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: public class ServiceArchiveOutputLocationPage extends WizardPanel {
034:
035: private JTextField txtLocation;
036: private JTextField txtFileName;
037: private JButton btnBrowes;
038: private JButton btnHint;
039: private JTextArea txaHint;
040: private boolean flag = false;
041: final JFileChooser DirChooser = new JFileChooser();
042: public static final String hint = "";
043: private ArchiveBean archiveBean;
044:
045: /**
046: * Constructor
047: * @param wizardComponents
048: */
049: public ServiceArchiveOutputLocationPage(
050: WizardComponents wizardComponents, ArchiveBean archiveBean) {
051: super (wizardComponents,
052: "Axis2 Idea Plugin Service Archiver Creator Wizards");
053: setPanelTopTitle("Service Archiver");
054: setPanelBottomTitle("Select the location for the generated Archiver");
055: this .archiveBean = archiveBean;
056: init();
057: }
058:
059: private void init() {
060: txaHint = new JTextArea();
061: txaHint.setBorder(null);
062: txaHint.setFocusable(false);
063: txaHint.setLineWrap(true);
064: txaHint.setWrapStyleWord(true);
065: txaHint.setOpaque(false);
066:
067: btnHint = new JButton("Hint >>");
068: btnHint.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
069:
070: txtFileName = new JTextField("Service_Archiver");
071:
072: txtLocation = new JTextField();
073:
074: btnBrowes = new JButton("Browse..");
075:
076: setBackButtonEnabled(true);
077: setNextButtonEnabled(false);
078: setFinishButtonEnabled(false);
079: this .setLayout(new GridBagLayout());
080:
081: this .add(new JLabel("OutPut File Name"),
082: new GridBagConstraints(0, 0, 1, 1, 0.1, 0.0,
083: GridBagConstraints.NORTHWEST,
084: GridBagConstraints.NONE,
085: new Insets(5, 10, 0, 0), 0, 0));
086:
087: this .add(txtFileName, new GridBagConstraints(1, 0, 1, 1, 1.0,
088: 0.0, GridBagConstraints.NORTHWEST,
089: GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0),
090: 0, 0));
091:
092: this
093: .add(new JLabel("OutPut Location"),
094: new GridBagConstraints(0, 1, 1, 1, 0.1, 0.0,
095: GridBagConstraints.WEST,
096: GridBagConstraints.NONE, new Insets(5,
097: 10, 0, 0), 0, 0));
098:
099: this .add(txtLocation, new GridBagConstraints(1, 1, 1, 1, 1.0,
100: 0.0, GridBagConstraints.WEST,
101: GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0),
102: 0, 0));
103:
104: this .add(btnBrowes,
105: new GridBagConstraints(2, 1, 1, 1, 0.1, 0.0,
106: GridBagConstraints.CENTER,
107: GridBagConstraints.NONE, new Insets(5, 10, 0,
108: 10), 0, 0));
109:
110: btnBrowes.addActionListener(new ActionListener() {
111: public void actionPerformed(ActionEvent e) {
112: DirChooser
113: .setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
114: int returnVal = DirChooser.showOpenDialog(btnBrowes);
115: if (returnVal == JFileChooser.APPROVE_OPTION) {
116: DirChooser
117: .setFileSelectionMode(JFileChooser.FILES_ONLY);
118: File newfile = DirChooser.getSelectedFile();
119: txtLocation.setText(newfile.getAbsolutePath());
120: }
121: update();
122: }
123: });
124: this .add(btnHint, new GridBagConstraints(0, 2, 1, 1, 0.1, 0.0,
125: GridBagConstraints.WEST, GridBagConstraints.NONE,
126: new Insets(5, 10, 0, 10), 0, 0));
127: btnHint.addActionListener(new ActionListener() {
128: public void actionPerformed(ActionEvent e) {
129: if (flag) {
130: btnHint.setText("Hint >>");
131: txaHint.setText("");
132: flag = false;
133: } else {
134: btnHint.setText("Hint <<");
135: txaHint.setText(hint);
136: flag = true;
137: }
138: update();
139: }
140: });
141:
142: this .add(txaHint, new GridBagConstraints(0, 3,
143: GridBagConstraints.REMAINDER, 1, 0.1, 1.0,
144: GridBagConstraints.CENTER, GridBagConstraints.BOTH,
145: new Insets(5, 10, 10, 10), 0, 0));
146: }
147:
148: public void back() {
149: if (!((ServiceXMLFileSelectionPage) getWizardComponents()
150: .getWizardPanel(CodegenFrame.PANEL_FOURTH_C))
151: .isIncludeXml()) {
152: switchPanel(CodegenFrame.PANEL_FOURTH_C);
153: } else {
154: switchPanel(CodegenFrame.PANEL_OPTION_C);
155: }
156: }
157:
158: public void next() {
159:
160: }
161:
162: public void update() {
163: if (!txtFileName.getText().equals("")) {
164: archiveBean.setArchiveName(txtFileName.getText());
165: }
166: if (!txtLocation.getText().equals("")) {
167: if (new File(txtLocation.getText()).isDirectory())
168: archiveBean.setOutPath(txtLocation.getText());
169: }
170: setBackButtonEnabled(true);
171: setNextButtonEnabled(false);
172:
173: }
174:
175: public int getPageType() {
176: return WizardPanel.SERVICE_ARCHIVE_TYPE;
177: }
178: }
|