KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ui > customizer > NbPropertyPanel


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.apisupport.project.ui.customizer;
21
22 import java.beans.PropertyChangeEvent JavaDoc;
23 import java.beans.PropertyChangeListener JavaDoc;
24 import javax.swing.JPanel JavaDoc;
25 import org.netbeans.spi.project.ui.support.ProjectCustomizer;
26 import org.openide.util.HelpCtx;
27
28 /**
29  * Provides common support for a <em>standard</em> panels in the NetBeans module
30  * and suite customizers.
31  *
32  * @author Martin Krauskopf
33  */

34 abstract class NbPropertyPanel extends JPanel JavaDoc implements
35         ModuleProperties.LazyStorage, PropertyChangeListener JavaDoc, HelpCtx.Provider {
36
37     private Class JavaDoc helpCtxClass;
38
39     /** Property whether <code>this</code> panel is valid. */
40     static final String JavaDoc VALID_PROPERTY = "isPanelValid"; // NOI18N
41

42     /** Property for error message of this panel. */
43     static final String JavaDoc ERROR_MESSAGE_PROPERTY = "errorMessage"; // NOI18N
44

45     protected ModuleProperties props;
46     
47     /** Creates new NbPropertyPanel */
48     NbPropertyPanel(final ModuleProperties props, final Class JavaDoc helpCtxClass) {
49         this.props = props;
50         props.addLazyStorage(this);
51         initComponents();
52         props.addPropertyChangeListener(this);
53         this.helpCtxClass = helpCtxClass;
54     }
55     
56     /**
57      * This method is called whenever {@link ModuleProperties} are refreshed.
58      */

59     abstract void refresh();
60     
61     String JavaDoc getProperty(String JavaDoc key) {
62         return props.getProperty(key);
63     }
64     
65     void setProperty(String JavaDoc key, String JavaDoc property) {
66         props.setProperty(key, property);
67     }
68     
69     boolean getBooleanProperty(String JavaDoc key) {
70         return props.getBooleanProperty(key);
71     }
72     
73     void setBooleanProperty(String JavaDoc key, boolean property) {
74         props.setBooleanProperty(key, property);
75     }
76     
77     
78     /**
79      * Gives subclasses a chance to set a warning or an error message after a
80      * customizer is loaded/displayed. Just use this method for checking a
81      * validity of a panel's data and eventually call {@link
82      * #setWarning(String)} or {@link #setErrorMessage(String)}. Default
83      * implementation does nothing.
84      */

85     
86     //TODO remove!!
87
protected final void checkForm() {}
88
89     
90     public void store() { /* empty implementation */ }
91     
92     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
93         if (ModuleProperties.PROPERTIES_REFRESHED == evt.getPropertyName()) {
94             refresh();
95         }
96     }
97     
98     public void addNotify() {
99         super.addNotify();
100         //TODO replace with something else..
101
firePropertyChange(CustomizerProviderImpl.LAST_SELECTED_PANEL, null, this);
102     }
103     
104     public HelpCtx getHelpCtx() {
105         return new HelpCtx(helpCtxClass);
106     }
107     
108     /** This method is called from within the constructor to
109      * initialize the form.
110      * WARNING: Do NOT modify this code. The content of this method is
111      * always regenerated by the Form Editor.
112      */

113     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
114
private void initComponents() {
115
116         setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 0, 0));
117
118     }
119     // </editor-fold>//GEN-END:initComponents
120

121     // Variables declaration - do not modify//GEN-BEGIN:variables
122
// End of variables declaration//GEN-END:variables
123

124     abstract static class Single extends NbPropertyPanel {
125         Single(final SingleModuleProperties props, final Class JavaDoc helpCtxClass) {
126             super(props, helpCtxClass);
127         }
128         SingleModuleProperties getProperties() {
129             return (SingleModuleProperties) props;
130         }
131     }
132     
133     abstract static class Suite extends NbPropertyPanel {
134         Suite(final SuiteProperties props, final Class JavaDoc helpCtxClass) {
135             super(props, helpCtxClass);
136         }
137         SuiteProperties getProperties() {
138             return (SuiteProperties) props;
139         }
140     }
141     
142 }
143
Popular Tags