KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > other > ModuleRefCustomizer


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  * ModuleRefCustomizer.java
21  *
22  * Created on September 4, 2003, 5:28 PM
23  */

24 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.other;
25
26 import java.beans.Customizer JavaDoc;
27 import java.beans.PropertyVetoException JavaDoc;
28 import java.text.MessageFormat JavaDoc;
29 import java.util.ResourceBundle JavaDoc;
30 import javax.swing.JPanel JavaDoc;
31
32 import org.netbeans.modules.j2ee.sun.share.configbean.BaseModuleRef;
33 import org.netbeans.modules.j2ee.sun.share.configbean.ErrorMessageDB;
34 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerErrorPanel;
35 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerTitlePanel;
36 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BaseCustomizer;
37
38
39 /**
40  *
41  * @author Peter Williams
42  */

43 public class ModuleRefCustomizer extends BaseCustomizer {
44     
45     /** Resource bundle */
46     private static final ResourceBundle JavaDoc bundle = ResourceBundle.getBundle(
47         "org.netbeans.modules.j2ee.sun.share.configbean.customizers.other.Bundle"); // NOI18N
48

49     private BaseModuleRef theBean;
50
51     /** Creates new form ModuleRefCustomizer */
52     public ModuleRefCustomizer() {
53         initComponents();
54         initUserComponents();
55     }
56
57     public BaseModuleRef getBean() {
58         return theBean;
59     }
60     
61     /** This method is called from within the constructor to
62      * initialize the form.
63      * WARNING: Do NOT modify this code. The content of this method is
64      * always regenerated by the Form Editor.
65      */

66     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
67
private void initComponents() {
68         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
69
70         jPnlGeneral = new javax.swing.JPanel JavaDoc();
71         jLblModuleUri = new javax.swing.JLabel JavaDoc();
72         jTxtModuleUri = new javax.swing.JTextField JavaDoc();
73         jPnlPlaceHolder = new javax.swing.JPanel JavaDoc();
74
75         setLayout(new java.awt.GridBagLayout JavaDoc());
76
77         jPnlGeneral.setLayout(new java.awt.GridBagLayout JavaDoc());
78
79         jLblModuleUri.setDisplayedMnemonic(bundle.getString("MNC_ModuleUri").charAt(0));
80         jLblModuleUri.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
81         jLblModuleUri.setLabelFor(jTxtModuleUri);
82         jLblModuleUri.setText(bundle.getString("LBL_ModuleURI_1"));
83         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
84         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
85         jPnlGeneral.add(jLblModuleUri, gridBagConstraints);
86         jLblModuleUri.getAccessibleContext().setAccessibleName(bundle.getString("ModuleURI_Acsbl_Name"));
87         jLblModuleUri.getAccessibleContext().setAccessibleDescription(bundle.getString("ModuleURI_Acsbl_Desc"));
88
89         jTxtModuleUri.setEditable(false);
90         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
91         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
92         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
93         gridBagConstraints.ipady = 2;
94         gridBagConstraints.weightx = 1.0;
95         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
96         jPnlGeneral.add(jTxtModuleUri, gridBagConstraints);
97         jTxtModuleUri.getAccessibleContext().setAccessibleName(bundle.getString("ModuleURI_Acsbl_Name"));
98         jTxtModuleUri.getAccessibleContext().setAccessibleDescription(bundle.getString("ModuleURI_Acsbl_Desc"));
99
100         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
101         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
102         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
103         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 5);
104         add(jPnlGeneral, gridBagConstraints);
105
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
108         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
109         gridBagConstraints.weightx = 1.0;
110         gridBagConstraints.weighty = 1.0;
111         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 5);
112         add(jPnlPlaceHolder, gridBagConstraints);
113
114     }// </editor-fold>//GEN-END:initComponents
115

116     // Variables declaration - do not modify//GEN-BEGIN:variables
117
private javax.swing.JLabel JavaDoc jLblModuleUri;
118     private javax.swing.JPanel JavaDoc jPnlGeneral;
119     private javax.swing.JPanel JavaDoc jPnlPlaceHolder;
120     private javax.swing.JTextField JavaDoc jTxtModuleUri;
121     // End of variables declaration//GEN-END:variables
122

123     private void initUserComponents() {
124         // Add title panel
125
addTitlePanel(bundle.getString("LBL_SunJ2eeModuleRef")); //NOI18N
126

127         
128         // Add error panel
129
addErrorPanel();
130     }
131     
132     /** Initialization of all the fields in the customizer from the bean that
133      * was passed in.
134      */

135     protected void initFields() {
136         // Set nice title based on the type of module this represents.
137
getTitlePanel().setCustomizerTitle(MessageFormat.format(
138                 bundle.getString("LBL_SunTFModuleRef"), new Object JavaDoc [] { theBean.getTitleFragment() }));
139         
140         jTxtModuleUri.setText(theBean.getModuleUri());
141
142         //jTxtIdentity.setText(theBean.getIdentity());
143
//jTxtRefIdentity.setText(theBean.getRefIdentity());
144
}
145
146     protected boolean setBean(Object JavaDoc bean) {
147         boolean result = super.setBean(bean);
148         
149         if(bean instanceof BaseModuleRef) {
150             theBean = (BaseModuleRef) bean;
151             result = true;
152         } else {
153             // if bean is not a BaseModuleRef, then it shouldn't have passed Base either.
154
assert (result == false) :
155                 "BaseModuleRefCustomizer was passed wrong bean type in setBean(Object bean)"; // NOI18N
156

157             theBean = null;
158             result = false;
159         }
160         
161         return result;
162     }
163     
164     public String JavaDoc getHelpId() {
165         return "AS_CFG_ModuleRef";
166     }
167 }
168
Popular Tags