1 22 23 package org.gjt.sp.jedit.search; 24 25 import javax.swing.SwingUtilities ; 27 import java.awt.Component ; 28 import java.io.*; 29 import org.gjt.sp.jedit.io.*; 30 import org.gjt.sp.jedit.*; 31 import org.gjt.sp.util.Log; 32 34 39 public class DirectoryListSet extends BufferListSet 40 { 41 public DirectoryListSet(String directory, String glob, boolean recurse) 43 { 44 this.directory = directory; 45 this.glob = glob; 46 this.recurse = recurse; 47 this.skipBinary = jEdit.getBooleanProperty("search.skipBinary.toggle"); 48 this.skipHidden = jEdit.getBooleanProperty("search.skipHidden.toggle"); 49 } 51 52 53 public String getDirectory() 55 { 56 return directory; 57 } 59 63 public void setDirectory(String directory) 64 { 65 this.directory = directory; 66 invalidateCachedList(); 67 } 69 public String getFileFilter() 71 { 72 return glob; 73 } 75 79 public void setFileFilter(String glob) 80 { 81 this.glob = glob; 82 invalidateCachedList(); 83 } 85 public boolean isRecursive() 87 { 88 return recurse; 89 } 91 95 public void setRecursive(boolean recurse) 96 { 97 this.recurse = recurse; 98 invalidateCachedList(); 99 } 101 public String getCode() 103 { 104 return "new DirectoryListSet(\"" + MiscUtilities.charsToEscapes(directory) 105 + "\",\"" + MiscUtilities.charsToEscapes(glob) + "\"," 106 + recurse + ")"; 107 } 109 protected String [] _getFiles(final Component comp) 111 { 112 this.skipBinary = jEdit.getBooleanProperty("search.skipBinary.toggle"); 113 this.skipHidden = jEdit.getBooleanProperty("search.skipHidden.toggle"); 114 final VFS vfs = VFSManager.getVFSForPath(directory); 115 Object session; 116 if(SwingUtilities.isEventDispatchThread()) 117 { 118 session = vfs.createVFSSession(directory,comp); 119 } 120 else 121 { 122 final Object [] returnValue = new Object [1]; 123 124 try 125 { 126 SwingUtilities.invokeAndWait(new Runnable () 127 { 128 public void run() 129 { 130 returnValue[0] = vfs.createVFSSession(directory,comp); 131 } 132 }); 133 } 134 catch(Exception e) 135 { 136 Log.log(Log.ERROR,this,e); 137 } 138 139 session = returnValue[0]; 140 } 141 142 if(session == null) 143 return null; 144 145 try 146 { 147 return vfs._listDirectory(session,directory,glob,recurse,comp, skipBinary, skipHidden); 148 } 149 catch(IOException io) 150 { 151 VFSManager.error(comp,directory,"ioerror",new String [] 152 { io.toString() }); 153 return null; 154 } 155 } 157 private String directory; 159 private String glob; 160 private boolean recurse; 161 private boolean skipHidden; 162 private boolean skipBinary; 163 } 165 | Popular Tags |