1 19 20 25 26 package org.netbeans.modules.xml.wsdl.ui.view; 27 28 import java.awt.event.ActionEvent ; 29 import java.awt.event.ActionListener ; 30 import java.util.Collection ; 31 import java.util.SortedSet ; 32 import java.util.TreeSet ; 33 import java.util.Vector ; 34 import javax.swing.ComboBoxModel ; 35 36 import javax.swing.DefaultComboBoxModel ; 37 import javax.swing.JTextField ; 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 49 public class BindingConfigurationPanel extends javax.swing.JPanel { 50 51 public static final String PROP_BINDING_TYPE = "PROP_BINDING_TYPE"; 52 public static final String PROP_BINDING_SUBTYPE = "PROP_BINDING_SUBTYPE"; 53 54 private ExtensibilityElementTemplateFactory factory; 55 private Vector <LocalizedTemplateGroup> protocols = new Vector <LocalizedTemplateGroup>(); 56 private LocalizedTemplateGroup defaultSelection; 58 59 public BindingConfigurationPanel() { 60 factory = new ExtensibilityElementTemplateFactory(); 61 Collection <TemplateGroup> groups = factory.getExtensibilityElementTemplateGroups(); 62 protocols = new Vector <LocalizedTemplateGroup>(); 63 64 SortedSet <LocalizedTemplateGroup> set = new TreeSet <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 84 private void initComponents() { 86 jLabel1 = new javax.swing.JLabel (); 87 bindingNameTextField = new javax.swing.JTextField (); 88 jLabel2 = new javax.swing.JLabel (); 89 bindingTypeComboBox = new javax.swing.JComboBox (); 90 jLabel3 = new javax.swing.JLabel (); 91 jPanel1 = new javax.swing.JPanel (); 92 jLabel4 = new javax.swing.JLabel (); 93 serviceNameTextField = new javax.swing.JTextField (); 94 jLabel5 = new javax.swing.JLabel (); 95 servicePortTextField = new javax.swing.JTextField (); 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 model = new DefaultComboBoxModel (protocols); 104 model.setSelectedItem(defaultSelection); 105 bindingTypeComboBox.setModel(model); 106 bindingTypeComboBox.addActionListener(new java.awt.event.ActionListener () { 107 public void actionPerformed(java.awt.event.ActionEvent 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 (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 } 171 private void bindingTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) { setBindingSubType(getBindingType()); 173 this.firePropertyChange(PROP_BINDING_TYPE, null, getBindingType()); 174 } 176 public String getBindingName() { 177 return this.bindingNameTextField.getText(); 178 } 179 180 public void setBindingName(String bindingName) { 181 this.bindingNameTextField.setText(bindingName); 182 } 183 184 public LocalizedTemplateGroup getBindingType() { 185 return (LocalizedTemplateGroup) bindingTypeComboBox.getSelectedItem(); 186 } 187 188 public void setBindingType(String 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 getServiceName() { 201 return serviceNameTextField.getText(); 202 } 203 204 public void setServiceName(String serviceName) { 205 this.serviceNameTextField.setText(serviceName); 206 } 207 208 public String getServicePortName() { 209 return servicePortTextField.getText(); 210 } 211 212 public void setServicePortName(String servicePortName) { 213 this.servicePortTextField.setText(servicePortName); 214 } 215 216 public JTextField getBindingNameTextField() { 217 return this.bindingNameTextField; 218 } 219 220 public JTextField getServiceNameTextField() { 221 return this.serviceNameTextField; 222 } 223 224 public JTextField 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 { 237 238 public void actionPerformed(ActionEvent e) { 239 firePropertyChange(PROP_BINDING_SUBTYPE, null, getBindingSubType()); 240 } 241 242 } 243 244 private BindingSubTypePanel subTypePanel; 245 private javax.swing.JTextField bindingNameTextField; 247 private javax.swing.JComboBox bindingTypeComboBox; 248 private javax.swing.JLabel jLabel1; 249 private javax.swing.JLabel jLabel2; 250 private javax.swing.JLabel jLabel3; 251 private javax.swing.JLabel jLabel4; 252 private javax.swing.JLabel jLabel5; 253 private javax.swing.JPanel jPanel1; 254 private javax.swing.JTextField serviceNameTextField; 255 private javax.swing.JTextField servicePortTextField; 256 258 } 259 | Popular Tags |