[224382] getJarredPluginPath()
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java
index 7cffcd2..0c3bfc9 100644
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java
+++ b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jst.server.preview.adapter.internal.core;
+import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -54,23 +55,13 @@
}
protected static IPath getJarredPluginPath(Bundle bundle) {
- Path runtimeLibFullPath = null;
- String jarPluginLocation = bundle.getLocation().substring(7);
-
- // handle case where jars are installed outside of eclipse installation
- Path jarPluginPath = new Path(jarPluginLocation);
- if (jarPluginPath.isAbsolute())
- runtimeLibFullPath = jarPluginPath;
- // handle normal case where all plugins under eclipse install
- else {
- int ind = jarPluginLocation.lastIndexOf(":");
- if (ind > 0)
- jarPluginLocation = jarPluginLocation.substring(ind+1);
-
- String installPath = Platform.getInstallLocation().getURL().getPath();
- runtimeLibFullPath = new Path(installPath+"/"+jarPluginLocation);
+ try {
+ File file = FileLocator.getBundleFile(bundle);
+ return new Path(file.getCanonicalPath());
+ } catch (IOException e) {
+ // ignore, return null
+ return null;
}
- return runtimeLibFullPath;
}
protected String getVMInstallTypeId() {
@@ -82,13 +73,6 @@
}
/**
- * @see RuntimeDelegate#setDefaults(IProgressMonitor)
- */
- public void setDefaults(IProgressMonitor monitor) {
- getRuntimeWorkingCopy().setLocation(new Path(""));
- }
-
- /**
* Returns <code>true</code> if the runtime is using the default JRE.
*
* @return <code>true</code> if the runtime is using the default JRE,
@@ -119,6 +103,10 @@
* @see RuntimeDelegate#validate()
*/
public IStatus validate() {
+ IStatus status = super.validate();
+ if (!status.isOK() && status.getMessage().length() > 0)
+ return status;
+
if (getVMInstall() == null)
return new Status(IStatus.ERROR, PreviewPlugin.PLUGIN_ID, 0, Messages.errorJRE, null);
diff --git a/plugins/org.eclipse.wst.server.preview.adapter/src/org/eclipse/wst/server/preview/adapter/internal/core/PreviewRuntime.java b/plugins/org.eclipse.wst.server.preview.adapter/src/org/eclipse/wst/server/preview/adapter/internal/core/PreviewRuntime.java
index ba0f6f7..3fbec23 100644
--- a/plugins/org.eclipse.wst.server.preview.adapter/src/org/eclipse/wst/server/preview/adapter/internal/core/PreviewRuntime.java
+++ b/plugins/org.eclipse.wst.server.preview.adapter/src/org/eclipse/wst/server/preview/adapter/internal/core/PreviewRuntime.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
* 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.wst.server.preview.adapter.internal.core;
+import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -45,29 +46,20 @@
}
protected static IPath getJarredPluginPath(Bundle bundle) {
- Path runtimeLibFullPath = null;
- String jarPluginLocation = bundle.getLocation().substring(7);
-
- // handle case where jars are installed outside of eclipse installation
- Path jarPluginPath = new Path(jarPluginLocation);
- if (jarPluginPath.isAbsolute())
- runtimeLibFullPath = jarPluginPath;
- // handle normal case where all plugins under eclipse install
- else {
- int ind = jarPluginLocation.lastIndexOf(":");
- if (ind > 0)
- jarPluginLocation = jarPluginLocation.substring(ind+1);
-
- String installPath = Platform.getInstallLocation().getURL().getPath();
- runtimeLibFullPath = new Path(installPath+"/"+jarPluginLocation);
+ try {
+ File file = FileLocator.getBundleFile(bundle);
+ return new Path(file.getCanonicalPath());
+ } catch (IOException e) {
+ // ignore, return null
+ return null;
}
- return runtimeLibFullPath;
}
- /**
- * @see RuntimeDelegate#setDefaults(IProgressMonitor)
- */
- public void setDefaults(IProgressMonitor monitor) {
- getRuntimeWorkingCopy().setLocation(new Path(""));
+ public IStatus validate() {
+ IStatus status = super.validate();
+ if (!status.isOK() && status.getMessage().length() > 0)
+ return status;
+
+ return Status.OK_STATUS;
}
}
\ No newline at end of file