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.ClassFileSelectionBean;
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 WizardPane1 extends WizardPane {
036:
037: private ClassFileSelectionBean myBean = null;
038:
039: private JLabel classFileLocationLabel;
040: private JTextField classFileLocationTextBox;
041: private JButton browseButton;
042:
043: public WizardPane1(WizardBean wizardBean, JFrame ownerFrame) {
044:
045: super (ownerFrame);
046:
047: init();
048:
049: if (wizardBean.getPage1bean() != null) {
050: myBean = wizardBean.getPage1bean();
051: this .classFileLocationTextBox.setText(myBean
052: .getFileLocation());
053: } else {
054: myBean = new ClassFileSelectionBean();
055: wizardBean.setPage1bean(myBean);
056: }
057:
058: }
059:
060: public boolean validateValues() {
061: String text = myBean.getFileLocation();
062: return (text != null && text.trim().length() > 0);
063: }
064:
065: private void init() {
066: this .setLayout(null);
067: this .setSize(width, height);
068:
069: initDescription("Welcome to the new AXIS Service packager Wizard Interface.\n\n "
070: + "Insert the location for the class files here.This should be a folder with \n"
071: + " the compiled classes");
072:
073: this .classFileLocationLabel = new JLabel("class file location");
074: this .add(this .classFileLocationLabel);
075: this .classFileLocationLabel.setBounds(hgap, descHeight,
076: Constants.UIConstants.LABEL_WIDTH,
077: Constants.UIConstants.GENERAL_COMP_HEIGHT);
078:
079: this .classFileLocationTextBox = new JTextField();
080: this .add(this .classFileLocationTextBox);
081: this .classFileLocationTextBox.setBounds(
082: Constants.UIConstants.LABEL_WIDTH + 2 * hgap,
083: descHeight, Constants.UIConstants.TEXT_BOX_WIDTH,
084: Constants.UIConstants.GENERAL_COMP_HEIGHT);
085: this .classFileLocationTextBox
086: .addActionListener(new ActionListener() {
087: public void actionPerformed(ActionEvent e) {
088: handleTextBoxChange();
089: }
090: });
091: this .classFileLocationTextBox.addKeyListener(new KeyListener() {
092: public void keyTyped(KeyEvent e) {
093: }
094:
095: public void keyPressed(KeyEvent e) {
096: }
097:
098: public void keyReleased(KeyEvent e) {
099: handleTextBoxChange();
100: }
101: });
102:
103: this .browseButton = new JButton(".");
104: this .add(this .browseButton);
105: this .browseButton.setBounds(Constants.UIConstants.LABEL_WIDTH
106: + 2 * hgap + Constants.UIConstants.TEXT_BOX_WIDTH,
107: descHeight, Constants.UIConstants.BROWSE_BUTTON_WIDTH,
108: Constants.UIConstants.GENERAL_COMP_HEIGHT);
109: this .browseButton.addActionListener(new ActionListener() {
110: public void actionPerformed(ActionEvent e) {
111: classFileLocationTextBox.setText(browseForAFolder());
112: handleTextBoxChange();
113: }
114: });
115: }
116:
117: private void handleTextBoxChange() {
118: String text = classFileLocationTextBox.getText();
119: if (text != null) {
120: this.myBean.setFileLocation(text);
121: }
122: }
123:
124: }
|