Author: Grid.Qian
Date: 2008-05-05 06:47:37 -0400 (Mon, 05 May 2008)
New Revision: 7977
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.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/utils/JbossWSCoreUtils.java
Log:
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-05-05 09:28:52 UTC
(rev 7976)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-05-05 10:47:37 UTC
(rev 7977)
@@ -10,7 +10,8 @@
org.eclipse.wst.common.project.facet.core,
org.eclipse.wst.common.frameworks,
org.eclipse.core.resources,
- org.eclipse.jst.ws
+ org.eclipse.jst.ws,
+ org.eclipse.jdt.core
Eclipse-LazyStart: true
Bundle-Vendor: %PLUGIN_PROVIDER
Export-Package: org.jboss.tools.ws.core,
Added:
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
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-05-05
10:47:37 UTC (rev 7977)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.command;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.jboss.tools.ws.core.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.JbossWSCorePlugin;
+import org.jboss.tools.ws.core.utils.JbossWSCoreUtils;
+
+public class JbossWSClassPathCommand extends AbstractDataModelOperation {
+
+ IProject project;
+ String runtimeLocation;
+
+ public JbossWSClassPathCommand(IProject project) {
+ 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;
+ JbossWSCoreUtils.addClassPath(project);
+ return status;
+ }
+
+}
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java 2008-05-05
09:28:52 UTC (rev 7976)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java 2008-05-05
10:47:37 UTC (rev 7977)
@@ -42,14 +42,8 @@
public IStatus executeOverride(IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
- IPreferenceStore ps = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- runtimeLocation = ps.getString("jbosswsruntimelocation");
-
// copy lib jars to project's folder
- IPath libPath = new Path(runtimeLocation);
- libPath = libPath.append(JbossWSCoreMessages.DIR_LIB);
-
+ IPath libPath = JbossWSCoreUtils.getJbossLibPath();
IPath targetPath = JbossWSCoreUtils.pathToWebProjectContainer(project
.toString());
targetPath = targetPath
@@ -57,11 +51,6 @@
JbossWSCoreMessages.DIR_LIB);
status = JbossWSCoreUtils.copy(libPath, targetPath);
-// // copy lib jars to project's folder
-// IPath clientPath = new Path(runtimeLocation);
-// clientPath = clientPath.append(JbossWSCoreMessages.DIR_CLIENT);
-// JbossWSCoreUtils.copy(clientPath,targetPath);
-
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-05-05
09:28:52 UTC (rev 7976)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-05-05
10:47:37 UTC (rev 7977)
@@ -17,7 +17,7 @@
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.jboss.tools.ws.core.JbossWSCoreMessages;
-import org.jboss.tools.ws.core.command.JbossWSRuntimeCommand;
+import org.jboss.tools.ws.core.command.JbossWSClassPathCommand;
public class JbossWSInstallRuntimeDelegate implements IDelegate {
@@ -25,7 +25,7 @@
IProgressMonitor monitor) throws CoreException {
monitor.beginTask(JbossWSCoreMessages.PROGRESS_INSTALL_JBOSSWS_RUNTIME, 2 );
- JbossWSRuntimeCommand command = new JbossWSRuntimeCommand(project);
+ JbossWSClassPathCommand command = new JbossWSClassPathCommand(project);
command.executeOverride(monitor);
monitor.worked( 1 );
monitor.done();
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-05-05
09:28:52 UTC (rev 7976)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-05-05
10:47:37 UTC (rev 7977)
@@ -26,11 +26,18 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
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.jface.preference.IPreferenceStore;
import org.eclipse.jst.ws.internal.common.J2EEUtils;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.ws.core.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.JbossWSCorePlugin;
public class JbossWSCoreUtils {
@@ -122,26 +129,29 @@
try {
finStream = new FileInputStream(children[i]);
} catch (FileNotFoundException e) {
- status = StatusUtils.errorStatus(
- NLS.bind(JbossWSCoreMessages.ERROR_COPY,
- new String[]{e.getLocalizedMessage()}), e);
+ status = StatusUtils.errorStatus(NLS.bind(
+ JbossWSCoreMessages.ERROR_COPY, new String[] { e
+ .getLocalizedMessage() }), e);
}
try {
makeFile(getWorkspaceRoot().getContainerForLocation(
targetPath), children[i].getName(), finStream);
} catch (CoreException e) {
- status = StatusUtils.errorStatus(
- NLS.bind(JbossWSCoreMessages.ERROR_COPY,
- new String[]{e.getLocalizedMessage()}), e);
+ status = StatusUtils.errorStatus(NLS.bind(
+ JbossWSCoreMessages.ERROR_COPY, new String[] { e
+ .getLocalizedMessage() }), e);
}
} else {
try {
- IFolder temp = makeFolder(getWorkspaceRoot().getContainerForLocation(targetPath),
children[i].getName());
- copy(sourcePath.append(children[i].getName()), temp.getLocation());
+ IFolder temp = makeFolder(getWorkspaceRoot()
+ .getContainerForLocation(targetPath), children[i]
+ .getName());
+ copy(sourcePath.append(children[i].getName()), temp
+ .getLocation());
} catch (CoreException e) {
- status = StatusUtils.errorStatus(
- NLS.bind(JbossWSCoreMessages.ERROR_COPY,
- new String[]{e.getLocalizedMessage()}), e);
+ status = StatusUtils.errorStatus(NLS.bind(
+ JbossWSCoreMessages.ERROR_COPY, new String[] { e
+ .getLocalizedMessage() }), e);
}
}
}
@@ -208,4 +218,55 @@
}
}
+ public static IStatus addClassPath(IProject project) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry newClasspath = JavaCore
+ .newContainerEntry(getJbossLibPath());
+
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .getRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (oldClasspathEntries[i].getPath().equals(
+ project.getFullPath())) {
+ isFolderInClassPathAlready = true;
+ break;
+ }
+ }
+
+ if (!isFolderInClassPathAlready) {
+
+ IClasspathEntry[] newClasspathEntries = new
IClasspathEntry[oldClasspathEntries.length + 1];
+ for (int i = 0; i < oldClasspathEntries.length; i++) {
+ newClasspathEntries[i] = oldClasspathEntries[i];
+ }
+ newClasspathEntries[oldClasspathEntries.length] = newClasspath;
+
+ javaProject.setRawClasspath(newClasspathEntries,
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JbossWSCoreMessages.ERROR_COPY, new String[] { e
+ .getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+ public static IPath getJbossLibPath() {
+ IPreferenceStore ps = JbossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+ String runtimeLocation = ps.getString("jbosswsruntimelocation");
+
+ IPath libPath = new Path(runtimeLocation);
+ return libPath.append(JbossWSCoreMessages.DIR_LIB);
+ }
+
}