public static void launchBrowserSim(String initialUrl) { Activator.getDefault().countLaunchEvent(); List<String> parameters = new ArrayList<String>(); parameters.add(NOT_STANDALONE); if (initialUrl != null) { parameters.add(initialUrl); } IVMInstall jvm = getSelectedVM(); if (jvm == null) { // no suitable vm ExternalProcessLauncher.showErrorDialog(Messages.BrowserSim); } else { String jvmPath = jvm.getInstallLocation().getAbsolutePath(); String jrePath = jvm.getInstallLocation().getAbsolutePath() + File.separator + "jre"; // $NON-NLS-1$ List<String> bundles = getBundles(); if (!ExternalProcessLauncher.isGTK2() || (!BrowserSimUtil.isJavaFxAvailable(jvmPath) && !BrowserSimUtil.isJavaFxAvailable(jrePath))) { bundles.add("org.jboss.tools.vpe.browsersim.javafx.mock"); // $NON-NLS-1$ } ExternalProcessLauncher.launchAsExternalProcess( bundles, RESOURCES_BUNDLES, BROWSERSIM_CALLBACKS, BROWSERSIM_CLASS_NAME, parameters, Messages.BrowserSim, jvm); } }
public static IVMInstall getSelectedVM() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); IVMInstall jvm = null; if (IPreferenceStore.FALSE.equals( store.getString(BrowserSimPreferencesPage.BROWSERSIM_JVM_AUTOMATICALLY))) { // path to browserSim jvm is located in preferences String jvmId = store.getString(BrowserSimPreferencesPage.BROWSERSIM_JVM_ID); jvm = PreferencesUtil.getJVM(jvmId); } else { // detect jvm automatically List<IVMInstall> jvms = PreferencesUtil.getSuitableJvms(1); if (!jvms.isEmpty()) { jvm = jvms.get(0); } } return jvm; }