1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webapp; 26 27 import java.util.ArrayList ; 28 import java.util.ResourceBundle ; 29 30 import java.awt.GridBagConstraints ; 31 import java.awt.Insets ; 32 import java.beans.PropertyVetoException ; 33 34 import javax.swing.event.TableModelEvent ; 35 import javax.swing.event.TableModelListener ; 36 37 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 38 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageDestination; 39 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageDestinationRef; 40 import org.netbeans.modules.j2ee.sun.share.configbean.ASDDVersion; 41 42 import org.netbeans.modules.j2ee.sun.share.configbean.WebAppRoot; 43 import org.netbeans.modules.j2ee.sun.share.configbean.StorageBeanFactory; 44 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTableModel; 45 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.GenericTablePanel; 46 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.HelpContext; 47 48 52 public class WebAppMessagesPanel extends javax.swing.JPanel implements TableModelListener { 53 54 private static final ResourceBundle webappBundle = ResourceBundle.getBundle( 55 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.webapp.Bundle"); 57 private WebAppRootCustomizer masterPanel; 58 59 private GenericTableModel messageDestinationModel; 61 private GenericTablePanel messageDestinationPanel; 62 63 67 private boolean as90FeaturesVisible; 69 70 71 public WebAppMessagesPanel(WebAppRootCustomizer src) { 72 masterPanel = src; 73 74 initComponents(); 75 initUserComponents(); 76 } 77 78 83 private void initComponents() { 85 setLayout(new java.awt.GridBagLayout ()); 86 87 getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_WebAppMessagesTab")); 88 getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_WebAppMessagesTab")); 89 } 91 92 95 private void initUserComponents() { 96 97 as90FeaturesVisible = true; 98 99 102 ArrayList tableColumns = new ArrayList (2); 103 tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.MESSAGE_DESTINATION_NAME, 104 webappBundle, "MessageDestinationName", true, true)); tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.JNDI_NAME, 106 webappBundle, "JNDIName", true, false)); 108 messageDestinationModel = new GenericTableModel(messageDestinationFactory, tableColumns); 109 messageDestinationPanel = new GenericTablePanel(messageDestinationModel, 110 webappBundle, "MessageDestination", HelpContext.HELP_WEBAPP_MESSAGE_DESTINATION_POPUP); 112 113 GridBagConstraints gridBagConstraints = new GridBagConstraints (); 114 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 115 gridBagConstraints.fill = GridBagConstraints.BOTH; 116 gridBagConstraints.weightx = 1.0; 117 gridBagConstraints.weighty = 1.0; 118 gridBagConstraints.insets = new Insets (6, 6, 0, 5); 119 add(messageDestinationPanel, gridBagConstraints); 120 121 124 } 143 144 public void addListeners() { 145 messageDestinationModel.addTableModelListener(this); 146 } 148 149 public void removeListeners() { 150 messageDestinationModel.removeTableModelListener(this); 152 } 153 154 157 public void initFields(WebAppRoot bean) { 158 messageDestinationPanel.setModel(bean.getMessageDestinations(), bean.getAppServerVersion()); 159 160 if(ASDDVersion.SUN_APPSERVER_9_0.compareTo(bean.getAppServerVersion()) <= 0) { 161 showAS90Fields(); 162 } 164 } 165 166 private void showAS90Fields() { 167 if(!as90FeaturesVisible) { 168 as90FeaturesVisible = true; 169 } 171 } 172 173 private void hideAS90Fields() { 174 if(as90FeaturesVisible) { 175 as90FeaturesVisible = false; 176 } 178 } 179 180 183 public void tableChanged(TableModelEvent e) { 184 WebAppRoot bean = masterPanel.getBean(); 185 if(bean != null) { 186 try { 187 Object eventSource = e.getSource(); 188 if(eventSource == messageDestinationModel) { 189 bean.setMessageDestinations(messageDestinationModel.getData()); 190 bean.firePropertyChange("messageDestination", null, messageDestinationModel.getData()); 191 } 195 } catch(PropertyVetoException ex) { 196 } 198 } 199 } 200 201 static GenericTableModel.ParentPropertyFactory messageDestinationFactory = 204 new GenericTableModel.ParentPropertyFactory() { 205 public CommonDDBean newParentProperty(ASDDVersion asVersion) { 206 return StorageBeanFactory.getStorageBeanFactory(asVersion).createMessageDestination(); 207 } 208 }; 209 210 } 217 | Popular Tags |