KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > project > ui > FoldersListSettings


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.project.ui;
21
22 import java.io.File JavaDoc;
23 import java.util.prefs.Preferences JavaDoc;
24
25 import org.openide.util.NbBundle;
26 import org.openide.util.NbPreferences;
27
28 /**
29  * Misnamed storage of information application to the new webproject wizard.
30  */

31 public class FoldersListSettings {
32     private static final FoldersListSettings INSTANCE = new FoldersListSettings();
33     private static final String JavaDoc NEW_PROJECT_COUNT = "newProjectCount"; //NOI18N
34

35     private static final String JavaDoc NEW_APP_COUNT = "newApplicationCount"; //NOI18N
36

37     private static final String JavaDoc LAST_USED_CP_FOLDER = "lastUsedClassPathFolder"; //NOI18N
38

39     private static final String JavaDoc LAST_USED_ARTIFACT_FOLDER = "lastUsedArtifactFolder"; //NOI18N
40

41     private static final String JavaDoc SHOW_AGAIN_BROKEN_REF_ALERT = "showAgainBrokenRefAlert"; //NOI18N
42

43     private static final String JavaDoc SHOW_AGAIN_BROKEN_SERVER_ALERT = "showAgainBrokenServerAlert"; //NOI18N
44

45     static final String JavaDoc LAST_USED_CHOOSER_LOCATIONS = "lastUsedChooserLocations"; //NOI18N
46

47     private static final String JavaDoc AGREED_SET_JDK_14 = "agreeSetJdk14"; // NOI18N
48

49     private static final String JavaDoc AGREED_SET_SOURCE_LEVEL_14 = "agreeSetSourceLevel14"; // NOI18N
50

51     private static final String JavaDoc AGREED_SET_JDK_15 = "agreeSetJdk15"; // NOI18N
52

53     private static final String JavaDoc AGREED_SET_SOURCE_LEVEL_15 = "agreeSetSourceLevel15"; // NOI18N
54

55     private static final String JavaDoc LAST_USED_SERVER = "lastUsedServer"; // NOI18N
56

57     private static final String JavaDoc LAST_USED_IMPORT_LOCATION = "lastUsedImportLocation"; // NOI18N
58

59     public static FoldersListSettings getDefault () {
60         return INSTANCE;
61     }
62     
63     static Preferences JavaDoc getPreferences() {
64         return NbPreferences.forModule(FoldersListSettings.class);
65     }
66     
67     public String JavaDoc 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 JavaDoc getLastUsedClassPathFolder () {
88         return new File JavaDoc(getPreferences().get(LAST_USED_CP_FOLDER, System.getProperty("user.home")));
89     }
90
91     public void setLastUsedClassPathFolder (File JavaDoc folder) {
92         assert folder != null : "ClassPath root can not be null";
93         String JavaDoc path = folder.getAbsolutePath();
94         getPreferences().put(LAST_USED_CP_FOLDER, path);
95     }
96
97     public File JavaDoc getLastUsedArtifactFolder () {
98         return new File JavaDoc(getPreferences().get(LAST_USED_ARTIFACT_FOLDER, System.getProperty("user.home")));
99         
100     }
101
102     public void setLastUsedArtifactFolder (File JavaDoc folder) {
103         assert folder != null : "Folder can not be null";
104         String JavaDoc 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 JavaDoc serverID) {
157         getPreferences().put(LAST_USED_SERVER, serverID);
158     }
159
160     public String JavaDoc getLastUsedServer() {
161         return getPreferences().get(LAST_USED_SERVER, null);
162     }
163     
164     public void setLastUsedImportLocation(File JavaDoc importLocation) {
165         String JavaDoc path = importLocation.getAbsolutePath();
166         getPreferences().put(LAST_USED_IMPORT_LOCATION, path);
167         
168     }
169
170     public File JavaDoc getLastUsedImportLocation() {
171         String JavaDoc path = getPreferences().get(LAST_USED_IMPORT_LOCATION, null);
172         if (path == null)
173             return null;
174         else
175             return new File JavaDoc(path);
176     }
177 }
178
Popular Tags