01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * 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-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.modules.sql.project.base;
21:
22: import org.openide.util.NbBundle;
23: import org.openide.util.NbPreferences;
24:
25: /**
26: * Settings for the PackageView presentation.
27: * According to the value of {@link PackageViewSettings#getPackageViewType}
28: * the package view is displayed.
29: * Currently there are two modes, the package structure and tree structure.
30: * @author Tomas Zezula
31: */
32: public final class PackageViewSettings {
33:
34: /**
35: * The package view should be diplayed as a list of packages
36: */
37: public static final int TYPE_PACKAGE_VIEW = 0;
38:
39: /**
40: * The package view should be diplayed as a tree of folders
41: */
42: public static final int TYPE_TREE = 1;
43:
44: public static final String PROP_PACKAGE_VIEW_TYPE = "packageViewType"; //NOI18N
45:
46: private static PackageViewSettings INSTANCE = new PackageViewSettings();
47:
48: private PackageViewSettings() {
49: }
50:
51: public String displayName() {
52: return PackageViewSettings.class.getName(); // irrelevant
53: }
54:
55: /**
56: * Returns how the package view should be displayed.
57: * @return {@link PackageViewSettings#TYPE_PACKAGE_VIEW} or
58: * {@link PackageViewSettings#TYPE_TREE}
59: *
60: */
61: public int getPackageViewType() {
62: return NbPreferences.forModule(PackageViewSettings.class)
63: .getInt(PROP_PACKAGE_VIEW_TYPE, 0);
64: }
65:
66: /**
67: * Sets how the package view should be displayed.
68: * @param type either {@link PackageViewSettings#TYPE_PACKAGE_VIEW} or
69: * {@link PackageViewSettings#TYPE_TREE}
70: *
71: */
72: public void setPackageViewType(int type) {
73: NbPreferences.forModule(PackageViewSettings.class).putInt(
74: PROP_PACKAGE_VIEW_TYPE, type);
75: }
76:
77: /**
78: * Returns an instance of the PackageViewSettings
79: * @return PackageViewSettings
80: */
81: public static PackageViewSettings getDefault() {
82: return INSTANCE;
83: }
84:
85: }
|