Author: bfitzpat
Date: 2010-01-29 17:44:07 -0500 (Fri, 29 Jan 2010)
New Revision: 20031
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/ServletDescriptor.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/data/ServiceModel.java
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java
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
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-29
22:05:14 UTC (rev 20030)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2010-01-29
22:44:07 UTC (rev 20031)
@@ -17,8 +17,8 @@
org.eclipse.wst.command.env,
org.apache.ant,
org.apache.xerces,
- org.eclipse.jst.j2ee,
- org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.j2ee;visibility:=reexport,
+ org.eclipse.jst.j2ee.core;visibility:=reexport,
org.eclipse.emf.common,
org.eclipse.emf.ecore,
org.eclipse.jdt.core,
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-29
22:05:14 UTC (rev 20030)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/data/ServiceModel.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -20,6 +20,7 @@
private int wsScenario;
private boolean extension;
private String serviceName;
+ private String customClassName;
public int getWsScenario() {
return wsScenario;
@@ -174,4 +175,12 @@
public String getServiceName() {
return serviceName;
}
+
+ public void setCustomClassName(String className) {
+ this.customClassName = className;
+ }
+
+ public String getCustomClassName() {
+ return customClassName;
+ }
}
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-29 22:05:14 UTC
(rev 20030)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-01-29 22:44:07 UTC
(rev 20031)
@@ -23,5 +23,6 @@
org.jboss.tools.ws.ui.preferences
Bundle-Vendor: %PLUGIN_PROVIDER
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.jboss.tools.ws.creation.core.commands,
+Import-Package: org.eclipse.jst.javaee.web,
+ org.jboss.tools.ws.creation.core.commands,
org.jboss.tools.ws.creation.core.data
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java 2010-01-29
22:05:14 UTC (rev 20030)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -11,8 +11,12 @@
package org.jboss.tools.ws.ui;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
import org.osgi.framework.BundleContext;
/**
@@ -63,4 +67,28 @@
path = "icons/" + path; //$NON-NLS-1$
return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.ws.ui",
path); //$NON-NLS-1$
}
+
+ public static boolean isDebugEnabled() {
+ return plugin.isDebugging();
+ }
+
+ public static void log(String msg) {
+ if(isDebugEnabled()) plugin.getLog().log(new Status(Status.INFO, PLUGIN_ID, Status.OK,
msg, null));
+ }
+
+ public static void log(IStatus status) {
+ if(isDebugEnabled() || !status.isOK()) plugin.getLog().log(status);
+ }
+
+ public static void log(String message, Throwable exception) {
+ plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, message,
exception));
+ }
+
+ public static void log(Throwable ex) {
+ plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK,
JBossWSUIMessages.JBossWS_UI_PLUGIN_NO_MESSAGES, ex));
+ }
+
+ public static Shell getShell() {
+ return plugin.getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
}
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-29
22:05:14 UTC (rev 20030)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-01-29
22:44:07 UTC (rev 20031)
@@ -55,3 +55,8 @@
Error_JBossWS_GenerateWizard_NotDynamicWebProject=The project must be a Dynamic Web
Project and contain a web.xml in a right Location
Error_JBossWS_GenerateWizard_ClassName_Same=The class name has been used in the web
project.
JBossWS_GenerateWizard_MessageDialog_Title=Error
+Error_JBossWS_GenerateWizard_ServiceName_Empty=The Service Name may not be an empty
string.
+Error_JBossWS_GenerateWizard_ClassName_Empty=The Class Name may not be an empty string.
+Error_JBossWS_GenerateWizard_PackageName_Empty=The Package Name may not be an empty
string.
+Error_JBossWS_GenerateWizard=Problems encountered while creating the web.xml and Java
class entries.
+JBossWS_UI_PLUGIN_NO_MESSAGES=No message
\ No newline at end of file
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-29
22:05:14 UTC (rev 20030)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -89,8 +89,12 @@
public static String Error_JBossWS_GenerateWizard_NotDynamicWebProject;
public static String Error_JBossWS_GenerateWizard_ClassName_Same;
public static String JBossWS_GenerateWizard_MessageDialog_Title;
+ public static String Error_JBossWS_GenerateWizard_ServiceName_Empty;
+ public static String Error_JBossWS_GenerateWizard_ClassName_Empty;
+ public static String Error_JBossWS_GenerateWizard_PackageName_Empty;
+
+ public static String JBossWS_UI_PLUGIN_NO_MESSAGES;
-
static {
NLS.initializeMessages(BUNDLE_NAME, JBossWSUIMessages.class);
}
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-29
22:05:14 UTC (rev 20030)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.ws.ui.wizards;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -22,6 +24,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
public class JBossWSGenerateSampleClassWizardPage extends WizardPage {
@@ -51,11 +54,8 @@
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);
- }
+ wizard.setClassName(packageName.getText());
+ setPageComplete(isPageComplete());
}
});
@@ -65,16 +65,13 @@
className = new Text(composite, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
className.setLayoutData(gd);
- className.setText(wizard.getClassName());
+ className.setText(updateDefaultName());
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);
- }
+ wizard.setClassName(className.getText());
+ setPageComplete(isPageComplete());
}
});
@@ -110,13 +107,7 @@
}
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;
+ return validate();
}
private Composite createDialogArea(Composite parent) {
@@ -132,4 +123,36 @@
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
return composite;
}
+
+ private String updateDefaultName () {
+ ServiceModel model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ String currentName = wizard.getClassName();
+ String testName = currentName;
+ IStatus status = JBossWSGenerateWizardValidator.isWSClassValid(testName,
wizard.getProject());
+ int i = 1;
+ while (status != null) {
+ testName = currentName + i;
+ wizard.setClassName(testName);
+ model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ status = JBossWSGenerateWizardValidator.isWSClassValid(testName,
wizard.getProject());
+ i++;
+ }
+ return testName;
+ }
+
+ private boolean validate() {
+ ServiceModel model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ IStatus status =
JBossWSGenerateWizardValidator.isWSClassValid(model.getCustomClassName(),
wizard.getProject());
+ if (status != null) {
+ setMessage(status.getMessage(), DialogPage.ERROR);
+ return false;
+ }
+ else {
+ setMessage(null);
+ return true;
+ }
+ }
}
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-29
22:05:14 UTC (rev 20030)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.ws.ui.wizards;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
@@ -23,9 +25,11 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
public class JBossWSGenerateWebXmlWizardPage extends WizardPage {
+
private JBossWSGenerateWizard wizard;
private Text name;
private Button checkDefault;
@@ -46,16 +50,13 @@
name = new Text(composite, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
name.setLayoutData(gd);
- name.setText(wizard.getServiceName());
+ name.setText(updateDefaultName());
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);
- }
+ wizard.setServiceName(name.getText());
+ setPageComplete(isPageComplete());
}
});
@@ -84,9 +85,8 @@
}
});
-
+
setControl(composite);
-
}
public IWizardPage getNextPage() {
@@ -107,4 +107,41 @@
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
return composite;
}
+
+ @Override
+ public boolean isPageComplete() {
+ return validate();
+ }
+
+ private String updateDefaultName () {
+ ServiceModel model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ String currentName = wizard.getServiceName();
+ String testName = currentName;
+ IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
+ int i = 1;
+ while (status != null) {
+ testName = currentName + i;
+ wizard.setServiceName(testName);
+ model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ status = JBossWSGenerateWizardValidator.isWSNameValid();
+ i++;
+ }
+ return testName;
+ }
+
+ private boolean validate() {
+ ServiceModel model = wizard.getServiceModel();
+ JBossWSGenerateWizardValidator.setServiceModel(model);
+ IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
+ if (status != null) {
+ setMessage(status.getMessage(), DialogPage.ERROR);
+ return false;
+ }
+ else {
+ setMessage(null);
+ return true;
+ }
+ }
}
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-29
22:05:14 UTC (rev 20030)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -15,7 +15,9 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -26,6 +28,7 @@
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;
import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
import org.jboss.tools.ws.ui.utils.UIUtils;
@@ -46,6 +49,7 @@
private IStructuredSelection selection;
private IProject project;
+
private static String WEB = "web.xml"; //$NON-NLS-1$
private static String JAVA = ".java"; //$NON-NLS-1$
private static String WEBINF = "WEB-INF"; //$NON-NLS-1$
@@ -93,7 +97,7 @@
MergeWebXMLCommand mergeCommand = new MergeWebXMLCommand(model);
status = mergeCommand.execute(null, null);
} catch (ExecutionException e) {
- e.printStackTrace();
+ JBossWSUIPlugin.log(e);
}
if (status != null && status.getSeverity() == Status.ERROR) {
MessageDialog
@@ -105,8 +109,21 @@
}
try {
new ServiceSampleCreationCommand(model).execute(null, null);
+ getProject().refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor());
} catch (ExecutionException e) {
- e.printStackTrace();
+ JBossWSUIPlugin.log(e);
+ MessageDialog
+ .openError(
+ this.getShell(),
+ JBossWSUIMessages.JBossWS_GenerateWizard_MessageDialog_Title,
+ e.getMessage());
+ } catch (CoreException e) {
+ JBossWSUIPlugin.log(e);
+ MessageDialog
+ .openError(
+ this.getShell(),
+ JBossWSUIMessages.JBossWS_GenerateWizard_MessageDialog_Title,
+ e.getMessage());
}
}
return true;
@@ -196,4 +213,21 @@
public void setUseDefaultClassName(boolean useDefaultClassName) {
this.useDefaultClassName = useDefaultClassName;
}
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public ServiceModel getServiceModel() {
+ 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());
+ model.setCustomClassName(getClassName());
+ return model;
+ }
+
}
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.jst.javaee.core.UrlPatternType;
+import org.eclipse.jst.javaee.web.Servlet;
+import org.eclipse.jst.javaee.web.ServletMapping;
+import org.eclipse.jst.javaee.web.WebApp;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+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;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+public class JBossWSGenerateWizardValidator {
+
+ private static ServiceModel model;
+ private static ServletDescriptor[] descriptors;
+
+ private static String JAVA = ".java"; //$NON-NLS-1$
+
+ public static void setServiceModel ( ServiceModel inModel ) {
+ model = inModel;
+
+ descriptors = new ServletDescriptor[model.getServiceClasses().size()];
+ List<String> serviceClasses = model.getServiceClasses();
+ for (int i = 0; i < serviceClasses.size(); i++) {
+ descriptors[i] = getServletDescriptor(serviceClasses.get(i));
+ }
+ }
+
+ public static IStatus isWSNameValid() {
+ final IModelProvider provider = ModelProviderManager
+ .getModelProvider(JBossWSCreationUtils.getProjectByName(model
+ .getWebProjectName()));
+ Object object = provider.getModelObject();
+ if (object instanceof WebApp) {
+ WebApp webApp = (WebApp) object;
+ if (model != null) {
+ for (int i = 0; i < descriptors.length; i++) {
+ if (descriptors[i].getName().trim().length() == 0 ) {
+ return
StatusUtils.errorStatus(JBossWSUIMessages.Error_JBossWS_GenerateWizard_ServiceName_Empty);
+ }
+ List<?> theServlets = webApp.getServlets();
+ for (int j = 0; j < theServlets.size(); j++) {
+ Servlet aServlet = (Servlet) theServlets
+ .get(j);
+ if (aServlet.getServletName().equals(descriptors[i].getName())) {
+ return
StatusUtils.errorStatus(JBossWSCreationCoreMessages.Error_JBossWS_GenerateWizard_WSName_Same);
+ }
+ }
+ List<?> theServletMappings = webApp.getServletMappings();
+ for (int j = 0; j < theServletMappings.size(); j++) {
+ ServletMapping aServletMapping = (ServletMapping) theServletMappings
+ .get(j);
+ List<?> urlPatterns = aServletMapping.getUrlPatterns();
+ for (int k = 0; k < urlPatterns.size(); k++) {
+ UrlPatternType upt = (UrlPatternType) urlPatterns.get(k);
+ if (aServletMapping.getServletName().equals(descriptors[i].getName()) ||
+ upt.getValue().equals(descriptors[i].getMappings())) {
+ return
StatusUtils.errorStatus(JBossWSCreationCoreMessages.Error_JBossWS_GenerateWizard_WSName_Same);
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+ return null;
+ }
+
+ public static IStatus isWSClassValid(String className, IProject project) {
+ if (model.getCustomPackage().trim().length() == 0) {
+ // empty package name
+ return
StatusUtils.errorStatus(JBossWSUIMessages.Error_JBossWS_GenerateWizard_ClassName_Same);
+ }
+ else if (model.getCustomClassName().trim().length() == 0 ) {
+ // empty class name
+ return
StatusUtils.errorStatus(JBossWSUIMessages.Error_JBossWS_GenerateWizard_ClassName_Same);
+ }
+ else {
+ File file = findFileByPath(className + JAVA, project
+ .getLocation().toOSString());
+ if (file != null) {
+ // class already exists
+ return
StatusUtils.errorStatus(JBossWSUIMessages.Error_JBossWS_GenerateWizard_ClassName_Same);
+ }
+ }
+ return null;
+ }
+
+ private static ServletDescriptor getServletDescriptor(String clsName) {
+ 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();
+ sd.setName(servletName);
+ sd.setDisplayName(sd.getName());
+ sd.setClassName(clsName);
+ sd.setMappings(JBossWSCreationCoreMessages.Separator_Java + sd.getDisplayName());
+ return sd;
+ }
+
+ private static File findFileByPath(String name, String path) {
+ File ret = null;
+ File folder = new File(path);
+ if (folder.isDirectory()) {
+ File[] files = folder.listFiles();
+ for (File file : files) {
+ ret = findFileByPath(name, file.getAbsolutePath());
+ if (ret != null) {
+ break;
+ }
+ }
+ } else {
+ if (name.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/JBossWSGenerateWizardValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/ServletDescriptor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/ServletDescriptor.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/ServletDescriptor.java 2010-01-29
22:44:07 UTC (rev 20031)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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;
+
+public class ServletDescriptor {
+ private String _name;
+ private String _className;
+ private String _displayName;
+ private String _mappings;
+
+ public ServletDescriptor() {
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ public String getClassName() {
+ return _className;
+ }
+
+ public void setClassName(String className) {
+ _className = className;
+ }
+
+ public String getDisplayName() {
+ return _displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ _displayName = displayName;
+ }
+
+ public String getMappings() {
+ return _mappings;
+ }
+
+ public void setMappings(String mappings) {
+ _mappings = mappings;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/ServletDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain