Author: yradtsevich
Date: 2011-10-28 10:40:43 -0400 (Fri, 28 Oct 2011)
New Revision: 36070
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/plugin.xml
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/src/org/jboss/tools/browsersim/application/Application.java
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/internal/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86_64.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_webkit_cocoa_macos.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_win32_win32_x86.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_backward.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_forward.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_go.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_home.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_print.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_refresh.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_stop.gif
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/synced.gif
Removed:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.cocoa.macosx/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
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86_64/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
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/plugin.xml
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/
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/Application.java
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/META-INF/MANIFEST.MF
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web
apps
- removing fragments and gathering all classes in one plugin is in progress
Modified:
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 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF 2011-10-28
14:40:43 UTC (rev 36070)
@@ -4,8 +4,6 @@
Bundle-SymbolicName: org.jboss.tools.browsersim;singleton:=true
Bundle-Version: 1.0.0.qualifier
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",
- org.eclipse.core.runtime;bundle-version="3.7.0",
- org.eclipse.ui;bundle-version="3.7.0"
+ org.jboss.tools.browsersim.webkit;bundle-version="1.0.0"
+Export-Package: org.jboss.tools.browsersim
Deleted:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/plugin.xml
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/plugin.xml 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/plugin.xml 2011-10-28
14:40:43 UTC (rev 36070)
@@ -1,10 +0,0 @@
-<plugin>
- <extension id="application"
- point="org.eclipse.core.runtime.applications">
- <application>
- <run
- class="org.jboss.tools.browsersim.Application">
- </run>
- </application>
- </extension>
-</plugin>
Deleted:
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 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Activator.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * 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.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.eclipse.swt.widgets.Display;
-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(new Display()).run();
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- }
-
-}
Deleted:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Application.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Application.java 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Application.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * 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.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Yahor Radtsevich (yradtsevich)
- */
-public class Application implements IApplication {
-
- @Override
- public Object start(IApplicationContext context) throws Exception {
- Display display = PlatformUI.createDisplay();
- new BrowserSim(display).run();
- return IApplication.EXIT_OK;
- }
-
- @Override
- public void stop() {
- // TODO Auto-generated method stub
-
- }
-
-}
Modified:
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 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.browsersim;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -44,13 +42,14 @@
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;
+import org.jboss.tools.browsersim.webkit.AbstractWebKitBrowser;
+import org.jboss.tools.browsersim.webkit.WebKitBrowserFactory;
/**
* @author Yahor Radtsevich (yradtsevich)
*/
public class BrowserSim implements Runnable {
- private WebKitBrowser browser;
+ private AbstractWebKitBrowser browser;
private Display display;
private Shell shell;
private Text locationText;
@@ -96,7 +95,7 @@
locationText.setLayoutData(data);
try {
- browser = new WebKitBrowser(shell, SWT.NONE);
+ browser = WebKitBrowserFactory.createWebKitBrowser(shell, SWT.NONE);
} catch (SWTError e) {
System.out.println("Could not instantiate Browser: " + e.getMessage());
display.dispose();
@@ -208,11 +207,11 @@
}
});
- 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"));
+ final Image imageBack = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_backward.gif"));
+ final Image imageForward = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_forward.gif"));
+ final Image imageStop = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_stop.gif"));
+ final Image imageRefresh = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_refresh.gif"));
+ final Image imageGo = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_go.gif"));
itemBack.setImage(imageBack);
itemForward.setImage(imageForward);
@@ -236,14 +235,6 @@
}
private InputStream getResourceAsStream(String name) {
- if (true) {
- try {
- return new FileInputStream(name);
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
return this.getClass().getResourceAsStream(name);
}
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_backward.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_backward.gif)
===================================================================
(Binary files differ)
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_forward.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_forward.gif)
===================================================================
(Binary files differ)
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_go.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_go.gif)
===================================================================
(Binary files differ)
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_home.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_home.gif)
===================================================================
(Binary files differ)
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_print.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_print.gif)
===================================================================
(Binary files differ)
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_refresh.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_refresh.gif)
===================================================================
(Binary files differ)
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/nav_stop.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/nav_stop.gif)
===================================================================
(Binary files differ)
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/icons/synced.gif
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/resources/icons/synced.gif)
===================================================================
(Binary files differ)
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/META-INF/MANIFEST.MF 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/META-INF/MANIFEST.MF 2011-10-28
14:40:43 UTC (rev 36070)
@@ -3,8 +3,6 @@
Bundle-Name: BrowserSim Application
Bundle-SymbolicName: org.jboss.tools.browsersim.application;singleton:=true
Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.jboss.tools.browsersim.application.Activator
-Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/plugin.xml
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/plugin.xml)
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/plugin.xml
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/plugin.xml 2011-10-28
14:40:43 UTC (rev 36070)
@@ -0,0 +1,10 @@
+<plugin>
+ <extension id="application"
+ point="org.eclipse.core.runtime.applications">
+ <application>
+ <run
+ class="org.jboss.tools.browsersim.application.Application">
+ </run>
+ </application>
+ </extension>
+</plugin>
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/src/org/jboss/tools/browsersim/application/Application.java
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Application.java)
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/src/org/jboss/tools/browsersim/application/Application.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.application/src/org/jboss/tools/browsersim/application/Application.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.application;
+
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.browsersim.BrowserSim;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class Application implements IApplication {
+
+ @Override
+ public Object start(IApplicationContext context) throws Exception {
+ Display display = PlatformUI.createDisplay();
+ new BrowserSim(display).run();
+ return IApplication.EXIT_OK;
+ }
+
+ @Override
+ public void stop() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
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
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/WebKitBrowserFactory.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.widgets.Composite;
+import org.jboss.tools.browsersim.webkit.internal.WebKitBrowser_win32_win32_x86;
+
+/**
+ * @author "Yahor Radtsevich (yradtsevich)"
+ */
+public class WebKitBrowserFactory {
+ public static AbstractWebKitBrowser createWebKitBrowser(Composite parent, int style) {
+ return new WebKitBrowser_win32_win32_x86(parent, style);
+ }
+}
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86.java
(from rev 36067,
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/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.internal;
+
+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.Converter;
+import org.eclipse.swt.internal.gtk.OS;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.browsersim.webkit.AbstractWebKitBrowser;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class WebKitBrowser_gtk_linux_x86 extends AbstractWebKitBrowser {
+ private static final byte[] USER_AGENT; // = WebKitGTK.user_agent
+ static {
+ int length = "user-agent".length();
+ char [] chars = new char[length];
+ "user-agent".getChars(0, length, chars, 0);
+ USER_AGENT = new byte[length + 1];
+ for (int i = 0; i < length; i++) {
+ USER_AGENT[i] = (byte) chars [i];
+ }
+ }
+
+ public WebKitBrowser_gtk_linux_x86(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);
+ Class webKitGTKClass =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.webkit.WebKitGTK");
+ Method webkit_web_view_get_settingsMethod =
webKitGTKClass.getDeclaredMethod("webkit_web_view_get_settings", int.class);
+ int settings = (Integer) webkit_web_view_get_settingsMethod.invoke(null, webView);
+
+ if (userAgent == null) {
+ OS.g_object_set(settings, USER_AGENT, 0, 0);
+ } else {
+ byte[] bytes = Converter.wcsToMbcs(null, userAgent, true);
+ OS.g_object_set(settings, USER_AGENT, bytes, 0);
+ }
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+}
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86_64.java
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86_64/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java)
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86_64.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_gtk_linux_x86_64.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.internal;
+
+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.widgets.Composite;
+import org.jboss.tools.browsersim.webkit.AbstractWebKitBrowser;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class WebKitBrowser_gtk_linux_x86_64 extends AbstractWebKitBrowser {
+ private static final byte[] USER_AGENT; // = WebKitGTK.user_agent
+ static {
+ int length = "user-agent".length();
+ char [] chars = new char[length];
+ "user-agent".getChars(0, length, chars, 0);
+ USER_AGENT = new byte[length + 1];
+ for (int i = 0; i < length; i++) {
+ USER_AGENT[i] = (byte) chars [i];
+ }
+ }
+
+ public WebKitBrowser_gtk_linux_x86_64(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ protected void setCustomUserAgent(String userAgent) {
+ try {
+ long webView = getThis_webBrowser_webView();
+
+ //long settings = WebKitGTK.webkit_web_view_get_settings(webView);
+ long settings = invokeWebKitGTK_webkit_web_view_get_settings(webView);
+
+ if (userAgent == null) {
+ //org.eclipse.swt.internal.gtk.OS.g_object_set(settings, USER_AGENT, 0, 0);
+ invokeOS_g_object_set(settings, USER_AGENT, 0, 0);
+ } else {
+ //byte[] bytes = org.eclipse.swt.internal.Converter.wcsToMbcs(null, userAgent,
true);
+ byte[] bytes = invokeConverter_wcsToMbcs(null, userAgent, true);
+
+ //org.eclipse.swt.internal.gtk.OS.g_object_set(settings, USER_AGENT, bytes, 0);
+ invokeOS_g_object_set(settings, USER_AGENT, bytes, 0);
+ }
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private long getThis_webBrowser_webView() throws NoSuchFieldException,
+ IllegalAccessException {
+ Field webBrowserField = Browser.class.getDeclaredField("webBrowser");
+ webBrowserField.setAccessible(true);
+ Object webKit = webBrowserField.get(this);
+
+ Field webViewField = webKit.getClass().getDeclaredField("webView");
+ webViewField.setAccessible(true);
+ long webView = (Long) webViewField.get(webKit);
+ return webView;
+ }
+
+ //void org.eclipse.swt.internal.gtk.OS#g_object_set(long /*int*/ object, byte[]
first_property_name, int data, long /*int*/ terminator)
+ private void invokeOS_g_object_set(long /*int*/ object, byte[] first_property_name, int
data, long /*int*/ terminator)
+ throws ClassNotFoundException, NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException {
+ Class<?> OS =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.gtk.OS");
+ Method OS_g_object_set = OS.getDeclaredMethod("g_object_set", long.class,
byte[].class, int.class, long.class);
+ OS_g_object_set.invoke(null, object, first_property_name, data, terminator);
+ }
+
+ //void org.eclipse.swt.internal.gtk.OS#void g_object_set(long /*int*/ object, byte[]
first_property_name, byte[] data, long /*int*/ terminator)
+ private void invokeOS_g_object_set(long /*int*/ object, byte[] first_property_name,
byte[] data, long /*int*/ terminator)
+ throws ClassNotFoundException, NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException {
+ Class<?> OS =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.gtk.OS");
+ Method OS_g_object_set = OS.getDeclaredMethod("g_object_set", long.class,
byte[].class, byte[].class, long.class);
+ OS_g_object_set.invoke(null, object, first_property_name, data, terminator);
+ }
+
+ // public static byte [] org.eclipse.swt.internal.Converter#wcsToMbcs (String codePage,
String string, boolean terminate)
+ private byte [] invokeConverter_wcsToMbcs (String codePage, String string, boolean
terminate)
+ throws ClassNotFoundException, NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException {
+ Class<?> Converter =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.Converter");
+ Method Converter_wcsToMbcs = Converter.getDeclaredMethod("wcsToMbcs",
String.class, String.class, boolean.class);
+ return (byte[]) Converter_wcsToMbcs.invoke(null, codePage, string, terminate);
+ }
+
+ // org.eclipse.swt.internal.webkit.WebKitGTK#webkit_web_view_get_settings(webView);
+ private long invokeWebKitGTK_webkit_web_view_get_settings(long /*int*/ webView)
+ throws ClassNotFoundException, NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException {
+ Class<?> webKitGTKClass =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.webkit.WebKitGTK");
+ Method webkit_web_view_get_settingsMethod =
webKitGTKClass.getDeclaredMethod("webkit_web_view_get_settings", long.class);
+ return (Long) webkit_web_view_get_settingsMethod.invoke(null, webView);
+ }
+}
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_webkit_cocoa_macos.java
(from rev 36067,
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.cocoa.macosx/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java)
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_webkit_cocoa_macos.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_webkit_cocoa_macos.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.internal;
+
+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.cocoa.NSString;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.browsersim.webkit.AbstractWebKitBrowser;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class WebKitBrowser_webkit_cocoa_macos extends AbstractWebKitBrowser {
+
+ public WebKitBrowser_webkit_cocoa_macos(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);
+ Object webView = webViewField.get(webKit);
+ Method setCustomUserAgent =
webView.getClass().getDeclaredMethod("setCustomUserAgent", NSString.class);
+
+ if (userAgent == null) {
+ setCustomUserAgent.invoke(webView, null);
+ } else {
+ setCustomUserAgent.invoke(webView, NSString.stringWith(userAgent));
+ }
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+}
Copied:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_win32_win32_x86.java
(from rev 36067,
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/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_win32_win32_x86.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit/src/org/jboss/tools/browsersim/webkit/internal/WebKitBrowser_win32_win32_x86.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.internal;
+
+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.widgets.Composite;
+import org.jboss.tools.browsersim.webkit.AbstractWebKitBrowser;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class WebKitBrowser_win32_win32_x86 extends AbstractWebKitBrowser {
+ public WebKitBrowser_win32_win32_x86(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ protected void setCustomUserAgent(String userAgent) {
+ try {
+ int userAgentValue;
+
+ if (userAgent != null) {
+ char[] data = (userAgent + '\0').toCharArray ();
+
+ //userAgentValue = org.eclipse.swt.internal.ole.win32.COM.SysAllocString(data);
+ userAgentValue = invokeCOM_SysAllocString(data);
+ } else {
+ userAgentValue = 0;
+ }
+
+ 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);
+
+ if (userAgent != null) {
+ //org.eclipse.swt.internal.ole.win32.COM.SysFreeString(userAgentValue);
+ invokeCOM_SysFreeString(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();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Invokes {@link org.eclipse.swt.internal.ole.win32.COM#SysAllocString(char[])}.
+ */
+ private int /*long*/ invokeCOM_SysAllocString(char [] sz) throws ClassNotFoundException,
SecurityException, NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
+ Class<?> COM =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.ole.win32.COM");
+ Method COM_SysAllocString = COM.getDeclaredMethod("SysAllocString",
char[].class);
+ return (Integer) COM_SysAllocString.invoke(null, sz);
+ }
+
+ /**
+ * Invokes {@link org.eclipse.swt.internal.ole.win32.COM#SysFreeString(int)}.
+ */
+ private void invokeCOM_SysFreeString(int /*long*/ bstr) throws ClassNotFoundException,
SecurityException, NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
+ Class<?> COM =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.ole.win32.COM");
+ Method COM_SysFreeString = COM.getDeclaredMethod("SysFreeString", int.class
/*long.class*/);
+ COM_SysFreeString.invoke(null, bstr);
+ }
+}
Deleted:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.cocoa.macosx/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.cocoa.macosx/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.cocoa.macosx/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * 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.cocoa.NSString;
-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);
- Object webView = webViewField.get(webKit);
- Method setCustomUserAgent =
webView.getClass().getDeclaredMethod("setCustomUserAgent", NSString.class);
-
- if (userAgent == null) {
- setCustomUserAgent.invoke(webView, null);
- } else {
- setCustomUserAgent.invoke(webView, NSString.stringWith(userAgent));
- }
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-}
Deleted:
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 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * 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.Converter;
-import org.eclipse.swt.internal.gtk.OS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @author Yahor Radtsevich (yradtsevich)
- */
-public class WebKitBrowser extends AbstractWebKitBrowser {
- private static final byte[] USER_AGENT; // = WebKitGTK.user_agent
- static {
- int length = "user-agent".length();
- char [] chars = new char[length];
- "user-agent".getChars(0, length, chars, 0);
- USER_AGENT = new byte[length + 1];
- for (int i = 0; i < length; i++) {
- USER_AGENT[i] = (byte) chars [i];
- }
- }
-
- 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);
- Class webKitGTKClass =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.webkit.WebKitGTK");
- Method webkit_web_view_get_settingsMethod =
webKitGTKClass.getDeclaredMethod("webkit_web_view_get_settings", int.class);
- int settings = (Integer) webkit_web_view_get_settingsMethod.invoke(null, webView);
-
- if (userAgent == null) {
- OS.g_object_set(settings, USER_AGENT, 0, 0);
- } else {
- byte[] bytes = Converter.wcsToMbcs(null, userAgent, true);
- OS.g_object_set(settings, USER_AGENT, bytes, 0);
- }
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-}
Deleted:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86_64/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86_64/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.gtk.linux.x86_64/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * 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.Converter;
-import org.eclipse.swt.internal.gtk.OS;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @author Yahor Radtsevich (yradtsevich)
- */
-public class WebKitBrowser extends AbstractWebKitBrowser {
- private static final byte[] USER_AGENT; // = WebKitGTK.user_agent
- static {
- int length = "user-agent".length();
- char [] chars = new char[length];
- "user-agent".getChars(0, length, chars, 0);
- USER_AGENT = new byte[length + 1];
- for (int i = 0; i < length; i++) {
- USER_AGENT[i] = (byte) chars [i];
- }
- }
-
- 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);
- long webView = (Long) webViewField.get(webKit);
-
-// long settings = WebKitGTK.webkit_web_view_get_settings(webView);
- Class webKitGTKClass =
Browser.class.getClassLoader().loadClass("org.eclipse.swt.internal.webkit.WebKitGTK");
- Method webkit_web_view_get_settingsMethod =
webKitGTKClass.getDeclaredMethod("webkit_web_view_get_settings", long.class);
- long settings = (Long) webkit_web_view_get_settingsMethod.invoke(null, webView);
-
- if (userAgent == null) {
- OS.g_object_set(settings, USER_AGENT, 0, 0);
- } else {
- byte[] bytes = Converter.wcsToMbcs(null, userAgent, true);
- OS.g_object_set(settings, USER_AGENT, bytes, 0);
- }
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-}
Deleted:
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 2011-10-28
13:39:25 UTC (rev 36069)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.webkit.win32.win32.x86/src/org/jboss/tools/browsersim/webkit/WebKitBrowser.java 2011-10-28
14:40:43 UTC (rev 36070)
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * 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);
- }
- }
-}