Author: Grid.Qian
Date: 2008-06-16 06:41:47 -0400 (Mon, 16 Jun 2008)
New Revision: 8779
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
Log:
JBIDE-2047: add uninstall command for jbossws facet
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml 2008-06-16 10:41:32 UTC (rev
8778)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml 2008-06-16 10:41:47 UTC (rev
8779)
@@ -25,32 +25,16 @@
class="org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider">
</config-factory>
</action>
-<!--
- <action type="UNINSTALL">
- <delegate
class="org.eclipse.jst.ws.axis2.facet.deligate.Axis2CoreFacetUnInstallDelegate"/>
- </action>
--->
+ <action
+ facet="jbossws.core"
+ id="jbossws.core.uninstall"
+ type="UNINSTALL">
+ <delegate
+
class="org.jboss.tools.ws.core.facet.delegate.JbossWSUnInstallRuntimeDelegate">
+ </delegate>
+ </action>
+
</project-facet-version>
-<!--
- <project-facet id="axis2.ext">
- <label>%JBOSSWS_FACET_EXT_LABEL</label>
- <description>%JBOSSWS_FACET_EXT_DISCRIPTION</description>
- <member category="axis2.category" />
- </project-facet>
-
- <project-facet-version facet="axis2.ext" version="1.1">
- <constraint>
- <requires facet="axis2.core" version="1.1"/>
- </constraint>
- <action type="INSTALL">
- <delegate
class="org.eclipse.jst.ws.axis2.facet.deligate.Axis2ExtFacetInstallDelegate"/>
- </action>
-
- <action type="UNINSTALL">
- <delegate
class="org.eclipse.jst.ws.axis2.facet.deligate.Axis2ExtFacetUnInstallDelegate"/>
- </action>
- </project-facet-version>
--->
</extension>
<extension
point="org.eclipse.wst.common.project.facet.core.runtimes">
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-16
10:41:32 UTC (rev 8778)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-16
10:41:47 UTC (rev 8779)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.ws.core.classpath;
import java.util.ArrayList;
@@ -70,31 +81,32 @@
ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
.findRuntimeByName(segment);
- if (jbws.isUserConfigClasspath()) {
- for (String jar : jbws.getLibraries()) {
- entryList.add(getEntry(new Path(jar)));
- }
- entries = entryList.toArray(new IClasspathEntry[entryList
- .size()]);
- } else {
- IPath wsPath = null;
- if (jbws != null) {
- wsPath = new Path(jbws.getHomeDir());
- }
- if (wsPath != null) {
- IPath libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Lib);
- entryList.addAll(Arrays.asList(getEntries(libPath,
- entryList)));
- libPath = wsPath.append(JbossWSCoreMessages.Dir_Client);
- entryList.addAll(Arrays.asList(getEntries(libPath,
- entryList)));
+ if (jbws != null) {
+ if (jbws.isUserConfigClasspath()) {
+ for (String jar : jbws.getLibraries()) {
+ entryList.add(getEntry(new Path(jar)));
+ }
entries = entryList
.toArray(new IClasspathEntry[entryList.size()]);
+ } else {
+ IPath wsPath = new Path(jbws.getHomeDir());
+ if (wsPath != null) {
+ IPath libPath = wsPath
+ .append(JbossWSCoreMessages.Dir_Lib);
+ entryList.addAll(Arrays.asList(getEntries(libPath,
+ entryList)));
+ libPath = wsPath
+ .append(JbossWSCoreMessages.Dir_Client);
+ entryList.addAll(Arrays.asList(getEntries(libPath,
+ entryList)));
+ entries = entryList
+ .toArray(new IClasspathEntry[entryList
+ .size()]);
+ }
}
+ if (entries == null)
+ return new IClasspathEntry[0];
}
- if (entries == null)
- return new IClasspathEntry[0];
}
return entries;
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-06-16
10:41:32 UTC (rev 8778)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-06-16
10:41:47 UTC (rev 8779)
@@ -64,7 +64,7 @@
IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED);
} else {
// store runtime name and runtime location to the project
-
+
String runtimeName = model
.getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID);
String runtimeLocation = model
@@ -121,10 +121,7 @@
for (int i = 0; i < oldClasspathEntries.length
&& !isFolderInClassPathAlready; i++) {
if (oldClasspathEntries[i].getPath().equals(
- project.getFullPath())
- || oldClasspathEntries[i].getPath().lastSegment()
- .toUpperCase().contains(
- JbossWSCoreMessages.JBossAS)) {
+ newClasspath.getPath())) {
isFolderInClassPathAlready = true;
break;
}
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java 2008-06-16
10:41:47 UTC (rev 8779)
@@ -0,0 +1,102 @@
+package org.jboss.tools.ws.core.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+
+public class UninstallJbossWSClassPathCommand {
+ IProject project;
+
+ public UninstallJbossWSClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ boolean isServerSupplied = Boolean
+ .getBoolean(project
+ .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME));
+ if (isServerSupplied) {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
+ } else {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
+ String runtimeName = project
+ .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+
+ status = removeClassPath(project, runtimeName);
+ }
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JbossWSCoreMessages.Error_Remove_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus removeClassPath(IProject project, String segment) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ List<IClasspathEntry> classpathEntries = new
ArrayList<IClasspathEntry>();
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (!oldClasspathEntries[i].getPath().equals(
+ new Path(JbossWSCoreMessages.JBossWS_Runtime_Lib)
+ .append(segment))) {
+ classpathEntries.add(oldClasspathEntries[i]);
+ }
+ }
+ if (classpathEntries.size() < oldClasspathEntries.length) {
+ javaProject.setRawClasspath(classpathEntries
+ .toArray(new IClasspathEntry[classpathEntries.size()]),
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JbossWSCoreMessages.Error_Remove_Facet_JBossWS,
+ new String[] { e.getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-06-16
10:41:32 UTC (rev 8778)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-06-16
10:41:47 UTC (rev 8779)
@@ -7,13 +7,15 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.ws.core.facet.delegate;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -25,16 +27,20 @@
*/
public class JbossWSInstallRuntimeDelegate implements IDelegate {
- public void execute(IProject project, IProjectFacetVersion arg1, Object arg2,
- IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(JbossWSCoreMessages.Progress_Install_JBossWS_Runtime, 2 );
+ public void execute(IProject project, IProjectFacetVersion arg1,
+ Object arg2, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(JbossWSCoreMessages.Progress_Install_JBossWS_Runtime,
+ 2);
- IDataModel model = (IDataModel)arg2;
-
-
- JbossWSClassPathCommand command = new JbossWSClassPathCommand(project, model);
- command.executeOverride(monitor);
- monitor.worked( 1 );
+ IDataModel model = (IDataModel) arg2;
+
+ JbossWSClassPathCommand command = new JbossWSClassPathCommand(project,
+ model);
+ IStatus status = command.executeOverride(monitor);
+ if(!status.equals(Status.OK_STATUS)){
+ throw new CoreException(status);
+ }
+ monitor.worked(1);
monitor.done();
}
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java 2008-06-16
10:41:47 UTC (rev 8779)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.facet.delegate;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.ws.core.command.UninstallJbossWSClassPathCommand;
+import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JbossWSUnInstallRuntimeDelegate implements IDelegate {
+
+ public void execute(IProject project, IProjectFacetVersion arg1,
+ Object arg2, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(
+ JbossWSCoreMessages.Progress_UnInstall_JBossWS_Runtime, 2);
+
+ IDataModel model = (IDataModel) arg2;
+
+ UninstallJbossWSClassPathCommand command = new UninstallJbossWSClassPathCommand(
+ project, model);
+ command.executeOverride(monitor);
+ monitor.worked(1);
+ monitor.done();
+ }
+
+}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties 2008-06-16
10:41:32 UTC (rev 8778)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties 2008-06-16
10:41:47 UTC (rev 8779)
@@ -1,4 +1,5 @@
Progress_Install_JBossWS_Runtime=JBoss Web Service Runtime
+Progress_UnInstall_JBossWS_Runtime=Uninstall JBoss Web Service Runtime
Dir_Lib=lib
Dir_Client=client
Dir_Web_Inf=WEB-INF
@@ -11,3 +12,4 @@
Error_WS_Location=The JBoss WS Runtime Location is NULL
Error_WS_Classpath=A error comes up when create JBoss WS Classpath
Error_Add_Facet_JBossWS=Exception while install JBossWS facet
+Error_Remove_Facet_JBossWS=Exception while uninstall JBossWS facet
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java 2008-06-16
10:41:32 UTC (rev 8778)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java 2008-06-16
10:41:47 UTC (rev 8779)
@@ -25,6 +25,7 @@
}
public static String Progress_Install_JBossWS_Runtime;
+ public static String Progress_UnInstall_JBossWS_Runtime;
public static String Dir_Lib;
public static String Dir_Client;
public static String Dir_Web_Inf;
@@ -37,6 +38,7 @@
public static String Error_WS_Location;
public static String Error_WS_Classpath;
public static String Error_Add_Facet_JBossWS;
+ public static String Error_Remove_Facet_JBossWS;
static {