📄 optionspage.java
字号:
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
* Licensed 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.tool.codegen.eclipse.ui;
import org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
import org.apache.axis2.tool.codegen.eclipse.util.UIConstants;
import org.apache.axis2.tool.codegen.eclipse.util.WSDLPropertyReader;
import org.apache.axis2.util.URLProcessor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import javax.xml.namespace.QName;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Options Page lets the user change general settings on the code generation. It
* is used in the CodegenWizardPlugin, CodeGenWizard.
*
*/
public class OptionsPage extends AbstractWizardPage implements UIConstants {
/**
* Selection list for target languages
*/
private Combo languageSelectionComboBox;
/**
* A radio button to enable/disable code generation for synchronous and
* asynchronous calls.
*/
private Button syncAndAsyncRadioButton;
/**
* A radio button to choose "synchronous only" code generation
*/
private Button syncOnlyRadioButton;
/**
* A radio button to choose "asynchronous only" code generation
*/
private Button asyncOnlyRadioButton;
/**
* Label holding the full qualified package name for generated code
*/
private Text packageText;
/**
* Checkbox to enable server-side skeleton code generation. If enabled,
* generates an empty implementation of the service
*/
private Button serverSideCheckBoxButton;
/**
* Checkbox to enable the generation of test case classes for the generated
* implementation of the webservice.
*/
private Button testCaseCheckBoxButton;
/**
* Checkbox to enable the generation of a default server.xml configuration
* file
*/
private Button serverXMLCheckBoxButton;
/**
* Checkbox to enable the generate all classes
*/
private Button generateAllCheckBoxButton;
/**
* check box for server side interface
*/
private Button generateServerSideInterfaceCheckBoxButton;
private Combo databindingTypeCombo;
/**
* Text box to have the portname
*/
private Combo portNameCombo;
/**
* Text box to have the service name
*/
private Combo serviceNameCombo;
private WSDLPropertyReader reader;
private List serviceQNameList = null;
private static final int EDITABLECOLUMN = 1;
/**
* A table to keep the namespace to
* package mappings
*/
private Table namespace2packageTable = null;
/**
* Creates the page and initialize some settings
*/
public OptionsPage() {
super("page2");
}
/**
* Sets the default values for the Options page
*
*/
protected void initializeDefaultSettings() {
settings.put(PREF_CHECK_GENERATE_SERVERCONFIG, false);
settings.put(PREF_CHECK_GENERATE_SERVERSIDE, false);
settings.put(PREF_CHECK_GENERATE_TESTCASE, false);
settings.put(PREF_LANGUAGE_INDEX, 0);
settings.put(PREF_PACKAGE_NAME, "org.example.webservice");
settings.put(PREF_RADIO_ASYNC_ONLY, false);
settings.put(PREF_RADIO_SYNC_AND_ASYNC, true);
settings.put(PREF_RADIO_SYNC_ONLY, false);
settings.put(PREF_COMBO_PORTNAME_INDEX, 0);
settings.put(PREF_COMBO_SERVICENAME_INDEX, 0);
settings.put(PREF_DATABINDER_INDEX, 0);
settings.put(PREF_GEN_ALL, false);
settings.put(PREF_GEN_SS_INTERFACE, false);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 3;
layout.verticalSpacing = 9;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
Label label = new Label(container, SWT.NULL);
label.setText(CodegenWizardPlugin
.getResourceString("page2.language.caption"));
languageSelectionComboBox = new Combo(container, SWT.DROP_DOWN
| SWT.BORDER | SWT.READ_ONLY);
// fill the combo
this.fillLanguageCombo();
languageSelectionComboBox.setLayoutData(gd);
languageSelectionComboBox.select(settings.getInt(PREF_LANGUAGE_INDEX));
languageSelectionComboBox.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_LANGUAGE_INDEX, languageSelectionComboBox
.getSelectionIndex());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
syncAndAsyncRadioButton = new Button(container, SWT.RADIO);
syncAndAsyncRadioButton.setText(CodegenWizardPlugin
.getResourceString("page2.syncAsync.caption"));
syncAndAsyncRadioButton.setSelection(settings
.getBoolean(PREF_RADIO_SYNC_AND_ASYNC));
syncAndAsyncRadioButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_RADIO_SYNC_AND_ASYNC, syncAndAsyncRadioButton
.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
syncOnlyRadioButton = new Button(container, SWT.RADIO);
syncOnlyRadioButton.setText(CodegenWizardPlugin
.getResourceString("page2.sync.caption"));
syncOnlyRadioButton.setSelection(settings
.getBoolean(PREF_RADIO_SYNC_ONLY));
syncOnlyRadioButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_RADIO_SYNC_ONLY, syncOnlyRadioButton
.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
asyncOnlyRadioButton = new Button(container, SWT.RADIO);
asyncOnlyRadioButton
.setText(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin
.getResourceString("page2.async.caption"));
asyncOnlyRadioButton.setSelection(settings
.getBoolean(PREF_RADIO_ASYNC_ONLY));
asyncOnlyRadioButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_RADIO_ASYNC_ONLY, asyncOnlyRadioButton
.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// service name
label = new Label(container, SWT.NULL);
label.setText(CodegenWizardPlugin
.getResourceString("page2.serviceName.caption"));
serviceNameCombo = new Combo(container, SWT.DROP_DOWN | SWT.BORDER
| SWT.READ_ONLY);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
serviceNameCombo.setLayoutData(gd);
// serviceNameCombo.setText(settings.get(PREF_TEXT_SERVICENAME));
serviceNameCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
// update the settings
settings.put(PREF_COMBO_SERVICENAME_INDEX, serviceNameCombo
.getSelectionIndex());
// reload the portName list
loadPortNames();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// port name
label = new Label(container, SWT.NULL);
label.setText(CodegenWizardPlugin
.getResourceString("page2.portName.caption"));
portNameCombo = new Combo(container, SWT.DROP_DOWN | SWT.BORDER
| SWT.READ_ONLY);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
portNameCombo.setLayoutData(gd);
portNameCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
// do something here
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// package name
label = new Label(container, SWT.NULL);
label.setText(CodegenWizardPlugin
.getResourceString("page2.package.caption"));
packageText = new Text(container, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
packageText.setLayoutData(gd);
String packageName;
String storedPackageName = settings.get(PREF_PACKAGE_NAME);
if (storedPackageName.equals("")) {
packageName = URLProcessor.makePackageName("");
} else {
packageName = storedPackageName;
}
//if the package name somehow turned out to be null set it to
//default package
if (packageName==null)packageName=URLProcessor.DEFAULT_PACKAGE;
packageText.setText(packageName); // get this text from the
// URLProcessor
packageText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
settings.put(PREF_PACKAGE_NAME, packageText.getText());
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
testCaseCheckBoxButton = new Button(container, SWT.CHECK);
testCaseCheckBoxButton.setLayoutData(gd);
testCaseCheckBoxButton
.setText(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin
.getResourceString("page2.testcase.caption"));
testCaseCheckBoxButton.setSelection(settings
.getBoolean(PREF_CHECK_GENERATE_TESTCASE));
testCaseCheckBoxButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_CHECK_GENERATE_TESTCASE,
testCaseCheckBoxButton.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// Server side check box
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
serverSideCheckBoxButton = new Button(container, SWT.CHECK);
serverSideCheckBoxButton.setLayoutData(gd);
serverSideCheckBoxButton.setText(CodegenWizardPlugin
.getResourceString("page2.serverside.caption"));
serverSideCheckBoxButton.setSelection(settings
.getBoolean(PREF_CHECK_GENERATE_SERVERSIDE));
serverSideCheckBoxButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
handleServersideSelection();
settings.put(PREF_CHECK_GENERATE_SERVERSIDE,
serverSideCheckBoxButton.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// Server side services xml
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
serverXMLCheckBoxButton = new Button(container, SWT.CHECK);
serverXMLCheckBoxButton.setLayoutData(gd);
serverXMLCheckBoxButton.setSelection(settings
.getBoolean(PREF_CHECK_GENERATE_SERVERCONFIG));
serverXMLCheckBoxButton.setText(CodegenWizardPlugin
.getResourceString("page2.serviceXML.caption"));
serverXMLCheckBoxButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_CHECK_GENERATE_SERVERCONFIG,
serverXMLCheckBoxButton.getEnabled());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// generate all
generateAllCheckBoxButton = new Button(container, SWT.CHECK);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
generateAllCheckBoxButton.setLayoutData(gd);
generateAllCheckBoxButton.setSelection(settings
.getBoolean(PREF_GEN_ALL));
generateAllCheckBoxButton.setText(CodegenWizardPlugin
.getResourceString("page2.genAll.caption"));
generateAllCheckBoxButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_GEN_ALL, generateAllCheckBoxButton
.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
//the server side interface option
generateServerSideInterfaceCheckBoxButton = new Button(container, SWT.CHECK);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
generateServerSideInterfaceCheckBoxButton.setLayoutData(gd);
generateServerSideInterfaceCheckBoxButton.setSelection(settings
.getBoolean(PREF_GEN_SS_INTERFACE));
generateServerSideInterfaceCheckBoxButton.setText(CodegenWizardPlugin
.getResourceString("page2.ssInterface.caption"));
generateServerSideInterfaceCheckBoxButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_GEN_SS_INTERFACE, generateServerSideInterfaceCheckBoxButton
.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// Databinding
label = new Label(container, SWT.NULL);
label.setText(CodegenWizardPlugin
.getResourceString("page2.databindingCheck.caption"));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
databindingTypeCombo = new Combo(container, SWT.DROP_DOWN | SWT.BORDER
| SWT.READ_ONLY);
databindingTypeCombo.setLayoutData(gd);
fillDatabinderCombo();
databindingTypeCombo.select(settings.getInt(PREF_DATABINDER_INDEX));
databindingTypeCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
settings.put(PREF_DATABINDER_INDEX, databindingTypeCombo
.getSelectionIndex());
};
public void widgetDefaultSelected(SelectionEvent e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -