📄 optionspage.java
字号:
};
});
// Databinding
label = new Label(container, SWT.NULL);
label.setText(CodegenWizardPlugin
.getResourceString("page2.namespace2Pkg.caption"));
//add a table to set namespace to package mapping
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 3;
gd.verticalSpan = 5;
namespace2packageTable = new Table(container,SWT.SINGLE|SWT.FULL_SELECTION);
namespace2packageTable.setLinesVisible(true);
namespace2packageTable.setHeaderVisible(true);
namespace2packageTable.setEnabled(true);
namespace2packageTable.setLayoutData(gd);
declareColumn(namespace2packageTable,
200, //a default width until we adjust
CodegenWizardPlugin
.getResourceString("page2.namespace.caption"));
declareColumn(namespace2packageTable,
200,//a default width until we adjust
CodegenWizardPlugin
.getResourceString("page2.package.caption"));
namespace2packageTable.setVisible(true);
// add the table editor
final TableEditor editor = new TableEditor(namespace2packageTable);
namespace2packageTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null) oldEditor.dispose();
// Identify the selected row
TableItem item = (TableItem)e.item;
if (item == null) return;
// The control that will be the editor must be a child of the Table
Text newEditor = new Text(namespace2packageTable, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent me) {
Text text = (Text)editor.getEditor();
editor.getItem().setText(EDITABLECOLUMN, text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item, EDITABLECOLUMN);
}
});
//adjust the width
//adjustColumnWidth(namespace2packageTable);
/*
* Check the state of server-side selection, so we can enable/disable
* the serverXML checkbox button.
*/
handleServersideSelection();
/*
* try populating the combos and other information from the WSDL if this
* is restored
*/
if (restoredFromPreviousSettings) {
populateParamsFromWSDL();
selectDefaults();
}
setControl(container);
setPageComplete(true);
}
/**
* Adjust the column widths
* @param table
*/
// private void adjustColumnWidth(Table table){
// Point p = namespace2packageTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// int columns = table.getColumnCount();
// for (int i=0;i<columns;i++){
// table.getColumn(i).setWidth(p.x/columns);
// }
// }
/**
* A util method to create a new column
* @param table
* @param width
* @param colName
*/
private void declareColumn(Table table, int width,String colName){
TableColumn column = new TableColumn(table,SWT.NONE);
column.setWidth(width);
column.setText(colName);
}
private void selectDefaults() {
serviceNameCombo.select(settings.getInt(PREF_COMBO_SERVICENAME_INDEX));
// ports need to be renamed in order for correct default selection
loadPortNames();
portNameCombo.select(settings.getInt(PREF_COMBO_SERVICENAME_INDEX));
}
private void populatePackageName() {
this.packageText.setText(reader.packageFromTargetNamespace());
}
/**
* populate the service and the port from the WSDL this needs to be public
* since the WSDLselection page may call this
*/
public void populateParamsFromWSDL() {
if (reader == null)
reader = new WSDLPropertyReader();
try {
String lname = getCodegenWizard().getWSDLname();
if (!"".equals(lname.trim())) {
reader.readWSDL(lname);
// enable the combo's
setComboBoxEnable(true);
this.serviceQNameList = reader.getServiceList();
if (!serviceQNameList.isEmpty()) {
serviceNameCombo.removeAll();
for (int i = 0; i < serviceQNameList.size(); i++) {
// add the local part of the
serviceNameCombo.add(((QName) serviceQNameList.get(i))
.getLocalPart());
}
;
// select the first one as the default
serviceNameCombo.select(0);
// load the ports
loadPortNames();
updateStatus(null);
} else {
// service name list being empty means we are switching to
// the interface mode
if (serviceNameCombo!=null) serviceNameCombo.removeAll();
if (portNameCombo!=null) portNameCombo.removeAll();
// disable the combo's
setComboBoxEnable(false);
//this is not an error
updateStatus(null);
}
populatePackageName();
//populate the namespacess
loadNamespaces(reader.getDefinitionNamespaceMap());
}
} catch (Exception e) {
// disable the combo's
setComboBoxEnable(false);
updateStatus(CodegenWizardPlugin
.getResourceString("page2.wsdlNotFound.message"));
}
}
private void loadPortNames() {
int selectionIndex = serviceNameCombo.getSelectionIndex();
if (selectionIndex != -1) {
List ports = reader.getPortNameList((QName) serviceQNameList
.get(selectionIndex));
if (!ports.isEmpty()) {
portNameCombo.removeAll();
for (int i = 0; i < ports.size(); i++) {
// add the local part of the
portNameCombo.add(ports.get(i).toString());
}
updateStatus(null);
portNameCombo.select(0);
} else {
updateStatus(CodegenWizardPlugin
.getResourceString("page2.noports.message"));// TODO
}
}
}
private void setComboBoxEnable(boolean b) {
if (serviceNameCombo != null) {
serviceNameCombo.setEnabled(b);
portNameCombo.setEnabled(b);
}
}
/**
* Loads the namespaces
* @param namespaceMap
*/
private void loadNamespaces(Map namespaceMap){
Iterator namespaces = namespaceMap.values().iterator();
namespace2packageTable.removeAll();
TableItem[] items = new TableItem[namespaceMap.size()]; // An item for each field
int i = 0;
while(namespaces.hasNext()){
items[i] = new TableItem(namespace2packageTable, SWT.NONE);
items[i].setText(0,(String)namespaces.next());
i++;
}
namespace2packageTable.setVisible(true);
}
/**
* Fill the combo with proper databinding names
*
*/
private void fillDatabinderCombo() {
databindingTypeCombo.add(DATA_BINDING_ADB);
databindingTypeCombo.add(DATA_BINDING_XMLBEANS);
//databindingTypeCombo.add(DATA_BINDING_JIBX);
//databindingTypeCombo.add(DATA_BINDING_JAXME);
databindingTypeCombo.add(DATA_BINDING_NONE);
}
/**
* Fill the combo with proper language names
*
*/
private void fillLanguageCombo() {
languageSelectionComboBox.add(JAVA);
//since we have not looked at C# support seriously
//for a long time, we'll just leave it out
//languageSelectionComboBox.add(C_SHARP);
languageSelectionComboBox.select(0);
}
/**
* Validates the status of the server-side checkbox, and enables/disables
* the generation checkbox for XML configuration file
*/
private void handleServersideSelection() {
if (this.serverSideCheckBoxButton.getSelection()) {
this.serverXMLCheckBoxButton.setEnabled(true);
this.generateAllCheckBoxButton.setEnabled(true);
this.generateServerSideInterfaceCheckBoxButton.setEnabled(true);
} else {
this.serverXMLCheckBoxButton.setEnabled(false);
this.generateAllCheckBoxButton.setEnabled(false);
this.generateServerSideInterfaceCheckBoxButton.setEnabled(false);
}
}
/**
* Get the selected language
*
* @return a string containing the name of the target language
*/
public String getSelectedLanguage() {
return languageSelectionComboBox.getItem(languageSelectionComboBox
.getSelectionIndex());
}
/**
* the async only status
*
* @return true if "Generate asynchronous code only" is checked
*/
public boolean isAsyncOnlyOn() {
return asyncOnlyRadioButton.getSelection();
}
/**
* the sync only status
*
* @return true if "Generate synchronous code only" is checked
*/
public boolean isSyncOnlyOn() {
return syncOnlyRadioButton.getSelection();
}
/**
* return the package name
*
* @return a string containing the package name to use for code generation
*/
public String getPackageName() {
if ("".equals(packageText.getText().trim())){
//we do not allow the packaging to be empty
//if the user sets it to empty we set it to
//the default
return URLProcessor.DEFAULT_PACKAGE;
}
return this.packageText.getText();
}
/**
* The serverside status
*
* @return true if "Generate Server-Side" is checked
*/
public boolean isServerside() {
return this.serverSideCheckBoxButton.getSelection();
}
/**
*
* @return true if "Generate XML configuration file" is checked
*/
public boolean isServerXML() {
if (this.serverXMLCheckBoxButton.isEnabled())
return this.serverXMLCheckBoxButton.getSelection();
else
return false;
}
/**
*
* @return true if "Generate test case" is checked
*/
public boolean isGenerateTestCase() {
return this.testCaseCheckBoxButton.getSelection();
}
/*
* (non-Javadoc)
*
* @see org.apache.axis2.tool.codegen.eclipse.ui.CodegenPage#getPageType()
*/
public int getPageType() {
return WSDL_2_JAVA_TYPE;
}
/**
*
* @return null if portname is empty
*/
public String getPortName() {
int selectionIndex = portNameCombo.getSelectionIndex();
if (selectionIndex != -1) {
String text = this.portNameCombo.getItem(selectionIndex);
if (text == null || text.trim().equals("")) {
return null;
}
return text;
} else {
return null;
}
}
/**
* @return null if the text is empty
*
*/
public String getServiceName() {
int selectionIndex = serviceNameCombo.getSelectionIndex();
// cater for the scenario where the combo's can be empty
if (selectionIndex != -1) {
String text = this.serviceNameCombo.getItem(selectionIndex);
if (text == null || text.trim().equals("")) {
return null;
}
return text;
} else {
return null;
}
}
/**
*
* @return
*/
public String getDatabinderName() {
return this.databindingTypeCombo.getItem(databindingTypeCombo
.getSelectionIndex());
}
/**
*
* @return
*/
public boolean getGenerateServerSideInterface() {
return this.generateServerSideInterfaceCheckBoxButton.getSelection();
}
/**
*
* @return
*/
public boolean getGenerateAll() {
return this.generateAllCheckBoxButton.getSelection();
}
/**
* get the package to namespace mappings
* @return
*/
public String getNs2PkgMapping(){
String returnList="";
TableItem[] items = namespace2packageTable.getItems();
String packageValue;
for (int i=0;i<items.length;i++){
packageValue = items[i].getText(1);
if (packageValue!=null && !"".equals(packageValue)){
returnList = returnList +
("".equals(returnList)?"":",") +
items[i].getText(0)+ "=" + packageValue;
}
}
return "".equals(returnList)?null:returnList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -