1 19 24 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.other; 25 26 import java.util.ArrayList ; 27 import java.util.ResourceBundle ; 28 29 import java.awt.GridBagConstraints ; 30 import java.awt.Insets ; 31 import java.beans.PropertyVetoException ; 32 import javax.swing.event.TableModelEvent ; 33 import javax.swing.event.TableModelListener ; 34 35 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 36 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageDestination; 37 38 import org.netbeans.modules.j2ee.sun.share.configbean.ASDDVersion; 39 import org.netbeans.modules.j2ee.sun.share.configbean.AppClientRoot; 40 import org.netbeans.modules.j2ee.sun.share.configbean.StorageBeanFactory; 41 import org.netbeans.modules.j2ee.sun.share.configbean.Utils; 42 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTableModel; 43 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTablePanel; 44 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BaseCustomizer; 45 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.HelpContext; 46 47 48 52 public class AppClientRootCustomizer extends BaseCustomizer implements TableModelListener { 53 54 private static final ResourceBundle otherBundle = ResourceBundle.getBundle( 55 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.other.Bundle"); 57 private AppClientRoot theBean; 58 59 private GenericTableModel messageDestinationModel; 61 private GenericTablePanel messageDestinationPanel; 62 63 67 private boolean as90FeaturesVisible; 69 70 private boolean setup; 72 73 74 public AppClientRootCustomizer() { 75 initComponents(); 76 initUserComponents(); 77 } 78 79 public AppClientRoot getBean() { 80 return theBean; 81 } 82 83 88 private void initComponents() { 90 java.awt.GridBagConstraints gridBagConstraints; 91 92 jPnlJws = new javax.swing.JPanel (); 93 jLblJavaWebStartAccess = new javax.swing.JLabel (); 94 jLblContextRoot = new javax.swing.JLabel (); 95 jTxtContextRoot = new javax.swing.JTextField (); 96 jLblVendor = new javax.swing.JLabel (); 97 jTxtVendor = new javax.swing.JTextField (); 98 jLblEligible = new javax.swing.JLabel (); 99 jChkEligible = new javax.swing.JCheckBox (); 100 101 setLayout(new java.awt.GridBagLayout ()); 102 103 jPnlJws.setLayout(new java.awt.GridBagLayout ()); 104 105 jLblJavaWebStartAccess.setText(otherBundle.getString("LBL_JavaWebStartAccess")); 106 gridBagConstraints = new java.awt.GridBagConstraints (); 107 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 108 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 109 jPnlJws.add(jLblJavaWebStartAccess, gridBagConstraints); 110 111 jLblContextRoot.setLabelFor(jTxtContextRoot); 112 jLblContextRoot.setText(otherBundle.getString("LBL_ContextRoot_1")); 113 gridBagConstraints = new java.awt.GridBagConstraints (); 114 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 115 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 116 jPnlJws.add(jLblContextRoot, gridBagConstraints); 117 118 jTxtContextRoot.addKeyListener(new java.awt.event.KeyAdapter () { 119 public void keyReleased(java.awt.event.KeyEvent evt) { 120 jTxtContextRootKeyReleased(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.weightx = 1.0; 128 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 129 jPnlJws.add(jTxtContextRoot, gridBagConstraints); 130 jTxtContextRoot.getAccessibleContext().setAccessibleName(otherBundle.getString("ContextRoot_Acsbl_Name")); 131 jTxtContextRoot.getAccessibleContext().setAccessibleDescription(otherBundle.getString("ContextRoot_Acsbl_Desc")); 132 133 jLblVendor.setLabelFor(jTxtVendor); 134 jLblVendor.setText(otherBundle.getString("LBL_Vendor_1")); 135 gridBagConstraints = new java.awt.GridBagConstraints (); 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 137 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 138 jPnlJws.add(jLblVendor, gridBagConstraints); 139 140 jTxtVendor.addKeyListener(new java.awt.event.KeyAdapter () { 141 public void keyReleased(java.awt.event.KeyEvent evt) { 142 jTxtVendorKeyReleased(evt); 143 } 144 }); 145 146 gridBagConstraints = new java.awt.GridBagConstraints (); 147 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 148 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 149 gridBagConstraints.weightx = 1.0; 150 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 151 jPnlJws.add(jTxtVendor, gridBagConstraints); 152 jTxtVendor.getAccessibleContext().setAccessibleName(otherBundle.getString("ASCN_Vendor")); 153 jTxtVendor.getAccessibleContext().setAccessibleDescription(otherBundle.getString("ASCD_Vendor")); 154 155 jLblEligible.setLabelFor(jChkEligible); 156 jLblEligible.setText(otherBundle.getString("LBL_Eligible_1")); 157 gridBagConstraints = new java.awt.GridBagConstraints (); 158 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 159 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 160 jPnlJws.add(jLblEligible, gridBagConstraints); 161 162 jChkEligible.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 163 jChkEligible.setMargin(new java.awt.Insets (0, 0, 0, 0)); 164 jChkEligible.addItemListener(new java.awt.event.ItemListener () { 165 public void itemStateChanged(java.awt.event.ItemEvent evt) { 166 jChkEligibleItemStateChanged(evt); 167 } 168 }); 169 170 gridBagConstraints = new java.awt.GridBagConstraints (); 171 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 172 gridBagConstraints.ipady = 8; 173 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 174 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 175 jPnlJws.add(jChkEligible, gridBagConstraints); 176 jChkEligible.getAccessibleContext().setAccessibleName(otherBundle.getString("ASCN_Eligible")); 177 jChkEligible.getAccessibleContext().setAccessibleDescription(otherBundle.getString("ASCD_Eligible")); 178 179 gridBagConstraints = new java.awt.GridBagConstraints (); 180 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 181 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 182 gridBagConstraints.weightx = 1.0; 183 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 5); 184 add(jPnlJws, gridBagConstraints); 185 186 } 188 private void jChkEligibleItemStateChanged(java.awt.event.ItemEvent evt) { if(!setup && jChkEligible.isVisible() && theBean != null) { 190 boolean newState = Utils.interpretCheckboxState(evt); 191 if(newState != theBean.isEligible()) { 192 try { 193 theBean.setEligible(newState); 194 } catch(java.beans.PropertyVetoException exception) { 195 jChkEligible.setSelected(theBean.isEligible()); 196 } 197 } 198 } 199 } 201 private void jTxtVendorKeyReleased(java.awt.event.KeyEvent evt) { if(!setup && jTxtVendor.isVisible() && theBean != null) { 203 String newVendor = jTxtVendor.getText(); 204 if(newVendor != null) { 205 newVendor = newVendor.trim(); 206 } 207 String oldVendor = theBean.getVendor(); 208 if(!Utils.strEquivalent(newVendor, oldVendor)) { 209 try { 210 theBean.setVendor(newVendor); 211 } catch(java.beans.PropertyVetoException exception) { 212 jTxtVendor.setText(oldVendor); 213 } 214 } 215 } 216 } 218 private void jTxtContextRootKeyReleased(java.awt.event.KeyEvent evt) { if(!setup && jTxtContextRoot.isVisible() && theBean != null) { 220 String newContextRoot = jTxtContextRoot.getText(); 221 if(newContextRoot != null) { 222 newContextRoot = newContextRoot.trim(); 223 } 224 String oldContextRoot = theBean.getContextRoot(); 225 if(!Utils.strEquivalent(newContextRoot, oldContextRoot)) { 226 try { 227 theBean.setContextRoot(newContextRoot); 228 } catch(java.beans.PropertyVetoException exception) { 230 jTxtContextRoot.setText(oldContextRoot); 231 } 232 } 233 } 234 } 236 private javax.swing.JCheckBox jChkEligible; 238 private javax.swing.JLabel jLblContextRoot; 239 private javax.swing.JLabel jLblEligible; 240 private javax.swing.JLabel jLblJavaWebStartAccess; 241 private javax.swing.JLabel jLblVendor; 242 private javax.swing.JPanel jPnlJws; 243 private javax.swing.JTextField jTxtContextRoot; 244 private javax.swing.JTextField jTxtVendor; 245 247 private void initUserComponents() { 248 as90FeaturesVisible = true; 249 250 addTitlePanel(otherBundle.getString("TITLE_SunApplicationClient")); getAccessibleContext().setAccessibleName(otherBundle.getString("ACSN_SunApplicationClient")); getAccessibleContext().setAccessibleDescription(otherBundle.getString("ACSD_SunApplicationClient")); 255 258 ArrayList tableColumns = new ArrayList (2); 259 tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.MESSAGE_DESTINATION_NAME, 260 otherBundle, "MessageDestinationName", true, true)); tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.JNDI_NAME, 262 otherBundle, "JNDIName", true, false)); 264 messageDestinationModel = new GenericTableModel(messageDestinationFactory, tableColumns); 265 messageDestinationPanel = new GenericTablePanel(messageDestinationModel, 266 otherBundle, "MessageDestination", HelpContext.HELP_APPCLIENT_MESSAGE_DESTINATION_POPUP); 268 269 GridBagConstraints gridBagConstraints = new GridBagConstraints (); 270 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 271 gridBagConstraints.fill = GridBagConstraints.BOTH; 272 gridBagConstraints.weightx = 1.0; 273 gridBagConstraints.weighty = 1.0; 274 gridBagConstraints.insets = new Insets (0, 6, 5, 5); 275 add(messageDestinationPanel, gridBagConstraints); 276 277 280 286 299 addErrorPanel(); 301 } 302 303 protected void initFields() { 304 try { 305 setup = true; 306 messageDestinationPanel.setModel(theBean.getMessageDestinations(), theBean.getAppServerVersion()); 307 if(ASDDVersion.SUN_APPSERVER_9_0.compareTo(theBean.getAppServerVersion()) <= 0) { 308 jTxtContextRoot.setText(theBean.getContextRoot()); 309 jTxtVendor.setText(theBean.getVendor()); 310 jChkEligible.setSelected(theBean.isEligible()); 311 showAS90Fields(true); 313 } else { 314 jTxtContextRoot.setText(""); 315 jTxtVendor.setText(""); 316 jChkEligible.setSelected(false); 317 showAS90Fields(false); 318 } 319 } finally { 320 setup = false; 321 } 322 } 323 324 private void showAS90Fields(boolean show) { 325 if(as90FeaturesVisible != show) { 326 as90FeaturesVisible = show; 327 jPnlJws.setVisible(show); 328 } 330 } 331 332 public void addListeners() { 333 super.addListeners(); 334 335 messageDestinationModel.addTableModelListener(this); 336 } 338 339 public void removeListeners() { 340 super.removeListeners(); 341 342 messageDestinationModel.removeTableModelListener(this); 344 } 345 346 protected boolean setBean(Object bean) { 347 boolean result = super.setBean(bean); 348 349 if(bean instanceof AppClientRoot) { 350 theBean = (AppClientRoot) bean; 351 result = true; 352 } else { 353 assert (result == false) : 355 "AppClientRootCustomizer was passed wrong bean type in setBean(Object bean)"; 357 theBean = null; 358 result = false; 359 } 360 361 return result; 362 } 363 364 367 public void tableChanged(TableModelEvent e) { 368 if(theBean != null) { 369 try { 370 Object eventSource = e.getSource(); 371 if(eventSource == messageDestinationModel) { 372 theBean.setMessageDestinations(messageDestinationModel.getData()); 373 theBean.firePropertyChange("messageDestination", null, messageDestinationModel.getData()); 374 } 378 } catch(PropertyVetoException ex) { 379 } 381 } 382 } 383 384 public String getHelpId() { 385 return "AS_CFG_AppClient"; 386 } 387 388 static GenericTableModel.ParentPropertyFactory messageDestinationFactory = 391 new GenericTableModel.ParentPropertyFactory() { 392 public CommonDDBean newParentProperty(ASDDVersion asVersion) { 393 return StorageBeanFactory.getStorageBeanFactory(asVersion).createMessageDestination(); 394 } 395 }; 396 397 } 404 | Popular Tags |