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.axis2.tools.idea;
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:
025: import javax.swing.*;
026: import javax.swing.border.EmptyBorder;
027: import java.awt.*;
028: import java.awt.event.ItemListener;
029: import java.awt.event.ItemEvent;
030: import java.awt.event.ActionListener;
031: import java.awt.event.ActionEvent;
032:
033: /**
034: * this panel used for as chooser
035: * java2wsdl codegen option
036: * wsdl2java codegen option
037: *
038: * extend from wizardPanel calss
039: */
040:
041: public class ChooserPanel extends WizardPanel {
042: /**
043: * varialbales
044: */
045: private JButton btnHint;
046: private JLabel lblHint;
047: private boolean flag = false;
048: private JRadioButton optionJ2WRadioButton;
049: private JRadioButton optionW2JRadioButton;
050: private JRadioButton optionServiceArchiverRadioButton;
051: private ButtonGroup bg;
052: private char selectedOption = 'A'; // 'N' is no option selected 'A', 'B','C' & 'F' stands for options
053: final private String hint = "You can generate java code from a WSDL or WSDL from a java source file.";
054:
055: /**
056: * construct method for chooserPanel
057: * @param wizardComponents
058: */
059:
060: public ChooserPanel(WizardComponents wizardComponents) {
061:
062: super (wizardComponents, "Axis2 Idea Plugin Wizards");
063: setPanelTopTitle("Select the wizard");
064: setPanelBottomTitle("Welcome to the Axis2 code generator wizard");
065: init();
066: }
067:
068: /**
069: * Panel initial method
070: */
071: private void init() {
072:
073: lblHint = new JLabel("");
074: btnHint = new JButton("Hint >>");
075: btnHint.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
076:
077: optionW2JRadioButton = new JRadioButton(
078: "Generate java sorce code from a WSDl file.", true);
079: optionJ2WRadioButton = new JRadioButton(
080: "Generate a WSDl from a java source file", false);
081: optionServiceArchiverRadioButton = new JRadioButton(
082: "Create Service Archiver", false);
083: ButtonGroup bg = new ButtonGroup();
084: bg.add(optionJ2WRadioButton);
085: bg.add(optionW2JRadioButton);
086: bg.add(optionServiceArchiverRadioButton);
087:
088: this .setLayout(new GridBagLayout());
089:
090: this .add(new JLabel("Please specify what you want to do."),
091: new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
092: GridBagConstraints.NORTHWEST,
093: GridBagConstraints.NONE, new Insets(10, 20, 0,
094: 0), 0, 0));
095:
096: // option button for java2wsdl
097: optionW2JRadioButton.setEnabled(true);
098: this .add(optionW2JRadioButton,
099: new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,
100: GridBagConstraints.NORTHWEST,
101: GridBagConstraints.NONE, new Insets(10, 20, 0,
102: 0), 0, 0));
103: optionW2JRadioButton.addItemListener(new ItemListener() {
104: public void itemStateChanged(ItemEvent e) {
105: if (e.getStateChange() == ItemEvent.SELECTED) {
106: selectedOption = 'A';
107: update();
108: }
109: }
110: });
111:
112: // option button for wsdl2java
113:
114: this .add(optionJ2WRadioButton,
115: new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
116: GridBagConstraints.NORTHWEST,
117: GridBagConstraints.NONE, new Insets(10, 20, 0,
118: 0), 0, 0));
119: optionJ2WRadioButton.addItemListener(new ItemListener() {
120: public void itemStateChanged(ItemEvent e) {
121: if (e.getStateChange() == ItemEvent.SELECTED) {
122: selectedOption = 'B';
123: update();
124: }
125: }
126: });
127: // option button for service Archive
128:
129: this .add(optionServiceArchiverRadioButton,
130: new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
131: GridBagConstraints.NORTHWEST,
132: GridBagConstraints.NONE, new Insets(10, 20, 0,
133: 0), 0, 0));
134: optionServiceArchiverRadioButton
135: .addItemListener(new ItemListener() {
136: public void itemStateChanged(ItemEvent e) {
137: if (e.getStateChange() == ItemEvent.SELECTED) {
138: selectedOption = 'C';
139: update();
140: }
141: }
142: });
143:
144: // hint button
145:
146: this .add(btnHint, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0,
147: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
148: new Insets(10, 20, 0, 0), 0, 0));
149: btnHint.addActionListener(new ActionListener() {
150: public void actionPerformed(ActionEvent e) {
151: if (flag) {
152: btnHint.setText("Hint >>");
153: lblHint.setText("");
154: flag = false;
155: } else {
156: btnHint.setText("Hint <<");
157: lblHint.setText(hint);
158: flag = true;
159: }
160: update();
161: }
162: });
163:
164: // hint lable
165:
166: this .add(lblHint, new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0,
167: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
168: new Insets(10, 20, 0, 0), 0, 0));
169:
170: setNextButtonEnabled((selectedOption == 'A')
171: || (selectedOption == 'B'));
172:
173: }
174:
175: /**
176: * method for update when panel has some change
177: */
178:
179: public void update() {
180: setNextButtonEnabled((selectedOption == 'A')
181: || (selectedOption == 'B') || (selectedOption == 'C'));
182: setBackButtonEnabled(false); // there is no way back
183: setProgressPanelVisible(false);
184: setPageComplete(true);
185: }
186:
187: /**
188: * method for next button
189: */
190: public void next() {
191: if (selectedOption == 'A') {
192: switchPanel(CodegenFrame.PANEL_FIRST_A);
193:
194: } else if (selectedOption == 'B') {
195: switchPanel(CodegenFrame.PANEL_FIRST_B);
196: } else if (selectedOption == 'C') {
197: switchPanel(CodegenFrame.PANEL_FIRST_C);
198: }
199: setNextButtonEnabled(false);
200: }
201:
202: /**
203: * methodd for back button
204: */
205: public void back() {
206: }
207: }
|