Author: yradtsevich
Date: 2011-10-30 17:45:31 -0400 (Sun, 30 Oct 2011)
New Revision: 36082
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/PlatformUtil.java
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/META-INF/MANIFEST.MF
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/handlers/SampleHandler.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/WebKitBrowserFactory.java
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web
apps
- created a handler which invokes BrowserSim in a standalone JVM
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/META-INF/MANIFEST.MF 2011-10-29
00:42:49 UTC (rev 36081)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/META-INF/MANIFEST.MF 2011-10-30
21:45:31 UTC (rev 36082)
@@ -5,6 +5,7 @@
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.jboss.tools.browsersim.eclipse.Activator
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.jboss.tools.browsersim.webkit;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/handlers/SampleHandler.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/handlers/SampleHandler.java 2011-10-29
00:42:49 UTC (rev 36081)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/handlers/SampleHandler.java 2011-10-30
21:45:31 UTC (rev 36082)
@@ -5,14 +5,18 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.jboss.tools.browsersim.webkit.PlatformUtil;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
@@ -32,16 +36,37 @@
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
- System.out.println(new
URL(Platform.getBundle("org.eclipse.swt").getLocation()));
- } catch (IOException e) {
- // TODO Auto-generated catch block
+ String classPath = getBundleLocation("org.jboss.tools.browsersim") +
"bin/"
+ + ';' + getBundleLocation("org.jboss.tools.browsersim.webkit") +
"bin/"
+ + ';' + getBundleLocation("org.eclipse.swt")
+ + ';' + getBundleLocation("org.eclipse.swt." +
PlatformUtil.CURRENT_PLATFORM);
+ String javaCommand = System.getProperty("java.home") +
"/bin/java";
+
+ List<String> commandElements = new ArrayList<String>();
+ commandElements.add(javaCommand);
+ commandElements.add("-Dosgi.os=" + Platform.getOS());
+ commandElements.add("-Dosgi.arch=" + Platform.getOSArch());
+ if (Platform.getWS() != null) {
+ commandElements.add("-Dosgi.ws=" + Platform.getWS());
+ }
+ commandElements.add("-cp");
+ commandElements.add(classPath);
+ commandElements.add("org.jboss.tools.browsersim.BrowserSim");
+
+ Process child = Runtime.getRuntime().exec(commandElements.toArray(new String[0]));
+
+ } catch (Throwable e) {
e.printStackTrace();
}
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- MessageDialog.openInformation(
- window.getShell(),
- "BrowserSim Eclipse Plug-in",
- "Hello, Eclipse world");
+ //Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
return null;
}
+
+ private String getBundleLocation(String symbolicName) {
+ String locationId = Platform.getBundle(symbolicName).getLocation();
+ if (locationId.startsWith("reference:file:/")) {
+ return locationId.substring("reference:file:/".length());
+ }
+ return locationId;
+ }
}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/PlatformUtil.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/PlatformUtil.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/PlatformUtil.java 2011-10-30
21:45:31 UTC (rev 36082)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.browsersim.webkit;
+
+/**
+ * @author "Yahor Radtsevich (yradtsevich)"
+ */
+public class PlatformUtil {
+
+ public static final String CURRENT_PLATFORM;
+ static {
+ String ws = System.getProperty("osgi.ws");
+ System.out.println(ws);
+ ws = (ws == null) ? "" : ws;
+ String os = System.getProperty("osgi.os");
+ os = (os == null) ? "" : os;
+ String arch = System.getProperty("osgi.arch");
+ arch = (arch == null) ? "" : arch;
+
+ CURRENT_PLATFORM = ws + '.' + os + ("macosx".equals(os) ?
"" : '.' + arch);
+ }
+}
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/WebKitBrowserFactory.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/WebKitBrowserFactory.java 2011-10-29
00:42:49 UTC (rev 36081)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/WebKitBrowserFactory.java 2011-10-30
21:45:31 UTC (rev 36082)
@@ -20,28 +20,14 @@
* @author "Yahor Radtsevich (yradtsevich)"
*/
public class WebKitBrowserFactory {
- private static final String CURRENT_PLATFORM;
- static {
-
- String ws = System.getProperty("osgi.ws");
- System.out.println(ws);
- ws = (ws == null) ? "" : ws;
- String os = System.getProperty("osgi.os");
- os = (os == null) ? "" : os;
- String arch = System.getProperty("osgi.arch");
- arch = (arch == null) ? "" : arch;
-
- CURRENT_PLATFORM = ws + '.' + os + ("macosx".equals(os) ?
"" : '.' + arch);
- }
-
public static AbstractWebKitBrowser createWebKitBrowser(Composite parent, int style) {
- if (CURRENT_PLATFORM.equals("gtl.linux.x86")) {
+ if (PlatformUtil.CURRENT_PLATFORM.equals("gtk.linux.x86")) {
return new WebKitBrowser_gtk_linux_x86(parent, style);
- } else if (CURRENT_PLATFORM.equals("gtl.linux.x86_64")) {
+ } else if (PlatformUtil.CURRENT_PLATFORM.equals("gtk.linux.x86_64")) {
return new WebKitBrowser_gtk_linux_x86_64(parent, style);
- } else if (CURRENT_PLATFORM.equals("cocoa.macosx")) {
+ } else if (PlatformUtil.CURRENT_PLATFORM.equals("cocoa.macosx")) {
return new WebKitBrowser_webkit_cocoa_macos(parent, style);
- } else if (CURRENT_PLATFORM.equals("win32.win32.x86")) {
+ } else if (PlatformUtil.CURRENT_PLATFORM.equals("win32.win32.x86")) {
return new WebKitBrowser_win32_win32_x86(parent, style);
}