Author: yradtsevich
Date: 2011-10-20 13:25:03 -0400 (Thu, 20 Oct 2011)
New Revision: 35854
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.classpath
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.project
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.jdt.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.pde.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/META-INF/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/META-INF/MANIFEST.MF
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/build.properties
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/browsersim/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/browsersim/webkit/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.classpath
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.project
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.jdt.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.pde.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/META-INF/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/META-INF/MANIFEST.MF
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/build.properties
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/browsersim/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/browsersim/webkit/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.classpath
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.project
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.jdt.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.pde.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/META-INF/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/META-INF/MANIFEST.MF
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/build.properties
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/AbstractWebKitBrowser.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.classpath
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.project
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.jdt.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.pde.core.prefs
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/build.properties
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_backward.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_forward.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_go.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_home.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_print.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_refresh.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_stop.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/synced.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Activator.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/IWebViewProxy.java
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web
apps
- initial commit: SWT and WebKit-based Browsersim application
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim
___________________________________________________________________
Added: svn:ignore
+ bin
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.classpath
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.classpath
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.classpath 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.project
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.project
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.project 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.browsersim</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.jdt.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,8 @@
+#Fri Oct 14 17:25:22 EEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.pde.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.pde.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/.settings/org.eclipse.pde.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+#Fri Oct 14 17:25:23 EEST 2011
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: BrowserSim
+Bundle-SymbolicName: org.jboss.tools.browsersim
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.browsersim.Activator
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.eclipse.swt;bundle-version="3.7.0",
+ org.jboss.tools.browsersim.webkit;bundle-version="1.0.0"
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/build.properties
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/build.properties
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/build.properties 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_backward.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_backward.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_forward.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_forward.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_go.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_go.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_home.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_home.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_print.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_print.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_refresh.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_refresh.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_stop.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_stop.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/synced.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/synced.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Activator.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Activator.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Activator.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class Activator implements BundleActivator {
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ new BrowserSim().run();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,314 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.browser.LocationListener;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.ProgressListener;
+import org.eclipse.swt.browser.StatusTextEvent;
+import org.eclipse.swt.browser.StatusTextListener;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.jboss.tools.browsersim.webkit.WebKitBrowser;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class BrowserSim implements Runnable {
+ private WebKitBrowser browser;
+ private Display display;
+ private Shell shell;
+ private Text locationText;
+ private Label statusLabel;
+ private ProgressBar progressBar;
+ private List<MenuItem> deviceMenuItems = new ArrayList<MenuItem>();
+
+ public static void main(String[] args) {
+ new BrowserSim().run();
+ }
+
+ @Override
+ public void run() {
+ display = new Display();
+ shell = new Shell(display);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 3;
+ shell.setLayout(gridLayout);
+ Menu appMenuBar = display.getMenuBar();
+ if (appMenuBar == null) {
+ appMenuBar = new Menu(shell, SWT.BAR);
+ shell.setMenuBar(appMenuBar);
+ }
+
+ ToolBar toolbar = createControlBar();
+ GridData data = new GridData();
+ data.horizontalSpan = 3;
+ toolbar.setLayoutData(data);
+
+ Label labelAddress = new Label(shell, SWT.NONE);
+ labelAddress.setText("Address");
+
+ locationText = new Text(shell, SWT.BORDER);
+ data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.horizontalSpan = 2;
+ data.grabExcessHorizontalSpace = true;
+ data.widthHint = 0;
+ locationText.setLayoutData(data);
+
+ try {
+ browser = new WebKitBrowser(shell, SWT.NONE);
+ } catch (SWTError e) {
+ System.out.println("Could not instantiate Browser: " + e.getMessage());
+ display.dispose();
+ return;
+ }
+
+ data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalSpan = 3;
+ data.grabExcessHorizontalSpace = true;
+ data.grabExcessVerticalSpace = true;
+ browser.setLayoutData(data);
+
+ statusLabel = new Label(shell, SWT.NONE);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ data.widthHint = 0;
+ statusLabel.setLayoutData(data);
+
+ progressBar = new ProgressBar(shell, SWT.NONE);
+ data = new GridData();
+ data.horizontalAlignment = GridData.END;
+ progressBar.setLayoutData(data);
+
+ browser.addProgressListener(new ProgressListener() {
+ public void changed(ProgressEvent event) {
+ if (event.total == 0) return;
+ int ratio = event.current * 100 / event.total;
+ progressBar.setSelection(ratio);
+ }
+ public void completed(ProgressEvent event) {
+ progressBar.setSelection(0);
+ }
+ });
+ browser.addStatusTextListener(new StatusTextListener() {
+ public void changed(StatusTextEvent event) {
+ statusLabel.setText(event.text);
+ }
+ });
+ browser.addLocationListener(new LocationListener() {
+ public void changed(LocationEvent event) {
+ if (event.top) locationText.setText(event.location);
+ }
+ public void changing(LocationEvent event) {
+ }
+ });
+
+ fillMenuBar(appMenuBar);
+
+ locationText.addListener(SWT.DefaultSelection, new Listener() {
+ public void handleEvent(Event e) {
+ browser.setUrl(locationText.getText());
+ }
+ });
+
+ if (!DevicesManager.getInstance().getDevices().isEmpty()) {
+ setDevice(DevicesManager.getInstance().getDevices().get(0));
+ }
+ shell.open();
+ browser.setUrl("file:///C:/doc/prj/JavaScript/user-agent.html");
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ public ToolBar createControlBar() {
+ ToolBar toolbar = new ToolBar(shell, SWT.NONE);
+ ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
+// itemBack.setText("Back");
+ itemBack.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.back();
+ }
+ });
+
+ ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
+// itemForward.setText("Forward");
+ itemForward.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.forward();
+ }
+ });
+
+ ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
+// itemStop.setText("Stop");
+ itemStop.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.stop();
+ }
+ });
+
+ ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
+// itemRefresh.setText("Refresh");
+ itemRefresh.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.refresh();
+ }
+ });
+
+ ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
+// itemGo.setText("Go");
+ itemGo.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.setUrl(locationText.getText());
+ }
+ });
+
+ final Image imageBack = new Image(display,
getResourceAsStream("/resources/icons/nav_backward.gif"));
+ final Image imageForward = new Image(display,
getResourceAsStream("/resources/icons/nav_forward.gif"));
+ final Image imageStop = new Image(display,
getResourceAsStream("/resources/icons/nav_stop.gif"));
+ final Image imageRefresh = new Image(display,
getResourceAsStream("/resources/icons/nav_refresh.gif"));
+ final Image imageGo = new Image(display,
getResourceAsStream("/resources/icons/nav_go.gif"));
+
+ itemBack.setImage(imageBack);
+ itemForward.setImage(imageForward);
+ itemStop.setImage(imageStop);
+ itemRefresh.setImage(imageRefresh);
+ itemGo.setImage(imageGo);
+ shell.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ imageBack.dispose();
+ imageForward.dispose();
+ imageStop.dispose();
+ imageRefresh.dispose();
+ imageGo.dispose();
+ }
+ });
+
+ itemForward.setImage(imageForward);
+
+
+ return toolbar;
+ }
+
+ private InputStream getResourceAsStream(String name) {
+ return this.getClass().getResourceAsStream(name);
+ }
+
+ public void fillMenuBar(Menu appMenuBar) {
+ Menu file = createDropDownMenu(appMenuBar, "File");
+ MenuItem exit = new MenuItem(file, SWT.PUSH);
+ exit.setText("Exit");
+ exit.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ display.dispose();
+ };
+ });
+
+ Menu devicesMenu = createDropDownMenu(appMenuBar, "Devices");
+ for (Device device : DevicesManager.getInstance().getDevices()) {
+ MenuItem deviceMenuItem = new MenuItem(devicesMenu, SWT.RADIO);
+ deviceMenuItem.setText(device.getName());
+ deviceMenuItem.setData(device);
+ deviceMenuItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ MenuItem menuItem = (MenuItem)e.widget;
+ if (menuItem.getSelection()) {
+ setDevice((Device) menuItem.getData());
+ }
+ };
+ });
+
+ deviceMenuItems.add(deviceMenuItem);
+ deviceMenuItem.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ deviceMenuItems.remove(e.widget);
+ }
+ });
+ }
+ }
+
+ private Menu createDropDownMenu(Menu menuBar, String name) {
+ MenuItem manuItem = new MenuItem(menuBar, SWT.CASCADE);
+ manuItem.setText(name);
+ Menu dropdown = new Menu(menuBar);
+ manuItem.setMenu(dropdown);
+ return dropdown;
+ }
+
+ public void setDevice(final Device device) {
+ for (MenuItem deviceMenuItem : deviceMenuItems) {
+ deviceMenuItem.setSelection(deviceMenuItem.getData() == device);
+ }
+
+ browser.setDefaultUserAgent(device.getUserAgent());
+ GridData data = (GridData) browser.getLayoutData();
+ data.widthHint = device.getWidth();
+ data.heightHint = device.getHeight();
+ Point shellSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle clientArea = display.getClientArea();
+ shellSize.x = Math.min(shellSize.x, clientArea.width);
+ shellSize.y = Math.min(shellSize.y, clientArea.height);
+ shell.setSize(shellSize);
+
+ Rectangle shellBounds = shell.getBounds();
+ int bottomOverlap = shellBounds.y + shellBounds.height - (clientArea.y +
clientArea.height);
+ if (bottomOverlap > 0) {
+ if (shellBounds.y > bottomOverlap) {
+ shellBounds.y -= bottomOverlap;
+ } else {
+ shellBounds.y = 0;
+ }
+ }
+
+ int rightOverlap = shellBounds.x + shellBounds.width - (clientArea.x +
clientArea.width);
+ if (rightOverlap > 0) {
+ if (shellBounds.x > rightOverlap) {
+ shellBounds.x -= rightOverlap;
+ } else {
+ shellBounds.x = 0;
+ }
+ }
+
+ shell.setBounds(shellBounds);
+ browser.refresh();
+ }
+}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class Device {
+ public static final int DEFAULT_SIZE = -1;
+
+ private String name;
+ private int width;
+ private int height;
+ private String userAgent;
+
+ public Device(String name, int width, int height, String userAgent) {
+ this.name = name;
+ this.width = width;
+ this.height = height;
+ this.userAgent = userAgent;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public String getUserAgent() {
+ return userAgent;
+ }
+
+ public void setUserAgent(String userAgent) {
+ this.userAgent = userAgent;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class DevicesManager {
+ private static DevicesManager instance;
+ private List<Device> devices;
+ public static final String IPHONE_OS_4_0_USER_AGENT = "Mozilla/5.0 (iPhone; U; CPU
iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5
Mobile/8A293 Safari/6531.22.7";
+
+ protected DevicesManager() {
+ devices = new ArrayList<Device>();
+ devices.add(new Device("iPhone 3", 320, 480, IPHONE_OS_4_0_USER_AGENT));
+ devices.add(new Device("iPhone 4", 640, 960, IPHONE_OS_4_0_USER_AGENT));
+ devices.add(new Device("BlackBerry Bold Touch 9900", 640, 480,
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.1+ (KHTML, like
Gecko) Version/6.0.0.246 Mobile Safari/534.1+"));
+ devices.add(new Device("Samsung GT-I9100 (Galaxy S II)", 640, 800,
"Mozilla/5.0 (Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1
(KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"));
+ }
+
+ public static DevicesManager getInstance() {
+ if (instance == null) {
+ instance = new DevicesManager();
+ }
+ return instance;
+ }
+
+ public List<Device> getDevices() {
+ return devices;
+ }
+}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/IWebViewProxy.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/IWebViewProxy.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/IWebViewProxy.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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;
+//import
org.eclipse.swt.internal.ole.win32.COM;
+//import org.eclipse.swt.internal.ole.win32.GUID;
+//import org.eclipse.swt.internal.webkit.IWebView;
+//import org.eclipse.swt.internal.win32.RECT;
+//
+///**
+// * @author Yahor Radtsevich (yradtsevich)
+// */
+//public class IWebViewProxy extends IWebView {
+// private IWebView webView;
+// private int defaultUserAgent;
+//
+// public void setDefaultUserAgent(String defaultUserAgentString) {
+// if (defaultUserAgentString == null) {
+// this.defaultUserAgent = 0;
+// } else {
+// char[] data = (defaultUserAgentString + '\0').toCharArray ();
+// this.defaultUserAgent = COM.SysAllocString(data);
+// }
+// setCustomUserAgent(this.defaultUserAgent);
+// }
+//
+// public int setCustomUserAgent(int valueString) {
+// if (valueString == 0) {
+// return webView.setCustomUserAgent(defaultUserAgent);
+// } else {
+// return webView.setCustomUserAgent(valueString);
+// }
+// }
+//
+// public IWebViewProxy(IWebView webView) {
+// super(webView.getAddress());
+// this.webView = webView;
+// }
+//
+// public int AddRef() {
+// return webView.AddRef();
+// }
+//
+// public int getAddress() {
+// return webView.getAddress();
+// }
+//
+// public int canShowMIMEType(int mimeType, int[] canShow) {
+// return webView.canShowMIMEType(mimeType, canShow);
+// }
+//
+// public int QueryInterface(GUID riid, int[] ppvObject) {
+// return webView.QueryInterface(riid, ppvObject);
+// }
+//
+// public int initWithFrame(RECT frame, int frameName, int groupName) {
+// return webView.initWithFrame(frame, frameName, groupName);
+// }
+//
+// public int Release() {
+// return webView.Release();
+// }
+//
+// public int setUIDelegate(int delegate) {
+// return webView.setUIDelegate(delegate);
+// }
+//
+// public int setResourceLoadDelegate(int delegate) {
+// return webView.setResourceLoadDelegate(delegate);
+// }
+//
+// public int setDownloadDelegate(int delegate) {
+// return webView.setDownloadDelegate(delegate);
+// }
+//
+// public int setFrameLoadDelegate(int delegate) {
+// return webView.setFrameLoadDelegate(delegate);
+// }
+//
+// public int setPolicyDelegate(int delegate) {
+// return webView.setPolicyDelegate(delegate);
+// }
+//
+// public int hashCode() {
+// return webView.hashCode();
+// }
+//
+// public int mainFrame(int[] frame) {
+// return webView.mainFrame(frame);
+// }
+//
+// public int goBack(int[] succeeded) {
+// return webView.goBack(succeeded);
+// }
+//
+// public int goForward(int[] succeeded) {
+// return webView.goForward(succeeded);
+// }
+//
+// public int setPreferences(int prefs) {
+// return webView.setPreferences(prefs);
+// }
+//
+// public int preferences(int[] prefs) {
+// return webView.preferences(prefs);
+// }
+//
+// public int setHostWindow(int window) {
+// return webView.setHostWindow(window);
+// }
+//
+// public int hostWindow(int[] window) {
+// return webView.hostWindow(window);
+// }
+//
+// public int estimatedProgress(int estimatedProgress) {
+// return webView.estimatedProgress(estimatedProgress);
+// }
+//
+// public boolean equals(Object obj) {
+// return webView.equals(obj);
+// }
+//
+// public String toString() {
+// return webView.toString();
+// }
+//}
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit
___________________________________________________________________
Added: svn:ignore
+ bin
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.classpath
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.classpath
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.classpath 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.project
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.project
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.project 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.browsersim.webkit</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.jdt.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,8 @@
+#Wed Oct 19 14:50:32 EEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.pde.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.pde.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/.settings/org.eclipse.pde.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+#Wed Oct 19 14:50:32 EEST 2011
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/META-INF/MANIFEST.MF
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/META-INF/MANIFEST.MF 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: WebKit
+Bundle-SymbolicName: org.jboss.tools.browsersim.webkit
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Eclipse-ExtensibleAPI: true
+Export-Package: org.jboss.tools.browsersim.webkit
+Require-Bundle: org.eclipse.swt;bundle-version="3.7.0"
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/build.properties
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/build.properties
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/build.properties 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/AbstractWebKitBrowser.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/AbstractWebKitBrowser.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/AbstractWebKitBrowser.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public abstract class AbstractWebKitBrowser extends Browser {
+
+ private String defaultUserAgent;
+
+ public AbstractWebKitBrowser(Composite parent, int style) {
+ super(parent, style | SWT.WEBKIT);
+ }
+
+ @Override
+ protected void checkSubclass() {
+ }
+
+ @Override
+ public boolean setUrl(String url, String postData, String[] headers) {
+ setCustomUserAgent(defaultUserAgent);
+ boolean result = super.setUrl(url, postData, headers);
+ setCustomUserAgent(defaultUserAgent);
+ return result;
+ }
+
+ public void setDefaultUserAgent(String defaultUserAgent) {
+ this.defaultUserAgent = defaultUserAgent;
+ setCustomUserAgent(defaultUserAgent);
+ }
+
+ protected abstract void setCustomUserAgent(String userAgent);
+}
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86
___________________________________________________________________
Added: svn:ignore
+ bin
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.classpath
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.classpath
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.classpath 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry combineaccessrules="false" kind="src"
path="/org.eclipse.swt"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.project
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.project
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.project 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.browsersim.webkit.gtk.linux.x86</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.jdt.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,8 @@
+#Thu Oct 20 00:05:13 EEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.pde.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.pde.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/.settings/org.eclipse.pde.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+#Thu Oct 20 00:05:13 EEST 2011
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/META-INF/MANIFEST.MF
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/META-INF/MANIFEST.MF 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: WebKit
+Bundle-SymbolicName: org.jboss.tools.browsersim.webkit.gtk.linux.x86
+Bundle-Version: 1.0.0.qualifier
+Fragment-Host: org.jboss.tools.browsersim.webkit;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Eclipse-PlatformFilter: (& (osgi.ws=gtk)(osgi.os=linux)(osgi.arch=x86))
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/build.properties
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/build.properties
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/build.properties 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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;
+
+import java.lang.reflect.Field;
+
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.gtk.OS;
+import org.eclipse.swt.internal.webkit.WebKitGTK;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class WebKitBrowser extends AbstractWebKitBrowser {
+ public WebKitBrowser(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ protected void setCustomUserAgent(String userAgent) {
+ try {
+ Field webBrowserField = Browser.class.getDeclaredField("webBrowser");
+ webBrowserField.setAccessible(true);
+ Object webKit = webBrowserField.get(this);
+
+ Field webViewField = webKit.getClass().getDeclaredField("webView");
+ webViewField.setAccessible(true);
+ int webView = (Integer) webViewField.get(webKit);
+ int settings = WebKitGTK.webkit_web_view_get_settings(webView);
+ if (userAgent != null) {
+ byte[] bytes = Converter.wcsToMbcs(null, userAgent, true);
+ OS.g_object_set(settings, WebKitGTK.user_agent, bytes, 0);
+ } else {
+ OS.g_object_set(settings, WebKitGTK.user_agent, 0, 0);
+ }
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+}
Property changes on:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86
___________________________________________________________________
Added: svn:ignore
+ bin
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.classpath
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.classpath
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.classpath 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.project
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.project
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.project 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.browsersim.webkit.win32.win32.x86</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.jdt.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,8 @@
+#Wed Oct 19 14:51:26 EEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.pde.core.prefs
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.pde.core.prefs
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/.settings/org.eclipse.pde.core.prefs 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+#Wed Oct 19 14:51:26 EEST 2011
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/META-INF/MANIFEST.MF
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/META-INF/MANIFEST.MF 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: WebKit
+Bundle-SymbolicName: org.jboss.tools.browsersim.webkit.win32.win32.x86
+Bundle-Version: 1.0.0.qualifier
+Fragment-Host: org.jboss.tools.browsersim.webkit;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.swt;bundle-version="3.7.0"
+Eclipse-PlatformFilter: (& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/build.properties
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/build.properties
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/build.properties 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-20
17:25:03 UTC (rev 35854)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.swt.browser.Browser;
+import
org.eclipse.swt.internal.ole.win32.COM;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class WebKitBrowser extends AbstractWebKitBrowser {
+ public WebKitBrowser(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ protected void setCustomUserAgent(String userAgent) {
+ int userAgentValue;
+ if (userAgent != null) {
+ char[] data = (userAgent + '\0').toCharArray ();
+ userAgentValue = COM.SysAllocString(data);
+ } else {
+ userAgentValue = 0;
+ }
+
+ try {
+ Field webBrowserField = Browser.class.getDeclaredField("webBrowser");
+ webBrowserField.setAccessible(true);
+ Object webKit = webBrowserField.get(this);
+
+ Field webViewField = webKit.getClass().getDeclaredField("webView");
+ webViewField.setAccessible(true);
+ Object webView = webViewField.get(webKit);
+
+ Method setCustomUserAgentMethod =
webView.getClass().getDeclaredMethod("setCustomUserAgent", int.class);
+ setCustomUserAgentMethod.invoke(webView, userAgentValue);
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+
+ if (userAgent != null) {
+ COM.SysFreeString(userAgentValue);
+ }
+ }
+}