1 19 package org.netbeans.modules.localhistory; 20 21 import java.io.File ; 22 import java.util.prefs.Preferences ; 23 import org.openide.ErrorManager; 24 import org.openide.util.NbPreferences; 25 26 34 public class LocalHistorySettings { 35 36 private static final LocalHistorySettings INSTANCE = new LocalHistorySettings(); 37 38 private static final String LAST_SELECTED_ENTRY = "RevertFileChanges.lastSelected"; 40 41 private LocalHistorySettings() { 42 } 43 44 public static LocalHistorySettings getInstance() { 45 return INSTANCE; 46 } 47 48 private Preferences getPreferences() { 49 return NbPreferences.forModule(LocalHistorySettings.class); 50 } 51 52 public static long getTTL() { 53 String ttl = System.getProperty("netbeans.localhistory.ttl"); 55 if( ttl != null && !ttl.trim().equals("") ) { 56 try { 57 return Long.parseLong(ttl) * 24 * 60 * 60 * 1000; } catch (Exception e) { 59 ErrorManager.getDefault().notify(ErrorManager.WARNING, e); 60 } 61 } 62 return 7 * 24 * 60 * 60 * 1000; 63 } 64 65 public static Long getMaxFileSize() { 66 String max = System.getProperty("netbeans.localhistory.maxFileSize"); 67 if( max != null && !max.trim().equals("") ) { 68 try { 69 return Long.parseLong(max); 70 } catch (Exception e) { 71 ErrorManager.getDefault().notify(ErrorManager.WARNING, e); 72 } 73 } 74 return 1024L * 1024L; 75 } 76 77 public static String getExludedFileNames() { 78 String excluded = System.getProperty("netbeans.localhistory.excludedFiles"); 79 if( excluded != null && !excluded.trim().equals("") ) { 80 return excluded; 81 } else { 82 return ".*(\\.class|\\.jar|\\.zip|\\.rar|\\.gz|\\.bz|\\.tgz|\\.tar|\\.gif|\\.jpg|\\.jpeg|\\.png|\\.nbm)"; } 84 } 85 86 public void setLastSelectedEntry(File file, long ts) { 87 getPreferences().putLong(LAST_SELECTED_ENTRY + "#" + file.getAbsoluteFile(), ts); 88 } 89 90 public long getLastSelectedEntry(File file) { 91 return getPreferences().getLong(LAST_SELECTED_ENTRY + "#" + file.getAbsoluteFile(), -1); 92 } 93 94 } 95 | Popular Tags |