| 1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule; 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.EjbJarRoot; 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 49 53 public class EjbJarMessagesPanel extends javax.swing.JPanel implements TableModelListener { 54 55 private static final ResourceBundle ejbjarBundle = ResourceBundle.getBundle( 56 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); 58 private EjbJarRootCustomizer masterPanel; 59 60 private GenericTableModel messageDestinationModel; 62 private GenericTablePanel messageDestinationPanel; 63 64 68 private boolean as90FeaturesVisible; 70 71 74 public EjbJarMessagesPanel(EjbJarRootCustomizer src) { 75 masterPanel = src; 76 77 initComponents(); 78 initUserComponents(); 79 } 80 81 86 private void initComponents() { 88 89 setLayout(new java.awt.GridBagLayout ()); 90 91 getAccessibleContext().setAccessibleName(ejbjarBundle.getString("ACSN_EjbJarMessagesTab")); 92 getAccessibleContext().setAccessibleDescription(ejbjarBundle.getString("ACSD_EjbJarMessagesTab")); 93 } 95 96 99 private void initUserComponents() { 100 101 as90FeaturesVisible = true; 102 103 106 ArrayList tableColumns = new ArrayList (2); 107 tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.MESSAGE_DESTINATION_NAME, 108 ejbjarBundle, "MessageDestinationName", true, true)); tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.JNDI_NAME, 110 ejbjarBundle, "JNDIName", true, false)); 112 messageDestinationModel = new GenericTableModel(messageDestinationFactory, tableColumns); 113 messageDestinationPanel = new GenericTablePanel(messageDestinationModel, 114 ejbjarBundle, "MessageDestination", HelpContext.HELP_WEBAPP_MESSAGE_DESTINATION_POPUP); 116 117 GridBagConstraints gridBagConstraints = new GridBagConstraints (); 118 gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; 119 gridBagConstraints.fill = GridBagConstraints.BOTH; 120 gridBagConstraints.weightx = 1.0; 121 gridBagConstraints.weighty = 1.0; 122 gridBagConstraints.insets = new Insets (6, 6, 0, 5); 123 add(messageDestinationPanel, gridBagConstraints); 124 125 128 } 147 148 public void addListeners() { 149 messageDestinationModel.addTableModelListener(this); 150 } 152 153 public void removeListeners() { 154 messageDestinationModel.removeTableModelListener(this); 156 } 157 158 161 public void initFields(EjbJarRoot bean) { 162 messageDestinationPanel.setModel(bean.getMessageDestinations(), bean.getAppServerVersion()); 163 164 if(ASDDVersion.SUN_APPSERVER_9_0.compareTo(bean.getAppServerVersion()) <= 0) { 165 showAS90Fields(); 166 } 168 } 169 170 private void showAS90Fields() { 171 if(!as90FeaturesVisible) { 172 as90FeaturesVisible = true; 173 } 175 } 176 177 private void hideAS90Fields() { 178 if(as90FeaturesVisible) { 179 as90FeaturesVisible = false; 180 } 182 } 183 184 187 public void tableChanged(TableModelEvent e) { 188 EjbJarRoot bean = masterPanel.getBean(); 189 if(bean != null) { 190 try { 191 Object eventSource = e.getSource(); 192 if(eventSource == messageDestinationModel) { 193 bean.setMessageDestinations(messageDestinationModel.getData()); 194 bean.firePropertyChange("messageDestination", null, messageDestinationModel.getData()); 195 } 199 } catch(PropertyVetoException ex) { 200 } 202 } 203 } 204 205 static GenericTableModel.ParentPropertyFactory messageDestinationFactory = 208 new GenericTableModel.ParentPropertyFactory() { 209 public CommonDDBean newParentProperty(ASDDVersion asVersion) { 210 return StorageBeanFactory.getStorageBeanFactory(asVersion).createMessageDestination(); 211 } 212 }; 213 214 } 221 | Popular Tags |