KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > service > swing > ui > WizardPane3


1 package org.apache.axis.tool.service.swing.ui;
2
3 import java.awt.event.ActionEvent JavaDoc;
4 import java.awt.event.ActionListener JavaDoc;
5 import java.awt.event.KeyEvent JavaDoc;
6 import java.awt.event.KeyListener JavaDoc;
7
8 import javax.swing.JButton JavaDoc;
9 import javax.swing.JFrame JavaDoc;
10 import javax.swing.JLabel JavaDoc;
11 import javax.swing.JTextField JavaDoc;
12
13 import org.apache.axis.tool.service.bean.Page3Bean;
14 import org.apache.axis.tool.service.bean.WizardBean;
15 import org.apache.axis.tool.util.Constants;
16
17 /*
18  * Copyright 2004,2005 The Apache Software Foundation.
19  *
20  * Licensed under the Apache License, Version 2.0 (the "License");
21  * you may not use this file except in compliance with the License.
22  * You may obtain a copy of the License at
23  *
24  * http://www.apache.org/licenses/LICENSE-2.0
25  *
26  * Unless required by applicable law or agreed to in writing, software
27  * distributed under the License is distributed on an "AS IS" BASIS,
28  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  * See the License for the specific language governing permissions and
30  * limitations under the License.
31  */

32
33 public class WizardPane3 extends WizardPane{
34
35     private Page3Bean myBean;
36
37     private JLabel JavaDoc outputFileLocationLabel;
38     private JTextField JavaDoc outputFileLocationTextBox;
39     private JButton JavaDoc browseButton;
40
41     private JLabel JavaDoc outputFileNameLabel;
42     private JTextField JavaDoc outputFileNameTextBox;
43
44     public WizardPane3(WizardBean bean, JFrame JavaDoc ownerFrame) {
45         super(ownerFrame);
46         init();
47         if (bean.getPage3bean()!=null){
48             this.myBean = bean.getPage3bean();
49             setBeanValues();
50         }else{
51             this.myBean = new Page3Bean();
52             bean.setPage3bean(myBean);
53         }
54     }
55
56     public boolean validateValues() {
57         String JavaDoc text1 = myBean.getOutputFileName();
58         String JavaDoc text2 = myBean.getOutputFolderName();
59         boolean text1Validity = (text1!=null && text1.trim().length()>0);
60         boolean text2Validity = (text2!=null && text2.trim().length()>0);
61
62         return text1Validity && text2Validity;
63     }
64
65     private void setBeanValues(){
66         this.outputFileLocationTextBox.setText(myBean.getOutputFolderName());
67         this.outputFileNameTextBox.setText(myBean.getOutputFileName());
68     }
69
70     private void init(){
71         this.setLayout(null);
72         this.setSize(width,height);
73
74         initDescription("\nInput the location for the output file and the name for \n" +
75                 "the compiled jar file " );
76
77
78         this.outputFileLocationLabel = new JLabel JavaDoc("Output Folder");
79         this.add(this.outputFileLocationLabel);
80         this.outputFileLocationLabel.setBounds(hgap,descHeight,Constants.UIConstants.LABEL_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT);
81
82         this.outputFileLocationTextBox = new JTextField JavaDoc();
83         this.add(this.outputFileLocationTextBox);
84         this.outputFileLocationTextBox.setBounds(Constants.UIConstants.LABEL_WIDTH + 2*hgap ,descHeight,Constants.UIConstants.TEXT_BOX_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT);
85         this.outputFileLocationTextBox.addActionListener(new ActionListener JavaDoc(){
86             public void actionPerformed(ActionEvent JavaDoc e) {
87                 handleLocationChange();
88             }
89         });
90         this.outputFileLocationTextBox.addKeyListener(new KeyListener JavaDoc(){
91             public void keyTyped(KeyEvent JavaDoc e) { }
92             public void keyPressed(KeyEvent JavaDoc e) {
93                 handleLocationChange();
94             }
95             public void keyReleased(KeyEvent JavaDoc e) {}
96         });
97
98
99         this.browseButton = new JButton JavaDoc(".");
100         this.add(this.browseButton);
101         this.browseButton.setBounds(Constants.UIConstants.LABEL_WIDTH + 2*hgap +Constants.UIConstants.TEXT_BOX_WIDTH,descHeight,Constants.UIConstants.BROWSE_BUTTON_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT);
102         this.browseButton.addActionListener(new ActionListener JavaDoc(){
103             public void actionPerformed(ActionEvent JavaDoc e) {
104                 outputFileLocationTextBox.setText(browseForAFolder());
105                 handleLocationChange();
106
107             }
108         });
109
110
111
112         this.outputFileNameLabel = new JLabel JavaDoc("Out File Name");
113         this.add(this.outputFileNameLabel);
114         this.outputFileNameLabel.setBounds(hgap,descHeight +Constants.UIConstants.GENERAL_COMP_HEIGHT +vgap,Constants.UIConstants.LABEL_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT);
115
116         this.outputFileNameTextBox = new JTextField JavaDoc();
117         this.add(this.outputFileNameTextBox);
118         this.outputFileNameTextBox.setBounds(Constants.UIConstants.LABEL_WIDTH + 2*hgap ,descHeight+Constants.UIConstants.GENERAL_COMP_HEIGHT +vgap,Constants.UIConstants.TEXT_BOX_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT);
119         this.outputFileNameTextBox.addActionListener(new ActionListener JavaDoc(){
120             public void actionPerformed(ActionEvent JavaDoc e) {
121                 handleFileNameChange();
122             }
123         });
124         this.outputFileNameTextBox.addKeyListener(new KeyListener JavaDoc(){
125             public void keyTyped(KeyEvent JavaDoc e) { }
126             public void keyPressed(KeyEvent JavaDoc e) { }
127             public void keyReleased(KeyEvent JavaDoc e) { handleFileNameChange();}
128         });
129
130     }
131
132     private void handleLocationChange(){
133         myBean.setOutputFolderName(outputFileLocationTextBox.getText());
134     }
135
136     private void handleFileNameChange(){
137         myBean.setOutputFileName(outputFileNameTextBox.getText());
138     }
139
140 }
141
Popular Tags