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.tool.codegen.eclipse.ui;
020:
021: import org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
022: import org.apache.axis2.tool.codegen.eclipse.util.NamespaceFinder;
023: import org.eclipse.swt.SWT;
024: import org.eclipse.swt.events.ModifyEvent;
025: import org.eclipse.swt.events.ModifyListener;
026: import org.eclipse.swt.layout.GridData;
027: import org.eclipse.swt.layout.GridLayout;
028: import org.eclipse.swt.widgets.Composite;
029: import org.eclipse.swt.widgets.Label;
030: import org.eclipse.swt.widgets.Text;
031:
032: /*
033: * Usage java2wsdl -cn <fully qualified class name> : class file name -o <output
034: * Location> : output file location -cp <class path uri> : list of classpath
035: * entries - (urls) -tn <target namespace> : target namespace -tp <target
036: * namespace prefix> : target namespace prefix -stn <schema target namespace> :
037: * target namespace for schema -stp <schema target namespace prefix> : target
038: * namespace prefix for schema -sn <service name> : service name -of <output
039: * file name> : output file name for the WSDL
040: */
041: public class JavaWSDLOptionsPage extends AbstractWizardPage {
042:
043: private Text targetNamespaceText;
044:
045: private Text targetNamespacePrefixText;
046:
047: private Text schemaTargetNamepaceText;
048:
049: private Text schemaTargetNamespacePrefixText;
050:
051: private Text serviceNameText;
052:
053: // TODO need more here
054:
055: /*
056: * (non-Javadoc)
057: *
058: * @see org.apache.axis2.tool.codegen.eclipse.ui.AbstractWizardPage#initializeDefaultSettings()
059: */
060: protected void initializeDefaultSettings() {
061: settings.put(PREF_JAVA_TARGET_NS, "");
062: settings.put(PREF_JAVA_TARGET_NS_PREF, "");
063: settings.put(PREF_JAVA_SCHEMA_TARGET_NS, "");
064: settings.put(PREF_JAVA_SCHEMA_TARGET_NS_PREF, "");
065: settings.put(PREF_JAVA_SERVICE_NAME, "");
066:
067: }
068:
069: public void setNamespaceDefaults(String fullyQualifiedClassName) {
070:
071: targetNamespaceText.setText(NamespaceFinder
072: .getTargetNamespaceFromClass(fullyQualifiedClassName));
073: schemaTargetNamepaceText
074: .setText(NamespaceFinder
075: .getSchemaTargetNamespaceFromClass(fullyQualifiedClassName));
076:
077: targetNamespacePrefixText.setText(NamespaceFinder
078: .getDefaultNamespacePrefix());
079: schemaTargetNamespacePrefixText.setText(NamespaceFinder
080: .getDefaultSchemaNamespacePrefix());
081:
082: // serviceNameText.setText(fullyQualifiedClassName.replaceAll("\\.","_"));
083: serviceNameText.setText(NamespaceFinder
084: .getServiceNameText(fullyQualifiedClassName));
085: }
086:
087: /**
088: * @param pageName
089: */
090: public JavaWSDLOptionsPage() {
091: super ("page5");
092:
093: }
094:
095: /*
096: * (non-Javadoc)
097: *
098: * @see org.apache.axis2.tool.codegen.eclipse.ui.CodegenPage#getPageType()
099: */
100: public int getPageType() {
101: return JAVA_2_WSDL_TYPE;
102: }
103:
104: /*
105: * (non-Javadoc)
106: *
107: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
108: */
109: public void createControl(Composite parent) {
110: Composite container = new Composite(parent, SWT.NULL);
111: GridLayout layout = new GridLayout();
112: container.setLayout(layout);
113: layout.numColumns = 2;
114: layout.verticalSpacing = 9;
115:
116: GridData gd = new GridData(GridData.FILL_HORIZONTAL);
117: Label label = new Label(container, SWT.NULL);
118: label.setText(CodegenWizardPlugin
119: .getResourceString("page5.targetNamespace.label"));
120:
121: targetNamespaceText = new Text(container, SWT.BORDER
122: | SWT.SINGLE);
123: targetNamespaceText.setLayoutData(gd);
124: targetNamespaceText.setText(settings.get(PREF_JAVA_TARGET_NS));
125: targetNamespaceText.addModifyListener(new ModifyListener() {
126: public void modifyText(ModifyEvent e) {
127: settings.put(PREF_JAVA_TARGET_NS, targetNamespaceText
128: .getText());
129: // dialogChanged();
130: }
131: });
132:
133: label = new Label(container, SWT.NULL);
134: label
135: .setText(CodegenWizardPlugin
136: .getResourceString("page5.targetNamespacePrefix.label"));
137:
138: gd = new GridData(GridData.FILL_HORIZONTAL);
139: targetNamespacePrefixText = new Text(container, SWT.BORDER);
140: targetNamespacePrefixText.setLayoutData(gd);
141: targetNamespacePrefixText.setText(settings
142: .get(PREF_JAVA_TARGET_NS_PREF));
143: targetNamespacePrefixText
144: .addModifyListener(new ModifyListener() {
145: public void modifyText(ModifyEvent e) {
146: settings.put(PREF_JAVA_TARGET_NS_PREF,
147: targetNamespacePrefixText.getText());
148: // dialogChanged();
149: }
150: });
151:
152: label = new Label(container, SWT.NULL);
153: label.setText(CodegenWizardPlugin
154: .getResourceString("page5.schemaTargetNs.label"));
155:
156: gd = new GridData(GridData.FILL_HORIZONTAL);
157: schemaTargetNamepaceText = new Text(container, SWT.BORDER);
158: schemaTargetNamepaceText.setLayoutData(gd);
159: schemaTargetNamepaceText.setText(settings
160: .get(PREF_JAVA_SCHEMA_TARGET_NS_PREF));
161: schemaTargetNamepaceText
162: .addModifyListener(new ModifyListener() {
163: public void modifyText(ModifyEvent e) {
164: settings.put(PREF_JAVA_SCHEMA_TARGET_NS_PREF,
165: schemaTargetNamepaceText.getText());
166: // dialogChanged();
167: }
168: });
169:
170: label = new Label(container, SWT.NULL);
171: label.setText(CodegenWizardPlugin
172: .getResourceString("page5.schemaTargetNsPrefix.label"));
173:
174: gd = new GridData(GridData.FILL_HORIZONTAL);
175: schemaTargetNamespacePrefixText = new Text(container,
176: SWT.BORDER);
177: schemaTargetNamespacePrefixText.setLayoutData(gd);
178: schemaTargetNamespacePrefixText.setText(settings
179: .get(PREF_JAVA_SCHEMA_TARGET_NS));
180: schemaTargetNamespacePrefixText
181: .addModifyListener(new ModifyListener() {
182: public void modifyText(ModifyEvent e) {
183: settings.put(PREF_JAVA_SCHEMA_TARGET_NS,
184: schemaTargetNamespacePrefixText
185: .getText());
186: // dialogChanged();
187: }
188: });
189:
190: label = new Label(container, SWT.NULL);
191: label.setText(CodegenWizardPlugin
192: .getResourceString("page5.serviceName.label"));
193:
194: gd = new GridData(GridData.FILL_HORIZONTAL);
195: serviceNameText = new Text(container, SWT.BORDER);
196: serviceNameText.setLayoutData(gd);
197: serviceNameText.setText(settings
198: .get(PREF_JAVA_SCHEMA_TARGET_NS));
199: serviceNameText.addModifyListener(new ModifyListener() {
200: public void modifyText(ModifyEvent e) {
201: settings.put(PREF_JAVA_SERVICE_NAME, serviceNameText
202: .getText());
203: dialogChanged();
204: }
205: });
206:
207: setControl(container);
208:
209: }
210:
211: public String getTargetNamespace() {
212: return this .targetNamespaceText.getText();
213: }
214:
215: public String getTargetNamespacePrefix() {
216: return this .targetNamespacePrefixText.getText();
217: }
218:
219: public String getSchemaTargetNamespace() {
220: return this .schemaTargetNamepaceText.getText();
221: }
222:
223: public String getSchemaTargetNamespacePrefix() {
224: return this .schemaTargetNamespacePrefixText.getText();
225: }
226:
227: public String getServiceName() {
228: return this .serviceNameText.getText();
229: }
230:
231: /**
232: * Handle the dialog change event. Basically evaluates the file name and
233: * sets the error message accordingly
234: */
235: private void dialogChanged() {
236: String fileName = getServiceName();
237:
238: if (fileName.length() == 0) {
239: updateStatus(CodegenWizardPlugin
240: .getResourceString("page5.error.filemissingerror"));
241: return;
242: }
243: // update the status
244: updateStatus(null);
245: }
246:
247: }
|