1 19 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui; 20 21 import java.awt.event.ItemListener ; 22 import javax.swing.DefaultComboBoxModel ; 23 import org.netbeans.modules.j2ee.websphere6.dd.beans.*; 24 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject; 25 import org.netbeans.modules.xml.multiview.*; 26 import org.netbeans.modules.xml.multiview.ui.*; 27 import org.netbeans.modules.xml.multiview.Error; 28 import org.openide.util.NbBundle; 29 33 public class WSEjbBindingsPanel extends SectionInnerPanel implements java.awt.event.ItemListener ,DDXmiConstants{ 34 EjbBindingsType ejbBinding; 35 WSMultiViewDataObject dObj; 36 private static String [] Types=new String [] { 37 NbBundle.getMessage(WSEjbBindingsPanel.class,"LBL_TypeSession"), 38 NbBundle.getMessage(WSEjbBindingsPanel.class,"LBL_TypeEntity"), 39 NbBundle.getMessage(WSEjbBindingsPanel.class,"LBL_TypeContainerManagedEntity"), 40 NbBundle.getMessage(WSEjbBindingsPanel.class,"LBL_TypeMessageDriven") 41 }; 42 43 private javax.swing.JTextField cmpConnectionFactoryNameField; 44 private javax.swing.JTextField cmpConnectionFactoryJndiNameField; 45 private javax.swing.JCheckBox cmpConnectionFactoryCheckBox; 46 private javax.swing.JComboBox cmpConnectionFactoryAuthType; 47 private final String FACTORY_NAME="CMP Connection Factory Name"; private final String FACTORY_JNDI_NAME="CMP Connection Factory JNDI Name"; 50 51 public WSEjbBindingsPanel(SectionView view,WSMultiViewDataObject dObj,EjbBindingsType ejbBinding) { 52 super(view); 53 this.dObj=dObj; 54 this.ejbBinding=ejbBinding; 55 initComponents(); 56 bindCmpConnectionFactoryComponents(); 57 initCmpConnectionFactoryComponents(); 58 59 60 61 62 idField.setText(ejbBinding.getXmiId()); 63 jndiNameField.setText(ejbBinding.getJndiName()); 64 hrefField.setText(ejbBinding.getHref()); 65 addModifier(hrefField); 66 addModifier(jndiNameField); 67 addModifier(idField); 68 beanTypeComboBox.setModel(new DefaultComboBoxModel (Types)); 69 String xmiType=ejbBinding.getXmiType(); 70 if(xmiType!=null) { 71 if(xmiType.equals(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_SESSION)) { 72 beanTypeComboBox.setSelectedIndex(0); 73 } else if(xmiType.equals(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_ENTITY)) { 74 beanTypeComboBox.setSelectedIndex(1); 75 } else if(xmiType.equals(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_CONTAINER_MANAGED_ENTITY)) { 76 beanTypeComboBox.setSelectedIndex(2); 77 } else if(xmiType.equals(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_MESSAGEDRIVEN)) { 78 beanTypeComboBox.setSelectedIndex(3); 79 } else { 80 beanTypeComboBox.setSelectedIndex(-1); 81 } 82 } else { 83 beanTypeComboBox.setSelectedIndex(-1); 84 } 85 beanTypeComboBox.addItemListener(this); 86 getSectionView().getErrorPanel().clearError(); 87 88 ReferencesTableModel model = new ReferencesTableModel(dObj.getModelSynchronizer()); 89 model.setHrefType(EJB_JAR); 90 ReferenceTablePanel ptp= new ReferenceTablePanel(dObj, model); 91 ptp.setModel(ejbBinding,ejbBinding.getReferences()); 92 java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 93 gridBagConstraints.gridx = 0; 94 gridBagConstraints.gridy = 10; 95 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 97 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 98 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 99 gridBagConstraints.weightx = 1.0; 100 jPanel1.add(ptp,gridBagConstraints); 101 102 } 103 private void bindCmpConnectionFactoryComponents() { 104 CMPConnectionFactory panel=(CMPConnectionFactory)cmpConnectionFactoryPanel; 105 cmpConnectionFactoryNameField=panel.getNameField(); 106 cmpConnectionFactoryJndiNameField=panel.getJndiNameField(); 107 cmpConnectionFactoryCheckBox=panel.getFactoryCheckBox(); 108 cmpConnectionFactoryAuthType=panel.getAuthTypeComboBox(); 109 panel.setComponentsBackground(SectionVisualTheme.getSectionActiveBackgroundColor()); 110 panel.setEnabledComponents(); 111 } 112 113 private void initCmpConnectionFactoryComponents(){ 114 addModifier(cmpConnectionFactoryNameField); 115 addModifier(cmpConnectionFactoryJndiNameField); 116 addValidatee(cmpConnectionFactoryNameField); 117 addValidatee(cmpConnectionFactoryJndiNameField); 118 119 boolean factoryEnabled=(ejbBinding.getCmpConnectionFactory()==null)?false:true; 120 cmpConnectionFactoryCheckBox.setSelected(factoryEnabled); 121 122 if(factoryEnabled) { 123 124 cmpConnectionFactoryNameField.setText( 125 ejbBinding.getCmpConnectionFactoryXmiId()); 126 127 cmpConnectionFactoryJndiNameField.setText( 128 ejbBinding.getCmpConnectionFactoryJndiName()); 129 130 cmpConnectionFactoryAuthType.setSelectedItem( 131 ejbBinding.getCmpConnectionFactoryResAuth()); 132 133 } 134 cmpConnectionFactoryCheckBox.addItemListener(this); 135 cmpConnectionFactoryAuthType.addItemListener(this); 136 ((CMPConnectionFactory)cmpConnectionFactoryPanel).setEnabledComponents(); 137 } 138 139 public void setValue(javax.swing.JComponent source, Object value) { 140 if (source==idField) { 141 ejbBinding.setXmiId((String )value); 142 } else if(source==jndiNameField) { 143 ejbBinding.setJndiName((String )value); 144 } else if(source==hrefField) { 145 ejbBinding.setHref((String )value); 146 } else if(source==cmpConnectionFactoryNameField) { 147 ejbBinding.setCmpConnectionFactoryXmiId((String )value); 148 } else if(source==cmpConnectionFactoryJndiNameField) { 149 ejbBinding.setCmpConnectionFactoryJndiName((String )value); 150 } 151 152 } 153 154 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 155 if (comp==idField) { 156 String val = (String )value; 157 if (val.length()==0) { 158 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "ID", comp)); 159 return; 160 } 161 getSectionView().getErrorPanel().clearError(); 162 } 163 if(comp==jndiNameField) { 164 String val = (String )value; 165 if (val.length()==0) { 166 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "JNDI Name", comp)); 167 return; 168 } 169 getSectionView().getErrorPanel().clearError(); 170 } 171 if(comp==hrefField) { 172 String val = (String )value; 173 if (val.length()==0) { 174 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "Bean Name", comp)); 175 return; 176 } 177 getSectionView().getErrorPanel().clearError(); 178 } 179 if(comp==cmpConnectionFactoryNameField) { 180 String val = (String )value; 181 if (val.length()==0) { 182 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, FACTORY_NAME, comp)); 183 return; 184 } 185 getSectionView().getErrorPanel().clearError(); 186 } 187 if(comp==cmpConnectionFactoryJndiNameField) { 188 String val = (String )value; 189 if (val.length()==0) { 190 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, FACTORY_JNDI_NAME, comp)); 191 return; 192 } 193 getSectionView().getErrorPanel().clearError(); 194 } 195 } 196 197 public void rollbackValue(javax.swing.text.JTextComponent source) { 198 if (idField==source) { 199 idField.setText(ejbBinding.getXmiId()); 200 } 201 if (jndiNameField==source) { 202 jndiNameField.setText(ejbBinding.getJndiName()); 203 } 204 if (hrefField==source) { 205 hrefField.setText(ejbBinding.getHref()); 206 } 207 if (cmpConnectionFactoryNameField==source) { 208 cmpConnectionFactoryNameField.setText(ejbBinding.getCmpConnectionFactoryXmiId()); 209 } 210 if (cmpConnectionFactoryJndiNameField==source) { 211 cmpConnectionFactoryNameField.setText(ejbBinding.getCmpConnectionFactoryJndiName()); 212 } 213 } 214 public void linkButtonPressed(Object ddBean, String ddProperty) { 215 } 216 public javax.swing.JComponent getErrorComponent(String errorId) { 217 if ("ID".equals(errorId)) return idField; 218 if ("JNDI Name".equals(errorId)) return jndiNameField; 219 if ("Bean Name".equals(errorId)) return hrefField; 220 if (FACTORY_NAME.equals(errorId)) return cmpConnectionFactoryNameField; 221 if (FACTORY_JNDI_NAME.equals(errorId)) return cmpConnectionFactoryJndiNameField; 222 return null; 223 } 224 public void itemStateChanged(java.awt.event.ItemEvent evt) { 225 dObj.setChangedFromUI(true); 226 String selectedString=(String )beanTypeComboBox.getSelectedItem(); 227 if(selectedString!=null) { 228 if(selectedString.equals(Types[0])) { ejbBinding.setXmiType(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_SESSION); 230 } else if(selectedString.equals(Types[1])) { ejbBinding.setXmiType(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_ENTITY); 232 } else if(selectedString.equals(Types[2])) { ejbBinding.setXmiType(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_CONTAINER_MANAGED_ENTITY); 234 } else if(selectedString.equals(Types[3])) { ejbBinding.setXmiType(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_MESSAGEDRIVEN); 236 } else { 237 ejbBinding.setXmiType(null); 238 239 } 240 } 241 changeCmpConnectionFactoryState(); 242 dObj.modelUpdatedFromUI(); 244 dObj.setChangedFromUI(false); 246 } 247 248 private void changeCmpConnectionFactoryState() { 249 if(cmpConnectionFactoryCheckBox.isSelected()) { 250 ejbBinding.setCmpConnectionFactory(""); 251 ejbBinding.setCmpConnectionFactoryXmiId(cmpConnectionFactoryNameField.getText()); 252 ejbBinding.setCmpConnectionFactoryResAuth( 253 cmpConnectionFactoryAuthType.getSelectedItem().toString()); 254 } else { 255 ejbBinding.setCmpConnectionFactory(null); 256 } 257 ((CMPConnectionFactory)cmpConnectionFactoryPanel).setEnabledComponents(); 258 } 259 260 262 protected void startUIChange() { 263 dObj.setChangedFromUI(true); 264 } 265 266 268 protected void endUIChange() { 269 dObj.modelUpdatedFromUI(); 270 dObj.setChangedFromUI(false); 271 } 272 277 private void initComponents() { 279 jLabel1 = new javax.swing.JLabel (); 280 jLabel2 = new javax.swing.JLabel (); 281 jLabel3 = new javax.swing.JLabel (); 282 idField = new javax.swing.JTextField (); 283 jndiNameField = new javax.swing.JTextField (); 284 hrefField = new javax.swing.JTextField (); 285 typeLabel = new javax.swing.JLabel (); 286 beanTypeComboBox = new javax.swing.JComboBox (); 287 jPanel1 = new javax.swing.JPanel (); 288 cmpConnectionFactoryPanel = new CMPConnectionFactory(); 289 jLabel4 = new javax.swing.JLabel (); 290 jSeparator1 = new javax.swing.JSeparator (); 291 292 jLabel1.setText("Id:"); 293 294 jLabel2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_JndiName")); 295 296 jLabel3.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_BeanName")); 297 298 typeLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_BeanType")); 299 300 jPanel1.setLayout(new java.awt.GridBagLayout ()); 301 302 jLabel4.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_ReferenceBindings")); 303 304 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 305 this.setLayout(layout); 306 layout.setHorizontalGroup( 307 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 308 .add(layout.createSequentialGroup() 309 .addContainerGap() 310 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 311 .add(org.jdesktop.layout.GroupLayout.TRAILING, cmpConnectionFactoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE) 312 .add(layout.createSequentialGroup() 313 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) 314 .add(typeLabel) 315 .add(jLabel2) 316 .add(jLabel3) 317 .add(jLabel1)) 318 .add(16, 16, 16) 319 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 320 .add(idField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE) 321 .add(hrefField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE) 322 .add(jndiNameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE) 323 .add(beanTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 156, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) 324 .addContainerGap()) 325 .add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 483, Short.MAX_VALUE) 326 .add(layout.createSequentialGroup() 327 .add(21, 21, 21) 328 .add(jLabel4) 329 .addContainerGap(370, Short.MAX_VALUE)) 330 .add(layout.createSequentialGroup() 331 .addContainerGap() 332 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE) 333 .addContainerGap()) 334 ); 335 layout.setVerticalGroup( 336 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 337 .add(layout.createSequentialGroup() 338 .addContainerGap() 339 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 340 .add(idField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 341 .add(jLabel1)) 342 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 343 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 344 .add(jndiNameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 345 .add(jLabel2)) 346 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 347 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 348 .add(jLabel3) 349 .add(hrefField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 350 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 351 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 352 .add(typeLabel) 353 .add(beanTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 354 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 355 .add(cmpConnectionFactoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 356 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 357 .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 358 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 359 .add(jLabel4) 360 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 361 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE) 362 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 363 ); 364 } 366 367 private javax.swing.JComboBox beanTypeComboBox; 369 private javax.swing.JPanel cmpConnectionFactoryPanel; 370 private javax.swing.JTextField hrefField; 371 private javax.swing.JTextField idField; 372 private javax.swing.JLabel jLabel1; 373 private javax.swing.JLabel jLabel2; 374 private javax.swing.JLabel jLabel3; 375 private javax.swing.JLabel jLabel4; 376 private javax.swing.JPanel jPanel1; 377 private javax.swing.JSeparator jSeparator1; 378 private javax.swing.JTextField jndiNameField; 379 private javax.swing.JLabel typeLabel; 380 382 } 383 | Popular Tags |