KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > gui > DataCollectionPanel


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * DataCollectionPanel.java
26  *
27  * Created on August 27, 2003, 5:04 PM
28  */

29
30 package com.sun.enterprise.tools.upgrade.gui;
31
32 /**
33  *
34  * @author prakash
35  */

36 import javax.swing.JFileChooser JavaDoc;
37 import com.sun.enterprise.tools.upgrade.gui.util.*;
38 import java.util.logging.*;
39 import com.sun.enterprise.util.i18n.StringManager;
40 import com.sun.enterprise.tools.upgrade.common.*;
41 import com.sun.enterprise.tools.upgrade.logging.*;
42
43 public class DataCollectionPanel extends javax.swing.JPanel JavaDoc {
44
45     private FlowLabel flowContentLabel;
46     private javax.swing.JLabel JavaDoc sourceDirLabel;
47     private javax.swing.JTextField JavaDoc sourceDirTextField;
48     private javax.swing.JButton JavaDoc sourceDirectoryBrowseButton;
49     private javax.swing.JButton JavaDoc destDirBrowseButton;
50     private javax.swing.JLabel JavaDoc destDirLabel;
51     private javax.swing.JTextField JavaDoc destDirTextField;
52     private javax.swing.JPanel JavaDoc containerPanel;
53     private javax.swing.JCheckBox JavaDoc upgradeCertificates;
54     private javax.swing.JPasswordField JavaDoc adminPWTextField;
55     private javax.swing.JTextField JavaDoc adminUserTextField;
56     private javax.swing.JPasswordField JavaDoc masterPWTextField;
57     
58     private CommonInfoModel commonInfoModel;
59
60     private JFileChooser JavaDoc fileChooser = null;
61     private java.util.Vector JavaDoc dialogListeners = new java.util.Vector JavaDoc();
62     
63     private StringManager stringManager = StringManager.getManager("com.sun.enterprise.tools.upgrade.gui");
64     private Logger logger = com.sun.enterprise.tools.upgrade.common.CommonInfoModel.getDefaultLogger();
65     
66     /** Creates new form DataCollectionPanel */
67     public DataCollectionPanel(CommonInfoModel coInfoModel) {
68         this.commonInfoModel = coInfoModel;
69         initialize();
70     }
71     private void initialize(){
72     initComponents();
73         this.setLayout(new java.awt.BorderLayout JavaDoc());
74         HeaderPanel headerPanel = new HeaderPanel(stringManager.getString("upgrade.gui.detailspanel.headerPanel"));
75         headerPanel.setInsets(new java.awt.Insets JavaDoc(12, 10, 5, 10));
76         add(headerPanel, "North");
77         add(containerPanel, "Center");
78         sourceDirectoryBrowseButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
79             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
80                 sourceActionPerformed(evt);
81             }
82         });
83         destDirBrowseButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
84             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
85                 destActionPerformed(evt);
86             }
87         });
88         getfileChooser().setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
89         java.awt.event.KeyAdapter JavaDoc keyAdapter = new java.awt.event.KeyAdapter JavaDoc(){
90             public void keyReleased(java.awt.event.KeyEvent JavaDoc ke){
91                 processDialogEvent();
92             }
93         };
94         sourceDirTextField.addKeyListener(keyAdapter);
95         destDirTextField.addKeyListener(keyAdapter);
96         String JavaDoc sourceDir=commonInfoModel.getSourceInstallDir();
97         String JavaDoc targetDir=commonInfoModel.getTargetDomainRoot();
98         if(sourceDir != null && !(sourceDir.equals("")))
99             sourceDirTextField.setText(sourceDir);
100         if(targetDir != null && !(targetDir.equals("")))
101             destDirTextField.setText(targetDir);
102         
103         String JavaDoc adminUserName = commonInfoModel.getAdminUserName();
104         String JavaDoc adminPassword = commonInfoModel.getAdminPassword();
105         adminUserTextField.addKeyListener(keyAdapter);
106         adminPWTextField.addKeyListener(keyAdapter);
107         
108         if(adminUserName != null && !(adminUserName.equals("")))
109             adminUserTextField.setText(adminUserName);
110         if(adminPassword != null && !(adminPassword.equals("")))
111             adminPWTextField.setText(adminPassword);
112         
113         if(!this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){
114             String JavaDoc masterPassword = commonInfoModel.getMasterPassword();
115             masterPWTextField.addKeyListener(keyAdapter);
116             if(masterPassword != null && !(masterPassword.equals("")))
117                 masterPWTextField.setText(masterPassword);
118         }
119         
120     }
121     /** This method is called from within the constructor to
122      * initialize the form.
123      * always regenerated by the Form Editor.
124      */

125     private void initComponents() {
126         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
127         flowContentLabel = new FlowLabel();
128         sourceDirLabel = new javax.swing.JLabel JavaDoc();
129         sourceDirTextField = new javax.swing.JTextField JavaDoc();
130         sourceDirectoryBrowseButton = new javax.swing.JButton JavaDoc();
131         destDirLabel = new javax.swing.JLabel JavaDoc();
132         destDirTextField = new javax.swing.JTextField JavaDoc();
133         destDirBrowseButton = new javax.swing.JButton JavaDoc();
134     containerPanel = new javax.swing.JPanel JavaDoc();
135
136         containerPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
137
138         flowContentLabel.setText(stringManager.getString("upgrade.gui.detailspanel.flowContentLable"));
139         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
140         gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0;
141         gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 1;
142         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
143         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 5, 0);
144         gridBagConstraints.weightx = 1.0;
145         containerPanel.add(flowContentLabel, gridBagConstraints);
146         
147         sourceDirLabel.setText(stringManager.getString("upgrade.gui.detailspanel.sourceDirLabel"));
148         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
149         gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1;
150         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
151         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 10, 3, 10);
153         gridBagConstraints.weightx = 1.0;
154         containerPanel.add(sourceDirLabel, gridBagConstraints);
155
156         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
157         gridBagConstraints.gridx = 0;
158         gridBagConstraints.gridy = 2;
159         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
160         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
161         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 10, 5);
162         gridBagConstraints.weightx = 1.0;
163         containerPanel.add(sourceDirTextField, gridBagConstraints);
164
165         sourceDirectoryBrowseButton.setText(stringManager.getString("upgrade.gui.detailspanel.browseButtonText"));
166         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
167         gridBagConstraints.gridx = 1;
168         gridBagConstraints.gridy = 2;
169         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 5, 10, 10);
171         containerPanel.add(sourceDirectoryBrowseButton, gridBagConstraints);
172
173         destDirLabel.setText(stringManager.getString("upgrade.gui.detailspanel.targetDirLabel"));
174         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
175         gridBagConstraints.gridx = 0;
176         gridBagConstraints.gridy = 3;
177         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
178         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
179         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 3, 10);
180         gridBagConstraints.weightx = 1.0;
181         containerPanel.add(destDirLabel, gridBagConstraints);
182
183         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
184         gridBagConstraints.gridx = 0;
185         gridBagConstraints.gridy = 4;
186         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
187         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
188         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 10, 5);
189         gridBagConstraints.weightx = 1.0;
190         containerPanel.add(destDirTextField, gridBagConstraints);
191
192         destDirBrowseButton.setText(stringManager.getString("upgrade.gui.detailspanel.browseButtonText"));
193         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
194         gridBagConstraints.gridx = 1;
195         gridBagConstraints.gridy = 4;
196         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 5, 10, 5);
197         containerPanel.add(destDirBrowseButton, gridBagConstraints);
198         
199         upgradeCertificates = new javax.swing.JCheckBox JavaDoc(stringManager.getString("upgrade.gui.detailspanel.transferCertCheckBoxText"),false);
200         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
201         gridBagConstraints.gridx = 0;
202         gridBagConstraints.gridy = 5;
203         gridBagConstraints.gridwidth = 2;
204         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
205         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 10, 10, 5);
206         gridBagConstraints.weightx = 1.0;
207         gridBagConstraints.weighty = 0;
208         containerPanel.add(upgradeCertificates, gridBagConstraints);
209         
210         javax.swing.JPanel JavaDoc adminUserPwPanel = getAdminUserPasswordPanel();
211         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
212         gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6;
213         gridBagConstraints.gridheight = 1; gridBagConstraints.gridwidth = 2;
214         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
215         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 3, 10);
216         gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 0.0;
217         containerPanel.add(adminUserPwPanel, gridBagConstraints);
218         
219         if(this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){
220             javax.swing.JPanel JavaDoc dummyPanel = new javax.swing.JPanel JavaDoc();
221             gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
222             gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7;
223             gridBagConstraints.gridheight = 1; gridBagConstraints.gridwidth = 2;
224             gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
225             gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 3, 10);
226             gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0;
227             containerPanel.add(dummyPanel, gridBagConstraints);
228         }
229     }
230     private javax.swing.JPanel JavaDoc getAdminUserPasswordPanel(){
231         javax.swing.JPanel JavaDoc panel = new javax.swing.JPanel JavaDoc();
232         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
233         javax.swing.JLabel JavaDoc admiUserLabel = new javax.swing.JLabel JavaDoc();
234         javax.swing.JLabel JavaDoc admiPWLabel = new javax.swing.JLabel JavaDoc();
235         adminUserTextField = new javax.swing.JTextField JavaDoc();
236         adminPWTextField = new javax.swing.JPasswordField JavaDoc();
237         
238         panel.setLayout(new java.awt.GridBagLayout JavaDoc());
239         
240         admiUserLabel.setText(stringManager.getString("upgrade.gui.detailspanel.adminUserLabel"));
241         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
242         gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0;
243         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
244         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
245         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 10, 3, 20);
246         gridBagConstraints.weightx = 1.0;
247         panel.add(admiUserLabel, gridBagConstraints);
248         
249         admiPWLabel.setText(stringManager.getString("upgrade.gui.detailspanel.adminPWLabel"));
250         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
251         gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0;
252         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
253         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
254         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 20, 3, 10);
255         gridBagConstraints.weightx = 1.0;
256         panel.add(admiPWLabel, gridBagConstraints);
257
258         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
259         gridBagConstraints.gridx = 0;
260         gridBagConstraints.gridy = 1;
261         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
262         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
263         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 5, 20);
264         gridBagConstraints.weightx = 1.0;
265         panel.add(adminUserTextField, gridBagConstraints);
266         
267         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
268         gridBagConstraints.gridx = 1;
269         gridBagConstraints.gridy = 1;
270         gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
271         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
272         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 20, 5, 10);
273         gridBagConstraints.weightx = 1.0;
274         panel.add(adminPWTextField, gridBagConstraints);
275         
276         if(!this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){
277             javax.swing.JLabel JavaDoc masterPWLabel = new javax.swing.JLabel JavaDoc();
278             masterPWTextField = new javax.swing.JPasswordField JavaDoc();
279             masterPWLabel.setText(stringManager.getString("upgrade.gui.detailspanel.masterPWLabel"));
280             gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
281             gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2;
282             gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 1;
283             gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
284             gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 10, 3, 5);
285             gridBagConstraints.weightx = 1.0;
286             panel.add(masterPWLabel, gridBagConstraints);
287         
288             gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
289             gridBagConstraints.gridx = 0;
290             gridBagConstraints.gridy = 3;
291             gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
292             gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
293             gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 10, 5);
294             gridBagConstraints.weightx = 1.0;
295             panel.add(masterPWTextField, gridBagConstraints);
296             
297             javax.swing.JPanel JavaDoc dummyPanel = new javax.swing.JPanel JavaDoc();
298             gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
299             gridBagConstraints.gridx = 1;
300             gridBagConstraints.gridy = 3;
301             gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1;
302             gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
303             gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 20, 10, 5);
304             gridBagConstraints.weightx = 1.0;
305             panel.add(dummyPanel, gridBagConstraints);
306         }
307         
308         return panel;
309     }
310     
311     private void sourceActionPerformed(java.awt.event.ActionEvent JavaDoc evt){
312         getfileChooser().setCurrentDirectory(new java.io.File JavaDoc(sourceDirTextField.getText()));
313         int returnedValue = getfileChooser().showOpenDialog(this);
314         if(returnedValue == javax.swing.JFileChooser.APPROVE_OPTION){
315             sourceDirTextField.setText(String.valueOf(getfileChooser().getSelectedFile()));
316             this.processDialogEvent();
317         }
318     }
319     private void destActionPerformed(java.awt.event.ActionEvent JavaDoc evt){
320         getfileChooser().setCurrentDirectory(new java.io.File JavaDoc(destDirTextField.getText()));
321         int returnedValue = getfileChooser().showOpenDialog(this);
322         if(returnedValue == javax.swing.JFileChooser.APPROVE_OPTION){
323             destDirTextField.setText(String.valueOf(getfileChooser().getSelectedFile()));
324             this.processDialogEvent();
325         }
326     }
327     private javax.swing.JFileChooser JavaDoc getfileChooser() {
328         if (fileChooser == null) {
329             fileChooser = new javax.swing.JFileChooser JavaDoc();
330             fileChooser.setName("fileChooser");
331             fileChooser.setBounds(668, 49, 500, 300);
332             fileChooser.setDialogTitle(stringManager.getString("upgrade.gui.detailspanel.fileChooseTitle"));
333             
334         }
335         return fileChooser;
336     }
337     public String JavaDoc getSourceDirectoryPath(){
338         return this.sourceDirTextField.getText();
339     }
340     public String JavaDoc getDestinationDirectoryPath(){
341         return this.destDirTextField.getText();
342     }
343     public String JavaDoc getAdminUserName(){
344         return this.adminUserTextField.getText();
345     }
346     public String JavaDoc getAdminPassword(){
347         return this.adminPWTextField.getText();
348     }
349     public String JavaDoc getMasterPassword(){
350         return this.masterPWTextField.getText();
351     }
352     public void addDialogListener(DialogListener listener){
353         this.dialogListeners.addElement(listener);
354     }
355     public boolean isUpgradeCertificatesSelected(){
356         return this.upgradeCertificates.isSelected();
357     }
358     public void removeDialogListener(DialogListener listener){
359         this.dialogListeners.removeElement(listener);
360     }
361     private void processDialogEvent(){
362         DialogEvent de = new DialogEvent(this, DialogEvent.CHANGE_ACTION);
363         for(int i=0 ; i<this.dialogListeners.size(); i++){
364             ((DialogListener)dialogListeners.elementAt(i)).dialogProcessed(de);
365         }
366     }
367     
368 }
369
Popular Tags