KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > webapp > WebAppMessagesPanel


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  * WebAppGeneralPanel.java
21  *
22  * Created on November 5, 2003, 4:56 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webapp;
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.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 /**
49  *
50  * @author Peter Williams
51  */

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

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

67     // true if AS 9.0+ fields are visible.
68
private boolean as90FeaturesVisible;
69     
70     /** Creates new form WebAppMessagesPanel */
71     public WebAppMessagesPanel(WebAppRootCustomizer src) {
72         masterPanel = src;
73         
74         initComponents();
75         initUserComponents();
76     }
77     
78     /** This method is called from within the constructor to
79      * initialize the form.
80      * WARNING: Do NOT modify this code. The content of this method is
81      * always regenerated by the Form Editor.
82      */

83     private void initComponents() {//GEN-BEGIN:initComponents
84

85         setLayout(new java.awt.GridBagLayout JavaDoc());
86
87         getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_WebAppMessagesTab"));
88         getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_WebAppMessagesTab"));
89     }//GEN-END:initComponents
90

91     
92     // Variables declaration - do not modify//GEN-BEGIN:variables
93
// End of variables declaration//GEN-END:variables
94

95     private void initUserComponents() {
96         
97         as90FeaturesVisible = true;
98         
99         /* Add message destination table panel :
100          * TableEntry list has two properties: destination name, jndi name
101          */

102         ArrayList JavaDoc tableColumns = new ArrayList JavaDoc(2);
103         tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.MESSAGE_DESTINATION_NAME,
104             webappBundle, "MessageDestinationName", true, true)); // NOI18N - property name
105
tableColumns.add(new GenericTableModel.ValueEntry(null, MessageDestination.JNDI_NAME,
106             webappBundle, "JNDIName", true, false)); // NOI18N - property name
107

108         messageDestinationModel = new GenericTableModel(messageDestinationFactory, tableColumns);
109         messageDestinationPanel = new GenericTablePanel(messageDestinationModel,
110             webappBundle, "MessageDestination", // NOI18N - property name
111
HelpContext.HELP_WEBAPP_MESSAGE_DESTINATION_POPUP);
112         
113         GridBagConstraints JavaDoc gridBagConstraints = new GridBagConstraints JavaDoc();
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 JavaDoc(6, 6, 0, 5);
119         add(messageDestinationPanel, gridBagConstraints);
120         
121         /* Add message destination ref table panel :
122          * TableEntry list has two properties: destination ref name, jndi name
123          */

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

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

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