[jbosstools-commits] JBoss Tools SVN: r41249 - trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/src/org/jboss/tools/vpe/browsersim/eclipse/util.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue May 22 08:13:11 EDT 2012
Author: yradtsevich
Date: 2012-05-22 08:13:10 -0400 (Tue, 22 May 2012)
New Revision: 41249
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/src/org/jboss/tools/vpe/browsersim/eclipse/util/BrowserSimLauncher.java
Log:
https://issues.jboss.org/browse/JBIDE-11923 : BrowserSim cannot start on Ubuntu with Eclipse 3.7.2 installed by package manager
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/src/org/jboss/tools/vpe/browsersim/eclipse/util/BrowserSimLauncher.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/src/org/jboss/tools/vpe/browsersim/eclipse/util/BrowserSimLauncher.java 2012-05-22 12:04:53 UTC (rev 41248)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/src/org/jboss/tools/vpe/browsersim/eclipse/util/BrowserSimLauncher.java 2012-05-22 12:13:10 UTC (rev 41249)
@@ -15,12 +15,14 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
-import org.jboss.tools.vpe.browsersim.browser.PlatformUtil;
+import org.eclipse.osgi.framework.internal.core.BundleFragment;
+import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.jboss.tools.vpe.browsersim.eclipse.Activator;
import org.jboss.tools.vpe.browsersim.eclipse.callbacks.BrowserSimCallback;
import org.jboss.tools.vpe.browsersim.eclipse.callbacks.OpenFileCallback;
@@ -30,17 +32,19 @@
/**
* @author "Yahor Radtsevich (yradtsevich)"
*/
+ at SuppressWarnings("restriction")
public class BrowserSimLauncher {
public static final String BROWSERSIM_CLASS_NAME = "org.jboss.tools.vpe.browsersim.ui.BrowserSim"; //$NON-NLS-1$
- private static final BrowserSimCallback[] BROWSERSIM_CALLBACKS = { new ViewSourceCallback(), new OpenFileCallback() };
+ private static final BrowserSimCallback[] BROWSERSIM_CALLBACKS = { new ViewSourceCallback(), new OpenFileCallback() };
+ private static final String[] REQUIRED_PLUGINS = {
+ "org.jboss.tools.vpe.browsersim",
+ "org.jboss.tools.vpe.browsersim.browser",
+ "org.eclipse.swt"};
public static void launchBrowserSim(String initialUrl) {
- String pathSeparator = System.getProperty("path.separator"); //$NON-NLS-1$
try {
- String classPath = getBundleLocation("org.jboss.tools.vpe.browsersim") //$NON-NLS-1$
- + pathSeparator + getBundleLocation("org.jboss.tools.vpe.browsersim.browser") //$NON-NLS-1$
- + pathSeparator + getBundleLocation("org.eclipse.swt") //$NON-NLS-1$
- + pathSeparator + getBundleLocation("org.eclipse.swt." + PlatformUtil.CURRENT_PLATFORM); //$NON-NLS-1$
+
+ String classPath = getClassPathString();
String javaCommand = System.getProperty("java.home") + "/bin/java"; //$NON-NLS-1$ //$NON-NLS-2$
List<String> commandElements = new ArrayList<String>();
@@ -99,13 +103,47 @@
Activator.logError(e.getMessage(), e);
}
}
+
+ private static String getClassPathString() throws IOException {
+ List<Bundle> classPathBundles = new ArrayList<Bundle>();
+ for (String requiredPlugin : REQUIRED_PLUGINS) {
+ classPathBundles.addAll(getBundleAndFragments(requiredPlugin));
+ }
+
+ String pathSeparator = System.getProperty("path.separator"); //$NON-NLS-1$
+ StringBuilder classPath = new StringBuilder();
+ if (classPathBundles.size() > 0) {
+ for (int i = 0; i < classPathBundles.size() - 1; i++) {
+ classPath.append(getBundleLocation(classPathBundles.get(i)));
+ classPath.append(pathSeparator);
+ }
+ classPath.append(getBundleLocation(classPathBundles.get(classPathBundles.size() - 1)));
+ }
+
+ return classPath.toString();
+ }
- private static String getBundleLocation(String symbolicName) throws IOException {
+ private static List<Bundle> getBundleAndFragments(String symbolicName) throws IOException {
+ List<Bundle> bundles = new ArrayList<Bundle>();
Bundle bundle = Platform.getBundle(symbolicName);
+
if (bundle == null) {
throw new IOException("Cannot find bundle: " + symbolicName);
}
+ bundles.add(bundle);
+
+ if (bundle instanceof BundleHost) {
+ BundleFragment[] fragments = ((BundleHost) bundle).getFragments();
+ if (fragments != null) {
+ Collections.addAll(bundles, fragments);
+ }
+ }
+
+ return bundles;
+ }
+
+ private static String getBundleLocation(Bundle bundle) throws IOException {
try {
File bundleLocation = FileLocator.getBundleFile(bundle);
@@ -118,7 +156,7 @@
return bundleLocation.getCanonicalPath();
} catch (IOException e) {
- throw new IOException("Cannot resolve the path to bundle: " + symbolicName, e);
+ throw new IOException("Cannot resolve the path to bundle: " + bundle.getSymbolicName(), e);
}
}
}
More information about the jbosstools-commits
mailing list