1 19 20 package org.netbeans.modules.j2ee.ddloaders.web.multiview; 21 22 import org.netbeans.modules.j2ee.dd.api.web.JspPropertyGroup; 23 import org.netbeans.modules.j2ee.dd.api.web.*; 24 import org.netbeans.modules.j2ee.ddloaders.web.*; 25 import org.netbeans.modules.xml.multiview.ui.*; 26 import org.netbeans.modules.xml.multiview.Utils; 27 import org.netbeans.modules.xml.multiview.Error; 28 import org.netbeans.api.project.SourceGroup; 29 30 33 public class OverviewPanel extends SectionInnerPanel implements java.awt.event.ItemListener { 34 DDDataObject dObj; 35 WebApp webApp; 36 37 public OverviewPanel(SectionView sectionView, DDDataObject dObj) { 38 super(sectionView); 39 this.dObj=dObj; 40 webApp=dObj.getWebApp(); 41 initComponents(); 42 43 dispNameTF.setText(webApp.getDefaultDisplayName()); 45 addModifier(dispNameTF); 46 47 Utils.makeTextAreaLikeTextField(descriptionTA,dispNameTF); 49 descriptionTA.setText(webApp.getDefaultDescription()); 50 addModifier(descriptionTA); 51 52 jCheckBox1.setSelected(webApp.isDistributable()); 54 jCheckBox1.addItemListener(this); 55 56 stTF.setText(getSessionTimeout()); 58 addValidatee(stTF); 59 60 } 61 62 private String getSessionTimeout() { 63 SessionConfig config = webApp.getSingleSessionConfig(); 64 if (config==null) return ""; 65 java.math.BigInteger timeout = config.getSessionTimeout(); 66 return (timeout==null?"":timeout.toString()); 67 } 68 69 private void setSessionTimeout(String text) { 70 String val = text.trim(); 71 SessionConfig config = webApp.getSingleSessionConfig(); 72 if (config!=null) { 73 if (text.length()==0) webApp.setSessionConfig(null); 74 else config.setSessionTimeout(new java.math.BigInteger (val)); 75 } else if (text.length()>0) { 76 try { 77 SessionConfig newConfig = (SessionConfig)webApp.createBean("SessionConfig"); 78 newConfig.setSessionTimeout(new java.math.BigInteger (val)); 79 webApp.setSessionConfig(newConfig); 80 } catch (ClassNotFoundException ex){} 81 } 82 83 } 84 85 public javax.swing.JComponent getErrorComponent(String errorId) { 86 return null; 87 } 88 89 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 90 if (comp==stTF) { 91 String text = value.trim(); 92 if (text.length()==0) { 93 getSectionView().getErrorPanel().clearError(); 94 } else { 95 java.math.BigInteger st=null; 96 try { 97 st = new java.math.BigInteger (text); 98 } catch (NumberFormatException ex) {} 99 if (st==null) { 100 getSectionView().getErrorPanel().setError(new Error (Error.TYPE_FATAL, Error.ERROR_MESSAGE, "Invalid Value : "+text, stTF)); 101 return; 102 } 103 getSectionView().getErrorPanel().clearError(); 104 } 105 } 106 } 107 108 public void setValue(javax.swing.JComponent source, Object value) { 109 String text = ((String )value).trim(); 110 if (source==dispNameTF) { 111 webApp.setDisplayName(text.length()==0?null:text); 112 } else if (source==descriptionTA) { 113 webApp.setDescription(text.length()==0?null:text); 114 } else if (source==stTF) { 115 setSessionTimeout(text); 116 } 117 } 118 119 public void rollbackValue(javax.swing.text.JTextComponent source) { 120 if (source==stTF) { 121 stTF.setText(getSessionTimeout()); 122 } 123 } 124 125 public void linkButtonPressed(Object obj, String id) { 126 } 127 128 129 134 private void initComponents() { 136 java.awt.GridBagConstraints gridBagConstraints; 137 138 filler = new javax.swing.JPanel (); 139 dispNameLabel = new javax.swing.JLabel (); 140 dispNameTF = new javax.swing.JTextField (); 141 descriptionLabel = new javax.swing.JLabel (); 142 descriptionTA = new javax.swing.JTextArea (); 143 jCheckBox1 = new javax.swing.JCheckBox (); 144 stLabel = new javax.swing.JLabel (); 145 stTF = new javax.swing.JTextField (); 146 jLabel1 = new javax.swing.JLabel (); 147 148 setLayout(new java.awt.GridBagLayout ()); 149 150 filler.setOpaque(false); 151 gridBagConstraints = new java.awt.GridBagConstraints (); 152 gridBagConstraints.gridx = 2; 153 gridBagConstraints.gridy = 0; 154 gridBagConstraints.gridwidth = 2; 155 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 156 gridBagConstraints.weightx = 1.0; 157 add(filler, gridBagConstraints); 158 159 dispNameLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_displayName_mnem").charAt(0)); 160 dispNameLabel.setLabelFor(dispNameTF); 161 dispNameLabel.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_displayName")); 162 gridBagConstraints = new java.awt.GridBagConstraints (); 163 gridBagConstraints.gridx = 0; 164 gridBagConstraints.gridy = 0; 165 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 166 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 10); 167 add(dispNameLabel, gridBagConstraints); 168 169 dispNameTF.setColumns(30); 170 gridBagConstraints = new java.awt.GridBagConstraints (); 171 gridBagConstraints.gridx = 1; 172 gridBagConstraints.gridy = 0; 173 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 174 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 175 add(dispNameTF, gridBagConstraints); 176 177 descriptionLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_description_mnem").charAt(0)); 178 descriptionLabel.setLabelFor(descriptionTA); 179 descriptionLabel.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_description")); 180 gridBagConstraints = new java.awt.GridBagConstraints (); 181 gridBagConstraints.gridx = 0; 182 gridBagConstraints.gridy = 1; 183 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 184 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 10); 185 add(descriptionLabel, gridBagConstraints); 186 187 descriptionTA.setRows(3); 188 gridBagConstraints = new java.awt.GridBagConstraints (); 189 gridBagConstraints.gridx = 1; 190 gridBagConstraints.gridy = 1; 191 gridBagConstraints.gridwidth = 3; 192 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 193 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 10); 194 add(descriptionTA, gridBagConstraints); 195 196 jCheckBox1.setMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_distributable_mnem").charAt(0)); 197 jCheckBox1.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_distributable")); 198 jCheckBox1.setOpaque(false); 199 gridBagConstraints = new java.awt.GridBagConstraints (); 200 gridBagConstraints.gridx = 1; 201 gridBagConstraints.gridy = 2; 202 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 203 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 204 add(jCheckBox1, gridBagConstraints); 205 206 stLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_sessionTimeout_mnem").charAt(0)); 207 stLabel.setLabelFor(stTF); 208 stLabel.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_sessionTimeout")); 209 gridBagConstraints = new java.awt.GridBagConstraints (); 210 gridBagConstraints.gridx = 0; 211 gridBagConstraints.gridy = 3; 212 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 213 gridBagConstraints.insets = new java.awt.Insets (5, 10, 5, 10); 214 add(stLabel, gridBagConstraints); 215 216 stTF.setColumns(5); 217 gridBagConstraints = new java.awt.GridBagConstraints (); 218 gridBagConstraints.gridx = 1; 219 gridBagConstraints.gridy = 3; 220 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 221 gridBagConstraints.insets = new java.awt.Insets (5, 0, 5, 0); 222 add(stTF, gridBagConstraints); 223 224 jLabel1.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_min")); 225 gridBagConstraints = new java.awt.GridBagConstraints (); 226 gridBagConstraints.gridx = 2; 227 gridBagConstraints.gridy = 3; 228 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 229 gridBagConstraints.insets = new java.awt.Insets (5, 5, 5, 0); 230 add(jLabel1, gridBagConstraints); 231 232 } 233 235 236 private javax.swing.JLabel descriptionLabel; 238 private javax.swing.JTextArea descriptionTA; 239 private javax.swing.JLabel dispNameLabel; 240 private javax.swing.JTextField dispNameTF; 241 private javax.swing.JPanel filler; 242 private javax.swing.JCheckBox jCheckBox1; 243 private javax.swing.JLabel jLabel1; 244 private javax.swing.JLabel stLabel; 245 private javax.swing.JTextField stTF; 246 248 public void itemStateChanged(java.awt.event.ItemEvent evt) { 249 if (evt.getSource() == jCheckBox1) { 251 dObj.modelUpdatedFromUI(); 252 dObj.setChangedFromUI(true); 253 webApp.setDistributable(jCheckBox1.isSelected()); 254 dObj.setChangedFromUI(false); 255 } 256 } 257 258 260 protected void startUIChange() { 261 dObj.setChangedFromUI(true); 262 } 263 264 266 protected void endUIChange() { 267 dObj.modelUpdatedFromUI(); 268 dObj.setChangedFromUI(false); 269 } 270 } 271 | Popular Tags |