KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ddloaders > web > multiview > OverviewPanel


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 package org.netbeans.modules.j2ee.ddloaders.web.multiview;
21
22 import org.netbeans.modules.j2ee.dd.api.web.JspPropertyGroup;
23 import org.netbeans.modules.j2ee.dd.api.web.*;
24 import org.netbeans.modules.j2ee.ddloaders.web.*;
25 import org.netbeans.modules.xml.multiview.ui.*;
26 import org.netbeans.modules.xml.multiview.Utils;
27 import org.netbeans.modules.xml.multiview.Error;
28 import org.netbeans.api.project.SourceGroup;
29
30 /**
31  * @author mkuchtiak
32  */

33 public class OverviewPanel extends SectionInnerPanel implements java.awt.event.ItemListener JavaDoc {
34     DDDataObject dObj;
35     WebApp webApp;
36     /** Creates new form JspPGPanel */
37     public OverviewPanel(SectionView sectionView, DDDataObject dObj) {
38         super(sectionView);
39         this.dObj=dObj;
40         webApp=dObj.getWebApp();
41         initComponents();
42         
43         // Display Name
44
dispNameTF.setText(webApp.getDefaultDisplayName());
45         addModifier(dispNameTF);
46         
47         // Description
48
Utils.makeTextAreaLikeTextField(descriptionTA,dispNameTF);
49         descriptionTA.setText(webApp.getDefaultDescription());
50         addModifier(descriptionTA);
51         
52         // Distributable
53
jCheckBox1.setSelected(webApp.isDistributable());
54         jCheckBox1.addItemListener(this);
55         
56         // Session Timeout
57
stTF.setText(getSessionTimeout());
58         addValidatee(stTF);
59         
60     }
61     
62     private String JavaDoc getSessionTimeout() {
63         SessionConfig config = webApp.getSingleSessionConfig();
64         if (config==null) return "";
65         java.math.BigInteger JavaDoc timeout = config.getSessionTimeout();
66         return (timeout==null?"":timeout.toString());
67     }
68     
69     private void setSessionTimeout(String JavaDoc text) {
70         String JavaDoc val = text.trim();
71         SessionConfig config = webApp.getSingleSessionConfig();
72         if (config!=null) {
73             if (text.length()==0) webApp.setSessionConfig(null);
74             else config.setSessionTimeout(new java.math.BigInteger JavaDoc(val));
75         } else if (text.length()>0) {
76             try {
77                 SessionConfig newConfig = (SessionConfig)webApp.createBean("SessionConfig");
78                 newConfig.setSessionTimeout(new java.math.BigInteger JavaDoc(val));
79                 webApp.setSessionConfig(newConfig);
80             } catch (ClassNotFoundException JavaDoc ex){}
81         }
82
83     }
84     
85     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
86         return null;
87     }
88
89     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
90         if (comp==stTF) {
91             String JavaDoc text = value.trim();
92             if (text.length()==0) {
93                 getSectionView().getErrorPanel().clearError();
94             } else {
95                 java.math.BigInteger JavaDoc st=null;
96                 try {
97                     st = new java.math.BigInteger JavaDoc(text);
98                 } catch (NumberFormatException JavaDoc ex) {}
99                 if (st==null) {
100                     getSectionView().getErrorPanel().setError(new Error JavaDoc(Error.TYPE_FATAL, Error.ERROR_MESSAGE, "Invalid Value : "+text, stTF));
101                     return;
102                 }
103                 getSectionView().getErrorPanel().clearError();
104             }
105         }
106     }
107     
108     public void setValue(javax.swing.JComponent JavaDoc source, Object JavaDoc value) {
109         String JavaDoc text = ((String JavaDoc)value).trim();
110         if (source==dispNameTF) {
111             webApp.setDisplayName(text.length()==0?null:text);
112         } else if (source==descriptionTA) {
113             webApp.setDescription(text.length()==0?null:text);
114         } else if (source==stTF) {
115             setSessionTimeout(text);
116         }
117     }
118     
119     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
120         if (source==stTF) {
121             stTF.setText(getSessionTimeout());
122         }
123     }
124     
125     public void linkButtonPressed(Object JavaDoc obj, String JavaDoc id) {
126     }
127     
128     
129     /** This method is called from within the constructor to
130      * initialize the form.
131      * WARNING: Do NOT modify this code. The content of this method is
132      * always regenerated by the Form Editor.
133      */

134     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
135
private void initComponents() {
136         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
137
138         filler = new javax.swing.JPanel JavaDoc();
139         dispNameLabel = new javax.swing.JLabel JavaDoc();
140         dispNameTF = new javax.swing.JTextField JavaDoc();
141         descriptionLabel = new javax.swing.JLabel JavaDoc();
142         descriptionTA = new javax.swing.JTextArea JavaDoc();
143         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
144         stLabel = new javax.swing.JLabel JavaDoc();
145         stTF = new javax.swing.JTextField JavaDoc();
146         jLabel1 = new javax.swing.JLabel JavaDoc();
147
148         setLayout(new java.awt.GridBagLayout JavaDoc());
149
150         filler.setOpaque(false);
151         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
152         gridBagConstraints.gridx = 2;
153         gridBagConstraints.gridy = 0;
154         gridBagConstraints.gridwidth = 2;
155         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
156         gridBagConstraints.weightx = 1.0;
157         add(filler, gridBagConstraints);
158
159         dispNameLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_displayName_mnem").charAt(0));
160         dispNameLabel.setLabelFor(dispNameTF);
161         dispNameLabel.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_displayName"));
162         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
163         gridBagConstraints.gridx = 0;
164         gridBagConstraints.gridy = 0;
165         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 10);
167         add(dispNameLabel, gridBagConstraints);
168
169         dispNameTF.setColumns(30);
170         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
171         gridBagConstraints.gridx = 1;
172         gridBagConstraints.gridy = 0;
173         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
174         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
175         add(dispNameTF, gridBagConstraints);
176
177         descriptionLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_description_mnem").charAt(0));
178         descriptionLabel.setLabelFor(descriptionTA);
179         descriptionLabel.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_description"));
180         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
181         gridBagConstraints.gridx = 0;
182         gridBagConstraints.gridy = 1;
183         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
184         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 10);
185         add(descriptionLabel, gridBagConstraints);
186
187         descriptionTA.setRows(3);
188         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
189         gridBagConstraints.gridx = 1;
190         gridBagConstraints.gridy = 1;
191         gridBagConstraints.gridwidth = 3;
192         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
193         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 10);
194         add(descriptionTA, gridBagConstraints);
195
196         jCheckBox1.setMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_distributable_mnem").charAt(0));
197         jCheckBox1.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_distributable"));
198         jCheckBox1.setOpaque(false);
199         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
200         gridBagConstraints.gridx = 1;
201         gridBagConstraints.gridy = 2;
202         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
203         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
204         add(jCheckBox1, gridBagConstraints);
205
206         stLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_sessionTimeout_mnem").charAt(0));
207         stLabel.setLabelFor(stTF);
208         stLabel.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_sessionTimeout"));
209         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
210         gridBagConstraints.gridx = 0;
211         gridBagConstraints.gridy = 3;
212         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
213         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 5, 10);
214         add(stLabel, gridBagConstraints);
215
216         stTF.setColumns(5);
217         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
218         gridBagConstraints.gridx = 1;
219         gridBagConstraints.gridy = 3;
220         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
221         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 5, 0);
222         add(stTF, gridBagConstraints);
223
224         jLabel1.setText(org.openide.util.NbBundle.getMessage(OverviewPanel.class, "LBL_min"));
225         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
226         gridBagConstraints.gridx = 2;
227         gridBagConstraints.gridy = 3;
228         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
229         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 0);
230         add(jLabel1, gridBagConstraints);
231
232     }
233     // </editor-fold>//GEN-END:initComponents
234

235     
236     // Variables declaration - do not modify//GEN-BEGIN:variables
237
private javax.swing.JLabel JavaDoc descriptionLabel;
238     private javax.swing.JTextArea JavaDoc descriptionTA;
239     private javax.swing.JLabel JavaDoc dispNameLabel;
240     private javax.swing.JTextField JavaDoc dispNameTF;
241     private javax.swing.JPanel JavaDoc filler;
242     private javax.swing.JCheckBox JavaDoc jCheckBox1;
243     private javax.swing.JLabel JavaDoc jLabel1;
244     private javax.swing.JLabel JavaDoc stLabel;
245     private javax.swing.JTextField JavaDoc stTF;
246     // End of variables declaration//GEN-END:variables
247

248     public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
249         // TODO add your handling code here:
250
if (evt.getSource() == jCheckBox1) {
251             dObj.modelUpdatedFromUI();
252             dObj.setChangedFromUI(true);
253             webApp.setDistributable(jCheckBox1.isSelected());
254             dObj.setChangedFromUI(false);
255         }
256     }
257     
258     /** This will be called before model is changed from this panel
259      */

260     protected void startUIChange() {
261         dObj.setChangedFromUI(true);
262     }
263     
264     /** This will be called after model is changed from this panel
265      */

266     protected void endUIChange() {
267         dObj.modelUpdatedFromUI();
268         dObj.setChangedFromUI(false);
269     }
270 }
271
Popular Tags