KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > BindingConfigurationPanel


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * BindingAndServiceConfigurationPanel.java
22  *
23  * Created on August 25, 2006, 2:51 PM
24  */

25
26 package org.netbeans.modules.xml.wsdl.ui.view;
27
28 import java.awt.event.ActionEvent JavaDoc;
29 import java.awt.event.ActionListener JavaDoc;
30 import java.util.Collection JavaDoc;
31 import java.util.SortedSet JavaDoc;
32 import java.util.TreeSet JavaDoc;
33 import java.util.Vector JavaDoc;
34 import javax.swing.ComboBoxModel JavaDoc;
35
36 import javax.swing.DefaultComboBoxModel JavaDoc;
37 import javax.swing.JTextField JavaDoc;
38 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPQName;
39
40 import org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensibilityElementTemplateFactory;
41 import org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateGroup;
42 import org.netbeans.modules.xml.wsdl.ui.view.wizard.localized.LocalizedTemplate;
43 import org.netbeans.modules.xml.wsdl.ui.view.wizard.localized.LocalizedTemplateGroup;
44
45 /**
46  *
47  * @author radval
48  */

49 public class BindingConfigurationPanel extends javax.swing.JPanel JavaDoc {
50     
51     public static final String JavaDoc PROP_BINDING_TYPE = "PROP_BINDING_TYPE";
52     public static final String JavaDoc PROP_BINDING_SUBTYPE = "PROP_BINDING_SUBTYPE";
53             
54     private ExtensibilityElementTemplateFactory factory;
55     private Vector JavaDoc<LocalizedTemplateGroup> protocols = new Vector JavaDoc<LocalizedTemplateGroup>();
56     private LocalizedTemplateGroup defaultSelection; //Select SOAP as default
57

58     /** Creates new form BindingAndServiceConfigurationPanel */
59     public BindingConfigurationPanel() {
60         factory = new ExtensibilityElementTemplateFactory();
61         Collection JavaDoc<TemplateGroup> groups = factory.getExtensibilityElementTemplateGroups();
62         protocols = new Vector JavaDoc<LocalizedTemplateGroup>();
63         
64         SortedSet JavaDoc<LocalizedTemplateGroup> set = new TreeSet JavaDoc<LocalizedTemplateGroup>();
65         for (TemplateGroup group : groups) {
66             LocalizedTemplateGroup ltg = factory.getLocalizedTemplateGroup(group);
67             if (ltg.getNamespace().equals(SOAPQName.SOAP_NS_URI)) {
68                 defaultSelection = ltg;
69             }
70             set.add(ltg);
71         }
72         
73         protocols.addAll(set);
74         
75         initComponents();
76         initGUI();
77     }
78     
79     /** This method is called from within the constructor to
80      * initialize the form.
81      * WARNING: Do NOT modify this code. The content of this method is
82      * always regenerated by the Form Editor.
83      */

84     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
85
private void initComponents() {
86         jLabel1 = new javax.swing.JLabel JavaDoc();
87         bindingNameTextField = new javax.swing.JTextField JavaDoc();
88         jLabel2 = new javax.swing.JLabel JavaDoc();
89         bindingTypeComboBox = new javax.swing.JComboBox JavaDoc();
90         jLabel3 = new javax.swing.JLabel JavaDoc();
91         jPanel1 = new javax.swing.JPanel JavaDoc();
92         jLabel4 = new javax.swing.JLabel JavaDoc();
93         serviceNameTextField = new javax.swing.JTextField JavaDoc();
94         jLabel5 = new javax.swing.JLabel JavaDoc();
95         servicePortTextField = new javax.swing.JTextField JavaDoc();
96
97         jLabel1.setLabelFor(bindingNameTextField);
98         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(BindingConfigurationPanel.class, "BindingConfigurationPanel.jLabel1.text"));
99
100         jLabel2.setLabelFor(bindingTypeComboBox);
101         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(BindingConfigurationPanel.class, "BindingConfigurationPanel.jLabel2.text"));
102
103         DefaultComboBoxModel JavaDoc model = new DefaultComboBoxModel JavaDoc(protocols);
104         model.setSelectedItem(defaultSelection);
105         bindingTypeComboBox.setModel(model);
106         bindingTypeComboBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
107             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
108                 bindingTypeComboBoxActionPerformed(evt);
109             }
110         });
111
112         jLabel3.setLabelFor(jPanel1);
113         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(BindingConfigurationPanel.class, "BindingConfigurationPanel.jLabel3.text"));
114
115         jPanel1.setLayout(new javax.swing.BoxLayout JavaDoc(jPanel1, javax.swing.BoxLayout.X_AXIS));
116
117         jLabel4.setLabelFor(serviceNameTextField);
118         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(BindingConfigurationPanel.class, "BindingConfigurationPanel.jLabel4.text"));
119
120         jLabel5.setLabelFor(servicePortTextField);
121         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(BindingConfigurationPanel.class, "BindingConfigurationPanel.jLabel5.text"));
122
123         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
124         this.setLayout(layout);
125         layout.setHorizontalGroup(
126             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
127             .add(layout.createSequentialGroup()
128                 .addContainerGap()
129                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
130                     .add(jLabel1)
131                     .add(jLabel2)
132                     .add(jLabel3)
133                     .add(jLabel4)
134                     .add(jLabel5))
135                 .add(18, 18, 18)
136                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
137                     .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
138                     .add(org.jdesktop.layout.GroupLayout.TRAILING, bindingTypeComboBox, 0, 274, Short.MAX_VALUE)
139                     .add(org.jdesktop.layout.GroupLayout.TRAILING, bindingNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
140                     .add(serviceNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
141                     .add(servicePortTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE))
142                 .addContainerGap())
143         );
144         layout.setVerticalGroup(
145             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
146             .add(layout.createSequentialGroup()
147                 .addContainerGap()
148                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
149                     .add(jLabel1)
150                     .add(bindingNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
151                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
152                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
153                     .add(jLabel2)
154                     .add(bindingTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
155                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
156                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
157                     .add(jLabel3)
158                     .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE))
159                 .add(8, 8, 8)
160                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
161                     .add(jLabel4)
162                     .add(serviceNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
163                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
164                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
165                     .add(jLabel5)
166                     .add(servicePortTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
167                 .add(106, 106, 106))
168         );
169     }// </editor-fold>//GEN-END:initComponents
170

171     private void bindingTypeComboBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_bindingTypeComboBoxActionPerformed
172
setBindingSubType(getBindingType());
173         this.firePropertyChange(PROP_BINDING_TYPE, null, getBindingType());
174     }//GEN-LAST:event_bindingTypeComboBoxActionPerformed
175

176     public String JavaDoc getBindingName() {
177         return this.bindingNameTextField.getText();
178     }
179     
180     public void setBindingName(String JavaDoc bindingName) {
181         this.bindingNameTextField.setText(bindingName);
182     }
183     
184     public LocalizedTemplateGroup getBindingType() {
185         return (LocalizedTemplateGroup) bindingTypeComboBox.getSelectedItem();
186     }
187     
188     public void setBindingType(String JavaDoc bindingSubType) {
189         this.bindingTypeComboBox.setSelectedItem(bindingSubType);
190     }
191     
192     public LocalizedTemplate getBindingSubType() {
193         return subTypePanel.getBindingSubType();
194     }
195     
196     private void setBindingSubType(LocalizedTemplateGroup bindingType) {
197         subTypePanel.reset(bindingType);
198     }
199     
200     public String JavaDoc getServiceName() {
201         return serviceNameTextField.getText();
202     }
203     
204     public void setServiceName(String JavaDoc serviceName) {
205         this.serviceNameTextField.setText(serviceName);
206     }
207     
208     public String JavaDoc getServicePortName() {
209         return servicePortTextField.getText();
210     }
211     
212     public void setServicePortName(String JavaDoc servicePortName) {
213         this.servicePortTextField.setText(servicePortName);
214     }
215     
216     public JTextField JavaDoc getBindingNameTextField() {
217         return this.bindingNameTextField;
218     }
219     
220     public JTextField JavaDoc getServiceNameTextField() {
221         return this.serviceNameTextField;
222     }
223     
224     public JTextField JavaDoc getServicePortTextField() {
225         return this.servicePortTextField;
226     }
227     
228     
229     private void initGUI() {
230         if (protocols.size() > 0) {
231             subTypePanel = new BindingSubTypePanel(defaultSelection, new BindingSubTypeActionListener());
232             jPanel1.add(subTypePanel);
233         }
234     }
235     
236     class BindingSubTypeActionListener implements ActionListener JavaDoc {
237         
238         public void actionPerformed(ActionEvent JavaDoc e) {
239             firePropertyChange(PROP_BINDING_SUBTYPE, null, getBindingSubType());
240         }
241         
242     }
243     
244     private BindingSubTypePanel subTypePanel;
245     // Variables declaration - do not modify//GEN-BEGIN:variables
246
private javax.swing.JTextField JavaDoc bindingNameTextField;
247     private javax.swing.JComboBox JavaDoc bindingTypeComboBox;
248     private javax.swing.JLabel JavaDoc jLabel1;
249     private javax.swing.JLabel JavaDoc jLabel2;
250     private javax.swing.JLabel JavaDoc jLabel3;
251     private javax.swing.JLabel JavaDoc jLabel4;
252     private javax.swing.JLabel JavaDoc jLabel5;
253     private javax.swing.JPanel JavaDoc jPanel1;
254     private javax.swing.JTextField JavaDoc serviceNameTextField;
255     private javax.swing.JTextField JavaDoc servicePortTextField;
256     // End of variables declaration//GEN-END:variables
257

258 }
259
Popular Tags