Refactoring, code cleanup
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUIMessages.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUIMessages.java
index c73c6ad..2d3a443 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUIMessages.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUIMessages.java
@@ -20,7 +20,6 @@
public static String JAVA2WS_SELECT_SEI_EXTRACTED_METHODS;
public static String JAVA2WS_SELECT_SEI_MESSAGE;
public static String JAVA2WS_SELECT_SEI_OPTION;
- public static String JAVA2WS_BROWSE_LABEL;
public static String JAVA2WS_SELECT_SEI_DIALOG_TITLE;
public static String JAVA2WS_SELECT_SEI_DIALOG_DESCRIPTION;
public static String JAVA2WS_SELECT_SEI_WEBSERVICE_NAME_ATTRIBUTE_PRESENT;
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUImessages.properties b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUImessages.properties
index f19d179..a7e42d8 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUImessages.properties
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/CXFCreationUImessages.properties
@@ -11,25 +11,25 @@
#Java2WS Pre Config Widget Factory
JAVA2WS_CLASS_CONFIG_PAGE_TITLE={0} {1} Web Service Java Class Starting Point Configuration
-JAVA2WS_CLASS_CONFIG_PAGE_DESCRIPTION=Select an existing Service Endpoint Interface (SEI) or create an SEI by extracting an interface from the implementation class
+JAVA2WS_CLASS_CONFIG_PAGE_DESCRIPTION=Select an existing Service Endpoint Interface (SEI) or create an SEI by extracting an interface from the implementation class.
JAVA2WS_INTERFACE_CONFIG_PAGE_TITLE={0} {1} Web Service Java Interface Starting Point Configuration
JAXWS_ANNOTATE_JJAVA_WIDGET_PREVIEW=Preview:
-JAVA2WS_INTERFACE_CONFIG_PAGE_DESCRIPTION=Select an implementation for the interface. Optional step for configuration purposes.
+JAVA2WS_INTERFACE_CONFIG_PAGE_DESCRIPTION=Select an implementation that implements all the methods of the SEI.
#Java2WS Config Widget Factory
-JAVA2WS_JAXWS_ANNOTATE_PAGE_TITLE={0} {1} Web Service Annotate Java Configuration
-JAVA2WS_JAXWS_ANNOTATE_PAGE_DESCRIPTION=Set the Annotation options on this page
+JAVA2WS_JAXWS_ANNOTATE_PAGE_TITLE={0} {1} Web Service JAX-WS Annotations Configuration
+JAVA2WS_JAXWS_ANNOTATE_PAGE_DESCRIPTION=Optionally, select the JAX-WS Annotations to add.
JAVA2WS_PAGE_TITLE={0} {1} Web Service Java2WS Configuration
-JAVA2WS_PAGE_DESCRIPTION=Customise your Web Service generation by selecting options on this page
+JAVA2WS_PAGE_DESCRIPTION=Configure the {0} Java to WS options.
#WSDL2Java Config Widget Factory
WSDL2JAVA_PAGE_TITLE={0} {1} Web Service WSDL2Java Configuration
-WSDL2JAVA_PAGE_DESCRIPTION=Customise your Web Service generation by selecting options on this page
+WSDL2JAVA_PAGE_DESCRIPTION=Configure the {0} WSDL to Java options.
WSDL2JAVA_DEFAULTS_PAGE_TITLE={0} {1} Web Service WSDL2Java Configuration
-WSDL2JAVA_DEFAULTS_PAGE_DESCRIPTION=The page allows the overriding of the default preferences for this Web Service generation
+WSDL2JAVA_DEFAULTS_PAGE_DESCRIPTION=The page allows the overriding of the default preferences for this Web Service generation.
#Java2WS Config Widget
JAVA2WS_GROUP_LABEL=Java2WS Generation Options:
@@ -38,7 +38,6 @@
JAVA2WS_SELECT_SEI_EXTRACTED_METHODS=Please select the methods you wish to extract from the {0} class
JAVA2WS_SELECT_SEI_MESSAGE=Please select a Service Endpoint Interface
JAVA2WS_SELECT_SEI_OPTION=Please select an SEI option
-JAVA2WS_BROWSE_LABEL=Browse...
JAVA2WS_SELECT_SEI_DIALOG_TITLE=Select Service Endpoint Interface
JAVA2WS_SELECT_SEI_DIALOG_DESCRIPTION=Select the Interface to use as the Service Endpoint Interface
JAVA2WS_SELECT_SEI_WEBSERVICE_NAME_ATTRIBUTE_PRESENT=Implementation class contains an @WebService annotation with a name attribute which cannot be combined with an endpointInterface attribute
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java
index aae69b8..ab02c68 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java
@@ -17,26 +17,17 @@
import javax.jws.WebService;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
-import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
import org.eclipse.jst.ws.internal.cxf.core.model.Java2WSDataModel;
@@ -60,7 +51,6 @@
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
@@ -206,8 +196,7 @@
gridData.horizontalSpan = 1;
selectSEICombo.setLayoutData(gridData);
- browseSEIButton = new Button(composite, SWT.PUSH);
- browseSEIButton.setText(CXFCreationUIMessages.JAVA2WS_BROWSE_LABEL);
+ browseSEIButton = Java2WSWidgetFactory.createBrowseButton(composite);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
gridData.horizontalSpan = 1;
@@ -217,15 +206,10 @@
@Override
public void widgetSelected(SelectionEvent e) {
- ElementTreeSelectionDialog selectionDialog = new ElementTreeSelectionDialog(composite.getShell(),
- new JavaElementLabelProvider(), new StandardJavaElementContentProvider());
- selectionDialog.setTitle(CXFCreationUIMessages.JAVA2WS_SELECT_SEI_DIALOG_TITLE);
- selectionDialog.setMessage(CXFCreationUIMessages.JAVA2WS_SELECT_SEI_DIALOG_DESCRIPTION);
- selectionDialog.setAllowMultiple(false);
- selectionDialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
- selectionDialog.addFilter(new JavaViewerFilter(JDTUtils.getJavaProject(model.getProjectName())));
-
- selectionDialog.setValidator(new JavaSelectionStatusValidator());
+ ElementTreeSelectionDialog selectionDialog = Java2WSWidgetFactory.createElementTreeSelectionDialog(
+ composite.getShell(), CXFCreationUIMessages.JAVA2WS_SELECT_SEI_DIALOG_TITLE,
+ CXFCreationUIMessages.JAVA2WS_SELECT_SEI_DIALOG_DESCRIPTION,
+ JDTUtils.getJavaProject(model.getProjectName()), true);
int returnCode = selectionDialog.open();
if (returnCode == Window.OK) {
@@ -465,52 +449,6 @@
return status;
}
- private static class JavaViewerFilter extends ViewerFilter {
-
- private IJavaProject javaProject;
-
- public JavaViewerFilter(IJavaProject javaProject) {
- this.javaProject = javaProject;
- }
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- try {
- if (element instanceof IJavaProject) {
- return javaProject.equals((IJavaProject) element);
- }
- if (element instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element;
- return packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE;
- }
- if (element instanceof IPackageFragment) {
- IPackageFragment packageFragment = (IPackageFragment) element;
- return packageFragment.hasChildren();
- }
- if (element instanceof ICompilationUnit) {
- ICompilationUnit compilationUnit = (ICompilationUnit) element;
- IType type = compilationUnit.findPrimaryType();
- return type.isInterface();
-
- }
- } catch (JavaModelException jme) {
- CXFCreationUIPlugin.log(jme.getStatus());
- }
- return false;
- }
- }
-
- private static class JavaSelectionStatusValidator implements ISelectionStatusValidator {
- public IStatus validate(Object[] selection) {
- if (selection.length == 1) {
- if (selection[0] instanceof ICompilationUnit) {
- return new Status(IStatus.OK, CXFCreationUIPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
- }
- }
- return new Status(IStatus.ERROR, CXFCreationUIPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
- }
- }
-
public void enableSelectSEIControls(boolean enable) {
selectSEICombo.setEnabled(enable);
browseSEIButton.setEnabled(enable);
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSConfigWidgetFactory.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSConfigWidgetFactory.java
index 1ee7aae..176cf0e 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSConfigWidgetFactory.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSConfigWidgetFactory.java
@@ -62,7 +62,8 @@
java2WSWidgetContributor.setTitle(title);
java2WSWidgetContributor
- .setDescription(CXFCreationUIMessages.JAVA2WS_PAGE_DESCRIPTION);
+ .setDescription(CXFCreationUIMessages.bind(CXFCreationUIMessages.JAVA2WS_PAGE_DESCRIPTION,
+ context.getCxfRuntimeEdition()));
java2WSWidgetContributor.setFactory(new WidgetContributorFactory() {
public WidgetContributor create() {
return java2WSConfigWidget;
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSInterfaceConfigWidget.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSInterfaceConfigWidget.java
index bd836dc..d8fcebd 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSInterfaceConfigWidget.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSInterfaceConfigWidget.java
@@ -13,22 +13,13 @@
import java.util.Arrays;
import java.util.List;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
-import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
import org.eclipse.jst.ws.internal.cxf.core.model.Java2WSDataModel;
import org.eclipse.jst.ws.internal.cxf.creation.ui.CXFCreationUIMessages;
@@ -47,7 +38,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
@@ -103,24 +93,19 @@
}
});
- Button browseButton = new Button(composite, SWT.PUSH);
- browseButton.setText(CXFCreationUIMessages.JAVA2WS_BROWSE_LABEL);
+ Button browseImplButton = Java2WSWidgetFactory.createBrowseButton(composite);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
- browseButton.setLayoutData(gridData);
+ browseImplButton.setLayoutData(gridData);
- browseButton.addSelectionListener(new SelectionAdapter() {
+ browseImplButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- ElementTreeSelectionDialog selectionDialog = new ElementTreeSelectionDialog(composite.getShell(),
- new JavaElementLabelProvider(), new StandardJavaElementContentProvider());
- selectionDialog.setTitle(CXFCreationUIMessages.JAVA2WS_SELECT_IMPL_DIALOG_TITLE);
- selectionDialog.setMessage(CXFCreationUIMessages.JAVA2WS_SELECT_IMPL_DIALOG_DESCRIPTION);
- selectionDialog.setAllowMultiple(false);
- selectionDialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
- selectionDialog.addFilter(new JavaViewerFilter(JDTUtils.getJavaProject(model.getProjectName())));
-
- selectionDialog.setValidator(new JavaSelectionStatusValidator());
+
+ ElementTreeSelectionDialog selectionDialog = Java2WSWidgetFactory.createElementTreeSelectionDialog(
+ composite.getShell(), CXFCreationUIMessages.JAVA2WS_SELECT_IMPL_DIALOG_TITLE,
+ CXFCreationUIMessages.JAVA2WS_SELECT_IMPL_DIALOG_DESCRIPTION,
+ JDTUtils.getJavaProject(model.getProjectName()), false);
int returnCode = selectionDialog.open();
if (returnCode == Window.OK) {
@@ -137,52 +122,6 @@
return this;
}
- private static class JavaViewerFilter extends ViewerFilter {
-
- private IJavaProject javaProject;
-
- public JavaViewerFilter(IJavaProject javaProject) {
- this.javaProject = javaProject;
- }
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- try {
- if (element instanceof IJavaProject) {
- return javaProject.equals((IJavaProject) element);
- }
- if (element instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element;
- return packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE;
- }
- if (element instanceof IPackageFragment) {
- IPackageFragment packageFragment = (IPackageFragment) element;
- return packageFragment.hasChildren();
- }
- if (element instanceof ICompilationUnit) {
- ICompilationUnit compilationUnit = (ICompilationUnit) element;
- IType type = compilationUnit.findPrimaryType();
- return type.isClass();
-
- }
- } catch (JavaModelException jme) {
- CXFCreationUIPlugin.log(jme.getStatus());
- }
- return false;
- }
- }
-
- private static class JavaSelectionStatusValidator implements ISelectionStatusValidator {
- public IStatus validate(Object[] selection) {
- if (selection.length == 1) {
- if (selection[0] instanceof ICompilationUnit) {
- return new Status(IStatus.OK, CXFCreationUIPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
- }
- }
- return new Status(IStatus.ERROR, CXFCreationUIPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
- }
- }
-
@Override
public IStatus getStatus() {
return IMPL_SELECTION_STATUS;
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/WSDL2JavaConfigWidgetFactory.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/WSDL2JavaConfigWidgetFactory.java
index 5d7b26c..31edd23 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/WSDL2JavaConfigWidgetFactory.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/WSDL2JavaConfigWidgetFactory.java
@@ -63,7 +63,8 @@
context.getCxfRuntimeVersion()});
wsdl2JavaWidgetContributor.setTitle(wsdl2JavaPageTitle);
wsdl2JavaWidgetContributor
- .setDescription(CXFCreationUIMessages.WSDL2JAVA_PAGE_DESCRIPTION);
+ .setDescription(CXFCreationUIMessages.bind(CXFCreationUIMessages.WSDL2JAVA_PAGE_DESCRIPTION,
+ context.getCxfRuntimeEdition()));
wsdl2JavaWidgetContributor.setFactory(new WidgetContributorFactory() {
public WidgetContributor create() {
return wsdl2JavaConfigWidget;
diff --git a/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUIMessages.java b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUIMessages.java
index d87601d..8756a4f 100644
--- a/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUIMessages.java
+++ b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUIMessages.java
@@ -96,6 +96,7 @@
public static String JAVA2WS_SELECT_SEI;
public static String JAVA2WS_SELECT_SEI_LABEL;
public static String JAVA2WS_SELECT_SEI_TOOLTIP;
+ public static String JAVA2WS_BROWSE_LABEL;
public static String JAVA2WS_EXTRACT_SEI;
public static String JAVA2WS_EXTRACT_SEI_LABEL;
public static String JAVA2WS_EXTRACT_SEI_TOOLTIP;
diff --git a/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUImessages.properties b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUImessages.properties
index 3ec0ee4..434ae2d 100644
--- a/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUImessages.properties
+++ b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/CXFUImessages.properties
@@ -94,6 +94,7 @@
#JAVA2WS_SELECT_SEI_LABEL=Select SEI from &Type Hierarchy:
JAVA2WS_SELECT_SEI_LABEL=Selec&t an SEI:
JAVA2WS_SELECT_SEI_TOOLTIP=Select the Interface from the Type Hierarchy to use as the SEI
+JAVA2WS_BROWSE_LABEL=Browse...
JAVA2WS_EXTRACT_SEI=Extract SEI:
JAVA2WS_EXTRACT_SEI_LABEL=&Create an SEI:
JAVA2WS_EXTRACT_SEI_TOOLTIP=Type the name of the Service Endpoint Interface to extract
diff --git a/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/viewers/JavaViewerFilter.java b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/viewers/JavaViewerFilter.java
new file mode 100644
index 0000000..8bf6f91
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/viewers/JavaViewerFilter.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.internal.cxf.ui.viewers;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jst.ws.internal.cxf.ui.CXFUIPlugin;
+
+/**
+ * <code>ViewerFilter</code> that filters on classes or interfaces within a <code>IJavaProject</code>
+ *
+ */
+public class JavaViewerFilter extends ViewerFilter {
+
+ private IJavaProject javaProject;
+ private boolean filterClasses;
+
+ /**
+ * Constructs an instance of <code>JavaViewerFilter</code> given a <code>IJavaProject</code> to filter and a
+ * boolean value that controls what to filter in the project.
+ *
+ * @param javaProject the java project to filter
+ * @param filterClasses true to filter all classes. false to filter all interfaces
+ */
+ public JavaViewerFilter(IJavaProject javaProject, boolean filterClasses) {
+ this.javaProject = javaProject;
+ this.filterClasses = filterClasses;
+
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ try {
+ if (element instanceof IJavaProject) {
+ return javaProject.equals((IJavaProject) element);
+ }
+ if (element instanceof IPackageFragmentRoot) {
+ IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element;
+ return packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE;
+ }
+ if (element instanceof IPackageFragment) {
+ IPackageFragment packageFragment = (IPackageFragment) element;
+ return packageFragment.hasChildren();
+ }
+ if (element instanceof ICompilationUnit) {
+ ICompilationUnit compilationUnit = (ICompilationUnit) element;
+ IType type = compilationUnit.findPrimaryType();
+ if (filterClasses) {
+ return type.isInterface() && !type.isAnnotation();
+ } else {
+ return type.isClass();
+ }
+
+ }
+ } catch (JavaModelException jme) {
+ CXFUIPlugin.log(jme.getStatus());
+ }
+ return false;
+ }
+
+}
diff --git a/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/widgets/Java2WSWidgetFactory.java b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/widgets/Java2WSWidgetFactory.java
index b79c9c5..77af3dd 100644
--- a/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/widgets/Java2WSWidgetFactory.java
+++ b/bundles/org.eclipse.jst.ws.cxf.ui/src/org/eclipse/jst/ws/internal/cxf/ui/widgets/Java2WSWidgetFactory.java
@@ -10,11 +10,17 @@
*******************************************************************************/
package org.eclipse.jst.ws.internal.cxf.ui.widgets;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jst.ws.internal.cxf.core.model.DataBinding;
@@ -23,6 +29,7 @@
import org.eclipse.jst.ws.internal.cxf.core.model.Java2WSDataModel;
import org.eclipse.jst.ws.internal.cxf.ui.CXFUIMessages;
import org.eclipse.jst.ws.internal.cxf.ui.CXFUIPlugin;
+import org.eclipse.jst.ws.internal.cxf.ui.viewers.JavaViewerFilter;
import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -33,7 +40,10 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
/**
* Provides widgets for Java2WS preferences, wizards, dialogs. Enables the reuse
@@ -267,6 +277,12 @@
return seiCombo;
}
+ public static Button createBrowseButton(Composite parent) {
+ Button browseButton = new Button(parent, SWT.PUSH);
+ browseButton.setText(CXFUIMessages.JAVA2WS_BROWSE_LABEL);
+ return browseButton;
+ }
+
public static Button createExtractSEIButton(Composite parent) {
Button extractSEIButton = new Button(parent, SWT.RADIO);
extractSEIButton.setText(CXFUIMessages.JAVA2WS_EXTRACT_SEI_LABEL);
@@ -352,5 +368,43 @@
selectImplementationCombo.select(-1);
return selectImplementationCombo;
}
+
+ /**
+ * Creates am <code>ElementTreeSelectionDialog</code> that displays all the classes or all the interfaces
+ * within a <code>IJavaProject</code> allowing one class or interface to be selected.
+ *
+ * @param parent the parent shell
+ * @param title the dialog title
+ * @param message the dialog message
+ * @param javaProject the java project that is filtered
+ * @param filterClasses true to filter all classes, false to filter all interfaces
+ * @return
+ */
+ public static ElementTreeSelectionDialog createElementTreeSelectionDialog(Shell parent, String title,
+ String message, IJavaProject javaProject, boolean filterClasses) {
+ ElementTreeSelectionDialog selectionDialog = new ElementTreeSelectionDialog(parent,
+ new JavaElementLabelProvider(), new StandardJavaElementContentProvider());
+ selectionDialog.setTitle(title);
+ selectionDialog.setMessage(message);
+ selectionDialog.setAllowMultiple(false);
+ selectionDialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
+ selectionDialog.addFilter(new JavaViewerFilter(javaProject, filterClasses));
+
+ selectionDialog.setValidator(new ISelectionStatusValidator() {
+
+ public IStatus validate(Object[] selection) {
+ if (selection.length == 1) {
+ if (selection[0] instanceof ICompilationUnit) {
+ return new Status(IStatus.OK, CXFUIPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
+ }
+ }
+ return new Status(IStatus.ERROR, CXFUIPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
+ }
+ });
+
+ return selectionDialog;
+
+ }
+
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
index e080a98..e53a5da 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
@@ -8,7 +8,6 @@
* Contributors:
* Shane Clarke - initial API and implementation
*******************************************************************************/
-
package org.eclipse.jst.ws.internal.jaxws.core;
import org.eclipse.osgi.util.NLS;