1 22 23 package org.gjt.sp.jedit.search; 24 25 import java.awt.Component ; 27 import java.util.ArrayList ; 28 import java.util.regex.Pattern ; 29 import org.gjt.sp.jedit.*; 30 import org.gjt.sp.util.Log; 31 import org.gjt.sp.util.StandardUtilities; 32 34 39 public class AllBufferSet extends BufferListSet 40 { 41 47 public AllBufferSet(String glob) 48 { 49 this.glob = glob; 50 } 52 57 public String getFileFilter() 58 { 59 return glob; 60 } 62 67 public String getCode() 68 { 69 return "new AllBufferSet(\"" + MiscUtilities.charsToEscapes(glob) 70 + "\")"; 71 } 73 private String glob; 75 77 protected String [] _getFiles(Component comp) 79 { 80 Buffer[] buffers = jEdit.getBuffers(); 81 ArrayList returnValue = new ArrayList (buffers.length); 82 83 Pattern filter; 84 try 85 { 86 filter = Pattern.compile(StandardUtilities.globToRE(glob)); 87 } 88 catch(Exception e) 89 { 90 Log.log(Log.ERROR,this,e); 91 return null; 92 } 93 94 for(int i = 0; i < buffers.length; i++) 95 { 96 Buffer buffer = buffers[i]; 97 if(filter.matcher(buffer.getName()).matches()) 98 returnValue.add(buffer.getPath()); 99 } 100 101 return (String [])returnValue.toArray(new String [returnValue.size()]); 102 } } 104 | Popular Tags |