PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Java | 128 lines | 79 code | 13 blank | 36 comment | 3 complexity | a956190348629bd081601c5cad1291a2 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. * DirectoryListSet.java - Directory list 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.RE;
  25. import javax.swing.SwingUtilities;
  26. import java.awt.Component;
  27. import java.io.*;
  28. import java.util.Vector;
  29. import org.gjt.sp.jedit.io.*;
  30. import org.gjt.sp.jedit.*;
  31. import org.gjt.sp.util.Log;
  32. //}}}
  33. /**
  34. * Recursive directory search.
  35. * @author Slava Pestov
  36. * @version $Id: DirectoryListSet.java 4261 2002-06-18 02:44:52Z spestov $
  37. */
  38. public class DirectoryListSet extends BufferListSet
  39. {
  40. //{{{ DirectoryListSet constructor
  41. public DirectoryListSet(String directory, String glob, boolean recurse)
  42. {
  43. this.directory = directory;
  44. this.glob = glob;
  45. this.recurse = recurse;
  46. } //}}}
  47. //{{{ getDirectory() method
  48. public String getDirectory()
  49. {
  50. return directory;
  51. } //}}}
  52. //{{{ getFileFilter() method
  53. public String getFileFilter()
  54. {
  55. return glob;
  56. } //}}}
  57. //{{{ isRecursive() method
  58. public boolean isRecursive()
  59. {
  60. return recurse;
  61. } //}}}
  62. //{{{ getCode() method
  63. public String getCode()
  64. {
  65. return "new DirectoryListSet(\"" + MiscUtilities.charsToEscapes(directory)
  66. + "\",\"" + MiscUtilities.charsToEscapes(glob) + "\","
  67. + recurse + ")";
  68. } //}}}
  69. //{{{ _getFiles() method
  70. protected String[] _getFiles(final Component comp)
  71. {
  72. final VFS vfs = VFSManager.getVFSForPath(directory);
  73. Object session;
  74. if(SwingUtilities.isEventDispatchThread())
  75. {
  76. session = vfs.createVFSSession(directory,comp);
  77. }
  78. else
  79. {
  80. final Object[] returnValue = new Object[1];
  81. try
  82. {
  83. SwingUtilities.invokeAndWait(new Runnable()
  84. {
  85. public void run()
  86. {
  87. returnValue[0] = vfs.createVFSSession(directory,comp);
  88. }
  89. });
  90. }
  91. catch(Exception e)
  92. {
  93. Log.log(Log.ERROR,this,e);
  94. }
  95. session = returnValue[0];
  96. }
  97. if(session == null)
  98. return null;
  99. try
  100. {
  101. return vfs._listDirectory(session,directory,glob,recurse,comp);
  102. }
  103. catch(IOException io)
  104. {
  105. VFSManager.error(comp,directory,"ioerror",new String[]
  106. { io.toString() });
  107. return null;
  108. }
  109. } //}}}
  110. //{{{ Private members
  111. private String directory;
  112. private String glob;
  113. private boolean recurse;
  114. //}}}
  115. }