KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > project > JavaProjectSettings


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.java.project;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24 import java.util.prefs.Preferences JavaDoc;
25 import org.openide.util.NbPreferences;
26
27 /**
28  * Preferences for the module.
29  * @author Tomas Zezula, Jesse Glick
30  */

31 public class JavaProjectSettings {
32
33     private JavaProjectSettings() {}
34
35     private static final PropertyChangeSupport JavaDoc pcs = new PropertyChangeSupport JavaDoc(JavaProjectSettings.class);
36
37     /**
38      * The package view should be displayed as a list of packages.
39      */

40     public static final int TYPE_PACKAGE_VIEW = 0;
41
42     /**
43      * The package view should be displayed as a tree of folders.
44      */

45     public static final int TYPE_TREE = 1;
46
47     public static final String JavaDoc PROP_PACKAGE_VIEW_TYPE = "packageViewType"; //NOI18N
48
private static final String JavaDoc PROP_SHOW_AGAIN_BROKEN_REF_ALERT = "showAgainBrokenRefAlert"; //NOI18N
49

50     private static Preferences JavaDoc prefs() {
51         return NbPreferences.forModule(JavaProjectSettings.class);
52     }
53
54     /**
55      * Returns how the package view should be displayed.
56      * @return {@link #TYPE_PACKAGE_VIEW} or {@link #TYPE_TREE}
57      */

58     public static int getPackageViewType() {
59         return prefs().getInt(PROP_PACKAGE_VIEW_TYPE, TYPE_PACKAGE_VIEW);
60     }
61
62     /**
63      * Sets how the package view should be displayed.
64      * @param type either {@link #TYPE_PACKAGE_VIEW} or {@link #TYPE_TREE}
65      */

66     public static void setPackageViewType(int type) {
67         int currentType = getPackageViewType();
68         if (currentType != type) {
69             prefs().putInt(PROP_PACKAGE_VIEW_TYPE, type);
70             pcs.firePropertyChange(PROP_PACKAGE_VIEW_TYPE, currentType, type);
71         }
72     }
73
74     public static boolean isShowAgainBrokenRefAlert() {
75         return prefs().getBoolean(PROP_SHOW_AGAIN_BROKEN_REF_ALERT, true);
76     }
77
78     public static void setShowAgainBrokenRefAlert(boolean again) {
79         prefs().putBoolean(PROP_SHOW_AGAIN_BROKEN_REF_ALERT, again);
80     }
81
82     public static void addPropertyChangeListener(PropertyChangeListener JavaDoc l) {
83         pcs.addPropertyChangeListener(l);
84     }
85
86     public static void removePropertyChangeListener(PropertyChangeListener JavaDoc l) {
87         pcs.removePropertyChangeListener(l);
88     }
89
90 }
91
Popular Tags