KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > ejbmodule > EjbJarMessagesPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * EjbJarMessagesPanel.java
21  *
22  * Created on May 25, 2006, 4:56 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule;
26
27 import java.util.ArrayList JavaDoc;
28 import java.util.ResourceBundle JavaDoc;
29
30 import java.awt.GridBagConstraints JavaDoc;
31 import java.awt.Insets JavaDoc;
32 import java.beans.PropertyVetoException JavaDoc;
33
34 import javax.swing.event.TableModelEvent JavaDoc;
35 import javax.swing.event.TableModelListener JavaDoc;
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 /**
50  *
51  * @author Peter Williams
52  */

53 public class EjbJarMessagesPanel extends javax.swing.JPanel JavaDoc implements TableModelListener JavaDoc {
54     
55     private static final ResourceBundle JavaDoc ejbjarBundle = ResourceBundle.getBundle(
56         "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); // NOI18N
57

58     private EjbJarRootCustomizer masterPanel;
59     
60     // Table for editing MessageDestination entries
61
private GenericTableModel messageDestinationModel;
62     private GenericTablePanel messageDestinationPanel;
63
64     // Table for editing MessageDestinationRef entries
65
// private GenericTableModel messageDestinationRefModel;
66
// private GenericTablePanel messageDestinationRefPanel;
67

68     // true if AS 9.0+ fields are visible.
69
private boolean as90FeaturesVisible;
70     
71     /**
72      * Creates new form EjbJarMessagesPanel
73      */

74     public EjbJarMessagesPanel(EjbJarRootCustomizer src) {
75         masterPanel = src;
76         
77         initComponents();
78         initUserComponents();
79     }
80     
81     /** This method is called from within the constructor to
82      * initialize the form.
83      * WARNING: Do NOT modify this code. The content of this method is
84      * always regenerated by the Form Editor.
85      */

86     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
87
private void initComponents() {
88
89         setLayout(new java.awt.GridBagLayout JavaDoc());
90
91         getAccessibleContext().setAccessibleName(ejbjarBundle.getString("ACSN_EjbJarMessagesTab"));
92         getAccessibleContext().setAccessibleDescription(ejbjarBundle.getString("ACSD_EjbJarMessagesTab"));
93     }// </editor-fold>//GEN-END:initComponents
94

95     
96     // Variables declaration - do not modify//GEN-BEGIN:variables
97
// End of variables declaration//GEN-END:variables
98

99     private void initUserComponents() {
100         
101         as90FeaturesVisible = true;
102         
103         /* Add message destination table panel :
104          * TableEntry list has two properties: destination name, jndi name
105          */

106         ArrayList JavaDoc tableColumns = new ArrayList JavaDoc(2);
107         tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.MESSAGE_DESTINATION_NAME,
108             ejbjarBundle, "MessageDestinationName", true, true)); // NOI18N - property name
109
tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.JNDI_NAME,
110             ejbjarBundle, "JNDIName", true, false)); // NOI18N - property name
111

112         messageDestinationModel = new GenericTableModel(messageDestinationFactory, tableColumns);
113         messageDestinationPanel = new GenericTablePanel(messageDestinationModel,
114             ejbjarBundle, "MessageDestination", // NOI18N - property name
115
HelpContext.HELP_WEBAPP_MESSAGE_DESTINATION_POPUP);
116         
117         GridBagConstraints JavaDoc gridBagConstraints = new GridBagConstraints JavaDoc();
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 JavaDoc(6, 6, 0, 5);
123         add(messageDestinationPanel, gridBagConstraints);
124         
125         /* Add message destination ref table panel :
126          * TableEntry list has two properties: destination ref name, jndi name
127          */

128 // tableColumns = new ArrayList(2);
129
// tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestinationRef.MESSAGE_DESTINATION_REF_NAME,
130
// webappBundle, "MessageDestinationRefName", true, true)); // NOI18N - property name
131
// tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestinationRef.JNDI_NAME,
132
// webappBundle, "JNDIName", true, false)); // NOI18N - property name
133
//
134
// messageDestinationRefModel = new GenericTableModel(messageDestinationRefFactory, tableColumns);
135
// messageDestinationRefPanel = new GenericTablePanel(messageDestinationRefModel,
136
// webappBundle, "MessageDestinationRef", // NOI18N - property name
137
// HelpContext.HELP_WEBAPP_MESSAGE_DESTINATION_REF_POPUP);
138
//
139
// gridBagConstraints = new GridBagConstraints();
140
// gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
141
// gridBagConstraints.fill = GridBagConstraints.BOTH;
142
// gridBagConstraints.weightx = 1.0;
143
// gridBagConstraints.weighty = 1.0;
144
// gridBagConstraints.insets = new Insets(0, 6, 0, 5);
145
// add(messageDestinationRefPanel, gridBagConstraints);
146
}
147     
148     public void addListeners() {
149         messageDestinationModel.addTableModelListener(this);
150 // messageDestinationRefModel.addTableModelListener(this);
151
}
152     
153     public void removeListeners() {
154 // messageDestinationRefModel.removeTableModelListener(this);
155
messageDestinationModel.removeTableModelListener(this);
156     }
157     
158     /** Initialization of all the fields in this panel from the bean that
159      * was passed in.
160      */

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 // messageDestinationRefPanel.setModel(bean.getMessageDestinationRefs(), bean.getAppServerVersion());
167
}
168     }
169     
170     private void showAS90Fields() {
171         if(!as90FeaturesVisible) {
172             as90FeaturesVisible = true;
173 // messageDestinationRefPanel.setVisible(true);
174
}
175     }
176     
177     private void hideAS90Fields() {
178         if(as90FeaturesVisible) {
179             as90FeaturesVisible = false;
180 // messageDestinationRefPanel.setVisible(false);
181
}
182     }
183     
184     /** -----------------------------------------------------------------------
185      * Implementation of javax.swing.event.TableModelListener
186      */

187     public void tableChanged(TableModelEvent JavaDoc e) {
188         EjbJarRoot bean = masterPanel.getBean();
189         if(bean != null) {
190             try {
191                 Object JavaDoc eventSource = e.getSource();
192                 if(eventSource == messageDestinationModel) {
193                     bean.setMessageDestinations(messageDestinationModel.getData());
194                     bean.firePropertyChange("messageDestination", null, messageDestinationModel.getData());
195 // } else if(eventSource == messageDestinationRefModel) {
196
// bean.setMessageDestinationRefs(messageDestinationRefModel.getData());
197
// bean.firePropertyChange("messageDestinationRef", null, messageDestinationRefModel.getData());
198
}
199             } catch(PropertyVetoException JavaDoc ex) {
200                 // FIXME undo whatever changed... how?
201
}
202         }
203     }
204     
205     // New for migration to sun DD API model. Factory instance to pass to generic table model
206
// to allow it to create messageDestination beans.
207
static GenericTableModel.ParentPropertyFactory messageDestinationFactory =
208         new GenericTableModel.ParentPropertyFactory() {
209             public CommonDDBean newParentProperty(ASDDVersion asVersion) {
210                 return StorageBeanFactory.getStorageBeanFactory(asVersion).createMessageDestination();
211             }
212         };
213         
214 // static GenericTableModel.ParentPropertyFactory messageDestinationRefFactory =
215
// new GenericTableModel.ParentPropertyFactory() {
216
// public CommonDDBean newParentProperty(ASDDVersion asVersion) {
217
// return StorageBeanFactory.getStorageBeanFactory(asVersion).createMessageDestinationRef();
218
// }
219
// };
220
}
221
Popular Tags