KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > ui > WSAppExtAttributesPanel


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 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui;
20
21 import org.netbeans.modules.j2ee.websphere6.dd.beans.DDXmiConstants;
22 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSAppExt;
23 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
24 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel;
25 import org.netbeans.modules.xml.multiview.ui.SectionView;
26 import org.netbeans.modules.xml.multiview.Error;
27
28 /**
29  *
30  * @author dlm198383
31  */

32 public class WSAppExtAttributesPanel extends SectionInnerPanel
33         implements java.awt.event.ItemListener JavaDoc, javax.swing.event.ChangeListener JavaDoc, DDXmiConstants{
34     
35     WSAppExt appext;
36     WSMultiViewDataObject dObj;
37     
38     /** Creates new form WSAppExtAttributesPanel */
39     public WSAppExtAttributesPanel(SectionView view, WSMultiViewDataObject dObj, WSAppExt appext) {
40         super(view);
41         this.dObj=dObj;
42         this.appext=appext;
43         initComponents();
44         idField.setText(appext.getXmiId());
45         hrefField.setText(appext.getApplicationHref());
46         reloadIntervalCheckBox.setSelected(appext.getReload());
47         shareSessionCheckBox.setSelected(appext.getSharedSession());
48         reloadIntervalSpinner.setModel(new javax.swing.SpinnerNumberModel JavaDoc(0,0,600,1));
49         reloadIntervalSpinner.setValue(new Integer JavaDoc(appext.getReloadInterval()));
50         reloadIntervalCheckBox.addItemListener(this);
51         shareSessionCheckBox.addItemListener(this);
52         reloadIntervalSpinner.addChangeListener(this);
53         addModifier(hrefField);
54         addModifier(idField);
55         
56         addValidatee(hrefField);
57         addValidatee(idField);
58         
59         
60         ModuleExtensionTableModel model = new ModuleExtensionTableModel(dObj.getModelSynchronizer());
61         ModuleExtensionTablePanel ptp= new ModuleExtensionTablePanel(dObj, model);
62         ptp.setModel(appext,appext.getModuleExtensions());
63         java.awt.GridBagConstraints JavaDoc gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
64         gridBagConstraints.gridx = 0;
65         gridBagConstraints.gridy = 10;
66         //gridBagConstraints.gridwidth = 4;
67
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
68         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
69         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 0);
70         gridBagConstraints.weightx = 1.0;
71         jPanel1.add(ptp,gridBagConstraints);
72     }
73     public void setValue(javax.swing.JComponent JavaDoc source,Object JavaDoc value) {
74         if(source==hrefField) {
75             appext.setApplicationHref((String JavaDoc)value);
76         }
77         if(source==idField) {
78             appext.setXmiId((String JavaDoc)value);
79         }
80     }
81     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) {
82     }
83     
84     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
85         if("Name".equals(errorId)) return idField;
86         if("Application Id".equals(errorId)) return hrefField;
87         return null;
88     }
89     public void stateChanged(javax.swing.event.ChangeEvent JavaDoc evt) {
90         appext.setReloadInterval(reloadIntervalSpinner.getValue().toString());
91         dObj.modelUpdatedFromUI();
92     }
93     public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
94     dObj.setChangedFromUI(true);
95         if(evt.getSource()==reloadIntervalCheckBox) {
96             appext.setReload(reloadIntervalCheckBox.isSelected());
97             if(reloadIntervalCheckBox.isSelected()) {
98                 appext.setReloadInterval(reloadIntervalSpinner.getValue().toString());
99                 reloadIntervalSpinner.setEnabled(true);
100             } else {
101                 appext.setReloadInterval(null);
102                 reloadIntervalSpinner.setEnabled(false);
103             }
104         } else if(evt.getSource()==shareSessionCheckBox) {
105             appext.setSharedSession(shareSessionCheckBox.isSelected());
106         }
107         dObj.modelUpdatedFromUI();
108     dObj.setChangedFromUI(false);
109     }
110     
111     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
112         if (comp==idField) {
113             String JavaDoc val = (String JavaDoc)value;
114             if (val.length()==0) {
115                 getSectionView()
116                 .getErrorPanel()
117                 .setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "Name", comp));
118                 return;
119             }
120             getSectionView().getErrorPanel().clearError();
121         }
122         if (comp==hrefField) {
123             String JavaDoc val = (String JavaDoc)value;
124             if (val.length()==0) {
125                 getSectionView()
126                 .getErrorPanel()
127                 .setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "Application Id", comp));
128                 return;
129             }
130             getSectionView().getErrorPanel().clearError();
131         }
132     }
133     
134     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
135         if (idField==source) {
136             idField.setText(appext.getXmiId());
137         } else if(hrefField==source) {
138             hrefField.setText(appext.getApplicationHref());
139         }
140         
141     }
142     /** This will be called before model is changed from this panel
143      */

144     
145     protected void startUIChange() {
146         dObj.setChangedFromUI(true);
147     }
148     
149     /** This will be called after model is changed from this panel
150      */

151     
152     protected void endUIChange() {
153         dObj.modelUpdatedFromUI();
154         dObj.setChangedFromUI(false);
155     }
156     
157     /** This method is called from within the constructor to
158      * initialize the form.
159      * WARNING: Do NOT modify this code. The content of this method is
160      * always regenerated by the Form Editor.
161      */

162     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
163
private void initComponents() {
164         jLabel1 = new javax.swing.JLabel JavaDoc();
165         idField = new javax.swing.JTextField JavaDoc();
166         shareSessionCheckBox = new javax.swing.JCheckBox JavaDoc();
167         reloadIntervalCheckBox = new javax.swing.JCheckBox JavaDoc();
168         reloadIntervalSpinner = new javax.swing.JSpinner JavaDoc();
169         jLabel2 = new javax.swing.JLabel JavaDoc();
170         hrefField = new javax.swing.JTextField JavaDoc();
171         jPanel1 = new javax.swing.JPanel JavaDoc();
172         jLabel3 = new javax.swing.JLabel JavaDoc();
173
174         jLabel1.setText("Name:");
175
176         shareSessionCheckBox.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_SharedSession"));
177         shareSessionCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
178         shareSessionCheckBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
179
180         reloadIntervalCheckBox.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_ReloadInterval"));
181         reloadIntervalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
182         reloadIntervalCheckBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
183
184         reloadIntervalSpinner.setFont(new java.awt.Font JavaDoc("Courier", 0, 12));
185
186         jLabel2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_ApplicationId"));
187
188         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
189
190         jLabel3.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_ModuleExtensions"));
191
192         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
193         this.setLayout(layout);
194         layout.setHorizontalGroup(
195             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
196             .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
197                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
198                     .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
199                         .addContainerGap()
200                         .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE))
201                     .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
202                         .add(20, 20, 20)
203                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
204                             .add(shareSessionCheckBox)
205                             .add(layout.createSequentialGroup()
206                                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
207                                     .add(jLabel2)
208                                     .add(jLabel1)
209                                     .add(reloadIntervalCheckBox))
210                                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
211                                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
212                                     .add(hrefField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
213                                     .add(reloadIntervalSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
214                                     .add(layout.createSequentialGroup()
215                                         .add(idField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
216                                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))))))
217                     .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
218                         .addContainerGap()
219                         .add(jLabel3)))
220                 .addContainerGap())
221         );
222         layout.setVerticalGroup(
223             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
224             .add(layout.createSequentialGroup()
225                 .addContainerGap()
226                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
227                     .add(jLabel1)
228                     .add(idField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
229                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
230                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
231                     .add(hrefField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
232                     .add(jLabel2))
233                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
234                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
235                     .add(reloadIntervalCheckBox)
236                     .add(reloadIntervalSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
237                 .add(11, 11, 11)
238                 .add(shareSessionCheckBox)
239                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 31, Short.MAX_VALUE)
240                 .add(jLabel3)
241                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
242                 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
243                 .addContainerGap())
244         );
245     }// </editor-fold>//GEN-END:initComponents
246

247     
248     // Variables declaration - do not modify//GEN-BEGIN:variables
249
private javax.swing.JTextField JavaDoc hrefField;
250     private javax.swing.JTextField JavaDoc idField;
251     private javax.swing.JLabel JavaDoc jLabel1;
252     private javax.swing.JLabel JavaDoc jLabel2;
253     private javax.swing.JLabel JavaDoc jLabel3;
254     private javax.swing.JPanel JavaDoc jPanel1;
255     private javax.swing.JCheckBox JavaDoc reloadIntervalCheckBox;
256     private javax.swing.JSpinner JavaDoc reloadIntervalSpinner;
257     private javax.swing.JCheckBox JavaDoc shareSessionCheckBox;
258     // End of variables declaration//GEN-END:variables
259

260 }
261
Popular Tags