Author: bfitzpat
Date: 2010-01-27 13:51:21 -0500 (Wed, 27 Jan 2010)
New Revision: 19968
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/icons/obj16/new_webserv_wiz.gif
Removed:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateAction.java
Modified:
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
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
Log:
OPEN - issue JBIDE-5715: Dynamic Web Service Project Wizard
https://jira.jboss.org/jira/browse/JBIDE-5715
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/icons/obj16/new_webserv_wiz.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.ui/icons/obj16/new_webserv_wiz.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2010-01-27 18:18:06 UTC (rev
19967)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2010-01-27 18:51:21 UTC (rev
19968)
@@ -2,4 +2,5 @@
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
+PLUGIN_PROVIDER=JBoss by Red Hat
+JBOSSWS_WIZARD_DESC=Create a sample web service
\ 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 18:18:06 UTC (rev 19967)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2010-01-27 18:51:21 UTC (rev 19968)
@@ -7,36 +7,35 @@
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
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="org.jboss.ide.eclipse.ui.wizards"
+ class="org.jboss.tools.ws.ui.wizards.JBossWSGenerateWizard"
+ hasPages="true"
+ icon="icons/obj16/new_webserv_wiz.gif"
+ id="org.jboss.tools.ws.ui.wizard.wsgenerate"
+ name="%JBOSSWS_GENERATEACTION_LABEL">
+ <selection
+ class="org.eclipse.core.resources.IProject">
+ </selection>
+ <description>
+ %JBOSSWS_WIZARD_DESC
+ </description>
+ </wizard>
+ <wizard
+ category="org.eclipse.jst.ws.ui.new"
+ class="org.jboss.tools.ws.ui.wizards.JBossWSGenerateWizard"
+ hasPages="true"
+ icon="icons/obj16/new_webserv_wiz.gif"
+ id="org.jboss.tools.ws.ui.wizard.wsgenerate2"
+ name="%JBOSSWS_GENERATEACTION_LABEL">
+ <selection
+ class="org.eclipse.core.resources.IProject">
+ </selection>
+ <description>
+ %JBOSSWS_WIZARD_DESC
+ </description>
+ </wizard>
</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
18:18:06 UTC (rev 19967)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-01-27
18:51:21 UTC (rev 19968)
@@ -52,3 +52,4 @@
JBossWS_GenerateWizard_WizardPage_CheckButton_Label=Use the default value
JBossWS_GenerateWizard_GenerateSampleClassPage_Package_Label=Package
JBossWS_GenerateWizard_GenerateSampleClassPage_ClassName_Label=Class
+JBossWS_GenerateWizard_NotDynamicWebProject_Error=This wizard may only be used on Dynamic
Web Projects.
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
18:18:06 UTC (rev 19967)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-01-27
18:51:21 UTC (rev 19968)
@@ -86,6 +86,7 @@
public static String JBossWS_GenerateWizard_WizardPage_CheckButton_Label;
public static String JBossWS_GenerateWizard_GenerateSampleClassPage_Package_Label;
public static String JBossWS_GenerateWizard_GenerateSampleClassPage_ClassName_Label;
+ public static String JBossWS_GenerateWizard_NotDynamicWebProject_Error;
static {
Deleted:
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 2010-01-27
18:18:06 UTC (rev 19967)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateAction.java 2010-01-27
18:51:21 UTC (rev 19968)
@@ -1,94 +0,0 @@
-package org.jboss.tools.ws.ui.wizards;
-
-import java.io.File;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-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 IProject 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.getName());
- 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 = (IProject) ((IStructuredSelection) selection)
- .getFirstElement();
- if (project != null
- && JavaEEProjectUtilities.isDynamicWebProject(project)) {
- webFile = findFileByPath(project.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;
- }
-
-}
Modified:
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 2010-01-27
18:18:06 UTC (rev 19967)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java 2010-01-27
18:51:21 UTC (rev 19968)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.ui.wizards;
import org.eclipse.jface.wizard.WizardPage;
Modified:
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 2010-01-27
18:18:06 UTC (rev 19967)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java 2010-01-27
18:51:21 UTC (rev 19968)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.ui.wizards;
import org.eclipse.jface.wizard.IWizardPage;
Modified:
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 2010-01-27
18:18:06 UTC (rev 19967)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-01-27
18:51:21 UTC (rev 19968)
@@ -1,9 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.ui.wizards;
+import java.io.File;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+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.messages.JBossWSUIMessages;
-public class JBossWSGenerateWizard extends Wizard {
+public class JBossWSGenerateWizard extends Wizard implements INewWizard {
private JBossWSGenerateWebXmlWizardPage firstPage;
private JBossWSGenerateSampleClassWizardPage secondPage;
@@ -17,6 +40,12 @@
private String className = CLASSDEFAULT;
private boolean useDefaultServiceName = true;
private boolean useDefaultClassName = true;
+
+ private IStructuredSelection selection;
+ private IProject project;
+ private static String WEB = "web.xml"; //$NON-NLS-1$
+ private File webFile;
+ private boolean hasInited = false;
public JBossWSGenerateWizard() {
super();
@@ -34,6 +63,22 @@
@Override
public boolean performFinish() {
+ if (canFinish()) {
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(project.getName());
+ model.addServiceClasses(new StringBuffer().append(
+ getPackageName())
+ .append(".").append(getClassName()).toString()); //$NON-NLS-1$
+ model.setServiceName(getServiceName());
+ model.setUpdateWebxml(true);
+ model.setCustomPackage(getPackageName());
+ try {
+ new MergeWebXMLCommand(model).execute(null, null);
+ new ServiceSampleCreationCommand(model).execute(null, null);
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
return true;
}
@@ -77,4 +122,53 @@
this.useDefaultClassName = useDefaultClassName;
}
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+
+ if (this.selection.getFirstElement() instanceof JavaProject) {
+ project = ((JavaProject)this.selection.getFirstElement()).getProject();
+ }
+ else if (this.selection.getFirstElement() instanceof IProject) {
+ project = (IProject) this.selection.getFirstElement();
+ }
+ if (project != null
+ && JavaEEProjectUtilities.isDynamicWebProject(project)) {
+ webFile = findFileByPath(project.getLocation().toOSString());
+ if (webFile != null) {
+ // TODO: if this is valid, we can finish
+ }
+ }
+ hasInited = true;
+ }
+
+ @Override
+ public boolean canFinish() {
+ if (hasInited && webFile == null ) {
+ if (firstPage != null && !firstPage.getControl().isDisposed()) {
+ firstPage.setErrorMessage(JBossWSUIMessages.JBossWS_GenerateWizard_NotDynamicWebProject_Error);
+ }
+ return false;
+ }
+ return super.canFinish();
+ }
+
+ 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;
+ }
+
}