1 19 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui; 20 21 import org.netbeans.modules.j2ee.websphere6.dd.beans.DDXmiConstants; 22 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSAppExt; 23 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject; 24 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel; 25 import org.netbeans.modules.xml.multiview.ui.SectionView; 26 import org.netbeans.modules.xml.multiview.Error; 27 28 32 public class WSAppExtAttributesPanel extends SectionInnerPanel 33 implements java.awt.event.ItemListener , javax.swing.event.ChangeListener , DDXmiConstants{ 34 35 WSAppExt appext; 36 WSMultiViewDataObject dObj; 37 38 39 public WSAppExtAttributesPanel(SectionView view, WSMultiViewDataObject dObj, WSAppExt appext) { 40 super(view); 41 this.dObj=dObj; 42 this.appext=appext; 43 initComponents(); 44 idField.setText(appext.getXmiId()); 45 hrefField.setText(appext.getApplicationHref()); 46 reloadIntervalCheckBox.setSelected(appext.getReload()); 47 shareSessionCheckBox.setSelected(appext.getSharedSession()); 48 reloadIntervalSpinner.setModel(new javax.swing.SpinnerNumberModel (0,0,600,1)); 49 reloadIntervalSpinner.setValue(new Integer (appext.getReloadInterval())); 50 reloadIntervalCheckBox.addItemListener(this); 51 shareSessionCheckBox.addItemListener(this); 52 reloadIntervalSpinner.addChangeListener(this); 53 addModifier(hrefField); 54 addModifier(idField); 55 56 addValidatee(hrefField); 57 addValidatee(idField); 58 59 60 ModuleExtensionTableModel model = new ModuleExtensionTableModel(dObj.getModelSynchronizer()); 61 ModuleExtensionTablePanel ptp= new ModuleExtensionTablePanel(dObj, model); 62 ptp.setModel(appext,appext.getModuleExtensions()); 63 java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 64 gridBagConstraints.gridx = 0; 65 gridBagConstraints.gridy = 10; 66 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 68 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 69 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 70 gridBagConstraints.weightx = 1.0; 71 jPanel1.add(ptp,gridBagConstraints); 72 } 73 public void setValue(javax.swing.JComponent source,Object value) { 74 if(source==hrefField) { 75 appext.setApplicationHref((String )value); 76 } 77 if(source==idField) { 78 appext.setXmiId((String )value); 79 } 80 } 81 public void linkButtonPressed(Object ddBean, String ddProperty) { 82 } 83 84 public javax.swing.JComponent getErrorComponent(String errorId) { 85 if("Name".equals(errorId)) return idField; 86 if("Application Id".equals(errorId)) return hrefField; 87 return null; 88 } 89 public void stateChanged(javax.swing.event.ChangeEvent evt) { 90 appext.setReloadInterval(reloadIntervalSpinner.getValue().toString()); 91 dObj.modelUpdatedFromUI(); 92 } 93 public void itemStateChanged(java.awt.event.ItemEvent evt) { 94 dObj.setChangedFromUI(true); 95 if(evt.getSource()==reloadIntervalCheckBox) { 96 appext.setReload(reloadIntervalCheckBox.isSelected()); 97 if(reloadIntervalCheckBox.isSelected()) { 98 appext.setReloadInterval(reloadIntervalSpinner.getValue().toString()); 99 reloadIntervalSpinner.setEnabled(true); 100 } else { 101 appext.setReloadInterval(null); 102 reloadIntervalSpinner.setEnabled(false); 103 } 104 } else if(evt.getSource()==shareSessionCheckBox) { 105 appext.setSharedSession(shareSessionCheckBox.isSelected()); 106 } 107 dObj.modelUpdatedFromUI(); 108 dObj.setChangedFromUI(false); 109 } 110 111 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 112 if (comp==idField) { 113 String val = (String )value; 114 if (val.length()==0) { 115 getSectionView() 116 .getErrorPanel() 117 .setError(new Error (Error.MISSING_VALUE_MESSAGE, "Name", comp)); 118 return; 119 } 120 getSectionView().getErrorPanel().clearError(); 121 } 122 if (comp==hrefField) { 123 String val = (String )value; 124 if (val.length()==0) { 125 getSectionView() 126 .getErrorPanel() 127 .setError(new Error (Error.MISSING_VALUE_MESSAGE, "Application Id", comp)); 128 return; 129 } 130 getSectionView().getErrorPanel().clearError(); 131 } 132 } 133 134 public void rollbackValue(javax.swing.text.JTextComponent source) { 135 if (idField==source) { 136 idField.setText(appext.getXmiId()); 137 } else if(hrefField==source) { 138 hrefField.setText(appext.getApplicationHref()); 139 } 140 141 } 142 144 145 protected void startUIChange() { 146 dObj.setChangedFromUI(true); 147 } 148 149 151 152 protected void endUIChange() { 153 dObj.modelUpdatedFromUI(); 154 dObj.setChangedFromUI(false); 155 } 156 157 162 private void initComponents() { 164 jLabel1 = new javax.swing.JLabel (); 165 idField = new javax.swing.JTextField (); 166 shareSessionCheckBox = new javax.swing.JCheckBox (); 167 reloadIntervalCheckBox = new javax.swing.JCheckBox (); 168 reloadIntervalSpinner = new javax.swing.JSpinner (); 169 jLabel2 = new javax.swing.JLabel (); 170 hrefField = new javax.swing.JTextField (); 171 jPanel1 = new javax.swing.JPanel (); 172 jLabel3 = new javax.swing.JLabel (); 173 174 jLabel1.setText("Name:"); 175 176 shareSessionCheckBox.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_SharedSession")); 177 shareSessionCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 178 shareSessionCheckBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 179 180 reloadIntervalCheckBox.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_ReloadInterval")); 181 reloadIntervalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 182 reloadIntervalCheckBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 183 184 reloadIntervalSpinner.setFont(new java.awt.Font ("Courier", 0, 12)); 185 186 jLabel2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_ApplicationId")); 187 188 jPanel1.setLayout(new java.awt.GridBagLayout ()); 189 190 jLabel3.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_ModuleExtensions")); 191 192 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 193 this.setLayout(layout); 194 layout.setHorizontalGroup( 195 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 196 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() 197 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) 198 .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() 199 .addContainerGap() 200 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE)) 201 .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() 202 .add(20, 20, 20) 203 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 204 .add(shareSessionCheckBox) 205 .add(layout.createSequentialGroup() 206 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) 207 .add(jLabel2) 208 .add(jLabel1) 209 .add(reloadIntervalCheckBox)) 210 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 211 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 212 .add(hrefField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE) 213 .add(reloadIntervalSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 214 .add(layout.createSequentialGroup() 215 .add(idField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE) 216 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))))) 217 .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() 218 .addContainerGap() 219 .add(jLabel3))) 220 .addContainerGap()) 221 ); 222 layout.setVerticalGroup( 223 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 224 .add(layout.createSequentialGroup() 225 .addContainerGap() 226 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 227 .add(jLabel1) 228 .add(idField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 229 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 230 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 231 .add(hrefField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 232 .add(jLabel2)) 233 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 234 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 235 .add(reloadIntervalCheckBox) 236 .add(reloadIntervalSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 237 .add(11, 11, 11) 238 .add(shareSessionCheckBox) 239 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 31, Short.MAX_VALUE) 240 .add(jLabel3) 241 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 242 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) 243 .addContainerGap()) 244 ); 245 } 247 248 private javax.swing.JTextField hrefField; 250 private javax.swing.JTextField idField; 251 private javax.swing.JLabel jLabel1; 252 private javax.swing.JLabel jLabel2; 253 private javax.swing.JLabel jLabel3; 254 private javax.swing.JPanel jPanel1; 255 private javax.swing.JCheckBox reloadIntervalCheckBox; 256 private javax.swing.JSpinner reloadIntervalSpinner; 257 private javax.swing.JCheckBox shareSessionCheckBox; 258 260 } 261 | Popular Tags |