Bug 347973 - Setting build path took 8 minutes
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/META-INF/MANIFEST.MF
index 00bb7be..e2603bd 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/META-INF/MANIFEST.MF
@@ -1,25 +1,26 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %Bundle-Name.0
-Bundle-Vendor: %Bundle-Vendor.0
-Bundle-SymbolicName: org.eclipse.jst.ws.jaxws.dom.integration;singleton:=true
-Bundle-Version: 1.0.100.qualifier
-Bundle-Activator: org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationPlugin
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.emf.edit.ui,
- org.eclipse.jdt.core,
- org.eclipse.ui.ide,
- org.eclipse.ui.navigator,
- org.eclipse.jdt.ui,
- org.eclipse.jst.j2ee.core,
- org.eclipse.jst.jee.ui,
- org.eclipse.jem.util,
- org.eclipse.jst.ws.jaxws.dom.ui,
- org.eclipse.jst.ws.jaxws.utils,
- org.eclipse.jdt.apt.core
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.jst.ws.jaxws.dom.integration.navigator;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration.tests",
- org.eclipse.jst.ws.jaxws.dom.integration.navigator.actions;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration.tests"
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-SymbolicName: org.eclipse.jst.ws.jaxws.dom.integration;singleton:=true
+Bundle-Version: 1.0.100.qualifier
+Bundle-Activator: org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationPlugin
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.jdt.core,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.navigator,
+ org.eclipse.jdt.ui,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.jee.ui,
+ org.eclipse.jem.util,
+ org.eclipse.jst.ws.jaxws.dom.ui,
+ org.eclipse.jst.ws.jaxws.utils,
+ org.eclipse.jdt.apt.core
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.jst.ws.jaxws.dom.integration.internal.util;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration.tests",
+ org.eclipse.jst.ws.jaxws.dom.integration.navigator;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration.tests",
+ org.eclipse.jst.ws.jaxws.dom.integration.navigator.actions;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration.tests"
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.java b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.java
index bb1a6d6..48c6fdc 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.java
@@ -1,42 +1,40 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin;
-
-import org.eclipse.osgi.util.NLS;
-
-public class DomIntegrationMessages extends NLS
-{
- private static final String BUNDLE_NAME = "org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationMessages"; //$NON-NLS-1$
-
- public static String DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel;
-
- public static String DOMAdapterFactoryLabelProvider_LoadingCanceledLabel;
-
- public static String DOMAdapterFactoryLabelProvider_LoadingDummyLabel;
-
- public static String DOMAdapterFactoryLabelProvider_SeiLabel;
-
- public static String DOMAdapterFactoryLabelProvider_WebServicesLabel;
-
- /** message constant */
- public static String OpenWSResourceAction_Name;
-
- /** message constant */
- public static String NavigateToImplementationAction_ShowInWebServicesAreaAction;
-
- /** message constant */
- public static String NavigateToImplementationAction_ShowInEJBAreaAction;
-
- static
- {
- NLS.initializeMessages(BUNDLE_NAME, DomIntegrationMessages.class);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin;
+
+import org.eclipse.osgi.util.NLS;
+
+public class DomIntegrationMessages extends NLS
+{
+ private static final String BUNDLE_NAME = "org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationMessages"; //$NON-NLS-1$
+
+ public static String DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel;
+
+ public static String DOMAdapterFactoryLabelProvider_LoadingDummyLabel;
+
+ public static String DOMAdapterFactoryLabelProvider_SeiLabel;
+
+ public static String DOMAdapterFactoryLabelProvider_WebServicesLabel;
+
+ /** message constant */
+ public static String OpenWSResourceAction_Name;
+
+ /** message constant */
+ public static String NavigateToImplementationAction_ShowInWebServicesAreaAction;
+
+ /** message constant */
+ public static String NavigateToImplementationAction_ShowInEJBAreaAction;
+
+ static
+ {
+ NLS.initializeMessages(BUNDLE_NAME, DomIntegrationMessages.class);
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.properties b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.properties
index 2927375..ede3019 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.properties
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/plugin/DomIntegrationMessages.properties
@@ -1,20 +1,19 @@
-###############################################################################
-# Copyright (c) 2009 by SAP AG, Walldorf.
-# 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:
-# SAP AG - initial API and implementation
-###############################################################################
-DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel = JAX-WS Web Services
-DOMAdapterFactoryLabelProvider_LoadingCanceledLabel = Loading Canceled
-DOMAdapterFactoryLabelProvider_LoadingDummyLabel = Loading...
-DOMAdapterFactoryLabelProvider_SeiLabel = Service Endpoint Interfaces
-DOMAdapterFactoryLabelProvider_WebServicesLabel = Web Services
-
-OpenWSResourceAction_Name = Open
-
-NavigateToImplementationAction_ShowInWebServicesAreaAction = Locate in Web Services Node
-NavigateToImplementationAction_ShowInEJBAreaAction = Locate in Deployment Descriptor Node
+###############################################################################
+# Copyright (c) 2009 by SAP AG, Walldorf.
+# 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:
+# SAP AG - initial API and implementation
+###############################################################################
+DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel = JAX-WS Web Services
+DOMAdapterFactoryLabelProvider_LoadingDummyLabel = Loading...
+DOMAdapterFactoryLabelProvider_SeiLabel = Service Endpoint Interfaces
+DOMAdapterFactoryLabelProvider_WebServicesLabel = Web Services
+
+OpenWSResourceAction_Name = Open
+
+NavigateToImplementationAction_ShowInWebServicesAreaAction = Locate in Web Services Node
+NavigateToImplementationAction_ShowInEJBAreaAction = Locate in Deployment Descriptor Node
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/util/LoadingWsProjectNodesCollector.java b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/util/LoadingWsProjectNodesCollector.java
new file mode 100644
index 0000000..dcf81f5
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/internal/util/LoadingWsProjectNodesCollector.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.integration.internal.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Utility which collects all tree items whose data is associated with {@link ILoadingWsProject} instance
+ * @see TreeItem#getData()
+ * @author Georgi Vachkov, Danail Branekov
+ */
+public class LoadingWsProjectNodesCollector
+{
+ public Collection<TreeItem> getLoadingWsProjects(final TreeItem[] treeItems)
+ {
+ final Collection<TreeItem> result = new ArrayList<TreeItem>();
+ for (TreeItem item : treeItems) {
+ result.addAll(getLoadingWsProjects(item));
+ }
+
+ return result;
+ }
+
+ private Collection<TreeItem> getLoadingWsProjects(final TreeItem treeItem)
+ {
+ if (treeItem.getData() instanceof IWebServiceProject) {
+ return Collections.emptyList();
+ }
+
+ final Collection<TreeItem> result = new ArrayList<TreeItem>();
+ if (treeItem.getData() instanceof ILoadingWsProject) {
+ result.add(treeItem);
+ }
+ else {
+ for (TreeItem child : treeItem.getItems()) {
+ result.addAll(getLoadingWsProjects(child));
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryContentProvider.java b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryContentProvider.java
index 5c0e3dd..b482f67 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryContentProvider.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryContentProvider.java
@@ -1,370 +1,342 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.integration.navigator;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
-import org.eclipse.jst.ws.jaxws.dom.integration.internal.util.ProjectExplorerUtil;
-import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingCanceled;
-import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingDummy;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IDOM;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IServiceEndpointInterface;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebMethod;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebParam;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebService;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDOMRuntimeExtension;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDomLoadListener;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMLoadCanceledException;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMRuntimeManager;
-import org.eclipse.jst.ws.jaxws.dom.runtime.registry.IWsDOMRuntimeInfo;
-import org.eclipse.jst.ws.jaxws.dom.runtime.registry.WsDOMRuntimeRegistry;
-import org.eclipse.jst.ws.jaxws.utils.ContractChecker;
-import org.eclipse.jst.ws.jaxws.utils.facets.FacetUtils;
-import org.eclipse.jst.ws.jaxws.utils.logging.Logger;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.CommonViewer;
-
-/**
- * Content provider for DOM related objects
- *
- * @author
- */
-public class DOMAdapterFactoryContentProvider extends AdapterFactoryContentProvider
-{
- private Map<IWsDOMRuntimeExtension, IWsDomLoadListener> loadListeners = new HashMap<IWsDOMRuntimeExtension, IWsDomLoadListener>();
-
- /**
- * Constructor
- */
- public DOMAdapterFactoryContentProvider()
- {
- this(CustomDomItemProviderAdapterFactory.INSTANCE);
- }
-
- /**
- * Constructor
- * @param adapterFactory
- */
- public DOMAdapterFactoryContentProvider(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- @Override
- public Object[] getChildren(final Object context)
- {
- if (context instanceof IAdaptable)
- {
- return getWsProject((IProject)((IAdaptable) context).getAdapter(IProject.class));
- }
- else if(context instanceof ILoadingWsProject)
- {
- return new Object[] { ((ILoadingWsProject)context).isLoadCanceled() ? new ILoadingCanceled(){} : new ILoadingDummy(){} };
- }
- else if(context instanceof IWebServiceProject)
- {
- return new Object[]{ adapterFactory.adapt(context, ISEIChildList.class),
- adapterFactory.adapt(context, IWebServiceChildList.class) };
- }
- else if(context instanceof IWebServiceChildList)
- {
- Object[] webServices = ((IWebServiceChildList)context).getWSChildList().toArray();
-
- for(int ii=0; ii<webServices.length; ii++)
- {
- adapterFactory.adapt(webServices[ii], ITreeItemContentProvider.class);
- }
-
- return webServices;
- }
- else if(context instanceof ISEIChildList)
- {
- Object[] sEIs = ((ISEIChildList)context).getSEIChildList().toArray();
-
- for(int ii=0; ii<sEIs.length; ii++)
- {
- adapterFactory.adapt(sEIs[ii], ITreeItemContentProvider.class);
- }
-
- return sEIs;
- }
- else if(context instanceof IWebService)
- {
- final IServiceEndpointInterface sei = ((IWebService)context).getServiceEndpoint();
- if (sei == null) {
- return new Object[0];
- }
-
- adapterFactory.adapt(sei, ITreeItemContentProvider.class);
- return new Object[]{ sei };
- }
- else if(context instanceof IServiceEndpointInterface) {
- return extractMethods((IServiceEndpointInterface) context);
- }
- else if (context instanceof IWebMethod) {
- return extractParams((IWebMethod)context);
- }
-
- return new Object[0];
- }
-
- protected Object[] getWsProject(final IProject project)
- {
- try {
- final IWsDOMRuntimeExtension runtime = getSupportingRuntime(project);
- if (runtime == null) {
- return new Object[0];
- }
-
- // WS project is loaded already
- final IWebServiceProject wsProject = getWsProject(runtime.getDOM(), project);
- if (wsProject != null)
- {
- adapterFactory.adapt(wsProject, ITreeItemContentProvider.class);
- return new Object[] { wsProject };
- }
-
- addRuntimeLoadListener(runtime);
- return new Object[] { new LoadingWsProject(project, false) };
- }
- catch (WsDOMLoadCanceledException e) { // $JL-EXC$
- return new Object[] { new LoadingWsProject(project, true) };
- }
- }
-
- protected IWsDomLoadListener addRuntimeLoadListener(final IWsDOMRuntimeExtension runtime)
- {
- IWsDomLoadListener loadListener = loadListeners.get(runtime);
- if (loadListener!=null) {
- return loadListener;
- }
-
- loadListener = new LoadListener(runtime);
- loadListeners.put(runtime, loadListener);
- runtime.addLoadListener(loadListener);
-
- return loadListener;
- }
-
- protected Object[] extractMethods(final IServiceEndpointInterface sei)
- {
- final List<IWebMethod> webMethods = sei.getWebMethods();
- for (IWebMethod webMethod : webMethods) {
- adapterFactory.adapt(webMethod, ITreeItemContentProvider.class);
- }
-
- return webMethods.toArray();
- }
-
- protected Object[] extractParams(final IWebMethod method)
- {
- final List<IWebParam> params = method.getParameters();
- for (IWebParam webParam : params) {
- adapterFactory.adapt(webParam, ITreeItemContentProvider.class);
- }
-
- return params.toArray();
- }
-
- @Override
- public boolean hasChildren(Object element)
- {
- if (element instanceof IWebServiceProject)
- {
- return true;
- }
- else if(element instanceof ILoadingWsProject)
- {
- return true;
- }
- else if(element instanceof IWebServiceChildList)
- {
- return !((IWebServiceChildList)element).getWSChildList().isEmpty();
- }
- else if(element instanceof ISEIChildList)
- {
- return !((ISEIChildList)element).getSEIChildList().isEmpty();
- }
- else if (element instanceof IWebService)
- {
- return ((IWebService) element).getServiceEndpoint() != null;
- }
- else if (element instanceof IServiceEndpointInterface)
- {
- return !((IServiceEndpointInterface)element).getWebMethods().isEmpty();
- }
- else if (element instanceof IWebMethod)
- {
- return !((IWebMethod)element).getParameters().isEmpty();
- }
-
- return false;
- }
-
- protected IWebServiceProject getWsProject(final IDOM dom, final IProject project)
- {
- if (dom == null) {
- return null;
- }
-
- for (IWebServiceProject wsProject : dom.getWebServiceProjects()) {
- if(wsProject.getName().equals(project.getName())) {
- return wsProject;
- }
- }
-
- return null;
- }
-
- protected IWsDOMRuntimeExtension getSupportingRuntime(final IProject project)
- {
- final Collection<IWsDOMRuntimeInfo> domRuntimeInfos = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
- Map<String, String> facets;
- for (IWsDOMRuntimeInfo domRuntimeInfo : domRuntimeInfos)
- {
- facets = domRuntimeInfo.getProjectFacets();
- if (hasFacet(facets, project)) {
- return getDomRuntime(domRuntimeInfo.getId());
- }
- }
-
- return null;
- }
-
- protected boolean hasFacet(final Map<String, String> facets, final IProject project)
- {
- for (String facetId : facets.keySet())
- {
- if (facetId == null || facets.get(facetId) == null) {
- continue;
- }
-
- try {
- if ((new FacetUtils()).hasFacetWithVersion(project, facets.get(facetId), facetId, true)){
- return true;
- }
- }
- catch (CoreException e) {
- (new Logger()).logError(e.getMessage(), e);
- }
- }
-
- return false;
- }
-
- protected IWsDOMRuntimeExtension getDomRuntime(String runtimeId) {
- return WsDOMRuntimeManager.instance().getDOMRuntime(runtimeId);
- }
-
- /**
- * Class that is used to listen when the DOM load will be finished. After the load has finished
- * this class traverses the project explorers tree in order to find all instances of
- * {@link ILoadingWsProject} and substitute them with loaded {@link IWebServiceProject}
- *
- * @author Georgi Vachkov
- */
- protected class LoadListener implements IWsDomLoadListener
- {
- private final IWsDOMRuntimeExtension runtime;
-
- public LoadListener(final IWsDOMRuntimeExtension runtime)
- {
- ContractChecker.nullCheckParam(runtime, "runtime"); //$NON-NLS-1$
- this.runtime = runtime;
- }
-
- public void finished()
- {
- Display.getDefault().asyncExec(new Runnable()
- {
- public void run()
- {
- final IViewPart viewPart = ProjectExplorerUtil.INSTANCE.findProjectExplorer();
- if (viewPart instanceof CommonNavigator)
- {
- final CommonViewer commonViewer = ((CommonNavigator)viewPart).getCommonViewer();
- for (TreeItem item : commonViewer.getTree().getItems()) {
- exchangeDummy(item, commonViewer);
- }
- }
- }
- });
- }
-
- protected void exchangeDummy(final TreeItem treeItem, final CommonViewer commonViewer)
- {
- if (treeItem == null || treeItem.getData() instanceof IWebServiceProject) {
- return;
- }
-
- if (treeItem.getData() instanceof ILoadingWsProject) {
- exchangeTreeItemData(treeItem, commonViewer);
- }
- else {
- for (TreeItem child : treeItem.getItems()) {
- exchangeDummy(child, commonViewer);
- }
- }
- }
-
- private void exchangeTreeItemData(final TreeItem treeItem, final CommonViewer commonViewer)
- {
- final ILoadingWsProject loadingProject = (ILoadingWsProject)treeItem.getData();
- try {
- final IWebServiceProject wsProject = getWsProject(runtime.getDOM(), loadingProject.getProject());
- adapterFactory.adapt(wsProject, ITreeItemContentProvider.class);
- treeItem.setData(wsProject);
-
- } catch (WsDOMLoadCanceledException e) { // $JL-EXC$
- treeItem.setData(new LoadingWsProject(loadingProject.getProject(), true));
- }
-
- commonViewer.refresh(loadingProject.getProject());
- }
-
- public void started() {
- // nothing to do here
- }
- }
-
- private class LoadingWsProject implements ILoadingWsProject
- {
- final IProject project;
- final boolean isCanceled;
-
- public LoadingWsProject(final IProject project, final boolean isCanceled) {
- ContractChecker.nullCheckParam(project, "project"); //$NON-NLS-1$
- this.project = project;
- this.isCanceled = isCanceled;
- }
-
- public IProject getProject() {
- return project;
- }
-
- public boolean isLoadCanceled() {
- return isCanceled;
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.integration.navigator;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.jst.ws.jaxws.dom.integration.internal.util.LoadingWsProjectNodesCollector;
+import org.eclipse.jst.ws.jaxws.dom.integration.internal.util.ProjectExplorerUtil;
+import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingDummy;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IDOM;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IServiceEndpointInterface;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebMethod;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebParam;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebService;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDOMRuntimeExtension;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMLoadCanceledException;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMRuntimeManager;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load.IWsDomCallback;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load.WsDomObtainerFactory;
+import org.eclipse.jst.ws.jaxws.dom.runtime.registry.IWsDOMRuntimeInfo;
+import org.eclipse.jst.ws.jaxws.dom.runtime.registry.WsDOMRuntimeRegistry;
+import org.eclipse.jst.ws.jaxws.utils.ContractChecker;
+import org.eclipse.jst.ws.jaxws.utils.facets.FacetUtils;
+import org.eclipse.jst.ws.jaxws.utils.logging.Logger;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * Content provider for DOM related objects
+ *
+ * @author
+ */
+public class DOMAdapterFactoryContentProvider extends AdapterFactoryContentProvider
+{
+ /**
+ * Constructor
+ */
+ public DOMAdapterFactoryContentProvider()
+ {
+ this(CustomDomItemProviderAdapterFactory.INSTANCE);
+ }
+
+ /**
+ * Constructor
+ * @param adapterFactory
+ */
+ public DOMAdapterFactoryContentProvider(AdapterFactory adapterFactory)
+ {
+ super(adapterFactory);
+ }
+
+ @Override
+ public Object[] getChildren(final Object context)
+ {
+ if (context instanceof IAdaptable)
+ {
+ return getWsProject((IProject)((IAdaptable) context).getAdapter(IProject.class));
+ }
+ else if(context instanceof ILoadingWsProject)
+ {
+ new WsDomObtainerFactory().createAsynchronousObtainer(getSupportingRuntime(((ILoadingWsProject)context).getProject())).getDom(new LoadListener());
+ return new Object[] { new ILoadingDummy(){} };
+ }
+ else if(context instanceof IWebServiceProject)
+ {
+ return new Object[]{ adapterFactory.adapt(context, ISEIChildList.class),
+ adapterFactory.adapt(context, IWebServiceChildList.class) };
+ }
+ else if(context instanceof IWebServiceChildList)
+ {
+ Object[] webServices = ((IWebServiceChildList)context).getWSChildList().toArray();
+
+ for(int ii=0; ii<webServices.length; ii++)
+ {
+ adapterFactory.adapt(webServices[ii], ITreeItemContentProvider.class);
+ }
+
+ return webServices;
+ }
+ else if(context instanceof ISEIChildList)
+ {
+ Object[] sEIs = ((ISEIChildList)context).getSEIChildList().toArray();
+
+ for(int ii=0; ii<sEIs.length; ii++)
+ {
+ adapterFactory.adapt(sEIs[ii], ITreeItemContentProvider.class);
+ }
+
+ return sEIs;
+ }
+ else if(context instanceof IWebService)
+ {
+ final IServiceEndpointInterface sei = ((IWebService)context).getServiceEndpoint();
+ if (sei == null) {
+ return new Object[0];
+ }
+
+ adapterFactory.adapt(sei, ITreeItemContentProvider.class);
+ return new Object[]{ sei };
+ }
+ else if(context instanceof IServiceEndpointInterface) {
+ return extractMethods((IServiceEndpointInterface) context);
+ }
+ else if (context instanceof IWebMethod) {
+ return extractParams((IWebMethod)context);
+ }
+
+ return new Object[0];
+ }
+
+ protected Object[] getWsProject(final IProject project)
+ {
+ try {
+ final IWsDOMRuntimeExtension runtime = getSupportingRuntime(project);
+ if (runtime == null) {
+ return new Object[0];
+ }
+
+ // WS project is loaded already
+ final IWebServiceProject wsProject = getWsProject(runtime.getDOM(), project);
+ if (wsProject != null)
+ {
+ adapterFactory.adapt(wsProject, ITreeItemContentProvider.class);
+ return new Object[] { wsProject };
+ }
+
+ return new Object[] { new LoadingWsProject(project) };
+ }
+ catch (WsDOMLoadCanceledException e) { // $JL-EXC$
+ return new Object[]{ new LoadingWsProject(project) };
+ }
+ }
+
+ protected Object[] extractMethods(final IServiceEndpointInterface sei)
+ {
+ final List<IWebMethod> webMethods = sei.getWebMethods();
+ for (IWebMethod webMethod : webMethods) {
+ adapterFactory.adapt(webMethod, ITreeItemContentProvider.class);
+ }
+
+ return webMethods.toArray();
+ }
+
+ protected Object[] extractParams(final IWebMethod method)
+ {
+ final List<IWebParam> params = method.getParameters();
+ for (IWebParam webParam : params) {
+ adapterFactory.adapt(webParam, ITreeItemContentProvider.class);
+ }
+
+ return params.toArray();
+ }
+
+ @Override
+ public boolean hasChildren(Object element)
+ {
+ if (element instanceof IWebServiceProject)
+ {
+ return true;
+ }
+ else if(element instanceof ILoadingWsProject)
+ {
+ return true;
+ }
+ else if(element instanceof IWebServiceChildList)
+ {
+ return !((IWebServiceChildList)element).getWSChildList().isEmpty();
+ }
+ else if(element instanceof ISEIChildList)
+ {
+ return !((ISEIChildList)element).getSEIChildList().isEmpty();
+ }
+ else if (element instanceof IWebService)
+ {
+ return ((IWebService) element).getServiceEndpoint() != null;
+ }
+ else if (element instanceof IServiceEndpointInterface)
+ {
+ return !((IServiceEndpointInterface)element).getWebMethods().isEmpty();
+ }
+ else if (element instanceof IWebMethod)
+ {
+ return !((IWebMethod)element).getParameters().isEmpty();
+ }
+
+ return false;
+ }
+
+ protected IWebServiceProject getWsProject(final IDOM dom, final IProject project)
+ {
+ if (dom == null) {
+ return null;
+ }
+
+ for (IWebServiceProject wsProject : dom.getWebServiceProjects()) {
+ if(wsProject.getName().equals(project.getName())) {
+ return wsProject;
+ }
+ }
+
+ return null;
+ }
+
+ protected IWsDOMRuntimeExtension getSupportingRuntime(final IProject project)
+ {
+ final Collection<IWsDOMRuntimeInfo> domRuntimeInfos = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
+ Map<String, String> facets;
+ for (IWsDOMRuntimeInfo domRuntimeInfo : domRuntimeInfos)
+ {
+ facets = domRuntimeInfo.getProjectFacets();
+ if (hasFacet(facets, project)) {
+ return getDomRuntime(domRuntimeInfo.getId());
+ }
+ }
+
+ return null;
+ }
+
+ protected boolean hasFacet(final Map<String, String> facets, final IProject project)
+ {
+ for (String facetId : facets.keySet())
+ {
+ if (facetId == null || facets.get(facetId) == null) {
+ continue;
+ }
+
+ try {
+ if ((new FacetUtils()).hasFacetWithVersion(project, facets.get(facetId), facetId, true)){
+ return true;
+ }
+ }
+ catch (CoreException e) {
+ (new Logger()).logError(e.getMessage(), e);
+ }
+ }
+
+ return false;
+ }
+
+ protected IWsDOMRuntimeExtension getDomRuntime(String runtimeId) {
+ return WsDOMRuntimeManager.instance().getDOMRuntime(runtimeId);
+ }
+
+ /**
+ * Class that is used to listen when the DOM load will be finished. After the load has finished
+ * this class traverses the project explorers tree in order to find all instances of
+ * {@link ILoadingWsProject} and substitute them with loaded {@link IWebServiceProject}
+ *
+ * @author Georgi Vachkov
+ */
+ protected class LoadListener implements IWsDomCallback
+ {
+ public void dom(final IDOM dom)
+ {
+ final Runnable exchangeWithDomRunnable = new ExchangeLoadingWsProjectRunnable()
+ {
+ @Override
+ protected void updateTreeItemData(final TreeItem treeItem, final CommonViewer commonViewer, final IProject relevantProject)
+ {
+ final IWebServiceProject wsProject = getWsProject(dom, relevantProject);
+ adapterFactory.adapt(wsProject, ITreeItemContentProvider.class);
+ treeItem.setData(wsProject);
+ }
+ };
+ Display.getDefault().asyncExec(exchangeWithDomRunnable);
+ }
+
+ public void domLoadStarting() {
+ // nothing to do here
+ }
+
+ public void domLoadCancelled() {
+ final Runnable exchangeWithDomRunnable = new ExchangeLoadingWsProjectRunnable()
+ {
+ @Override
+ protected void updateTreeItemData(final TreeItem treeItem, final CommonViewer commonViewer, final IProject relevantProject)
+ {
+ // DOM Load has been cancelled and therefore there is nothing to update. The next time the user expands the JSX-WS node the content provider schedules another DOM load routine
+ }
+ };
+ Display.getDefault().asyncExec(exchangeWithDomRunnable);
+ }
+
+ public void domLoadFailed() {
+ // TODO: Maybe add a "DOM Load Failed node"
+ }
+ }
+
+ private class LoadingWsProject implements ILoadingWsProject
+ {
+ final IProject project;
+
+ public LoadingWsProject(final IProject project) {
+ ContractChecker.nullCheckParam(project, "project"); //$NON-NLS-1$
+ this.project = project;
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+ }
+
+ private abstract class ExchangeLoadingWsProjectRunnable implements Runnable
+ {
+ public void run()
+ {
+ final IViewPart viewPart = ProjectExplorerUtil.INSTANCE.findProjectExplorer();
+ if (viewPart instanceof CommonNavigator)
+ {
+ final CommonViewer commonViewer = ((CommonNavigator)viewPart).getCommonViewer();
+ for(TreeItem treeItem : new LoadingWsProjectNodesCollector().getLoadingWsProjects(commonViewer.getTree().getItems()))
+ {
+ final IProject relevantProject = ((ILoadingWsProject)treeItem.getData()).getProject();
+ updateTreeItemData(treeItem, commonViewer, relevantProject);
+ commonViewer.refresh(relevantProject);
+ }
+ }
+ }
+
+ protected abstract void updateTreeItemData(TreeItem treeItem, CommonViewer commonViewer, final IProject relevantProject);
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryLabelProvider.java b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryLabelProvider.java
index 9484e8f..fec941d 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryLabelProvider.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/DOMAdapterFactoryLabelProvider.java
@@ -1,141 +1,136 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.integration.navigator;
-
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationMessages;
-import org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationPlugin;
-import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingCanceled;
-import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingDummy;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IServiceEndpointInterface;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebMethod;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebService;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
-import org.eclipse.jst.ws.jaxws.dom.ui.Images;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.navigator.IDescriptionProvider;
-
-/**
- * DOM adapter factory that extends {@link AdapterFactoryLabelProvider} by providing
- * icons and labels for some objects that are not part of DOM and also overrides some
- * labels
- *
- * @author
- */
-public class DOMAdapterFactoryLabelProvider extends AdapterFactoryLabelProvider implements IDescriptionProvider
-{
- /**
- * Default Constructor uses {@link CustomDomItemProviderAdapterFactory} as default
- * adapter factory provided to the base class.
- */
- public DOMAdapterFactoryLabelProvider()
- {
- super(CustomDomItemProviderAdapterFactory.INSTANCE);
-
- DomIntegrationPlugin.getDefault().setLabelProvider(this);
- }
-
- @Override
- public Image getImage(Object element)
- {
- if(element instanceof IWebServiceChildList)
- {
- return Images.INSTANCE.getImage(Images.IMG_WEB_SERVICE_GROUP);
- }
- else if(element instanceof ISEIChildList)
- {
- return Images.INSTANCE.getImage(Images.IMG_SEI_GROUP);
- }
- else if(element instanceof ILoadingWsProject)
- {
- return Images.INSTANCE.getImage(Images.IMG_DOM_WS_PROVIDER);
- }
- else if (element instanceof ILoadingDummy || element instanceof ILoadingCanceled)
- {
- return null;
- }
-
- return super.getImage(element);
- }
-
- @Override
- public String getText(Object element)
- {
- if(element instanceof IWebServiceProject || element instanceof ILoadingWsProject)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel;
- }
- if (element instanceof ILoadingDummy)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_LoadingDummyLabel;
- }
- if (element instanceof ILoadingCanceled)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_LoadingCanceledLabel;
- }
- else if(element instanceof IWebServiceChildList)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_WebServicesLabel;
- }
- else if(element instanceof ISEIChildList)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_SeiLabel;
- }
-
- return super.getText(element);
- }
-
- public String getDescription(Object element)
- {
- if(element instanceof IWebService)
- {
- return ((IWebService)element).getName();
- }
- else if(element instanceof IServiceEndpointInterface)
- {
- return ((IServiceEndpointInterface)element).getName();
- }
- else if(element instanceof IWebServiceProject || element instanceof ILoadingWsProject)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel;
- }
- else if(element instanceof IWebServiceChildList)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_WebServicesLabel;
- }
- else if(element instanceof ISEIChildList)
- {
- return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_SeiLabel;
- }
- else if(element instanceof IWebMethod)
- {
- return ((IWebMethod)element).getName();
- }
-
- return super.getText(element);
- }
-
- public void fireLabelProviderChanged(Object element)
- {
- for (ILabelProviderListener labelProviderListener : labelProviderListeners) {
- labelProviderListener.labelProviderChanged(new LabelProviderChangedEvent(this, element));
- }
- }
-
- @Override
- protected Image getDefaultImage(Object object)
- {
- // No dfault images
- return null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.integration.navigator;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationMessages;
+import org.eclipse.jst.ws.jaxws.dom.integration.internal.plugin.DomIntegrationPlugin;
+import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingDummy;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IServiceEndpointInterface;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebMethod;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebService;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
+import org.eclipse.jst.ws.jaxws.dom.ui.Images;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.navigator.IDescriptionProvider;
+
+/**
+ * DOM adapter factory that extends {@link AdapterFactoryLabelProvider} by providing
+ * icons and labels for some objects that are not part of DOM and also overrides some
+ * labels
+ *
+ * @author
+ */
+public class DOMAdapterFactoryLabelProvider extends AdapterFactoryLabelProvider implements IDescriptionProvider
+{
+ /**
+ * Default Constructor uses {@link CustomDomItemProviderAdapterFactory} as default
+ * adapter factory provided to the base class.
+ */
+ public DOMAdapterFactoryLabelProvider()
+ {
+ super(CustomDomItemProviderAdapterFactory.INSTANCE);
+
+ DomIntegrationPlugin.getDefault().setLabelProvider(this);
+ }
+
+ @Override
+ public Image getImage(Object element)
+ {
+ if(element instanceof IWebServiceChildList)
+ {
+ return Images.INSTANCE.getImage(Images.IMG_WEB_SERVICE_GROUP);
+ }
+ else if(element instanceof ISEIChildList)
+ {
+ return Images.INSTANCE.getImage(Images.IMG_SEI_GROUP);
+ }
+ else if(element instanceof ILoadingWsProject)
+ {
+ return Images.INSTANCE.getImage(Images.IMG_DOM_WS_PROVIDER);
+ }
+ else if (element instanceof ILoadingDummy)
+ {
+ return null;
+ }
+
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element)
+ {
+ if(element instanceof IWebServiceProject || element instanceof ILoadingWsProject)
+ {
+ return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel;
+ }
+ if (element instanceof ILoadingDummy)
+ {
+ return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_LoadingDummyLabel;
+ }
+ else if(element instanceof IWebServiceChildList)
+ {
+ return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_WebServicesLabel;
+ }
+ else if(element instanceof ISEIChildList)
+ {
+ return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_SeiLabel;
+ }
+
+ return super.getText(element);
+ }
+
+ public String getDescription(Object element)
+ {
+ if(element instanceof IWebService)
+ {
+ return ((IWebService)element).getName();
+ }
+ else if(element instanceof IServiceEndpointInterface)
+ {
+ return ((IServiceEndpointInterface)element).getName();
+ }
+ else if(element instanceof IWebServiceProject || element instanceof ILoadingWsProject)
+ {
+ return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_JaxWsWebServicesLabel;
+ }
+ else if(element instanceof IWebServiceChildList)
+ {
+ return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_WebServicesLabel;
+ }
+ else if(element instanceof ISEIChildList)
+ {
+ return DomIntegrationMessages.DOMAdapterFactoryLabelProvider_SeiLabel;
+ }
+ else if(element instanceof IWebMethod)
+ {
+ return ((IWebMethod)element).getName();
+ }
+
+ return super.getText(element);
+ }
+
+ public void fireLabelProviderChanged(Object element)
+ {
+ for (ILabelProviderListener labelProviderListener : labelProviderListeners) {
+ labelProviderListener.labelProviderChanged(new LabelProviderChangedEvent(this, element));
+ }
+ }
+
+ @Override
+ protected Image getDefaultImage(Object object)
+ {
+ // No default images
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/ILoadingWsProject.java b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/ILoadingWsProject.java
index 262eaa6..d3c8573 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/ILoadingWsProject.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.integration/src/org/eclipse/jst/ws/jaxws/dom/integration/navigator/ILoadingWsProject.java
@@ -1,44 +1,37 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.integration.navigator;
-
-import org.eclipse.core.resources.IProject;
-
-
-/**
- * An interface presenting not loaded web service project. This interface is used
- * to be added to the project explorer WS tree in cases when the project is relevant
- * but it is not yet loaded by DOM loader.
- *
- * @author Georgi Vachkov
- */
-public interface ILoadingWsProject
-{
- /**
- * @return the relevant project
- */
- public IProject getProject();
-
- /**
- * @return if the DOM loading has been canceled
- */
- public boolean isLoadCanceled();
-
- /**
- * Interface used to be added to the tree as a sub node of INotLoadedWsProject node
- * and displayed with text "Loading...".
- *
- * @author Georgi Vachkov
- */
- public interface ILoadingDummy {};
-
- public interface ILoadingCanceled {};
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.integration.navigator;
+
+import org.eclipse.core.resources.IProject;
+
+
+/**
+ * An interface presenting not loaded web service project. This interface is used
+ * to be added to the project explorer WS tree in cases when the project is relevant
+ * but it is not yet loaded by DOM loader.
+ *
+ * @author Georgi Vachkov
+ */
+public interface ILoadingWsProject
+{
+ /**
+ * @return the relevant project
+ */
+ public IProject getProject();
+
+ /**
+ * Interface used to be added to the tree as a sub node of INotLoadedWsProject node
+ * and displayed with text "Loading...".
+ *
+ * @author Georgi Vachkov
+ */
+ public interface ILoadingDummy {};
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/META-INF/MANIFEST.MF
index 4255de3..1fecc2e 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/META-INF/MANIFEST.MF
@@ -1,33 +1,34 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %Bundle-Name.0
-Bundle-Vendor: %Bundle-Vendor.0
-Bundle-SymbolicName: org.eclipse.jst.ws.jaxws.dom.runtime;singleton:=true
-Bundle-Version: 1.0.100.qualifier
-Bundle-Localization: plugin
-Bundle-Activator: org.eclipse.jst.ws.jaxws.dom.runtime.internal.plugin.JaxWsDomRuntimePlugin
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.jdt.core,
- org.eclipse.jst.ws.jaxws.utils,
- org.eclipse.ui,
- org.eclipse.core.resources,
- org.eclipse.emf.ecore
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.jst.ws.jaxws.dom.runtime,
- org.eclipse.jst.ws.jaxws.dom.runtime.api,
- org.eclipse.jst.ws.jaxws.dom.runtime.internal.impl;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.internal.plugin;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.internal.util;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.persistence;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.integration.tests,org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.persistence.annotation;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.persistence.annotation.impl;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.persistence.defaults;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.dom.ui",
- org.eclipse.jst.ws.jaxws.dom.runtime.persistence.serializer;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.persistence.state;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.dom.ui",
- org.eclipse.jst.ws.jaxws.dom.runtime.persistence.sync;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.registry;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.runtime.tests",
- org.eclipse.jst.ws.jaxws.dom.runtime.util;
- x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
- org.eclipse.jst.ws.jaxws.dom.runtime.tests,
- org.eclipse.jst.ws.jaxws.dom.ui,
- org.eclipse.jst.ws.jaxws.ui"
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-SymbolicName: org.eclipse.jst.ws.jaxws.dom.runtime;singleton:=true
+Bundle-Version: 1.0.100.qualifier
+Bundle-Localization: plugin
+Bundle-Activator: org.eclipse.jst.ws.jaxws.dom.runtime.internal.plugin.JaxWsDomRuntimePlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.jdt.core,
+ org.eclipse.jst.ws.jaxws.utils,
+ org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.eclipse.emf.ecore
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.jst.ws.jaxws.dom.runtime,
+ org.eclipse.jst.ws.jaxws.dom.runtime.api,
+ org.eclipse.jst.ws.jaxws.dom.runtime.internal.impl;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.internal.plugin;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.internal.util;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.integration.tests,org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence.annotation;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence.annotation.impl;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence.defaults;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.dom.ui",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.dom.integration",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence.serializer;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence.state;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.dom.ui",
+ org.eclipse.jst.ws.jaxws.dom.runtime.persistence.sync;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.registry;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.runtime.tests",
+ org.eclipse.jst.ws.jaxws.dom.runtime.util;
+ x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
+ org.eclipse.jst.ws.jaxws.dom.runtime.tests,
+ org.eclipse.jst.ws.jaxws.dom.ui,
+ org.eclipse.jst.ws.jaxws.ui"
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/plugin.xml b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/plugin.xml
index 7746a9a..4a34439 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/plugin.xml
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/plugin.xml
@@ -1,38 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<!--
- Copyright (c) 2009 by SAP AG, Walldorf.
- 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:
- SAP AG - initial API and implementation
- -->
-
-<plugin>
-
- <extension-point id="domruntimes" name="%DomRuntimesExtension_Name" schema="schema/runtimes.exsd"/>
-
- <extension point="org.eclipse.ui.startup">
- <startup class="org.eclipse.jst.ws.jaxws.dom.runtime.WsDomStartupParticipant"/>
- </extension>
-
- <extension point="org.eclipse.emf.ecore.generated_package">
- <package
- uri = "http:///org/eclipse/jst/ws/jaxws/dom/runtime/dom.ecore"
- class = "org.eclipse.jst.ws.jaxws.dom.runtime.api.DomPackage" />
- </extension>
-
-
- <extension
- id="org.eclipse.jst.ws.jaxws.dom.jee5"
- name="%ExtensionPoint-Name.3"
- point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
- <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.persistence.Jee5WsDomRuntimeExtension"/>
- <project_facet id="jst.ejb" version="3.0"/>
- <project_facet id="jst.web" version="2.5"/>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2009 by SAP AG, Walldorf.
+ 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:
+ SAP AG - initial API and implementation
+ -->
+
+<plugin>
+
+ <extension-point id="domruntimes" name="%DomRuntimesExtension_Name" schema="schema/runtimes.exsd"/>
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http:///org/eclipse/jst/ws/jaxws/dom/runtime/dom.ecore"
+ class = "org.eclipse.jst.ws.jaxws.dom.runtime.api.DomPackage" />
+ </extension>
+
+
+ <extension
+ id="org.eclipse.jst.ws.jaxws.dom.jee5"
+ name="%ExtensionPoint-Name.3"
+ point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
+ <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.persistence.Jee5WsDomRuntimeExtension"/>
+ <project_facet id="jst.ejb" version="3.0"/>
+ <project_facet id="jst.web" version="2.5"/>
+ </extension>
+
+</plugin>
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/WsDomStartupParticipant.java b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/WsDomStartupParticipant.java
deleted file mode 100755
index 8d13853..0000000
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/WsDomStartupParticipant.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.runtime;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMRuntimeManager;
-import org.eclipse.jst.ws.jaxws.dom.runtime.internal.plugin.JaxWsDomRuntimeMessages;
-import org.eclipse.ui.IStartup;
-
-/**
- * Startup participant registered on IDE startup extension point
- *
- * @author Georgi Vachkov
- * @noextend This class is not intended to be extended by clients.
- */
-public class WsDomStartupParticipant implements IStartup
-{
-
- /**
- * Called by the Eclipse on workbench startup.
- * Starts load for registered web service runtimes
- */
- public void earlyStartup()
- {
- Job job = new Job(JaxWsDomRuntimeMessages.WsDomStartupParticipant_Startup_Job_Message)
- {
- @Override
- protected IStatus run(final IProgressMonitor monitor)
- {
- WsDOMRuntimeManager.instance().createDOMRuntimes(monitor);
- return Status.OK_STATUS;
- }
- };
-
- job.setUser(false);
- job.setPriority(Job.LONG);
- job.setRule(ResourcesPlugin.getWorkspace().getRoot());
- job.schedule();
- }
-}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/IWsDomCallback.java b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/IWsDomCallback.java
new file mode 100644
index 0000000..e1cd485
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/IWsDomCallback.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load;
+
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IDOM;
+
+/**
+ * Interface for a callback which is notified upon a DOM instance being available
+ *
+ * @author Danail Branekov
+ *
+ */
+public interface IWsDomCallback
+{
+ /**
+ * Notifies that the {@link IDOM} instance specified is now available
+ *
+ * @param dom
+ * the {@link IDOM} instance; never <code>null</code>
+ */
+ public void dom(final IDOM dom);
+
+ /**
+ * Notifies that the {@link IDOM} load routine is starting since {@link IDOM} is not available
+ */
+ public void domLoadStarting();
+
+ /**
+ * Notifies the the {@link IDOM} load process has been cancelled and therefore the {@link IDOM} instance is not available
+ */
+ public void domLoadCancelled();
+
+ /**
+ * Notifies that DOM load has failed
+ */
+ public void domLoadFailed();
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/IWsDomObtainer.java b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/IWsDomObtainer.java
new file mode 100644
index 0000000..fbbbe2d
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/IWsDomObtainer.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load;
+
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IDOM;
+
+public interface IWsDomObtainer
+{
+ /**
+ * Obtains a {@link IDOM} instance. The implementation may perform a lazy {@link IDOM} load and returns the {@link IDOM} instance via the
+ * {@link IWsDomCallback} specified
+ *
+ * @param loadCallback
+ * the callback which is notified on {@link IDOM} instance availability
+ * @see IWsDomCallback#dom(IDOM)
+ */
+ public void getDom(final IWsDomCallback loadCallback);
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/WsDomObtainer.java b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/WsDomObtainer.java
new file mode 100644
index 0000000..5618f3f
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/WsDomObtainer.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IDOM;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDOMRuntimeExtension;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMLoadCanceledException;
+import org.eclipse.jst.ws.jaxws.utils.operation.IOperationRunner;
+
+/**
+ * Implementation of the {@link IWsDomObtainer} interface which performs {@link IDOM} load if necessary. The implementation performs the load
+ * operation via the {@link IOperationRunner} supplied in the contructor
+ *
+ * @author Danail Branekov
+ */
+public class WsDomObtainer implements IWsDomObtainer
+{
+ private final IWsDOMRuntimeExtension domRuntime;
+ private final IOperationRunner opRunner;
+
+ public WsDomObtainer(final IWsDOMRuntimeExtension domRuntime, final IOperationRunner opRunner)
+ {
+ this.domRuntime = domRuntime;
+ this.opRunner = opRunner;
+ }
+
+ public void getDom(final IWsDomCallback loadCallback)
+ {
+ if (isDomAlreadyLoaded())
+ {
+ loadCallback.dom(getDomAlreadyLoaded());
+ return;
+ }
+
+ opRunner.run(loadRunnable(loadCallback));
+ }
+
+ private IRunnableWithProgress loadRunnable(final IWsDomCallback loadCallback)
+ {
+ return new LoadDomRunnable(loadCallback);
+ }
+
+ private IDOM getDomAlreadyLoaded()
+ {
+ try
+ {
+ return domRuntime.getDOM();
+ }
+ catch (WsDOMLoadCanceledException e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private boolean isDomAlreadyLoaded()
+ {
+ try
+ {
+ return domRuntime.getDOM() != null;
+ }
+ catch (WsDOMLoadCanceledException e)
+ {
+ return false;
+ }
+ }
+
+ private final class LoadDomRunnable implements IRunnableWithProgress
+ {
+ private final IWsDomCallback loadCallback;
+
+ private LoadDomRunnable(IWsDomCallback loadCallback)
+ {
+ this.loadCallback = loadCallback;
+ }
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ if (isDomAlreadyLoaded())
+ {
+ loadCallback.dom(getDomAlreadyLoaded());
+ return;
+ }
+
+ try
+ {
+ loadCallback.domLoadStarting();
+ loadCallback.dom(performLoad(monitor));
+ }
+ catch (WsDOMLoadCanceledException e)
+ {
+ cancelled(e);
+ }
+ catch (IOException e)
+ {
+ failed(e);
+ }
+ }
+
+ private IDOM performLoad(final IProgressMonitor monitor) throws IOException, WsDOMLoadCanceledException
+ {
+ try
+ {
+ domRuntime.createDOM(monitor);
+ }
+ catch (WsDOMLoadCanceledException e)
+ {
+ throw e;
+ }
+ return domRuntime.getDOM();
+ }
+
+ private void failed(IOException e) throws InvocationTargetException
+ {
+ loadCallback.domLoadFailed();
+ throw new InvocationTargetException(e);
+ }
+
+ private void cancelled(WsDOMLoadCanceledException e) throws InterruptedException
+ {
+ loadCallback.domLoadCancelled();
+ throw new InterruptedException(e.getMessage());
+ }
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/WsDomObtainerFactory.java b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/WsDomObtainerFactory.java
new file mode 100644
index 0000000..659d0b1
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/load/WsDomObtainerFactory.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IDOM;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDOMRuntimeExtension;
+import org.eclipse.jst.ws.jaxws.dom.runtime.internal.plugin.JaxWsDomRuntimeMessages;
+import org.eclipse.jst.ws.jaxws.utils.operation.OperationInJobRunner;
+
+/**
+ * Factory for creating {@link IWsDomObtainer} instances
+ *
+ * @author Danail Branekov
+ */
+public class WsDomObtainerFactory
+{
+ /**
+ * Creates a {@link IWsDomObtainer} instance which loads web service DOM asynchronously if necessary. The load routine is performed within a job
+ * which has the workspace root as a scheduling rule
+ *
+ * @param domRuntime
+ * the runtime for which the {@link IDOM} is to be loaded
+ */
+ public IWsDomObtainer createAsynchronousObtainer(final IWsDOMRuntimeExtension domRuntime)
+ {
+ return new WsDomObtainer(domRuntime, new OperationInJobRunner(JaxWsDomRuntimeMessages.JAXWS_DOM_LOADING, ResourcesPlugin.getWorkspace().getRoot()));
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.utils/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws.jaxws.utils/META-INF/MANIFEST.MF
index 50783b1..158933e 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.utils/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws.jaxws.utils/META-INF/MANIFEST.MF
@@ -1,39 +1,40 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %Bundle-Name.0
-Bundle-Vendor: %Bundle-Vendor.0
-Bundle-SymbolicName: org.eclipse.jst.ws.jaxws.utils;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.jdt.core,
- org.eclipse.core.resources,
- org.eclipse.text,
- org.eclipse.ui,
- org.eclipse.ui.ide,
- org.eclipse.wst.common.project.facet.core
-Export-Package: org.eclipse.jst.ws.jaxws.utils;
- x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
- org.eclipse.jst.ws.jaxws.dom.runtime,
- org.eclipse.jst.ws.jaxws.dom.runtime.tests,
- org.eclipse.jst.ws.jaxws.testutils,
- org.eclipse.jst.ws.jaxws.utils.tests",
- org.eclipse.jst.ws.jaxws.utils.annotations;
- x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
- org.eclipse.jst.ws.jaxws.dom.integration.tests,
- org.eclipse.jst.ws.jaxws.dom.runtime,
- org.eclipse.jst.ws.jaxws.dom.runtime.tests,
- org.eclipse.jst.ws.jaxws.utils.tests",
- org.eclipse.jst.ws.jaxws.utils.clazz;x-friends:="org.eclipse.jst.ws.jaxws.utils.tests",
- org.eclipse.jst.ws.jaxws.utils.exception;x-friends:="org.eclipse.jst.ws.jaxws.testutils",
- org.eclipse.jst.ws.jaxws.utils.facets;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.runtime",
- org.eclipse.jst.ws.jaxws.utils.internal.annotations.impl;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.utils.tests",
- org.eclipse.jst.ws.jaxws.utils.logging;
- x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
- org.eclipse.jst.ws.jaxws.dom.runtime,
- org.eclipse.jst.ws.jaxws.dom.runtime.tests,
- org.eclipse.jst.ws.jaxws.dom.ui,
- org.eclipse.jst.ws.jaxws.testutils",
- org.eclipse.jst.ws.jaxws.utils.resources;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.utils.tests"
-Bundle-Activator: org.eclipse.jst.ws.jaxws.utils.internal.plugin.JaxwsUtilsPlugin
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-SymbolicName: org.eclipse.jst.ws.jaxws.utils;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.jdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.text,
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.wst.common.project.facet.core
+Export-Package: org.eclipse.jst.ws.jaxws.utils;
+ x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
+ org.eclipse.jst.ws.jaxws.dom.runtime,
+ org.eclipse.jst.ws.jaxws.dom.runtime.tests,
+ org.eclipse.jst.ws.jaxws.testutils,
+ org.eclipse.jst.ws.jaxws.utils.tests",
+ org.eclipse.jst.ws.jaxws.utils.annotations;
+ x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
+ org.eclipse.jst.ws.jaxws.dom.integration.tests,
+ org.eclipse.jst.ws.jaxws.dom.runtime,
+ org.eclipse.jst.ws.jaxws.dom.runtime.tests,
+ org.eclipse.jst.ws.jaxws.utils.tests",
+ org.eclipse.jst.ws.jaxws.utils.clazz;x-friends:="org.eclipse.jst.ws.jaxws.utils.tests",
+ org.eclipse.jst.ws.jaxws.utils.exception;x-friends:="org.eclipse.jst.ws.jaxws.testutils",
+ org.eclipse.jst.ws.jaxws.utils.facets;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.runtime",
+ org.eclipse.jst.ws.jaxws.utils.internal.annotations.impl;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.utils.tests",
+ org.eclipse.jst.ws.jaxws.utils.logging;
+ x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,
+ org.eclipse.jst.ws.jaxws.dom.runtime,
+ org.eclipse.jst.ws.jaxws.dom.runtime.tests,
+ org.eclipse.jst.ws.jaxws.dom.ui,
+ org.eclipse.jst.ws.jaxws.testutils",
+ org.eclipse.jst.ws.jaxws.utils.operation;x-friends:="org.eclipse.jst.ws.jaxws.dom.runtime,org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.utils.tests",
+ org.eclipse.jst.ws.jaxws.utils.resources;x-friends:="org.eclipse.jst.ws.jaxws.dom.integration,org.eclipse.jst.ws.jaxws.dom.runtime.tests,org.eclipse.jst.ws.jaxws.utils.tests"
+Bundle-Activator: org.eclipse.jst.ws.jaxws.utils.internal.plugin.JaxwsUtilsPlugin
diff --git a/bundles/org.eclipse.jst.ws.jaxws.utils/src/org/eclipse/jst/ws/jaxws/utils/operation/IOperationRunner.java b/bundles/org.eclipse.jst.ws.jaxws.utils/src/org/eclipse/jst/ws/jaxws/utils/operation/IOperationRunner.java
new file mode 100644
index 0000000..7f9f150
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.utils/src/org/eclipse/jst/ws/jaxws/utils/operation/IOperationRunner.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.utils.operation;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+/**
+ * Utility interface for running operations
+ *
+ * @author Danail Branekov
+ */
+public interface IOperationRunner
+{
+ /**
+ * Runs the operation specified
+ *
+ * @param runnable
+ * the operation to run
+ */
+ public void run(final IRunnableWithProgress runnable);
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.utils/src/org/eclipse/jst/ws/jaxws/utils/operation/OperationInJobRunner.java b/bundles/org.eclipse.jst.ws.jaxws.utils/src/org/eclipse/jst/ws/jaxws/utils/operation/OperationInJobRunner.java
new file mode 100644
index 0000000..b7cbc4b
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.jaxws.utils/src/org/eclipse/jst/ws/jaxws/utils/operation/OperationInJobRunner.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.utils.operation;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jst.ws.jaxws.utils.StatusUtils;
+import org.eclipse.jst.ws.jaxws.utils.logging.ILogger;
+import org.eclipse.jst.ws.jaxws.utils.logging.Logger;
+
+/**
+ * Implementation of the {@link IOperationRunner} interface which runs the operation in a job which the supplied scheduling rule
+ *
+ * @author Danail Branekov
+ */
+public class OperationInJobRunner implements IOperationRunner
+{
+ private final String jobName;
+ private final ISchedulingRule jobRule;
+ private final ILogger logger;
+
+ /**
+ * Constructor
+ *
+ * @param jobName
+ * the name of the job which performs the operation
+ * @param jobRule
+ * the scheduling rule of the job
+ */
+ public OperationInJobRunner(final String jobName, final ISchedulingRule jobRule)
+ {
+ this.jobName = jobName;
+ this.jobRule = jobRule;
+ this.logger = new Logger();
+ }
+
+ public void run(final IRunnableWithProgress runnable)
+ {
+ final Job job = new Job(jobName)
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ try
+ {
+ runnable.run(monitor);
+ }
+ catch (InvocationTargetException e)
+ {
+ logger.logError(e.getMessage(), e);
+ return StatusUtils.statusError(e.getMessage(), e);
+ }
+ catch (InterruptedException e)
+ {
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setRule(this.jobRule);
+ job.schedule();
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/dom/AllTestsSuite.java b/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/dom/AllTestsSuite.java
index 687502f..b9af6d9 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/dom/AllTestsSuite.java
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/dom/AllTestsSuite.java
@@ -1,34 +1,36 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.integration.tests.dom;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.DOMAdapterFactoryContentProviderTest;
-import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.DOMAdapterFactoryLabelProviderTest;
-import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.DOMPropertyViewAdapterFactoryTest;
-import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.WebServiceDecoratorTest;
-
-public class AllTestsSuite
-{
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTestSuite(DOMAdapterFactoryContentProviderTest.class);
- suite.addTestSuite(DOMAdapterFactoryLabelProviderTest.class);
- suite.addTestSuite(DOMPropertyViewAdapterFactoryTest.class);
- suite.addTestSuite(WebServiceDecoratorTest.class);
-
- return suite;
- }
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.integration.tests.dom;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.DOMAdapterFactoryContentProviderTest;
+import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.DOMAdapterFactoryLabelProviderTest;
+import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.DOMPropertyViewAdapterFactoryTest;
+import org.eclipse.jst.ws.jaxws.dom.integration.tests.navigator.WebServiceDecoratorTest;
+import org.eclipse.jst.ws.jaxws.dom.integration.tests.util.LoadingWsProjectNodesCollectorTest;
+
+public class AllTestsSuite
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(DOMAdapterFactoryContentProviderTest.class);
+ suite.addTestSuite(DOMAdapterFactoryLabelProviderTest.class);
+ suite.addTestSuite(DOMPropertyViewAdapterFactoryTest.class);
+ suite.addTestSuite(WebServiceDecoratorTest.class);
+ suite.addTestSuite(LoadingWsProjectNodesCollectorTest.class);
+
+ return suite;
+ }
}
\ No newline at end of file
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/navigator/DOMAdapterFactoryContentProviderTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/navigator/DOMAdapterFactoryContentProviderTest.java
index 5866960..e4d3dcb 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/navigator/DOMAdapterFactoryContentProviderTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/navigator/DOMAdapterFactoryContentProviderTest.java
@@ -19,7 +19,6 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jst.ws.jaxws.dom.integration.navigator.DOMAdapterFactoryContentProvider;
import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject;
-import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingCanceled;
import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject.ILoadingDummy;
import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ISEIChildList;
import org.eclipse.jst.ws.jaxws.dom.integration.navigator.IWebServiceChildList;
@@ -250,31 +249,6 @@
return null;
}
-// public void testNotifyChanged()
-// {
-// Object[] children = adapterFactory.getChildren(testPrj1.getProject());
-//
-// try
-// {
-// testPrj1.createType(modelSync1, "Sei3.java", "@javax.jws.WebService(name=\"Sei3Name\") public interface Sei3 {}");
-// testPrj1.createType(modelSync1, "WS3.java", "@javax.jws.WebService(serviceName=\"WS3Name\", endpointInterface=\"org.eclipse.test.modelsync1.Sei3\") public class WS3 {}");
-// }
-// catch(JavaModelException e)
-// {
-// fail(e.toString());
-// }
-//
-// children = adapterFactory.getChildren(children[0]);
-//
-// Object[] sEIs = adapterFactory.getChildren(children[0]);
-//
-// assertEquals(sEIs.length, 3);
-//
-// Object[] wSs = adapterFactory.getChildren(children[1]);
-//
-// assertEquals(wSs.length, 3);
-// }
-
public void testGetWSProject()
{
adapterFactory = new DOMAdapterFactoryContentProvider();
@@ -299,11 +273,10 @@
assertTrue(children[0] instanceof ILoadingDummy);
}
- public void testGetWsProjectChildsDomLoadNotCanceled()
+ public void testGetWsProjectChildsDomNotLoaded()
{
ILoadingWsProject loadingProject = new ILoadingWsProject() {
- public IProject getProject() { return null; }
- public boolean isLoadCanceled() {return false;}
+ public IProject getProject() { return testPrj1.getProject(); }
};
Object[] children = adapterFactory.getChildren(loadingProject);
@@ -311,18 +284,6 @@
assertTrue(children[0] instanceof ILoadingDummy);
}
- public void testGetWsProjectChildsDomLoadCanceled()
- {
- ILoadingWsProject loadingProject = new ILoadingWsProject() {
- public IProject getProject() { return null; }
- public boolean isLoadCanceled() {return true;}
- };
-
- Object[] children = adapterFactory.getChildren(loadingProject);
- assertEquals(1, children.length);
- assertTrue(children[0] instanceof ILoadingCanceled);
- }
-
public void testGetSupportingRuntime()
{
DOMAdapterFactoryContentProviderMy provider = new DOMAdapterFactoryContentProviderMy();
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/util/LoadingWsProjectNodesCollectorTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/util/LoadingWsProjectNodesCollectorTest.java
new file mode 100644
index 0000000..91d5cbe
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.integration.tests/src/org/eclipse/jst/ws/jaxws/dom/integration/tests/util/LoadingWsProjectNodesCollectorTest.java
@@ -0,0 +1,75 @@
+package org.eclipse.jst.ws.jaxws.dom.integration.tests.util;
+
+import java.util.Collection;
+
+import org.eclipse.jst.ws.jaxws.dom.integration.internal.util.LoadingWsProjectNodesCollector;
+import org.eclipse.jst.ws.jaxws.dom.integration.navigator.ILoadingWsProject;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.Mock;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.MockObjectTestCase;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class LoadingWsProjectNodesCollectorTest extends MockObjectTestCase
+{
+ private TreeItem parentItem;
+ private TreeItem childItem;
+ private Mock<ILoadingWsProject> loadingProject;
+ private Shell treeShell;
+ private LoadingWsProjectNodesCollector collector;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ collector = new LoadingWsProjectNodesCollector();
+ loadingProject = mock(ILoadingWsProject.class);
+
+ treeShell = new Shell();
+ final Tree parentTree = new Tree(treeShell, SWT.NONE);
+ parentItem = new TreeItem(parentTree, SWT.NONE);
+ childItem = new TreeItem(parentItem, SWT.NONE);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ treeShell.dispose();
+ }
+
+ public void testLoadingProjectAsParent()
+ {
+ parentItem.setData(loadingProject.proxy());
+ childItem.setData(new Object());
+ verifyFoundItem(parentItem);
+ }
+
+ public void testLoadingProjectAsChild()
+ {
+ parentItem.setData(new Object());
+ childItem.setData(loadingProject.proxy());
+ verifyFoundItem(childItem);
+ }
+
+ public void testStopCollectingOnWebServiceProject()
+ {
+ parentItem.setData(mock(IWebServiceProject.class).proxy());
+ childItem.setData(loadingProject.proxy());
+ assertEquals("Collector did not stop when IWebServiceProject encoutered", 0, getLoadingProjectItems().size());
+ }
+
+ private void verifyFoundItem(final TreeItem expectedItem)
+ {
+ final Collection<TreeItem> items = getLoadingProjectItems();
+ assertEquals("One item expected", 1, items.size());
+ assertSame("Unexpected item", expectedItem, items.iterator().next());
+ }
+
+ private Collection<TreeItem> getLoadingProjectItems()
+ {
+ return collector.getLoadingWsProjects(new TreeItem[] { parentItem });
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/plugin.xml b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/plugin.xml
index 3693b7f..35e4f2a 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/plugin.xml
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/plugin.xml
@@ -1,48 +1,48 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<!--
- Copyright (c) 2009 by SAP AG, Walldorf.
- 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:
- SAP AG - initial API and implementation
- -->
-
-<fragment>
- <extension
- id="supportedruntimetest"
- name="Testing"
- point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
- <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.TestWsDOMRuntimeExtension"/>
- <project_facet
- id="jst.web"
- version="1.0.0.0"/>
- <project_facet
- id="test.facet"/>
- </extension>
- <extension
- id="supportedruntimetest1"
- name="Testing1"
- point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
- <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.TestWsDOMRuntimeExtension"/>
- <project_facet
- id="jst.webb"
- version="1.0.0.0"/>
- <project_facet
- id="test.facett"/>
- </extension>
- <extension
- id="supportedruntimetest2"
- name="Testing2"
- point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
- <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.WsDOMRuntimeRegistryTest"/>
- <project_facet
- id="jst.webb"
- version="1.0.0.0"/>
- <project_facet
- id="test.facett"/>
- </extension>
-</fragment>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2009 by SAP AG, Walldorf.
+ 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:
+ SAP AG - initial API and implementation
+ -->
+
+<fragment>
+ <extension
+ id="supportedruntimetest"
+ name="Testing"
+ point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
+ <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.TestWsDOMRuntimeExtension"/>
+ <project_facet
+ id="jst.webb"
+ version="1.0.0.0"/>
+ <project_facet
+ id="test.facet"/>
+ </extension>
+ <extension
+ id="supportedruntimetest1"
+ name="Testing1"
+ point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
+ <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.TestWsDOMRuntimeExtension"/>
+ <project_facet
+ id="jst.webb"
+ version="1.0.0.0"/>
+ <project_facet
+ id="test.facett"/>
+ </extension>
+ <extension
+ id="supportedruntimetest2"
+ name="Testing2"
+ point="org.eclipse.jst.ws.jaxws.dom.runtime.domruntimes">
+ <implementation class="org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.WsDOMRuntimeRegistryTest"/>
+ <project_facet
+ id="jst.webb"
+ version="1.0.0.0"/>
+ <project_facet
+ id="test.facett"/>
+ </extension>
+</fragment>
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java
index c5c18f6..11c25ce 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java
@@ -32,6 +32,7 @@
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.defaults.ParameterPropertyDefaultsAdapterTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.defaults.SeiPropertyDefaultsAdapterTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.defaults.WsPropertyDefaultsAdapterTest;
+import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.load.WsDomObtainerTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.serializer.AbstractSerializerAdapterTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.serializer.MethodSerializerAdapterTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.serializer.ParameterSerializerAdapterTest;
@@ -122,6 +123,9 @@
suite.addTestSuite(WmValidationTest.class);
suite.addTestSuite(WpValidationTest.class);
suite.addTestSuite(EndpointIsSessionBeanRuleTest.class);
+
+ // DOM load tests
+ suite.addTestSuite(WsDomObtainerTest.class);
return suite;
}
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeManagerTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeManagerTest.java
index e14c0d6..6c5abf6 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeManagerTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeManagerTest.java
@@ -1,124 +1,107 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom;
-
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDOMRuntimeExtension;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMRuntimeManager;
-import org.eclipse.jst.ws.jaxws.dom.runtime.registry.IWsDOMRuntimeInfo;
-import org.eclipse.jst.ws.jaxws.dom.runtime.registry.WsDOMRuntimeRegistry;
-
-public class WsDOMRuntimeManagerTest extends TestCase
-{
- private WsDOMRuntimeManager target;
-
- @Override
- public void setUp()
- {
- target = (WsDOMRuntimeManager)WsDOMRuntimeManager.instance();
- }
-
- public void testGetDOMRuntimeForRuntimeInfo()
- {
- Collection<IWsDOMRuntimeInfo> registeredRuntimes = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
-
- assertNotNull(target.getDOMRuntime(registeredRuntimes.iterator().next()));
-
- IWsDOMRuntimeExtension runtime = target.getDOMRuntime(registeredRuntimes.iterator().next());
-
- assertEquals(runtime, target.getDOMRuntime(registeredRuntimes.iterator().next()));
-
- registeredRuntimes = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
-
- assertEquals(runtime, target.getDOMRuntime(registeredRuntimes.iterator().next()));
- }
-
- public void testGetDOMRuntimeForRuntimeId()
- {
- assertNotNull(target.getDOMRuntime("supportedruntimetest"));
- assertNull(target.getDOMRuntime("test.id"));
- assertEquals(target.getDOMRuntime("supportedruntimetest"), target.getDOMRuntime("supportedruntimetest"));
- }
-
- public void testCreateDOMRuntimes()
- {
- target.createDOMRuntimes(null);
-
- assertNotNull(target.getDOMRuntime("supportedruntimetest"));
- assertNotNull(target.getDOMRuntime("supportedruntimetest1"));
- }
-
- public void testEarlyStartup()
- {
- IConfigurationElement[] confElements = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.ui.startup").getConfigurationElements();
-
- for(int ii=0; ii<confElements.length; ii++)
- {
- if("org.eclipse.jst.ws.jaxws.dom.runtime.WsDomStartupParticipant".equals(confElements[ii].getAttribute("class")))
- {
- return;
- }
- }
-
- fail("The early startup for DOM Model is not defined !");
- }
-
- public void testReloadDOMRuntimes()
- {
- target.reloadDOMRuntimes(null);
-
- IWsDOMRuntimeExtension domRuntime = target.getDOMRuntime("supportedruntimetest");
- IWsDOMRuntimeExtension domRuntime1 = target.getDOMRuntime("supportedruntimetest1");
-
- target.reloadDOMRuntimes(null);
-
- assertNotSame(domRuntime,target.getDOMRuntime(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest").getId()));
- assertNotSame(domRuntime1,target.getDOMRuntime(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest1").getId()));
- }
-
- public void testGetDOMRuntimes()
- {
- IWsDOMRuntimeExtension domRuntime = target.getDOMRuntime("supportedruntimetest");
- assertNotNull(domRuntime);
- assertTrue(domRuntime instanceof TestWsDOMRuntimeExtension);
-
- IWsDOMRuntimeExtension domRuntime1 = target.getDOMRuntime("supportedruntimetest1");
- assertNotNull(domRuntime1);
- assertTrue(domRuntime1 instanceof TestWsDOMRuntimeExtension);
-
- IWsDOMRuntimeExtension domRuntime2 = target.getDOMRuntime("supportedruntimetest2");
- assertNull(domRuntime2);
- }
-
- public void testCreateDOMPassesProgressMonitor()
- {
- MyWsDomRuntimeManager manager = new MyWsDomRuntimeManager();
- IWsDOMRuntimeInfo info = WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest1");
- NullProgressMonitor npm = new NullProgressMonitor();
- IWsDOMRuntimeExtension rtEx = manager.createDOMRuntime(info, npm);
- assertTrue(rtEx instanceof TestWsDOMRuntimeExtension);
- assertEquals(npm, ((TestWsDOMRuntimeExtension)rtEx).monitor);
- }
-
- private class MyWsDomRuntimeManager extends WsDOMRuntimeManager
- {
- protected IWsDOMRuntimeExtension createDOMRuntime(final IWsDOMRuntimeInfo runtimeInfo, final IProgressMonitor monitor) {
- return super.createDOMRuntime(runtimeInfo, monitor);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom;
+
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDOMRuntimeExtension;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMRuntimeManager;
+import org.eclipse.jst.ws.jaxws.dom.runtime.registry.IWsDOMRuntimeInfo;
+import org.eclipse.jst.ws.jaxws.dom.runtime.registry.WsDOMRuntimeRegistry;
+
+public class WsDOMRuntimeManagerTest extends TestCase
+{
+ private WsDOMRuntimeManager target;
+
+ @Override
+ public void setUp()
+ {
+ target = (WsDOMRuntimeManager)WsDOMRuntimeManager.instance();
+ }
+
+ public void testGetDOMRuntimeForRuntimeInfo()
+ {
+ Collection<IWsDOMRuntimeInfo> registeredRuntimes = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
+
+ assertNotNull(target.getDOMRuntime(registeredRuntimes.iterator().next()));
+
+ IWsDOMRuntimeExtension runtime = target.getDOMRuntime(registeredRuntimes.iterator().next());
+
+ assertEquals(runtime, target.getDOMRuntime(registeredRuntimes.iterator().next()));
+
+ registeredRuntimes = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
+
+ assertEquals(runtime, target.getDOMRuntime(registeredRuntimes.iterator().next()));
+ }
+
+ public void testGetDOMRuntimeForRuntimeId()
+ {
+ assertNotNull(target.getDOMRuntime("supportedruntimetest"));
+ assertNull(target.getDOMRuntime("test.id"));
+ assertEquals(target.getDOMRuntime("supportedruntimetest"), target.getDOMRuntime("supportedruntimetest"));
+ }
+
+ public void testCreateDOMRuntimes()
+ {
+ target.createDOMRuntimes(null);
+
+ assertNotNull(target.getDOMRuntime("supportedruntimetest"));
+ assertNotNull(target.getDOMRuntime("supportedruntimetest1"));
+ }
+
+ public void testReloadDOMRuntimes()
+ {
+ target.reloadDOMRuntimes(null);
+
+ IWsDOMRuntimeExtension domRuntime = target.getDOMRuntime("supportedruntimetest");
+ IWsDOMRuntimeExtension domRuntime1 = target.getDOMRuntime("supportedruntimetest1");
+
+ target.reloadDOMRuntimes(null);
+
+ assertNotSame(domRuntime,target.getDOMRuntime(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest").getId()));
+ assertNotSame(domRuntime1,target.getDOMRuntime(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest1").getId()));
+ }
+
+ public void testGetDOMRuntimes()
+ {
+ IWsDOMRuntimeExtension domRuntime = target.getDOMRuntime("supportedruntimetest");
+ assertNotNull(domRuntime);
+ assertTrue(domRuntime instanceof TestWsDOMRuntimeExtension);
+
+ IWsDOMRuntimeExtension domRuntime1 = target.getDOMRuntime("supportedruntimetest1");
+ assertNotNull(domRuntime1);
+ assertTrue(domRuntime1 instanceof TestWsDOMRuntimeExtension);
+
+ IWsDOMRuntimeExtension domRuntime2 = target.getDOMRuntime("supportedruntimetest2");
+ assertNull(domRuntime2);
+ }
+
+ public void testCreateDOMPassesProgressMonitor()
+ {
+ MyWsDomRuntimeManager manager = new MyWsDomRuntimeManager();
+ IWsDOMRuntimeInfo info = WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest1");
+ NullProgressMonitor npm = new NullProgressMonitor();
+ IWsDOMRuntimeExtension rtEx = manager.createDOMRuntime(info, npm);
+ assertTrue(rtEx instanceof TestWsDOMRuntimeExtension);
+ assertEquals(npm, ((TestWsDOMRuntimeExtension)rtEx).monitor);
+ }
+
+ private class MyWsDomRuntimeManager extends WsDOMRuntimeManager
+ {
+ protected IWsDOMRuntimeExtension createDOMRuntime(final IWsDOMRuntimeInfo runtimeInfo, final IProgressMonitor monitor) {
+ return super.createDOMRuntime(runtimeInfo, monitor);
+ }
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeRegistryTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeRegistryTest.java
index 26fc228..d8b4a72 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeRegistryTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/WsDOMRuntimeRegistryTest.java
@@ -1,146 +1,146 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jst.ws.jaxws.dom.runtime.internal.util.NamedExtensionInfo;
-import org.eclipse.jst.ws.jaxws.dom.runtime.registry.IWsDOMRuntimeInfo;
-import org.eclipse.jst.ws.jaxws.dom.runtime.registry.WsDOMRuntimeRegistry;
-
-public class WsDOMRuntimeRegistryTest extends TestCase
-{
- private static final class RuntimeInfo extends NamedExtensionInfo implements IWsDOMRuntimeInfo
- {
- private HashMap<String, String> projectFacets;
-
- RuntimeInfo(final String pId, final String pLabel, final HashMap<String, String> projectFacets)
- {
- super(pId, pLabel);
-
- this.projectFacets = projectFacets;
- }
-
- public HashMap<String,String> getProjectFacets()
- {
- return this.projectFacets;
- }
- }
-
-
- public void testInstantiateRuntime()
- {
- Collection<IWsDOMRuntimeInfo> runtimeInfos = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
- Iterator<IWsDOMRuntimeInfo> runtimeInfoIter = runtimeInfos.iterator();
-
- while(runtimeInfoIter.hasNext())
- {
- IWsDOMRuntimeInfo runtimeInfo = runtimeInfoIter.next();
-
- if(runtimeInfo.getId().equals("supportedruntimetest")
- || runtimeInfo.getId().equals("supportedruntimetest1"))
- {
- assertNotNull(WsDOMRuntimeRegistry.instantiateRuntime(runtimeInfo));
- assertTrue(WsDOMRuntimeRegistry.instantiateRuntime(runtimeInfo) instanceof TestWsDOMRuntimeExtension);
- }
- else if(runtimeInfo.getId().equals("supportedruntimetest2"))
- {
- assertNull(WsDOMRuntimeRegistry.instantiateRuntime(runtimeInfo));
- }
- }
-
- assertNull(WsDOMRuntimeRegistry.instantiateRuntime(null));
-
- RuntimeInfo info = new RuntimeInfo("Tst", "ddgg", new HashMap<String,String>());
-
- assertNull(WsDOMRuntimeRegistry.instantiateRuntime(info));
- }
-
- public void testFindExtension()
- {
- assertNotNull(WsDOMRuntimeRegistry.findExtension(WsDOMRuntimeRegistry.getRegisteredRuntimesInfo().iterator().next()));
- assertNull(WsDOMRuntimeRegistry.findExtension(null));
-
- RuntimeInfo runtimeInfo = new RuntimeInfo("Tst", "ddgg", new HashMap<String,String>());
- assertNull(WsDOMRuntimeRegistry.findExtension(runtimeInfo));
- }
-
- public void testGetRegisteredRuntimeInfo()
- {
- Collection<IWsDOMRuntimeInfo> runtimeInfos = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
-
- assertNotNull(runtimeInfos);
- assertTrue(runtimeInfos.size() >= 3);
-
- Iterator<IWsDOMRuntimeInfo> runtimeInfoIter = runtimeInfos.iterator();
-
- while(runtimeInfoIter.hasNext())
- {
- IWsDOMRuntimeInfo runtimeInfo = runtimeInfoIter.next();
-
- assertNotNull(runtimeInfo.getId());
-
- if(runtimeInfo.getId().equals("supportedruntimetest"))
- {
- assertNotNull(runtimeInfo.getName());
- assertEquals(runtimeInfo.getName(), "Testing");
-
- assertNotNull(runtimeInfo.getProjectFacets());
- assertEquals(runtimeInfo.getProjectFacets().size(), 2);
-
- assertTrue(runtimeInfo.getProjectFacets().containsKey("jst.web"));
- assertTrue(runtimeInfo.getProjectFacets().containsKey("test.facet"));
-
- assertFalse(runtimeInfo.getProjectFacets().containsKey("jst.webb"));
- assertFalse(runtimeInfo.getProjectFacets().containsKey("test.facett"));
-
- assertNotNull(runtimeInfo.getProjectFacets().get("jst.web"));
- assertEquals(runtimeInfo.getProjectFacets().get("jst.web"), "1.0.0.0");
- assertNull(runtimeInfo.getProjectFacets().get("test.facet"));
-
- assertNull(runtimeInfo.getProjectFacets().get("dummy.facet"));
- }
- else if(runtimeInfo.getId().equals("supportedruntimetest1"))
- {
- assertNotNull(runtimeInfo.getName());
- assertEquals(runtimeInfo.getName(), "Testing1");
-
- assertNotNull(runtimeInfo.getProjectFacets());
- assertEquals(runtimeInfo.getProjectFacets().size(), 2);
-
- assertTrue(runtimeInfo.getProjectFacets().containsKey("jst.webb"));
- assertTrue(runtimeInfo.getProjectFacets().containsKey("test.facett"));
-
- assertFalse(runtimeInfo.getProjectFacets().containsKey("jst.web"));
- assertFalse(runtimeInfo.getProjectFacets().containsKey("test.facet"));
-
- assertNotNull(runtimeInfo.getProjectFacets().get("jst.webb"));
- assertEquals(runtimeInfo.getProjectFacets().get("jst.webb"), "1.0.0.0");
- assertNull(runtimeInfo.getProjectFacets().get("test.facett"));
-
- assertNull(runtimeInfo.getProjectFacets().get("dummy.facet"));
- }
- }
- }
-
-
- public void testGetRuntimeInfo()
- {
- assertNull(WsDOMRuntimeRegistry.getRuntimeInfo("test.id"));
- assertNotNull(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest"));
- assertNotNull(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest1"));
- assertNull(WsDOMRuntimeRegistry.getRuntimeInfo(null));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jst.ws.jaxws.dom.runtime.internal.util.NamedExtensionInfo;
+import org.eclipse.jst.ws.jaxws.dom.runtime.registry.IWsDOMRuntimeInfo;
+import org.eclipse.jst.ws.jaxws.dom.runtime.registry.WsDOMRuntimeRegistry;
+
+public class WsDOMRuntimeRegistryTest extends TestCase
+{
+ private static final class RuntimeInfo extends NamedExtensionInfo implements IWsDOMRuntimeInfo
+ {
+ private HashMap<String, String> projectFacets;
+
+ RuntimeInfo(final String pId, final String pLabel, final HashMap<String, String> projectFacets)
+ {
+ super(pId, pLabel);
+
+ this.projectFacets = projectFacets;
+ }
+
+ public HashMap<String,String> getProjectFacets()
+ {
+ return this.projectFacets;
+ }
+ }
+
+
+ public void testInstantiateRuntime()
+ {
+ Collection<IWsDOMRuntimeInfo> runtimeInfos = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
+ Iterator<IWsDOMRuntimeInfo> runtimeInfoIter = runtimeInfos.iterator();
+
+ while(runtimeInfoIter.hasNext())
+ {
+ IWsDOMRuntimeInfo runtimeInfo = runtimeInfoIter.next();
+
+ if(runtimeInfo.getId().equals("supportedruntimetest")
+ || runtimeInfo.getId().equals("supportedruntimetest1"))
+ {
+ assertNotNull(WsDOMRuntimeRegistry.instantiateRuntime(runtimeInfo));
+ assertTrue(WsDOMRuntimeRegistry.instantiateRuntime(runtimeInfo) instanceof TestWsDOMRuntimeExtension);
+ }
+ else if(runtimeInfo.getId().equals("supportedruntimetest2"))
+ {
+ assertNull(WsDOMRuntimeRegistry.instantiateRuntime(runtimeInfo));
+ }
+ }
+
+ assertNull(WsDOMRuntimeRegistry.instantiateRuntime(null));
+
+ RuntimeInfo info = new RuntimeInfo("Tst", "ddgg", new HashMap<String,String>());
+
+ assertNull(WsDOMRuntimeRegistry.instantiateRuntime(info));
+ }
+
+ public void testFindExtension()
+ {
+ assertNotNull(WsDOMRuntimeRegistry.findExtension(WsDOMRuntimeRegistry.getRegisteredRuntimesInfo().iterator().next()));
+ assertNull(WsDOMRuntimeRegistry.findExtension(null));
+
+ RuntimeInfo runtimeInfo = new RuntimeInfo("Tst", "ddgg", new HashMap<String,String>());
+ assertNull(WsDOMRuntimeRegistry.findExtension(runtimeInfo));
+ }
+
+ public void testGetRegisteredRuntimeInfo()
+ {
+ Collection<IWsDOMRuntimeInfo> runtimeInfos = WsDOMRuntimeRegistry.getRegisteredRuntimesInfo();
+
+ assertNotNull(runtimeInfos);
+ assertTrue(runtimeInfos.size() >= 3);
+
+ Iterator<IWsDOMRuntimeInfo> runtimeInfoIter = runtimeInfos.iterator();
+
+ while(runtimeInfoIter.hasNext())
+ {
+ IWsDOMRuntimeInfo runtimeInfo = runtimeInfoIter.next();
+
+ assertNotNull(runtimeInfo.getId());
+
+ if(runtimeInfo.getId().equals("supportedruntimetest"))
+ {
+ assertNotNull(runtimeInfo.getName());
+ assertEquals(runtimeInfo.getName(), "Testing");
+
+ assertNotNull(runtimeInfo.getProjectFacets());
+ assertEquals(runtimeInfo.getProjectFacets().size(), 2);
+
+ assertTrue(runtimeInfo.getProjectFacets().containsKey("jst.webb"));
+ assertTrue(runtimeInfo.getProjectFacets().containsKey("test.facet"));
+
+ assertFalse(runtimeInfo.getProjectFacets().containsKey("jst.web"));
+ assertFalse(runtimeInfo.getProjectFacets().containsKey("test.facett"));
+
+ assertNotNull(runtimeInfo.getProjectFacets().get("jst.webb"));
+ assertEquals(runtimeInfo.getProjectFacets().get("jst.webb"), "1.0.0.0");
+ assertNull(runtimeInfo.getProjectFacets().get("test.facet"));
+
+ assertNull(runtimeInfo.getProjectFacets().get("dummy.facet"));
+ }
+ else if(runtimeInfo.getId().equals("supportedruntimetest1"))
+ {
+ assertNotNull(runtimeInfo.getName());
+ assertEquals(runtimeInfo.getName(), "Testing1");
+
+ assertNotNull(runtimeInfo.getProjectFacets());
+ assertEquals(runtimeInfo.getProjectFacets().size(), 2);
+
+ assertTrue(runtimeInfo.getProjectFacets().containsKey("jst.webb"));
+ assertTrue(runtimeInfo.getProjectFacets().containsKey("test.facett"));
+
+ assertFalse(runtimeInfo.getProjectFacets().containsKey("jst.web"));
+ assertFalse(runtimeInfo.getProjectFacets().containsKey("test.facet"));
+
+ assertNotNull(runtimeInfo.getProjectFacets().get("jst.webb"));
+ assertEquals(runtimeInfo.getProjectFacets().get("jst.webb"), "1.0.0.0");
+ assertNull(runtimeInfo.getProjectFacets().get("test.facett"));
+
+ assertNull(runtimeInfo.getProjectFacets().get("dummy.facet"));
+ }
+ }
+ }
+
+
+ public void testGetRuntimeInfo()
+ {
+ assertNull(WsDOMRuntimeRegistry.getRuntimeInfo("test.id"));
+ assertNotNull(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest"));
+ assertNotNull(WsDOMRuntimeRegistry.getRuntimeInfo("supportedruntimetest1"));
+ assertNull(WsDOMRuntimeRegistry.getRuntimeInfo(null));
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/load/WsDomObtainerTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/load/WsDomObtainerTest.java
new file mode 100644
index 0000000..74991df
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/load/WsDomObtainerTest.java
@@ -0,0 +1,194 @@
+package org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.load;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IDOM;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWsDOMRuntimeExtension;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.WsDOMLoadCanceledException;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load.IWsDomCallback;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.load.WsDomObtainer;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.Mock;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.MockObjectTestCase;
+import org.eclipse.jst.ws.jaxws.utils.operation.IOperationRunner;
+import org.jmock.core.Constraint;
+
+public class WsDomObtainerTest extends MockObjectTestCase
+{
+ private static final String LOAD_CANCELLED_MSG = "Load_Cancelled";
+ private IOperationRunner operationRunner;
+ private WsDomObtainer domObtainer;
+ private Mock<IWsDOMRuntimeExtension> domRuntime;
+ private Mock<IDOM> dom;
+ private Mock<IWsDomCallback> domCallback;
+ private Mock<IExceptionHandler> excHandler;
+
+ private interface IExceptionHandler
+ {
+ public void handleException(final Exception e);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ setupOperationRunner();
+ domRuntime = mock(IWsDOMRuntimeExtension.class);
+ dom = mock(IDOM.class);
+ domObtainer = new WsDomObtainer(domRuntime.proxy(), operationRunner);
+ domCallback = mock(IWsDomCallback.class);
+ }
+
+ private void setupOperationRunner()
+ {
+ excHandler = mock(IExceptionHandler.class);
+ operationRunner = new IOperationRunner()
+ {
+ public void run(IRunnableWithProgress runnable)
+ {
+ try
+ {
+ runnable.run(new NullProgressMonitor());
+ }
+ catch (InvocationTargetException e)
+ {
+ excHandler.proxy().handleException(e);
+ }
+ catch (InterruptedException e)
+ {
+ excHandler.proxy().handleException(e);
+ }
+ }
+ };
+ }
+
+ public void testDomNotLoaded()
+ {
+ expectDomLoad();
+ performLoad();
+ }
+
+ public void testDomAlreadyLoaded()
+ {
+ expectDomAlreadyLoaded();
+ performLoad();
+ }
+
+ public void testCancelDomLoad()
+ {
+ expectCancelWhileLoading();
+ performLoad();
+ }
+
+ public void testDomLoadPreviouslyCancelled()
+ {
+ expectLoadCancelledPreviously();
+ performLoad();
+ }
+
+ public void testDomLoadFails()
+ {
+ expectLoadFails();
+ performLoad();
+ }
+
+ public void testDomLoadedPriorLoadOperationStarts()
+ {
+ expectDomLoadedPriorLoadOperation();
+ performLoad();
+ }
+
+ private void expectDomLoadedPriorLoadOperation()
+ {
+ domRuntime.expects(once()).method("getDOM").will(returnValue(null)).id("first_get");
+ domRuntime.stubs().method("getDOM").after("first_get").will(returnValue(dom.proxy()));
+
+ domCallback.expects(once()).method("dom").with(same(dom.proxy()));
+ }
+
+ private void expectLoadFails()
+ {
+ final IOException ioExc = new IOException("dom load failure");
+ domRuntime.stubs().method("getDOM").will(returnValue(null));
+ domRuntime.expects(once()).method("createDOM").with(isA(IProgressMonitor.class)).after("getDOM").will(throwException(ioExc));
+
+ domCallback.expects(once()).method("domLoadStarting").withNoArguments();
+ domCallback.expects(once()).method("domLoadFailed").after("domLoadStarting");
+
+ excHandler.expects(once()).method("handleException").with(invTargetExcMatcher(ioExc));
+
+ }
+
+ private Constraint invTargetExcMatcher(final Exception cause)
+ {
+ return new Constraint()
+ {
+
+ public StringBuffer describeTo(StringBuffer buffer)
+ {
+ buffer.append("unexpected exception");
+ return buffer;
+ }
+
+ public boolean eval(Object o)
+ {
+ if (!(o instanceof InvocationTargetException))
+ {
+ return false;
+ }
+ final InvocationTargetException invTargetE = (InvocationTargetException) o;
+ return invTargetE.getCause() == cause;
+ }
+ };
+ }
+
+ private void expectLoadCancelledPreviously()
+ {
+ domRuntime.stubs().method("getDOM").will(throwException(loadCancelledExc())).id("first_getDOM");
+ domRuntime.expects(once()).method("createDOM").with(isA(IProgressMonitor.class)).after("first_getDOM").isVoid();
+ domRuntime.stubs().method("getDOM").after("createDOM").will(returnValue(dom.proxy()));
+
+ domCallback.expects(once()).method("domLoadStarting").withNoArguments();
+ domCallback.expects(once()).method("dom").with(same(dom.proxy())).after("domLoadStarting");
+ }
+
+ private void expectCancelWhileLoading()
+ {
+ domRuntime.stubs().method("getDOM").will(returnValue(null));
+ domRuntime.expects(once()).method("createDOM").with(isA(IProgressMonitor.class)).after("getDOM").will(throwException(loadCancelledExc()));
+
+ domCallback.expects(once()).method("domLoadStarting").withNoArguments();
+ domCallback.expects(once()).method("domLoadCancelled");
+
+ excHandler.expects(once()).method("handleException").with(isA(InterruptedException.class));
+ }
+
+ private void expectDomLoad()
+ {
+ domRuntime.stubs().method("getDOM").will(returnValue(null));
+ domRuntime.expects(once()).method("createDOM").with(isA(IProgressMonitor.class)).after("getDOM").isVoid();
+ domRuntime.stubs().method("getDOM").after("createDOM").will(returnValue(dom.proxy()));
+
+ domCallback.expects(once()).method("domLoadStarting").withNoArguments();
+ domCallback.expects(once()).method("dom").with(same(dom.proxy())).after("domLoadStarting");
+ }
+
+ private void expectDomAlreadyLoaded()
+ {
+ domRuntime.stubs().method("getDOM").will(returnValue(dom.proxy()));
+ domCallback.expects(once()).method("dom").with(same(dom.proxy()));
+ }
+
+ private void performLoad()
+ {
+ domObtainer.getDom(domCallback.proxy());
+ }
+
+ private WsDOMLoadCanceledException loadCancelledExc()
+ {
+ return new WsDOMLoadCanceledException(LOAD_CANCELLED_MSG, LOAD_CANCELLED_MSG);
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.utils.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jst.ws.jaxws.utils.tests/META-INF/MANIFEST.MF
index bf20195..7d2eb5b 100755
--- a/tests/org.eclipse.jst.ws.jaxws.utils.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.jst.ws.jaxws.utils.tests/META-INF/MANIFEST.MF
@@ -13,7 +13,8 @@
org.eclipse.jst.ws.jaxws.testutils,
org.jmock,
org.junit,
- org.eclipse.ui.workbench
+ org.eclipse.ui.workbench,
+ org.eclipse.jface;bundle-version="3.6.2"
Export-Package: org.eclipse.jst.ws.jaxws.utils.resources,
org.eclipse.jst.ws.jaxws.utils.tests,
org.eclipse.jst.ws.jaxws.utils.tests.internal,
diff --git a/tests/org.eclipse.jst.ws.jaxws.utils.tests/src/org/eclipse/jst/ws/jaxws/utils/tests/AllTestsSuite.java b/tests/org.eclipse.jst.ws.jaxws.utils.tests/src/org/eclipse/jst/ws/jaxws/utils/tests/AllTestsSuite.java
index f8c1bfe..6af5a93 100755
--- a/tests/org.eclipse.jst.ws.jaxws.utils.tests/src/org/eclipse/jst/ws/jaxws/utils/tests/AllTestsSuite.java
+++ b/tests/org.eclipse.jst.ws.jaxws.utils.tests/src/org/eclipse/jst/ws/jaxws/utils/tests/AllTestsSuite.java
@@ -1,64 +1,66 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * 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:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.utils.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.jst.ws.jaxws.utils.resources.StringInputStreamAdapterTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.FileUtilsUnitTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.JaxWsUtilsTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationFactoryTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationInspectorImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationPropertyContainerTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationUtilsTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationsBaseImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.ArrayValueImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.BooleanValueImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.ClassValueImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.IntegerValueImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.ParamValuePairImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.QualifiedNameValueImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.StringValueImplTest;
-import org.eclipse.jst.ws.jaxws.utils.tests.internal.clazz.ASTUtilsTest;
-
-
-public class AllTestsSuite
-{
- /**
- * Returns a test suite containing the tests to be run by Java Developer Test Dispatcher
- *
- * @return - a suite of junit pde test
- */
- public static Test suite()
- {
- final TestSuite suite = new TestSuite();
-
- suite.addTestSuite(AnnotationFactoryTest.class);
- suite.addTestSuite(ArrayValueImplTest.class);
- suite.addTestSuite(AnnotationsBaseImplTest.class);
- suite.addTestSuite(AnnotationInspectorImplTest.class);
- suite.addTestSuite(AnnotationUtilsTest.class);
- suite.addTestSuite(BooleanValueImplTest.class);
- suite.addTestSuite(IntegerValueImplTest.class);
- suite.addTestSuite(ParamValuePairImplTest.class);
- suite.addTestSuite(QualifiedNameValueImplTest.class);
- suite.addTestSuite(StringValueImplTest.class);
- suite.addTestSuite(ClassValueImplTest.class);
- suite.addTestSuite(AnnotationPropertyContainerTest.class);
- suite.addTestSuite(ASTUtilsTest.class);
- suite.addTestSuite(FileUtilsUnitTest.class);
- suite.addTestSuite(JaxWsUtilsTest.class);
- suite.addTestSuite(StringInputStreamAdapterTest.class);
-
- return suite;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.utils.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jst.ws.jaxws.utils.resources.StringInputStreamAdapterTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.FileUtilsUnitTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.JaxWsUtilsTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationFactoryTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationInspectorImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationPropertyContainerTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationUtilsTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.AnnotationsBaseImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.ArrayValueImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.BooleanValueImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.ClassValueImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.IntegerValueImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.ParamValuePairImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.QualifiedNameValueImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.annotations.StringValueImplTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.clazz.ASTUtilsTest;
+import org.eclipse.jst.ws.jaxws.utils.tests.internal.operation.OperationInJobRunnerTest;
+
+
+public class AllTestsSuite
+{
+ /**
+ * Returns a test suite containing the tests to be run by Java Developer Test Dispatcher
+ *
+ * @return - a suite of junit pde test
+ */
+ public static Test suite()
+ {
+ final TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(AnnotationFactoryTest.class);
+ suite.addTestSuite(ArrayValueImplTest.class);
+ suite.addTestSuite(AnnotationsBaseImplTest.class);
+ suite.addTestSuite(AnnotationInspectorImplTest.class);
+ suite.addTestSuite(AnnotationUtilsTest.class);
+ suite.addTestSuite(BooleanValueImplTest.class);
+ suite.addTestSuite(IntegerValueImplTest.class);
+ suite.addTestSuite(ParamValuePairImplTest.class);
+ suite.addTestSuite(QualifiedNameValueImplTest.class);
+ suite.addTestSuite(StringValueImplTest.class);
+ suite.addTestSuite(ClassValueImplTest.class);
+ suite.addTestSuite(AnnotationPropertyContainerTest.class);
+ suite.addTestSuite(ASTUtilsTest.class);
+ suite.addTestSuite(FileUtilsUnitTest.class);
+ suite.addTestSuite(JaxWsUtilsTest.class);
+ suite.addTestSuite(StringInputStreamAdapterTest.class);
+ suite.addTestSuite(OperationInJobRunnerTest.class);
+
+ return suite;
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.utils.tests/src/org/eclipse/jst/ws/jaxws/utils/tests/internal/operation/OperationInJobRunnerTest.java b/tests/org.eclipse.jst.ws.jaxws.utils.tests/src/org/eclipse/jst/ws/jaxws/utils/tests/internal/operation/OperationInJobRunnerTest.java
new file mode 100644
index 0000000..0f6f0fa
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.utils.tests/src/org/eclipse/jst/ws/jaxws/utils/tests/internal/operation/OperationInJobRunnerTest.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.utils.tests.internal.operation;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jst.ws.jaxws.testutils.IWaitCondition;
+import org.eclipse.jst.ws.jaxws.testutils.assertions.Assertions;
+import org.eclipse.jst.ws.jaxws.testutils.assertions.ConditionCheckException;
+import org.eclipse.jst.ws.jaxws.utils.operation.OperationInJobRunner;
+
+public class OperationInJobRunnerTest extends TestCase
+{
+ private static final String TEST_JOB_NAME = "OperationInJobRunnerTestJob" + System.currentTimeMillis();
+ private OperationInJobRunner opRunner;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ opRunner = new OperationInJobRunner(TEST_JOB_NAME, null);
+ }
+
+ public void testOperationExecutedSuccessfully()
+ {
+ runOperation(new TestOperation(), IStatus.OK);
+ }
+
+ public void testOperationInterrupted()
+ {
+ runOperation(interruptedOperation(), IStatus.CANCEL);
+ }
+
+ public void testOperationFailed()
+ {
+ runOperation(failingOperation(), IStatus.ERROR);
+ }
+
+ private void runOperation(final TestOperation op, final int expectedExecutionStatusSeverity)
+ {
+ final IStatus status = runOperation(op);
+ assertOperationExecuted(op);
+ assertEquals("Unexpected job status severity", expectedExecutionStatusSeverity, status.getSeverity());
+ }
+
+ private TestOperation interruptedOperation()
+ {
+ return new TestOperation()
+ {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ super.run(monitor);
+ throw new InterruptedException();
+ }
+ };
+ }
+
+ private TestOperation failingOperation()
+ {
+ return new TestOperation()
+ {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ super.run(monitor);
+ throw new InvocationTargetException(new Exception());
+ }
+ };
+ }
+
+ private void assertOperationExecuted(final TestOperation op)
+ {
+ assertTrue("Operation not executed", op.isExecuted);
+ }
+
+ private IStatus runOperation(final IRunnableWithProgress runnable)
+ {
+ final IStatus[] jobStatus = new IStatus[1];
+ final IJobChangeListener jobListener = new TestJobChangeListener(jobStatus);
+ Job.getJobManager().addJobChangeListener(jobListener);
+ try
+ {
+ opRunner.run(runnable);
+ waitForStatus(jobStatus);
+ }
+ finally
+ {
+ Job.getJobManager().removeJobChangeListener(jobListener);
+ }
+ return jobStatus[0];
+ }
+
+ private void waitForStatus(final IStatus[] statusHolder)
+ {
+ Assertions.waitAssert(new IWaitCondition()
+ {
+
+ public boolean checkCondition() throws ConditionCheckException
+ {
+ return statusHolder[0] != null;
+ }
+ }, "test job did not finish");
+ }
+
+ private class TestOperation implements IRunnableWithProgress
+ {
+ public boolean isExecuted = false;
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ isExecuted = true;
+ }
+ }
+
+ private class TestJobChangeListener extends JobChangeAdapter
+ {
+ private IStatus[] statusHolder;
+
+ public TestJobChangeListener(final IStatus[] statusHolder)
+ {
+ this.statusHolder = statusHolder;
+ }
+
+ @Override
+ public void done(IJobChangeEvent event)
+ {
+ if (isTheTestJob(event))
+ {
+ statusHolder[0] = event.getResult();
+ }
+ }
+
+ private boolean isTheTestJob(final IJobChangeEvent event)
+ {
+ return event.getJob().getName() == TEST_JOB_NAME;
+ }
+ }
+}