Author: Grid.Qian
Date: 2008-05-11 05:19:56 -0400 (Sun, 11 May 2008)
New Revision: 8036
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java
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/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:
JBIDE2047: modify for validating ws location
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties 2008-05-11
09:19:31 UTC (rev 8035)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCore.properties 2008-05-11
09:19:56 UTC (rev 8036)
@@ -4,4 +4,9 @@
DIR_WEB_INF=WEB-INF
DIR_WEB_CONTENT=WebContent
ERROR_COPY=Exception while copy JBossWS jars
-WS_LOCATION=jbosswsruntimelocation
\ No newline at end of file
+WS_LOCATION=jbosswsruntimelocation
+JBOSSWS_RUNTIME_LIB=JbossWSRuntimeLib
+JBOSSWS_RUNTIME=JBoss WS Runtime
+JBOSSAS=JBOSS
+ERROR_WS_LOCATION=The JBoss WS Runtime Location is NULL
+ERROR_WS_CLASSPATH=A error comes up when create JBoss WS Classpath
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java 2008-05-11
09:19:31 UTC (rev 8035)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCoreMessages.java 2008-05-11
09:19:56 UTC (rev 8036)
@@ -13,6 +13,9 @@
import org.eclipse.osgi.util.NLS;
+/**
+ * @author Grid Qian
+ */
public class JbossWSCoreMessages {
private static final String BUNDLE_NAME =
"org.jboss.tools.ws.core.JbossWSCore"; //$NON-NLS-1$
@@ -28,6 +31,11 @@
public static String DIR_WEB_CONTENT;
public static String ERROR_COPY;
public static String WS_LOCATION;
+ public static String JBOSSWS_RUNTIME_LIB;
+ public static String JBOSSWS_RUNTIME;
+ public static String JBOSSAS;
+ public static String ERROR_WS_LOCATION;
+ public static String ERROR_WS_CLASSPATH;
static {
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-05-11
09:19:31 UTC (rev 8035)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-05-11
09:19:56 UTC (rev 8036)
@@ -11,13 +11,15 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.jboss.tools.ws.core.JbossWSCoreMessages;
import org.jboss.tools.ws.core.utils.JbossWSCoreUtils;
+/**
+ * @author Grid Qian
+ */
public class JbossWSRuntimeClassPathInitializer extends
ClasspathContainerInitializer {
- public static final String ID = "JbossWSRuntimeLib";
-
public JbossWSRuntimeClassPathInitializer() {
}
@@ -25,20 +27,13 @@
public void initialize(IPath containerPath, IJavaProject project)
throws CoreException {
- if (containerPath.segment(0).equals(ID)) {
+ if (containerPath.segment(0).equals(
+ JbossWSCoreMessages.JBOSSWS_RUNTIME_LIB)) {
JbossWSRuntimeClasspathContainer container = new JbossWSRuntimeClasspathContainer(
containerPath);
- System.out.println(project.getElementName()+ " before
"+project.getRawClasspath().length);
- for(int i=0;i<project.getRawClasspath().length;i++){
- System.out.println(i+" classpath entry = " +
project.getRawClasspath()[i]);
- }
JavaCore.setClasspathContainer(containerPath,
- new IJavaProject[] {project},
- new IClasspathContainer[] {container}, null);
- System.out.println(project.getElementName()+" after
"+project.getRawClasspath().length);
- for(int i=0;i<project.getRawClasspath().length;i++){
- System.out.println(i+" classpath entry = " +
project.getRawClasspath()[i]);
- }
+ new IJavaProject[] { project },
+ new IClasspathContainer[] { container }, null);
}
}
@@ -56,7 +51,7 @@
}
public String getDescription() {
- return "JBoss WS Runtime";
+ return JbossWSCoreMessages.JBOSSWS_RUNTIME;
}
public int getKind() {
@@ -69,24 +64,21 @@
public IClasspathEntry[] getClasspathEntries() {
if (entries == null) {
- loadClasspathEntries();
+ ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
+ IPath wsPath = JbossWSCoreUtils.getJbossWSRuntimePath();
+ if (wsPath != null) {
+ IPath libPath = wsPath.append(JbossWSCoreMessages.DIR_LIB);
+ list.addAll(Arrays.asList(getEntries(libPath)));
+ libPath = wsPath.append(JbossWSCoreMessages.DIR_CLIENT);
+ list.addAll(Arrays.asList(getEntries(libPath)));
+ entries = list.toArray(new IClasspathEntry[list.size()]);
+ }
if (entries == null)
return new IClasspathEntry[0];
}
return entries;
}
- private void loadClasspathEntries() {
- ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- IPath libpath = JbossWSCoreUtils.getJbossLibPath();
- list.addAll(Arrays.asList(getEntries(libpath)));
- libpath = JbossWSCoreUtils.getJbossClientPath();
-
- list.addAll(Arrays.asList(getEntries(libpath)));
-
- entries = list.toArray(new IClasspathEntry[list.size()]);
- }
-
protected IClasspathEntry getEntry(IPath path) {
return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
.getClasspathEntry();
@@ -98,7 +90,10 @@
for (int i = 0; i < files.length; i++) {
if (files[i].endsWith(".jar")) {
list.add(getEntry(folder.append(files[i])));
- }//else if(new File(files[i] instanceof Folder)){}
+ } else if (folder.append(files[i]).toFile().isDirectory()) {
+ list.addAll(Arrays.asList(getEntries(folder
+ .append(files[i]))));
+ }
}
return list.toArray(new IClasspathEntry[list.size()]);
}
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-05-11
09:19:31 UTC (rev 8035)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-05-11
09:19:56 UTC (rev 8036)
@@ -16,10 +16,21 @@
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.AbstractDataModelOperation;
-import org.jboss.tools.ws.core.utils.JbossWSCoreUtils;
+import org.jboss.tools.ws.core.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+/**
+ * @author Grid Qian
+ */
public class JbossWSClassPathCommand extends AbstractDataModelOperation {
IProject project;
@@ -36,8 +47,54 @@
public IStatus executeOverride(IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
- JbossWSCoreUtils.addClassPath(project);
+ status = addClassPath(project);
return status;
}
+ public IStatus addClassPath(IProject project) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ IJavaProject javaProject = JavaCore.create(project);
+
+ IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path(
+ JbossWSCoreMessages.JBOSSWS_RUNTIME_LIB));
+
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (oldClasspathEntries[i].getPath().equals(
+ project.getFullPath())
+ || oldClasspathEntries[i].getPath().lastSegment()
+ .toUpperCase().contains(
+ JbossWSCoreMessages.JBOSSAS)) {
+ 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;
+ }
+
}
\ 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-11
09:19:31 UTC (rev 8035)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSRuntimeCommand.java 2008-05-11
09:19:56 UTC (rev 8036)
@@ -18,10 +18,15 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.jboss.tools.ws.core.JbossWSCoreMessages;
import org.jboss.tools.ws.core.utils.JbossWSCoreUtils;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+/**
+ * @author Grid Qian
+ */
public class JbossWSRuntimeCommand extends AbstractDataModelOperation {
IProject project;
@@ -40,14 +45,28 @@
IStatus status = Status.OK_STATUS;
// copy lib jars to project's folder
- IPath libPath = JbossWSCoreUtils.getJbossLibPath();
+ IPath wsPath = JbossWSCoreUtils.getJbossWSRuntimePath();
+ IPath libPath = null;
+ try {
+ libPath = wsPath.append(JbossWSCoreMessages.DIR_LIB);
+ } catch (Exception e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JbossWSCoreMessages.ERROR_WS_LOCATION, new String[] { e
+ .getLocalizedMessage() }), e);
+ return status;
+ }
IPath targetPath = JbossWSCoreUtils.pathToWebProjectContainer(project
.toString());
- targetPath = targetPath
- .append(JbossWSCoreMessages.DIR_WEB_INF).append(
- JbossWSCoreMessages.DIR_LIB);
+ targetPath = targetPath.append(JbossWSCoreMessages.DIR_WEB_INF).append(
+ JbossWSCoreMessages.DIR_LIB);
status = JbossWSCoreUtils.copy(libPath, targetPath);
-
+
+ if (status == Status.OK_STATUS) {
+ // copy client jars to project's folder
+ libPath = wsPath.append(JbossWSCoreMessages.DIR_CLIENT);
+ status = JbossWSCoreUtils.copy(libPath, 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-11
09:19:31 UTC (rev 8035)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-05-11
09:19:56 UTC (rev 8036)
@@ -19,6 +19,9 @@
import org.jboss.tools.ws.core.JbossWSCoreMessages;
import org.jboss.tools.ws.core.command.JbossWSClassPathCommand;
+/**
+ * @author Grid Qian
+ */
public class JbossWSInstallRuntimeDelegate implements IDelegate {
public void execute(IProject project, IProjectFacetVersion arg1, Object arg2,
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-11
09:19:31 UTC (rev 8035)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-05-11
09:19:56 UTC (rev 8036)
@@ -39,6 +39,9 @@
import org.jboss.tools.ws.core.JbossWSCoreMessages;
import org.jboss.tools.ws.core.JbossWSCorePlugin;
+/**
+ * @author Grid Qian
+ */
public class JbossWSCoreUtils {
public static IPath pathToWebProjectContainer(String project) {
@@ -217,83 +220,14 @@
return file;
}
}
-
- public static IStatus addClassPath(IProject project) {
- IStatus status = Status.OK_STATUS;
- try {
-
- IJavaProject javaProject = JavaCore.create(project);
-
- IClasspathEntry newClasspath = JavaCore
- .newContainerEntry(new Path("JbossWSRuntimeLib"));
-
- IClasspathEntry[] oldClasspathEntries = javaProject
- .readRawClasspath();
-
- 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(JbossWSCoreMessages.WS_LOCATION);
-
- if(runtimeLocation == null || runtimeLocation.equals("")){
-
- }
-
- IPath libPath = new Path(runtimeLocation);
- return libPath.append(JbossWSCoreMessages.DIR_LIB);
- }
- public static IPath getJbossClientPath() {
- IPreferenceStore ps = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- String runtimeLocation = ps.getString(JbossWSCoreMessages.WS_LOCATION);
-
- if(runtimeLocation == null || runtimeLocation.equals("")){
-
- }
-
- IPath libPath = new Path(runtimeLocation);
- return libPath.append(JbossWSCoreMessages.DIR_CLIENT);
- }
-
public static IPath getJbossWSRuntimePath() {
IPreferenceStore ps = JbossWSCorePlugin.getDefault()
.getPreferenceStore();
String runtimeLocation = ps.getString(JbossWSCoreMessages.WS_LOCATION);
if(runtimeLocation == null || runtimeLocation.equals("")){
-
+ return null;
}
return new Path(runtimeLocation);
}