001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.axis2.tool.service.swing.ui;
021:
022: import org.apache.axis2.tool.service.bean.Page3Bean;
023: import org.apache.axis2.tool.service.bean.WizardBean;
024: import org.apache.axis2.tool.util.Constants;
025:
026: import javax.swing.JButton;
027: import javax.swing.JFrame;
028: import javax.swing.JLabel;
029: import javax.swing.JTextField;
030: import java.awt.event.ActionEvent;
031: import java.awt.event.ActionListener;
032: import java.awt.event.KeyEvent;
033: import java.awt.event.KeyListener;
034:
035: public class WizardPane3 extends WizardPane {
036:
037: private Page3Bean myBean;
038:
039: private JLabel outputFileLocationLabel;
040: private JTextField outputFileLocationTextBox;
041: private JButton browseButton;
042:
043: private JLabel outputFileNameLabel;
044: private JTextField outputFileNameTextBox;
045:
046: public WizardPane3(WizardBean bean, JFrame ownerFrame) {
047: super (ownerFrame);
048: init();
049: if (bean.getPage3bean() != null) {
050: this .myBean = bean.getPage3bean();
051: setBeanValues();
052: } else {
053: this .myBean = new Page3Bean();
054: bean.setPage3bean(myBean);
055: }
056: }
057:
058: public boolean validateValues() {
059: String text1 = myBean.getOutputFileName();
060: String text2 = myBean.getOutputFolderName();
061: boolean text1Validity = (text1 != null && text1.trim().length() > 0);
062: boolean text2Validity = (text2 != null && text2.trim().length() > 0);
063:
064: return text1Validity && text2Validity;
065: }
066:
067: private void setBeanValues() {
068: this .outputFileLocationTextBox.setText(myBean
069: .getOutputFolderName());
070: this .outputFileNameTextBox.setText(myBean.getOutputFileName());
071: }
072:
073: private void init() {
074: this .setLayout(null);
075: this .setSize(width, height);
076:
077: initDescription("\nInput the location for the output file and the name for \n"
078: + "the compiled jar file ");
079:
080: this .outputFileLocationLabel = new JLabel("Output Folder");
081: this .add(this .outputFileLocationLabel);
082: this .outputFileLocationLabel.setBounds(hgap, descHeight,
083: Constants.UIConstants.LABEL_WIDTH,
084: Constants.UIConstants.GENERAL_COMP_HEIGHT);
085:
086: this .outputFileLocationTextBox = new JTextField();
087: this .add(this .outputFileLocationTextBox);
088: this .outputFileLocationTextBox.setBounds(
089: Constants.UIConstants.LABEL_WIDTH + 2 * hgap,
090: descHeight, Constants.UIConstants.TEXT_BOX_WIDTH,
091: Constants.UIConstants.GENERAL_COMP_HEIGHT);
092: this .outputFileLocationTextBox
093: .addActionListener(new ActionListener() {
094: public void actionPerformed(ActionEvent e) {
095: handleLocationChange();
096: }
097: });
098: this .outputFileLocationTextBox
099: .addKeyListener(new KeyListener() {
100: public void keyTyped(KeyEvent e) {
101: }
102:
103: public void keyPressed(KeyEvent e) {
104: handleLocationChange();
105: }
106:
107: public void keyReleased(KeyEvent e) {
108: }
109: });
110:
111: this .browseButton = new JButton(".");
112: this .add(this .browseButton);
113: this .browseButton.setBounds(Constants.UIConstants.LABEL_WIDTH
114: + 2 * hgap + Constants.UIConstants.TEXT_BOX_WIDTH,
115: descHeight, Constants.UIConstants.BROWSE_BUTTON_WIDTH,
116: Constants.UIConstants.GENERAL_COMP_HEIGHT);
117: this .browseButton.addActionListener(new ActionListener() {
118: public void actionPerformed(ActionEvent e) {
119: outputFileLocationTextBox.setText(browseForAFolder());
120: handleLocationChange();
121:
122: }
123: });
124:
125: this .outputFileNameLabel = new JLabel("Out File Name");
126: this .add(this .outputFileNameLabel);
127: this .outputFileNameLabel.setBounds(hgap, descHeight
128: + Constants.UIConstants.GENERAL_COMP_HEIGHT + vgap,
129: Constants.UIConstants.LABEL_WIDTH,
130: Constants.UIConstants.GENERAL_COMP_HEIGHT);
131:
132: this .outputFileNameTextBox = new JTextField();
133: this .add(this .outputFileNameTextBox);
134: this .outputFileNameTextBox.setBounds(
135: Constants.UIConstants.LABEL_WIDTH + 2 * hgap,
136: descHeight + Constants.UIConstants.GENERAL_COMP_HEIGHT
137: + vgap, Constants.UIConstants.TEXT_BOX_WIDTH,
138: Constants.UIConstants.GENERAL_COMP_HEIGHT);
139: this .outputFileNameTextBox
140: .addActionListener(new ActionListener() {
141: public void actionPerformed(ActionEvent e) {
142: handleFileNameChange();
143: }
144: });
145: this .outputFileNameTextBox.addKeyListener(new KeyListener() {
146: public void keyTyped(KeyEvent e) {
147: }
148:
149: public void keyPressed(KeyEvent e) {
150: }
151:
152: public void keyReleased(KeyEvent e) {
153: handleFileNameChange();
154: }
155: });
156:
157: }
158:
159: private void handleLocationChange() {
160: myBean.setOutputFolderName(outputFileLocationTextBox.getText());
161: }
162:
163: private void handleFileNameChange() {
164: myBean.setOutputFileName(outputFileNameTextBox.getText());
165: }
166:
167: }
|