1 19 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui; 20 21 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject; 22 import org.netbeans.modules.xml.multiview.*; 23 import org.netbeans.modules.xml.multiview.ui.*; 24 import org.netbeans.modules.xml.multiview.Error; 25 import org.netbeans.modules.j2ee.websphere6.dd.loaders.ejbbnd.*; 26 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSEjbBnd; 27 import org.openide.util.NbBundle; 28 32 public class WSEjbBndAttributesPanel extends SectionInnerPanel implements java.awt.event.ItemListener { 33 34 WSEjbBnd ejbbnd; 35 WSMultiViewDataObject dObj; 36 37 private javax.swing.JTextField cmpConnectionFactoryNameField; 38 private javax.swing.JTextField cmpConnectionFactoryJndiNameField; 39 private javax.swing.JCheckBox cmpConnectionFactoryCheckBox; 40 private javax.swing.JComboBox cmpConnectionFactoryAuthType; 41 private final String FACTORY_NAME="Default CMP Connection Factory Name"; private final String FACTORY_JNDI_NAME="Default CMP Connection Factory JNDI Name"; 44 45 46 public WSEjbBndAttributesPanel(SectionView view, WSMultiViewDataObject dObj,WSEjbBnd ejbbnd) { 47 super(view); 48 this.dObj=dObj; 49 this.ejbbnd=ejbbnd; 50 initComponents(); 51 bindCmpConnectionFactoryComponents(); 52 initCmpConnectionFactoryComponents(); 53 54 nameField.setText(ejbbnd.getXmiId()); 55 hrefField.setText(ejbbnd.getEjbJarHref()); 56 currentBackendIdField.setText(ejbbnd.getCurrentBackendId()); 57 addModifier(nameField); 58 addModifier(hrefField); 59 addModifier(currentBackendIdField); 60 } 61 private void bindCmpConnectionFactoryComponents() { 62 CMPConnectionFactory panel=(CMPConnectionFactory)cmpConnectionFactoryPanel; 63 cmpConnectionFactoryNameField=panel.getNameField(); 64 cmpConnectionFactoryJndiNameField=panel.getJndiNameField(); 65 cmpConnectionFactoryCheckBox=panel.getFactoryCheckBox(); 66 cmpConnectionFactoryAuthType=panel.getAuthTypeComboBox(); 67 panel.setComponentsBackground(SectionVisualTheme.getSectionActiveBackgroundColor()); 68 panel.setEnabledComponents(); 69 } 70 71 private void initCmpConnectionFactoryComponents(){ 72 addModifier(cmpConnectionFactoryNameField); 73 addModifier(cmpConnectionFactoryJndiNameField); 74 addValidatee(cmpConnectionFactoryNameField); 75 addValidatee(cmpConnectionFactoryJndiNameField); 76 77 boolean factoryEnabled=(ejbbnd.getCmpConnectionFactory()==null)?false:true; 78 cmpConnectionFactoryCheckBox.setSelected(factoryEnabled); 79 80 if(factoryEnabled) { 81 82 cmpConnectionFactoryNameField.setText( 83 ejbbnd.getCmpConnectionFactoryXmiId()); 84 85 cmpConnectionFactoryJndiNameField.setText( 86 ejbbnd.getCmpConnectionFactoryJndiName()); 87 88 cmpConnectionFactoryAuthType.setSelectedItem( 89 ejbbnd.getCmpConnectionFactoryResAuth()); 90 91 } 92 cmpConnectionFactoryCheckBox.addItemListener(this); 93 cmpConnectionFactoryAuthType.addItemListener(this); 94 ((CMPConnectionFactory)cmpConnectionFactoryPanel).setEnabledComponents(); 95 } 96 public void setValue(javax.swing.JComponent source,Object value) { 97 if (source==nameField) { 98 ejbbnd.setXmiId((String )value); 99 } else if (source==hrefField) { 100 ejbbnd.setEjbJarHref((String )value); 101 } else if (source==currentBackendIdField) { 102 ejbbnd.setCurrentBackendId((String )value); 103 } else if(source==cmpConnectionFactoryNameField) { 104 ejbbnd.setCmpConnectionFactoryXmiId((String )value); 105 } else if(source==cmpConnectionFactoryJndiNameField) { 106 ejbbnd.setCmpConnectionFactoryJndiName((String )value); 107 } 108 109 } 110 public void linkButtonPressed(Object ddBean, String ddProperty) { 111 } 112 public void rollbackValue(javax.swing.text.JTextComponent source) { 113 if (nameField==source) { 114 nameField.setText(ejbbnd.getXmiId()); 115 } 116 if (hrefField==source) { 117 hrefField.setText(ejbbnd.getEjbJarHref()); 118 } 119 if (currentBackendIdField==source) { 120 currentBackendIdField.setText(ejbbnd.getCurrentBackendId()); 121 } 122 if (cmpConnectionFactoryNameField==source) { 123 cmpConnectionFactoryNameField.setText(ejbbnd.getCmpConnectionFactoryXmiId()); 124 } 125 if (cmpConnectionFactoryJndiNameField==source) { 126 cmpConnectionFactoryNameField.setText(ejbbnd.getCmpConnectionFactoryJndiName()); 127 } 128 } 129 public javax.swing.JComponent getErrorComponent(String errorId) { 130 if ("Name".equals(errorId)) return nameField; 131 if ("Ejb-Jar ID".equals(errorId)) return hrefField; 132 if("Current Backend ID".equals(errorId)) return currentBackendIdField; 133 return null; 134 } 135 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 136 if (comp==nameField) { 137 String val = (String )value; 138 if (val.length()==0) { 139 getSectionView() 140 .getErrorPanel() 141 .setError(new Error (Error.MISSING_VALUE_MESSAGE, "Name", comp)); 142 return; 143 } 144 getSectionView().getErrorPanel().clearError(); 145 } 146 if (comp==hrefField) { 147 String val = (String )value; 148 if (val.length()==0) { 149 getSectionView() 150 .getErrorPanel() 151 .setError(new Error (Error.MISSING_VALUE_MESSAGE, "Ejb-Jar ID", comp)); 152 return; 153 } 154 getSectionView().getErrorPanel().clearError(); 155 } 156 if (comp==currentBackendIdField) { 157 String val = (String )value; 158 if (val.length()==0) { 159 getSectionView() 160 .getErrorPanel() 161 .setError(new Error (Error.MISSING_VALUE_MESSAGE, "Current Backend ID", comp)); 162 return; 163 } 164 getSectionView().getErrorPanel().clearError(); 165 } 166 if(comp==cmpConnectionFactoryNameField) { 167 String val = (String )value; 168 if (val.length()==0) { 169 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, FACTORY_NAME, comp)); 170 return; 171 } 172 getSectionView().getErrorPanel().clearError(); 173 } 174 if(comp==cmpConnectionFactoryJndiNameField) { 175 String val = (String )value; 176 if (val.length()==0) { 177 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, FACTORY_JNDI_NAME, comp)); 178 return; 179 } 180 getSectionView().getErrorPanel().clearError(); 181 } 182 } 183 private void changeCmpConnectionFactoryState() { 184 if(cmpConnectionFactoryCheckBox.isSelected()) { 185 ejbbnd.setCmpConnectionFactory(""); 186 ejbbnd.setCmpConnectionFactoryXmiId(cmpConnectionFactoryNameField.getText()); 187 ejbbnd.setCmpConnectionFactoryResAuth( 188 cmpConnectionFactoryAuthType.getSelectedItem().toString()); 189 } else { 190 ejbbnd.setCmpConnectionFactory(null); 191 } 192 ((CMPConnectionFactory)cmpConnectionFactoryPanel).setEnabledComponents(); 193 } 194 public void itemStateChanged(java.awt.event.ItemEvent evt) { 195 dObj.setChangedFromUI(true); 196 changeCmpConnectionFactoryState(); 197 dObj.modelUpdatedFromUI(); 199 dObj.setChangedFromUI(false); 201 } 202 protected void startUIChange() { 203 dObj.setChangedFromUI(true); 204 } 205 protected void endUIChange() { 206 dObj.modelUpdatedFromUI(); 207 dObj.setChangedFromUI(false); 208 } 209 214 private void initComponents() { 216 nameLabel = new javax.swing.JLabel (); 217 nameField = new javax.swing.JTextField (); 218 currentBackendIdLabel = new javax.swing.JLabel (); 219 currentBackendIdField = new javax.swing.JTextField (); 220 rootId = new javax.swing.JLabel (); 221 hrefField = new javax.swing.JTextField (); 222 cmpConnectionFactoryPanel = new CMPConnectionFactory(); 223 ((CMPConnectionFactory)cmpConnectionFactoryPanel).getFactoryCheckBox().setText(NbBundle.getMessage(CMPConnectionFactory.class,"LBL_DefaultCMPConnectionFactory")); 224 225 nameLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_Name")); 226 227 currentBackendIdLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_CurrentBackendId")); 228 229 rootId.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_EjbJarId")); 230 231 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 232 this.setLayout(layout); 233 layout.setHorizontalGroup( 234 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 235 .add(layout.createSequentialGroup() 236 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 237 .add(layout.createSequentialGroup() 238 .add(58, 58, 58) 239 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) 240 .add(rootId) 241 .add(nameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 242 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 243 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 244 .add(hrefField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE) 245 .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE))) 246 .add(layout.createSequentialGroup() 247 .addContainerGap() 248 .add(currentBackendIdLabel) 249 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 250 .add(currentBackendIdField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)) 251 .add(layout.createSequentialGroup() 252 .addContainerGap() 253 .add(cmpConnectionFactoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE))) 254 .addContainerGap()) 255 ); 256 layout.setVerticalGroup( 257 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 258 .add(layout.createSequentialGroup() 259 .addContainerGap() 260 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 261 .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 262 .add(nameLabel)) 263 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 264 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 265 .add(rootId, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE) 266 .add(hrefField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 267 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 268 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 269 .add(currentBackendIdLabel) 270 .add(currentBackendIdField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 271 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 272 .add(cmpConnectionFactoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 273 .addContainerGap()) 274 ); 275 } 277 278 private javax.swing.JPanel cmpConnectionFactoryPanel; 280 private javax.swing.JTextField currentBackendIdField; 281 private javax.swing.JLabel currentBackendIdLabel; 282 private javax.swing.JTextField hrefField; 283 private javax.swing.JTextField nameField; 284 private javax.swing.JLabel nameLabel; 285 private javax.swing.JLabel rootId; 286 288 } 289 | Popular Tags |