PageRenderTime 35ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/org/gjt/sp/jedit/search/AllBufferSet.java

#
Java | 102 lines | 45 code | 10 blank | 47 comment | 2 complexity | a83b0b701aa56f1c2b5de42c198136fc MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * AllBufferSet.java - All buffer matcher
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 1999, 2000, 2001 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit.search;
  23. //{{{ Imports
  24. import gnu.regexp.*;
  25. import java.awt.Component;
  26. import java.util.ArrayList;
  27. import org.gjt.sp.jedit.*;
  28. import org.gjt.sp.util.Log;
  29. //}}}
  30. /**
  31. * A file set for searching all open buffers.
  32. * @author Slava Pestov
  33. * @version $Id: AllBufferSet.java 4261 2002-06-18 02:44:52Z spestov $
  34. */
  35. public class AllBufferSet extends BufferListSet
  36. {
  37. //{{{ AllBufferSet constructor
  38. /**
  39. * Creates a new all buffer set.
  40. * @param glob The filename glob
  41. * @since jEdit 2.7pre3
  42. */
  43. public AllBufferSet(String glob)
  44. {
  45. this.glob = glob;
  46. } //}}}
  47. //{{{ getFileFilter() method
  48. /**
  49. * Returns the filename filter.
  50. * @since jEdit 2.7pre3
  51. */
  52. public String getFileFilter()
  53. {
  54. return glob;
  55. } //}}}
  56. //{{{ getCode() method
  57. /**
  58. * Returns the BeanShell code that will recreate this file set.
  59. * @since jEdit 2.7pre3
  60. */
  61. public String getCode()
  62. {
  63. return "new AllBufferSet(\"" + MiscUtilities.charsToEscapes(glob)
  64. + "\")";
  65. } //}}}
  66. //{{{ Instance variables
  67. private String glob;
  68. //}}}
  69. //{{{ _getFiles() method
  70. protected String[] _getFiles(Component comp)
  71. {
  72. Buffer[] buffers = jEdit.getBuffers();
  73. ArrayList returnValue = new ArrayList(buffers.length);
  74. RE filter;
  75. try
  76. {
  77. filter = new RE(MiscUtilities.globToRE(glob));
  78. }
  79. catch(Exception e)
  80. {
  81. Log.log(Log.ERROR,this,e);
  82. return null;
  83. }
  84. for(int i = 0; i < buffers.length; i++)
  85. {
  86. Buffer buffer = buffers[i];
  87. if(filter.isMatch(buffer.getName()))
  88. returnValue.add(buffer.getPath());
  89. }
  90. return (String[])returnValue.toArray(new String[returnValue.size()]);
  91. } //}}}
  92. }