secondpanel.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 700 行 · 第 1/2 页
JAVA
700 行
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.axis2.tools.idea;
import org.apache.axis2.tools.bean.CodegenBean;
import org.apache.axis2.tools.wizardframe.CodegenFrame;
import org.apache.axis2.tools.component.WizardPanel;
import org.apache.axis2.tools.component.WizardComponents;
import org.apache.axis2.util.URLProcessor;
import javax.swing.*;
import javax.xml.namespace.QName;
import javax.wsdl.WSDLException;
import java.awt.*;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.util.Iterator;
import java.util.Collection;
import java.util.List;
public class SecondPanel extends WizardPanel {
private JComboBox cmbCodeGenOption;
private JComboBox cmbLan;
private JComboBox cmbServiceName;
private JComboBox cmbPortName;
private JTextField txtPacakgeName;
private JComboBox cmbdbtype;
private JCheckBox chkTestCase;
private JRadioButton clientSide;
private JRadioButton rdBoth;
private JRadioButton rdsyn;
private JRadioButton rdasync;
private JRadioButton serverSide;
private JCheckBox serviceXML;
private JCheckBox serverSideInterface;
private JRadioButton all;
private JTable table;
private JScrollPane spTable;
private List serviceNameList;
private PackageNameTableModel model;
private CodegenBean codegenBean;
public SecondPanel(WizardComponents wizardComponents,CodegenBean codegenBean) {
super(wizardComponents, "Axis2 Idea Plugin WSDL2Java Wizards");
this.codegenBean=codegenBean;
setPanelTopTitle("Options");
setPanelBottomTitle("Set the options for the code generator. If you wish to edit the codegen options, Select custom");
init();
}
private void init(){
cmbLan = new JComboBox();
cmbLan.addItem("java");
cmbLan.setToolTipText("Select the language of the generated code");
cmbServiceName = new JComboBox();
add(cmbServiceName);
cmbServiceName.setToolTipText("Select the name of the service that the code should be generated for");
cmbPortName = new JComboBox();
cmbPortName.setToolTipText("Select the port name that the code should be generated for");
txtPacakgeName = new JTextField("org.axis2");
txtPacakgeName.setToolTipText("Set the package name of the generated code");
cmbdbtype = new JComboBox();
cmbdbtype.addItem("adb");
cmbdbtype.addItem("xmlbeans");
cmbdbtype.addItem("none");
cmbdbtype.setToolTipText("Select the databinding framework to be used in the generation process");
chkTestCase = new JCheckBox("Generate Test Case", false);
chkTestCase.setVisible(true);
chkTestCase.setToolTipText("A test case will be generated if this is checked");
ButtonGroup generationType = new ButtonGroup();
clientSide = new JRadioButton("Generate Client Side",true);
generationType.add(clientSide);
ButtonGroup buttonGroup = new ButtonGroup();
rdBoth = new JRadioButton("Generate both sync and async", true);
buttonGroup.add(rdBoth);
rdsyn = new JRadioButton("Generate sync only", false);
buttonGroup.add(rdsyn);
rdasync = new JRadioButton("Generate async only", false);
buttonGroup.add(rdasync);
serverSide = new JRadioButton("Generate Server Side");
generationType.add(serverSide);
serviceXML = new JCheckBox("Generate default service.xml", false);
serverSideInterface = new JCheckBox("Generate an interface for skeleton", false);
all = new JRadioButton("Generate All");
generationType.add(all);
model = new PackageNameTableModel(new Object [1][2]);
table = new JTable(model);
spTable=new JScrollPane(table);
cmbCodeGenOption =new JComboBox();
cmbCodeGenOption .addItem("default");
cmbCodeGenOption .addItem("custom");
cmbCodeGenOption .setToolTipText("Select the Codegen option");
this.setLayout(new GridBagLayout());
this.add(new JLabel("Cogen Option")
, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 10, 0,10), 0, 0));
this.add(cmbCodeGenOption
, new GridBagConstraints(1, 0, GridBagConstraints.REMAINDER, 1, 1.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL
, new Insets(1, 5, 0,10), 0, 0));
cmbCodeGenOption.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
setEnabledForCodegenType();
update();
}
}
});
this.add(new JLabel("Out put lang")
, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1,10, 0,10), 0, 0));
this.add(cmbLan
, new GridBagConstraints(1, 1, GridBagConstraints.REMAINDER, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 5, 0,10), 0, 0));
this.add(new JLabel("Service name")
, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 10, 0,10), 0, 0));
this.add(cmbServiceName
, new GridBagConstraints(1, 2, GridBagConstraints.REMAINDER, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 5, 0,10), 0, 0));
this.add(new JLabel("port Name")
, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 10, 0,10), 0, 0));
this.add(cmbPortName
, new GridBagConstraints(1, 3, GridBagConstraints.REMAINDER, 1,1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 5, 0,10), 0, 0));
this.add(new JLabel("DataBinding")
, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 10, 0,10), 0, 0));
this.add(cmbdbtype
, new GridBagConstraints(1, 4, GridBagConstraints.REMAINDER, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 5, 0,10), 0, 0));
this.add(new JLabel("Custom Packege")
, new GridBagConstraints(0, 5, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 10, 0,10), 0, 0));
this.add(txtPacakgeName
, new GridBagConstraints(1, 5, GridBagConstraints.REMAINDER, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 5, 0,10), 0, 0));
this.add(chkTestCase
, new GridBagConstraints(0, 6, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 10, 0,10), 0, 0));
this.add(new JSeparator()
, new GridBagConstraints(0, 7, GridBagConstraints.REMAINDER, 1, 0.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.BOTH
, new Insets(1, 10, 1,1), 0, 0));
this.add(clientSide
, new GridBagConstraints(0, 8, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 10, 0,10), 0, 0));
clientSide.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
setEnabledForCustom();
update();
}
}
});
this.add(rdBoth
, new GridBagConstraints(0, 9, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 10, 0,10), 0, 0));
this.add(rdsyn
, new GridBagConstraints(1, 9, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 5, 0,10), 0, 0));
this.add(rdasync
, new GridBagConstraints(2, 9, 1, 1, 1.0,0.0
, GridBagConstraints.WEST , GridBagConstraints.NONE
, new Insets(1, 5, 0,10), 0, 0));
this.add(new JSeparator()
, new GridBagConstraints(0, 10, GridBagConstraints.REMAINDER, 1, 0.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.BOTH
, new Insets(1, 10, 1,1), 0, 0));
this.add(serverSide
, new GridBagConstraints(0, 11, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 10, 0,10), 0, 0));
serverSide.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
setEnabledForCustom();
update();
}
}
});
this.add(serviceXML
, new GridBagConstraints(0, 12, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 10, 0,10), 0, 0));
this.add(serverSideInterface
, new GridBagConstraints(1, 12, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1, 5, 0,10), 0, 0));
this.add(new JSeparator()
, new GridBagConstraints(0, 13, GridBagConstraints.REMAINDER, 1, 0.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.BOTH
, new Insets(1, 10, 1,1), 0, 0));
this.add(all
, new GridBagConstraints(0, 14, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1,10, 0,10), 0, 0));
all.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
setEnabledForCustom();
update();
}
}
});
this.add(new JSeparator()
, new GridBagConstraints(0, 15, GridBagConstraints.REMAINDER, 1, 0.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.BOTH
, new Insets(1, 10, 1,1), 0, 0));
this.add(new JLabel("Namespace to Package Mapping")
, new GridBagConstraints(0, 16, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL
, new Insets(1,10, 0,10), 0, 0));
this.add(spTable
, new GridBagConstraints(0, 17, GridBagConstraints.REMAINDER, 1, 1.0, 1.0
, GridBagConstraints.NORTHWEST , GridBagConstraints.BOTH
, new Insets(1,10, 20,10), 0, 0));
setNextButtonEnabled(false);
setEnabledForCodegenType();
}
public void next() {
switchPanel(CodegenFrame.PANEL_LAST_A );
}
public void back() {
switchPanel(CodegenFrame.PANEL_FIRST_A );
}
public void update(){
checkPageComlete();
populateParamsFromWSDL();
}
private void loadNamespaces(Collection namespaceMap){
Iterator namespaces = namespaceMap.iterator();
Object tableData [][] = new Object[namespaceMap.size()][2];
int i = 0;
while(namespaces.hasNext()){
String namespace = (String)namespaces.next();
tableData[i][0] = namespace;
tableData[i][1] = getPackageFromNamespace(namespace);
i++;
}
model.setTableData(tableData);
}
private void setEnabledForCodegenType(){
if(cmbCodeGenOption.getSelectedItem().equals("default") ){
cmbdbtype.setEnabled(false);
cmbLan.setEnabled(false);
cmbPortName .setEnabled(false);
cmbServiceName.setEnabled(false);
txtPacakgeName.setEnabled(false);
cmbdbtype.setEnabled(false);
if(chkTestCase.isSelected()) {
chkTestCase.setEnabled(false);
chkTestCase.setSelected(false);
} else
chkTestCase.setEnabled(false);
clientSide.setEnabled(false);
rdBoth .setEnabled(false);
rdsyn.setEnabled(false);
rdasync.setEnabled(false);
serverSide.setEnabled(false);
table.setEnabled(false);
spTable.setEnabled(false);
serviceXML.setEnabled(false);
serverSideInterface.setEnabled(false);
all.setEnabled(false);
}else{
cmbdbtype.setEnabled(true);
cmbLan.setEnabled(true);
cmbPortName .setEnabled(true);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?