1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webapp; 26 27 import java.awt.GridBagConstraints ; 28 import java.awt.GridBagLayout ; 29 import java.awt.Insets ; 30 import java.util.ArrayList ; 31 32 import java.util.ResourceBundle ; 33 import java.beans.PropertyVetoException ; 34 35 import javax.swing.JPanel ; 36 import javax.swing.DefaultComboBoxModel ; 37 import javax.swing.event.TableModelListener ; 38 import javax.swing.event.TableModelEvent ; 39 40 import org.netbeans.modules.j2ee.sun.dd.api.web.ManagerProperties; 41 import org.netbeans.modules.j2ee.sun.dd.api.web.StoreProperties; 42 import org.netbeans.modules.j2ee.sun.dd.api.web.SessionProperties; 43 import org.netbeans.modules.j2ee.sun.dd.api.web.CookieProperties; 44 import org.netbeans.modules.j2ee.sun.dd.api.web.WebProperty; 45 import org.netbeans.modules.j2ee.sun.share.configbean.ASDDVersion; 46 47 import org.netbeans.modules.j2ee.sun.share.configbean.ValidationError; 48 import org.netbeans.modules.j2ee.sun.share.configbean.WebAppRoot; 49 import org.netbeans.modules.j2ee.sun.share.configbean.SessionConfigSubBean; 50 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.TextMapping; 51 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTableModel; 52 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTablePanel; 53 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.HelpContext; 54 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicPropertyPanel; 55 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.PropertyListMapping; 56 57 62 public class WebAppSessionConfigPanel extends JPanel implements TableModelListener { 63 64 65 private static final ResourceBundle webappBundle = ResourceBundle.getBundle( 66 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.webapp.Bundle"); 68 private static final ResourceBundle commonBundle = ResourceBundle.getBundle( 69 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.Bundle"); 71 72 private static final TextMapping [] persistenceTypes = { 73 new TextMapping("", ""), new TextMapping("memory", webappBundle.getString("MEMORY_PERSISTENCE_TYPE")), new TextMapping("file", webappBundle.getString("FILE_PERSISTENCE_TYPE")), new TextMapping("ha", webappBundle.getString("HA_PERSISTENCE_TYPE")), new TextMapping("mmap", webappBundle.getString("MMAP_PERSISTENCE_TYPE")), new TextMapping("replicated", webappBundle.getString("REPLICATED_PERSISTENCE_TYPE")), new TextMapping("s1ws60", webappBundle.getString("S1WS60_PERSISTENCE_TYPE")), new TextMapping("custom", webappBundle.getString("CUSTOM_PERSISTENCE_TYPE")), }; 82 83 private WebAppRootCustomizer masterPanel; 84 85 private DefaultComboBoxModel persistenceTypeModel; 86 87 private GenericTableModel mgrPropertiesModel; 89 private GenericTablePanel mgrPropertiesPanel; 90 91 private GenericTableModel storePropertiesModel; 93 private GenericTablePanel storePropertiesPanel; 94 95 private GenericTableModel sessionPropertiesModel; 97 private GenericTablePanel sessionPropertiesPanel; 98 99 private GenericTableModel cookiePropertiesModel; 101 private GenericTablePanel cookiePropertiesPanel; 102 103 104 public WebAppSessionConfigPanel(WebAppRootCustomizer src) { 105 masterPanel = src; 106 107 initComponents(); 108 initUserComponents(); 109 } 110 111 116 private void initComponents() { 118 java.awt.GridBagConstraints gridBagConstraints; 119 120 sessionMgrPanel = new javax.swing.JPanel (); 121 jLblSessionManager = new javax.swing.JLabel (); 122 jLblPersistenceType = new javax.swing.JLabel (); 123 jComboPersistenceType = new javax.swing.JComboBox (); 124 propertyTabbedPanel = new javax.swing.JTabbedPane (); 125 126 setLayout(new java.awt.GridBagLayout ()); 127 128 getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_WebAppSessionConfigTab")); 129 getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_WebAppSessionConfigTab")); 130 sessionMgrPanel.setLayout(new java.awt.GridBagLayout ()); 131 132 jLblSessionManager.setText(webappBundle.getString("LBL_SessionManager")); 133 gridBagConstraints = new java.awt.GridBagConstraints (); 134 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 135 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 136 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 137 sessionMgrPanel.add(jLblSessionManager, gridBagConstraints); 138 139 jLblPersistenceType.setLabelFor(jComboPersistenceType); 140 jLblPersistenceType.setText(webappBundle.getString("LBL_PersistenceType_1")); 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 143 gridBagConstraints.insets = new java.awt.Insets (6, 6, 5, 0); 144 sessionMgrPanel.add(jLblPersistenceType, gridBagConstraints); 145 146 jComboPersistenceType.setPrototypeDisplayValue("Ay"); 147 jComboPersistenceType.addActionListener(new java.awt.event.ActionListener () { 148 public void actionPerformed(java.awt.event.ActionEvent evt) { 149 jComboPersistenceTypeActionPerformed(evt); 150 } 151 }); 152 153 gridBagConstraints = new java.awt.GridBagConstraints (); 154 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 155 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 156 gridBagConstraints.weightx = 1.0; 157 gridBagConstraints.insets = new java.awt.Insets (6, 6, 5, 5); 158 sessionMgrPanel.add(jComboPersistenceType, gridBagConstraints); 159 jComboPersistenceType.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_PersistenceType")); 160 jComboPersistenceType.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_PersistenceType")); 161 162 gridBagConstraints = new java.awt.GridBagConstraints (); 163 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 164 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 165 gridBagConstraints.weightx = 1.0; 166 add(sessionMgrPanel, gridBagConstraints); 167 168 propertyTabbedPanel.setTabPlacement(javax.swing.JTabbedPane.BOTTOM); 169 gridBagConstraints = new java.awt.GridBagConstraints (); 170 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 171 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 172 gridBagConstraints.weightx = 1.0; 173 gridBagConstraints.weighty = 1.0; 174 add(propertyTabbedPanel, gridBagConstraints); 175 176 } 178 private void jComboPersistenceTypeActionPerformed(java.awt.event.ActionEvent evt) { TextMapping type = (TextMapping) persistenceTypeModel.getSelectedItem(); 181 182 WebAppRoot theBean = masterPanel.getBean(); 183 if(theBean != null) { 184 SessionConfigSubBean sessonConfigBean = theBean.getSessionConfigBean(); 185 try { 186 sessonConfigBean.setPersistenceType(type.getXMLString()); 187 } catch(PropertyVetoException ex) { 188 persistenceTypeModel.setSelectedItem( 189 getPersistenceTypeMapping(sessonConfigBean.getPersistenceType())); 190 } 191 } 192 } 194 private javax.swing.JComboBox jComboPersistenceType; 196 private javax.swing.JLabel jLblPersistenceType; 197 private javax.swing.JLabel jLblSessionManager; 198 private javax.swing.JTabbedPane propertyTabbedPanel; 199 private javax.swing.JPanel sessionMgrPanel; 200 202 void initUserComponents() { 203 persistenceTypeModel = new DefaultComboBoxModel (); 205 for(int i = 0; i < persistenceTypes.length; i++) { 206 persistenceTypeModel.addElement(persistenceTypes[i]); 207 } 208 jComboPersistenceType.setModel(persistenceTypeModel); 209 210 214 ArrayList tableColumns = new ArrayList (3); 215 tableColumns.add(new GenericTableModel.AttributeEntry(WebProperty.NAME, 216 commonBundle.getString("LBL_Name"), true)); tableColumns.add(new GenericTableModel.AttributeEntry(WebProperty.VALUE, 218 commonBundle.getString("LBL_Value"), true)); tableColumns.add(new GenericTableModel.ValueEntry(WebProperty.DESCRIPTION, 220 commonBundle.getString("LBL_Description"))); 222 mgrPropertiesModel = new GenericTableModel(ManagerProperties.PROPERTY, WebAppRootCustomizer.webPropertyFactory, tableColumns); 224 mgrPropertiesPanel = new GenericTablePanel(mgrPropertiesModel, 225 webappBundle, "ManagerProperties", DynamicPropertyPanel.class, HelpContext.HELP_SESSIONCONFIG_MANAGER_POPUP, 227 PropertyListMapping.getPropertyList(PropertyListMapping.CONFIG_MANAGER_PROPERTIES)); 228 229 GridBagConstraints gridBagConstraints = new GridBagConstraints (); 230 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 231 gridBagConstraints.fill = GridBagConstraints.BOTH; 232 gridBagConstraints.weightx = 1.0; 233 gridBagConstraints.weighty = 1.0; 234 gridBagConstraints.insets = new Insets (6, 6, 0, 5); 235 JPanel holderPanel = new JPanel (); 236 holderPanel.setLayout(new GridBagLayout ()); 237 holderPanel.add(mgrPropertiesPanel, gridBagConstraints); 238 239 propertyTabbedPanel.addTab(webappBundle.getString("TAB_ManagerProperties"), holderPanel); 241 242 storePropertiesModel = new GenericTableModel(StoreProperties.PROPERTY, WebAppRootCustomizer.webPropertyFactory, tableColumns); 244 storePropertiesPanel = new GenericTablePanel(storePropertiesModel, 245 webappBundle, "StoreProperties", DynamicPropertyPanel.class, HelpContext.HELP_SESSIONCONFIG_STORE_POPUP, 247 PropertyListMapping.getPropertyList(PropertyListMapping.CONFIG_STORE_PROPERTIES)); 248 249 gridBagConstraints = new GridBagConstraints (); 250 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 251 gridBagConstraints.fill = GridBagConstraints.BOTH; 252 gridBagConstraints.weightx = 1.0; 253 gridBagConstraints.weighty = 1.0; 254 gridBagConstraints.insets = new Insets (6, 6, 0, 5); 255 holderPanel = new JPanel (); 256 holderPanel.setLayout(new GridBagLayout ()); 257 holderPanel.add(storePropertiesPanel, gridBagConstraints); 258 259 propertyTabbedPanel.addTab(webappBundle.getString("TAB_StoreProperties"), holderPanel); 261 262 sessionPropertiesModel = new GenericTableModel(SessionProperties.PROPERTY, WebAppRootCustomizer.webPropertyFactory, tableColumns); 264 sessionPropertiesPanel = new GenericTablePanel(sessionPropertiesModel, 265 webappBundle, "SessionProperties", DynamicPropertyPanel.class, HelpContext.HELP_SESSIONCONFIG_SESSION_POPUP, 267 PropertyListMapping.getPropertyList(PropertyListMapping.CONFIG_SESSION_PROPERTIES)); 268 269 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 (6, 6, 0, 5); 275 holderPanel = new JPanel (); 276 holderPanel.setLayout(new GridBagLayout ()); 277 holderPanel.add(sessionPropertiesPanel, gridBagConstraints); 278 279 propertyTabbedPanel.addTab(webappBundle.getString("TAB_SessionProperties"), holderPanel); 281 282 cookiePropertiesModel = new GenericTableModel(CookieProperties.PROPERTY, WebAppRootCustomizer.webPropertyFactory, tableColumns); 284 cookiePropertiesPanel = new GenericTablePanel(cookiePropertiesModel, 285 webappBundle, "CookieProperties", DynamicPropertyPanel.class, HelpContext.HELP_SESSIONCONFIG_COOKIE_POPUP, 287 PropertyListMapping.getPropertyList(PropertyListMapping.CONFIG_COOKIE_PROPERTIES)); 288 289 gridBagConstraints = new GridBagConstraints (); 290 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 291 gridBagConstraints.fill = GridBagConstraints.BOTH; 292 gridBagConstraints.weightx = 1.0; 293 gridBagConstraints.weighty = 1.0; 294 gridBagConstraints.insets = new Insets (6, 6, 0, 5); 295 holderPanel = new JPanel (); 296 holderPanel.setLayout(new GridBagLayout ()); 297 holderPanel.add(cookiePropertiesPanel, gridBagConstraints); 298 299 propertyTabbedPanel.addTab(webappBundle.getString("TAB_CookieProperties"), holderPanel); 301 } 302 303 public void addListeners() { 304 mgrPropertiesModel.addTableModelListener(this); 305 storePropertiesModel.addTableModelListener(this); 306 sessionPropertiesModel.addTableModelListener(this); 307 cookiePropertiesModel.addTableModelListener(this); 308 } 309 310 public void removeListeners() { 311 mgrPropertiesModel.removeTableModelListener(this); 312 storePropertiesModel.removeTableModelListener(this); 313 sessionPropertiesModel.removeTableModelListener(this); 314 cookiePropertiesModel.removeTableModelListener(this); 315 } 316 317 320 public void initFields(WebAppRoot theBean) { 321 ASDDVersion asVersion = theBean.getAppServerVersion(); 322 323 SessionConfigSubBean sessonConfigBean = theBean.getSessionConfigBean(); 324 persistenceTypeModel.setSelectedItem( 325 getPersistenceTypeMapping(sessonConfigBean.getPersistenceType())); 326 327 mgrPropertiesPanel.setModel(sessonConfigBean.getManagerProperties(), asVersion); 328 storePropertiesPanel.setModel(sessonConfigBean.getStoreProperties(), asVersion); 329 sessionPropertiesPanel.setModel(sessonConfigBean.getSessionProperties(), asVersion); 330 cookiePropertiesPanel.setModel(sessonConfigBean.getCookieProperties(), asVersion); 331 } 332 333 private TextMapping getPersistenceTypeMapping(String xmlKey) { 334 TextMapping result = persistenceTypes[0]; if(xmlKey == null) { 336 xmlKey = ""; } 338 339 for(int i = 0; i < persistenceTypes.length; i++) { 340 if(persistenceTypes[i].getXMLString().compareTo(xmlKey) == 0) { 341 result = persistenceTypes[i]; 342 break; 343 } 344 } 345 346 return result; 347 } 348 349 350 353 public void tableChanged(TableModelEvent e) { 354 WebAppRoot bean = masterPanel.getBean(); 355 if(bean != null) { 356 bean.setDirty(); 357 } 358 } 359 360 361 366 public String getHelpId() { 367 String result = "AS_CFG_SessionConfigurationManager"; 369 switch(propertyTabbedPanel.getSelectedIndex()) { 371 case 3: 372 result = "AS_CFG_SessionConfigurationCookie"; break; 374 case 2: 375 result = "AS_CFG_SessionConfigurationSession"; break; 377 case 1: 378 result = "AS_CFG_SessionConfigurationStore"; break; 380 } 381 382 return result; 383 } 384 385 390 public ValidationError.Partition getPartition() { 391 switch(propertyTabbedPanel.getSelectedIndex()) { 392 case 3: 393 return ValidationError.PARTITION_SESSION_COOKIE; 394 case 2: 395 return ValidationError.PARTITION_SESSION_SESSION; 396 case 1: 397 return ValidationError.PARTITION_SESSION_STORE; 398 default: 399 return ValidationError.PARTITION_SESSION_MANAGER; 400 } 401 } 402 } 403 | Popular Tags |