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: package org.apache.ideaplugin.frames;
020:
021: import org.apache.axis2.tools.component.WizardPanel;
022: import org.apache.axis2.tools.component.WizardComponents;
023: import org.apache.axis2.tools.wizardframe.CodegenFrame;
024: import org.apache.ideaplugin.bean.ArchiveBean;
025:
026: import javax.swing.*;
027: import javax.swing.border.EmptyBorder;
028: import java.awt.*;
029: import java.awt.event.ActionListener;
030: import java.awt.event.ActionEvent;
031: import java.io.File;
032:
033: /**
034: * Created by IntelliJ IDEA.
035: * User: shivantha
036: * Date: 16/07/2007
037: * Time: 10:55:31
038: * To change this template use File | Settings | File Templates.
039: */
040: public class ClassFileLocationPage extends WizardPanel {
041: /**
042: * varialbales
043: */
044: private JTextField txtClassDir;
045: private JButton butSelect;
046: private JCheckBox chkBoxIncludeClass;
047: private JCheckBox chkBoxArchiveType;
048: private JButton btnHint;
049: private JTextArea txaHint;
050: private boolean flag = false;
051: private String hint = ":";
052: private ArchiveBean archiveBean;
053: public final JFileChooser fileChooser = new JFileChooser();
054: private File file;
055:
056: /**
057: * Constructor
058: * @param wizardComponents
059: */
060: public ClassFileLocationPage(WizardComponents wizardComponents,
061: ArchiveBean archiveBean) {
062: super (wizardComponents,
063: "Axis2 Idea Plugin Service Archiver Creator Wizards");
064: setPanelTopTitle("Service Archiver");
065: setPanelBottomTitle("Welcome to Axis2 Service Archive Wizard.Insert the class files and select the service type. ");
066: this .archiveBean = archiveBean;
067: init();
068: }
069:
070: /**
071: * initiate panel
072: */
073: private void init() {
074:
075: txaHint = new JTextArea();
076: txaHint.setBorder(null);
077: txaHint.setFocusable(false);
078: txaHint.setLineWrap(true);
079: txaHint.setWrapStyleWord(true);
080: txaHint.setOpaque(false);
081: btnHint = new JButton("Hint >>");
082: btnHint.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
083: txtClassDir = new JTextField();
084: butSelect = new JButton("Browse..");
085: chkBoxIncludeClass = new JCheckBox("include .class file only");
086: chkBoxArchiveType = new JCheckBox(
087: "Select for Service Group Archive");
088:
089: setBackButtonEnabled(true);
090: setFinishButtonEnabled(false);
091: setPageComplete(false);
092:
093: this .setLayout(new GridBagLayout());
094:
095: this .add(new JLabel("Class file location"),
096: new GridBagConstraints(0, 0, 1, 1, 0.1, 0.0,
097: GridBagConstraints.WEST,
098: GridBagConstraints.NONE,
099: new Insets(5, 10, 0, 0), 0, 0));
100:
101: this .add(txtClassDir, new GridBagConstraints(1, 0,
102: GridBagConstraints.RELATIVE, 1, 1.0, 0.0,
103: GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
104: new Insets(5, 1, 1, 1), 0, 0));
105:
106: txtClassDir.addActionListener(new ActionListener() {
107: public void actionPerformed(ActionEvent e) {
108: update();
109: }
110: });
111:
112: this
113: .add(butSelect, new GridBagConstraints(2, 0, 1, 1, 0.1,
114: 0.0, GridBagConstraints.CENTER,
115: GridBagConstraints.NONE,
116: new Insets(5, 1, 1, 10), 0, 0));
117:
118: butSelect.addActionListener(new ActionListener() {
119: public void actionPerformed(ActionEvent e) {
120: fileChooser
121: .setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
122: int returnVal = fileChooser.showOpenDialog(butSelect);
123: if (returnVal == JFileChooser.APPROVE_OPTION) {
124: file = fileChooser.getSelectedFile();
125: fileChooser.setCurrentDirectory(file);
126: txtClassDir.setText(file.getAbsolutePath());
127: setPageComplete(true);
128: setNextButtonEnabled(true);
129: } else {
130: txtClassDir.setText("");
131: }
132:
133: update();
134: }
135: });
136:
137: this .add(chkBoxIncludeClass, new GridBagConstraints(0, 1,
138: GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
139: GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
140: new Insets(5, 10, 1, 1), 0, 0));
141: chkBoxIncludeClass.addActionListener(new ActionListener() {
142: public void actionPerformed(ActionEvent e) {
143: update();
144: }
145: });
146:
147: // this.add(chkBoxArchiveType
148: // , new GridBagConstraints(0, 2, GridBagConstraints.REMAINDER, 1, 0.0, 0.0
149: // , GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
150: // , new Insets(5, 10, 1,1), 0, 0));
151: // chkBoxArchiveType .addActionListener(new ActionListener() {
152: // public void actionPerformed(ActionEvent e) {
153: // update();
154: // }
155: // });
156: this .add(btnHint, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
157: GridBagConstraints.WEST, GridBagConstraints.NONE,
158: new Insets(5, 10, 0, 10), 0, 0));
159: btnHint.addActionListener(new ActionListener() {
160: public void actionPerformed(ActionEvent e) {
161: if (flag) {
162: btnHint.setText("Hint >>");
163: txaHint.setText("");
164: flag = false;
165: } else {
166: btnHint.setText("Hint <<");
167: txaHint.setText(hint);
168: flag = true;
169: }
170: update();
171: }
172: });
173:
174: this .add(txaHint, new GridBagConstraints(0, 3,
175: GridBagConstraints.REMAINDER, 1, 0.0, 1.0,
176: GridBagConstraints.WEST, GridBagConstraints.BOTH,
177: new Insets(5, 10, 10, 10), 0, 0));
178:
179: }
180:
181: //next
182: public void next() {
183: switchPanel(CodegenFrame.PANEL_SECOND_C);
184: }
185:
186: //back
187: public void back() {
188: switchPanel(CodegenFrame.PANEL_CHOOSER);
189: }
190:
191: //update
192: public void update() {
193: fillBean();
194: }
195:
196: private void fillBean() {
197: // if(!chkBoxArchiveType.isSelected()){
198: // archiveBean.setSingleService(true);
199: // } else
200: // archiveBean.setSingleService(false);
201: if (!txtClassDir.getText().trim().equals("")) {
202: archiveBean.setClassLoc(file);
203: archiveBean.addClassLocation(file);
204: }
205: if (chkBoxIncludeClass.isSelected()) {
206: archiveBean.setIncludeClass(true);
207: } else
208: archiveBean.setIncludeClass(false);
209: }
210:
211: //get page type
212: public int getPageType() {
213: return WizardPanel.SERVICE_ARCHIVE_TYPE;
214: }
215: }
|