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.ejbext.WSEjbExtDataObject; 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 30 34 public class EjbExtensionPanel extends SectionInnerPanel implements java.awt.event.ItemListener { 35 EjbExtensionsType ejbExtension; 36 WSEjbExtDataObject dObj; 37 38 private javax.swing.JCheckBox localTransactionCheckBox; 39 private javax.swing.JTextField transactionNameField; 40 41 42 private javax.swing.JComboBox unresolvedActionComboBox; 43 private javax.swing.JCheckBox resolverCheckBox; 44 private javax.swing.JComboBox resolverComboBox; 45 private javax.swing.JCheckBox boundaryCheckBox; 46 private javax.swing.JComboBox boundaryComboBox; 47 48 49 private static String [] Types=new String [] { 50 NbBundle.getMessage(EjbExtensionPanel.class,"LBL_TypeSession"), 51 NbBundle.getMessage(EjbExtensionPanel.class,"LBL_TypeEntity"), 52 NbBundle.getMessage(EjbExtensionPanel.class,"LBL_TypeMessageDriven")}; 53 54 public EjbExtensionPanel(SectionView view, WSEjbExtDataObject dObj, EjbExtensionsType ejbExtension) { 55 56 super(view); 57 this.dObj=dObj; 58 this.ejbExtension=ejbExtension; 59 initComponents(); 60 bindLocalTransactionComponents(); 61 62 initLocalTransactionComponents(); 63 64 ((LocalTransactionPanel)jPanel1).setEnabledComponents(); 65 66 typeComboBox.setModel(new DefaultComboBoxModel (Types)); 67 68 nameField.setText(ejbExtension.getXmiName()); 69 idField.setText(ejbExtension.getXmiId()); 70 beanIdField.setText(ejbExtension.getHref()); 71 72 String [] data = new String [] { 73 ejbExtension.getEjbExtensionsType(), 74 ejbExtension.getEnterpriseBean(), 75 ejbExtension.getHref(), 76 ejbExtension.getXmiId(), 77 ejbExtension.getXmiName(), 78 ejbExtension.getXmiType() 79 }; 80 addModifier(nameField); 81 addModifier(idField); 82 addModifier(beanIdField); 83 84 addValidatee(nameField); 85 addValidatee(idField); 86 addValidatee(beanIdField); 87 88 89 String xmiType=ejbExtension.getXmiType(); 90 if(xmiType!=null) { 91 if(xmiType.equals(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_SESSION)) { 92 typeComboBox.setSelectedIndex(0); 93 } else if(xmiType.equals(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_ENTITY)) { 94 typeComboBox.setSelectedIndex(1); 95 } else if(xmiType.equals(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_MESSAGEDRIVEN)) { 96 typeComboBox.setSelectedIndex(2); 97 } else { 98 typeComboBox.setSelectedIndex(-1); 99 } 100 } else { 101 typeComboBox.setSelectedIndex(-1); 102 } 103 typeComboBox.addItemListener(this); 104 } 105 106 private void bindLocalTransactionComponents(){ 107 LocalTransactionPanel localTransactionPanel=(LocalTransactionPanel)jPanel1; 108 109 localTransactionCheckBox=localTransactionPanel.getLocalTransactionCheckBox(); 110 transactionNameField=localTransactionPanel.getTransactionNameField(); 111 unresolvedActionComboBox=localTransactionPanel.getUnresolvedActionComboBox(); 112 resolverCheckBox=localTransactionPanel.getResolverCheckBox(); 113 resolverComboBox=localTransactionPanel.getResolverComboBox(); 114 boundaryCheckBox=localTransactionPanel.getBoundaryCheckBox(); 115 boundaryComboBox=localTransactionPanel.getBoundaryComboBox(); 116 localTransactionPanel.setComponentsBackground(SectionVisualTheme.getSectionActiveBackgroundColor()); 117 118 } 119 120 public void initLocalTransactionComponents() { 121 addModifier(nameField); 122 addModifier(transactionNameField); 123 addValidatee(transactionNameField); 124 boolean localTransactionEnabled=(ejbExtension.getLocalTransaction()==null)?false:true; 125 localTransactionCheckBox.setSelected(localTransactionEnabled); 126 127 if(localTransactionEnabled) { 128 transactionNameField.setText(ejbExtension.getLocalTransactionXmiId()); 129 130 unresolvedActionComboBox.setSelectedItem(ejbExtension.getLocalTransactionUnresolvedAction()); 131 String str=ejbExtension.getLocalTransactionResolver(); 132 if(str==null) { 133 resolverCheckBox.setSelected(false); 134 } else { 135 resolverCheckBox.setSelected(true); 136 resolverComboBox.setSelectedItem(str); 137 } 138 139 str=ejbExtension.getLocalTransactionBoundary(); 140 if(str==null) { 141 boundaryCheckBox.setSelected(false); 142 } else { 143 boundaryCheckBox.setSelected(true); 144 boundaryComboBox.setSelectedItem(str); 145 } 146 } 147 148 149 localTransactionCheckBox.addItemListener(this); 150 unresolvedActionComboBox.addItemListener(this); 151 152 resolverCheckBox.addItemListener(this); 153 resolverComboBox.addItemListener(this); 154 155 boundaryCheckBox.addItemListener(this); 156 boundaryComboBox.addItemListener(this); 157 } 158 159 160 public void setValue(javax.swing.JComponent source, Object value) { 161 if (source==nameField) { 162 ejbExtension.setXmiName((String )value); 163 } 164 if (source==idField) { 165 ejbExtension.setXmiId((String )value); 166 167 } 168 if (source==beanIdField) { 169 ejbExtension.setHref((String )value); 170 } 171 172 } 173 public void itemStateChanged(java.awt.event.ItemEvent evt) { 174 dObj.setChangedFromUI(true); 175 String selectedString=(String )typeComboBox.getSelectedItem(); 176 if(selectedString!=null) { 177 if(selectedString.equals(Types[0])) { ejbExtension.setXmiType(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_SESSION); 179 ejbExtension.setEjbExtensionsType(DDXmiConstants.EJB_EXTENSIONS_TYPE_SESSION); 180 } else if(selectedString.equals(Types[1])) { ejbExtension.setXmiType(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_ENTITY); 182 ejbExtension.setEjbExtensionsType(DDXmiConstants.EJB_EXTENSIONS_TYPE_ENTITY); 183 } else if(selectedString.equals(Types[2])) { ejbExtension.setXmiType(DDXmiConstants.EJB_ENTERPRISE_BEAN_TYPE_MESSAGEDRIVEN); 185 ejbExtension.setEjbExtensionsType(DDXmiConstants.EJB_EXTENSIONS_TYPE_MESSAGEDRIVEN); 186 } else { 187 ejbExtension.setXmiType(null); 188 ejbExtension.setEjbExtensionsType(null); 189 } 190 } 191 changeLocalTransactionState(); 192 dObj.modelUpdatedFromUI(); 193 dObj.setChangedFromUI(false); 195 } 196 197 public void changeLocalTransactionState() { 198 if(localTransactionCheckBox.isSelected()) { 199 ejbExtension.setLocalTransaction(""); 200 ejbExtension.setLocalTransactionXmiId(transactionNameField.getText()); 201 202 ejbExtension.setLocalTransactionUnresolvedAction( 203 unresolvedActionComboBox.getSelectedItem().toString()); 204 205 ejbExtension.setLocalTransactionResolver( 206 resolverCheckBox.isSelected()? 207 resolverComboBox.getSelectedItem().toString(): 208 null); 209 ejbExtension.setLocalTransactionBoundary( 210 boundaryCheckBox.isSelected()? 211 boundaryComboBox.getSelectedItem().toString(): 212 null); 213 } else { 214 ejbExtension.setLocalTransaction(null); 215 } 217 ((LocalTransactionPanel)jPanel1).setEnabledComponents(); 218 } 219 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 220 if (comp==nameField) { 221 String val = (String )value; 222 if (val.length()==0) { 223 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "Name", comp)); 224 return; 225 } 226 getSectionView().getErrorPanel().clearError(); 227 } 228 if(comp==idField) { 229 String val = (String )value; 230 if (val.length()==0) { 231 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "ID", comp)); 232 return; 233 } 234 getSectionView().getErrorPanel().clearError(); 235 } 236 if(comp==beanIdField) { 237 String val = (String )value; 238 if (val.length()==0) { 239 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "Bean Name", comp)); 240 return; 241 } 242 getSectionView().getErrorPanel().clearError(); 243 } 244 if (comp==transactionNameField) { 245 String val = (String )value; 246 if (val.length()==0) { 247 getSectionView() 248 .getErrorPanel() 249 .setError(new Error (Error.MISSING_VALUE_MESSAGE, "Local transaction name", comp)); 250 return; 251 } 252 getSectionView().getErrorPanel().clearError(); 253 } 254 } 255 256 public void rollbackValue(javax.swing.text.JTextComponent source) { 257 if (nameField==source) { 258 nameField.setText(ejbExtension.getXmiName()); 259 } 260 if (idField==source) { 261 idField.setText(ejbExtension.getXmiId()); 262 } 263 if (beanIdField==source) { 264 beanIdField.setText(ejbExtension.getHref()); 265 } 266 if (transactionNameField==source) { 267 transactionNameField.setText(ejbExtension.getLocalTransactionXmiId()); 268 } 269 270 } 271 public void linkButtonPressed(Object ddBean, String ddProperty) { 272 } 273 public javax.swing.JComponent getErrorComponent(String errorId) { 274 if ("Name".equals(errorId)) return nameField; 275 if ("ID".equals(errorId)) return idField; 276 if ("Bean Name".equals(errorId)) return beanIdField; 277 if("Local transaction name".equals(errorId)) return transactionNameField; 278 return null; 279 } 280 281 283 protected void startUIChange() { 284 dObj.setChangedFromUI(true); 285 } 286 287 289 protected void endUIChange() { 290 dObj.modelUpdatedFromUI(); 291 dObj.setChangedFromUI(false); 292 } 293 298 private void initComponents() { 300 nameLabel = new javax.swing.JLabel (); 301 jLabel2 = new javax.swing.JLabel (); 302 jLabel3 = new javax.swing.JLabel (); 303 nameField = new javax.swing.JTextField (); 304 idField = new javax.swing.JTextField (); 305 beanIdField = new javax.swing.JTextField (); 306 jLabel4 = new javax.swing.JLabel (); 307 typeComboBox = new javax.swing.JComboBox (); 308 jPanel1 = new LocalTransactionPanel(); 309 jSeparator1 = new javax.swing.JSeparator (); 310 311 nameLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_Name")); 312 313 jLabel2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_Id")); 314 315 jLabel3.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_BeanName")); 316 317 jLabel4.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_BeanType")); 318 319 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 320 this.setLayout(layout); 321 layout.setHorizontalGroup( 322 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 323 .add(layout.createSequentialGroup() 324 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 325 .add(layout.createSequentialGroup() 326 .add(10, 10, 10) 327 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) 328 .add(layout.createSequentialGroup() 329 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 330 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) 331 .add(nameLabel) 332 .add(jLabel2) 333 .add(jLabel3)) 334 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)) 335 .add(jLabel4)) 336 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 337 .add(idField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE) 338 .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE) 339 .add(beanIdField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE) 340 .add(typeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) 341 .add(layout.createSequentialGroup() 342 .add(10, 10, 10) 343 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE))) 344 .addContainerGap()) 345 .add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE) 346 ); 347 layout.setVerticalGroup( 348 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 349 .add(layout.createSequentialGroup() 350 .addContainerGap() 351 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 352 .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 353 .add(nameLabel)) 354 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 355 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 356 .add(idField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 357 .add(jLabel2)) 358 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 359 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 360 .add(beanIdField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 361 .add(jLabel3)) 362 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 363 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 364 .add(typeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 365 .add(jLabel4)) 366 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 367 .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 368 .add(2, 2, 2) 369 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 370 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 371 ); 372 } 374 375 private javax.swing.JTextField beanIdField; 377 private javax.swing.JTextField idField; 378 private javax.swing.JLabel jLabel2; 379 private javax.swing.JLabel jLabel3; 380 private javax.swing.JLabel jLabel4; 381 private javax.swing.JPanel jPanel1; 382 private javax.swing.JSeparator jSeparator1; 383 private javax.swing.JTextField nameField; 384 private javax.swing.JLabel nameLabel; 385 private javax.swing.JComboBox typeComboBox; 386 388 } 389 | Popular Tags |