Author: Grid.Qian
Date: 2010-01-27 04:36:41 -0500 (Wed, 27 Jan 2010)
New Revision: 19950
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceSampleCreationCommand.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateAction.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/data/ServiceModel.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
Log:
JBIDE-5715: create a wizard for generating a sample web service class in a dynamic
project
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2010-01-27
09:33:52 UTC (rev 19949)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2010-01-27
09:36:41 UTC (rev 19950)
@@ -9,7 +9,6 @@
org.eclipse.core.runtime,
org.eclipse.wst.common.frameworks,
org.eclipse.wst.ws,
- org.jboss.tools.ws.ui,
org.eclipse.core.resources,
org.eclipse.jst.ws,
org.jboss.tools.ws.core,
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -30,7 +30,6 @@
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
-import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -60,8 +59,8 @@
if (location.equals("")) { //$NON-NLS-1$
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
- } else if (!new Path(location).append(JBossWSUIMessages.Bin)
- .append(JBossWSUIMessages.Command).toFile().exists()) {
+ } else if (!new Path(location).append(JBossWSCreationCoreMessages.Bin)
+ .append(JBossWSCreationCoreMessages.Command).toFile().exists()) {
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -21,7 +21,6 @@
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
-import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
public class InitialCommand extends AbstractDataModelOperation {
@@ -44,7 +43,7 @@
if (location.equals("")) { //$NON-NLS-1$
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
- } else if(!new
Path(location).append(JBossWSUIMessages.Bin).append(JBossWSUIMessages.Command).toFile().exists()){
+ } else if(!new
Path(location).append(JBossWSCreationCoreMessages.Bin).append(JBossWSCreationCoreMessages.Command).toFile().exists()){
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -48,10 +48,10 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- if(!model.isUpdateWebxml()){
+ if (!model.isUpdateWebxml()) {
return Status.OK_STATUS;
}
-
+
IEnvironment environment = getEnvironment();
IStatus status = null;
ServletDescriptor[] servletDescriptors = new ServletDescriptor[model
@@ -105,7 +105,8 @@
org.eclipse.jst.j2ee.webapplication.WebApp webapp) {
List theServlets = webapp.getServlets();
for (int i = 0; i < theServlets.size(); i++) {
- org.eclipse.jst.j2ee.webapplication.Servlet aServlet =
(org.eclipse.jst.j2ee.webapplication.Servlet) theServlets.get(i);
+ org.eclipse.jst.j2ee.webapplication.Servlet aServlet =
(org.eclipse.jst.j2ee.webapplication.Servlet) theServlets
+ .get(i);
if (aServlet.getServletName().equals(servletDescriptor._name)) {
return;
}
@@ -134,9 +135,12 @@
}
private ServletDescriptor getServletDescriptor(String clsName) {
-
- String servletName = JBossWSCreationUtils.classNameFromQualifiedName(clsName);
- if(servletName.endsWith("Impl") && servletName.length() > 4){
//$NON-NLS-1$
+ String servletName = model.getServiceName();
+ if (servletName == null) {
+ servletName = JBossWSCreationUtils
+ .classNameFromQualifiedName(clsName);
+ }
+ if (servletName.endsWith("Impl") && servletName.length() > 4) {
//$NON-NLS-1$
servletName = servletName.substring(0, servletName.length() - 4);
}
ServletDescriptor sd = new ServletDescriptor();
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceSampleCreationCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceSampleCreationCommand.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceSampleCreationCommand.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -0,0 +1,99 @@
+package org.jboss.tools.ws.creation.core.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+
+public class ServiceSampleCreationCommand extends AbstractDataModelOperation {
+
+ private ServiceModel model;
+ private static final String SRC = "src"; //$NON-NLS-1$
+ public static final String LINE_SEPARATOR = System
+ .getProperty("line.separator"); //$NON-NLS-1$
+
+ public ServiceSampleCreationCommand(ServiceModel model) {
+ this.model = model;
+ }
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ IStatus status = Status.OK_STATUS;
+ IJavaProject project = null;
+ try {
+ project = JBossWSCreationUtils.getJavaProjectByName(model
+ .getWebProjectName());
+ } catch (JavaModelException e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ return StatusUtils
+ .errorStatus(JBossWSCreationCoreMessages.Error_Create_Client_Sample);
+ }
+
+ createJavaClass(model.getCustomPackage(), JBossWSCreationUtils
+ .classNameFromQualifiedName(model.getServiceClasses().get(0)),
+ project);
+ return null;
+ }
+
+ private ICompilationUnit createJavaClass(String packageName,
+ String className, IJavaProject project) {
+ try {
+ IPath srcPath = project.getProject().getFolder(SRC).getFullPath();
+ IPackageFragmentRoot root = project
+ .findPackageFragmentRoot(srcPath);
+ if (packageName == null) {
+ packageName = ""; //$NON-NLS-1$
+ }
+ IPackageFragment pkg = root.createPackageFragment(packageName,
+ false, null);
+ ICompilationUnit wrapperCls = pkg.createCompilationUnit(className
+ + ".java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
+ if (!packageName.equals("")) { //$NON-NLS-1$
+ wrapperCls.createPackageDeclaration(packageName, null);
+ }
+
+ StringBuffer clsContent = new StringBuffer();
+ clsContent.append("(a)WebService()").append(LINE_SEPARATOR);
+ clsContent.append("public class ").append(className).append(" {" +
LINE_SEPARATOR);
+ clsContent.append("}").append(LINE_SEPARATOR);
+ wrapperCls.createType(clsContent.toString(), null, true, null);
+
+ wrapperCls.createImport("javax.jws.WebMethod", null,null);
+ wrapperCls.createImport("javax.jws.WebService", null,null);
+
+ IType serviceClsType = wrapperCls.findPrimaryType();
+ clsContent = new StringBuffer();
+ clsContent.append("@WebMethod()"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("public String sayHello(String name) {"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append(" System.out.println(\"Hello: \" + name);");
//$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append(" return \"Hello \" + name +
\"!\";"); //$NON-NLS-1$
+ clsContent.append(LINE_SEPARATOR);
+ clsContent.append("}"); //$NON-NLS-1$
+ serviceClsType.createMethod(clsContent.toString(), null, true, null);
+ wrapperCls.save(null, true);
+ return wrapperCls;
+ } catch (Exception e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ return null;
+ }
+ }
+
+}
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ServiceSampleCreationCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/data/ServiceModel.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/data/ServiceModel.java 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/data/ServiceModel.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -19,6 +19,7 @@
private String target;
private int wsScenario;
private boolean extension;
+ private String serviceName;
public int getWsScenario() {
return wsScenario;
@@ -165,4 +166,12 @@
public void setEnableSOAP12(boolean enable){
this.extension = enable;
}
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2010-01-27
09:36:41 UTC (rev 19950)
@@ -51,3 +51,5 @@
JBossWSRuntimeInstallPage_NoValidJBossWSRuntime=The specified target runtime should be
JBoss AS 5.0 or later.
Client_Sample_Run_Over= Call Over!
+Command=wsconsume.sh
+Bin=bin
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -61,6 +61,9 @@
public static String Error_Message_No_Runtime_Specified;
public static String Client_Sample_Run_Over;
+
+ public static String Command;
+ public static String Bin;
private JBossWSCreationCoreMessages() {
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-01-27 09:33:52 UTC
(rev 19949)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-01-27 09:36:41 UTC
(rev 19950)
@@ -10,10 +10,17 @@
org.eclipse.core.resources,
org.jboss.tools.ws.core,
org.eclipse.ui.ide,
- org.eclipse.wst.common.project.facet.core
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.jdt.core,
+ org.eclipse.jst.j2ee,
+ org.eclipse.jem.util,
+ org.jboss.tools.ws.creation.core,
+ org.eclipse.wst.common.frameworks
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.ui,
org.jboss.tools.ws.ui.messages,
org.jboss.tools.ws.ui.preferences
Bundle-Vendor: %PLUGIN_PROVIDER
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.jboss.tools.ws.creation.core.commands,
+ org.jboss.tools.ws.creation.core.data
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2010-01-27 09:33:52 UTC (rev
19949)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2010-01-27 09:36:41 UTC (rev
19950)
@@ -1,3 +1,5 @@
JBOSSWS_PREFERENCE_PAGE=JBossWS Preferences
+JBOSSWS_POPUPMENU_LABEL=JBoss Tools
+JBOSSWS_GENERATEACTION_LABEL=Create a Sample Web Service
PLUGIN_NAME=JBoss WebServices Tools
PLUGIN_PROVIDER=JBoss by Red Hat
\ No newline at end of file
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2010-01-27 09:33:52 UTC (rev 19949)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2010-01-27 09:36:41 UTC (rev 19950)
@@ -7,4 +7,36 @@
id="org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage">
</page>
</extension>
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution id="RedHatEclipse4Web_IProject"
objectClass="org.eclipse.core.resources.IProject">
+ <menu id="RedHat4Web" label="%JBOSSWS_POPUPMENU_LABEL"
path="additions">
+ <separator name="a">
+ </separator>
+ <separator name="b">
+ </separator>
+ <separator name="c">
+ </separator>
+ <separator name="d">
+ </separator>
+ </menu>
+ <action class="org.jboss.tools.ws.ui.wizards.JBossWSGenerateAction"
enablesFor="*"
id="org.jboss.tools.ws.ui.wizards.JBossWSGenerateAction"
label="%JBOSSWS_GENERATEACTION_LABEL" menubarPath="RedHat4Web/c">
+ </action>
+ </objectContribution>
+ </extension>
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution id="RedHatEclipse4Web_IJavaProject"
objectClass="org.eclipse.jdt.core.IJavaProject">
+ <menu id="RedHat4Web" label="%JBOSSWS_POPUPMENU_LABEL"
path="additions">
+ <separator name="a">
+ </separator>
+ <separator name="b">
+ </separator>
+ <separator name="c">
+ </separator>
+ <separator name="d">
+ </separator>
+ </menu>
+ <action class="org.jboss.tools.ws.ui.wizards.JBossWSGenerateAction"
enablesFor="*"
id="org.jboss.tools.ws.ui.wizards.JBossWSGenerateAction"
label="%JBOSSWS_GENERATEACTION_LABEL" menubarPath="RedHat4Web/c">
+ </action>
+ </objectContribution>
+ </extension>
</plugin>
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-01-27
09:36:41 UTC (rev 19950)
@@ -43,3 +43,12 @@
JBossWSLibraryListFieldEditor_ActionAdd=&Add
JBossWSLibraryListFieldEditor_ActionRemove=&Remove
JBossWSLibraryListFieldEditor_LIBRARY_JARS=Library Jars
+JBossWS_GenerateWizard_Title=Generate a Sample Web Service
+JBossWS_GenerateWizard_GenerateWebXmlPage_Title=Web Service
+JBossWS_GenerateWizard_GenerateWebXmlPage_Description=Create a Sample Web Service Name
+JBossWS_GenerateWizard_GenerateSampleClassPage_Title=Sample Web Service Class
+JBossWS_GenerateWizard_GenerateSampleClassPage_Description=Generate a Sample Web Service
Class
+JBossWS_GenerateWizard_GenerateWebXmlPage_ServiceName_Label=Name
+JBossWS_GenerateWizard_WizardPage_CheckButton_Label=Use the default value
+JBossWS_GenerateWizard_GenerateSampleClassPage_Package_Label=Package
+JBossWS_GenerateWizard_GenerateSampleClassPage_ClassName_Label=Class
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-01-27
09:33:52 UTC (rev 19949)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -76,6 +76,16 @@
public static String JBossWSLibraryListFieldEditor_ActionRemove;
public static String JBossWSLibraryListFieldEditor_LIBRARY_JARS;
+
+ public static String JBossWS_GenerateWizard_Title;
+ public static String JBossWS_GenerateWizard_GenerateWebXmlPage_Title;
+ public static String JBossWS_GenerateWizard_GenerateWebXmlPage_Description;
+ public static String JBossWS_GenerateWizard_GenerateSampleClassPage_Title;
+ public static String JBossWS_GenerateWizard_GenerateSampleClassPage_Description;
+ public static String JBossWS_GenerateWizard_GenerateWebXmlPage_ServiceName_Label;
+ public static String JBossWS_GenerateWizard_WizardPage_CheckButton_Label;
+ public static String JBossWS_GenerateWizard_GenerateSampleClassPage_Package_Label;
+ public static String JBossWS_GenerateWizard_GenerateSampleClassPage_ClassName_Label;
static {
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateAction.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateAction.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateAction.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -0,0 +1,95 @@
+package org.jboss.tools.ws.ui.wizards;
+
+import java.io.File;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
+import org.jboss.tools.ws.creation.core.commands.ServiceSampleCreationCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.ui.JBossWSUIPlugin;
+
+public class JBossWSGenerateAction implements IWorkbenchWindowActionDelegate {
+ private IJavaProject project;
+ private static String WEB = "web.xml"; //$NON-NLS-1$
+ private static File webFile;
+
+ public void dispose() {
+ }
+
+ public void init(IWorkbenchWindow window) {
+ }
+
+ public void run(IAction action) {
+ JBossWSGenerateWizard wizard = new JBossWSGenerateWizard();
+
+ WizardDialog dialog = new WizardDialog(JBossWSUIPlugin.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.create();
+ int result = dialog.open();
+ if (result == WizardDialog.OK) {
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(project.getElementName());
+ model.addServiceClasses(new StringBuffer().append(
+ wizard.getPackageName())
+ .append(".").append(wizard.getClassName()).toString()); //$NON-NLS-1$
+ model.setServiceName(wizard.getServiceName());
+ model.setUpdateWebxml(true);
+ model.setCustomPackage(wizard.getPackageName());
+ try {
+ new MergeWebXMLCommand(model).execute(null, null);
+ new ServiceSampleCreationCommand(model).execute(null, null);
+ } catch (ExecutionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ dialog.close();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ project = (IJavaProject) ((IStructuredSelection) selection)
+ .getFirstElement();
+ if (JavaEEProjectUtilities
+ .isDynamicWebProject(project.getProject())) {
+ webFile = findFileByPath(project.getProject().getLocation()
+ .toOSString());
+ if (webFile != null) {
+ action.setEnabled(true);
+ return;
+ }
+ }
+ }
+ action.setEnabled(false);
+
+ }
+
+ private File findFileByPath(String path) {
+ File ret = null;
+ File folder = new File(path);
+ if (folder.isDirectory()) {
+ File[] files = folder.listFiles();
+ for (File file : files) {
+ ret = findFileByPath(file.getAbsolutePath());
+ if (ret != null) {
+ break;
+ }
+ }
+ } else {
+ if (WEB.equals(folder.getName())) {
+ ret = folder;
+ }
+ }
+ return ret;
+ }
+
+}
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -0,0 +1,122 @@
+package org.jboss.tools.ws.ui.wizards;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+public class JBossWSGenerateSampleClassWizardPage extends WizardPage {
+ private JBossWSGenerateWizard wizard;
+ private Text packageName;
+ private Text className;
+ private Button checkDefault;
+
+ protected JBossWSGenerateSampleClassWizardPage(String pageName) {
+ super(pageName);
+ this
+ .setTitle(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateSampleClassPage_Title);
+ this
+ .setDescription(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateSampleClassPage_Description);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+ this.wizard = (JBossWSGenerateWizard) this.getWizard();
+ new Label(composite,
SWT.NONE).setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateSampleClassPage_Package_Label);
+ packageName = new Text(composite, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ packageName.setLayoutData(gd);
+ packageName.setText(wizard.getPackageName());
+ packageName.setEnabled(!wizard.isUseDefaultClassName());
+ packageName.addModifyListener(new ModifyListener(){
+
+ public void modifyText(ModifyEvent e) {
+ if
(!"".equals(packageName.getText())&&!"".equals(className.getText())){
//$NON-NLS-1$ //$NON-NLS-2$
+ setPageComplete(true);
+ }else {
+ setPageComplete(false);
+ }
+ }
+
+ });
+
+ new Label(composite,
SWT.NONE).setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateSampleClassPage_ClassName_Label);
+ className = new Text(composite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ className.setLayoutData(gd);
+ className.setText(wizard.getClassName());
+ className.setEnabled(!wizard.isUseDefaultClassName());
+ className.addModifyListener(new ModifyListener(){
+
+ public void modifyText(ModifyEvent e) {
+ if
(!"".equals(packageName.getText())&&!"".equals(className.getText())){
//$NON-NLS-1$ //$NON-NLS-2$
+ setPageComplete(true);
+ }else {
+ setPageComplete(false);
+ }
+ }
+
+ });
+
+ checkDefault = new Button(composite, SWT.CHECK);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ checkDefault.setLayoutData(gd);
+ checkDefault.setSelection(wizard.isUseDefaultClassName());
+ checkDefault.setText(JBossWSUIMessages.JBossWS_GenerateWizard_WizardPage_CheckButton_Label);
+ checkDefault.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (checkDefault.getSelection()) {
+ checkDefault.setSelection(true);
+ packageName.setText(wizard.PACKAGEDEFAULT);
+ className.setText(wizard.CLASSDEFAULT);
+ } else {
+ checkDefault.setSelection(false);
+ }
+ packageName.setEnabled(!checkDefault.getSelection());
+ className.setEnabled(!checkDefault.getSelection());
+ wizard.setUseDefaultClassName(!checkDefault.getSelection());
+ }
+
+ });
+ setControl(composite);
+
+ }
+
+ public boolean isPageComplete() {
+
if(!"".equals(packageName.getText())&&!"".equals(className.getText())){
//$NON-NLS-1$//$NON-NLS-2$
+ wizard.setPackageName(packageName.getText());
+ wizard.setClassName(className.getText());
+ return true;
+ }
+
+ return false;
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+}
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -0,0 +1,99 @@
+package org.jboss.tools.ws.ui.wizards;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+public class JBossWSGenerateWebXmlWizardPage extends WizardPage {
+ private JBossWSGenerateWizard wizard;
+ private Text name;
+ private Button checkDefault;
+
+
+ protected JBossWSGenerateWebXmlWizardPage(String pageName) {
+ super(pageName);
+ this.setTitle(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWebXmlPage_Title);
+ this.setDescription(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWebXmlPage_Description);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+ this.wizard = (JBossWSGenerateWizard)this.getWizard();
+ new Label (composite,
SWT.NONE).setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWebXmlPage_ServiceName_Label);
+ name = new Text(composite, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ name.setLayoutData(gd);
+ name.setText(wizard.getServiceName());
+ name.setEnabled(!wizard.isUseDefaultServiceName());
+ name.addModifyListener(new ModifyListener(){
+
+ public void modifyText(ModifyEvent e) {
+ if (!"".equals(name.getText())){ //$NON-NLS-1$
+ setPageComplete(true);
+ } else {
+ setPageComplete(false);
+ }
+ }
+
+ });
+
+
+ checkDefault = new Button(composite, SWT.CHECK);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ checkDefault.setLayoutData(gd);
+ checkDefault.setSelection(wizard.isUseDefaultServiceName());
+ checkDefault.setText(JBossWSUIMessages.JBossWS_GenerateWizard_WizardPage_CheckButton_Label);
+ checkDefault.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (checkDefault.getSelection()){
+ checkDefault.setSelection(true);
+ name.setText(wizard.NAMEDEFAULT);
+ } else {
+ checkDefault.setSelection(false);
+ }
+ name.setEnabled(!checkDefault.getSelection());
+ wizard.setUseDefaultServiceName(!checkDefault.getSelection());
+ }
+
+ });
+
+ setControl(composite);
+
+
+ }
+
+ public IWizardPage getNextPage(){
+ wizard.setServiceName(name.getText());
+ return super.getNextPage();
+ }
+
+ private Composite createDialogArea(Composite parent) {
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 7;
+ layout.marginWidth = 7;
+ layout.verticalSpacing = 4;
+ layout.horizontalSpacing = 4;
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+ }
+}
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-01-27
09:36:41 UTC (rev 19950)
@@ -0,0 +1,80 @@
+package org.jboss.tools.ws.ui.wizards;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+public class JBossWSGenerateWizard extends Wizard {
+
+ private JBossWSGenerateWebXmlWizardPage firstPage;
+ private JBossWSGenerateSampleClassWizardPage secondPage;
+
+ String NAMEDEFAULT = "HelloWorld"; //$NON-NLS-1$
+ String PACKAGEDEFAULT = "org.jboss.samples.webservices"; //$NON-NLS-1$
+ String CLASSDEFAULT = "HelloWorld"; //$NON-NLS-1$
+
+ private String serviceName = NAMEDEFAULT;
+ private String packageName = PACKAGEDEFAULT;
+ private String className = CLASSDEFAULT;
+ private boolean useDefaultServiceName = true;
+ private boolean useDefaultClassName = true;
+
+ public JBossWSGenerateWizard() {
+ super();
+ super.setWindowTitle(JBossWSUIMessages.JBossWS_GenerateWizard_Title);
+ super.setHelpAvailable(false);
+ }
+
+ public void addPages() {
+ super.addPages();
+ firstPage = new JBossWSGenerateWebXmlWizardPage("first"); //$NON-NLS-1$
+ secondPage = new JBossWSGenerateSampleClassWizardPage("second");
//$NON-NLS-1$
+ addPage(firstPage);
+ addPage(secondPage);
+ }
+
+ @Override
+ public boolean performFinish() {
+ return true;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public boolean isUseDefaultServiceName() {
+ return useDefaultServiceName;
+ }
+
+ public void setUseDefaultServiceName(boolean useDefaultServiceName) {
+ this.useDefaultServiceName = useDefaultServiceName;
+ }
+
+ public boolean isUseDefaultClassName() {
+ return useDefaultClassName;
+ }
+
+ public void setUseDefaultClassName(boolean useDefaultClassName) {
+ this.useDefaultClassName = useDefaultClassName;
+ }
+
+}
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain