1 22 23 package org.gjt.sp.jedit.search; 24 25 import java.awt.Component ; 27 import org.gjt.sp.jedit.*; 28 import org.gjt.sp.jedit.io.*; 29 import org.gjt.sp.util.StandardUtilities; 30 32 37 public abstract class BufferListSet implements SearchFileSet 38 { 39 public synchronized String getFirstFile(View view) 41 { 42 if(files == null) 43 files = _getFiles(view); 44 45 if(files == null || files.length == 0) 46 return null; 47 else 48 return files[0]; 49 } 51 public synchronized String getNextFile(View view, String path) 53 { 54 if(files == null) 55 files = _getFiles(view); 56 57 if(files == null || files.length == 0) 58 return null; 59 60 if(path == null) 61 { 62 path = view.getBuffer().getSymlinkPath(); 63 VFS vfs = VFSManager.getVFSForPath(path); 64 boolean ignoreCase = ((vfs.getCapabilities() 65 & VFS.CASE_INSENSITIVE_CAP) != 0); 66 67 for(int i = 0; i < files.length; i++) 68 { 69 if(StandardUtilities.compareStrings( 70 files[i],path,ignoreCase) == 0) 71 { 72 return path; 73 } 74 } 75 76 return getFirstFile(view); 77 } 78 else 79 { 80 VFS vfs = VFSManager.getVFSForPath(path); 82 boolean ignoreCase = ((vfs.getCapabilities() 83 & VFS.CASE_INSENSITIVE_CAP) != 0); 84 85 for(int i = 0; i < files.length - 1; i++) 86 { 87 if(StandardUtilities.compareStrings( 88 files[i],path,ignoreCase) == 0) 89 { 90 return files[i+1]; 91 } 92 } 93 94 return null; 95 } 96 } 98 public synchronized String [] getFiles(View view) 100 { 101 if(files == null) 102 files = _getFiles(view); 103 104 if(files == null || files.length == 0) 105 return null; 106 else 107 return files; 108 } 110 public synchronized int getFileCount(View view) 112 { 113 if(files == null) 114 files = _getFiles(view); 115 116 if(files == null) 117 return 0; 118 else 119 return files.length; 120 } 122 public String getCode() 124 { 125 return null; 127 } 129 public void invalidateCachedList() 131 { 132 files = null; 133 } 135 139 protected abstract String [] _getFiles(Component comp); 140 141 private String [] files; 142 } 143 | Popular Tags |