Author: bfitzpat
Date: 2010-02-18 20:10:07 -0500 (Thu, 18 Feb 2010)
New Revision: 20373
Modified:
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
Log:
Fixes for JBIDE-5877: Web service sample wizard not working
https://jira.jboss.org/jira/browse/JBIDE-5877 - to CR2 branch
Modified:
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
---
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-02-19
01:08:19 UTC (rev 20372)
+++
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-02-19
01:10:07 UTC (rev 20373)
@@ -44,10 +44,10 @@
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_GenerateWebXmlPage_Title=Project and Web Service Name
+JBossWS_GenerateWizard_GenerateWebXmlPage_Description=Specify the Dynamic Web Project and
service name for the new sample web service.
JBossWS_GenerateWizard_GenerateSampleClassPage_Title=Sample Web Service Class
-JBossWS_GenerateWizard_GenerateSampleClassPage_Description=Generate a Sample Web Service
Class
+JBossWS_GenerateWizard_GenerateSampleClassPage_Description=Define the package and class
name for the generated 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
@@ -59,4 +59,8 @@
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
+JBossWS_UI_PLUGIN_NO_MESSAGES=No message
+JBossWSGenerateWebXmlWizardPage_Project_Group=Dynamic Web Project Name
+JBossWSGenerateWebXmlWizardPage_Project_Group_Tooltip=If no Dynamic Web Project exists,
you must create one before creating your sample web service.
+JBossWSGenerateWebXmlWizardPage_Web_Service_Group=Web Service
+JBossWSGenerateWizard_NoProjectSelected=No project selected. Please select a Dynamic Web
Project to continue.
Modified:
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
---
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-02-19
01:08:19 UTC (rev 20372)
+++
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-02-19
01:10:07 UTC (rev 20373)
@@ -95,6 +95,14 @@
public static String JBossWS_UI_PLUGIN_NO_MESSAGES;
+ public static String JBossWSGenerateWebXmlWizardPage_Project_Group;
+
+ public static String JBossWSGenerateWebXmlWizardPage_Project_Group_Tooltip;
+
+ public static String JBossWSGenerateWebXmlWizardPage_Web_Service_Group;
+
+ public static String JBossWSGenerateWizard_NoProjectSelected;
+
static {
NLS.initializeMessages(BUNDLE_NAME, JBossWSUIMessages.class);
}
Modified:
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java
===================================================================
---
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java 2010-02-19
01:08:19 UTC (rev 20372)
+++
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java 2010-02-19
01:10:07 UTC (rev 20373)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.ws.ui.wizards;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.wizard.WizardPage;
@@ -128,6 +129,22 @@
ServiceModel model = wizard.getServiceModel();
JBossWSGenerateWizardValidator.setServiceModel(model);
String currentName = wizard.getClassName();
+ if (wizard.getProject() == null) {
+ return currentName;
+ }
+ else {
+ boolean isDynamicWebProject = false;
+ try {
+ if
(wizard.getProject().getNature("org.eclipse.wst.common.project.facet.core.nature")
!= null) { //$NON-NLS-1$
+ isDynamicWebProject = true;
+ }
+ } catch (CoreException e) {
+ // ignore
+ }
+ if (!isDynamicWebProject) {
+ return currentName;
+ }
+ }
String testName = currentName;
IStatus status = JBossWSGenerateWizardValidator.isWSClassValid(testName,
wizard.getProject());
int i = 1;
@@ -142,7 +159,7 @@
return testName;
}
- private boolean validate() {
+ protected boolean validate() {
ServiceModel model = wizard.getServiceModel();
JBossWSGenerateWizardValidator.setServiceModel(model);
IStatus status =
JBossWSGenerateWizardValidator.isWSClassValid(model.getCustomClassName(),
wizard.getProject());
@@ -155,4 +172,8 @@
return true;
}
}
+
+ protected void refresh() {
+ className.setText(updateDefaultName());
+ }
}
Modified:
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java
===================================================================
---
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java 2010-02-19
01:08:19 UTC (rev 20372)
+++
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java 2010-02-19
01:10:07 UTC (rev 20373)
@@ -10,10 +10,14 @@
******************************************************************************/
package org.jboss.tools.ws.ui.wizards;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
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.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -22,7 +26,9 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
@@ -32,7 +38,9 @@
private JBossWSGenerateWizard wizard;
private Text name;
+ private Combo projects;
private Button checkDefault;
+ private boolean bHasChanged = false;
protected JBossWSGenerateWebXmlWizardPage(String pageName) {
super(pageName);
@@ -45,10 +53,46 @@
public void createControl(Composite parent) {
Composite composite = createDialogArea(parent);
this.wizard = (JBossWSGenerateWizard) this.getWizard();
- new Label(composite, SWT.NONE)
+
+ Group group = new Group (composite, SWT.NONE);
+ group.setText(JBossWSUIMessages.JBossWSGenerateWebXmlWizardPage_Project_Group);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ group.setLayout(new GridLayout(2, false));
+ group.setLayoutData(gd);
+
+ projects = new Combo(group, SWT.BORDER | SWT.DROP_DOWN);
+ projects.setToolTipText(JBossWSUIMessages.JBossWSGenerateWebXmlWizardPage_Project_Group_Tooltip);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ projects.setLayoutData(gd);
+ refreshProjectList(wizard.getServiceModel().getWebProjectName());
+
+ projects.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ wizard.setProject(projects.getText());
+ name.setText(updateDefaultName());
+ wizard.getSecondPage().refresh();
+ bHasChanged = true;
+ setPageComplete(isPageComplete());
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ Group group2 = new Group (composite, SWT.NONE);
+ group2.setText(JBossWSUIMessages.JBossWSGenerateWebXmlWizardPage_Web_Service_Group);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ group2.setLayout(new GridLayout(2, false));
+ group2.setLayoutData(gd);
+
+ new Label(group2, SWT.NONE)
.setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWebXmlPage_ServiceName_Label);
- name = new Text(composite, SWT.BORDER);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ name = new Text(group2, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
name.setLayoutData(gd);
name.setText(updateDefaultName());
name.setEnabled(!wizard.isUseDefaultServiceName());
@@ -56,12 +100,13 @@
public void modifyText(ModifyEvent e) {
wizard.setServiceName(name.getText());
+ bHasChanged = true;
setPageComplete(isPageComplete());
}
});
- checkDefault = new Button(composite, SWT.CHECK);
+ checkDefault = new Button(group2, SWT.CHECK);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
checkDefault.setLayoutData(gd);
@@ -89,6 +134,20 @@
setControl(composite);
}
+ private void refreshProjectList ( String projectName ) {
+ String[] projectNames = getProjects();
+ boolean foundInitialProject = false;
+ projects.removeAll();
+ for (int i = 0; i < projectNames.length; i++) {
+ projects.add(projectNames[i]);
+ if (projectNames[i].equals(projectName)) {
+ foundInitialProject = true;
+ }
+ }
+ if (foundInitialProject)
+ projects.setText(projectName);
+ }
+
public IWizardPage getNextPage() {
wizard.setServiceName(name.getText());
return super.getNextPage();
@@ -117,8 +176,15 @@
ServiceModel model = wizard.getServiceModel();
JBossWSGenerateWizardValidator.setServiceModel(model);
String currentName = wizard.getServiceName();
+ IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
+ try {
+ if (status.getSeverity() == IStatus.ERROR &&
!JavaEEProjectUtilities.isDynamicWebProject(wizard.getProject())) {
+ return currentName;
+ }
+ } catch (NullPointerException npe) {
+ return currentName;
+ }
String testName = currentName;
- IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
int i = 1;
while (status != null) {
testName = currentName + i;
@@ -134,14 +200,33 @@
private boolean validate() {
ServiceModel model = wizard.getServiceModel();
JBossWSGenerateWizardValidator.setServiceModel(model);
+ if (!projects.isDisposed() && projects.getText().length() > 0) {
+ model.setWebProjectName(projects.getText());
+ }
IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
if (status != null) {
- setMessage(status.getMessage(), DialogPage.ERROR);
+ setErrorMessage(status.getMessage());
return false;
}
else {
- setMessage(null);
+ setErrorMessage(null);
return true;
}
}
+
+ private String[] getProjects() {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ ArrayList<String> dynamicProjects = new ArrayList<String>();
+ for (int i = 0; i < projects.length; i++) {
+ boolean isDynamicWebProject =
JavaEEProjectUtilities.isDynamicWebProject(projects[i]);
+ if (isDynamicWebProject) {
+ dynamicProjects.add(projects[i].getName());
+ }
+ }
+ return dynamicProjects.toArray(new String[dynamicProjects.size()]);
+ }
+
+ protected boolean hasChanged() {
+ return bHasChanged;
+ }
}
Modified:
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
===================================================================
---
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-02-19
01:08:19 UTC (rev 20372)
+++
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-02-19
01:10:07 UTC (rev 20373)
@@ -15,6 +15,7 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -145,9 +146,18 @@
@Override
public boolean canFinish() {
+ if (getProject() == null) {
+ if (firstPage != null && !firstPage.getControl().isDisposed()) {
+ if (firstPage.hasChanged())
+ firstPage
+ .setErrorMessage(JBossWSUIMessages.JBossWSGenerateWizard_NoProjectSelected);
+ }
+ return false;
+ }
if (hasInited && (webFile == null || !webFile.exists())) {
if (firstPage != null && !firstPage.getControl().isDisposed()) {
- firstPage
+ if (firstPage.hasChanged())
+ firstPage
.setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NotDynamicWebProject);
}
return false;
@@ -220,9 +230,13 @@
public ServiceModel getServiceModel() {
ServiceModel model = new ServiceModel();
- model.setWebProjectName(project.getName());
- model.addServiceClasses(new StringBuffer().append(getPackageName())
+ if (project != null) {
+ model.setWebProjectName(project.getName());
+ }
+ if (getPackageName() != null) {
+ model.addServiceClasses(new StringBuffer().append(getPackageName())
.append(".").append(getClassName()).toString()); //$NON-NLS-1$
+ }
model.setServiceName(getServiceName());
model.setUpdateWebxml(true);
model.setCustomPackage(getPackageName());
@@ -230,4 +244,27 @@
return model;
}
+ public JBossWSGenerateWebXmlWizardPage getFirstPage() {
+ return this.firstPage;
+ }
+
+ public JBossWSGenerateSampleClassWizardPage getSecondPage() {
+ return this.secondPage;
+ }
+
+ public void setProject (String projectName) {
+ if (projectName != null && projectName.trim().length() > 0) {
+ IProject test =
+ ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (test != null) {
+ this.project = test;
+ if (project != null
+ && JavaEEProjectUtilities.isDynamicWebProject(project)) {
+ webFile = project.getParent().getFolder(
+ UIUtils.getWebContentRootPath(project).append(WEBINF))
+ .getFile(WEB);
+ }
+ }
+ }
+ }
}
Modified:
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
===================================================================
---
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java 2010-02-19
01:08:19 UTC (rev 20372)
+++
branches/jbosstools-3.1.0.RC2/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java 2010-02-19
01:10:07 UTC (rev 20373)
@@ -45,6 +45,20 @@
}
public static IStatus isWSNameValid() {
+ if (model.getWebProjectName() == null) {
+ return
StatusUtils.errorStatus(JBossWSUIMessages.JBossWSGenerateWizard_NoProjectSelected);
+ }
+ else {
+ try {
+ ModelProviderManager
+ .getModelProvider(JBossWSCreationUtils.getProjectByName(model
+ .getWebProjectName()));
+ } catch (IllegalArgumentException iae) {
+ // ignore
+ model.setWebProjectName(null);
+ return
StatusUtils.errorStatus(JBossWSUIMessages.JBossWSGenerateWizard_NoProjectSelected);
+ }
+ }
final IModelProvider provider = ModelProviderManager
.getModelProvider(JBossWSCreationUtils.getProjectByName(model
.getWebProjectName()));
@@ -93,6 +107,9 @@
// empty class name
return
StatusUtils.errorStatus(JBossWSUIMessages.Error_JBossWS_GenerateWizard_ClassName_Same);
}
+ else if (project == null) {
+ return
StatusUtils.errorStatus(JBossWSUIMessages.JBossWSGenerateWizard_NoProjectSelected);
+ }
else {
File file = findFileByPath(className + JAVA, project
.getLocation().toOSString());