1 22 23 package org.gjt.sp.jedit; 24 25 import java.io.File ; 27 import org.gjt.sp.jedit.io.VFS; 28 import org.gjt.sp.jedit.io.VFSManager; 29 import org.gjt.sp.jedit.msg.VFSUpdate; 30 import org.gjt.sp.jedit.search.*; 31 33 class SettingsReloader implements EBComponent 34 { 35 public void handleMessage(EBMessage msg) 37 { 38 if(msg instanceof VFSUpdate) 39 { 40 VFSUpdate vmsg = (VFSUpdate)msg; 41 maybeReload(vmsg.getPath()); 42 } 43 } 45 private void maybeReload(String path) 47 { 48 String jEditHome = jEdit.getJEditHome(); 49 String settingsDirectory = jEdit.getSettingsDirectory(); 50 51 if(!MiscUtilities.isURL(path)) 52 path = MiscUtilities.resolveSymlinks(path); 53 54 if((VFSManager.getVFSForPath(path).getCapabilities() 56 & VFS.CASE_INSENSITIVE_CAP) != 0) 57 { 58 path = path.toLowerCase(); 59 jEditHome = jEditHome.toLowerCase(); 60 settingsDirectory = settingsDirectory.toLowerCase(); 61 } 62 63 SearchFileSet fileset = SearchAndReplace.getSearchFileSet(); 65 if(fileset instanceof DirectoryListSet) 66 { 67 DirectoryListSet dirset = (DirectoryListSet)fileset; 68 String dir = MiscUtilities.resolveSymlinks( 69 dirset.getDirectory()); 70 if(path.startsWith(dir)) 71 dirset.invalidateCachedList(); 72 } 73 74 if(jEditHome != null && path.startsWith(jEditHome)) 75 path = path.substring(jEditHome.length()); 76 else if(settingsDirectory != null && path.startsWith(settingsDirectory)) 77 path = path.substring(settingsDirectory.length()); 78 else 79 { 80 return; 83 } 84 85 if(path.startsWith(File.separator) || path.startsWith("/")) 86 path = path.substring(1); 87 88 if(path.startsWith("macros")) 89 Macros.loadMacros(); 90 else if(path.startsWith("modes") && (path.endsWith(".xml") 91 || path.endsWith("catalog"))) 92 jEdit.reloadModes(); 93 } } 95 | Popular Tags |