1 19 package org.netbeans.modules.localhistory; 20 21 import java.io.File ; 22 import org.netbeans.modules.localhistory.store.LocalHistoryStore; 23 import org.netbeans.modules.localhistory.store.LocalHistoryStoreFactory; 24 import org.netbeans.modules.versioning.spi.VCSAnnotator; 25 import org.netbeans.modules.versioning.spi.VCSInterceptor; 26 import org.openide.cookies.EditCookie; 27 import org.openide.filesystems.FileObject; 28 import org.openide.filesystems.FileUtil; 29 import org.openide.loaders.DataObject; 30 import org.openide.loaders.DataObjectNotFoundException; 31 32 38 public class LocalHistory { 39 40 private static LocalHistory instance; 41 private VCSInterceptor vcsInterceptor; 42 private VCSAnnotator vcsAnnotator; 43 private LocalHistoryStore store; 44 45 private static String userDir; 46 47 public static synchronized LocalHistory getInstance() { 48 if(instance == null) { 49 instance = new LocalHistory(); 50 } 51 return instance; 52 } 53 54 VCSInterceptor getVCSInterceptor() { 55 if(vcsInterceptor == null) { 56 vcsInterceptor = new LocalHistoryVCSInterceptor(); 57 } 58 return vcsInterceptor; 59 } 60 61 VCSAnnotator getVCSAnnotator() { 62 if(vcsAnnotator == null) { 63 vcsAnnotator = new LocalHistoryVCSAnnotator(); 64 } 65 return vcsAnnotator; 66 } 67 68 public LocalHistoryStore getLocalHistoryStore() { 69 if(store == null) { 70 store = LocalHistoryStoreFactory.getInstance().createLocalHistoryStorage(); 71 } 72 return store; 73 } 74 75 private String getUserDir() { 76 if(userDir == null) { 77 userDir = System.getProperty("netbeans.user"); } 79 return userDir; 80 } 81 82 File isManagedByParent(File file) { 83 File parent = file.getParentFile(); 84 while(parent != null) { 85 86 if(parent.getAbsolutePath().equals(getUserDir())) { 87 return null; 89 } 90 91 file = parent; 92 parent = file.getParentFile(); 93 } 94 return file; 95 } 96 97 boolean isManaged(File file) { 98 if(file.isDirectory()) { 99 return true; } 101 if(Diagnostics.ON) { 102 Diagnostics.println(".isManaged() " + file); 103 } 104 return file.length() <= LocalHistorySettings.getMaxFileSize(); 105 } 106 107 } 108 | Popular Tags |