KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > webservice > ServiceRefCustomizer


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

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webservice;
26
27 import java.util.ResourceBundle JavaDoc;
28
29 import java.beans.Customizer JavaDoc;
30 import java.beans.PropertyVetoException JavaDoc;
31
32 import javax.swing.JPanel JavaDoc;
33 import javax.swing.text.BadLocationException JavaDoc;
34 import javax.swing.text.Document JavaDoc;
35 import javax.swing.event.DocumentEvent JavaDoc;
36 import javax.swing.event.DocumentListener JavaDoc;
37
38 import org.netbeans.modules.j2ee.sun.share.configbean.ServiceRef;
39 import org.netbeans.modules.j2ee.sun.share.configbean.ErrorMessageDB;
40 import org.netbeans.modules.j2ee.sun.share.configbean.ValidationError;
41 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerErrorPanel;
42 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerTitlePanel;
43 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BaseCustomizer;
44
45
46 /**
47  *
48  * @author Peter Williams
49  */

50 public class ServiceRefCustomizer extends BaseCustomizer {
51
52     static final ResourceBundle JavaDoc bundle = ResourceBundle.getBundle(
53             "org.netbeans.modules.j2ee.sun.share.configbean.customizers.webservice.Bundle"); // NOI18N
54

55     /** The bean currently being customized, or null if there isn't one
56      */

57     private ServiceRef theBean;
58
59     /** The two tabbed panels */
60     private ServiceRefGeneralPanel generalPanel;
61     private ServiceRefPortInfoPanel portInfoPanel;
62
63     /** Creates new form ServiceRefCustomizer */
64     public ServiceRefCustomizer() {
65         initComponents();
66         initUserComponents();
67     }
68
69     public ServiceRef getBean() {
70         return theBean;
71     }
72
73     /** This method is called from within the constructor to
74      * initialize the form.
75      * WARNING: Do NOT modify this code. The content of this method is
76      * always regenerated by the Form Editor.
77      */

78     private void initComponents() {//GEN-BEGIN:initComponents
79
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
80
81         serviceRefTabbedPanel = new javax.swing.JTabbedPane JavaDoc();
82
83         setLayout(new java.awt.GridBagLayout JavaDoc());
84
85         serviceRefTabbedPanel.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
86         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
87         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
88         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
89         gridBagConstraints.weightx = 1.0;
90         gridBagConstraints.weighty = 1.0;
91         add(serviceRefTabbedPanel, gridBagConstraints);
92
93     }//GEN-END:initComponents
94

95     // Variables declaration - do not modify//GEN-BEGIN:variables
96
private javax.swing.JTabbedPane JavaDoc serviceRefTabbedPanel;
97     // End of variables declaration//GEN-END:variables
98

99     private void initUserComponents() {
100         // Add title panel
101
addTitlePanel(bundle.getString("TITLE_ServiceRef"));
102         getAccessibleContext().setAccessibleName(bundle.getString("ACSN_ServiceRef")); // NOI18N
103
getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_ServiceRef")); // NOI18N
104

105         // add general panel
106
generalPanel = new ServiceRefGeneralPanel(this);
107         serviceRefTabbedPanel.addTab(bundle.getString("TAB_General"), generalPanel); // NOI18N
108

109         // add port info panel
110
portInfoPanel = new ServiceRefPortInfoPanel(this);
111         serviceRefTabbedPanel.addTab(bundle.getString("TAB_PortInfo"), portInfoPanel); // NOI18N
112

113         // Add error panel
114
addErrorPanel();
115     }
116
117     protected void initFields() {
118         generalPanel.initFields(theBean);
119         portInfoPanel.initFields(theBean);
120     }
121
122     public void partitionStateChanged(ErrorMessageDB.PartitionState oldState, ErrorMessageDB.PartitionState newState) {
123         if(newState.getPartition() == getPartition()) {
124             showErrors();
125         }
126
127         if(oldState.hasMessages() != newState.hasMessages()) {
128             serviceRefTabbedPanel.setIconAt(newState.getPartition().getTabIndex(), newState.hasMessages() ? panelErrorIcon : null);
129         }
130     }
131
132     protected void addListeners() {
133         super.addListeners();
134         generalPanel.addListeners(theBean);
135         portInfoPanel.addListeners(theBean);
136     }
137     
138     protected void removeListeners() {
139         super.removeListeners();
140         generalPanel.removeListeners(theBean);
141         portInfoPanel.removeListeners(theBean);
142     }
143     
144     protected boolean setBean(Object JavaDoc bean) {
145         boolean result = super.setBean(bean);
146
147         if(bean instanceof ServiceRef) {
148             theBean = (ServiceRef) bean;
149             result = true;
150         } else {
151             // if bean is not a ServiceRef, then it shouldn't have passed Base either.
152
assert (result == false) :
153                 "ServiceRefCustomizer was passed wrong bean type in setBean(Object bean)"; // NOI18N
154

155             theBean = null;
156             result = false;
157         }
158
159         return result;
160     }
161
162     public String JavaDoc getHelpId() {
163         String JavaDoc result = "AS_CFG_ServiceRefGeneral"; // NOI18N
164

165         // Determine which tab has focus and return help context for that tab.
166
switch(serviceRefTabbedPanel.getSelectedIndex()) {
167             case 1:
168                 result = "AS_CFG_ServiceRefPortInfo"; // NOI18N
169
break;
170         }
171
172         return result;
173     }
174
175     /** Retrieve the partition that should be associated with the current
176      * selected tab.
177      *
178      * @return ValidationError.Partition
179      */

180     public ValidationError.Partition getPartition() {
181         switch(serviceRefTabbedPanel.getSelectedIndex()) {
182             case 1:
183                 return ValidationError.PARTITION_SERVICEREF_PORTINFO;
184             default:
185                 return ValidationError.PARTITION_SERVICEREF_GENERAL;
186         }
187     }
188 }
189
Popular Tags