Author: Grid.Qian
Date: 2010-07-20 04:36:09 -0400 (Tue, 20 Jul 2010)
New Revision: 23578
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardPage.java
Removed:
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
Modified:
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/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/JBossWSGenerateWizard.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
Log:
JBIDE-6592: commit to trunk for M2
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-07-20 06:29:52 UTC
(rev 23577)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-07-20 08:36:09 UTC
(rev 23578)
@@ -31,7 +31,8 @@
javax.wsdl;bundle-version="1.6.2",
org.jdom,
javax.xml.ws,
- org.eclipse.ui.forms
+ org.eclipse.ui.forms,
+ org.eclipse.emf.common
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.ui,
org.jboss.tools.ws.ui.messages,
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-07-20
06:29:52 UTC (rev 23577)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-07-20
08:36:09 UTC (rev 23578)
@@ -31,19 +31,17 @@
JBossWSLibraryListFieldEditor_ActionRemove=&Remove
JBossWSLibraryListFieldEditor_LIBRARY_JARS=Library Jars
JBossWS_GenerateWizard_Title=Generate a Sample Web Service
-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=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
-JBossWS_GenerateWizard_GenerateSampleClassPage_ClassName_Label=Class
+JBossWS_GenerateWizard_GenerateWizardPage_Title=Project and Web Service Name
+JBossWS_GenerateWizard_GenerateWizardPage_Description=Specify the Dynamic Web Project,
service, package and class name for the sample web service and web service class.
+JBossWS_GenerateWizard_GenerateWizardPage_ServiceName_Label=Name
+JBossWS_GenerateWizard_GenerateWizardPage_Package_Label=Package
+JBossWS_GenerateWizard_GenerateWizardPage_ClassName_Label=Class
JBossWS_GenerateWizard_MessageDialog_Title=Error
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
+JBossWS_GenerateWizard_GenerateWizardPage_Project_Group=Dynamic Web Project Name
+JBossWS_GenerateWizard_GenerateWizardPage_Project_Group_Tooltip=If no Dynamic Web Project
exists, you must create one before creating your sample web service.
+JBossWS_GenerateWizard_GenerateWizardPage_Web_Service_Group=Web Service
+JBossWS_GenerateWizard_GenerateWizardPage_Class_Group=Sample Web Service Class
JBossWSFacetInstallPage_ServerSuppliedJBossWS=Server Supplied JBossWS Runtime
JBossWSFacetInstallPage_New=New...
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-07-20
06:29:52 UTC (rev 23577)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-07-20
08:36:09 UTC (rev 23578)
@@ -63,19 +63,17 @@
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;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_Title;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_Description;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_ServiceName_Label;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_Package_Label;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_ClassName_Label;
public static String JBossWS_GenerateWizard_MessageDialog_Title;
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 JBossWS_GenerateWizard_GenerateWizardPage_Project_Group;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_Project_Group_Tooltip;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_Web_Service_Group;
+ public static String JBossWS_GenerateWizard_GenerateWizardPage_Class_Group;
public static String JBossWSFacetInstallPage_ServerSuppliedJBossWS;
public static String JBossWSFacetInstallPage_New;
Deleted:
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-07-20
06:29:52 UTC (rev 23577)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateSampleClassWizardPage.java 2010-07-20
08:36:09 UTC (rev 23578)
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * 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.core.runtime.CoreException;
-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;
-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.creation.core.data.ServiceModel;
-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) {
- wizard.setPackageName(packageName.getText());
- setPageComplete(isPageComplete());
- }
-
- });
-
- 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(updateDefaultName());
- className.setEnabled(!wizard.isUseDefaultClassName());
- className.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- wizard.setClassName(className.getText());
- setPageComplete(isPageComplete());
- }
-
- });
-
- 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() {
- return validate();
- }
-
- 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;
- }
-
- private String updateDefaultName() {
- 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;
- while (status != null && status.getSeverity() == IStatus.ERROR) {
- testName = currentName + i;
- wizard.setClassName(testName);
- model = wizard.getServiceModel();
- JBossWSGenerateWizardValidator.setServiceModel(model);
- status = JBossWSGenerateWizardValidator.isWSClassValid(testName,
- wizard.getProject());
- i++;
- }
- return testName;
- }
-
- protected boolean validate() {
- ServiceModel model = wizard.getServiceModel();
- JBossWSGenerateWizardValidator.setServiceModel(model);
- IStatus status = JBossWSGenerateWizardValidator.isWSClassValid(model
- .getCustomClassName(), wizard.getProject());
- if (status != null) {
- if (status.getSeverity() == IStatus.ERROR) {
- setMessage(status.getMessage(), DialogPage.ERROR);
- return false;
- } else if (status.getSeverity() == IStatus.WARNING) {
- setMessage(status.getMessage(), DialogPage.WARNING);
- return true;
- }
- }
- setMessage(null);
- return true;
- }
-
- protected void refresh() {
- className.setText(updateDefaultName());
- }
-}
Deleted:
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-07-20
06:29:52 UTC (rev 23577)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWebXmlWizardPage.java 2010-07-20
08:36:09 UTC (rev 23578)
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * 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.util.ArrayList;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.JavaModelException;
-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;
-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.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;
-import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
-import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
-
-public class JBossWSGenerateWebXmlWizardPage extends WizardPage {
-
- private JBossWSGenerateWizard wizard;
- private Text name;
- private Combo projects;
- private Button checkDefault;
- private boolean bHasChanged = false;
-
- 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();
-
- 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(group2, SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- name.setLayoutData(gd);
- name.setText(updateDefaultName());
- name.setEnabled(!wizard.isUseDefaultServiceName());
- name.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- wizard.setServiceName(name.getText());
- bHasChanged = true;
- setPageComplete(isPageComplete());
- }
-
- });
-
- checkDefault = new Button(group2, 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);
- }
-
- 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();
- }
-
- 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;
- }
-
- @Override
- public boolean isPageComplete() {
- return validate();
- }
-
- private String updateDefaultName() {
- 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;
- 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);
- if (!projects.isDisposed() && projects.getText().length() > 0) {
- model.setWebProjectName(projects.getText());
- }
-
- if (((JBossWSGenerateWizard) this.getWizard()).getProject() == null) {
- setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoProjectSelected);
- return false;
- }
-
- IFile web = ((JBossWSGenerateWizard) this.getWizard()).getWebFile();
- if (web == null || !web.exists()) {
- setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NotDynamicWebProject);
- return false;
- }
-
- try {
- if
("" .equals(JBossWSCreationUtils.getJavaProjectSrcLocation(((JBossWSGenerateWizard)
this.getWizard()).getProject()))) { //$NON-NLS-1$
- setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoSrcInProject);
- return false;
- }
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
-
- IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
- if (status != null) {
- setErrorMessage(status.getMessage());
- return false;
- } else {
- 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:
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-07-20
06:29:52 UTC (rev 23577)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-07-20
08:36:09 UTC (rev 23578)
@@ -35,9 +35,6 @@
public class JBossWSGenerateWizard extends Wizard implements INewWizard {
- 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$
@@ -64,10 +61,9 @@
public void addPages() {
super.addPages();
- firstPage = new JBossWSGenerateWebXmlWizardPage("first"); //$NON-NLS-1$
- secondPage = new JBossWSGenerateSampleClassWizardPage("second");
//$NON-NLS-1$
- addPage(firstPage);
- addPage(secondPage);
+ JBossWSGenerateWizardPage onePage =
+ new JBossWSGenerateWizardPage("onePage"); //$NON-NLS-1$
+ addPage(onePage);
}
@Override
@@ -207,14 +203,6 @@
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 =
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardPage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardPage.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardPage.java 2010-07-20
08:36:09 UTC (rev 23578)
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+
+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.jdt.core.JavaModelException;
+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;
+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.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;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+public class JBossWSGenerateWizardPage extends WizardPage {
+
+ private JBossWSGenerateWizard wizard;
+ private Text name;
+ private Combo projects;
+ private boolean bHasChanged = false;
+ private Text packageName;
+ private Text className;
+
+ protected JBossWSGenerateWizardPage(String pageName) {
+ super(pageName);
+ this
+ .setTitle(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Title);
+ this
+ .setDescription(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Description);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = createDialogArea(parent);
+ this.wizard = (JBossWSGenerateWizard) this.getWizard();
+
+ Group group = new Group(composite, SWT.NONE);
+ group
+ .setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_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.JBossWS_GenerateWizard_GenerateWizardPage_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());
+ className.setText(updateDefaultClassName());
+ bHasChanged = true;
+ setPageComplete(isPageComplete());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ Group group2 = new Group(composite, SWT.NONE);
+ group2
+ .setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_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_GenerateWizardPage_ServiceName_Label);
+ name = new Text(group2, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ name.setLayoutData(gd);
+ name.setText(updateDefaultName());
+ name.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ wizard.setServiceName(name.getText());
+ bHasChanged = true;
+ setPageComplete(isPageComplete());
+ }
+
+ });
+
+ Group group3 = new Group(composite, SWT.NONE);
+ group3.setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Class_Group);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ group3.setLayout(new GridLayout(2, false));
+ group3.setLayoutData(gd);
+
+ new Label(group3, SWT.NONE)
+ .setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Package_Label);
+ packageName = new Text(group3, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ packageName.setLayoutData(gd);
+ packageName.setText(wizard.getPackageName());
+ packageName.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ wizard.setPackageName(packageName.getText());
+ setPageComplete(isPageComplete());
+ }
+
+ });
+
+ new Label(group3, SWT.NONE)
+ .setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_ClassName_Label);
+ className = new Text(group3, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ className.setLayoutData(gd);
+ className.setText(updateDefaultClassName());
+ className.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ wizard.setClassName(className.getText());
+ setPageComplete(isPageComplete());
+ }
+
+ });
+
+ 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() {
+ 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;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return validate();
+ }
+
+ private String updateDefaultName() {
+ 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;
+ 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 String updateDefaultClassName() {
+ 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;
+ while (status != null && status.getSeverity() == IStatus.ERROR) {
+ 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);
+ if (!projects.isDisposed() && projects.getText().length() > 0) {
+ model.setWebProjectName(projects.getText());
+ }
+
+ if (((JBossWSGenerateWizard) this.getWizard()).getProject() == null) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoProjectSelected);
+ return false;
+ }
+
+ IFile web = ((JBossWSGenerateWizard) this.getWizard()).getWebFile();
+ if (web == null || !web.exists()) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NotDynamicWebProject);
+ return false;
+ }
+
+ try {
+ if
("" .equals(JBossWSCreationUtils.getJavaProjectSrcLocation(((JBossWSGenerateWizard)
this.getWizard()).getProject()))) { //$NON-NLS-1$
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NoSrcInProject);
+ return false;
+ }
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+
+ IStatus status = JBossWSGenerateWizardValidator.isWSNameValid();
+ if (status != null) {
+ setErrorMessage(status.getMessage());
+ return false;
+ }
+
+ IStatus classNameStatus = JBossWSGenerateWizardValidator.isWSClassValid(model
+ .getCustomClassName(), wizard.getProject());
+ if (classNameStatus != null) {
+ if (classNameStatus.getSeverity() == IStatus.ERROR) {
+ setMessage(classNameStatus.getMessage(), DialogPage.ERROR);
+ return false;
+ } else if (classNameStatus.getSeverity() == IStatus.WARNING) {
+ setMessage(classNameStatus.getMessage(), DialogPage.WARNING);
+ return true;
+ }
+ }
+
+ setMessage(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Description);
+ 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:
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 2010-07-20
06:29:52 UTC (rev 23577)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java 2010-07-20
08:36:09 UTC (rev 23578)
@@ -105,6 +105,39 @@
}
}
return null;
+ } else if (object instanceof org.eclipse.jst.j2ee.webapplication.WebApp) {
+ org.eclipse.jst.j2ee.webapplication.WebApp webApp =
(org.eclipse.jst.j2ee.webapplication.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++) {
+ org.eclipse.jst.j2ee.webapplication.Servlet aServlet =
(org.eclipse.jst.j2ee.webapplication.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++) {
+ org.eclipse.jst.j2ee.webapplication.ServletMapping aServletMapping =
(org.eclipse.jst.j2ee.webapplication.ServletMapping) theServletMappings
+ .get(j);
+ String url = aServletMapping.getUrlPattern();
+ if (aServletMapping.getServlet().getServletName().equals(
+ descriptors[i].getName())
+ || url.equals(descriptors[i].getMappings())) {
+ return StatusUtils
+ .errorStatus(JBossWSCreationCoreMessages.Error_JBossWS_GenerateWizard_WSName_Same);
+ }
+ }
+ }
+ }
+ return null;
}
return null;
}
@@ -122,8 +155,8 @@
|| !JavaEEProjectUtilities.isDynamicWebProject(project)) {
return null;
} else {
- IStatus status = JBossWSUIUtils.validatePackageName(model
- .getCustomPackage(), JavaCore.create(project));
+ IStatus status = JBossWSUIUtils.validatePackageName(
+ model.getCustomPackage(), JavaCore.create(project));
if (status != null && status.getSeverity() == IStatus.ERROR) {
return status;
}