1 19 20 package org.netbeans.modules.web.project.ui; 21 22 import java.io.File ; 23 import java.util.prefs.Preferences ; 24 25 import org.openide.util.NbBundle; 26 import org.openide.util.NbPreferences; 27 28 31 public class FoldersListSettings { 32 private static final FoldersListSettings INSTANCE = new FoldersListSettings(); 33 private static final String NEW_PROJECT_COUNT = "newProjectCount"; 35 private static final String NEW_APP_COUNT = "newApplicationCount"; 37 private static final String LAST_USED_CP_FOLDER = "lastUsedClassPathFolder"; 39 private static final String LAST_USED_ARTIFACT_FOLDER = "lastUsedArtifactFolder"; 41 private static final String SHOW_AGAIN_BROKEN_REF_ALERT = "showAgainBrokenRefAlert"; 43 private static final String SHOW_AGAIN_BROKEN_SERVER_ALERT = "showAgainBrokenServerAlert"; 45 static final String LAST_USED_CHOOSER_LOCATIONS = "lastUsedChooserLocations"; 47 private static final String AGREED_SET_JDK_14 = "agreeSetJdk14"; 49 private static final String AGREED_SET_SOURCE_LEVEL_14 = "agreeSetSourceLevel14"; 51 private static final String AGREED_SET_JDK_15 = "agreeSetJdk15"; 53 private static final String AGREED_SET_SOURCE_LEVEL_15 = "agreeSetSourceLevel15"; 55 private static final String LAST_USED_SERVER = "lastUsedServer"; 57 private static final String LAST_USED_IMPORT_LOCATION = "lastUsedImportLocation"; 59 public static FoldersListSettings getDefault () { 60 return INSTANCE; 61 } 62 63 static Preferences getPreferences() { 64 return NbPreferences.forModule(FoldersListSettings.class); 65 } 66 67 public String displayName() { 68 return NbBundle.getMessage(FoldersListSettings.class, "TXT_WebProjectFolderList"); 69 } 70 71 public int getNewProjectCount () { 72 return getPreferences().getInt(NEW_PROJECT_COUNT, 0); 73 } 74 75 public void setNewProjectCount (int count) { 76 getPreferences().putInt(NEW_PROJECT_COUNT, count); 77 } 78 79 public int getNewApplicationCount () { 80 return getPreferences().getInt(NEW_APP_COUNT, 0); 81 } 82 83 public void setNewApplicationCount (int count) { 84 getPreferences().putInt(NEW_APP_COUNT, count); 85 } 86 87 public File getLastUsedClassPathFolder () { 88 return new File (getPreferences().get(LAST_USED_CP_FOLDER, System.getProperty("user.home"))); 89 } 90 91 public void setLastUsedClassPathFolder (File folder) { 92 assert folder != null : "ClassPath root can not be null"; 93 String path = folder.getAbsolutePath(); 94 getPreferences().put(LAST_USED_CP_FOLDER, path); 95 } 96 97 public File getLastUsedArtifactFolder () { 98 return new File (getPreferences().get(LAST_USED_ARTIFACT_FOLDER, System.getProperty("user.home"))); 99 100 } 101 102 public void setLastUsedArtifactFolder (File folder) { 103 assert folder != null : "Folder can not be null"; 104 String path = folder.getAbsolutePath(); 105 getPreferences().put(LAST_USED_ARTIFACT_FOLDER, path); 106 } 107 108 public boolean isShowAgainBrokenRefAlert() { 109 return getPreferences().getBoolean(SHOW_AGAIN_BROKEN_REF_ALERT, true); 110 } 111 112 public void setShowAgainBrokenRefAlert(boolean again) { 113 getPreferences().putBoolean(SHOW_AGAIN_BROKEN_REF_ALERT, again); 114 } 115 116 public boolean isShowAgainBrokenServerAlert() { 117 return getPreferences().getBoolean(SHOW_AGAIN_BROKEN_SERVER_ALERT, true); 118 } 119 120 public void setShowAgainBrokenServerAlert(boolean again) { 121 getPreferences().putBoolean(SHOW_AGAIN_BROKEN_SERVER_ALERT, again); 122 } 123 124 public boolean isAgreedSetJdk14() { 125 return getPreferences().getBoolean(AGREED_SET_JDK_14, true); 126 } 127 128 public void setAgreedSetJdk14(boolean agreed) { 129 getPreferences().putBoolean(AGREED_SET_JDK_14, agreed); 130 } 131 132 public boolean isAgreedSetSourceLevel14() { 133 return getPreferences().getBoolean(AGREED_SET_SOURCE_LEVEL_14, true); 134 } 135 136 public void setAgreedSetSourceLevel14(boolean agreed) { 137 getPreferences().putBoolean(AGREED_SET_SOURCE_LEVEL_14, agreed); 138 } 139 140 public boolean isAgreedSetJdk15() { 141 return getPreferences().getBoolean(AGREED_SET_JDK_15, true); 142 } 143 144 public void setAgreedSetJdk15(boolean agreed) { 145 getPreferences().putBoolean(AGREED_SET_JDK_15, agreed); 146 } 147 148 public boolean isAgreedSetSourceLevel15() { 149 return getPreferences().getBoolean(AGREED_SET_SOURCE_LEVEL_15, true); 150 } 151 152 public void setAgreedSetSourceLevel15(boolean agreed) { 153 getPreferences().putBoolean(AGREED_SET_SOURCE_LEVEL_15, agreed); 154 } 155 156 public void setLastUsedServer(String serverID) { 157 getPreferences().put(LAST_USED_SERVER, serverID); 158 } 159 160 public String getLastUsedServer() { 161 return getPreferences().get(LAST_USED_SERVER, null); 162 } 163 164 public void setLastUsedImportLocation(File importLocation) { 165 String path = importLocation.getAbsolutePath(); 166 getPreferences().put(LAST_USED_IMPORT_LOCATION, path); 167 168 } 169 170 public File getLastUsedImportLocation() { 171 String path = getPreferences().get(LAST_USED_IMPORT_LOCATION, null); 172 if (path == null) 173 return null; 174 else 175 return new File (path); 176 } 177 } 178 | Popular Tags |