1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule; 26 27 import java.util.ArrayList ; 28 import java.util.List ; 29 import java.util.ResourceBundle ; 30 31 import java.awt.GridBagConstraints ; 32 import java.awt.Insets ; 33 34 import javax.swing.event.TableModelEvent ; 35 import javax.swing.event.TableModelListener ; 36 37 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 38 import org.netbeans.modules.j2ee.sun.dd.api.ejb.CmpResource; 39 import org.netbeans.modules.j2ee.sun.dd.api.ejb.PropertyElement; 40 import org.netbeans.modules.j2ee.sun.dd.api.ejb.SchemaGeneratorProperties; 41 42 import org.netbeans.modules.j2ee.sun.share.configbean.ASDDVersion; 43 import org.netbeans.modules.j2ee.sun.share.configbean.EjbJarRoot; 44 import org.netbeans.modules.j2ee.sun.share.configbean.StorageBeanFactory; 45 import org.netbeans.modules.j2ee.sun.share.configbean.Utils; 46 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTableModel; 47 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTablePanel; 48 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.HelpContext; 49 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicPropertyPanel; 50 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.PropertyListMapping; 51 52 53 57 public class EjbJarCmpResourcePanel extends javax.swing.JPanel implements TableModelListener { 58 59 private static final ResourceBundle ejbjarBundle = ResourceBundle.getBundle( 60 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); 62 private static final ResourceBundle commonBundle = ResourceBundle.getBundle( 63 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.Bundle"); 65 private EjbJarRootCustomizer masterPanel; 66 67 private GenericTableModel cmpPropertiesModel; 69 private GenericTablePanel cmpPropertiesPanel; 70 71 private GenericTableModel schemaGeneratorPropertiesModel; 73 private GenericTablePanel schemaGeneratorPropertiesPanel; 74 75 76 79 public EjbJarCmpResourcePanel(EjbJarRootCustomizer src) { 80 masterPanel = src; 81 82 initComponents(); 83 initUserComponents(); 84 } 85 86 91 private void initComponents() { 93 java.awt.GridBagConstraints gridBagConstraints; 94 95 cmpResourcePanel = new javax.swing.JPanel (); 96 jLblJndiName = new javax.swing.JLabel (); 97 jTxtJndiName = new javax.swing.JTextField (); 98 jLblVendorName = new javax.swing.JLabel (); 99 jTxtVendorName = new javax.swing.JTextField (); 100 tablePrefsPanel = new javax.swing.JPanel (); 101 jLblCreateOnDeploy = new javax.swing.JLabel (); 102 jCbxCreateOnDeploy = new javax.swing.JComboBox (); 103 jLblDropOnUndeploy = new javax.swing.JLabel (); 104 jCbxDropOnUndeploy = new javax.swing.JComboBox (); 105 106 setLayout(new java.awt.GridBagLayout ()); 107 108 getAccessibleContext().setAccessibleName(ejbjarBundle.getString("ACSN_EjbJarMessagesTab")); 109 getAccessibleContext().setAccessibleDescription(ejbjarBundle.getString("ACSD_EjbJarMessagesTab")); 110 cmpResourcePanel.setLayout(new java.awt.GridBagLayout ()); 111 112 jLblJndiName.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("LBL_Jndi_Name_1")); 113 gridBagConstraints = new java.awt.GridBagConstraints (); 114 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 115 cmpResourcePanel.add(jLblJndiName, gridBagConstraints); 116 117 jTxtJndiName.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("Cmp_Resource_Jndi_Name_Tool_Tip")); 118 jTxtJndiName.addKeyListener(new java.awt.event.KeyAdapter () { 119 public void keyReleased(java.awt.event.KeyEvent evt) { 120 jTxtJndiNameKeyReleased(evt); 121 } 122 }); 123 124 gridBagConstraints = new java.awt.GridBagConstraints (); 125 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 126 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 127 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 128 gridBagConstraints.weightx = 1.0; 129 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 130 cmpResourcePanel.add(jTxtJndiName, gridBagConstraints); 131 132 jLblVendorName.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("LBL_Database_Vendor_Name_1")); 133 gridBagConstraints = new java.awt.GridBagConstraints (); 134 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 135 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 136 cmpResourcePanel.add(jLblVendorName, gridBagConstraints); 137 138 jTxtVendorName.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("Database_Vendor_Name_Tool_Tip")); 139 jTxtVendorName.addKeyListener(new java.awt.event.KeyAdapter () { 140 public void keyReleased(java.awt.event.KeyEvent evt) { 141 jTxtVendorNameKeyReleased(evt); 142 } 143 }); 144 145 gridBagConstraints = new java.awt.GridBagConstraints (); 146 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 147 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 148 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 149 gridBagConstraints.weightx = 1.0; 150 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 151 cmpResourcePanel.add(jTxtVendorName, gridBagConstraints); 152 153 tablePrefsPanel.setLayout(new java.awt.GridBagLayout ()); 154 155 jLblCreateOnDeploy.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("LBL_Create_Table_At_Deploy_1")); 156 gridBagConstraints = new java.awt.GridBagConstraints (); 157 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 158 tablePrefsPanel.add(jLblCreateOnDeploy, gridBagConstraints); 159 160 jCbxCreateOnDeploy.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "", "true", "false" })); 161 jCbxCreateOnDeploy.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("Create_Table_At_Deploy_Tool_Tip")); 162 jCbxCreateOnDeploy.addActionListener(new java.awt.event.ActionListener () { 163 public void actionPerformed(java.awt.event.ActionEvent evt) { 164 jCbxCreateOnDeployActionPerformed(evt); 165 } 166 }); 167 168 gridBagConstraints = new java.awt.GridBagConstraints (); 169 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 170 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 171 gridBagConstraints.weightx = 1.0; 172 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 173 tablePrefsPanel.add(jCbxCreateOnDeploy, gridBagConstraints); 174 175 jLblDropOnUndeploy.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("LBL_Drop_Table_At_Undeploy_1")); 176 gridBagConstraints = new java.awt.GridBagConstraints (); 177 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 178 gridBagConstraints.insets = new java.awt.Insets (0, 18, 0, 0); 179 tablePrefsPanel.add(jLblDropOnUndeploy, gridBagConstraints); 180 181 jCbxDropOnUndeploy.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "", "true", "false" })); 182 jCbxDropOnUndeploy.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/share/configbean/customizers/ejbmodule/Bundle").getString("Drop_Table_At_Undeploy_Tool_Tip")); 183 jCbxDropOnUndeploy.addActionListener(new java.awt.event.ActionListener () { 184 public void actionPerformed(java.awt.event.ActionEvent evt) { 185 jCbxDropOnUndeployActionPerformed(evt); 186 } 187 }); 188 189 gridBagConstraints = new java.awt.GridBagConstraints (); 190 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 191 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 192 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 193 gridBagConstraints.weightx = 1.0; 194 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 195 tablePrefsPanel.add(jCbxDropOnUndeploy, gridBagConstraints); 196 197 gridBagConstraints = new java.awt.GridBagConstraints (); 198 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 199 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 200 gridBagConstraints.weightx = 1.0; 201 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 202 cmpResourcePanel.add(tablePrefsPanel, gridBagConstraints); 203 204 gridBagConstraints = new java.awt.GridBagConstraints (); 205 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 206 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 207 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 208 gridBagConstraints.weightx = 1.0; 209 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 5); 210 add(cmpResourcePanel, gridBagConstraints); 211 212 } 214 private void jCbxDropOnUndeployActionPerformed(java.awt.event.ActionEvent evt) { EjbJarRoot theBean = masterPanel.getBean(); 216 if(theBean != null) { 217 CmpResource cmpResource = theBean.getCmpResource(); 218 String newDropValue = (String ) jCbxDropOnUndeploy.getSelectedItem(); 219 String oldDropValue = cmpResource.getDropTablesAtUndeploy(); 220 221 if(!Utils.strEquals(oldDropValue, newDropValue)) { 222 if(Utils.notEmpty(newDropValue)) { 223 cmpResource.setDropTablesAtUndeploy(newDropValue); 224 } else { 225 cmpResource.setDropTablesAtUndeploy(null); 226 } 227 228 theBean.firePropertyChange("cmpDropTables", oldDropValue, newDropValue); masterPanel.validateField(EjbJarRoot.FIELD_CMP_RESOURCE); 230 } 231 } 232 } 234 private void jCbxCreateOnDeployActionPerformed(java.awt.event.ActionEvent evt) { EjbJarRoot theBean = masterPanel.getBean(); 236 if(theBean != null) { 237 CmpResource cmpResource = theBean.getCmpResource(); 238 String newCreateValue = (String ) jCbxCreateOnDeploy.getSelectedItem(); 239 String oldCreateValue = cmpResource.getCreateTablesAtDeploy(); 240 241 if(!Utils.strEquals(oldCreateValue, newCreateValue)) { 242 if(Utils.notEmpty(newCreateValue)) { 243 cmpResource.setCreateTablesAtDeploy(newCreateValue); 244 } else { 245 cmpResource.setCreateTablesAtDeploy(null); 246 } 247 248 theBean.firePropertyChange("cmpCreateTables", oldCreateValue, newCreateValue); masterPanel.validateField(EjbJarRoot.FIELD_CMP_RESOURCE); 250 } 251 } 252 } 254 private void jTxtVendorNameKeyReleased(java.awt.event.KeyEvent evt) { EjbJarRoot theBean = masterPanel.getBean(); 256 if(theBean != null) { 257 CmpResource cmpResource = theBean.getCmpResource(); 258 String newVendorName = jTxtVendorName.getText(); 259 String oldVendorName = cmpResource.getDatabaseVendorName(); 260 261 if(!Utils.strEquals(oldVendorName, newVendorName)) { 262 if(Utils.notEmpty(newVendorName)) { 263 cmpResource.setDatabaseVendorName(newVendorName); 264 } else { 265 cmpResource.setDatabaseVendorName(null); 266 } 267 268 theBean.firePropertyChange("cmpDBVendorName", oldVendorName, newVendorName); masterPanel.validateField(EjbJarRoot.FIELD_CMP_RESOURCE); 270 } 271 } 272 } 274 private void jTxtJndiNameKeyReleased(java.awt.event.KeyEvent evt) { EjbJarRoot theBean = masterPanel.getBean(); 276 if(theBean != null) { 277 CmpResource cmpResource = theBean.getCmpResource(); 278 String newJndiName = jTxtJndiName.getText(); 279 String oldJndiName = cmpResource.getJndiName(); 280 281 if(!Utils.strEquals(oldJndiName, newJndiName)) { 282 if(Utils.notEmpty(newJndiName)) { 283 cmpResource.setJndiName(newJndiName); 284 } else { 285 cmpResource.setJndiName(null); 286 } 287 288 theBean.firePropertyChange("cmpJndiName", oldJndiName, newJndiName); masterPanel.validateField(EjbJarRoot.FIELD_CMP_RESOURCE); 290 } 291 } 292 } 294 295 private javax.swing.JPanel cmpResourcePanel; 297 private javax.swing.JComboBox jCbxCreateOnDeploy; 298 private javax.swing.JComboBox jCbxDropOnUndeploy; 299 private javax.swing.JLabel jLblCreateOnDeploy; 300 private javax.swing.JLabel jLblDropOnUndeploy; 301 private javax.swing.JLabel jLblJndiName; 302 private javax.swing.JLabel jLblVendorName; 303 private javax.swing.JTextField jTxtJndiName; 304 private javax.swing.JTextField jTxtVendorName; 305 private javax.swing.JPanel tablePrefsPanel; 306 308 private void initUserComponents() { 309 ArrayList tableColumns = new ArrayList (2); 311 tableColumns.add(new GenericTableModel.ValueEntry( 312 PropertyElement.NAME, commonBundle.getString("LBL_Name"), true)); tableColumns.add(new GenericTableModel.ValueEntry( 314 PropertyElement.VALUE, commonBundle.getString("LBL_Value"), true)); 316 cmpPropertiesModel = new GenericTableModel(CmpResource.PROPERTY, 318 cmpPropertyFactory, tableColumns); 319 cmpPropertiesPanel = new GenericTablePanel(cmpPropertiesModel, 320 ejbjarBundle, "CmpProperties", DynamicPropertyPanel.class, HelpContext.HELP_EJBJAR_CMP_PROPERTY_POPUP, 322 PropertyListMapping.getPropertyList(PropertyListMapping.EJBJAR_CMP_PROPERTIES)); 323 324 GridBagConstraints gridBagConstraints = new GridBagConstraints (); 325 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 326 gridBagConstraints.fill = GridBagConstraints.BOTH; 327 gridBagConstraints.weightx = 1.0; 328 gridBagConstraints.weighty = 1.0; 329 gridBagConstraints.insets = new Insets (6, 6, 0, 5); 330 add(cmpPropertiesPanel, gridBagConstraints); 331 332 schemaGeneratorPropertiesModel = new GenericTableModel(SchemaGeneratorProperties.PROPERTY, 334 cmpPropertyFactory, tableColumns); 335 schemaGeneratorPropertiesPanel = new GenericTablePanel(schemaGeneratorPropertiesModel, 336 ejbjarBundle, "SchemaGeneratorProperties", DynamicPropertyPanel.class, HelpContext.HELP_EJBJAR_SCHEMA_PROPERTY_POPUP, 338 PropertyListMapping.getPropertyList(PropertyListMapping.EJBJAR_CMP_SCHEMA_PROPERTIES)); 339 340 gridBagConstraints = new GridBagConstraints (); 341 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 342 gridBagConstraints.fill = GridBagConstraints.BOTH; 343 gridBagConstraints.weightx = 1.0; 344 gridBagConstraints.weighty = 1.0; 345 gridBagConstraints.insets = new Insets (0, 6, 0, 5); 346 add(schemaGeneratorPropertiesPanel, gridBagConstraints); 347 } 348 349 public void addListeners() { 350 cmpPropertiesModel.addTableModelListener(this); 351 schemaGeneratorPropertiesModel.addTableModelListener(this); 352 } 353 354 public void removeListeners() { 355 schemaGeneratorPropertiesModel.removeTableModelListener(this); 356 cmpPropertiesModel.removeTableModelListener(this); 357 } 358 359 362 public void initFields(EjbJarRoot bean) { 363 CmpResource cmpResource = bean.getCmpResource(); 364 365 jTxtJndiName.setText(cmpResource.getJndiName()); 366 jTxtVendorName.setText(cmpResource.getDatabaseVendorName()); 367 368 jCbxCreateOnDeploy.setSelectedItem(cmpResource.getCreateTablesAtDeploy()); 369 jCbxDropOnUndeploy.setSelectedItem(cmpResource.getDropTablesAtUndeploy()); 370 371 cmpPropertiesPanel.setModel(cmpResource, bean.getAppServerVersion()); 372 SchemaGeneratorProperties sgp = cmpResource.getSchemaGeneratorProperties(); 373 if(sgp == null) { 374 sgp = cmpResource.newSchemaGeneratorProperties(); 375 } 376 schemaGeneratorPropertiesPanel.setModel(sgp, bean.getAppServerVersion()); 377 } 378 379 380 383 public void tableChanged(TableModelEvent e) { 384 EjbJarRoot bean = masterPanel.getBean(); 385 if(bean != null) { 386 CmpResource cmpResource = bean.getCmpResource(); 387 Object eventSource = e.getSource(); 388 389 if(eventSource == cmpPropertiesModel) { 391 List rows = cmpPropertiesModel.getData(); 392 bean.firePropertyChange("cmpProperties", null, rows); 393 masterPanel.validateField(EjbJarRoot.FIELD_CMP_RESOURCE); 394 } else if(eventSource == schemaGeneratorPropertiesModel) { 395 SchemaGeneratorProperties sgp = 396 (SchemaGeneratorProperties) schemaGeneratorPropertiesModel.getDataBaseBean(); 397 if(sgp.sizePropertyElement() > 0) { 398 cmpResource.setSchemaGeneratorProperties(sgp); 399 } else { 400 cmpResource.setSchemaGeneratorProperties(null); 401 } 402 bean.firePropertyChange("schemaGeneratorProperties", null, sgp); 403 masterPanel.validateField(EjbJarRoot.FIELD_CMP_RESOURCE); 404 } 405 } 406 } 407 408 static GenericTableModel.ParentPropertyFactory cmpPropertyFactory = 411 new GenericTableModel.ParentPropertyFactory() { 412 public CommonDDBean newParentProperty(ASDDVersion asVersion) { 413 return StorageBeanFactory.getStorageBeanFactory(asVersion).createPropertyElement(); 414 } 415 }; 416 } 417 | Popular Tags |