Remove SWT, collapse dev platforms to a single one, rewrite runstyles to new
API.
TODO: ant checkstyle fails, need better handling of argument processing
errors for runstyles.
Patch by: jat
Review by: amitmanjhi, rjrjr (TBR)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/branches/farewellSwt@6169 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/build.xml b/build.xml
index bad7399..f071628 100755
--- a/build.xml
+++ b/build.xml
@@ -35,22 +35,17 @@
<target name="buildonly"
description="[action] Minimal one-platform devel build, without distro packaging">
- <call-subproject subproject="dev-one" subtarget="build" />
+ <call-subproject subproject="dev" subtarget="build" />
<call-subproject subproject="user" subtarget="build" />
<call-subproject subproject="servlet" subtarget="build" />
- <call-subproject subproject="jni-one" subtarget="build" />
</target>
<target name="dist" depends="build, doc" description="[action] Make all the distributions">
<gwt.ant dir="distro-source" />
</target>
- <target name="dist-one" depends="buildonly, tools, samples, doc" description="[action] Make only this platform's distribution">
- <gwt.ant dir="distro-source" target="${build.host.platform}" />
- </target>
-
<target name="dist-dev" depends="buildonly" description="[action] Make this platform's distribution, minus doc and samples">
- <gwt.ant dir="distro-source" target="${build.host.platform}" />
+ <gwt.ant dir="distro-source" target="build" />
</target>
<target name="dev" description="[subdir] Builds (or runs ${target} if set) all the dev libraries">
@@ -58,14 +53,8 @@
<gwt.ant dir="dev" />
</target>
- <target name="dev-one" description="[subdir] Builds only the dev library for this platform">
- <call-subproject subproject="buildtools" subtarget="build" />
- <gwt.ant dir="dev" target="${build.host.platform}"/>
- <gwt.ant dir="dev" target="oophm"/>
- </target>
-
<target name="user" description="[subdir] Builds (or runs ${target} if set) only the user library">
- <call-subproject subproject="dev-one" subtarget="build"/>
+ <call-subproject subproject="dev" subtarget="build"/>
<gwt.ant dir="user" />
</target>
@@ -79,14 +68,6 @@
<gwt.ant dir="servlet" />
</target>
- <target name="jni" description="[subdir] Builds (or runs ${target} if set) jni for all platforms">
- <gwt.ant dir="jni" />
- </target>
-
- <target name="jni-one" description="[subdir] Builds jni for only this platform">
- <gwt.ant dir="jni" target="${build.host.platform}" />
- </target>
-
<target name="doc" description="[subdir] Builds (or runs ${target} if set) the doc">
<call-subproject subproject="user" subtarget="build" />
<gwt.ant dir="doc" />
@@ -106,7 +87,6 @@
<call-subproject subproject="user" subtarget="build"/>
<call-subproject subproject="servlet" subtarget="build"/>
<call-subproject subproject="tools" subtarget="build"/>
- <call-subproject subproject="jni" subtarget="build"/>
<call-subproject subproject="samples" subtarget="build"/>
</target>
@@ -178,10 +158,9 @@
<java failonerror="true" fork="true"
classname="com.google.gwt.tools.apichecker.ApiCompatibilityChecker">
<jvmarg line="-Xmx512m" />
- <sysproperty key="gwt.devjar" value="${gwt.dev.staging.jar}" />
<classpath>
<pathelement location="${gwt.build.out}/tools/api-checker/bin"/>
- <fileset dir="${gwt.build.lib}" includes="gwt-user.jar,gwt-dev-*.jar" />
+ <fileset dir="${gwt.build.lib}" includes="gwt-user.jar,gwt-dev.jar" />
<pathelement path="${java.class.path}"/>
<pathelement location="${gwt.tools.lib}/apache/ant-1.6.5.jar" />
</classpath>
diff --git a/common.ant.xml b/common.ant.xml
index 2121879..1e47100 100755
--- a/common.ant.xml
+++ b/common.ant.xml
@@ -100,7 +100,7 @@
</condition>
<!-- JUnit support -->
- <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${build.host.platform}-${gwt.version}/gwt-dev-${build.host.platform}.jar" />
+ <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${gwt.version}/gwt-dev.jar" />
<property name="gwt.junit.port" value="8888" />
<property name="gwt.junit.testcase.includes" value="**/*Suite.class"/>
@@ -208,7 +208,6 @@
<jvmarg value="-Demma.coverage.out.merge=true" />
<sysproperty key="gwt.args" value="${junit.notheadless.arg} @{test.args}" />
<sysproperty key="java.awt.headless" value="${junit.headless}" />
- <sysproperty key="gwt.devjar" value="${gwt.dev.staging.jar}" />
<classpath>
<path refid="project.classpath.src" />
<pathelement location="${gwt.root}/${project.tail}/super" />
diff --git a/dev/build.xml b/dev/build.xml
index dde2ebb..1236d41 100755
--- a/dev/build.xml
+++ b/dev/build.xml
@@ -2,18 +2,285 @@
<property name="gwt.root" location=".." />
<property name="project.tail" value="dev" />
<import file="${gwt.root}/platforms.ant.xml" />
+ <import file="${gwt.root}/common.ant.xml" />
-
- <target name="test" description="Tests this project, but only on this platform">
- <gwt.ant dir="core" target="test"/>
- <gwt.ant dir="oophm" target="test"/>
- <gwt.ant dir="${build.host.platform}" target="test"/>
- </target>
+ <property name="alldeps.jar" location="${project.build}/alldeps.jar" />
+ <property name="gwt.junit.testcase.dev.core.includes" value="**/com/google/**/*Test.class" />
+ <property name="gwt.junit.testcase.dev.core.excludes" value="" />
<target name="clean" description="Cleans this project's intermediate and output files">
<delete dir="${project.build}" failonerror="false" />
+ <delete file="${project.lib}" failonerror="false" />
<delete failonerror="false">
- <fileset dir="${gwt.build.lib}" includes="gwt-dev-*.jar"/>
+ <fileset dir="${gwt.build.lib}" includes="gwt-dev.jar"/>
</delete>
</target>
+
+ <target name="compile.tests" depends="build, compile.emma" description="Compiles the test code for this project">
+ <mkdir dir="${javac.junit.out}" />
+ <gwt.javac destdir="${javac.junit.out}">
+ <src path="core/test" />
+ <src path="oophm/src" />
+ <src path="oophm/overlay" />
+ <src path="oophm/test" />
+ <classpath>
+ <pathelement location="${javac.out}" />
+ <pathelement location="${alldeps.jar}" />
+ <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
+ </classpath>
+ </gwt.javac>
+ </target>
+
+ <target name="build.alldeps.jar" description="Merges all dependency jars into a single jar">
+ <mkdir dir="${project.build}" />
+ <outofdate> <!-- saves rescanning all the source jars' contents -->
+ <sourcefiles>
+ <fileset dir="${gwt.tools.lib}">
+ <include name="apache/tapestry-util-text-4.0.2.jar" />
+ <include name="apache/ant-1.6.5.jar" />
+ <include name="eclipse/jdt-3.4.2.jar" />
+ <include name="jetty/jetty-6.1.11.jar" />
+ <include name="tomcat/ant-launcher-1.6.5.jar" />
+ <include name="tomcat/catalina-1.0.jar" />
+ <include name="tomcat/catalina-optional-1.0.jar" />
+ <include name="tomcat/commons-beanutils-1.6.jar" />
+ <include name="tomcat/commons-collections-3.1.jar" />
+ <include name="tomcat/commons-digester-1.5.jar" />
+ <include name="tomcat/commons-el-1.0.jar" />
+ <include name="tomcat/commons-logging-1.0.jar" />
+ <include name="tomcat/commons-modeler-1.1.jar" />
+ <include name="tomcat/jakarta-regexp-1.3.jar" />
+ <include name="tomcat/jasper-compiler-1.0.jar" />
+ <include name="tomcat/jasper-runtime-1.0.jar" />
+ <include name="tomcat/jsp-api-2.0.jar" />
+ <include name="tomcat/mx4j-jmx-1.1.jar" />
+ <include name="tomcat/naming-common-1.0.jar" />
+ <include name="tomcat/naming-factory-1.0.jar" />
+ <include name="tomcat/naming-java-1.0.jar" />
+ <include name="tomcat/naming-resources-1.0.jar" />
+ <include name="tomcat/servlet-api-2.5.jar" />
+ <include name="tomcat/servlet-api-2.4.jar" />
+ <include name="tomcat/servlets-common-1.0.jar" />
+ <include name="tomcat/servlets-default-1.0.jar" />
+ <include name="tomcat/servlets-invoker-1.0.jar" />
+ <include name="tomcat/tomcat-coyote-1.0.jar" />
+ <include name="tomcat/tomcat-http11-1.0.jar" />
+ <include name="tomcat/tomcat-jk2-2.1.jar" />
+ <include name="tomcat/tomcat-util-5.1.jar" />
+ <!-- htmlunit dependencies not already included: BEGIN -->
+ <include name="apache/commons/commons-codec-1.3.jar" />
+ <include name="apache/commons/commons-httpclient-3.1.jar" />
+ <include name="apache/commons/commons-io-1.4.jar" />
+ <include name="apache/commons/commons-lang-2.4.jar" />
+ <include name="cssparser/cssparser-0.9.5.jar" />
+ <include name="htmlunit/htmlunit-2.5.jar" />
+ <include name="htmlunit/htmlunit-core-js-2.5.jar" />
+ <include name="nekohtml/nekohtml-1.9.12.jar" />
+ <include name="xalan/xalan-2.7.1.jar" />
+ <include name="xerces/xerces-2_9_1/serializer.jar" />
+ <include name="xerces/xerces-2_9_1/xercesImpl-NoMetaInf.jar" />
+ <include name="xerces/xerces-2_9_1/xml-apis.jar" />
+ <include name="w3c/sac/sac-1.3.jar" />
+ <!-- htmlunit dependencies not already included: END -->
+ <include name="sun/swingworker/swing-worker-1.1.jar" />
+ </fileset>
+ <fileset file="build.xml"/>
+ </sourcefiles>
+ <targetfiles>
+ <fileset file="${alldeps.jar}"/>
+ </targetfiles>
+ <sequential>
+ <gwt.jar destfile="${alldeps.jar}">
+ <zipfileset src="${gwt.tools.lib}/apache/tapestry-util-text-4.0.2.jar" />
+ <zipfileset src="${gwt.tools.lib}/apache/ant-1.6.5.jar" />
+ <zipfileset src="${gwt.tools.lib}/eclipse/jdt-3.4.2.jar" />
+ <zipfileset src="${gwt.tools.lib}/jetty/jetty-6.1.11.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/ant-launcher-1.6.5.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/catalina-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/catalina-optional-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/commons-beanutils-1.6.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/commons-collections-3.1.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/commons-digester-1.5.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/commons-el-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/commons-logging-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/commons-modeler-1.1.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/jakarta-regexp-1.3.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/jasper-compiler-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/jasper-runtime-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/jsp-api-2.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/mx4j-jmx-1.1.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/naming-common-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/naming-factory-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/naming-java-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/naming-resources-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/servlet-api-2.5.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/servlet-api-2.4.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/servlets-common-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/servlets-default-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/servlets-invoker-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/tomcat-coyote-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/tomcat-http11-1.0.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/tomcat-jk2-2.1.jar" />
+ <zipfileset src="${gwt.tools.lib}/tomcat/tomcat-util-5.1.jar" />
+ <!-- htmlunit dependencies not already included: BEGIN -->
+ <zipfileset src="${gwt.tools.lib}/apache/commons/commons-codec-1.3.jar" />
+ <zipfileset src="${gwt.tools.lib}/apache/commons/commons-httpclient-3.1.jar" />
+ <zipfileset src="${gwt.tools.lib}/apache/commons/commons-io-1.4.jar" />
+ <zipfileset src="${gwt.tools.lib}/apache/commons/commons-lang-2.4.jar" />
+ <zipfileset src="${gwt.tools.lib}/cssparser/cssparser-0.9.5.jar" />
+ <zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-2.5.jar" />
+ <zipfileset src="${gwt.tools.lib}/htmlunit/htmlunit-core-js-2.5.jar" />
+ <zipfileset src="${gwt.tools.lib}/nekohtml/nekohtml-1.9.12.jar" />
+ <zipfileset src="${gwt.tools.lib}/xalan/xalan-2.7.1.jar" />
+ <zipfileset src="${gwt.tools.lib}/xerces/xerces-2_9_1/serializer.jar" />
+ <zipfileset src="${gwt.tools.lib}/xerces/xerces-2_9_1/xercesImpl-NoMetaInf.jar" />
+ <zipfileset src="${gwt.tools.lib}/xerces/xerces-2_9_1/xml-apis.jar" />
+ <zipfileset src="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
+ <!-- htmlunit dependencies not already included: END -->
+ <zipfileset src="${gwt.tools.lib}/sun/swingworker/swing-worker-1.1.jar" />
+ </gwt.jar>
+ </sequential>
+ </outofdate>
+ </target>
+
+ <property name="filter.pattern" value="com/google/gwt/dev/About.properties" />
+
+ <target name="-filter.props" description="Creates filtered About.properties with version info"
+ unless="filter.uptodate">
+ <gwt.revfilter todir="${javac.out}">
+ <fileset dir="core/src" includes="${filter.pattern}" />
+ </gwt.revfilter>
+ <touch file="${filter.sentinel}" />
+ </target>
+
+ <target name="compiler.standalone" description="Validates that the standalone gwt-compiler project can build.">
+ <mkdir dir="${javac.out}" />
+ <gwt.javac srcdir="core/super" excludes="com/google/gwt/dev/jjs/intrinsic/"/>
+ <gwt.javac srcdir="core/src">
+ <include name="com/google/gwt/core/ext/**"/>
+ <include name="com/google/gwt/core/linker/**"/>
+ <include name="com/google/gwt/dev/About.java"/>
+ <include name="com/google/gwt/dev/asm/**"/>
+ <include name="com/google/gwt/dev/cfg/**"/>
+ <include name="com/google/gwt/dev/javac/**"/>
+ <include name="com/google/gwt/dev/jdt/**"/>
+ <include name="com/google/gwt/dev/jjs/**"/>
+ <include name="com/google/gwt/dev/js/**"/>
+ <include name="com/google/gwt/dev/resource/**"/>
+ <include name="com/google/gwt/dev/util/**"/>
+ <include name="com/google/gwt/util/tools/**"/>
+ <classpath>
+ <pathelement location="${gwt.tools.lib}/apache/ant-1.6.5.jar" />
+ <pathelement location="${gwt.tools.lib}/eclipse/jdt-3.4.2.jar" />
+ <pathelement location="${gwt.tools.lib}/tomcat/commons-collections-3.1.jar" />
+ <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
+ </classpath>
+ </gwt.javac>
+
+ </target>
+
+ <target name="compile" depends="compiler.standalone, build.alldeps.jar" description="Compiles this project">
+ <gwt.javac srcdir="" excludes="${filter.pattern}">
+ <src path="core/src" />
+ <src path="oophm/src" />
+ <src path="oophm/overlay" />
+ <classpath>
+ <pathelement location="${alldeps.jar}" />
+ <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
+ </classpath>
+ </gwt.javac>
+ <copy todir="${javac.out}">
+ <fileset dir="core/src" includes="**/*.properties" excludes="${filter.pattern}"/>
+ </copy>
+
+ <!-- Files with hardcoded version information must be filtered -->
+ <gwt.getsvninfo />
+ <condition property="filter.uptodate">
+ <and>
+ <available file="${filter.sentinel}" />
+ <uptodate>
+ <srcfiles dir="core/src" includes="${filter.pattern}" />
+ <globmapper from="*" to="${javac.out}/*" />
+ </uptodate>
+ </and>
+ </condition>
+ <antcall target="-filter.props" />
+ </target>
+
+ <target name="checkstyle" description="Static analysis of source">
+ <gwt.checkstyle>
+ <fileset dir="core/src">
+ <filename name="com/google/gwt/dev/asm/**/*.java" negate="yes" />
+ <filename name="com/google/gwt/dev/js/rhino/**/*.java" negate="yes" />
+ <filename name="org/eclipse/**/*.java" negate="yes" />
+ <filename name="org/apache/**/*.java" negate="yes" />
+ </fileset>
+ <fileset dir="oophm/src" />
+ <fileset dir="oophm/overlay" />
+ <fileset dir="oophm/test" />
+ </gwt.checkstyle>
+
+ <gwt.checkstyle>
+ <fileset dir="core/super/com/google/gwt/dev/jjs/intrinsic" />
+ </gwt.checkstyle>
+
+ </target>
+
+ <target name="test" depends="build, compile.tests" description="Run unit tests for this project.">
+ <fileset id="tests.dev.core" dir="${javac.junit.out}" includes="${gwt.junit.testcase.dev.core.includes}" excludes="${gwt.junit.testcase.dev.core.excludes}" />
+ <gwt.junit test.out="${junit.out}" test.cases="tests.dev.core" >
+ <extraclasspaths>
+ <pathelement location="${alldeps.jar}" />
+ <!-- Pull in gwt-dev and gwt-user sources for .gwt.xml files -->
+ <pathelement location="${gwt.root}/user/src/" />
+ <pathelement location="${gwt.root}/user/super/" />
+ </extraclasspaths>
+ </gwt.junit>
+ </target>
+
+ <property.ensure name="gwt.tools.soyc" location="${gwt.root}/tools/soyc-vis" />
+ <target name="build" depends="compile" description="Build and package this project">
+ <mkdir dir="${gwt.build.lib}" />
+ <outofdate>
+ <sourcefiles>
+ <fileset dir="oophm/src" excludes="**/package.html"/>
+ <fileset dir="oophm/overlay" excludes="**/package.html"/>
+ <fileset dir="core/src">
+ <exclude name="**/package.html"/>
+ <exclude name="**/*.properties"/> <!-- copied and/or filtered into bin -->
+ </fileset>
+ <fileset dir="core/super" excludes="**/package.html" />
+ <fileset dir="${javac.out}" />
+ <fileset dir="${project.build}/bin" />
+ <fileset file="${project.build}/alldeps.jar" />
+ <fileset dir="${gwt.tools.soyc}/images"/>
+ <fileset file="${gwt.tools.soyc}/classLevel.css"/>
+ <fileset file="${gwt.tools.soyc}/roundedCorners.css"/>
+ </sourcefiles>
+ <targetfiles>
+ <fileset file="${project.lib}"/>
+ </targetfiles>
+ <sequential>
+ <gwt.jar>
+ <fileset dir="oophm/src" excludes="**/package.html"/>
+ <fileset dir="oophm/overlay" excludes="**/package.html"/>
+ <fileset dir="core/src">
+ <exclude name="**/package.html"/>
+ <exclude name="**/*.properties"/> <!-- copied and/or filtered into bin -->
+ </fileset>
+ <fileset dir="core/super" excludes="**/package.html" />
+ <fileset dir="${javac.out}" />
+ <zipfileset src="${alldeps.jar}" />
+
+ <zipfileset dir="${gwt.tools.soyc}/images" prefix="com/google/gwt/soyc/resources/images"/>
+ <zipfileset file="${gwt.tools.soyc}/classLevel.css" prefix="com/google/gwt/soyc/resources/"/>
+ <zipfileset file="${gwt.tools.soyc}/roundedCorners.css" prefix="com/google/gwt/soyc/resources/"/>
+
+ <manifest>
+ <attribute name="Main-Class" value="com.google.gwt.dev.GWTMain" />
+ </manifest>
+ </gwt.jar>
+ </sequential>
+ </outofdate>
+ </target>
</project>
diff --git a/dev/core/build.xml b/dev/core/build.xml
index 4bdbd75..1a34b89 100755
--- a/dev/core/build.xml
+++ b/dev/core/build.xml
@@ -10,6 +10,8 @@
<target name="compile.tests" depends="build, compile.emma" description="Compiles the test code for this project">
<mkdir dir="${javac.junit.out}" />
<gwt.javac srcdir="test" destdir="${javac.junit.out}">
+ <src path="../oophm/src" />
+ <src path="../oophm/overlay" />
<classpath>
<pathelement location="${javac.out}" />
<pathelement location="${alldeps.jar}" />
@@ -69,6 +71,7 @@
<include name="xerces/xerces-2_9_1/xml-apis.jar" />
<include name="w3c/sac/sac-1.3.jar" />
<!-- htmlunit dependencies not already included: END -->
+ <include name="sun/swingworker/swing-worker-1.1.jar" />
</fileset>
<fileset file="build.xml"/>
</sourcefiles>
@@ -123,6 +126,7 @@
<zipfileset src="${gwt.tools.lib}/xerces/xerces-2_9_1/xml-apis.jar" />
<zipfileset src="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
<!-- htmlunit dependencies not already included: END -->
+ <zipfileset src="${gwt.tools.lib}/sun/swingworker/swing-worker-1.1.jar" />
</gwt.jar>
</sequential>
</outofdate>
@@ -165,23 +169,10 @@
</target>
<target name="build" depends="compiler.standalone, build.alldeps.jar" description="Compiles this project">
- <!--
- There are classes missing from dev/core that are necessary
- to compile the rest of dev/core (e.g. BootStrapPlatform); these are
- provided by each platform implementation, but in order to compile the
- core standalone, we need a dummy version of the class to build against.
- -->
- <property name="javac.out-dummy" location="${project.build}/bin-dummy" />
- <mkdir dir="${javac.out-dummy}" />
- <gwt.javac srcdir="src-dummy" destdir="${javac.out-dummy}" />
-
- <gwt.javac srcdir="src" excludes="${filter.pattern}">
+ <gwt.javac srcdir="src:../oophm/overlay:../oophm/src" excludes="${filter.pattern}">
<classpath>
- <pathelement location="${javac.out-dummy}" />
<pathelement location="${alldeps.jar}" />
<pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
- <!-- Must build against a version of SWT; just pick one -->
- <pathelement location="${gwt.tools.lib}/eclipse/org.eclipse.swt.gtk-linux-3.2.1.jar" />
</classpath>
</gwt.javac>
<copy todir="${javac.out}">
diff --git a/dev/core/src-dummy/com/google/gwt/dev/BootStrapPlatform.java b/dev/core/src-dummy/com/google/gwt/dev/BootStrapPlatform.java
deleted file mode 100644
index 3d2fc28..0000000
--- a/dev/core/src-dummy/com/google/gwt/dev/BootStrapPlatform.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-/**
- * This is a dummy version of the class. It only exists so that dev/core can be
- * compiled indepedently. This class is replaced by a platform-specific version.
- */
-public class BootStrapPlatform {
-
- public static void applyPlatformHacks() {
- // nothing to do
- }
-
- public static void initGui() {
- // nothing to do
- }
-
- public static void initHostedMode() {
- // nothing to do.
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java b/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java
index 02f8348..4156ae4 100644
--- a/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java
+++ b/dev/core/src/com/google/gwt/dev/CompileTaskRunner.java
@@ -17,7 +17,7 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.shell.log.DetachedTreeLoggerWindow;
+import com.google.gwt.dev.shell.log.SwingLoggerPanel;
import com.google.gwt.dev.util.log.AbstractTreeLogger;
import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
@@ -43,11 +43,11 @@
// Set any platform specific system properties.
BootStrapPlatform.applyPlatformHacks();
- if (options.isUseGuiLogger()) {
+ // TODO(jat): add support for GUI logger back
+ if (false && options.isUseGuiLogger()) {
// Initialize a tree logger window.
- DetachedTreeLoggerWindow loggerWindow = DetachedTreeLoggerWindow.getInstance(
- "Build Output for " + options.getModuleNames(), 800, 600, true,
- options.getLogLevel());
+ SwingLoggerPanel loggerWindow = new SwingLoggerPanel(
+ options.getLogLevel(), null);
// Eager AWT initialization for OS X to ensure safe coexistence with SWT.
BootStrapPlatform.initGui();
@@ -66,8 +66,8 @@
compilerThread.setName("GWTCompiler Thread");
compilerThread.start();
- loggerWindow.run();
-
+ // TODO(jat): create an app frame for loggerWindow
+
// Even if the tree logger window is closed, we wait for the compiler
// to finish.
waitForThreadToTerminate(compilerThread);
diff --git a/dev/core/src/com/google/gwt/dev/GWTShell.java b/dev/core/src/com/google/gwt/dev/GWTShell.java
deleted file mode 100644
index 53924db..0000000
--- a/dev/core/src/com/google/gwt/dev/GWTShell.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.core.ext.linker.EmittedArtifact;
-import com.google.gwt.dev.GWTCompiler.GWTCompilerOptionsImpl;
-import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.dev.shell.ArtifactAcceptor;
-import com.google.gwt.dev.shell.WorkDirs;
-import com.google.gwt.dev.shell.tomcat.EmbeddedTomcatServer;
-import com.google.gwt.dev.util.Util;
-import com.google.gwt.dev.util.arg.ArgHandlerOutDir;
-import com.google.gwt.util.tools.ArgHandlerExtra;
-import com.google.gwt.util.tools.ToolBase;
-
-import java.io.File;
-
-/**
- * The main executable class for the hosted mode shell.
- *
- * @deprecated Use {@link HostedMode} instead
- */
-@Deprecated
-public class GWTShell extends SwtHostedModeBase {
-
- /**
- * Handles the list of startup urls that can be passed at the end of the
- * command line.
- */
- protected static class ArgHandlerStartupURLsExtra extends ArgHandlerExtra {
-
- private final OptionStartupURLs options;
-
- public ArgHandlerStartupURLsExtra(OptionStartupURLs options) {
- this.options = options;
- }
-
- @Override
- public boolean addExtraArg(String arg) {
- options.addStartupURL(arg);
- return true;
- }
-
- @Override
- public String getPurpose() {
- return "Automatically launches the specified URL";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"url"};
- }
- }
-
- /**
- * The GWTShell argument processor.
- */
- protected static class ArgProcessor extends HostedModeBase.ArgProcessor {
- public ArgProcessor(ShellOptionsImpl options, boolean forceServer,
- boolean noURLs) {
- super(options, forceServer);
- if (!noURLs) {
- registerHandler(new ArgHandlerStartupURLsExtra(options));
- }
- registerHandler(new ArgHandlerOutDir(options));
- }
-
- @Override
- protected String getName() {
- return GWTShell.class.getName();
- }
- }
-
- /**
- * Concrete class to implement all shell options.
- */
- static class ShellOptionsImpl extends HostedModeBaseOptionsImpl implements
- HostedModeBaseOptions, WorkDirs, LegacyCompilerOptions {
- private int localWorkers;
- private File outDir;
-
- public File getCompilerOutputDir(ModuleDef moduleDef) {
- return new File(getOutDir(), moduleDef.getName());
- }
-
- public int getLocalWorkers() {
- return localWorkers;
- }
-
- public File getOutDir() {
- if (System.getProperty("com.google.gwt.shell.outdir") != null) {
- // deprecated old property way to set outputs
- return new File(System.getProperty("com.google.gwt.shell.outdir"));
- }
- return outDir;
- }
-
- public File getShellPublicGenDir(ModuleDef moduleDef) {
- return new File(getShellBaseWorkDir(moduleDef), "public");
- }
-
- @Override
- public File getWorkDir() {
- return new File(getOutDir(), ".gwt-tmp");
- }
-
- public void setLocalWorkers(int localWorkers) {
- this.localWorkers = localWorkers;
- }
-
- public void setOutDir(File outDir) {
- this.outDir = outDir;
- }
- }
-
- public static void main(String[] args) {
- ToolBase.legacyWarn(GWTShell.class, HostedMode.class);
-
- /*
- * NOTE: main always exits with a call to System.exit to terminate any
- * non-daemon threads that were started in Generators. Typically, this is to
- * shutdown AWT related threads, since the contract for their termination is
- * still implementation-dependent.
- */
- GWTShell gwtShell = new GWTShell();
- ArgProcessor argProcessor = new ArgProcessor(gwtShell.options, false, false);
-
- if (argProcessor.processArgs(args)) {
- gwtShell.run();
- // Exit w/ success code.
- System.exit(0);
- }
- // Exit w/ non-success code.
- System.exit(-1);
- }
-
- /**
- * Hiding super field because it's actually the same object, just with a
- * stronger type.
- */
- @SuppressWarnings("hiding")
- protected final ShellOptionsImpl options = (ShellOptionsImpl) super.options;
-
- public LegacyCompilerOptions getCompilerOptions() {
- return new GWTCompilerOptionsImpl(options);
- }
-
- public WebServerRestart hasWebServer() {
- return WebServerRestart.NONE;
- }
-
- public void restartServer(TreeLogger logger) throws UnableToCompleteException {
- // Unimplemented.
- }
-
- public void setCompilerOptions(CompilerOptions options) {
- this.options.copyFrom(options);
- }
-
- @Override
- protected void compile(TreeLogger logger) throws UnableToCompleteException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Compiles a logical module def. The caller can modify the specified module
- * def programmatically in some cases (this is needed for JUnit support, for
- * example).
- */
- @Override
- protected void compile(TreeLogger logger, ModuleDef moduleDef)
- throws UnableToCompleteException {
- LegacyCompilerOptions newOptions = new GWTCompilerOptionsImpl(options);
- newOptions.setCompilationStateRetained(true);
- if (!new GWTCompiler(newOptions).run(logger, moduleDef)) {
- throw new UnableToCompleteException();
- }
- }
-
- @Override
- protected HostedModeBaseOptions createOptions() {
- return new ShellOptionsImpl();
- }
-
- @Override
- protected ArtifactAcceptor doCreateArtifactAcceptor(final ModuleDef module) {
- return new ArtifactAcceptor() {
- public void accept(TreeLogger logger, ArtifactSet artifacts)
- throws UnableToCompleteException {
-
- /*
- * Copied from StandardLinkerContext.produceOutputDirectory() for legacy
- * GWTShellServlet support.
- */
- for (EmittedArtifact artifact : artifacts.find(EmittedArtifact.class)) {
- if (!artifact.isPrivate()) {
- File outFile = new File(options.getShellPublicGenDir(module),
- artifact.getPartialPath());
- Util.copy(logger, artifact.getContents(logger), outFile);
- }
- }
- }
- };
- }
-
- @Override
- protected void doShutDownServer() {
- // Stop the HTTP server.
- //
- EmbeddedTomcatServer.stop();
- }
-
- @Override
- protected int doStartUpServer() {
- // TODO(bruce): make tomcat work in terms of the modular launcher
- String whyFailed = EmbeddedTomcatServer.start(getTopLogger(), getPort(),
- options, shouldAutoGenerateResources());
-
- // TODO(bruce): test that we can remove this old approach in favor of
- // a better, logger-based error reporting
- if (whyFailed != null) {
- System.err.println(whyFailed);
- return -1;
- }
- return EmbeddedTomcatServer.getPort();
- }
-
- @Override
- protected String getTitleText() {
- return "Google Web Toolkit Development Shell";
- }
-
- @Override
- protected boolean initModule(String moduleName) {
- /*
- * Not used in legacy mode due to GWTShellServlet playing this role.
- *
- * TODO: something smarter here and actually make GWTShellServlet less
- * magic?
- */
- return false;
- }
-
- /**
- * Whether this shell should auto-generate GWT resources when it recognizes
- * requests for them. By default this is true. Subclasses can disable such
- * auto-generation and make this servlet appear to be like any arbitrary web
- * server that knows nothing about GWT.
- */
- protected boolean shouldAutoGenerateResources() {
- return true;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/HostedMode.java b/dev/core/src/com/google/gwt/dev/HostedMode.java
deleted file mode 100644
index 83d8800..0000000
--- a/dev/core/src/com/google/gwt/dev/HostedMode.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-import com.google.gwt.core.ext.ServletContainer;
-import com.google.gwt.core.ext.ServletContainerLauncher;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.core.ext.linker.impl.StandardLinkerContext;
-import com.google.gwt.dev.Compiler.CompilerOptionsImpl;
-import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.dev.shell.ArtifactAcceptor;
-import com.google.gwt.dev.shell.jetty.JettyLauncher;
-import com.google.gwt.dev.util.InstalledHelpInfo;
-import com.google.gwt.dev.util.Util;
-import com.google.gwt.dev.util.arg.ArgHandlerExtraDir;
-import com.google.gwt.dev.util.arg.ArgHandlerLocalWorkers;
-import com.google.gwt.dev.util.arg.ArgHandlerModuleName;
-import com.google.gwt.dev.util.arg.ArgHandlerWarDir;
-import com.google.gwt.dev.util.arg.ArgHandlerWorkDirOptional;
-import com.google.gwt.util.tools.ArgHandlerString;
-import com.google.gwt.util.tools.Utility;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.BindException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The main executable class for the hosted mode shell. NOTE: the public API for
- * this class is to be determined. Consider this class as having <b>no</b>
- * public API other than {@link #main(String[])}.
- */
-public class HostedMode extends SwtHostedModeBase {
-
- /**
- * Handles the -server command line flag.
- */
- protected static class ArgHandlerServer extends ArgHandlerString {
- private HostedModeOptions options;
-
- public ArgHandlerServer(HostedModeOptions options) {
- this.options = options;
- }
-
- @Override
- public String[] getDefaultArgs() {
- if (options.isNoServer()) {
- return null;
- } else {
- return new String[] {getTag(), JettyLauncher.class.getName()};
- }
- }
-
- @Override
- public String getPurpose() {
- return "Specifies a different embedded web server to run (must implement ServletContainerLauncher)";
- }
-
- @Override
- public String getTag() {
- return "-server";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"servletContainerLauncher"};
- }
-
- @Override
- public boolean setString(String sclClassName) {
- // Supercedes -noserver.
- options.setNoServer(false);
- Throwable t;
- try {
- Class<?> clazz = Class.forName(sclClassName, true,
- Thread.currentThread().getContextClassLoader());
- Class<? extends ServletContainerLauncher> sclClass = clazz.asSubclass(ServletContainerLauncher.class);
- options.setServletContainerLauncher(sclClass.newInstance());
- return true;
- } catch (ClassCastException e) {
- t = e;
- } catch (ClassNotFoundException e) {
- t = e;
- } catch (InstantiationException e) {
- t = e;
- } catch (IllegalAccessException e) {
- t = e;
- }
- System.err.println("Unable to load server class '" + sclClassName + "'");
- t.printStackTrace();
- return false;
- }
- }
-
- /**
- * Handles a startup url that can be passed on the command line.
- */
- protected static class ArgHandlerStartupURLs extends ArgHandlerString {
- private final OptionStartupURLs options;
-
- public ArgHandlerStartupURLs(OptionStartupURLs options) {
- this.options = options;
- }
-
- @Override
- public String getPurpose() {
- return "Automatically launches the specified URL";
- }
-
- @Override
- public String getTag() {
- return "-startupUrl";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"url"};
- }
-
- @Override
- public boolean setString(String arg) {
- options.addStartupURL(arg);
- return true;
- }
- }
-
- static class ArgProcessor extends HostedModeBase.ArgProcessor {
- public ArgProcessor(HostedModeOptions options) {
- super(options, false);
- registerHandler(new ArgHandlerServer(options));
- registerHandler(new ArgHandlerStartupURLs(options));
- registerHandler(new ArgHandlerWarDir(options));
- registerHandler(new ArgHandlerExtraDir(options));
- registerHandler(new ArgHandlerWorkDirOptional(options));
- registerHandler(new ArgHandlerLocalWorkers(options));
- registerHandler(new ArgHandlerModuleName(options) {
- @Override
- public String getPurpose() {
- return super.getPurpose() + " to host";
- }
- });
- }
-
- @Override
- protected String getName() {
- return HostedMode.class.getName();
- }
- }
-
- interface HostedModeOptions extends HostedModeBaseOptions, CompilerOptions {
- ServletContainerLauncher getServletContainerLauncher();
-
- void setServletContainerLauncher(ServletContainerLauncher scl);
- }
-
- /**
- * Concrete class to implement all hosted mode options.
- */
- static class HostedModeOptionsImpl extends HostedModeBaseOptionsImpl
- implements HostedModeOptions {
- private File extraDir;
- private int localWorkers;
- private File outDir;
- private ServletContainerLauncher scl;
- private File warDir;
-
- public File getExtraDir() {
- return extraDir;
- }
-
- public int getLocalWorkers() {
- return localWorkers;
- }
-
- @Deprecated
- public File getOutDir() {
- return outDir;
- }
-
- public ServletContainerLauncher getServletContainerLauncher() {
- return scl;
- }
-
- public File getShellBaseWorkDir(ModuleDef moduleDef) {
- return new File(new File(getWorkDir(), moduleDef.getName()), "shell");
- }
-
- public File getShellPublicGenDir(ModuleDef moduleDef) {
- return new File(getShellBaseWorkDir(moduleDef), "public");
- }
-
- public File getWarDir() {
- return warDir;
- }
-
- public void setExtraDir(File extraDir) {
- this.extraDir = extraDir;
- }
-
- public void setLocalWorkers(int localWorkers) {
- this.localWorkers = localWorkers;
- }
-
- @Deprecated
- public void setOutDir(File outDir) {
- this.outDir = outDir;
- }
-
- public void setServletContainerLauncher(ServletContainerLauncher scl) {
- this.scl = scl;
- }
-
- public void setWarDir(File warDir) {
- this.warDir = warDir;
- }
- }
-
- public static void main(String[] args) {
- /*
- * NOTE: main always exits with a call to System.exit to terminate any
- * non-daemon threads that were started in Generators. Typically, this is to
- * shutdown AWT related threads, since the contract for their termination is
- * still implementation-dependent.
- */
- HostedMode hostedMode = new HostedMode();
- if (new ArgProcessor(hostedMode.options).processArgs(args)) {
- hostedMode.run();
- // Exit w/ success code.
- System.exit(0);
- }
- // Exit w/ non-success code.
- System.exit(-1);
- }
-
- /**
- * Hiding super field because it's actually the same object, just with a
- * stronger type.
- */
- @SuppressWarnings("hiding")
- protected final HostedModeOptionsImpl options = (HostedModeOptionsImpl) super.options;
-
- /**
- * Maps each active linker stack by module.
- */
- private final Map<String, StandardLinkerContext> linkerStacks = new HashMap<String, StandardLinkerContext>();
-
- /**
- * The set of specified modules by name; the keys represent the renamed name
- * of each module rather than the canonical name.
- */
- private Map<String, ModuleDef> modulesByName = new HashMap<String, ModuleDef>();
-
- /**
- * The server that was started.
- */
- private ServletContainer server;
-
- /**
- * Tracks whether we created a temp workdir that we need to destroy.
- */
- private boolean tempWorkDir = false;
-
- /**
- * Default constructor for testing; no public API yet.
- */
- HostedMode() {
- }
-
- public WebServerRestart hasWebServer() {
- return options.isNoServer() ? WebServerRestart.DISABLED
- : WebServerRestart.ENABLED;
- }
-
- public void restartServer(TreeLogger logger) throws UnableToCompleteException {
- server.refresh();
- }
-
- @Override
- protected void compile(TreeLogger logger) throws UnableToCompleteException {
- CompilerOptions newOptions = new CompilerOptionsImpl(options);
- newOptions.setCompilationStateRetained(true);
- new Compiler(newOptions).run(logger);
- }
-
- @Deprecated
- @Override
- protected void compile(TreeLogger logger, ModuleDef moduleDef)
- throws UnableToCompleteException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected HostedModeBaseOptions createOptions() {
- return new HostedModeOptionsImpl();
- }
-
- @Override
- protected ArtifactAcceptor doCreateArtifactAcceptor(final ModuleDef module) {
- return new ArtifactAcceptor() {
- public void accept(TreeLogger logger, ArtifactSet newlyGeneratedArtifacts)
- throws UnableToCompleteException {
- relink(logger, module, newlyGeneratedArtifacts);
- }
- };
- }
-
- @Override
- protected void doShutDownServer() {
- if (server != null) {
- try {
- server.stop();
- } catch (UnableToCompleteException e) {
- // Already logged.
- }
- server = null;
- }
-
- if (tempWorkDir) {
- Util.recursiveDelete(options.getWorkDir(), false);
- }
- }
-
- @Override
- protected boolean doStartup() {
- if (!super.doStartup()) {
- return false;
- }
- tempWorkDir = options.getWorkDir() == null;
- if (tempWorkDir) {
- try {
- options.setWorkDir(Utility.makeTemporaryDirectory(null, "gwtc"));
- } catch (IOException e) {
- System.err.println("Unable to create hosted mode work directory");
- e.printStackTrace();
- return false;
- }
- }
-
- ServletValidator servletValidator = null;
- File webXml = new File(options.getWarDir(), "WEB-INF/web.xml");
- if (webXml.exists()) {
- servletValidator = ServletValidator.create(getTopLogger(), webXml);
- }
-
- for (String moduleName : options.getModuleNames()) {
- TreeLogger loadLogger = getTopLogger().branch(TreeLogger.DEBUG,
- "Bootstrap link for command-line module '" + moduleName + "'");
- try {
- ModuleDef module = loadModule(loadLogger, moduleName, false);
- validateServletTags(loadLogger, servletValidator, module, webXml);
- link(loadLogger, module);
- } catch (UnableToCompleteException e) {
- // Already logged.
- return false;
- }
- }
- return true;
- }
-
- @Override
- protected int doStartUpServer() {
- try {
- server = options.getServletContainerLauncher().start(getTopLogger(),
- getPort(), options.getWarDir());
- assert (server != null);
- return server.getPort();
- } catch (BindException e) {
- System.err.println("Port "
- + getPort()
- + " is already is use; you probably still have another session active");
- } catch (Exception e) {
- System.err.println("Unable to start embedded HTTP server");
- e.printStackTrace();
- }
- return -1;
- }
-
- @Override
- protected String getHost() {
- if (server != null) {
- return server.getHost();
- }
- return super.getHost();
- }
-
- @Override
- protected String getTitleText() {
- return "Google Web Toolkit Hosted Mode";
- }
-
- @Override
- protected boolean initModule(String moduleName) {
- ModuleDef module = modulesByName.get(moduleName);
- if (module == null) {
- getTopLogger().log(
- TreeLogger.WARN,
- "Unknown module requested '"
- + moduleName
- + "'; all active GWT modules must be specified in the command line arguments");
- return false;
- }
- try {
- TreeLogger logger = getTopLogger().branch(TreeLogger.DEBUG,
- "Initializing module '" + module.getName() + "' for hosted mode");
- boolean shouldRefreshPage = false;
- if (module.isGwtXmlFileStale()) {
- shouldRefreshPage = true;
- module = loadModule(logger, module.getCanonicalName(), false);
- }
- link(logger, module);
- return shouldRefreshPage;
- } catch (UnableToCompleteException e) {
- // Already logged.
- return false;
- }
- }
-
- /*
- * Overridden to keep our map up to date.
- */
- @Override
- protected ModuleDef loadModule(TreeLogger logger, String moduleName,
- boolean refresh) throws UnableToCompleteException {
- ModuleDef module = super.loadModule(logger, moduleName, refresh);
- modulesByName.put(module.getName(), module);
- return module;
- }
-
- /**
- * Perform an initial hosted mode link, without overwriting newer or
- * unmodified files in the output folder.
- *
- * @param logger the logger to use
- * @param module the module to link
- * @param includePublicFiles if <code>true</code>, include public files in
- * the link, otherwise do not include them
- * @throws UnableToCompleteException
- */
- private void link(TreeLogger logger, ModuleDef module)
- throws UnableToCompleteException {
- TreeLogger linkLogger = logger.branch(TreeLogger.DEBUG, "Linking module '"
- + module.getName() + "'");
-
- // Create a new active linker stack for the fresh link.
- StandardLinkerContext linkerStack = new StandardLinkerContext(linkLogger,
- module, options);
- linkerStacks.put(module.getName(), linkerStack);
-
- ArtifactSet artifacts = linkerStack.invokeLink(linkLogger);
- produceOutput(linkLogger, linkerStack, artifacts, module);
- }
-
- private void produceOutput(TreeLogger logger,
- StandardLinkerContext linkerStack, ArtifactSet artifacts, ModuleDef module)
- throws UnableToCompleteException {
- File moduleOutDir = new File(options.getWarDir(), module.getName());
- linkerStack.produceOutputDirectory(logger, artifacts, moduleOutDir);
- if (options.getExtraDir() != null) {
- File moduleExtraDir = new File(options.getExtraDir(), module.getName());
- linkerStack.produceExtraDirectory(logger, artifacts, moduleExtraDir);
- }
- }
-
- /**
- * Perform hosted mode relink when new artifacts are generated, without
- * overwriting newer or unmodified files in the output folder.
- *
- * @param logger the logger to use
- * @param module the module to link
- * @param newlyGeneratedArtifacts the set of new artifacts
- * @throws UnableToCompleteException
- */
- private void relink(TreeLogger logger, ModuleDef module,
- ArtifactSet newlyGeneratedArtifacts) throws UnableToCompleteException {
- TreeLogger linkLogger = logger.branch(TreeLogger.DEBUG,
- "Relinking module '" + module.getName() + "'");
-
- // Find the existing linker stack.
- StandardLinkerContext linkerStack = linkerStacks.get(module.getName());
- assert linkerStack != null;
-
- ArtifactSet artifacts = linkerStack.invokeRelink(linkLogger,
- newlyGeneratedArtifacts);
- produceOutput(linkLogger, linkerStack, artifacts, module);
- }
-
- private void validateServletTags(TreeLogger logger,
- ServletValidator servletValidator, ModuleDef module, File webXml) {
- TreeLogger servletLogger = logger.branch(TreeLogger.DEBUG,
- "Validating <servlet> tags for module '" + module.getName() + "'",
- null, new InstalledHelpInfo("servletMappings.html"));
- String[] servletPaths = module.getServletPaths();
- if (servletValidator == null && servletPaths.length > 0) {
- servletLogger.log(
- TreeLogger.WARN,
- "Module declares "
- + servletPaths.length
- + " <servlet> declaration(s), but a valid 'web.xml' was not found at '"
- + webXml.getAbsolutePath() + "'");
- } else {
- for (String servletPath : servletPaths) {
- String servletClass = module.findServletForPath(servletPath);
- assert (servletClass != null);
- // Prefix module name to convert module mapping to global mapping.
- servletPath = "/" + module.getName() + servletPath;
- servletValidator.validate(servletLogger, servletClass, servletPath);
- }
- }
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/HostedModeBase.java b/dev/core/src/com/google/gwt/dev/HostedModeBase.java
index 44fd711..aea57f1 100644
--- a/dev/core/src/com/google/gwt/dev/HostedModeBase.java
+++ b/dev/core/src/com/google/gwt/dev/HostedModeBase.java
@@ -23,7 +23,6 @@
import com.google.gwt.dev.cfg.ModuleDefLoader;
import com.google.gwt.dev.jjs.JJSOptions;
import com.google.gwt.dev.shell.ArtifactAcceptor;
-import com.google.gwt.dev.shell.BrowserWidget;
import com.google.gwt.dev.shell.BrowserWidgetHost;
import com.google.gwt.dev.shell.BrowserWidgetHostChecker;
import com.google.gwt.dev.shell.BrowserWindowController;
@@ -236,10 +235,6 @@
}
}
- public abstract ModuleSpaceHost createModuleSpaceHost(TreeLogger logger,
- BrowserWidget widget, String moduleName)
- throws UnableToCompleteException;
-
public TreeLogger getLogger() {
return getTopLogger();
}
@@ -256,11 +251,6 @@
public String normalizeURL(String whatTheUserTyped) {
return HostedModeBase.this.normalizeURL(whatTheUserTyped);
}
-
- public BrowserWidget openNewBrowserWindow()
- throws UnableToCompleteException {
- return HostedModeBase.this.openNewBrowserWindow();
- }
}
protected interface HostedModeBaseOptions extends JJSOptions, OptionLogDir,
@@ -538,8 +528,6 @@
protected abstract void doShutDownServer();
protected boolean doStartup() {
- loadRequiredNativeLibs();
-
// Create the main app window.
openAppWindow();
@@ -613,8 +601,6 @@
return moduleDef;
}
- protected abstract void loadRequiredNativeLibs();
-
protected abstract boolean notDone();
protected abstract void openAppWindow();
diff --git a/dev/core/src/com/google/gwt/dev/RunWebApp.java b/dev/core/src/com/google/gwt/dev/RunWebApp.java
deleted file mode 100644
index cd5896a..0000000
--- a/dev/core/src/com/google/gwt/dev/RunWebApp.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2009 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-import com.google.gwt.core.ext.ServletContainer;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.HostedModeBase.OptionPort;
-import com.google.gwt.dev.HostedModeBase.OptionStartupURLs;
-import com.google.gwt.dev.shell.BrowserWidget;
-import com.google.gwt.dev.shell.jetty.JettyLauncher;
-import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-import com.google.gwt.util.tools.ArgHandlerExtra;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * An experimental class for running web apps.
- */
-public class RunWebApp {
-
- interface RunWebAppOptions extends OptionStartupURLs, OptionPort {
- }
-
- static class RunWebAppOptionsImpl implements RunWebAppOptions {
- private int port;
- private final List<String> startupURLs = new ArrayList<String>();
-
- public void addStartupURL(String url) {
- startupURLs.add(url);
- }
-
- public int getPort() {
- return port;
- }
-
- public List<String> getStartupURLs() {
- return Collections.unmodifiableList(startupURLs);
- }
-
- public void setPort(int port) {
- this.port = port;
- }
- }
-
- private class ArgHandlerWar extends ArgHandlerExtra {
- @Override
- public boolean addExtraArg(String arg) {
- warFile = new File(arg);
- if (!warFile.exists()) {
- System.err.println("Could not open war file '"
- + warFile.getAbsolutePath() + "'");
- return false;
- }
- return true;
- }
-
- @Override
- public String getPurpose() {
- return "Specifies the location of the target .war file or war directory";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"war"};
- }
-
- @Override
- public boolean isRequired() {
- return true;
- }
- }
-
- private class ArgProcessor extends ArgProcessorBase {
- public ArgProcessor(RunWebAppOptions options) {
- registerHandler(new HostedMode.ArgHandlerStartupURLs(options));
- registerHandler(new HostedModeBase.ArgHandlerPort(options));
- registerHandler(new ArgHandlerWar());
- }
-
- @Override
- protected String getName() {
- return RunWebApp.class.getName();
- }
- }
-
- public static void main(String[] args) {
- try {
- RunWebAppOptionsImpl options = new RunWebAppOptionsImpl();
- RunWebApp runWebApp = new RunWebApp(options);
- ArgProcessor argProcessor = runWebApp.new ArgProcessor(options);
- if (argProcessor.processArgs(args)) {
- runWebApp.run();
- }
- } catch (Exception e) {
- System.err.println("Unable to start Jetty server");
- e.printStackTrace();
- }
- }
-
- protected File warFile;
-
- private final RunWebAppOptions options;
-
- public RunWebApp(RunWebAppOptions options) {
- this.options = options;
- }
-
- protected void run() {
- PrintWriterTreeLogger logger = new PrintWriterTreeLogger();
- logger.setMaxDetail(TreeLogger.WARN);
- int port = options.getPort();
- try {
- ServletContainer scl = new JettyLauncher().start(logger, port, warFile);
- port = scl.getPort();
- } catch (Exception e) {
- System.err.println("Unable to start Jetty server");
- e.printStackTrace();
- return;
- }
- if (options.getStartupURLs().isEmpty()) {
- options.addStartupURL("/");
- }
- for (String startupUrl : options.getStartupURLs()) {
- startupUrl = HostedModeBase.normalizeURL(startupUrl, port, "localhost");
- BrowserWidget.launchExternalBrowser(logger, startupUrl);
- }
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/SwtHostedModeBase.java b/dev/core/src/com/google/gwt/dev/SwtHostedModeBase.java
deleted file mode 100644
index 38ee586..0000000
--- a/dev/core/src/com/google/gwt/dev/SwtHostedModeBase.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.dev.shell.BrowserWidget;
-import com.google.gwt.dev.shell.BrowserWidgetHost;
-import com.google.gwt.dev.shell.ModuleSpaceHost;
-import com.google.gwt.dev.shell.ShellMainWindow;
-import com.google.gwt.dev.shell.ShellModuleSpaceHost;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
-import com.google.gwt.util.tools.ToolBase;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.Library;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The main executable class for hosted mode shells based on SWT.
- */
-abstract class SwtHostedModeBase extends HostedModeBase {
-
- private class SwtBrowserWidgetHostImpl extends BrowserWidgetHostImpl {
-
- @Override
- public ModuleSpaceHost createModuleSpaceHost(TreeLogger logger,
- BrowserWidget widget, String moduleName)
- throws UnableToCompleteException {
- // Switch to a wait cursor.
- Shell widgetShell = widget.getShell();
- try {
- Cursor waitCursor = display.getSystemCursor(SWT.CURSOR_WAIT);
- widgetShell.setCursor(waitCursor);
-
- // Try to find an existing loaded version of the module def.
- //
- ModuleDef moduleDef = loadModule(logger, moduleName, true);
- assert (moduleDef != null);
-
- TypeOracle typeOracle = moduleDef.getTypeOracle(logger);
- ShellModuleSpaceHost host = doCreateShellModuleSpaceHost(
- getTopLogger(), typeOracle, moduleDef);
- return host;
- } finally {
- Cursor normalCursor = display.getSystemCursor(SWT.CURSOR_ARROW);
- widgetShell.setCursor(normalCursor);
- }
- }
-
- public ModuleSpaceHost createModuleSpaceHost(TreeLogger logger,
- String moduleName, String userAgent, String url, String tabKey,
- String sessionKey, String remoteEndpoint)
- throws UnableToCompleteException {
- throw new UnsupportedOperationException();
- }
-
- public void unloadModule(ModuleSpaceHost moduleSpaceHost) {
- throw new UnsupportedOperationException();
- }
- }
-
- /**
- * All of these classes must extend BrowserWidget. The first one that loads
- * will be used, so it is important that only the correct one be on the
- * classpath.
- */
- private static final String[] browserClassNames = new String[] {
- "com.google.gwt.dev.shell.ie.BrowserWidgetIE6",
- "com.google.gwt.dev.shell.moz.BrowserWidgetMoz",
- "com.google.gwt.dev.shell.mac.BrowserWidgetSaf"};
-
- static {
- // Force ToolBase to clinit, which causes SWT stuff to happen.
- new ToolBase() {
- };
- // Correct menu on Mac OS X
- Display.setAppName("GWT");
- }
-
- private static BrowserWidget createBrowserWidget(TreeLogger logger,
- Composite parent, BrowserWidgetHost host)
- throws UnableToCompleteException {
- Throwable caught = null;
- try {
- for (int i = 0; i < browserClassNames.length; i++) {
- Class<? extends BrowserWidget> clazz = null;
- try {
- clazz = Class.forName(browserClassNames[i]).asSubclass(
- BrowserWidget.class);
- Constructor<? extends BrowserWidget> ctor = clazz.getDeclaredConstructor(new Class[] {
- Shell.class, BrowserWidgetHost.class});
- BrowserWidget bw = ctor.newInstance(new Object[] {parent, host});
- return bw;
- } catch (ClassNotFoundException e) {
- caught = e;
- }
- }
- logger.log(TreeLogger.ERROR,
- "No instantiable browser widget class could be found", caught);
- throw new UnableToCompleteException();
- } catch (SecurityException e) {
- caught = e;
- } catch (NoSuchMethodException e) {
- caught = e;
- } catch (IllegalArgumentException e) {
- caught = e;
- } catch (InstantiationException e) {
- caught = e;
- } catch (IllegalAccessException e) {
- caught = e;
- } catch (InvocationTargetException e) {
- caught = e.getTargetException();
- } catch (ClassCastException e) {
- caught = e;
- }
- logger.log(TreeLogger.ERROR,
- "The browser widget class could not be instantiated", caught);
- throw new UnableToCompleteException();
- }
-
- private BrowserWidgetHostImpl browserHost = new SwtBrowserWidgetHostImpl();
-
- private final List<Shell> browserShells = new ArrayList<Shell>();
-
- /**
- * Use the default display; constructing a new one would make instantiating
- * multiple GWTShells fail with a mysterious exception.
- */
- private final Display display = Display.getDefault();
-
- private ShellMainWindow mainWnd;
-
- public SwtHostedModeBase() {
- super();
- }
-
- @Override
- public final void closeAllBrowserWindows() {
- while (!browserShells.isEmpty()) {
- browserShells.get(0).dispose();
- }
- }
-
- @Override
- public TreeLogger getTopLogger() {
- return mainWnd.getLogger();
- }
-
- @Override
- public final boolean hasBrowserWindowsOpen() {
- if (browserShells.isEmpty()) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Launch the arguments as Urls in separate windows.
- */
- @Override
- public void launchStartupUrls(final TreeLogger logger) {
- // Launch a browser window for each startup url.
- String startupURL = "";
- try {
- for (String prenormalized : options.getStartupURLs()) {
- startupURL = normalizeURL(prenormalized);
- logger.log(TreeLogger.TRACE, "Starting URL: " + startupURL, null);
- BrowserWidget bw = openNewBrowserWindow();
- bw.go(startupURL);
- }
- } catch (UnableToCompleteException e) {
- logger.log(TreeLogger.ERROR,
- "Unable to open new window for startup URL: " + startupURL, null);
- }
- }
-
- /**
- * Called directly by ShellMainWindow and indirectly via BrowserWidgetHost.
- */
- public final BrowserWidget openNewBrowserWindow()
- throws UnableToCompleteException {
- boolean succeeded = false;
- Shell s = createTrackedBrowserShell();
- try {
- BrowserWidget bw = createBrowserWidget(getTopLogger(), s, browserHost);
-
- if (mainWnd != null) {
- Rectangle r = mainWnd.getShell().getBounds();
- int n = browserShells.size() + 1;
- s.setBounds(r.x + n * 50, r.y + n * 50, 800, 600);
- } else {
- s.setSize(800, 600);
- }
-
- if (!isHeadless()) {
- s.open();
- }
-
- bw.onFirstShown();
- succeeded = true;
- return bw;
- } finally {
- if (!succeeded) {
- s.dispose();
- }
- }
- }
-
- protected final BrowserWidgetHost getBrowserHost() {
- return browserHost;
- }
-
- protected abstract String getTitleText();
-
- @Override
- protected void initializeLogger() {
- final AbstractTreeLogger logger = mainWnd.getLogger();
- logger.setMaxDetail(options.getLogLevel());
- }
-
- @Override
- protected void loadRequiredNativeLibs() {
- String libName = null;
- try {
- libName = "swt";
- Library.loadLibrary(libName);
- } catch (UnsatisfiedLinkError e) {
- StringBuffer sb = new StringBuffer();
- sb.append("Unable to load required native library '" + libName + "'");
- sb.append("\n\tPlease specify the JVM startup argument ");
- sb.append("\"-Djava.library.path\"");
- throw new RuntimeException(sb.toString(), e);
- }
- }
-
- @Override
- protected boolean notDone() {
- if (!mainWnd.isDisposed()) {
- return true;
- }
- if (!browserShells.isEmpty()) {
- return true;
- }
- return false;
- }
-
- @Override
- protected void openAppWindow() {
- final Shell shell = new Shell(display);
-
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginWidth = 0;
- fillLayout.marginHeight = 0;
- shell.setLayout(fillLayout);
-
- shell.setImages(ShellMainWindow.getIcons());
-
- mainWnd = new ShellMainWindow(this, shell, getTitleText(),
- options.isNoServer() ? 0 : getPort(),
- options.alsoLogToFile() ? options.getLogFile("hosted.log") : null,
- options.getLogLevel());
-
- shell.setSize(700, 600);
- if (!isHeadless()) {
- shell.open();
- }
- }
-
- @Override
- protected void processEvents() throws Exception {
- if (!display.readAndDispatch()) {
- sleep();
- }
- }
-
- protected void sleep() {
- display.sleep();
- }
-
- private Shell createTrackedBrowserShell() {
- final Shell shell = new Shell(display);
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginWidth = 0;
- fillLayout.marginHeight = 0;
- shell.setLayout(fillLayout);
- browserShells.add(shell);
- shell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (e.widget == shell) {
- browserShells.remove(shell);
- }
- }
- });
-
- shell.setImages(ShellMainWindow.getIcons());
-
- return shell;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserDialog.java b/dev/core/src/com/google/gwt/dev/shell/BrowserDialog.java
deleted file mode 100644
index 4ae9ab1..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserDialog.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import com.google.gwt.core.ext.TreeLogger;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.browser.LocationEvent;
-import org.eclipse.swt.browser.LocationListener;
-import org.eclipse.swt.browser.TitleEvent;
-import org.eclipse.swt.browser.TitleListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import java.net.URL;
-
-/**
- * A composite containing a browser widget.
- */
-public class BrowserDialog extends DialogBase {
-
- private final String html;
-
- private final URL url;
-
- private final TreeLogger logger;
-
- public BrowserDialog(Shell parent, TreeLogger logger, String html) {
- super(parent, 550, 520);
- this.logger = logger;
- this.html = html;
- this.url = null;
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Browser browser = new Browser(parent, SWT.BORDER);
-
- browser.addTitleListener(new TitleListener() {
- public void changed(TitleEvent event) {
- BrowserDialog.this.setText(event.title);
- }
- });
-
- if (html != null) {
- browser.setText(html);
- } else if (url != null) {
- browser.setUrl(url.toString());
- }
-
- browser.addLocationListener(new LocationListener() {
- public void changed(LocationEvent event) {
- }
-
- public void changing(LocationEvent event) {
- event.doit = false;
- BrowserWidget.launchExternalBrowser(logger, event.location);
- }
- });
-
- return browser;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java b/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java
deleted file mode 100644
index 50ed0e1..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java
+++ /dev/null
@@ -1,609 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.util.Util;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.browser.LocationEvent;
-import org.eclipse.swt.browser.LocationListener;
-import org.eclipse.swt.browser.OpenWindowListener;
-import org.eclipse.swt.browser.StatusTextEvent;
-import org.eclipse.swt.browser.StatusTextListener;
-import org.eclipse.swt.browser.TitleEvent;
-import org.eclipse.swt.browser.TitleListener;
-import org.eclipse.swt.browser.WindowEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolItem;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Represents an individual browser window and all of its controls.
- */
-public abstract class BrowserWidget extends Composite {
-
- private class Toolbar extends HeaderBarBase implements SelectionListener {
- private final ToolItem backButton;
-
- private final ToolItem forwardButton;
-
- private final ToolItem openWebModeButton;
-
- private final ToolItem refreshButton;
- private final ToolItem stopButton;
-
- public Toolbar(Composite parent) {
- super(parent);
-
- backButton = newItem("back.gif", " &Back ", "Go back one state");
- backButton.addSelectionListener(this);
-
- forwardButton = newItem("forward.gif", "&Forward", "Go forward one state");
- forwardButton.addSelectionListener(this);
-
- refreshButton = newItem("refresh.gif", " &Refresh ", "Reload the page");
- refreshButton.addSelectionListener(this);
-
- stopButton = newItem("stop.gif", " &Stop ", "Stop loading the page");
- stopButton.addSelectionListener(this);
-
- newSeparator();
-
- openWebModeButton = newItem("new-web-mode-window.gif", "&Compile/Browse",
- "Compiles and opens the current URL in the system browser");
- openWebModeButton.addSelectionListener(this);
- updateWebMode();
- }
-
- @Deprecated
- public void updateWebMode() {
- if (!openWebModeButton.isDisposed()) {
- if (getHost().isLegacyMode()) {
- openWebModeButton.setEnabled(!loadedModules.isEmpty());
- } else {
- openWebModeButton.setEnabled(true);
- }
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- @SuppressWarnings("deprecation")
- public void widgetSelected(SelectionEvent evt) {
- if (evt.widget == backButton) {
- browser.back();
- } else if (evt.widget == forwardButton) {
- browser.forward();
- } else if (evt.widget == refreshButton) {
- // we have to clean up old module spaces here b/c we don't get a
- // location changed event
-
- // lastHostPageLocation = null;
- browser.refresh();
- } else if (evt.widget == stopButton) {
- browser.stop();
- } else if (evt.widget == openWebModeButton) {
- // first, compile
- try {
- Cursor waitCursor = getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
- getShell().setCursor(waitCursor);
- if (getHost().isLegacyMode()) {
- Set<String> keySet = new HashSet<String>();
- for (Map.Entry<?, ModuleSpace> entry : loadedModules.entrySet()) {
- ModuleSpace module = entry.getValue();
- keySet.add(module.getModuleName());
- }
- String[] moduleNames = Util.toStringArray(keySet);
- if (moduleNames.length == 0) {
- // A latent problem with a module.
- //
- openWebModeButton.setEnabled(false);
- return;
- }
- getHost().compile(moduleNames);
- } else {
- getHost().compile();
- }
- } catch (UnableToCompleteException e) {
- // Already logged by callee.
- //
- MessageBox msgBox = new MessageBox(getShell(), SWT.OK
- | SWT.ICON_ERROR);
- msgBox.setText("Compilation Failed");
- msgBox.setMessage("Compilation failed. Please see the log in the development shell for details.");
- msgBox.open();
- return;
- } finally {
- // Restore the cursor.
- //
- Cursor normalCursor = getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
- getShell().setCursor(normalCursor);
- }
-
- String locationText = location.getText();
-
- launchExternalBrowser(logger, locationText);
- }
- }
- }
-
- public static void launchExternalBrowser(TreeLogger logger, String location) {
- String browserCmd = System.getenv("GWT_EXTERNAL_BROWSER");
- if (browserCmd != null) {
- browserCmd += " " + location;
- try {
- Runtime.getRuntime().exec(browserCmd);
- return;
- } catch (IOException e) {
- logger.log(TreeLogger.ERROR,
- "Error launching GWT_EXTERNAL_BROWSER executable '" + browserCmd
- + "'", e);
- return;
- }
- }
-
- // legacy: gwt.browser.default
- browserCmd = System.getProperty("gwt.browser.default");
- if (browserCmd != null) {
- browserCmd += " " + location;
- try {
- Runtime.getRuntime().exec(browserCmd);
- return;
- } catch (IOException e) {
- logger.log(TreeLogger.ERROR,
- "Error launching gwt.browser.default executable '" + browserCmd
- + "'", e);
- return;
- }
- }
-
- // Programmatically try to find something that can handle html files
- Program browserProgram = Program.findProgram("html");
- if (browserProgram != null) {
- if (browserProgram.execute(location)) {
- return;
- } else {
- logger.log(TreeLogger.ERROR, "Error launching external HTML program '"
- + browserProgram.getName() + "'", null);
- return;
- }
- }
-
- // We're out of options, so fail.
- logger.log(TreeLogger.ERROR,
- "Unable to find a default external web browser", null);
-
- logger.log(TreeLogger.WARN, "Try setting the environment variable "
- + "GWT_EXTERNAL_BROWSER to your web browser executable before "
- + "launching the GWT shell", null);
- }
-
- protected Browser browser;
-
- private Color bgColor = new Color(null, 239, 237, 216);
-
- private Button goButton;
-
- private final BrowserWidgetHost host;
-
- private final Map<Object, ModuleSpace> loadedModules = new HashMap<Object, ModuleSpace>();
-
- private Text location;
-
- private final TreeLogger logger;
-
- private Label statusBar;
-
- private Toolbar toolbar;
-
- public BrowserWidget(Composite parent, BrowserWidgetHost host) {
- super(parent, SWT.NONE);
-
- this.host = host;
- logger = this.host.getLogger();
-
- bgColor = new Color(null, 239, 237, 216);
-
- toolbar = new Toolbar(this);
- Composite secondBar = buildLocationBar(this);
-
- browser = new Browser(this, SWT.NONE);
-
- {
- statusBar = new Label(this, SWT.BORDER | SWT.SHADOW_IN);
- statusBar.setBackground(bgColor);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.verticalAlignment = GridData.CENTER;
- gridData.verticalIndent = 0;
- gridData.horizontalIndent = 0;
- statusBar.setLayoutData(gridData);
- }
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.verticalSpacing = 1;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- setLayout(layout);
-
- toolbar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- secondBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridData data = new GridData(GridData.FILL_BOTH);
- data.grabExcessVerticalSpace = true;
- data.grabExcessHorizontalSpace = true;
- browser.setLayoutData(data);
-
- // Hook up all appropriate event listeners.
- //
- hookBrowserListeners();
- }
-
- /**
- * Gets the browser object wrapped by this window.
- */
- public Browser getBrowser() {
- return browser;
- }
-
- public BrowserWidgetHost getHost() {
- return host;
- }
-
- public abstract String getUserAgent();
-
- /**
- * Go to a given url, possibly rewriting it if it can be served from any
- * project's public directory.
- */
- public void go(String target) {
- String url = host.normalizeURL(target);
- browser.setUrl(url);
- }
-
- public void onFirstShown() {
- String baseUrl = host.normalizeURL("/");
- setLocationText(baseUrl);
- location.setFocus();
- location.setSelection(baseUrl.length());
- location.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- int length = location.getText().length();
- location.setSelection(length, length);
- }
-
- public void focusLost(FocusEvent e) {
- }
- });
- }
-
- /**
- * Initializes and attaches module space to this browser widget. Called by
- * subclasses in response to calls from JavaScript.
- *
- * @param moduleSpaceLogger logger to use for attaching the ModuleSpace
- * @param space ModuleSpace instance to initialize
- */
- protected final void attachModuleSpace(TreeLogger moduleSpaceLogger,
- ModuleSpace space) throws UnableToCompleteException {
- Object key = space.getKey();
- loadedModules.put(key, space);
-
- moduleSpaceLogger.log(TreeLogger.SPAM, "Loading module "
- + space.getModuleName() + " (id " + key.toString() + ")", null);
-
- // Let the space do its thing.
- //
- space.onLoad(moduleSpaceLogger);
-
- // Enable the compile button since we successfully loaded.
- //
- toolbar.updateWebMode();
- }
-
- /**
- * Unload one or more modules. If key is null, emulate old behavior by
- * unloading all loaded modules.
- *
- * @param key unique key to identify module to unload or null for all
- */
- protected void doUnload(Object key) {
- if (key == null) {
- // BEGIN BACKWARD COMPATIBILITY
- // remove all modules
- for (Map.Entry<?, ModuleSpace> entry : loadedModules.entrySet()) {
- unloadModule(entry.getValue());
- }
- loadedModules.clear();
- // END BACKWARD COMPATIBILITY
- } else {
- ModuleSpace moduleSpace = loadedModules.get(key);
- if (moduleSpace != null) {
- // If the module failed to load at all, it may not be in the map.
- unloadModule(moduleSpace);
- loadedModules.remove(key);
- }
- }
- toolbar.updateWebMode();
- }
-
- /**
- * Report that an external method was called with the wrong number of
- * arguments.
- */
- protected void reportIncorrectInvocation(String name, int expectedArgs,
- int actualArgs) {
- getHost().getLogger().log(
- TreeLogger.ERROR,
- "Not enough arguments (" + actualArgs + ") passed to external." + name
- + "(), expected (" + expectedArgs + "); "
- + "your hosted mode bootstrap file may be out of date; "
- + "if you are using -noserver try recompiling and redeploying "
- + "your app");
- }
-
- /**
- * Unload the specified module.
- *
- * @param moduleSpace a ModuleSpace instance to unload.
- */
- protected void unloadModule(ModuleSpace moduleSpace) {
- String moduleName = moduleSpace.getModuleName();
- Object key = moduleSpace.getKey();
- moduleSpace.dispose();
- logger.log(TreeLogger.SPAM, "Unloading module " + moduleName + " (id "
- + key.toString() + ")", null);
- }
-
- private Composite buildLocationBar(Composite parent) {
- Color white = new Color(null, 255, 255, 255);
-
- Composite bar = new Composite(parent, SWT.BORDER);
- bar.setBackground(white);
-
- location = new Text(bar, SWT.FLAT);
-
- goButton = new Button(bar, SWT.NONE);
- goButton.setBackground(bgColor);
- goButton.setText("Go");
- goButton.setImage(LowLevel.loadImage("go.gif"));
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = layout.marginHeight = 0;
- layout.marginLeft = 2;
- layout.verticalSpacing = layout.horizontalSpacing = 0;
- bar.setLayout(layout);
-
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.grabExcessHorizontalSpace = true;
- data.verticalAlignment = GridData.CENTER;
- location.setLayoutData(data);
-
- return bar;
- }
-
- /**
- * Hooks up all necessary event listeners.
- */
- private void hookBrowserListeners() {
-
- this.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- bgColor.dispose();
- }
- });
-
- goButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- go(location.getText());
- }
- });
-
- // Hook up the return key in the location bar.
- //
- location.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- if (e.character == '\r') {
- go(location.getText());
- }
- }
-
- public void keyReleased(KeyEvent e) {
- }
- });
-
- // Tie the status label to the browser's status.
- //
- browser.addStatusTextListener(new StatusTextListener() {
- public void changed(StatusTextEvent evt) {
- // Add a little space so it doesn't look so crowded.
- statusBar.setText(" " + evt.text);
- }
- });
-
- browser.addTitleListener(new TitleListener() {
- public void changed(TitleEvent evt) {
- browser.getShell().setText(evt.title);
- }
- });
-
- // Tie the location text box to the browser's location.
- //
- browser.addLocationListener(new LocationListener() {
-
- public void changed(LocationEvent evt) {
- if (evt.top) {
- setLocationText(evt.location);
- }
- }
-
- public void changing(LocationEvent evt) {
- String whitelistRuleFound = null;
- String blacklistRuleFound = null;
- if (evt.location.indexOf(":") == -1) {
- evt.location = "file://" + evt.location;
- }
- String url = evt.location;
- evt.doit = false;
-
- // Ensure that the request is 'safe', meaning it targets the user's
- // local machine or a host that has been whitelisted.
- //
- if (BrowserWidgetHostChecker.isAlwaysWhitelisted(url)) {
- // if the URL is 'always whitelisted', i.e. localhost
- // we load the page without regard to blacklisting
- evt.doit = true;
- return;
- }
- whitelistRuleFound = BrowserWidgetHostChecker.matchWhitelisted(url);
- blacklistRuleFound = BrowserWidgetHostChecker.matchBlacklisted(url);
-
- // If a host is blacklisted and whitelisted, disallow
- evt.doit = whitelistRuleFound != null && blacklistRuleFound == null;
- // We need these if we show a dialog box, so we declare them here and
- // initialize them inside the dialog box case before we change the
- // [in]valid hosts
- // no opinion either way
- if (whitelistRuleFound == null && blacklistRuleFound == null) {
- if (DialogBase.confirmAction(
- (Shell) getParent(),
- "Browsing to remote sites is a security risk! A malicious site could\r\n"
- + "execute Java code though this browser window. Only click \"Yes\" if you\r\n"
- + "are sure you trust the remote site. See the log for details and\r\n"
- + "configuration instructions.\r\n" + "\r\n" + "\r\n"
- + "Allow access to '" + url
- + "' for the rest of this session?\r\n", "Security Warning")) {
- evt.doit = true;
- BrowserWidgetHostChecker.whitelistURL(url);
- } else {
- evt.doit = false;
- BrowserWidgetHostChecker.blacklistURL(url);
- }
- }
-
- // Check for file system.
- //
- if (!evt.doit) {
- // Rip off the query string part. When launching files directly from
- // the filesystem, the existence of a query string when doing the
- // lookup below causes problems (e.g. we don't want to look up a file
- // called "C:\www\myapp.html?gwt.hybrid").
- //
- int lastQues = url.lastIndexOf('?');
- int lastSlash = url.lastIndexOf(File.pathSeparatorChar);
- if (lastQues != -1 && lastQues > lastSlash) {
- url = url.substring(0, lastQues);
- }
-
- // If any part of the path exists, it is at least a valid attempt.
- // This avoids the misleading security message when a file simply
- // cannot be found.
- //
- if (!url.startsWith("http:") && !url.startsWith("https:")) {
- File file = new File(url);
- while (file != null) {
- if (file.exists()) {
- evt.doit = true;
- break;
- } else {
- logger.log(TreeLogger.ERROR, "Cannot find file '"
- + file.getAbsolutePath() + "'");
- }
- file = file.getParentFile();
- }
- }
- }
- // if it wasn't whitelisted or we were blocked we want to say something
- if (whitelistRuleFound == null || !evt.doit) {
- // Restore the URL.
- String typeStr = "untrusted";
- if (blacklistRuleFound != null) {
- typeStr = "blocked";
- }
- TreeLogger header;
- TreeLogger.Type msgType = TreeLogger.ERROR;
- if (!evt.doit) {
- header = logger.branch(msgType, "Unable to visit " + typeStr
- + " URL: '" + url, null);
- } else {
- msgType = TreeLogger.WARN;
- header = logger.branch(TreeLogger.WARN,
- "Confirmation was required to visit " + typeStr + " URL: '"
- + url, null);
- }
- if (blacklistRuleFound == null) {
- BrowserWidgetHostChecker.notifyUntrustedHost(url, header, msgType);
- } else {
- BrowserWidgetHostChecker.notifyBlacklistedHost(blacklistRuleFound,
- url, header, msgType);
- }
- setLocationText(browser.getUrl());
- }
- }
-
- });
-
- // Handle new window requests.
- //
- browser.addOpenWindowListener(new OpenWindowListener() {
- public void open(WindowEvent event) {
- try {
- event.browser = host.openNewBrowserWindow().getBrowser();
- event.browser.getShell().open();
- } catch (UnableToCompleteException e) {
- logger.log(TreeLogger.ERROR, "Unable to open new browser window", e);
- }
- }
- });
- }
-
- private void setLocationText(String text) {
- location.setText(text);
- int length = text.length();
- location.setSelection(length, length);
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java b/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
index 2fce44c..72bce17 100644
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
+++ b/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
@@ -42,12 +42,6 @@
void compile(String[] modules) throws UnableToCompleteException;
/**
- * For SWT.
- */
- ModuleSpaceHost createModuleSpaceHost(TreeLogger logger,
- BrowserWidget widget, String moduleName) throws UnableToCompleteException;
-
- /**
* For OOPHM.
*
* @param logger
@@ -90,10 +84,6 @@
String normalizeURL(String whatTheUserTyped);
- /**
- * For SWT.
- */
- BrowserWidget openNewBrowserWindow() throws UnableToCompleteException;
/**
* For OOPHM.
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserWindowController.java b/dev/core/src/com/google/gwt/dev/shell/BrowserWindowController.java
index ec178b1..ce0bade 100644
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserWindowController.java
+++ b/dev/core/src/com/google/gwt/dev/shell/BrowserWindowController.java
@@ -37,7 +37,5 @@
String normalizeURL(String string);
- BrowserWidget openNewBrowserWindow() throws UnableToCompleteException;
-
void restartServer(TreeLogger logger) throws UnableToCompleteException;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/DialogBase.java b/dev/core/src/com/google/gwt/dev/shell/DialogBase.java
deleted file mode 100644
index c73d642..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/DialogBase.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import org.eclipse.swt.SWT;
-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.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Shared boilerplate for dialogs.
- */
-public abstract class DialogBase extends Dialog implements DisposeListener {
-
- private class Buttons extends GridPanel {
- public Buttons(Composite parent) {
- super(parent, SWT.NONE, 1, true, 12, 6);
-
- okButton = new Button(this, SWT.PUSH);
- setGridData(okButton, 1, 1, FILL, FILL, false, false);
- okButton.setText("Close");
- okButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickOkButton();
- }
- });
-
- shell.setDefaultButton(okButton);
- }
- }
-
- private class Contents extends GridPanel {
-
- public Contents(Composite parent) {
- super(parent, SWT.NONE, 1, false, 0, 0);
-
- Control contents = createContents(this);
- setGridData(contents, 1, 1, FILL, FILL, true, true);
-
- Buttons buttons = new Buttons(this);
- setGridData(buttons, 1, 1, RIGHT, BOTTOM, false, false);
- }
- }
-
- /**
- * Pops up a confirm/cancel dialog.
- */
- public static boolean confirmAction(Shell shell, String msg, String msgTitle) {
- MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES
- | SWT.NO);
- msgBox.setText(msgTitle);
- msgBox.setMessage(msg);
- return msgBox.open() == SWT.YES;
- }
-
- private boolean cancelled = true;
-
- private int minHeight;
-
- private int minWidth;
-
- private Button okButton;
-
- private Shell shell;
-
- public DialogBase(Shell parent, int minWidth, int minHeight) {
- super(parent, SWT.NONE);
- this.minWidth = minWidth;
- this.minHeight = minHeight;
- }
-
- public Shell getShell() {
- return shell;
- }
-
- public boolean open() {
- return open(true);
- }
-
- public boolean open(boolean autoSize) {
- Shell parent = getParent();
- shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL
- | SWT.RESIZE);
- shell.setImages(ShellMainWindow.getIcons());
- shell.setText(getText());
- shell.setLayout(new FillLayout());
-
- new Contents(shell);
-
- onOpen();
-
- int myWidth;
- int myHeight;
- if (autoSize) {
- // Try to make the dialog big enough to hold the packed layout or
- // the requested size, whichever is bigger.
- //
- shell.pack();
-
- Rectangle shellBounds = shell.getBounds();
-
- myWidth = Math.max(shellBounds.width, minWidth);
- myHeight = Math.max(shellBounds.height, minHeight);
- } else {
- myWidth = minWidth;
- myHeight = minHeight;
- }
-
- // Try to center within parent shell.
- //
- Rectangle parentBounds = parent.getBounds();
- int myLeft = parentBounds.x + (parentBounds.width / 2 - myWidth / 2);
- int myTop = parentBounds.y + (parentBounds.height / 4);
-
- shell.setBounds(myLeft, myTop, myWidth, myHeight);
-
- shell.open();
-
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- return !cancelled;
- }
-
- @Override
- public void setText(String string) {
- super.setText(string);
- shell.setText(string);
- }
-
- public void widgetDisposed(DisposeEvent e) {
- }
-
- protected void clickCancelButton() {
- cancelled = true;
- onCancel();
- shell.dispose();
- }
-
- protected void clickOkButton() {
- cancelled = false;
- onOk();
- shell.dispose();
- }
-
- protected abstract Control createContents(Composite parent);
-
- protected void onCancel() {
- }
-
- protected void onOk() {
- }
-
- protected void onOpen() {
- }
-
- protected void setOkEnabled(boolean enabled) {
- okButton.setEnabled(enabled);
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java b/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java
index 3a11993..b483799 100644
--- a/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java
+++ b/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java
@@ -310,7 +310,8 @@
if (partialPath.equals(moduleName + ".nocache.js")) {
// If the '?compiled' request property is specified, don't auto-generate.
- if (request.getParameter("compiled") == null) {
+ String compiledParam = request.getParameter("compiled");
+ if (compiledParam == null) {
// Generate the .js file.
try {
String js = genSelectionScript(logger, moduleName);
diff --git a/dev/core/src/com/google/gwt/dev/shell/GridPanel.java b/dev/core/src/com/google/gwt/dev/shell/GridPanel.java
deleted file mode 100644
index 2a923cf..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/GridPanel.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Shared boilerplate for grid-style UIs.
- */
-public class GridPanel extends Composite {
-
- protected static final int FILL = GridData.FILL;
-
- protected static final int CENTER = GridData.CENTER;
-
- protected static final int MIDDLE = GridData.CENTER;
-
- protected static final int LEFT = GridData.BEGINNING;
-
- protected static final int RIGHT = GridData.END;
-
- protected static final int TOP = GridData.BEGINNING;
- protected static final int BOTTOM = GridData.END;
-
- public GridPanel(Composite parent, int style, int numCols,
- boolean equalWidthCols) {
- this(parent, style, numCols, equalWidthCols, 5, 5);
- }
-
- public GridPanel(Composite parent, int style, int numCols,
- boolean equalWidthCols, int marginWidth, int marginHeight) {
- super(parent, style);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = numCols;
- gridLayout.makeColumnsEqualWidth = equalWidthCols;
- gridLayout.marginWidth = marginWidth;
- gridLayout.marginHeight = marginHeight;
- gridLayout.horizontalSpacing = 1;
- gridLayout.verticalSpacing = 1;
- setLayout(gridLayout);
- }
-
- protected GridData getGridData(Control control) {
- GridData gridData = (GridData) control.getLayoutData();
- if (gridData == null) {
- gridData = new GridData();
- control.setLayoutData(gridData);
- }
- return gridData;
- }
-
- protected GridData setGridData(Control control, int rowSpan, int colSpan,
- int hAlign, int vAlign, boolean hGrab, boolean vGrab) {
- return setGridData(control, rowSpan, colSpan, hAlign, vAlign, hGrab, vGrab,
- SWT.DEFAULT, SWT.DEFAULT);
- }
-
- protected GridData setGridData(Control control, int rowSpan, int colSpan,
- int hAlign, int vAlign, boolean hGrab, boolean vGrab, int widthHint,
- int heightHint) {
- GridData gridData = getGridData(control);
- gridData.horizontalSpan = colSpan;
- gridData.verticalSpan = rowSpan;
- gridData.horizontalAlignment = hAlign;
- gridData.verticalAlignment = vAlign;
- gridData.grabExcessHorizontalSpace = hGrab;
- gridData.grabExcessVerticalSpace = vGrab;
- if (heightHint != SWT.DEFAULT) {
- gridData.heightHint = heightHint;
- }
-
- if (widthHint != SWT.DEFAULT) {
- gridData.widthHint = widthHint;
- }
-
- control.setLayoutData(gridData);
- return gridData;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/HeaderBarBase.java b/dev/core/src/com/google/gwt/dev/shell/HeaderBarBase.java
deleted file mode 100644
index 4eb1678..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/HeaderBarBase.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-/**
- * Base class for <code>Composites</code> that contain <code>ToolItem</code>
- * entities.
- */
-public class HeaderBarBase extends Composite implements DisposeListener {
-
- private final Color bgColor;
- private final ToolBar toolBar;
-
- public HeaderBarBase(Composite parent) {
- super(parent, SWT.NONE);
-
- Composite outer = new Composite(this, SWT.NONE);
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginHeight = 1;
- fillLayout.marginWidth = 1;
- setLayout(fillLayout);
-
- bgColor = new Color(null, 239, 237, 216);
- addDisposeListener(this);
-
- GridLayout gridLayout = new GridLayout(2, false);
- gridLayout.marginLeft = 8;
- gridLayout.marginRight = 2;
- gridLayout.marginTop = 0;
- gridLayout.marginBottom = 0;
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- outer.setLayout(gridLayout);
- outer.setBackground(bgColor);
-
- toolBar = new ToolBar(outer, SWT.FLAT);
- toolBar.setBackground(new Color(null, 255, 0, 0));
- GridData data = new GridData();
- data.grabExcessHorizontalSpace = true;
- data.verticalAlignment = SWT.CENTER;
- data.horizontalAlignment = SWT.FILL;
- toolBar.setLayoutData(data);
- toolBar.setBackground(bgColor);
-
- RowLayout rowLayout = new RowLayout();
- rowLayout.fill = true;
- rowLayout.pack = false;
- rowLayout.wrap = false;
- toolBar.setLayout(rowLayout);
-
- Label logoLabel = new Label(outer, SWT.BORDER | SWT.SHADOW_IN);
- logoLabel.setImage(LowLevel.loadImage("logo.gif"));
- logoLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- }
-
- public ToolBar getToolBar() {
- return toolBar;
- }
-
- public ToolItem newItem(String imageName, String label, String tooltip) {
- ToolItem item = new ToolItem(toolBar, SWT.PUSH);
- item.setImage(LowLevel.loadImage(imageName));
- item.setText(label);
- item.setSelection(false);
- item.setToolTipText(tooltip);
- item.setWidth(60);
- return item;
- }
-
- public void newSeparator() {
- new ToolItem(toolBar, SWT.SEPARATOR);
- }
-
- public void widgetDisposed(DisposeEvent e) {
- bgColor.dispose();
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/JsValue.java b/dev/core/src/com/google/gwt/dev/shell/JsValue.java
deleted file mode 100644
index 7cda3d6..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/JsValue.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import java.util.Vector;
-
-/**
- * Represents a JavaScript value.
- *
- * Note that in general the various get*() methods will return
- * platform-independent values only if the corresponding is*() method returns
- * true. In some cases, an IllegalStateException may be thrown if the JavaScript
- * value is not of the appropriate type or bogus values may be returned. Note
- * that getString will try very hard to return a reasonable result for any
- * value, but it is intended only for human consumption and the exact format for
- * anything besides a string value cannot be relied upon.
- */
-public abstract class JsValue {
-
- /**
- * Allows JsValue subclasses to clean themselves up.
- */
- protected interface JsCleanup {
- void doCleanup();
- }
-
- /**
- * For a thread-safety check to make sure only one thread ever accesses it.
- */
- private static Thread theOnlyThreadAllowed;
-
- /**
- * A queue of JsCleanup objects ready to be released by the main thread.
- */
- private static Vector<JsCleanup> toBeReleased = new Vector<JsCleanup>();
-
- private static final Object toBeReleasedLock = new Object();
-
- /**
- * The main thread should call this from time to time to release hosted-mode
- * objects that Java is no longer referencing.
- */
- public static void mainThreadCleanup() {
- checkThread();
- Vector<JsCleanup> temp;
- synchronized (toBeReleasedLock) {
- temp = toBeReleased;
- toBeReleased = new Vector<JsCleanup>();
- }
- for (JsCleanup cleanup : temp) {
- cleanup.doCleanup();
- }
- temp.clear();
- }
-
- /**
- * Ensures that the current thread is actually the UI thread.
- */
- private static synchronized void checkThread() {
- if (theOnlyThreadAllowed == null) {
- theOnlyThreadAllowed = Thread.currentThread();
- } else if (theOnlyThreadAllowed != Thread.currentThread()) {
- throw new RuntimeException("This object has permanent thread affinity.");
- }
- }
-
- /**
- * Moves this JS value to the queue of objects that are ready to be released.
- */
- private static void queueCleanup(JsCleanup cleanup) {
- // Add to the queue to be released by the main thread later.
- //
- synchronized (toBeReleasedLock) {
- toBeReleased.add(cleanup);
- }
- }
-
- /**
- * Get the value of the object as a boolean. May attempt to convert the value
- * to a boolean if it is not a boolean.
- *
- * @return the value of the underlying object as a boolean
- */
- public abstract boolean getBoolean();
-
- /**
- * Get the value of the object as an integer. May attempt to convert the value
- * to an integer if it is not an integer.
- *
- * @return the value of the underlying object as an int
- */
- public abstract int getInt();
-
- /**
- * Returns a unique value corresponding to the underlying JavaScript object.
- * In general, two different JsValues will return the same value IFF the
- * underlying JavaScript objects are identical (===).
- *
- * @return a unique number corresponding to the underlying object, or
- * <code>0</code> if {@link #isJavaScriptObject()} is
- * <code>false</code>
- */
- public abstract int getJavaScriptObjectPointer();
-
- /**
- * Get the value of the object as a double. May attempt to convert the value
- * to a double if it is not a double.
- *
- * @return the value of the underlying object as a double
- */
- public abstract double getNumber();
-
- /**
- * Get the value of the object as a string. Will coerce the underlying type to
- * a string, but stable cross-platform behavior is only guaranteed when
- * {@link #isString()} is <code>true</code>.
- *
- * @return the value of the underlying object as a string
- */
- public abstract String getString();
-
- /**
- * Returns a human-readable string describing the type of the JS object. This
- * is intended only for human consumption and may vary across platforms.
- */
- public abstract String getTypeString();
-
- /**
- * Unwrap a wrapped Java object.
- *
- * @return the original Java object wrapped in this JS object
- */
- public abstract Object getWrappedJavaObject();
-
- /**
- * Returns true if the JS value is a boolean.
- */
- public abstract boolean isBoolean();
-
- /**
- * Returns true if getInt() can be used on this value.
- */
- public abstract boolean isInt();
-
- /**
- * Returns true if the JS value is a native JS object.
- */
- public abstract boolean isJavaScriptObject();
-
- /**
- * Returns true if the JS value is null.
- */
- public abstract boolean isNull();
-
- /**
- * Returns true if the JS value is a numeric type.
- */
- public abstract boolean isNumber();
-
- /**
- * Returns true if the JS value is a string.
- */
- public abstract boolean isString();
-
- /**
- * Returns true if the JS value is undefined (void).
- */
- public abstract boolean isUndefined();
-
- /**
- * Returns true if the JS value is a wrapped Java object.
- */
- public abstract boolean isWrappedJavaObject();
-
- /**
- * Sets the JS object to be a boolean value.
- *
- * @param val the boolean value to set
- */
- public abstract void setBoolean(boolean val);
-
- /**
- * Sets the JS object to be a number, passed as an byte.
- *
- * @param val the value to store
- */
- public abstract void setByte(byte val);
-
- /**
- * Sets the JS object to be a number, passed as a char.
- *
- * @param val the value to store
- */
- public abstract void setChar(char val);
-
- /**
- * Sets the JS object to be a number, passed as a double.
- *
- * @param val the value to store
- */
- public abstract void setDouble(double val);
-
- /**
- * Sets the JS object to be a number, passed as an int.
- *
- * @param val the value to store
- */
- public abstract void setInt(int val);
-
- /**
- * Set the JS object to be null.
- *
- * @throws HostedModeException
- */
- public abstract void setNull();
-
- /**
- * Sets the JS object to be a number, passed as a short.
- *
- * @param val the value to store
- */
- public abstract void setShort(short val);
-
- /**
- * Set the JS object to the supplied string.
- *
- * @param val the string to put in the JS object
- * @throws HostedModeException on JS allocation failures
- */
- public abstract void setString(String val);
-
- /**
- * Set the JS object to be undefined (void).
- *
- * @throws HostedModeException on JS allocation failures
- */
- public abstract void setUndefined();
-
- /**
- * Make this JsValue refer to the same underlying object as another JsValue.
- *
- * @param other JsValue to copy JS object from
- */
- public abstract void setValue(JsValue other);
-
- /**
- * Set the JS object to the supplied object, which will be wrapped in a
- * platform-dependent JavaScript class.
- *
- * @param <T> the type of the Java object to wrap
- * @param cl the classloader to create the wrapper object with
- * @param val the Java object to wrap
- * @throws HostedModeException
- */
- public abstract <T> void setWrappedJavaObject(CompilingClassLoader cl, T val);
-
- /**
- * Produce a string representation of the JsValue.
- */
- @Override
- public String toString() {
- if (isUndefined()) {
- return "void";
- } else if (isNull()) {
- return "null";
- } else if (isBoolean()) {
- return "bool: " + (getBoolean() ? "true" : "false");
- } else if (isInt()) {
- return "int: " + Integer.toString(getInt());
- } else if (isNumber()) {
- return "double: " + Double.toString(getNumber());
- } else if (isWrappedJavaObject()) {
- return "Java object: " + getWrappedJavaObject().toString();
- } else if (isJavaScriptObject()) {
- return "JS object [" + getTypeString() + "] : " + getString();
- } else if (isString()) {
- return "string: '" + getString() + "'";
- } else {
- return "*unknown type: " + getTypeString() + "*";
- }
- }
-
- /**
- * Create an object which frees the underlying JS resource.
- *
- * @return a JsCleanup object which will free the underlying JS resource
- */
- protected abstract JsCleanup createCleanupObject();
-
- /**
- * When the Java object is garbage-collected, make sure the associated JS
- * resource is freed. A helper object is used to avoid issues with
- * resurrecting this object.
- */
- @Override
- protected final void finalize() throws Throwable {
- queueCleanup(createCleanupObject());
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java b/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
deleted file mode 100644
index 927c341..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.util.TypeInfo;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Glue layer that performs GWT-specific operations on JsValues. Used to isolate
- * HostedModeExceptions/etc from JsValue code
- */
-public final class JsValueGlue {
- public static final String HOSTED_MODE_REFERENCE = "hostedModeReference";
- public static final String JSO_CLASS = "com.google.gwt.core.client.JavaScriptObject";
- public static final String JSO_IMPL_CLASS = "com.google.gwt.core.client.JavaScriptObject$";
-
- /**
- * Return an object containing the value JavaScript object as a specified
- * type.
- *
- * @param value the JavaScript value
- * @param type expected type of the returned object
- * @param msgPrefix a prefix for error/warning messages
- * @return the object reference
- * @throws HostedModeException if the JavaScript object is not assignable to
- * the supplied type.
- */
- @SuppressWarnings("unchecked")
- public static <T> T get(JsValue value, CompilingClassLoader cl,
- Class<T> type, String msgPrefix) {
-
- if (type.isPrimitive()) {
- if (value.isUndefined()) {
- throw new HostedModeException("Expected primitive type " + type
- + "; actual value was undefined");
- } else if (value.isNull()) {
- throw new HostedModeException("Expected primitive type " + type
- + "; actual value was null");
- }
- if (type == Boolean.TYPE) {
- if (!value.isBoolean()) {
- throw new HostedModeException(msgPrefix + ": JS value of type "
- + value.getTypeString() + ", expected boolean");
- }
- return (T) Boolean.valueOf(value.getBoolean());
- } else if (type == Byte.TYPE) {
- return (T) Byte.valueOf((byte) getIntRange(value, Byte.MIN_VALUE,
- Byte.MAX_VALUE, "byte", msgPrefix));
- } else if (type == Character.TYPE) {
- return (T) Character.valueOf((char) getIntRange(value,
- Character.MIN_VALUE, Character.MAX_VALUE, "char", msgPrefix));
- } else if (type == Double.TYPE) {
- if (!value.isNumber()) {
- throw new HostedModeException(msgPrefix + ": JS value of type "
- + value.getTypeString() + ", expected double");
- }
- return (T) Double.valueOf(value.getNumber());
- } else if (type == Float.TYPE) {
- if (!value.isNumber()) {
- throw new HostedModeException(msgPrefix + ": JS value of type "
- + value.getTypeString() + ", expected float");
- }
- double doubleVal = value.getNumber();
-
- // Check for small changes near MIN_VALUE and replace with the
- // actual end point value, in case it is being used as a sentinel
- // value. This test works by the subtraction result rounding off to
- // zero if the delta is not representable in a float.
- // TODO(jat): add similar test for MAX_VALUE if we have a JS
- // platform that alters the value while converting to/from strings.
- if ((float) (doubleVal - Float.MIN_VALUE) == 0.0f) {
- doubleVal = Float.MIN_VALUE;
- }
-
- float floatVal = (float) doubleVal;
- if (Float.isInfinite(floatVal) && !Double.isInfinite(doubleVal)) {
- // in this case we had overflow from the double value which was
- // outside the range of supported float values, and the cast
- // converted it to infinity. Since this lost data, we treat this
- // as an error in hosted mode.
- throw new HostedModeException(msgPrefix + ": JS value " + doubleVal
- + " out of range for a float");
- }
- return (T) Float.valueOf(floatVal);
- } else if (type == Integer.TYPE) {
- return (T) Integer.valueOf(getIntRange(value, Integer.MIN_VALUE,
- Integer.MAX_VALUE, "int", msgPrefix));
- } else if (type == Long.TYPE) {
- if (!value.isWrappedJavaObject()) {
- throw new HostedModeException(msgPrefix + ": JS value of type "
- + value.getTypeString() + ", expected Java long");
- }
- JavaLong javaLong = (JavaLong) value.getWrappedJavaObject();
- return (T) Long.valueOf(javaLong.longValue());
- } else if (type == Short.TYPE) {
- return (T) Short.valueOf((short) getIntRange(value, Short.MIN_VALUE,
- Short.MAX_VALUE, "short", msgPrefix));
- }
- }
-
- if (value.isNull() || value.isUndefined()) {
- return null;
- }
- if (value.isWrappedJavaObject()) {
- return type.cast(value.getWrappedJavaObject());
- }
- if (value.isString()) {
- return type.cast(value.getString());
- }
- if (value.isJavaScriptObject()) {
- return type.cast(createJavaScriptObject(value, cl));
- }
-
- // Just don't know what do to with this.
- throw new IllegalArgumentException(msgPrefix + ": Cannot convert to type "
- + TypeInfo.getSourceRepresentation(type) + " from "
- + value.getTypeString());
- }
-
- /**
- * Set the underlying value.
- *
- * @param value JsValue to set
- * @param type static type of the object
- * @param obj the object to store in the JS value
- */
- public static void set(JsValue value, CompilingClassLoader cl, Class<?> type,
- Object obj) {
- if (type.isPrimitive()) {
- if (type == Boolean.TYPE) {
- value.setBoolean(((Boolean) obj).booleanValue());
- } else if (type == Byte.TYPE) {
- value.setInt(((Byte) obj).byteValue());
- } else if (type == Character.TYPE) {
- value.setInt(((Character) obj).charValue());
- } else if (type == Double.TYPE) {
- value.setDouble(((Double) obj).doubleValue());
- } else if (type == Float.TYPE) {
- value.setDouble(((Float) obj).floatValue());
- } else if (type == Integer.TYPE) {
- value.setInt(((Integer) obj).intValue());
- } else if (type == Long.TYPE) {
- long longVal = ((Long) obj).longValue();
- value.setWrappedJavaObject(cl, new JavaLong(longVal));
- } else if (type == Short.TYPE) {
- value.setInt(((Short) obj).shortValue());
- } else if (type == Void.TYPE) {
- value.setUndefined();
- } else {
- throw new HostedModeException("Cannot marshal primitive type " + type);
- }
- } else if (obj == null) {
- value.setNull();
- } else {
- // not a boxed primitive
- try {
- Class<?> jsoType = Class.forName(JSO_IMPL_CLASS, false, cl);
- if (jsoType == obj.getClass()) {
- JsValue jsObject = getUnderlyingObject(obj);
- value.setValue(jsObject);
- return;
- }
- } catch (ClassNotFoundException e) {
- // Ignore the exception, if we can't find the class then obviously we
- // don't have to worry about o being one
- }
-
- // Fall through case: Object.
- if (!type.isInstance(obj)) {
- throw new HostedModeException("object is of type "
- + obj.getClass().getName() + ", expected " + type.getName());
- }
- if (obj instanceof String) {
- value.setString((String) obj);
- } else {
- value.setWrappedJavaObject(cl, obj);
- }
- }
- }
-
- /**
- * Create a JavaScriptObject instance referring to this JavaScript object.
- *
- * @param classLoader the classLoader to create from
- * @return the constructed JavaScriptObject
- */
- private static Object createJavaScriptObject(JsValue value,
- CompilingClassLoader classLoader) {
- Throwable caught;
- try {
- // See if there's already a wrapper object (assures identity comparison).
- Object jso = classLoader.getCachedJso(value.getJavaScriptObjectPointer());
- if (jso != null) {
- return jso;
- }
-
- // Instantiate the JSO class.
- Class<?> jsoType = Class.forName(JSO_IMPL_CLASS, true, classLoader);
- Constructor<?> ctor = jsoType.getDeclaredConstructor();
- jso = ctor.newInstance();
-
- // Set the reference field to this JsValue using reflection.
- Field referenceField = jsoType.getField(HOSTED_MODE_REFERENCE);
- referenceField.set(jso, value);
-
- classLoader.putCachedJso(value.getJavaScriptObjectPointer(), jso);
- return jso;
- } catch (InstantiationException e) {
- caught = e;
- } catch (IllegalAccessException e) {
- caught = e;
- } catch (SecurityException e) {
- caught = e;
- } catch (NoSuchMethodException e) {
- caught = e;
- } catch (IllegalArgumentException e) {
- caught = e;
- } catch (InvocationTargetException e) {
- caught = e;
- } catch (ClassNotFoundException e) {
- caught = e;
- } catch (NoSuchFieldException e) {
- caught = e;
- }
- throw new RuntimeException("Error creating JavaScript object", caught);
- }
-
- private static int getIntRange(JsValue value, int low, int high,
- String typeName, String msgPrefix) {
- int intVal;
- if (value.isInt()) {
- intVal = value.getInt();
- if (intVal < low || intVal > high) {
- throw new HostedModeException(msgPrefix + ": JS int value " + intVal
- + " out of range for a " + typeName);
- }
- } else if (value.isNumber()) {
- double doubleVal = value.getNumber();
- if (doubleVal < low || doubleVal > high) {
- throw new HostedModeException(msgPrefix + ": JS double value "
- + doubleVal + " out of range for a " + typeName);
- }
- intVal = (int) doubleVal;
- if (intVal != doubleVal) {
- ModuleSpace.getLogger().log(TreeLogger.WARN,
- msgPrefix + ": Rounding double to int for " + typeName, null);
- }
- } else {
- throw new HostedModeException(msgPrefix + ": JS value of type "
- + value.getTypeString() + ", expected " + typeName);
- }
- return intVal;
- }
-
- /**
- * Returns the underlying JsValue from a JavaScriptObject instance.
- *
- * The tricky part is that it is in a different ClassLoader so therefore can't
- * be specified directly. The type is specified as Object, and reflection is
- * used to retrieve the reference field.
- *
- * @param jso the instance of JavaScriptObject to retrieve the JsValue from.
- * @return the JsValue representing the JavaScript object
- */
- private static JsValue getUnderlyingObject(Object jso) {
- Throwable caught;
- try {
- Field referenceField = jso.getClass().getField(HOSTED_MODE_REFERENCE);
- referenceField.setAccessible(true);
- return (JsValue) referenceField.get(jso);
- } catch (IllegalAccessException e) {
- caught = e;
- } catch (SecurityException e) {
- caught = e;
- } catch (NoSuchFieldException e) {
- caught = e;
- }
- throw new RuntimeException("Error reading " + HOSTED_MODE_REFERENCE, caught);
- }
-
- private JsValueGlue() {
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/Jsni.java b/dev/core/src/com/google/gwt/dev/shell/Jsni.java
deleted file mode 100644
index a4dcbb0..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/Jsni.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.javac.JsniMethod;
-import com.google.gwt.dev.js.JsSourceGenerationVisitor;
-import com.google.gwt.dev.js.ast.JsContext;
-import com.google.gwt.dev.js.ast.JsExpression;
-import com.google.gwt.dev.js.ast.JsFunction;
-import com.google.gwt.dev.js.ast.JsNameRef;
-import com.google.gwt.dev.js.ast.JsNode;
-import com.google.gwt.dev.util.DefaultTextOutput;
-import com.google.gwt.dev.util.TextOutput;
-
-/**
- * Helper methods working with JSNI.
- */
-public class Jsni {
-
- /**
- * Generate source code, fixing up any JSNI references for hosted mode.
- *
- * <p/><table>
- * <tr>
- * <td>Original</td>
- * <td>Becomes</td>
- * </tr>
- * <tr>
- * <td><code>.@class::method(params)(args)</code></td>
- *
- * <td><code>["@class::method(params)"](args)</code></td>
- * </tr>
- * <tr>
- * <td><code>@class::method(params)(args)</code></td>
- *
- * <td><code>__static["@class::method(params)"](args)</code></td>
- * </tr>
- * <tr>
- * <td><code>.@class::field</code></td>
- *
- * <td><code>["@class::field"]</code></td>
- * </tr>
- * <tr>
- * <td><code>@class::field</code></td>
- *
- * <td><code>__static["@class::field"]</code></td>
- * </tr>
- * </table>
- */
- private static class JsSourceGenWithJsniIdentFixup extends
- JsSourceGenerationVisitor {
- private final TextOutput out;
-
- public JsSourceGenWithJsniIdentFixup(TextOutput out) {
- super(out);
- this.out = out;
- }
-
- @Override
- public boolean visit(JsNameRef x, JsContext<JsExpression> ctx) {
- String ident = x.getIdent();
- if (ident.startsWith("@")) {
- JsExpression q = x.getQualifier();
- if (q != null) {
- accept(q);
- out.print("[\"");
- out.print(ident);
- out.print("\"]");
- } else {
- out.print("__static[\"");
- out.print(ident);
- out.print("\"]");
- }
- return false;
- } else {
- return super.visit(x, ctx);
- }
- }
- }
-
- public static final String JAVASCRIPTHOST_NAME = JavaScriptHost.class.getName();
-
- /**
- * Gets the body of a JSNI method, with Java refs escaped for hosted mode
- * injection.
- */
- public static String getJavaScriptForHostedMode(TreeLogger logger,
- DispatchIdOracle dispatchInfo, JsniMethod jsniMethod) {
- /*
- * Surround the original JS body statements with a try/catch so that we can
- * map JavaScript exceptions back into Java. Note that the method body
- * itself will print curly braces, so we don't need them around the
- * try/catch.
- */
- String jsTry = "try ";
- String jsCatch = " catch (e) {\n __static[\"@" + Jsni.JAVASCRIPTHOST_NAME
- + "::exceptionCaught(Ljava/lang/Object;)\"](e);\n" + "}\n";
- JsFunction func = jsniMethod.function(logger);
- if (func == null) {
- return null;
- }
- return jsTry + generateJavaScriptForHostedMode(func.getBody()) + jsCatch;
- }
-
- /**
- * Returns a string representing the source output of the JsNode, where all
- * JSNI idents have been replaced with legal JavaScript for hosted mode.
- */
- private static String generateJavaScriptForHostedMode(JsNode<?> node) {
- DefaultTextOutput out = new DefaultTextOutput(false);
- JsSourceGenWithJsniIdentFixup vi = new JsSourceGenWithJsniIdentFixup(out);
- vi.accept(node);
- return out.toString();
- }
-
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/LowLevel.java b/dev/core/src/com/google/gwt/dev/shell/LowLevel.java
index 40f962f..39441b0 100644
--- a/dev/core/src/com/google/gwt/dev/shell/LowLevel.java
+++ b/dev/core/src/com/google/gwt/dev/shell/LowLevel.java
@@ -17,11 +17,8 @@
import com.google.gwt.util.tools.Utility;
-import org.eclipse.swt.graphics.Image;
-
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.lang.reflect.Field;
/**
@@ -110,29 +107,6 @@
}
/**
- * Loads an image from the classpath.
- */
- public static Image loadImage(String name) {
- ClassLoader cl = LowLevel.class.getClassLoader();
- InputStream is = cl.getResourceAsStream(LowLevel.PACKAGE_PATH + name);
- if (is != null) {
- try {
- Image image = new Image(null, is);
- return image;
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- } else {
- // Bad image.
- //
- return new Image(null, 1, 1);
- }
- }
-
- /**
* Creates a global ref on the specified object, returning its int handle.
*/
public static int newGlobalRefInt(Object o) {
diff --git a/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java b/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
deleted file mode 100644
index 8a3bebc..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.dev.shell.BrowserWindowController.WebServerRestart;
-import com.google.gwt.dev.shell.log.TreeLoggerWidget;
-import com.google.gwt.dev.util.Util;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
-
-import org.eclipse.swt.SWT;
-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.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolItem;
-
-import java.io.File;
-
-/**
- * Implements the GWTShell's main window control.
- */
-public class ShellMainWindow extends Composite implements DisposeListener,
- ShellListener {
-
- private class Toolbar extends HeaderBarBase {
-
- private ToolItem about;
- private ToolItem clearLog;
- private ToolItem collapseAll;
- private ToolItem expandAll;
- private ToolItem newWindow;
- private ToolItem restartServer;
-
- public Toolbar(Composite parent) {
- super(parent);
-
- newWindow = newItem("new-window.gif", "&Hosted Browser",
- "Opens a new hosted mode browser window for debugging");
- newWindow.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- String startupUrl = browserWindowController.normalizeURL("/");
- try {
- BrowserWidget bw = browserWindowController.openNewBrowserWindow();
- bw.go(startupUrl);
- } catch (UnableToCompleteException e) {
- getLogger().log(TreeLogger.ERROR,
- "Unable to open a new hosted browser window", e);
- }
- }
- });
- newSeparator();
-
- if (browserWindowController.hasWebServer() != WebServerRestart.NONE) {
- restartServer = newItem("reload-server.gif", "&Restart Server",
- "Restart the embedded web server to pick up code changes");
- restartServer.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- try {
- browserWindowController.restartServer(getLogger());
- } catch (UnableToCompleteException e) {
- getLogger().log(TreeLogger.ERROR, "Unable to restart server", e);
- }
- }
- });
- newSeparator();
- if (browserWindowController.hasWebServer() == WebServerRestart.DISABLED) {
- restartServer.setEnabled(false);
- }
- }
-
- collapseAll = newItem("collapse.gif", "&Collapse All",
- "Collapses all log entries");
- collapseAll.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- logPane.collapseAll();
- }
- });
-
- expandAll = newItem("expand.gif", "&Expand All",
- "Expands all log entries");
- expandAll.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- logPane.expandAll();
- }
- });
-
- clearLog = newItem("clear-log.gif", "Clear &Log",
- "Removes all log entries");
- clearLog.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- logPane.removeAll();
- }
- });
-
- newSeparator();
-
- about = newItem("about.gif", " &About ", "About...");
- about.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- String aboutHtml = Util.getFileFromInstallPath("about.html");
- if (aboutHtml != null) {
- String serial = verify("TwysxNpVumPBvFyBoxzLy");
- StringBuffer sb = new StringBuffer();
- sb.append("<div style='overflow:hidden;width:100%;white-space:nowrap;font-size:1px'><br/><br/><br/><br/><font style='background-color:gray;color:lightgrey'>");
- for (int i = 0; i < 100; ++i) {
- sb.append(serial);
- }
- sb.append("</font></div>");
- serial = sb.toString();
- int pos;
- while ((pos = aboutHtml.indexOf("<hr/>")) >= 0) {
- aboutHtml = aboutHtml.substring(0, pos) + serial
- + aboutHtml.substring(pos + 5);
- }
- while ((pos = aboutHtml.indexOf("<body>")) >= 0) {
- aboutHtml = aboutHtml.substring(0, pos)
- + "<body oncontextmenu='return false'>"
- + aboutHtml.substring(pos + 6);
- }
- } else {
- aboutHtml = "Could not locate 'about.html' in installation directory.";
- }
- BrowserDialog browserDialog = new BrowserDialog(getShell(),
- getLogger(), aboutHtml);
- browserDialog.open(true);
- }
- });
- }
- }
-
- private static Image[] icons;
-
- /**
- * Well-known place to get the GWT icons.
- */
- public static Image[] getIcons() {
- // Make sure icon images are loaded.
- //
- if (icons == null) {
- icons = new Image[] {
- LowLevel.loadImage("icon16.png"), LowLevel.loadImage("icon24.png"),
- LowLevel.loadImage("icon32.png"), LowLevel.loadImage("icon48.png"),
- LowLevel.loadImage("icon128.png")};
- }
- return icons;
- }
-
- private static String verify(String hash) {
- char[] in = hash.toCharArray();
- char[] ou = new char[in.length];
- for (int i = 0, c = 0; i < in.length; ++i) {
- if (in[i] < 'a') {
- c += in[i] - 'A';
- } else {
- c += in[i] - 'a' - 26;
- }
-
- if (c == 0) {
- ou[i] = ' ';
- } else {
- ou[i] = (char) ('@' + c);
- }
- }
- return String.valueOf(ou);
- }
-
- private BrowserWindowController browserWindowController;
-
- private Color colorWhite;
-
- private TreeLoggerWidget logPane;
-
- private Toolbar toolbar;
-
- public ShellMainWindow(BrowserWindowController browserWindowController,
- Shell parent, String titleText, int serverPort, File logFile,
- Type logLevel) {
- super(parent, SWT.NONE);
- this.browserWindowController = browserWindowController;
-
- colorWhite = new Color(null, 255, 255, 255);
-
- addDisposeListener(this);
- parent.addShellListener(this);
-
- setLayout(new FillLayout());
- if (serverPort > 0) {
- parent.setText(titleText + " / Port " + serverPort);
- } else {
- parent.setText(titleText);
- }
-
- GridLayout gridLayout = new GridLayout(1, true);
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- gridLayout.horizontalSpacing = 0;
- gridLayout.verticalSpacing = 0;
- setLayout(gridLayout);
-
- // Create the toolbar.
- {
- toolbar = new Toolbar(this);
- GridData data = new GridData();
- data.grabExcessHorizontalSpace = true;
- data.horizontalAlignment = GridData.FILL;
- toolbar.setLayoutData(data);
- }
-
- // Create the log pane.
- {
- logPane = new TreeLoggerWidget(this, logFile, logLevel);
- GridData data = new GridData();
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- logPane.setLayoutData(data);
- }
- }
-
- public AbstractTreeLogger getLogger() {
- return logPane.getLogger();
- }
-
- public void shellActivated(ShellEvent e) {
- }
-
- public void shellClosed(ShellEvent e) {
- if (browserWindowController.hasBrowserWindowsOpen()) {
- boolean closeWindows = true;
- if (System.getProperty("gwt.shell.endquick") == null) {
- closeWindows = DialogBase.confirmAction((Shell) e.widget,
- "Closing the development shell will close "
- + "all hosted mode browsers. Continue?", "Confirm close");
- }
-
- if (closeWindows) {
- browserWindowController.closeAllBrowserWindows();
- e.doit = true;
- } else {
- e.doit = false;
- }
- }
- }
-
- public void shellDeactivated(ShellEvent e) {
- }
-
- public void shellDeiconified(ShellEvent e) {
- }
-
- public void shellIconified(ShellEvent e) {
- }
-
- public void widgetDisposed(DisposeEvent e) {
- colorWhite.dispose();
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/log/DetachedTreeLoggerWindow.java b/dev/core/src/com/google/gwt/dev/shell/log/DetachedTreeLoggerWindow.java
deleted file mode 100644
index 0aaf638..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/log/DetachedTreeLoggerWindow.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.log;
-
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.dev.shell.LowLevel;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
-
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Useful for debugging, this class manages to standalone window
- * and provides access to a logger you can use to write to it.
- *
- */
-public class DetachedTreeLoggerWindow implements Runnable {
- private static DetachedTreeLoggerWindow singleton;
-
- /**
- * Provides a reference to a singleton <code>DetachedTreeLoggerWindow</code>.
- *
- * @param caption the text to appear in the windows title bar.
- * @param width the widget of the window
- * @param height the height of the window
- * @param autoScroll whether or not the window should autoscroll as output is
- * produced
- * @return a proxy object providing limited control of the window.
- */
- public static synchronized DetachedTreeLoggerWindow getInstance(
- final String caption, final int width, final int height,
- final boolean autoScroll, Type logLevel) {
- if (singleton == null) {
- singleton = new DetachedTreeLoggerWindow(caption, width, height,
- autoScroll, logLevel);
- }
- return singleton;
- }
-
- private final Shell shell;
- private final AbstractTreeLogger logger;
- private boolean isRunning = false;
-
- private DetachedTreeLoggerWindow(final String caption, final int width,
- final int height, final boolean autoScroll, Type logLevel) {
-
- shell = new Shell(Display.getCurrent());
- shell.setText(caption);
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginWidth = 0;
- fillLayout.marginHeight = 0;
- shell.setLayout(fillLayout);
-
- final TreeLoggerWidget treeLoggerWidget = new TreeLoggerWidget(shell, null,
- logLevel);
- treeLoggerWidget.setAutoScroll(autoScroll);
- logger = treeLoggerWidget.getLogger();
-
- shell.setImage(LowLevel.loadImage("gwt.ico"));
- shell.setSize(width, height);
- shell.open();
- }
-
- public AbstractTreeLogger getLogger() {
- return logger;
- }
-
- public synchronized boolean isRunning() {
- return isRunning;
- }
-
- public void run() {
- if (!maybeStart()) {
- throw new IllegalStateException(
- "DetachedTreeLogger window is already running.");
- }
-
- final Display display = shell.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- private synchronized boolean maybeStart() {
- if (isRunning) {
- return false;
- }
- isRunning = true;
- return true;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/log/TreeItemLogger.java b/dev/core/src/com/google/gwt/dev/shell/log/TreeItemLogger.java
deleted file mode 100644
index b24b750..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/log/TreeItemLogger.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.log;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Stack;
-
-/**
- * Tree logger built on an SWT tree item.
- */
-public final class TreeItemLogger extends AbstractTreeLogger {
-
- /**
- * Represents an individual log event.
- */
- public static class LogEvent {
- public final String exceptionDetail;
-
- public final String exceptionName;
-
- public final HelpInfo helpInfo;
-
- public final int index;
-
- public final boolean isBranchCommit;
-
- public final TreeItemLogger logger;
-
- public final String message;
-
- public final TreeLogger.Type type;
-
- public LogEvent(TreeItemLogger logger, boolean isBranchCommit, int index,
- Type type, String message, Throwable caught, HelpInfo helpInfo) {
- this.exceptionDetail = AbstractTreeLogger.getStackTraceAsString(caught);
- this.exceptionName = AbstractTreeLogger.getExceptionName(caught);
- this.logger = logger;
- this.isBranchCommit = isBranchCommit;
- this.index = index;
- this.type = type;
- this.message = message;
- this.helpInfo = helpInfo;
- }
-
- @Override
- public String toString() {
- String s = "";
- s += "[logger " + logger.toString();
- s += ", " + (isBranchCommit ? "BRANCH" : "LOG");
- s += ", index " + index;
- s += ", type " + type.toString();
- s += ", msg '" + message + "'";
- s += "]";
- return s;
- }
-
- /**
- * Can only be called by the UI thread.
- */
- public void uiFlush(Tree tree) {
- // Get or create the tree item associated with this logger.
- //
- TreeItem treeItem = createTreeItem(tree);
-
- if (treeItem == null) {
- // The logger associated with this log event is dead, so it should
- // show no ui at all.
- //
- return;
- }
-
- // Style all ancestors.
- //
- uiStyleChildAndAncestors(type, treeItem);
- }
-
- /**
- * Creates a tree item in a way that is sensitive to the log event and its
- * position in the tree.
- */
- private TreeItem createTreeItem(Tree tree) {
- TreeItem treeItem = null;
-
- if (isBranchCommit) {
- // A child logger is committing.
- // 'logger' is the logger that needs a tree item.
- // We can be sure that the child logger's parent is non-null
- // and that either (1) it is has a TreeItem meaning it is not a
- // top-level entry or (2) it is a top-level entry and gets attached to
- // the Tree.
- //
- TreeItemLogger parentLogger = (TreeItemLogger) logger.getParentLogger();
- if (parentLogger.lazyTreeItem == null) {
- // Is top level.
- //
- treeItem = new TreeItem(tree, SWT.NONE);
- logger.lazyTreeItem = treeItem;
- } else if (!parentLogger.lazyTreeItem.isDisposed()) {
- // Is not top level, but still valid to write to.
- //
- treeItem = new TreeItem(parentLogger.lazyTreeItem, SWT.NONE);
- logger.lazyTreeItem = treeItem;
- } else {
- // The tree item associated with this logger's parent has been
- // disposed, so we simply ignore all pending updates related to it.
- // We also mark that logger dead to avoid adding log events for it.
- //
- parentLogger.markLoggerDead();
- return null;
- }
- } else {
- // Create a regular log item on 'logger'.
- // The logger may be the root logger, in which case we create TreeItems
- // directly underneath Tree, or it may be a branched logger, in which
- // case we create TreeItems underneath the branched logger's TreeItem
- // (which cannot be null because of the careful ordering of log events).
- //
- if (logger.lazyTreeItem == null) {
- // Is top level.
- //
- treeItem = new TreeItem(tree, SWT.NONE);
- } else if (!logger.lazyTreeItem.isDisposed()) {
- // Is not top level, but still valid to write to.
- //
- treeItem = new TreeItem(logger.lazyTreeItem, SWT.NONE);
- } else {
- // The tree item associated with this logger's parent has been
- // disposed, so we simply ignore all pending updates related to it.
- // We also mark that logger dead to avoid adding log events for it.
- //
- logger.markLoggerDead();
- return null;
- }
- }
-
- // Set the text of the new tree item.
- //
- String label = message;
- if (label == null) {
- assert (exceptionName != null);
- label = exceptionName;
- }
- treeItem.setText(label);
-
- if (helpInfo != null) {
- URL url = helpInfo.getURL();
- if (url != null) {
- TreeItem helpItem = new TreeItem(treeItem, SWT.NONE);
- helpItem.setImage(imageLink);
- helpItem.setText("More info: " + url.toString());
- helpItem.setForeground(helpItem.getDisplay().getSystemColor(
- SWT.COLOR_BLUE));
- helpItem.setData(helpInfo);
- treeItem.setExpanded(true);
- }
- }
-
- // This LogEvent object becomes the tree item's custom data.
- //
- treeItem.setData(this);
-
- return treeItem;
- }
-
- /**
- * Can only be called by the UI thread.
- */
- private void uiStyleChildAndAncestors(TreeLogger.Type type, TreeItem child) {
- Display display = child.getDisplay();
- Color color;
-
- Image image = null;
- if (type == TreeLogger.ERROR) {
- color = display.getSystemColor(SWT.COLOR_RED);
- image = imageError;
- } else if (type == TreeLogger.WARN) {
- color = display.getSystemColor(SWT.COLOR_DARK_YELLOW);
- image = imageWarning;
- } else if (type == TreeLogger.INFO) {
- color = display.getSystemColor(SWT.COLOR_BLACK);
- image = imageInfo;
- } else if (type == TreeLogger.TRACE) {
- color = display.getSystemColor(SWT.COLOR_DARK_GRAY);
- image = imageTrace;
- } else if (type == TreeLogger.DEBUG) {
- color = display.getSystemColor(SWT.COLOR_DARK_CYAN);
- image = imageDebug;
- } else {
- // if (type == TreeLogger.SPAM)
- color = display.getSystemColor(SWT.COLOR_DARK_GREEN);
- image = imageSpam;
- }
-
- if (image != null) {
- child.setImage(image);
- }
-
- // Set this item's color.
- //
- child.setForeground(color);
-
- // For types needing attention, set all parents to the warning color.
- //
- if (type.needsAttention()) {
- /*
- * Originally, this code would expand TreeItems from this child up to
- * its top level ancestor. However, on Mac and Linux, the TreeItems fail
- * to expand if its parent is not already expanded. It appears to be an
- * interaction between SWT and GTK, specifically bug
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=97757. The following
- * loop stores the ancestors and the second loop will set the expanded
- * attribute on from the top level ancestor down to this child.
- */
- Stack<TreeItem> parents = new Stack<TreeItem>();
-
- boolean propagateColor = true;
- TreeItem parent = child.getParentItem();
- while (parent != null) {
- parents.push(parent);
-
- LogEvent parentEvent = (LogEvent) parent.getData();
- if (propagateColor) {
- if (parentEvent.type.isLowerPriorityThan(type)) {
- parent.setForeground(color);
- } else {
- propagateColor = false;
- }
- }
-
- parent = parent.getParentItem();
- }
-
- while (!parents.isEmpty()) {
- parent = parents.pop();
- parent.setExpanded(true);
- }
- }
- }
- }
- /**
- * One object that is shared across all logger instances in the same tree.
- * This class is the synchronization choke point that prevents the ui thread
- * from flushing events while other threads are adding them, and it also
- * provides tree-wide shared objects such as log item images.
- */
- private static class PendingUpdates {
- private List<LogEvent> updates = new LinkedList<LogEvent>();
-
- private final Object updatesLock = new Object();
-
- public void add(LogEvent update) {
- synchronized (updatesLock) {
- updates.add(update);
- }
- }
-
- /**
- * Flushes any pending log entries.
- *
- * @return <code>true</code> if any new entries were written
- */
- public synchronized boolean uiFlush(Tree tree) {
- // Move the list to flush into a local copy then release the udpate
- // lock so log events can keep coming in while we flush.
- //
- List<LogEvent> toFlush = null;
- synchronized (updatesLock) {
- if (updates.isEmpty()) {
- // Nothing to do.
- //
- return false;
- }
- toFlush = updates;
- updates = new LinkedList<LogEvent>();
- }
-
- for (Iterator<LogEvent> iter = toFlush.iterator(); iter.hasNext();) {
- LogEvent update = iter.next();
- // Loggers can be die while flushing, so we have to be sure never
- // to try to flush an entry to a dead logger.
- //
- if (!update.logger.isLoggerDead()) {
- update.uiFlush(tree);
- }
- }
-
- return true;
- }
- }
-
- // These don't get disposed, but they do last for the entire process, so
- // not a big deal.
- //
- private static final Image imageDebug = tryLoadImage("log-item-debug.gif");
- private static final Image imageError = tryLoadImage("log-item-error.gif");
- private static final Image imageInfo = tryLoadImage("log-item-info.gif");
- private static final Image imageLink = tryLoadImage("log-link.gif");
- private static final Image imageSpam = tryLoadImage("log-item-spam.gif");
- private static final Image imageTrace = tryLoadImage("log-item-trace.gif");
- private static final Image imageWarning = tryLoadImage("log-item-warning.gif");
-
- private static Image tryLoadImage(String simpleName) {
- InputStream is = TreeItemLogger.class.getResourceAsStream(simpleName);
- if (is != null) {
- try {
- Image image = new Image(null, is);
- return image;
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- } else {
- // Bad image.
- //
- return null;
- }
- }
-
- private boolean dead;
-
- private TreeItem lazyTreeItem;
-
- private final PendingUpdates sharedPendingUpdates;
-
- /**
- * Constructs the top-level TreeItemLogger.
- */
- public TreeItemLogger() {
- sharedPendingUpdates = new PendingUpdates();
- }
-
- /**
- * Constructs an internal logger.
- */
- private TreeItemLogger(PendingUpdates sharedPendingUpdates) {
- // Inherit the one and only update list from my parent.
- this.sharedPendingUpdates = sharedPendingUpdates;
- }
-
- public void markLoggerDead() {
- // Cannot kill the root logger, even if attempted.
- //
- if (getParentLogger() != null) {
- dead = true;
- }
- }
-
- /**
- * Flushes log records to the UI; must only be called by the UI thread.
- *
- * @return <code>true</code> if any new entries were written
- */
- public boolean uiFlush(Tree tree) {
- return sharedPendingUpdates.uiFlush(tree);
- }
-
- @Override
- protected AbstractTreeLogger doBranch() {
- return new TreeItemLogger(sharedPendingUpdates);
- }
-
- @Override
- protected void doCommitBranch(AbstractTreeLogger childBeingCommitted,
- Type type, String msg, Throwable caught, HelpInfo helpInfo) {
- if (isLoggerDead()) {
- return;
- }
-
- TreeItemLogger commitChild = (TreeItemLogger) childBeingCommitted;
- sharedPendingUpdates.add(new LogEvent(commitChild, true,
- commitChild.getBranchedIndex(), type, msg, caught, helpInfo));
- }
-
- @Override
- protected void doLog(int index, Type type, String msg, Throwable caught,
- HelpInfo helpInfo) {
- if (isLoggerDead()) {
- return;
- }
-
- sharedPendingUpdates.add(new LogEvent(this, false, index, type, msg,
- caught, helpInfo));
- }
-
- /**
- * Used for an extra check to avoid creating log events for dead loggers. A
- * dead logger is one that can no longer interact with the UI.
- */
- private boolean isLoggerDead() {
- // Deadness was cached.
- //
- if (dead) {
- return true;
- }
-
- // Check upward in the parent chain for any dead parent.
- //
- TreeItemLogger parentLogger = (TreeItemLogger) getParentLogger();
- if (parentLogger == null) {
- // This is the root logger, which cannot die.
- //
- return false;
- }
-
- // Otherwise, this logger is dead if its parent is dead (recursively).
- //
- if (parentLogger.isLoggerDead()) {
- // This logger is dead because my parent is dead.
- //
- markLoggerDead();
- return true;
- }
-
- // I'm not quite dead yet.
- //
- return false;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/shell/log/TreeLoggerWidget.java b/dev/core/src/com/google/gwt/dev/shell/log/TreeLoggerWidget.java
deleted file mode 100644
index 2bfc484..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/log/TreeLoggerWidget.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.log;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.HelpInfo;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.dev.shell.BrowserWidget;
-import com.google.gwt.dev.shell.log.TreeItemLogger.LogEvent;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
-import com.google.gwt.dev.util.log.CompositeTreeLogger;
-import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TreeEvent;
-import org.eclipse.swt.events.TreeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URL;
-
-/**
- * SWT widget containing a tree logger.
- */
-public class TreeLoggerWidget extends Composite implements TreeListener,
- SelectionListener {
-
- private boolean autoScroll;
-
- private final Text details;
-
- private final AbstractTreeLogger logger;
-
- private final TreeItemLogger uiLogger;
-
- private final Tree tree;
-
- /**
- * Creates a graphical widget, and optionally logging to file as well.
- *
- * @param parent the graphical interface parent
- * @param logFile the file to log to
- */
- public TreeLoggerWidget(Composite parent, File logFile, Type logLevel) {
- super(parent, SWT.NONE);
-
- setLayout(new FillLayout());
-
- // The sash (aka "splitter").
- //
- SashForm sash = new SashForm(this, SWT.VERTICAL);
-
- // The tree.
- //
- tree = new Tree(sash, SWT.BORDER | SWT.SHADOW_IN);
- tree.setLinesVisible(false);
- tree.addSelectionListener(this);
- tree.addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent e) {
- openHelpOnSelection(tree);
- }
- });
- tree.setFocus();
- tree.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- switch (e.keyCode) {
- case 'c':
- if (e.stateMask == SWT.CTRL) {
- copyTreeSelectionToClipboard(tree);
- }
- break;
- case '\r':
- case '\n':
- openHelpOnSelection(tree);
- }
- }
- });
-
- uiLogger = new TreeItemLogger();
- AbstractTreeLogger bestLogger = uiLogger;
- if (logFile != null) {
- try {
- PrintWriterTreeLogger fileLogger = new PrintWriterTreeLogger(logFile);
- bestLogger = new CompositeTreeLogger(uiLogger, fileLogger);
- fileLogger.setMaxDetail(logLevel);
- uiLogger.setMaxDetail(logLevel);
- } catch (IOException ex) {
- uiLogger.log(TreeLogger.ERROR, "Can't log to " +
- logFile.getAbsolutePath(), ex);
- }
- }
- logger = bestLogger;
- logger.setMaxDetail(logLevel);
-
- // The detail
- details = new Text(sash, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.BORDER
- | SWT.V_SCROLL);
- final Color detailsBgColor = new Color(null, 255, 255, 255);
- details.setBackground(detailsBgColor);
- details.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent arg0) {
- detailsBgColor.dispose();
- }
- });
-
- sash.setWeights(new int[] {80, 20});
-
- initLogFlushTimer(parent.getDisplay());
- }
-
- public void collapseAll() {
- TreeItem[] items = tree.getItems();
- for (int i = 0, n = items.length; i < n; ++i) {
- TreeItem item = items[i];
- collapseAll(item);
- }
- if (items.length > 0) {
- tree.setSelection(new TreeItem[] {items[0]});
- }
- }
-
- public void collapseAll(TreeItem from) {
- TreeItem[] items = from.getItems();
- for (int i = 0, n = items.length; i < n; ++i) {
- TreeItem item = items[i];
- collapseAll(item);
- }
- from.setExpanded(false);
- }
-
- public void expandAll() {
- TreeItem[] items = tree.getItems();
- for (int i = 0, n = items.length; i < n; ++i) {
- TreeItem item = items[i];
- expandAll(item);
- }
- if (items.length > 0) {
- tree.setSelection(new TreeItem[] {items[0]});
- }
- }
-
- public void expandAll(TreeItem from) {
- from.setExpanded(true);
- TreeItem[] items = from.getItems();
- for (int i = 0, n = items.length; i < n; ++i) {
- TreeItem item = items[i];
- expandAll(item);
- }
- }
-
- public boolean getAutoScroll() {
- return autoScroll;
- }
-
- public AbstractTreeLogger getLogger() {
- return logger;
- }
-
- public void removeAll() {
- tree.removeAll();
- details.setText("");
- }
-
- public void setAutoScroll(boolean autoScroll) {
- this.autoScroll = autoScroll;
- }
-
- public synchronized void treeCollapsed(TreeEvent treeEvent) {
- }
-
- public synchronized void treeExpanded(TreeEvent treeEvent) {
- }
-
- public void widgetDefaultSelected(SelectionEvent event) {
- }
-
- public void widgetSelected(SelectionEvent event) {
- syncDetailsPane((TreeItem) event.item);
- }
-
- protected void appendTreeItemText(PrintWriter result, TreeItem[] items,
- int depth) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- for (int j = 0; j < depth; j++) {
- result.print(" ");
- }
- result.println(item.getText());
- TreeItem[] children = item.getItems();
- if (children != null) {
- appendTreeItemText(result, children, depth + 1);
- }
- }
- }
-
- protected void copyTreeSelectionToClipboard(Tree tree) {
- TreeItem[] selected = tree.getSelection();
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw, false);
- if (selected != null) {
- appendTreeItemText(pw, selected, 0);
- }
- pw.close();
- Clipboard cb = new Clipboard(tree.getDisplay());
-
- final Object[] cbText = new Object[] {sw.toString()};
- final Transfer[] cbFormat = new Transfer[] {TextTransfer.getInstance()};
- cb.setContents(cbText, cbFormat);
- }
-
- protected void openHelpOnSelection(Tree tree) {
- TreeItem[] selected = tree.getSelection();
- for (TreeItem item : selected) {
- Object itemData = item.getData();
- if (itemData instanceof HelpInfo) {
- HelpInfo helpInfo = (HelpInfo) itemData;
- URL url = helpInfo.getURL();
- if (url != null) {
- BrowserWidget.launchExternalBrowser(logger, url.toString());
- }
- }
- }
- }
-
- private void initLogFlushTimer(final Display display) {
- final int flushDelay = 1000;
-
- display.timerExec(flushDelay, new Runnable() {
- public void run() {
- if (tree.isDisposed()) {
- return;
- }
-
- if (uiLogger.uiFlush(tree)) {
- // Sync to the end of the tree.
- //
- if (autoScroll) {
- TreeItem lastItem = findLastVisibleItem(tree);
- if (lastItem != null) {
- tree.setSelection(new TreeItem[] {lastItem});
- tree.showItem(lastItem);
- expandAllChildren(lastItem);
- syncDetailsPane(lastItem);
- }
- }
- }
-
- display.timerExec(flushDelay, this);
- }
-
- private void expandAllChildren(TreeItem item) {
- item.setExpanded(true);
- for (int i = 0, n = item.getItemCount(); i < n; ++i) {
- expandAllChildren(item.getItem(i));
- }
- }
-
- private TreeItem findLastVisibleItem(Tree tree) {
- int n = tree.getItemCount() - 1;
- if (n > 0) {
- TreeItem item = tree.getItem(n);
- if (item.getExpanded()) {
- return findLastVisibleItem(item);
- } else {
- return item;
- }
- } else {
- return null;
- }
- }
-
- private TreeItem findLastVisibleItem(TreeItem item) {
- int n = item.getItemCount() - 1;
- if (n > 0) {
- TreeItem child = item.getItem(n);
- if (child.getExpanded()) {
- return findLastVisibleItem(child);
- }
- }
- return item;
- }
- });
- }
-
- private void syncDetailsPane(TreeItem item) {
- // Try to get a LogEvent from the item's custom data.
- //
- TreeItemLogger.LogEvent logEvent = null;
- Object testLogEvent = item.getData();
- if (testLogEvent instanceof TreeItemLogger.LogEvent) {
- logEvent = (LogEvent) testLogEvent;
- }
-
- // Build a detail string.
- //
- StringBuffer sb = new StringBuffer();
-
- // Show the message type.
- //
- if (logEvent != null && logEvent.type != null) {
- sb.append("[");
- sb.append(logEvent.type.getLabel());
- sb.append("] ");
- }
-
- // Show the item text.
- //
- sb.append(item.getText());
- sb.append("\n");
-
- // Show the exception info for anything other than "UnableToComplete".
- //
- if (logEvent != null && logEvent.exceptionDetail != null) {
- sb.append(logEvent.exceptionDetail);
- }
-
- details.setText(sb.toString());
- }
-}
diff --git a/dev/core/src/com/google/gwt/util/tools/Utility.java b/dev/core/src/com/google/gwt/util/tools/Utility.java
index a7dab7b..8c9a339 100644
--- a/dev/core/src/com/google/gwt/util/tools/Utility.java
+++ b/dev/core/src/com/google/gwt/util/tools/Utility.java
@@ -159,13 +159,6 @@
return file;
}
- public static String getDevJarName() {
- if (sDevJarName == null) {
- computeInstallationPath();
- }
- return sDevJarName;
- }
-
/**
* @param parent Parent directory of the requested directory.
* @param dirName Requested name for the directory.
diff --git a/dev/linux/build.xml b/dev/linux/build.xml
deleted file mode 100755
index 0b077f4..0000000
--- a/dev/linux/build.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<project name="dev-linux" default="build" basedir=".">
- <property name="project.tail" value="dev/linux" />
- <property name="gwt.dev.swt.jar" value="org.eclipse.swt.gtk-linux-3.2.1.jar"/>
- <import file="../common.ant.xml" />
-</project>
diff --git a/dev/linux/src/com/google/gwt/dev/BootStrapPlatform.java b/dev/linux/src/com/google/gwt/dev/BootStrapPlatform.java
deleted file mode 100644
index f3313c4..0000000
--- a/dev/linux/src/com/google/gwt/dev/BootStrapPlatform.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-import com.google.gwt.dev.shell.moz.MozillaInstall;
-
-/**
- * Initializes low-level libraries for linux.
- */
-public class BootStrapPlatform {
-
- public static void applyPlatformHacks() {
- // nothing to do
- }
-
- public static void initGui() {
- // nothing to do
- }
-
- /**
- * Find a usable Mozilla installation and load it. Fail immediately, logging
- * to stderr and exiting with a failure code, if we are unable to find or load
- * it. If successful, store the loaded path in the property swt.mozilla.path
- * so SWT's Browser object can use it.
- */
- public static void initHostedMode() {
- String home = System.getenv("HOME");
- if (home == null || home.length() == 0) {
- System.err.println("The HOME environment variable must be defined.");
- System.exit(1);
- }
- MozillaInstall mozInstall = MozillaInstall.find();
- if (mozInstall == null) {
- System.err.println("** Unable to find a usable Mozilla install **");
- System.err.println("You may specify one in mozilla-hosted-browser.conf, "
- + "see comments in the file for details.");
- System.exit(1);
- }
- try {
- mozInstall.load();
- } catch (UnsatisfiedLinkError e) {
- System.err.println("** Unable to load Mozilla for hosted mode **");
- e.printStackTrace();
- System.exit(1);
- }
- String mozillaPath = mozInstall.getPath();
- System.setProperty("swt.mozilla.path", mozillaPath);
- }
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/BrowserWidgetMoz.java b/dev/linux/src/com/google/gwt/dev/shell/moz/BrowserWidgetMoz.java
deleted file mode 100644
index cd847ae..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/BrowserWidgetMoz.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.shell.BrowserWidget;
-import com.google.gwt.dev.shell.BrowserWidgetHost;
-import com.google.gwt.dev.shell.HostedHtmlVersion;
-import com.google.gwt.dev.shell.LowLevel;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.shell.ModuleSpaceHost;
-import com.google.gwt.dev.shell.moz.LowLevelMoz.ExternalFactory;
-import com.google.gwt.dev.shell.moz.LowLevelMoz.ExternalObject;
-
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.internal.mozilla.nsIWebBrowser;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Represents an individual browser window and all of its controls.
- */
-public class BrowserWidgetMoz extends BrowserWidget {
-
- private class ExternalObjectImpl implements ExternalObject {
-
- public boolean gwtOnLoad(int scriptObject, String moduleName, String version) {
- if (moduleName == null) {
- // Indicates one or more modules are being unloaded.
- return handleUnload(scriptObject);
- }
-
- TreeLogger logger = getHost().getLogger().branch(TreeLogger.DEBUG,
- "Loading an instance of module '" + moduleName + "'");
- try {
- if (!HostedHtmlVersion.validHostedHtmlVersion(logger, version)) {
- return false;
- }
-
- Object key = Integer.valueOf(scriptObject);
- // Attach a new ModuleSpace to make it programmable.
- ModuleSpaceHost msh = getHost().createModuleSpaceHost(logger,
- BrowserWidgetMoz.this, moduleName);
- ModuleSpace moduleSpace = new ModuleSpaceMoz(logger, msh, scriptObject,
- moduleName, key);
- attachModuleSpace(logger, moduleSpace);
- return true;
- } catch (Throwable e) {
- // We do catch Throwable intentionally because there are a ton of things
- // that can go wrong trying to load a module, including Error-derived
- // things like NoClassDefFoundError.
- logger.log(TreeLogger.ERROR, "Failure to load module '" + moduleName
- + "'", e);
- return false;
- }
- }
-
- /**
- * Causes a link to occur for the specified module.
- *
- * @param moduleName the module name to link
- * @return <code>true</code> if this module is stale and should be
- * reloaded
- */
- public boolean initModule(String moduleName) {
- return getHost().initModule(moduleName);
- }
-
- /**
- * Unload one or more modules.
- *
- * @param scriptObject window to unload, 0 if all
- */
- protected boolean handleUnload(int scriptObject) {
- try {
- Integer key = null;
- if (scriptObject != 0) {
- key = Integer.valueOf(scriptObject);
- }
- doUnload(key);
- return true;
- } catch (Throwable e) {
- getHost().getLogger().log(TreeLogger.ERROR,
- "Failure to unload modules", e);
- return false;
- }
- }
- }
-
- public BrowserWidgetMoz(Shell shell, BrowserWidgetHost host) {
- super(shell, host);
- host.getLogger().log(TreeLogger.DEBUG,
- "Using Mozilla install at " + MozillaInstall.getLoaded().getPath(),
- null);
-
- // Expose a 'window.external' object factory. The created object's
- // gwtOnLoad() method will be called when a hosted mode application's
- // wrapper
- // HTML is done loading.
- //
- final ExternalFactory externalFactory = new ExternalFactory() {
-
- private ExternalObject externalObject = null;
-
- public ExternalObject createExternalObject() {
- if (externalObject == null) {
- externalObject = new ExternalObjectImpl();
- }
- return externalObject;
- }
-
- public boolean matchesDOMWindow(int domWindow) {
- nsIWebBrowser webBrowser = (nsIWebBrowser) LowLevel.snatchFieldObjectValue(
- browser.getClass(), browser, "webBrowser");
- int[] aContentDOMWindow = new int[1];
- webBrowser.GetContentDOMWindow(aContentDOMWindow);
- if (aContentDOMWindow[0] == domWindow) {
- return true;
- }
- return false;
- }
-
- };
-
- LowLevelMoz.registerExternalFactory(externalFactory);
-
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- LowLevelMoz.unregisterExternalFactory(externalFactory);
- }
- });
- }
-
- @Override
- public String getUserAgent() {
- // OLD Mozilla. See UserAgent.gwt.xml
- return "gecko";
- }
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/GeckoDispatchAdapter.java b/dev/linux/src/com/google/gwt/dev/shell/moz/GeckoDispatchAdapter.java
deleted file mode 100644
index fbec94e..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/GeckoDispatchAdapter.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JavaDispatch;
-import com.google.gwt.dev.shell.JavaDispatchImpl;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.MethodAdaptor;
-import com.google.gwt.dev.shell.moz.LowLevelMoz.DispatchMethod;
-import com.google.gwt.dev.shell.moz.LowLevelMoz.DispatchObject;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-
-/**
- * Wraps an arbitrary Java Object as a Dispatch component. The class was
- * motivated by the need to expose Java objects into JavaScript.
- *
- * An instance of this class with no target is used to globally access all
- * static methods or fields.
- */
-class GeckoDispatchAdapter implements DispatchObject {
-
- private final CompilingClassLoader classLoader;
-
- private final JavaDispatch javaDispatch;
-
- /**
- * This constructor initializes as the static dispatcher, which handles only
- * static method calls and field references.
- *
- * @param cl this class's classLoader
- */
- GeckoDispatchAdapter(CompilingClassLoader cl) {
- javaDispatch = new JavaDispatchImpl(cl);
- classLoader = cl;
- }
-
- /**
- * This constructor initializes a dispatcher, around a particular instance.
- *
- * @param cl this class's classLoader
- * @param target the object being wrapped as an IDispatch
- */
- GeckoDispatchAdapter(CompilingClassLoader cl, Object target) {
- javaDispatch = new JavaDispatchImpl(cl, target);
- classLoader = cl;
- }
-
- /**
- * Retrieve a field and store in the passed JsValue. This function is called
- * exclusively from native code.
- *
- * @param name name of the field to retrieve
- * @param jsValue a reference to the JsValue object to receive the value of
- * the field
- */
- public void getField(String name, int jsRootedValue) {
- JsValueMoz jsValue = new JsValueMoz(jsRootedValue);
- // TODO(jat): factor out remaining code into platform-independent code
- int dispId = classLoader.getDispId(name);
- if (dispId < 0) {
- // no field by that name, return undefined
- jsValue.setUndefined();
- return;
- }
- if (javaDispatch.isField(dispId)) {
- Field field = javaDispatch.getField(dispId);
- JsValueGlue.set(jsValue, classLoader, field.getType(),
- javaDispatch.getFieldValue(dispId));
- return;
- } else {
- MethodAdaptor method = javaDispatch.getMethod(dispId);
- AccessibleObject obj = method.getUnderlyingObject();
- DispatchMethod dispMethod = (DispatchMethod) classLoader.getWrapperForObject(obj);
- if (dispMethod == null) {
- dispMethod = new MethodDispatch(classLoader, method);
- classLoader.putWrapperForObject(obj, dispMethod);
- }
- jsValue.setWrappedFunction(method.toString(), dispMethod);
- }
- }
-
- public Object getTarget() {
- return javaDispatch.getTarget();
- }
-
- public void setField(String name, int jsRootedValue) {
- JsValue jsValue = new JsValueMoz(jsRootedValue);
- int dispId = classLoader.getDispId(name);
- if (dispId < 0) {
- // no field by that name
- // TODO: expandos?
- throw new RuntimeException("No such field " + name);
- }
- if (javaDispatch.isMethod(dispId)) {
- throw new RuntimeException("Cannot reassign method " + name);
- }
- Field field = javaDispatch.getField(dispId);
- Object val = JsValueGlue.get(jsValue, classLoader, field.getType(),
- "setField");
- javaDispatch.setFieldValue(dispId, val);
- }
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/JsValueMoz.java b/dev/linux/src/com/google/gwt/dev/shell/moz/JsValueMoz.java
deleted file mode 100644
index ed739ce..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/JsValueMoz.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.moz.LowLevelMoz.DispatchMethod;
-import com.google.gwt.dev.shell.moz.LowLevelMoz.DispatchObject;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents a Mozilla JavaScript value.
- *
- * TODO(jat): 64-bit compatibility - currently underlying pointers are passed
- * around in a Java int, which only works on standard 32-bit platforms where
- * sizeof(void*)=4
- */
-public class JsValueMoz extends JsValue {
-
- /**
- * Records debug information, only used when {@link JsValueMoz#debugFlag} is
- * <code>true</code>.
- */
- private static class DebugLogging {
- private Map<Integer, Throwable> alreadyCleanedJsRootedValues = Collections.synchronizedMap(new HashMap<Integer, Throwable>());
- private int maxActive = 0;
- private int numActive = 0;
- private Map<Integer, Throwable> seenJsRootedValues = Collections.synchronizedMap(new HashMap<Integer, Throwable>());
- private int totAlloc = 0;
-
- /**
- * Count a JsValueMoz instance being created.
- *
- * Verify that the underlying JsRootedValue is not currently active, and
- * mark that it is active.
- *
- * This is debug code that is only executed if debugFlag is true. Since this
- * is a private static final field, the compiler should optimize out all
- * this code. It is useful to have for tracking down problems, so it is
- * being left in but disabled.
- */
- public void createInstance(int jsRootedValue) {
- Integer jsrv = new Integer(jsRootedValue);
- if (seenJsRootedValues.containsKey(jsrv)) {
- Throwable t = seenJsRootedValues.get(jsrv);
- String msg = hexString(jsRootedValue);
- System.err.println(msg + ", original caller stacktrace:");
- t.printStackTrace();
- throw new RuntimeException(msg);
- }
- Throwable t = new Throwable();
- seenJsRootedValues.put(jsrv, t);
- if (alreadyCleanedJsRootedValues.containsKey(jsrv)) {
- alreadyCleanedJsRootedValues.remove(jsrv);
- }
- if (++numActive > maxActive) {
- maxActive = numActive;
- }
- ++totAlloc;
- }
-
- /**
- * Count a JsValueMoz instance being destroyed.
- *
- * Verify that this instance hasn't already been destroyed, that it has
- * previously been created, and that the underlying JsRootedValue is only
- * being cleaned once.
- *
- * This is debug code that is only executed if debugFlag is true. Since this
- * is a private static final field, the compiler should optimize out all
- * this code. It is useful to have for tracking down problems, so it is
- * being left in but disabled.
- */
- public void destroyInstance(int jsRootedValue) {
- if (jsRootedValue == 0) {
- throw new RuntimeException("Cleaning already-cleaned JsValueMoz");
- }
- Integer jsrv = new Integer(jsRootedValue);
- if (!seenJsRootedValues.containsKey(jsrv)) {
- throw new RuntimeException("cleaning up 0x" + hexString(jsRootedValue)
- + ", not active");
- }
- if (alreadyCleanedJsRootedValues.containsKey(jsrv)) {
- Throwable t = seenJsRootedValues.get(jsrv);
- String msg = "Already cleaned 0x" + hexString(jsRootedValue);
- System.err.println(msg + ", original allocator stacktrace:");
- t.printStackTrace();
- throw new RuntimeException(msg);
- }
- Throwable t = new Throwable();
- alreadyCleanedJsRootedValues.put(jsrv, t);
- seenJsRootedValues.remove(jsrv);
- --numActive;
- }
-
- /**
- * Print collected statistics on JsValueMoz usage.
- */
- public void dumpStatistics() {
- System.gc();
- System.out.println("JsValueMoz usage:");
- System.out.println(" " + totAlloc + " total instances created");
- System.out.println(" " + maxActive + " at any one time");
- System.out.println(" " + seenJsRootedValues.size() + " uncleaned entries");
- }
- }
-
- private static class JsCleanupMoz implements JsCleanup {
- private final int jsRootedValue;
-
- public JsCleanupMoz(int jsRootedValue) {
- this.jsRootedValue = jsRootedValue;
- }
-
- public void doCleanup() {
- _destroyJsRootedValue(jsRootedValue);
- }
- }
-
- /**
- * Flag to enable debug checks on underlying JsRootedValues.
- */
- private static final boolean debugFlag = false;
-
- /**
- * Flag to enable debug checks on underlying JsRootedValues.
- */
- private static final DebugLogging debugInfo = debugFlag ? new DebugLogging()
- : null;
-
- /**
- * This must match the value from jsapi.h.
- */
- private static final int JSVAL_VOID = 0x80000001;
-
- // CHECKSTYLE_NAMING_OFF -- native methods start with '_'
- protected static native boolean _getBoolean(int jsRootedValue);
-
- protected static native int _getInt(int jsRootedValue);
-
- protected static native int _getJsval(int jsRootedValue);
-
- protected static native double _getNumber(int jsRootedValue);
-
- protected static native String _getString(int jsRootedValue);
-
- protected static native String _getTypeString(int jsRootedValue);
-
- protected static native DispatchObject _getWrappedJavaObject(int jsRootedValue);
-
- protected static native boolean _isBoolean(int jsRootedValue);
-
- protected static native boolean _isInt(int jsRootedValue);
-
- protected static native boolean _isJavaScriptObject(int jsRootedValue);
-
- protected static native boolean _isJavaScriptString(int jsRootedValue);
-
- protected static native boolean _isNull(int jsRootedValue);
-
- protected static native boolean _isNumber(int jsRootedValue);
-
- protected static native boolean _isString(int jsRootedValue);
-
- protected static native boolean _isUndefined(int jsRootedValue);
-
- protected static native boolean _isWrappedJavaObject(int jsRootedValue);
-
- protected static native void _setBoolean(int jsRootedValue, boolean val);
-
- protected static native void _setDouble(int jsRootedValue, double val);
-
- protected static native void _setInt(int jsRootedValue, int val);
-
- protected static native void _setJsRootedValue(int jsRootedValue,
- int jsOtherRootedValue);
-
- protected static native void _setJsval(int jsRootedValue, int jsval);
-
- protected static native void _setNull(int jsRootedValue);
-
- protected static native void _setString(int jsRootedValue, String val);
-
- protected static native void _setUndefined(int jsRootedValue);
-
- protected static native void _setWrappedFunction(int jsRootedValue,
- String methodName, DispatchMethod dispatchMethod);
-
- protected static native void _setWrappedJavaObject(int jsRootedValue,
- DispatchObject val);
-
- private static native int _copyJsRootedValue(int jsRootedValue);
-
- /**
- * Create a JsRootedValue and return a pointer to it as a Java int.
- *
- * @param jsval JavaScript jsval for initial value
- * @return pointer to JsRootedValue object as an integer
- */
- private static native int _createJsRootedValue(int jsval);
-
- /**
- * Destroy a JsRootedValue.
- *
- * @param jsRootedValue pointer to underlying JsRootedValue as an integer.
- */
- private static native void _destroyJsRootedValue(int jsRootedValue);
-
- // CHECKSTYLE_NAMING_ON
-
- /**
- * Convert an address to a hex string.
- *
- * @param jsRootedValue underlying JavaScript value as an opaque integer
- * @return a string with the JavaScript value represented as hex
- */
- private static String hexString(int jsRootedValue) {
- long l = jsRootedValue;
- l = l & 0xffffffffL;
- return Long.toHexString(l);
- }
-
- // pointer to underlying JsRootedValue object as an integer
- private int jsRootedValue;
-
- /**
- * Create a JsValueMoz object representing the undefined value.
- */
- public JsValueMoz() {
- this.jsRootedValue = _createJsRootedValue(JSVAL_VOID);
- if (debugFlag) {
- debugInfo.createInstance(jsRootedValue);
- }
- }
-
- /**
- * Create a JsValueMoz object wrapping a JsRootedValue object given the
- * pointer to it as an integer.
- *
- * @param jsRootedValue pointer to underlying JsRootedValue as an integer.
- */
- public JsValueMoz(int jsRootedValue) {
- this.jsRootedValue = jsRootedValue;
- if (debugFlag) {
- debugInfo.createInstance(jsRootedValue);
- }
- }
-
- /**
- * Copy constructor.
- *
- * @param other JsValueMoz instance to copy
- */
- public JsValueMoz(JsValueMoz other) {
- jsRootedValue = _copyJsRootedValue(other.jsRootedValue);
- if (debugFlag) {
- debugInfo.createInstance(jsRootedValue);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getBoolean()
- */
- @Override
- public boolean getBoolean() {
- return _getBoolean(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getInt()
- */
- @Override
- public int getInt() {
- return _getInt(jsRootedValue);
- }
-
- @Override
- public int getJavaScriptObjectPointer() {
- assert isJavaScriptObject();
- return _getJsval(jsRootedValue);
- }
-
- /**
- * Returns the underlying JavaScript object pointer as an integer.
- */
- public int getJsRootedValue() {
- return jsRootedValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getNumber()
- */
- @Override
- public double getNumber() {
- return _getNumber(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getString()
- */
- @Override
- public String getString() {
- return _getString(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getTypeString()
- */
- @Override
- public String getTypeString() {
- return _getTypeString(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getWrappedJavaObject()
- */
- @Override
- public Object getWrappedJavaObject() {
- DispatchObject obj = _getWrappedJavaObject(jsRootedValue);
- return obj.getTarget();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isBoolean()
- */
- @Override
- public boolean isBoolean() {
- return _isBoolean(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isInt()
- */
- @Override
- public boolean isInt() {
- return _isInt(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isJavaScriptObject()
- */
- @Override
- public boolean isJavaScriptObject() {
- return _isJavaScriptObject(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isNull()
- */
- @Override
- public boolean isNull() {
- return _isNull(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isNumber()
- */
- @Override
- public boolean isNumber() {
- return _isNumber(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isString()
- */
- @Override
- public boolean isString() {
- // String objects are acceptable for String value returns
- return _isString(jsRootedValue) || _isJavaScriptString(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isUndefined()
- */
- @Override
- public boolean isUndefined() {
- return _isUndefined(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isWrappedJavaObject()
- */
- @Override
- public boolean isWrappedJavaObject() {
- return _isWrappedJavaObject(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setBoolean(boolean)
- */
- @Override
- public void setBoolean(boolean val) {
- _setBoolean(jsRootedValue, val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setByte(byte)
- */
- @Override
- public void setByte(byte val) {
- _setInt(jsRootedValue, val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setChar(char)
- */
- @Override
- public void setChar(char val) {
- _setInt(jsRootedValue, val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setDouble(double)
- */
- @Override
- public void setDouble(double val) {
- _setDouble(jsRootedValue, val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setInt(int)
- */
- @Override
- public void setInt(int val) {
- _setInt(jsRootedValue, val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setNull()
- */
- @Override
- public void setNull() {
- _setNull(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setShort(short)
- */
- @Override
- public void setShort(short val) {
- _setInt(jsRootedValue, val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setString(java.lang.String)
- */
- @Override
- public void setString(String val) {
- _setString(jsRootedValue, val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setUndefined()
- */
- @Override
- public void setUndefined() {
- _setUndefined(jsRootedValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setValue(com.google.gwt.dev.shell.JsValue)
- */
- @Override
- public void setValue(JsValue other) {
- _setJsRootedValue(jsRootedValue, ((JsValueMoz) other).jsRootedValue);
- }
-
- /**
- * Wrap a function call to a Java method in this JavaScript value.
- *
- * @param methodName the name of the method to invoke
- * @param dispatchMethod the wrapper object
- */
- public void setWrappedFunction(String methodName,
- DispatchMethod dispatchMethod) {
- Integer jsval = LowLevelMoz.sObjectToJsval.get(dispatchMethod);
- if (jsval != null) {
- _setJsval(jsRootedValue, jsval);
- } else {
- _setWrappedFunction(jsRootedValue, methodName, dispatchMethod);
- LowLevelMoz.sObjectToJsval.put(dispatchMethod, _getJsval(jsRootedValue));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setWrappedJavaObject(com.google.gwt.dev.shell.CompilingClassLoader,
- * java.lang.Object)
- */
- @Override
- public <T> void setWrappedJavaObject(CompilingClassLoader cl, T val) {
- if (val == null) {
- setNull();
- return;
- }
- DispatchObject dispObj;
- if (val instanceof DispatchObject) {
- dispObj = (DispatchObject) val;
- } else {
- dispObj = (DispatchObject) cl.getWrapperForObject(val);
- if (dispObj == null) {
- dispObj = new GeckoDispatchAdapter(cl, val);
- cl.putWrapperForObject(val, dispObj);
- }
- }
- Integer cached = LowLevelMoz.sObjectToJsval.get(dispObj);
- if (cached != null) {
- _setJsval(jsRootedValue, cached);
- } else {
- _setWrappedJavaObject(jsRootedValue, dispObj);
- LowLevelMoz.sObjectToJsval.put(dispObj, _getJsval(jsRootedValue));
- }
- }
-
- /**
- * Create a cleanup object that will free the underlying JsRootedValue object.
- */
- @Override
- protected JsCleanup createCleanupObject() {
- JsCleanup cleanup = new JsCleanupMoz(jsRootedValue);
- if (debugFlag) {
- debugInfo.destroyInstance(jsRootedValue);
- jsRootedValue = 0;
- }
- return cleanup;
- }
-
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/LowLevelMoz.java b/dev/linux/src/com/google/gwt/dev/shell/moz/LowLevelMoz.java
deleted file mode 100644
index 2b89c2e..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/LowLevelMoz.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import com.google.gwt.dev.shell.LowLevel;
-
-import java.util.IdentityHashMap;
-import java.util.Map;
-import java.util.Vector;
-
-/**
- * Various low-level helper methods for dealing with Gecko.
- */
-public class LowLevelMoz {
-
- /**
- * Provides interface for methods to be exposed on JavaScript side.
- */
- public interface DispatchMethod {
- /**
- * Invoke a Java method from JavaScript.
- *
- * @param jsthis the wrapped Java object to invoke
- * @param jsargs an array of JavaScript values to pass as parameters
- * @param returnValue the JavaScript value in which to store the returned
- * value
- */
- void invoke(int jsthis, int[] jsargs, int returnValue);
- }
-
- /**
- * Provides interface for objects to be exposed to JavaScript code.
- */
- public interface DispatchObject {
- /**
- * Retrieve a field from an object.
- *
- * @param name the name of the field
- * @param value pointer to the JsRootedValue to receive the field value
- */
- void getField(String name, int value);
-
- Object getTarget();
-
- /**
- * Set the value of a field on an object.
- *
- * @param name the name of the field
- * @param value pointer to the JsRootedValue to store into the field
- */
- void setField(String name, int value);
- }
-
- interface ExternalFactory {
- ExternalObject createExternalObject();
-
- boolean matchesDOMWindow(int domWindow);
- }
-
- /**
- * TODO: rip this whole thing out if possible and use DispatchObject like on
- * Safari.
- */
- interface ExternalObject {
- boolean initModule(String moduleName);
-
- boolean gwtOnLoad(int scriptGlobalObject, String moduleName, String version);
- }
-
- /**
- * Stores a map from DispatchObject/DispatchMethod to the live underlying
- * jsval. This is used to both preserve identity for the same Java Object and
- * also prevent GC.
- */
- static Map<Object, Integer> sObjectToJsval = new IdentityHashMap<Object, Integer>();
-
- private static Vector<ExternalFactory> sExternalFactories = new Vector<ExternalFactory>();
- private static boolean sInitialized = false;
-
- /**
- * Executes JavaScript code, retaining file and line information.
- *
- * @param scriptObject An opaque handle to the script frame window
- * @param code The JavaScript code to execute
- * @param file A file name associated with the code
- * @param line A line number associated with the code.
- */
- public static void executeScriptWithInfo(int scriptObject, String code,
- String file, int line) {
- if (!_executeScriptWithInfo(scriptObject, code, file, line)) {
- throw new RuntimeException(file + "(" + line
- + "): Failed to execute script: " + code);
- }
- }
-
- public static synchronized void init() {
- // Force LowLevel initialization to load gwt-ll
- LowLevel.init();
- if (!sInitialized) {
- if (!_registerExternalFactoryHandler()) {
- throw new RuntimeException(
- "Failed to register external factory handler.");
- }
- sInitialized = true;
- }
- }
-
- /**
- * Invokes a method implemented in JavaScript.
- *
- * @param scriptObject An opaque handle to the script frame window
- * @param methodName the method name on jsthis to call
- * @param jsthis A wrapped java object as a JsRootedValue pointer
- * @param jsargs the arguments to pass to the method as JsRootedValue pointers
- * @param retval the jsvalue to write the result into
- * @throws RuntimeException if the invoke fails
- */
- public static void invoke(int scriptObject, String methodName, int jsthis,
- int[] jsargs, int retval) {
- if (!_invoke(scriptObject, methodName, jsthis, jsargs, retval)) {
- throw new RuntimeException("Failed to invoke native method: "
- + methodName + " with " + jsargs.length + " arguments.");
- }
- }
-
- /**
- * Call this to raise an exception in JavaScript before returning control.
- * Currently, the JavaScript exception throw is always null.
- */
- public static void raiseJavaScriptException() {
- if (!_raiseJavaScriptException()) {
- throw new RuntimeException(
- "Failed to raise Java Exception into JavaScript.");
- }
- }
-
- /**
- * BrowserWindows register here so that if their contained window gets a call
- * to window.external, the call can be routed correctly by nsIDOMWindow
- * pointer.
- *
- * @param externalFactory the factory to register
- */
- public static void registerExternalFactory(ExternalFactory externalFactory) {
- synchronized (sExternalFactories) {
- sExternalFactories.add(externalFactory);
- }
- }
-
- /**
- * Unregisters an existing registration.
- *
- * @param externalFactory the factory to unregister
- */
- public static void unregisterExternalFactory(ExternalFactory externalFactory) {
- synchronized (sExternalFactories) {
- sExternalFactories.remove(externalFactory);
- }
- }
-
- /**
- * Called from native code to create an external object for a particular
- * window.
- *
- * @param domWindow an nsIDOMWindow to check against our ExternalFactories map
- * @return a new ExternalObject
- */
- protected static ExternalObject createExternalObjectForDOMWindow(int domWindow) {
- for (ExternalFactory fac : sExternalFactories) {
- if (fac.matchesDOMWindow(domWindow)) {
- return fac.createExternalObject();
- }
- }
- return null;
- }
-
- /**
- * Called from native code to do tracing.
- *
- * @param s the string to trace
- */
- protected static void trace(String s) {
- System.out.println(s);
- System.out.flush();
- }
-
- /**
- * Native code accessor to remove the mapping upon GC.
- */
- static void removeJsvalForObject(Object o) {
- sObjectToJsval.remove(o);
- }
-
- // CHECKSTYLE_NAMING_OFF: Non JSNI native code may have leading '_'s.
-
- private static native boolean _executeScriptWithInfo(int scriptObject,
- String newScript, String file, int line);
-
- /**
- * Native method for invoking a JavaScript method.
- *
- * @param scriptObject nsIScriptGlobalObject* as an int
- * @param methodName name of JavaScript method
- * @param jsThisInt JavaScript object to invoke the method on, as a
- * JsRootedValue int
- * @param jsArgsInt array of arguments, as an array of JsRootedValue ints
- * @param jsRetValint pointer to JsRootedValue to receive return value
- * @return true on success
- */
- private static native boolean _invoke(int scriptObject, String methodName,
- int jsThisInt, int[] jsArgsInt, int jsRetValInt);
-
- private static native boolean _raiseJavaScriptException();
-
- private static native boolean _registerExternalFactoryHandler();
-
- // CHECKSTYLE_NAMING_ON
-
- /**
- * Print debug information for a JS method invocation.
- *
- * TODO(jat): remove this method
- *
- * @param methodName the name of the JS method being invoked
- * @param jsthis the JS object with the named method
- * @param jsargs an array of arguments to the method
- */
- @SuppressWarnings("unused")
- // kept for future debugging purposes
- private static void printInvocationParams(String methodName,
- JsValueMoz jsthis, JsValueMoz[] jsargs) {
- System.out.println("LowLevelMoz.invoke:");
- System.out.println(" method = " + methodName);
- System.out.println(" # args = " + (jsargs.length));
- System.out.println(" jsthis = " + jsthis.toString());
- for (int i = 0; i < jsargs.length; ++i) {
- System.out.println(" jsarg[" + i + "] = " + jsargs[i].toString());
- }
- System.out.println("");
- }
-
- /**
- * Not instantiable.
- */
- private LowLevelMoz() {
- }
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/MethodDispatch.java b/dev/linux/src/com/google/gwt/dev/shell/moz/MethodDispatch.java
deleted file mode 100644
index 805e419..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/MethodDispatch.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.MethodAdaptor;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.shell.moz.LowLevelMoz.DispatchMethod;
-
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Wraps an arbitrary Java Method as a Dispatchable component. The class was
- * motivated by the need to expose Java objects into JavaScript.
- */
-class MethodDispatch implements DispatchMethod {
-
- private final CompilingClassLoader classLoader;
-
- private final MethodAdaptor method;
-
- public MethodDispatch(CompilingClassLoader classLoader, MethodAdaptor method) {
- this.classLoader = classLoader;
- this.method = method;
- }
-
- /**
- * Invoke a Java method from JavaScript. This is called solely from native
- * code.
- *
- * @param jsthis JavaScript reference to Java object
- * @param jsargs array of JavaScript values for parameters
- * @param returnValue JavaScript value to return result in
- * @throws RuntimeException if improper arguments are supplied
- *
- * TODO(jat): lift most of this interface to platform-independent code (only
- * exceptions still need to be made platform-independent)
- */
- public void invoke(int jsthisInt, int[] jsargsInt, int returnValueInt) {
- JsValue jsthis = new JsValueMoz(jsthisInt);
- JsValue jsargs[] = new JsValue[jsargsInt.length];
- for (int i = 0; i < jsargsInt.length; ++i) {
- jsargs[i] = new JsValueMoz(jsargsInt[i]);
- }
- JsValue returnValue = new JsValueMoz(returnValueInt);
- Class<?>[] paramTypes = method.getParameterTypes();
- int argc = paramTypes.length;
- Object args[] = new Object[argc];
- // too many arguments are ok: the extra will be silently ignored
- if (jsargs.length < argc) {
- throw new RuntimeException("Not enough arguments to " + method);
- }
- Object jthis = null;
- if (method.needsThis()) {
- jthis = JsValueGlue.get(jsthis, classLoader, method.getDeclaringClass(),
- "invoke this");
- }
- for (int i = 0; i < argc; ++i) {
- args[i] = JsValueGlue.get(jsargs[i], classLoader, paramTypes[i],
- "invoke arguments");
- }
- try {
- Object result;
- try {
- result = method.invoke(jthis, args);
- } catch (IllegalAccessException e) {
- // should never, ever happen
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- JsValueGlue.set(returnValue, classLoader, method.getReturnType(), result);
- } catch (InstantiationException e) {
- // If we get here, it means an exception is being thrown from
- // Java back into JavaScript
- Throwable t = e.getCause();
- // TODO(jat): if this was originally JavaScript exception, re-throw the
- // original exception rather than just a null.
- ModuleSpace.setThrownJavaException(t);
- LowLevelMoz.raiseJavaScriptException();
- } catch (InvocationTargetException e) {
- // If we get here, it means an exception is being thrown from
- // Java back into JavaScript
- Throwable t = e.getTargetException();
- // TODO(jat): if this was originally JavaScript exception, re-throw the
- // original exception rather than just a null.
- ModuleSpace.setThrownJavaException(t);
- LowLevelMoz.raiseJavaScriptException();
- } catch (IllegalArgumentException e) {
- // TODO(jat): log to treelogger instead? If so, how do I get to it?
- System.err.println("MethodDispatch.invoke, method=" + method.toString()
- + ": argument mismatch");
- for (int i = 0; i < argc; ++i) {
- System.err.println(" param " + i + " type is "
- + paramTypes[i].toString() + " value is type "
- + jsargs[i].getTypeString() + " = " + args[i].toString());
- }
- throw e;
- }
- }
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/ModuleSpaceMoz.java b/dev/linux/src/com/google/gwt/dev/shell/moz/ModuleSpaceMoz.java
deleted file mode 100644
index 874be51..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/ModuleSpaceMoz.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.javac.JsniMethod;
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.DispatchIdOracle;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.Jsni;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.shell.ModuleSpaceHost;
-
-import java.util.List;
-
-/**
- * An implementation of {@link com.google.gwt.dev.shell.ModuleSpace} for
- * Mozilla.
- */
-public class ModuleSpaceMoz extends ModuleSpace {
-
- private final int window;
-
- /**
- * Constructs a browser interface for use with a Mozilla global window object.
- */
- public ModuleSpaceMoz(TreeLogger logger, ModuleSpaceHost host,
- int scriptGlobalObject, String moduleName, Object key) {
- super(logger, host, moduleName, key);
-
- // Hang on to the parent window.
- //
- window = scriptGlobalObject;
- SwtGeckoGlue.addRefInt(window);
- }
-
- /**
- * Define one or more JSNI methods.
- *
- * @param logger
- * @param jsniMethods
- */
- public void createNativeMethods(TreeLogger logger,
- List<JsniMethod> jsniMethods, DispatchIdOracle dispatchIdOracle) {
- for (JsniMethod jsniMethod : jsniMethods) {
- String body = Jsni.getJavaScriptForHostedMode(logger, dispatchIdOracle,
- jsniMethod);
- if (body == null) {
- // The error has been logged; just ignore it for now.
- continue;
- }
- createNative(jsniMethod.location(), jsniMethod.line(), jsniMethod.name(),
- jsniMethod.paramNames(), body);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.ModuleSpace#dispose()
- */
- @Override
- public void dispose() {
- SwtGeckoGlue.releaseInt(window);
- super.dispose();
- }
-
- @Override
- protected void createStaticDispatcher(TreeLogger logger) {
- createNative("initializeStaticDispatcher", 0, "__defineStatic",
- new String[] {"__arg0"}, "window.__static = __arg0;");
- }
-
- /**
- * Invokes a native JavaScript function.
- *
- * @param name the name of the function to invoke
- * @param jthis the function's 'this' context
- * @param types the type of each argument
- * @param args the arguments to be passed
- * @return the return value as a Object.
- */
- @Override
- protected JsValue doInvoke(String name, Object jthis, Class<?>[] types,
- Object[] args) {
- CompilingClassLoader isolatedClassLoader = getIsolatedClassLoader();
-
- JsValueMoz jsthis = new JsValueMoz();
- Class<?> jthisType = (jthis == null) ? Object.class : jthis.getClass();
- JsValueGlue.set(jsthis, isolatedClassLoader, jthisType, jthis);
-
- int argc = args.length;
- JsValueMoz argv[] = new JsValueMoz[argc];
- int[] jsArgsInt = new int[argc];
- for (int i = 0; i < argc; ++i) {
- argv[i] = new JsValueMoz();
- JsValueGlue.set(argv[i], isolatedClassLoader, types[i], args[i]);
- jsArgsInt[i] = argv[i].getJsRootedValue();
- }
- JsValueMoz returnVal = new JsValueMoz();
- LowLevelMoz.invoke(window, name, jsthis.getJsRootedValue(), jsArgsInt,
- returnVal.getJsRootedValue());
- return returnVal;
- }
-
- @Override
- protected Object getStaticDispatcher() {
- return new GeckoDispatchAdapter(getIsolatedClassLoader());
- }
-
- /**
- * Defines a new native JavaScript function.
- *
- * @param name the function's name, usually a JSNI signature
- * @param paramNames parameter names
- * @param js the script body
- */
- private void createNative(String file, int line, String jsniSignature,
- String[] paramNames, String js) {
- // Execute the function definition within the browser, which will define
- // a new top-level function.
- //
- String newScript = createNativeMethodInjector(jsniSignature, paramNames, js);
- LowLevelMoz.executeScriptWithInfo(window, newScript, file, line);
- }
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/MozillaInstall.java b/dev/linux/src/com/google/gwt/dev/shell/moz/MozillaInstall.java
deleted file mode 100644
index e9aebdb..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/MozillaInstall.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import com.google.gwt.util.tools.Utility;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-
-/**
- * Utility class to represent a Mozilla installation, including its installation
- * directory and a load order file. Instances are immutable, and static helper
- * functions are provided to create instances.
- */
-public class MozillaInstall {
-
- // Default hosted browser config file.
- private static final String CONFIG_FILENAME = "mozilla-hosted-browser.conf";
-
- // Default load order file (optional).
- private static final String LOAD_ORDER_CONFIG_FILE = "gwt-dl-loadorder.conf";
-
- // Mozilla installation which was actually loaded.
- private static MozillaInstall loadedInstallation = null;
-
- /**
- * Find a suitable mozilla install for GWT hosted mode.
- *
- * This is done by reading the mozilla-hosted-browser.conf in the install
- * directory, which contains one or more entries, each describing a Mozilla
- * install to try and load. The first suitable (present and compiled against
- * GTK2 instead of GTK1) one found is used.
- *
- * Blank lines and lines beginning with # are ignored. The install directory
- * is prepended to non-absolute paths.
- *
- * @return a MozillaInstall instance or <code>null</code> if none could be
- * found
- */
- public static MozillaInstall find() {
- String installPath = Utility.getInstallPath();
- try {
- // try to make absolute
- installPath = new File(installPath).getCanonicalPath();
- } catch (IOException e) {
- /*
- * We might have an exception here if a parent directory is not readable,
- * so leave it non-absolute and hope the relative path works. If this
- * fails, the libraries will fail to load when SWT initializes.
- */
- }
-
- /*
- * Read from the mozilla-hosted-browser.conf file and try to find a suitable
- * mozilla installation. Return immediately if a suitable one is found.
- */
- try {
- BufferedReader reader = new BufferedReader(new FileReader(installPath
- + "/" + CONFIG_FILENAME));
- try { // make sure we close the reader
- String mozillaDir;
- while ((mozillaDir = reader.readLine()) != null) {
- if (mozillaDir.startsWith("#") || mozillaDir.matches("^\\s*$")) {
- // lines beginning with # are comments, ignore blank lines
- continue;
- }
- if (!mozillaDir.startsWith("/")) {
- mozillaDir = installPath + "/" + mozillaDir;
- }
- MozillaInstall mozInstall = new MozillaInstall(mozillaDir);
- if (mozInstall.isAcceptable()) {
- return mozInstall;
- }
- }
- } finally {
- reader.close();
- }
- } catch (FileNotFoundException e) {
- // fall through to common error-path code
- } catch (IOException e) {
- // fall through to common error-path code
- }
-
- // if we get here, nothing worked. Return failure.
- return null;
- }
-
- /**
- * @return the installation which was loaded, or null if none
- */
- public static MozillaInstall getLoaded() {
- return loadedInstallation;
- }
-
- /**
- * The absolute path to a directory containing a Mozilla install.
- */
- private String path;
-
- /**
- * Create a new instance. Private since this should only be created via the
- * find factory method.
- *
- * @param path absolute path to the directory containing the Mozilla install
- */
- private MozillaInstall(String path) {
- this.path = path;
- }
-
- /**
- * @return the path of this Mozilla install
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Load any libraries required for this Mozilla install, reading from the
- * loadOrderFile.
- *
- * The format of the load order configuration file is simply one library path
- * per line (if non-absolute, the install directory is prepended) to be
- * loaded. This is necessary because we have to forcibly load some libraries
- * to make sure they are used instead of system-supplied libraries.
- *
- * Blank lines and lines beginning with # are ignored.
- *
- * @throws UnsatisfiedLinkError if libxpcom.so failed to load
- */
- public void load() {
- try {
- /*
- * Read the library load order configuration file to get the list of
- * libraries which must be preloaded. This is required because Eclipse
- * seems to always add the system mozilla directory to the
- * java.library.path, which results in loading the system-supplied
- * libraries to fulfill dependencies rather than the ones we supply. So,
- * to get around this we preload individual libraries in a particular
- * order to make sure they get pulled in properly.
- *
- * The file has one line per library, each giving either an absolute path
- * or a path relative to the browser directory, in the order the libraries
- * should be loaded.
- */
- String loadOrderFile = path + "/" + LOAD_ORDER_CONFIG_FILE;
- BufferedReader reader = new BufferedReader(new FileReader(loadOrderFile));
- try {
- // read each line and load the library specified
- String library;
- while ((library = reader.readLine()) != null) {
- if (library.startsWith("#") || library.matches("^\\s*$")) {
- // lines beginning with # are comments, ignore blank lines
- continue;
- }
- if (!library.startsWith("/")) {
- library = path + "/" + library;
- }
- System.load(library);
- }
- } finally {
- reader.close();
- }
- } catch (FileNotFoundException e) {
- // ignore error, assume system will load libraries properly
- } catch (IOException e) {
- // ignore error, assume system will load libraries properly
- }
- /*
- * Forcibly load libxpcom.so. Since it has to be loaded before SWT loads its
- * swt-mozilla library, load it here. This will also cause a failure early
- * in the process if we have a problem rather than waiting until SWT starts
- * up.
- */
- System.load(path + "/libxpcom.so");
- loadedInstallation = this;
- }
-
- /**
- * Checks to see if the specified path refers to an acceptable Mozilla
- * install.
- *
- * In this case, acceptable means it is present and was not compiled against
- * GTK1.
- *
- * Note: Embedding a Mozilla GTK1.2 causes a crash. The workaround is to check
- * the version of GTK used by Mozilla by looking for the libwidget_gtk.so
- * library used by Mozilla GTK1.2. Mozilla GTK2 uses the libwidget_gtk2.so
- * library.
- *
- * @return <code>true</code> if this Mozilla installation is acceptable for
- * use with GWT
- */
- private boolean isAcceptable() {
- // make sure the main library exists
- if (!new File(path, "libxpcom.so").exists()) {
- return false;
- }
- // check to see if it was built against GTK1 instead of GTK2
- if (new File(path, "components/libwidget_gtk.so").exists()) {
- return false;
- }
- return true;
- }
-}
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/SwtGeckoGlue.java b/dev/linux/src/com/google/gwt/dev/shell/moz/SwtGeckoGlue.java
deleted file mode 100644
index 431d39f..0000000
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/SwtGeckoGlue.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.moz;
-
-import org.eclipse.swt.internal.mozilla.XPCOM;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * A bag of static helper methods for mucking about with low-level SWT and Gecko
- * constructs.
- *
- * TODO(jat): remove this class by replacing the nsISupports code with
- * JsRootedValue references.
- */
-class SwtGeckoGlue {
-
- private static boolean areMethodsInitialized;
- private static final String ERRMSG_CANNOT_ACCESS = "Unable to find or access necessary SWT XPCOM methods. Ensure that the correct version of swt.jar is being used.";
- private static final String ERRMSG_CANNOT_INVOKE = "Unable to invoke a necessary SWT XPCOM method. Ensure that the correct version of swt.jar is being used.";
- private static Method XPCOMVtblCall;
-
- /**
- * Wrapper for XPCOM's nsISupports::AddRef().
- */
- public static int addRefInt(int nsISupports) {
- ensureMethodsInitialized();
- Throwable rethrow = null;
- try {
- Object retVal = XPCOMVtblCall.invoke(null, new Object[] {
- Integer.valueOf(1), new Integer(nsISupports)});
- return ((Integer) retVal).intValue();
- } catch (IllegalArgumentException e) {
- rethrow = e;
- } catch (IllegalAccessException e) {
- rethrow = e;
- } catch (InvocationTargetException e) {
- rethrow = e;
- }
- throw new RuntimeException(ERRMSG_CANNOT_INVOKE, rethrow);
- }
-
- /**
- * Wrapper for XPCOM's nsISupports::Release().
- */
- public static int releaseInt(int nsISupports) {
- ensureMethodsInitialized();
- Throwable rethrow = null;
- try {
- Object retVal = XPCOMVtblCall.invoke(null, new Object[] {
- Integer.valueOf(2), new Integer(nsISupports)});
- return ((Integer) retVal).intValue();
- } catch (IllegalArgumentException e) {
- rethrow = e;
- } catch (IllegalAccessException e) {
- rethrow = e;
- } catch (InvocationTargetException e) {
- rethrow = e;
- }
- throw new RuntimeException(ERRMSG_CANNOT_INVOKE, rethrow);
- }
-
- private static void ensureMethodsInitialized() {
- if (!areMethodsInitialized) {
- Throwable rethrow = null;
-
- // Never try more than once to initialize, even if there's an exception.
- areMethodsInitialized = true;
- try {
- XPCOMVtblCall = XPCOM.class.getDeclaredMethod("VtblCall", new Class[] {
- int.class, int.class});
- XPCOMVtblCall.setAccessible(true);
- } catch (SecurityException e) {
- rethrow = e;
- } catch (NoSuchMethodException e) {
- rethrow = e;
- }
-
- if (rethrow != null) {
- throw new RuntimeException(ERRMSG_CANNOT_ACCESS, rethrow);
- }
- }
- }
-}
diff --git a/dev/linux/src/org/eclipse/COPYING.html b/dev/linux/src/org/eclipse/COPYING.html
deleted file mode 100644
index 5bfebd8..0000000
--- a/dev/linux/src/org/eclipse/COPYING.html
+++ /dev/null
@@ -1,256 +0,0 @@
-<html>
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<title>Eclipse Public License - Version 1.0</title>
-</head>
-
-<body>
-
-<div>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span>1. DEFINITIONS</span></b> </p>
-
-<p><span>"Contribution" means:</span> </p>
-
-<p><span>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p><span>i)
-changes to the Program, and</span></p>
-
-<p><span>ii)
-additions to the Program;</span></p>
-
-<p><span>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span>"Contributor" means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span>"Licensed Patents " mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span>"Program" means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span>"Recipient" means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span>2. GRANT OF RIGHTS</span></b> </p>
-
-<p><span>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p><span>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p><span>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p><span>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span>3. REQUIREMENTS</span></b> </p>
-
-<p><span>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p><span>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p><span>b)
-its license agreement:</span></p>
-
-<p><span>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p><span>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p><span>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p><span>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span>When the Program is made available in source
-code form:</span> </p>
-
-<p><span>a)
-it must be made available under this Agreement; and </span></p>
-
-<p><span>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor ("Commercial
-Contributor") hereby agrees to defend and indemnify every other
-Contributor ("Indemnified Contributor") against any losses, damages and
-costs (collectively "Losses") arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span>5. NO WARRANTY</span></b> </p>
-
-<p><span>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span>7. GENERAL</span></b> </p>
-
-<p><span>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/dev/linux/src/org/eclipse/swt/browser/Browser.java b/dev/linux/src/org/eclipse/swt/browser/Browser.java
deleted file mode 100644
index 0ae657e..0000000
--- a/dev/linux/src/org/eclipse/swt/browser/Browser.java
+++ /dev/null
@@ -1,2595 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.browser;
-
-import com.google.gwt.dev.shell.moz.LowLevelMoz; // GOOGLE
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.internal.mozilla.*;
-import org.eclipse.swt.layout.*;
-
-/**
- * Instances of this class implement the browser user interface
- * metaphor. It allows the user to visualize and navigate through
- * HTML documents.
- * <p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @since 3.0
- */
-public class Browser extends Composite {
- int /*long*/ embedHandle;
- int /*long*/ mozillaHandle;
- nsIWebBrowser webBrowser;
-
- /* Interfaces for this Mozilla embedding notification */
- XPCOMObject supports;
- XPCOMObject weakReference;
- XPCOMObject webProgressListener;
- XPCOMObject webBrowserChrome;
- XPCOMObject webBrowserChromeFocus;
- XPCOMObject embeddingSiteWindow;
- XPCOMObject interfaceRequestor;
- XPCOMObject supportsWeakReference;
- XPCOMObject contextMenuListener;
- XPCOMObject uriContentListener;
- XPCOMObject tooltipListener;
- int chromeFlags = nsIWebBrowserChrome.CHROME_DEFAULT;
- int refCount = 0;
- int /*long*/ request;
- Point location;
- Point size;
- boolean addressBar, menuBar, statusBar, toolBar;
- boolean visible;
- Shell tip = null;
-
- /* External Listener management */
- CloseWindowListener[] closeWindowListeners = new CloseWindowListener[0];
- LocationListener[] locationListeners = new LocationListener[0];
- OpenWindowListener[] openWindowListeners = new OpenWindowListener[0];
- ProgressListener[] progressListeners = new ProgressListener[0];
- StatusTextListener[] statusTextListeners = new StatusTextListener[0];
- TitleListener[] titleListeners = new TitleListener[0];
- VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0];
-
- static nsIAppShell AppShell;
- static WindowCreator WindowCreator;
- static int BrowserCount;
- static boolean mozilla, ignoreDispose, usingProfile;
- static Callback eventCallback;
- static int /*long*/ eventProc;
-
- /* Package Name */
- static final String PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
- static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; //$NON-NLS-1$
- static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
- static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$
- static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
- static final String PREFERENCE_LANGUAGES = "intl.accept_languages"; //$NON-NLS-1$
- static final String PREFERENCE_CHARSET = "intl.charset.default"; //$NON-NLS-1$
- static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$
- static final String TOKENIZER_LOCALE = ","; //$NON-NLS-1$
- static final String PROFILE_DIR = "/eclipse"; //$NON-NLS-1$
- static final int STOP_PROPOGATE = 1;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li>
- * </ul>
- *
- * @see #getStyle
- *
- * @since 3.0
- */
-public Browser(Composite parent, int style) {
- super(fixIM(parent), style);
- Display display = parent.getDisplay();
- display.setData(NO_INPUT_METHOD, null);
-
- int /*long*/[] result = new int /*long*/[1];
- if (!mozilla) {
- /*
- * GOOGLE: We ship our own bundled version of Mozilla; the
- * bootstrap process stores the path of the one we loaded in
- * the system property swt.mozilla.path, so we get it from
- * there rather than using SWT's normal process to find it.
- */
- String mozillaPath = System.getProperty("swt.mozilla.path");
-
- int ptr;
- //String mozillaPath = null;
- //int /*long*/ ptr = OS.getenv(Converter.wcsToMbcs(null, XPCOM.MOZILLA_FIVE_HOME, true));
- //if (ptr != 0) {
- // int length = OS.strlen(ptr);
- // byte[] buffer = new byte[length];
- // OS.memmove(buffer, ptr, length);
- // mozillaPath = new String (Converter.mbcsToWcs (null, buffer));
- //}
- //if (mozillaPath == null) {
- // dispose();
- // SWT.error(SWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$
- //}
-
- try {
- Library.loadLibrary ("swt-mozilla"); //$NON-NLS-1$
- } catch (UnsatisfiedLinkError e) {
- try {
- /*
- * The initial loadLibrary attempt may have failed as a result of the user's
- * system not having libstdc++.so.6 installed, so try to load the alternate
- * swt mozilla library that depends on libswtc++.so.5 instead.
- */
- Library.loadLibrary ("swt-mozilla-gcc3"); //$NON-NLS-1$
- } catch (UnsatisfiedLinkError ex) {
- dispose ();
- /*
- * Print the error from the first failed attempt since at this point it's
- * known that the failure was not due to the libstdc++.so.6 dependency.
- */
- SWT.error (SWT.ERROR_NO_HANDLES, e);
- }
- }
-
- /*
- * Try to load the various profile libraries until one is found that loads successfully:
- * - mozilla14profile/mozilla14profile-gcc should succeed for mozilla 1.4 - 1.6
- * - mozilla17profile/mozilla17profile-gcc should succeed for mozilla 1.7.x and firefox
- * - mozilla18profile/mozilla18profile-gcc should succeed for mozilla 1.8.x (seamonkey)
- */
- try {
- Library.loadLibrary ("swt-mozilla14-profile"); //$NON-NLS-1$
- usingProfile = true;
- } catch (UnsatisfiedLinkError e1) {
- try {
- Library.loadLibrary ("swt-mozilla17-profile"); //$NON-NLS-1$
- usingProfile = true;
- } catch (UnsatisfiedLinkError e2) {
- try {
- Library.loadLibrary ("swt-mozilla14-profile-gcc3"); //$NON-NLS-1$
- usingProfile = true;
- } catch (UnsatisfiedLinkError e3) {
- try {
- Library.loadLibrary ("swt-mozilla17-profile-gcc3"); //$NON-NLS-1$
- usingProfile = true;
- } catch (UnsatisfiedLinkError e4) {
- try {
- Library.loadLibrary ("swt-mozilla18-profile"); //$NON-NLS-1$
- usingProfile = true;
- } catch (UnsatisfiedLinkError e5) {
- try {
- Library.loadLibrary ("swt-mozilla18-profile-gcc3"); //$NON-NLS-1$
- usingProfile = true;
- } catch (UnsatisfiedLinkError e6) {
- /*
- * fail silently, the Browser will still work without profile support
- * but will abort any attempts to navigate to HTTPS pages
- */
- }
- }
- }
- }
- }
- }
-
- int /*long*/[] retVal = new int /*long*/[1];
- nsEmbedString pathString = new nsEmbedString(mozillaPath);
- int rc = XPCOM.NS_NewLocalFile(pathString.getAddress(), true, retVal);
- pathString.dispose();
- if (rc != XPCOM.NS_OK) error(rc);
- if (retVal[0] == 0) error(XPCOM.NS_ERROR_NULL_POINTER);
-
- nsILocalFile localFile = new nsILocalFile(retVal[0]);
- rc = XPCOM.NS_InitEmbedding(localFile.getAddress(), 0);
- localFile.Release();
- if (rc != XPCOM.NS_OK) {
- dispose();
- SWT.error(SWT.ERROR_NO_HANDLES, null, " [NS_InitEmbedding "+mozillaPath+" error "+rc+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- rc = XPCOM.NS_GetComponentManager(result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIComponentManager componentManager = new nsIComponentManager(result[0]);
- result[0] = 0;
- rc = componentManager.CreateInstance(XPCOM.NS_APPSHELL_CID, 0, nsIAppShell.NS_IAPPSHELL_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- AppShell = new nsIAppShell(result[0]);
- rc = AppShell.Create(0, null);
- if (rc != XPCOM.NS_OK) error(rc);
- rc = AppShell.Spinup();
- if (rc != XPCOM.NS_OK) error(rc);
-
- WindowCreator = new WindowCreator();
- WindowCreator.AddRef();
-
- rc = XPCOM.NS_GetServiceManager(result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIServiceManager serviceManager = new nsIServiceManager(result[0]);
- result[0] = 0;
- byte[] buffer = XPCOM.NS_WINDOWWATCHER_CONTRACTID.getBytes();
- byte[] aContractID = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aContractID, 0, buffer.length);
- rc = serviceManager.GetServiceByContractID(aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIWindowWatcher windowWatcher = new nsIWindowWatcher(result[0]);
- result[0] = 0;
- rc = windowWatcher.SetWindowCreator(WindowCreator.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
- windowWatcher.Release();
-
- /* specify the user profile directory */
- if (usingProfile) {
- buffer = Converter.wcsToMbcs(null, XPCOM.NS_DIRECTORYSERVICE_CONTRACTID, true);
- rc = serviceManager.GetServiceByContractID(buffer, nsIDirectoryService.NS_IDIRECTORYSERVICE_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIDirectoryService directoryService = new nsIDirectoryService(result[0]);
- result[0] = 0;
- rc = directoryService.QueryInterface(nsIProperties.NS_IPROPERTIES_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- directoryService.Release();
-
- nsIProperties properties = new nsIProperties(result[0]);
- result[0] = 0;
- buffer = Converter.wcsToMbcs(null, XPCOM.NS_APP_APPLICATION_REGISTRY_DIR, true);
- rc = properties.Get(buffer, nsIFile.NS_IFILE_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- properties.Release();
-
- nsIFile profileDir = new nsIFile(result[0]);
- result[0] = 0;
- int /*long*/ path = XPCOM.nsEmbedCString_new();
- rc = profileDir.GetNativePath(path);
- if (rc != XPCOM.NS_OK) error(rc);
- profileDir.Release(); //
-
- int length = XPCOM.nsEmbedCString_Length(path);
- ptr = XPCOM.nsEmbedCString_get(path);
- buffer = new byte [length];
- XPCOM.memmove(buffer, ptr, length);
- XPCOM.nsEmbedCString_delete(path);
- String string = new String(Converter.mbcsToWcs(null, buffer)) + PROFILE_DIR;
- pathString = new nsEmbedString(string);
- rc = XPCOM.NS_NewLocalFile(pathString.getAddress(), true, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NULL_POINTER);
- pathString.dispose(); //
-
- profileDir = new nsIFile(result[0]);
- result[0] = 0;
-
- rc = XPCOM_PROFILE.NS_NewProfileDirServiceProvider(true, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- final int /*long*/ dirServiceProvider = result[0];
- result[0] = 0;
- rc = XPCOM_PROFILE.ProfileDirServiceProvider_Register(dirServiceProvider);
- if (rc != XPCOM.NS_OK) error(rc);
- rc = XPCOM_PROFILE.ProfileDirServiceProvider_SetProfileDir(dirServiceProvider, profileDir.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
-
- getDisplay().addListener(SWT.Dispose, new Listener() {
- public void handleEvent(Event e) {
- XPCOM_PROFILE.ProfileDirServiceProvider_Shutdown(dirServiceProvider);
- }
- });
- }
-
- /*
- * As a result of using a common profile (or none at all), the user cannot specify
- * their locale and charset. The fix for this is to set mozilla's locale and charset
- * preference values according to the user's current locale and charset.
- */
- buffer = XPCOM.NS_PREFSERVICE_CONTRACTID.getBytes();
- aContractID = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aContractID, 0, buffer.length);
- rc = serviceManager.GetServiceByContractID(aContractID, nsIPrefService.NS_IPREFSERVICE_IID, result);
- serviceManager.Release();
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIPrefService prefService = new nsIPrefService(result[0]);
- result[0] = 0;
- buffer = new byte[1];
- rc = prefService.GetBranch(buffer, result); /* empty buffer denotes root preference level */
- prefService.Release();
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIPrefBranch prefBranch = new nsIPrefBranch(result[0]);
- result[0] = 0;
-
- /* get Mozilla's current locale preference value */
- String prefLocales = null;
- nsIPrefLocalizedString localizedString = null;
- buffer = Converter.wcsToMbcs(null, PREFERENCE_LANGUAGES, true);
- rc = prefBranch.GetComplexValue(buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
- /*
- * Feature of Debian. For some reason attempting to query for the current locale
- * preference fails on Debian. The workaround for this is to assume a value of
- * "en-us,en" since this is typically the default value when mozilla is used without
- * a profile.
- */
- if (rc != XPCOM.NS_OK) {
- prefLocales = "en-us,en" + TOKENIZER_LOCALE; //$NON-NLS-1$
- } else {
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- localizedString = new nsIPrefLocalizedString(result[0]);
- result[0] = 0;
- rc = localizedString.ToString(result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- int length = XPCOM.strlen_PRUnichar(result[0]);
- char[] dest = new char[length];
- XPCOM.memmove(dest, result[0], length * 2);
- prefLocales = new String(dest) + TOKENIZER_LOCALE;
- }
- result[0] = 0;
-
- /*
- * construct the new locale preference value by prepending the
- * user's current locale and language to the original value
- */
- Locale locale = Locale.getDefault();
- String language = locale.getLanguage();
- String country = locale.getCountry();
- StringBuffer stringBuffer = new StringBuffer (language);
- stringBuffer.append(SEPARATOR_LOCALE);
- stringBuffer.append(country.toLowerCase());
- stringBuffer.append(TOKENIZER_LOCALE);
- stringBuffer.append(language);
- stringBuffer.append(TOKENIZER_LOCALE);
- String newLocales = stringBuffer.toString();
- StringTokenizer tokenzier = new StringTokenizer(prefLocales, TOKENIZER_LOCALE);
- while (tokenzier.hasMoreTokens()) {
- String token = (tokenzier.nextToken() + TOKENIZER_LOCALE).trim();
- /* ensure that duplicate locale values are not added */
- if (newLocales.indexOf(token) == -1) {
- stringBuffer.append(token);
- }
- }
- newLocales = stringBuffer.toString();
- if (!newLocales.equals(prefLocales)) {
- /* write the new locale value */
- newLocales = newLocales.substring(0, newLocales.length() - TOKENIZER_LOCALE.length ()); /* remove trailing tokenizer */
- int length = newLocales.length();
- char[] charBuffer = new char[length + 1];
- newLocales.getChars(0, length, charBuffer, 0);
- if (localizedString == null) {
- byte[] contractID = Converter.wcsToMbcs(null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
- rc = componentManager.CreateInstanceByContractID(contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- localizedString = new nsIPrefLocalizedString(result[0]);
- result[0] = 0;
- }
- localizedString.SetDataWithLength(length, charBuffer);
- rc = prefBranch.SetComplexValue(buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress());
- }
- if (localizedString != null) {
- localizedString.Release();
- localizedString = null;
- }
-
- /* get Mozilla's current charset preference value */
- String prefCharset = null;
- buffer = Converter.wcsToMbcs(null, PREFERENCE_CHARSET, true);
- rc = prefBranch.GetComplexValue(buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
- /*
- * Feature of Debian. For some reason attempting to query for the current charset
- * preference fails on Debian. The workaround for this is to assume a value of
- * "ISO-8859-1" since this is typically the default value when mozilla is used
- * without a profile.
- */
- if (rc != XPCOM.NS_OK) {
- prefCharset = "ISO-8859-1"; //$NON_NLS-1$
- } else {
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- localizedString = new nsIPrefLocalizedString(result[0]);
- result[0] = 0;
- rc = localizedString.ToString(result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- int length = XPCOM.strlen_PRUnichar(result[0]);
- char[] dest = new char[length];
- XPCOM.memmove(dest, result[0], length * 2);
- prefCharset = new String(dest);
- }
- result[0] = 0;
-
- String newCharset = System.getProperty("file.encoding"); // $NON-NLS-1$
- if (!newCharset.equals(prefCharset)) {
- /* write the new charset value */
- int length = newCharset.length();
- char[] charBuffer = new char[length + 1];
- newCharset.getChars(0, length, charBuffer, 0);
- if (localizedString == null) {
- byte[] contractID = Converter.wcsToMbcs(null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
- rc = componentManager.CreateInstanceByContractID(contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- localizedString = new nsIPrefLocalizedString(result[0]);
- result[0] = 0;
- }
- localizedString.SetDataWithLength(length, charBuffer);
- rc = prefBranch.SetComplexValue(buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress());
- }
- if (localizedString != null) localizedString.Release();
- prefBranch.Release();
-
- PromptServiceFactory factory = new PromptServiceFactory();
- factory.AddRef();
-
- rc = componentManager.QueryInterface(nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar(result[0]);
- result[0] = 0;
- buffer = XPCOM.NS_PROMPTSERVICE_CONTRACTID.getBytes();
- aContractID = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aContractID, 0, buffer.length);
- buffer = "Prompt Service".getBytes(); //$NON-NLS-1$
- byte[] aClassName = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aClassName, 0, buffer.length);
- rc = componentRegistrar.RegisterFactory(XPCOM.NS_PROMPTSERVICE_CID, aClassName, aContractID, factory.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
- factory.Release();
-
- HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory();
- dialogFactory.AddRef();
-
- buffer = XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID.getBytes();
- aContractID = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aContractID, 0, buffer.length);
- buffer = "Helper App Launcher Dialog".getBytes(); //$NON-NLS-1$
- aClassName = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aClassName, 0, buffer.length);
- rc = componentRegistrar.RegisterFactory(XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
- dialogFactory.Release();
-
- DownloadFactory downloadFactory = new DownloadFactory();
- downloadFactory.AddRef();
-
- buffer = XPCOM.NS_DOWNLOAD_CONTRACTID.getBytes();
- aContractID = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aContractID, 0, buffer.length);
- buffer = "Download".getBytes(); //$NON-NLS-1$
- aClassName = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aClassName, 0, buffer.length);
- rc = componentRegistrar.RegisterFactory(XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
- downloadFactory.Release();
-
- FilePickerFactory pickerFactory = new FilePickerFactory();
- pickerFactory.AddRef();
-
- buffer = XPCOM.NS_FILEPICKER_CONTRACTID.getBytes();
- aContractID = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aContractID, 0, buffer.length);
- buffer = "FilePicker".getBytes(); //$NON-NLS-1$
- aClassName = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, aClassName, 0, buffer.length);
- rc = componentRegistrar.RegisterFactory(XPCOM.NS_FILEPICKER_CID, aClassName, aContractID, pickerFactory.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
- pickerFactory.Release();
-
- componentRegistrar.Release();
- componentManager.Release();
- mozilla = true;
-
- /*
- * GOOGLE: If we don't force LowLevel into existence during this narrow
- * window of opportunity, registering our "window.external" handler seems
- * to have no effect.
- */
- LowLevelMoz.init();
- }
- BrowserCount++;
- int rc = XPCOM.NS_GetComponentManager(result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIComponentManager componentManager = new nsIComponentManager(result[0]);
- result[0] = 0;
- nsID NS_IWEBBROWSER_CID = new nsID("F1EAC761-87E9-11d3-AF80-00A024FFC08C"); //$NON-NLS-1$
- rc = componentManager.CreateInstance(NS_IWEBBROWSER_CID, 0, nsIWebBrowser.NS_IWEBBROWSER_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- componentManager.Release();
-
- webBrowser = new nsIWebBrowser(result[0]);
-
- createCOMInterfaces();
- AddRef();
-
- rc = webBrowser.SetContainerWindow(webBrowserChrome.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
-
- rc = webBrowser.QueryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIBaseWindow baseWindow = new nsIBaseWindow(result[0]);
- Rectangle rect = getClientArea();
- if (rect.isEmpty()) {
- rect.width = 1;
- rect.height = 1;
- }
-
- /*
- * Bug in Mozilla Linux GTK. Embedding Mozilla into a GtkFixed
- * handle causes problems with some Mozilla plug-ins. For some
- * reason, the Flash plug-in causes the child of the GtkFixed
- * handle to be resized to 1 when the Flash document is loaded.
- * That could be due to gtk_container_resize_children being called
- * by Mozilla - or one of its plug-ins - on the GtkFixed handle,
- * causing the child of the GtkFixed handle to be resized to 1.
- * The workaround is to embed Mozilla into a GtkHBox handle.
- */
- embedHandle = OS.gtk_hbox_new (false, 0);
- OS.gtk_container_add (handle, embedHandle);
- OS.gtk_widget_show (embedHandle);
-
- rc = baseWindow.InitWindow(embedHandle, 0, 0, 0, rect.width, rect.height);
- if (rc != XPCOM.NS_OK) error(XPCOM.NS_ERROR_FAILURE);
- rc = baseWindow.Create();
- if (rc != XPCOM.NS_OK) error(XPCOM.NS_ERROR_FAILURE);
- rc = baseWindow.SetVisibility(true);
- if (rc != XPCOM.NS_OK) error(XPCOM.NS_ERROR_FAILURE);
- baseWindow.Release();
-
- rc = webBrowser.AddWebBrowserListener(weakReference.getAddress(), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
- if (rc != XPCOM.NS_OK) error(rc);
-
- rc = webBrowser.SetParentURIContentListener(uriContentListener.getAddress());
- if (rc != XPCOM.NS_OK) error(rc);
-
- if (eventCallback == null) {
- eventCallback = new Callback(Browser.class, "eventProc", 3);
- eventProc = eventCallback.getAddress();
- if (eventProc == 0) error(SWT.ERROR_NO_MORE_CALLBACKS);
- }
-
- /*
- * Feature in Mozilla. GtkEvents such as key down, key pressed may be consumed
- * by Mozilla and never be received by the parent embedder. The workaround
- * is to find the top Mozilla gtk widget that receives all the Mozilla GtkEvents,
- * i.e. the first child of the parent embedder. Then hook event callbacks and
- * forward the event to the parent embedder before Mozilla received and consumed
- * them.
- */
- int /*long*/ list = OS.gtk_container_get_children(embedHandle);
- if (list != 0) {
- mozillaHandle = OS.g_list_data(list);
- OS.g_list_free(list);
-
- if (mozillaHandle != 0) {
- getDisplay().setData(ADD_WIDGET_KEY, new Object[] {new LONG(mozillaHandle), this});
-
- /* Note. Callback to get events before Mozilla receives and consumes them. */
- OS.g_signal_connect (mozillaHandle, OS.event, eventProc, 0);
-
- /*
- * Note. Callback to get the events not consumed by Mozilla - and to block
- * them so that they don't get propagated to the parent handle twice.
- * This hook is set after Mozilla and is therefore called after Mozilla's
- * handler because GTK dispatches events in their order of registration.
- */
- OS.g_signal_connect (mozillaHandle, OS.key_press_event, eventProc, STOP_PROPOGATE);
- OS.g_signal_connect (mozillaHandle, OS.key_release_event, eventProc, STOP_PROPOGATE);
- }
- }
-
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose: {
- /* make this handler run after other dispose listeners */
- if (ignoreDispose) {
- ignoreDispose = false;
- break;
- }
- ignoreDispose = true;
- notifyListeners (event.type, event);
- event.type = SWT.NONE;
- onDispose(event.display);
- break;
- }
- case SWT.Resize: onResize(); break;
- case SWT.FocusIn: Activate(); break;
- case SWT.Deactivate: {
- Display display = event.display;
- if (Browser.this == display.getFocusControl()) Deactivate();
- break;
- }
- case SWT.Show: {
- /*
- * Feature on GTK Mozilla. Mozilla does not show up when
- * its container (a GTK fixed handle) is made visible
- * after having been hidden. The workaround is to reset
- * its size after the container has been made visible.
- */
- Display display = event.display;
- display.asyncExec(new Runnable() {
- public void run() {
- if (Browser.this.isDisposed()) return;
- onResize();
- }
- });
- break;
- }
- }
- }
- };
- int[] folderEvents = new int[]{
- SWT.Dispose,
- SWT.Resize,
- SWT.FocusIn,
- SWT.Deactivate,
- SWT.Show
- };
- for (int i = 0; i < folderEvents.length; i++) {
- addListener(folderEvents[i], listener);
- }
-}
-
-public static void clearSessions () {
- if (!mozilla) return;
- int /*long*/[] result = new int /*long*/[1];
- int rc = XPCOM.NS_GetServiceManager (result);
- if (rc != XPCOM.NS_OK) error (rc);
- if (result [0] == 0) error (XPCOM.NS_NOINTERFACE);
- nsIServiceManager serviceManager = new nsIServiceManager (result [0]);
- result [0] = 0;
- byte[] buffer = XPCOM.NS_COOKIEMANAGER_CONTRACTID.getBytes ();
- byte[] aContractID = new byte [buffer.length + 1];
- System.arraycopy (buffer, 0, aContractID, 0, buffer.length);
- rc = serviceManager.GetServiceByContractID (aContractID, nsICookieManager.NS_ICOOKIEMANAGER_IID, result);
- if (rc != XPCOM.NS_OK) error (rc);
- if (result [0] == 0) error (XPCOM.NS_NOINTERFACE);
- serviceManager.Release ();
-
- nsICookieManager manager = new nsICookieManager (result [0]);
- result [0] = 0;
- rc = manager.GetEnumerator (result);
- if (rc != XPCOM.NS_OK) error (rc);
- manager.Release ();
-
- nsISimpleEnumerator enumerator = new nsISimpleEnumerator (result [0]);
- boolean[] moreElements = new boolean [1];
- rc = enumerator.HasMoreElements (moreElements);
- if (rc != XPCOM.NS_OK) error (rc);
- while (moreElements [0]) {
- result [0] = 0;
- rc = enumerator.GetNext (result);
- if (rc != XPCOM.NS_OK) error (rc);
- nsICookie cookie = new nsICookie (result [0]);
- long[] expires = new long [1];
- rc = cookie.GetExpires (expires);
- if (expires [0] == 0) {
- /* indicates a session cookie */
- int /*long*/ domain = XPCOM.nsEmbedCString_new ();
- int /*long*/ name = XPCOM.nsEmbedCString_new ();
- int /*long*/ path = XPCOM.nsEmbedCString_new ();
- cookie.GetHost (domain);
- cookie.GetName (name);
- cookie.GetPath (path);
- rc = manager.Remove (domain, name, path, false);
- XPCOM.nsEmbedCString_delete (domain);
- XPCOM.nsEmbedCString_delete (name);
- XPCOM.nsEmbedCString_delete (path);
- if (rc != XPCOM.NS_OK) error (rc);
- }
- cookie.Release ();
- rc = enumerator.HasMoreElements (moreElements);
- if (rc != XPCOM.NS_OK) error (rc);
- }
- enumerator.Release ();
-}
-
-static int /*long*/ eventProc (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) {
- Widget widget = Display.getCurrent().findWidget(handle);
- if (widget != null && widget instanceof Browser) {
- return ((Browser)widget).gtk_event(handle, gdkEvent, pointer);
- }
- return 0;
-}
-
-static Composite fixIM(Composite parent) {
- /*
- * Note. Mozilla provides all IM suport needed for text input in webpages.
- * If SWTcreates another input method context for the widget it will cause
- * undetermine results to happen (hungs and crashes). The fix is to prevent
- * SWT from creating an input method context for the Browser widget.
- */
- if (parent != null && !parent.isDisposed()) {
- Display display = parent.getDisplay();
- if (display != null) {
- if (display.getThread() == Thread.currentThread ()) {
- display.setData (NO_INPUT_METHOD, "true");
- }
- }
- }
- return parent;
-}
-
-int /*long*/ gtk_event (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) {
- /*
- * Stop the propagation of events that are not consumed by Mozilla, before
- * they reach the parent embedder. These event have already been received.
- */
- if (pointer == STOP_PROPOGATE) return 1;
-
- GdkEvent event = new GdkEvent ();
- OS.memmove (event, gdkEvent, GdkEvent.sizeof);
- switch (event.type) {
- case OS.GDK_KEY_PRESS:
- case OS.GDK_KEY_RELEASE:
- case OS.GDK_BUTTON_PRESS:
- case OS.GDK_BUTTON_RELEASE: {
- /*
- * Forward the event to the parent embedder before Mozilla receives it,
- * as Mozilla may or may not consume it.
- */
- OS.gtk_widget_event (this.handle, gdkEvent);
- break;
- }
- }
- return 0;
-}
-
-/**
- * Adds the listener to receive events.
- * <p>
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addCloseWindowListener(CloseWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length + 1];
- System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, closeWindowListeners.length);
- closeWindowListeners = newCloseWindowListeners;
- closeWindowListeners[closeWindowListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to receive events.
- * <p>
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addLocationListener(LocationListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- LocationListener[] newLocationListeners = new LocationListener[locationListeners.length + 1];
- System.arraycopy(locationListeners, 0, newLocationListeners, 0, locationListeners.length);
- locationListeners = newLocationListeners;
- locationListeners[locationListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to receive events.
- * <p>
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addOpenWindowListener(OpenWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length + 1];
- System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, openWindowListeners.length);
- openWindowListeners = newOpenWindowListeners;
- openWindowListeners[openWindowListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to receive events.
- * <p>
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addProgressListener(ProgressListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length + 1];
- System.arraycopy(progressListeners, 0, newProgressListeners, 0, progressListeners.length);
- progressListeners = newProgressListeners;
- progressListeners[progressListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to receive events.
- * <p>
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addStatusTextListener(StatusTextListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length + 1];
- System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, statusTextListeners.length);
- statusTextListeners = newStatusTextListeners;
- statusTextListeners[statusTextListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to receive events.
- * <p>
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addTitleListener(TitleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- TitleListener[] newTitleListeners = new TitleListener[titleListeners.length + 1];
- System.arraycopy(titleListeners, 0, newTitleListeners, 0, titleListeners.length);
- titleListeners = newTitleListeners;
- titleListeners[titleListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to receive events.
- * <p>
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addVisibilityWindowListener(VisibilityWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length + 1];
- System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, visibilityWindowListeners.length);
- visibilityWindowListeners = newVisibilityWindowListeners;
- visibilityWindowListeners[visibilityWindowListeners.length - 1] = listener;
-}
-
-/**
- * Navigate to the previous session history item.
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #forward
- *
- * @since 3.0
- */
-public boolean back() {
- checkWidget();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- rc = webNavigation.GoBack();
- webNavigation.Release();
-
- return rc == XPCOM.NS_OK;
-}
-
-protected void checkSubclass() {
- String name = getClass().getName();
- int index = name.lastIndexOf('.');
- if (!name.substring(0, index + 1).equals(PACKAGE_PREFIX)) {
- SWT.error(SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-
-void createCOMInterfaces() {
- // Create each of the interfaces that this object implements
- supports = new XPCOMObject(new int[]{2, 0, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- };
-
- weakReference = new XPCOMObject(new int[]{2, 0, 0, 2}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return QueryReferent(args[0], args[1]);}
- };
-
- webProgressListener = new XPCOMObject(new int[]{2, 0, 0, 4, 6, 3, 4, 3}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return OnStateChange(args[0], args[1], args[2],args[3]);}
- public int /*long*/ method4(int /*long*/[] args) {return OnProgressChange(args[0], args[1], args[2],args[3],args[4],args[5]);}
- public int /*long*/ method5(int /*long*/[] args) {return OnLocationChange(args[0], args[1], args[2]);}
- public int /*long*/ method6(int /*long*/[] args) {return OnStatusChange(args[0], args[1], args[2],args[3]);}
- public int /*long*/ method7(int /*long*/[] args) {return OnSecurityChange(args[0], args[1], args[2]);}
- };
-
- webBrowserChrome = new XPCOMObject(new int[]{2, 0, 0, 2, 1, 1, 1, 1, 0, 2, 0, 1, 1}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return SetStatus(args[0], args[1]);}
- public int /*long*/ method4(int /*long*/[] args) {return GetWebBrowser(args[0]);}
- public int /*long*/ method5(int /*long*/[] args) {return SetWebBrowser(args[0]);}
- public int /*long*/ method6(int /*long*/[] args) {return GetChromeFlags(args[0]);}
- public int /*long*/ method7(int /*long*/[] args) {return SetChromeFlags(args[0]);}
- public int /*long*/ method8(int /*long*/[] args) {return DestroyBrowserWindow();}
- public int /*long*/ method9(int /*long*/[] args) {return SizeBrowserTo(args[0], args[1]);}
- public int /*long*/ method10(int /*long*/[] args) {return ShowAsModal();}
- public int /*long*/ method11(int /*long*/[] args) {return IsWindowModal(args[0]);}
- public int /*long*/ method12(int /*long*/[] args) {return ExitModalEventLoop(args[0]);}
- };
-
- webBrowserChromeFocus = new XPCOMObject(new int[]{2, 0, 0, 0, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return FocusNextElement();}
- public int /*long*/ method4(int /*long*/[] args) {return FocusPrevElement();}
- };
-
- embeddingSiteWindow = new XPCOMObject(new int[]{2, 0, 0, 5, 5, 0, 1, 1, 1, 1, 1}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return SetDimensions(args[0], args[1], args[2], args[3], args[4]);}
- public int /*long*/ method4(int /*long*/[] args) {return GetDimensions(args[0], args[1], args[2], args[3], args[4]);}
- public int /*long*/ method5(int /*long*/[] args) {return SetFocus();}
- public int /*long*/ method6(int /*long*/[] args) {return GetVisibility(args[0]);}
- public int /*long*/ method7(int /*long*/[] args) {return SetVisibility(args[0]);}
- public int /*long*/ method8(int /*long*/[] args) {return GetTitle(args[0]);}
- public int /*long*/ method9(int /*long*/[] args) {return SetTitle(args[0]);}
- public int /*long*/ method10(int /*long*/[] args) {return GetSiteWindow(args[0]);}
- };
-
- interfaceRequestor = new XPCOMObject(new int[]{2, 0, 0, 2}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return GetInterface(args[0], args[1]);}
- };
-
- supportsWeakReference = new XPCOMObject(new int[]{2, 0, 0, 1}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return GetWeakReference(args[0]);}
- };
-
- contextMenuListener = new XPCOMObject(new int[]{2, 0, 0, 3}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return OnShowContextMenu(args[0],args[1],args[2]);}
- };
-
- uriContentListener = new XPCOMObject(new int[]{2, 0, 0, 2, 5, 3, 4, 1, 1, 1, 1}) {
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return OnStartURIOpen(args[0], args[1]);}
- public int /*long*/ method4(int /*long*/[] args) {return DoContent(args[0], args[1], args[2], args[3], args[4]);}
- public int /*long*/ method5(int /*long*/[] args) {return IsPreferred(args[0], args[1], args[2]);}
- public int /*long*/ method6(int /*long*/[] args) {return CanHandleContent(args[0], args[1], args[2], args[3]);}
- public int /*long*/ method7(int /*long*/[] args) {return GetLoadCookie(args[0]);}
- public int /*long*/ method8(int /*long*/[] args) {return SetLoadCookie(args[0]);}
- public int /*long*/ method9(int /*long*/[] args) {return GetParentContentListener(args[0]);}
- public int /*long*/ method10(int /*long*/[] args) {return SetParentContentListener(args[0]);}
- };
-
- tooltipListener = new XPCOMObject(new int[]{2, 0, 0, 3, 0}) {
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return OnShowTooltip(args[0], args[1], args[2]);}
- public int /*long*/ method4(int /*long*/[] args) {return OnHideTooltip();}
- };
-}
-
-void disposeCOMInterfaces() {
- if (supports != null) {
- supports.dispose();
- supports = null;
- }
- if (weakReference != null) {
- weakReference.dispose();
- weakReference = null;
- }
- if (webProgressListener != null) {
- webProgressListener.dispose();
- webProgressListener = null;
- }
- if (webBrowserChrome != null) {
- webBrowserChrome.dispose();
- webBrowserChrome = null;
- }
- if (webBrowserChromeFocus != null) {
- webBrowserChromeFocus.dispose();
- webBrowserChromeFocus = null;
- }
- if (embeddingSiteWindow != null) {
- embeddingSiteWindow.dispose();
- embeddingSiteWindow = null;
- }
- if (interfaceRequestor != null) {
- interfaceRequestor.dispose();
- interfaceRequestor = null;
- }
- if (supportsWeakReference != null) {
- supportsWeakReference.dispose();
- supportsWeakReference = null;
- }
- if (contextMenuListener != null) {
- contextMenuListener.dispose();
- contextMenuListener = null;
- }
- if (uriContentListener != null) {
- uriContentListener.dispose();
- uriContentListener = null;
- }
- if (tooltipListener != null) {
- tooltipListener.dispose();
- tooltipListener = null;
- }
-}
-
-public boolean execute(String script) {
- checkWidget();
- if (script == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- String url = "javascript:"+script+";void(0);";//$NON-NLS-1$ //$NON-NLS-2$
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- char[] arg = url.toCharArray();
- char[] c = new char[arg.length+1];
- System.arraycopy(arg,0,c,0,arg.length);
- rc = webNavigation.LoadURI(c, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
- webNavigation.Release();
- return rc == XPCOM.NS_OK;
-}
-
-static Browser findBrowser(int /*long*/ handle) {
- /*
- * Note. On GTK, Mozilla is embedded into a GtkHBox handle
- * and not directly into the parent Composite handle.
- */
- int /*long*/ parent = OS.gtk_widget_get_parent(handle);
- Display display = Display.getCurrent();
- return (Browser)display.findWidget(parent);
-}
-
-/**
- * Navigate to the next session history item.
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #back
- *
- * @since 3.0
- */
-public boolean forward() {
- checkWidget();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- rc = webNavigation.GoForward();
- webNavigation.Release();
-
- return rc == XPCOM.NS_OK;
-}
-
-/**
- * Returns the current URL.
- *
- * @return the current URL or an empty <code>String</code> if there is no current URL
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #setUrl
- *
- * @since 3.0
- */
-public String getUrl() {
- checkWidget();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- int /*long*/[] aCurrentURI = new int /*long*/[1];
- rc = webNavigation.GetCurrentURI(aCurrentURI);
- if (rc != XPCOM.NS_OK) error(rc);
- /*
- * This code is intentionally commented. aCurrentURI is 0
- * when no location has previously been set.
- */
- //if (aCurrentURI[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
- webNavigation.Release();
-
- byte[] dest = null;
- if (aCurrentURI[0] != 0) {
- nsIURI uri = new nsIURI(aCurrentURI[0]);
- int /*long*/ aSpec = XPCOM.nsEmbedCString_new();
- rc = uri.GetSpec(aSpec);
- if (rc != XPCOM.NS_OK) error(rc);
- int length = XPCOM.nsEmbedCString_Length(aSpec);
- int /*long*/ buffer = XPCOM.nsEmbedCString_get(aSpec);
- dest = new byte[length];
- XPCOM.memmove(dest, buffer, length);
- XPCOM.nsEmbedCString_delete(aSpec);
- uri.Release();
- }
- if (dest == null) return ""; //$NON-NLS-1$
- /*
- * If the URI indicates that the current page is being rendered from
- * memory (ie.- via setText()) then answer about:blank as the URL
- * to be consistent with win32.
- */
- String location = new String (dest);
- if (location.equals (URI_FROMMEMORY)) location = ABOUT_BLANK;
- return location;
-}
-
-/**
- * Returns <code>true</code> if the receiver can navigate to the
- * previous session history item, and <code>false</code> otherwise.
- *
- * @return the receiver's back command enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #back
- */
-public boolean isBackEnabled() {
- checkWidget();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- boolean[] aCanGoBack = new boolean[1];
- rc = webNavigation.GetCanGoBack(aCanGoBack);
- webNavigation.Release();
-
- return aCanGoBack[0];
-}
-
-/**
- * Returns <code>true</code> if the receiver can navigate to the
- * next session history item, and <code>false</code> otherwise.
- *
- * @return the receiver's forward command enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #forward
- */
-public boolean isForwardEnabled() {
- checkWidget();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- boolean[] aCanGoForward = new boolean[1];
- rc = webNavigation.GetCanGoForward(aCanGoForward);
- webNavigation.Release();
-
- return aCanGoForward[0];
-}
-
-static String error(int code) {
- throw new SWTError("XPCOM error "+code); //$NON-NLS-1$
-}
-
-void onDispose(Display display) {
- display.setData(ADD_WIDGET_KEY, new Object[] {new LONG(mozillaHandle), null});
-
- int rc = webBrowser.RemoveWebBrowserListener(weakReference.getAddress(), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
- if (rc != XPCOM.NS_OK) error(rc);
-
- rc = webBrowser.SetParentURIContentListener(0);
- if (rc != XPCOM.NS_OK) error(rc);
-
- int /*long*/[] result = new int /*long*/[1];
- rc = webBrowser.QueryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIBaseWindow baseWindow = new nsIBaseWindow(result[0]);
- rc = baseWindow.Destroy();
- if (rc != XPCOM.NS_OK) error(rc);
- baseWindow.Release();
-
- Release();
- webBrowser.Release();
-
- if (tip != null && !tip.isDisposed()) tip.dispose();
- tip = null;
-
- BrowserCount--;
- /*
- * This code is intentionally commented. It is not possible to reinitialize
- * Mozilla once it has been terminated. NS_InitEmbedding always fails after
- * NS_TermEmbedding has been called. The workaround is to call NS_InitEmbedding
- * once and never call NS_TermEmbedding.
- */
-// if (BrowserCount == 0) {
-// if (AppShell != null) {
-// // Shutdown the appshell service.
-// rc = AppShell.Spindown();
-// if (rc != XPCOM.NS_OK) error(rc);
-// AppShell.Release();
-// AppShell = null;
-// }
-// WindowCreator.Release();
-// WindowCreator = null;
-// PromptService.Release();
-// PromptService = null;
-// XPCOM.NS_TermEmbedding();
-// mozilla = false;
-// }
-}
-
-void Activate() {
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus(result[0]);
- rc = webBrowserFocus.Activate();
- if (rc != XPCOM.NS_OK) error(rc);
- webBrowserFocus.Release();
-}
-
-void Deactivate() {
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus(result[0]);
- rc = webBrowserFocus.Deactivate();
- if (rc != XPCOM.NS_OK) error(rc);
- webBrowserFocus.Release();
-}
-
-void SetFocusAtFirstElement() {
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus(result[0]);
- rc = webBrowserFocus.SetFocusAtFirstElement();
- if (rc != XPCOM.NS_OK) error(rc);
- webBrowserFocus.Release();
-}
-
-void onResize() {
- Rectangle rect = getClientArea();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- OS.gtk_widget_set_size_request(embedHandle, rect.width, rect.height);
- nsIBaseWindow baseWindow = new nsIBaseWindow(result[0]);
- rc = baseWindow.SetPositionAndSize(rect.x, rect.y, rect.width, rect.height, true);
- if (rc != XPCOM.NS_OK) error(rc);
- baseWindow.Release();
-}
-
-/**
- * Refresh the current page.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void refresh() {
- checkWidget();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- rc = webNavigation.Reload(nsIWebNavigation.LOAD_FLAGS_NONE);
- webNavigation.Release();
- if (rc == XPCOM.NS_OK) return;
- /*
- * Feature in Mozilla. Reload returns an error code NS_ERROR_INVALID_POINTER
- * when it is called immediately after a request to load a new document using
- * LoadURI. The workaround is to ignore this error code.
- *
- * Feature in Mozilla. Attempting to reload a file that no longer exists
- * returns an error code of NS_ERROR_FILE_NOT_FOUND. This is equivalent to
- * attempting to load a non-existent local url, which is not a Browser error,
- * so this error code should be ignored.
- */
- if (rc != XPCOM.NS_ERROR_INVALID_POINTER && rc != XPCOM.NS_ERROR_FILE_NOT_FOUND) error(rc);
-}
-
-/**
- * Removes the listener.
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeCloseWindowListener(CloseWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (closeWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < closeWindowListeners.length; i++) {
- if (listener == closeWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (closeWindowListeners.length == 1) {
- closeWindowListeners = new CloseWindowListener[0];
- return;
- }
- CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length - 1];
- System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, index);
- System.arraycopy(closeWindowListeners, index + 1, newCloseWindowListeners, index, closeWindowListeners.length - index - 1);
- closeWindowListeners = newCloseWindowListeners;
-}
-
-/**
- * Removes the listener.
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeLocationListener(LocationListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (locationListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < locationListeners.length; i++) {
- if (listener == locationListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (locationListeners.length == 1) {
- locationListeners = new LocationListener[0];
- return;
- }
- LocationListener[] newLocationListeners = new LocationListener[locationListeners.length - 1];
- System.arraycopy(locationListeners, 0, newLocationListeners, 0, index);
- System.arraycopy(locationListeners, index + 1, newLocationListeners, index, locationListeners.length - index - 1);
- locationListeners = newLocationListeners;
-}
-
-/**
- * Removes the listener.
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeOpenWindowListener(OpenWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (openWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < openWindowListeners.length; i++) {
- if (listener == openWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (openWindowListeners.length == 1) {
- openWindowListeners = new OpenWindowListener[0];
- return;
- }
- OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length - 1];
- System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, index);
- System.arraycopy(openWindowListeners, index + 1, newOpenWindowListeners, index, openWindowListeners.length - index - 1);
- openWindowListeners = newOpenWindowListeners;
-}
-
-/**
- * Removes the listener.
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeProgressListener(ProgressListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (progressListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < progressListeners.length; i++) {
- if (listener == progressListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (progressListeners.length == 1) {
- progressListeners = new ProgressListener[0];
- return;
- }
- ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length - 1];
- System.arraycopy(progressListeners, 0, newProgressListeners, 0, index);
- System.arraycopy(progressListeners, index + 1, newProgressListeners, index, progressListeners.length - index - 1);
- progressListeners = newProgressListeners;
-}
-
-/**
- * Removes the listener.
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeStatusTextListener(StatusTextListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (statusTextListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < statusTextListeners.length; i++) {
- if (listener == statusTextListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (statusTextListeners.length == 1) {
- statusTextListeners = new StatusTextListener[0];
- return;
- }
- StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length - 1];
- System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, index);
- System.arraycopy(statusTextListeners, index + 1, newStatusTextListeners, index, statusTextListeners.length - index - 1);
- statusTextListeners = newStatusTextListeners;
-}
-
-/**
- * Removes the listener.
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeTitleListener(TitleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (titleListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < titleListeners.length; i++) {
- if (listener == titleListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (titleListeners.length == 1) {
- titleListeners = new TitleListener[0];
- return;
- }
- TitleListener[] newTitleListeners = new TitleListener[titleListeners.length - 1];
- System.arraycopy(titleListeners, 0, newTitleListeners, 0, index);
- System.arraycopy(titleListeners, index + 1, newTitleListeners, index, titleListeners.length - index - 1);
- titleListeners = newTitleListeners;
-}
-
-/**
- * Removes the listener.
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeVisibilityWindowListener(VisibilityWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (visibilityWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < visibilityWindowListeners.length; i++) {
- if (listener == visibilityWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (visibilityWindowListeners.length == 1) {
- visibilityWindowListeners = new VisibilityWindowListener[0];
- return;
- }
- VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length - 1];
- System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, index);
- System.arraycopy(visibilityWindowListeners, index + 1, newVisibilityWindowListeners, index, visibilityWindowListeners.length - index - 1);
- visibilityWindowListeners = newVisibilityWindowListeners;
-}
-
-/**
- * Renders HTML.
- *
- * @param html the HTML content to be rendered
- *
- * @return true if the operation was successful and false otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the html is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #setUrl
- *
- * @since 3.0
- */
-public boolean setText(String html) {
- checkWidget();
- if (html == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- /*
- * Feature in Mozilla. The focus memory of Mozilla must be
- * properly managed through the nsIWebBrowserFocus interface.
- * In particular, nsIWebBrowserFocus.deactivate must be called
- * when the focus moves from the browser (or one of its children
- * managed by Mozilla to another widget. We currently do not
- * get notified when a widget takes focus away from the Browser.
- * As a result, deactivate is not properly called. This causes
- * Mozilla to retake focus the next time a document is loaded.
- * This breaks the case where the HTML loaded in the Browser
- * varies while the user enters characters in a text widget. The text
- * widget loses focus every time new content is loaded.
- * The current workaround is to call deactivate everytime if
- * the browser currently does not have focus. A better workaround
- * would be to have a mean to call deactivate when the Browser
- * or one of its children loses focus.
- */
- if (this != getDisplay().getFocusControl()) Deactivate();
-
- /*
- * Convert the String containing HTML to an array of
- * bytes with UTF-8 data.
- */
- byte[] data = null;
- try {
- data = html.getBytes("UTF-8"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- return false;
- }
-
- int /*long*/[] result = new int /*long*/[1];
- int rc = XPCOM.NS_GetServiceManager(result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIServiceManager serviceManager = new nsIServiceManager(result[0]);
- result[0] = 0;
- rc = serviceManager.GetService(XPCOM.NS_IOSERVICE_CID, nsIIOService.NS_IIOSERVICE_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- serviceManager.Release();
-
- nsIIOService ioService = new nsIIOService(result[0]);
- result[0] = 0;
- /*
- * Note. Mozilla ignores LINK tags used to load CSS stylesheets
- * when the URI protocol for the nsInputStreamChannel
- * is about:blank. The fix is to specify the file protocol.
- */
- byte[] aString = URI_FROMMEMORY.getBytes();
- int /*long*/ aSpec = XPCOM.nsEmbedCString_new(aString, aString.length);
- rc = ioService.NewURI(aSpec, null, 0, result);
- XPCOM.nsEmbedCString_delete(aSpec);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- ioService.Release();
-
- nsIURI uri = new nsIURI(result[0]);
- result[0] = 0;
-
- /* aContentType */
- byte[] buffer = "text/html".getBytes(); //$NON-NLS-1$
- byte[] contentTypeBuffer = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, contentTypeBuffer, 0, buffer.length);
- int /*long*/ aContentType = XPCOM.nsEmbedCString_new(contentTypeBuffer, contentTypeBuffer.length);
-
- /*
- * First try to use nsIWebBrowserStream to set the text into the Browser, since this
- * interface is frozen. However, this may fail because this interface was only introduced
- * as of mozilla 1.8; if this interface is not found then use the pre-1.8 approach of
- * utilizing nsIDocShell instead.
- */
- result[0] = 0;
- rc = webBrowser.QueryInterface(nsIWebBrowserStream.NS_IWEBBROWSERSTREAM_IID, result);
- if (rc == XPCOM.NS_OK) {
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
- nsIWebBrowserStream stream = new nsIWebBrowserStream(result[0]);
- rc = stream.OpenStream(uri.getAddress(), aContentType);
- if (rc != XPCOM.NS_OK) error(rc);
- int /*long*/ ptr = XPCOM.PR_Malloc(data.length);
- XPCOM.memmove(ptr, data, data.length);
- rc = stream.AppendToStream(ptr, data.length);
- if (rc != XPCOM.NS_OK) error(rc);
- rc = stream.CloseStream();
- if (rc != XPCOM.NS_OK) error(rc);
- XPCOM.PR_Free(ptr);
- stream.Release();
- } else {
- rc = webBrowser.QueryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor(result[0]);
- result[0] = 0;
- rc = interfaceRequestor.GetInterface(nsIDocShell.NS_IDOCSHELL_IID, result);
- interfaceRequestor.Release();
-
- nsIDocShell docShell = new nsIDocShell(result[0]);
- result[0] = 0;
- buffer = "UTF-8".getBytes(); //$NON-NLS-1$
- byte[] contentCharsetBuffer = new byte[buffer.length + 1];
- System.arraycopy(buffer, 0, contentCharsetBuffer, 0, buffer.length);
- int /*long*/ aContentCharset = XPCOM.nsEmbedCString_new(contentCharsetBuffer, contentCharsetBuffer.length);
-
- /*
- * Feature in Mozilla. LoadStream invokes the nsIInputStream argument
- * through a different thread. The callback mechanism must attach
- * a non java thread to the JVM otherwise the nsIInputStream Read and
- * Close methods never get called.
- */
- InputStream inputStream = new InputStream(data);
- inputStream.AddRef();
- rc = docShell.LoadStream(inputStream.getAddress(), uri.getAddress(), aContentType, aContentCharset, 0);
- if (rc != XPCOM.NS_OK) error(rc);
- XPCOM.nsEmbedCString_delete(aContentCharset);
- inputStream.Release();
- docShell.Release();
- }
-
- XPCOM.nsEmbedCString_delete(aContentType);
- uri.Release();
- return true;
-}
-
-/**
- * Loads a URL.
- *
- * @param url the URL to be loaded
- *
- * @return true if the operation was successful and false otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the url is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #getUrl
- *
- * @since 3.0
- */
-public boolean setUrl(String url) {
- checkWidget();
- if (url == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- char[] arg = url.toCharArray();
- char[] c = new char[arg.length+1];
- System.arraycopy(arg,0,c,0,arg.length);
- rc = webNavigation.LoadURI(c, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
- webNavigation.Release();
- return rc == XPCOM.NS_OK;
-}
-
-/**
- * Stop any loading and rendering activity.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void stop() {
- checkWidget();
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIWebNavigation webNavigation = new nsIWebNavigation(result[0]);
- rc = webNavigation.Stop(nsIWebNavigation.STOP_ALL);
- if (rc != XPCOM.NS_OK) error(rc);
- webNavigation.Release();
-}
-
-/* nsISupports */
-
-int /*long*/ QueryInterface(int /*long*/ riid, int /*long*/ ppvObject) {
- if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
-
- nsID guid = new nsID();
- XPCOM.memmove(guid, riid, nsID.sizeof);
-
- if (guid.Equals(nsISupports.NS_ISUPPORTS_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {supports.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIWeakReference.NS_IWEAKREFERENCE_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {weakReference.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {webProgressListener.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIWebBrowserChrome.NS_IWEBBROWSERCHROME_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {webBrowserChrome.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIWebBrowserChromeFocus.NS_IWEBBROWSERCHROMEFOCUS_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {webBrowserChromeFocus.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {embeddingSiteWindow.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {interfaceRequestor.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsISupportsWeakReference.NS_ISUPPORTSWEAKREFERENCE_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {supportsWeakReference.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIContextMenuListener.NS_ICONTEXTMENULISTENER_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {contextMenuListener.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsIURIContentListener.NS_IURICONTENTLISTENER_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {uriContentListener.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- if (guid.Equals(nsITooltipListener.NS_ITOOLTIPLISTENER_IID)) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {tooltipListener.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
- }
- XPCOM.memmove(ppvObject, new int /*long*/[] {0}, OS.PTR_SIZEOF);
- return XPCOM.NS_ERROR_NO_INTERFACE;
-}
-
-int /*long*/ AddRef() {
- refCount++;
- return refCount;
-}
-
-int /*long*/ Release() {
- refCount--;
- if (refCount == 0) disposeCOMInterfaces();
- return refCount;
-}
-
-/* nsIWeakReference */
-
-int /*long*/ QueryReferent(int /*long*/ riid, int /*long*/ ppvObject) {
- return QueryInterface(riid,ppvObject);
-}
-
-/* nsIInterfaceRequestor */
-
-int /*long*/ GetInterface(int /*long*/ riid, int /*long*/ ppvObject) {
- if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
- nsID guid = new nsID();
- XPCOM.memmove(guid, riid, nsID.sizeof);
- if (guid.Equals(nsIDOMWindow.NS_IDOMWINDOW_IID)) {
- int /*long*/[] aContentDOMWindow = new int /*long*/[1];
- int rc = webBrowser.GetContentDOMWindow(aContentDOMWindow);
- if (rc != XPCOM.NS_OK) error(rc);
- if (aContentDOMWindow[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
- XPCOM.memmove(ppvObject, aContentDOMWindow, OS.PTR_SIZEOF);
- return rc;
- }
- return QueryInterface(riid,ppvObject);
-}
-
-int /*long*/ GetWeakReference(int /*long*/ ppvObject) {
- XPCOM.memmove(ppvObject, new int /*long*/[] {weakReference.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return XPCOM.NS_OK;
-}
-
-/* nsIWebProgressListener */
-
-int /*long*/ OnStateChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aStateFlags, int /*long*/ aStatus) {
- if ((aStateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) == 0) return XPCOM.NS_OK;
- if ((aStateFlags & nsIWebProgressListener.STATE_START) != 0) {
- if (request == 0) request = aRequest;
- } else if ((aStateFlags & nsIWebProgressListener.STATE_REDIRECTING) != 0) {
- if (request == aRequest) request = 0;
- } else if ((aStateFlags & nsIWebProgressListener.STATE_STOP) != 0) {
- /*
- * Feature on Mozilla. When a request is redirected (STATE_REDIRECTING),
- * it never reaches the state STATE_STOP and it is replaced with a new request.
- * The new request is received when it is in the state STATE_STOP.
- * To handle this case, the variable request is set to 0 when the corresponding
- * request is redirected. The following request received with the state STATE_STOP
- * - the new request resulting from the redirection - is used to send
- * the ProgressListener.completed event.
- */
- if (request == aRequest || request == 0) {
- request = 0;
- StatusTextEvent event = new StatusTextEvent(this);
- event.display = getDisplay();
- event.widget = this;
- event.text = ""; //$NON-NLS-1$
- for (int i = 0; i < statusTextListeners.length; i++)
- statusTextListeners[i].changed(event);
-
- ProgressEvent event2 = new ProgressEvent(this);
- event2.display = getDisplay();
- event2.widget = this;
- for (int i = 0; i < progressListeners.length; i++)
- progressListeners[i].completed(event2);
- }
- }
- return XPCOM.NS_OK;
-}
-
-int /*long*/ OnProgressChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress, int /*long*/ aMaxSelfProgress, int /*long*/ aCurTotalProgress, int /*long*/ aMaxTotalProgress) {
- if (progressListeners.length == 0) return XPCOM.NS_OK;
-
- int /*long*/ total = aMaxTotalProgress;
- if (total <= 0) total = Integer.MAX_VALUE;
- ProgressEvent event = new ProgressEvent(this);
- event.display = getDisplay();
- event.widget = this;
- event.current = (int)/*64*/aCurTotalProgress;
- event.total = (int)/*64*/aMaxTotalProgress;
- for (int i = 0; i < progressListeners.length; i++)
- progressListeners[i].changed(event);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ OnLocationChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) {
- /*
- * Feature on Mozilla. When a page is loaded via setText before a previous
- * setText page load has completed, the expected OnStateChange STATE_STOP for the
- * original setText never arrives because it gets replaced by the OnStateChange
- * STATE_STOP for the new request. This results in the request field never being
- * cleared because the original request's OnStateChange STATE_STOP is still expected
- * (but never arrives). To handle this case, the request field is updated to the new
- * overriding request since its OnStateChange STATE_STOP will be received next.
- */
- if (request != 0 && request != aRequest) request = aRequest;
-
- if (locationListeners.length == 0) return XPCOM.NS_OK;
-
- nsIWebProgress webProgress = new nsIWebProgress(aWebProgress);
- int /*long*/[] aDOMWindow = new int /*long*/[1];
- int rc = webProgress.GetDOMWindow(aDOMWindow);
- if (rc != XPCOM.NS_OK) error(rc);
- if (aDOMWindow[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIDOMWindow domWindow = new nsIDOMWindow(aDOMWindow[0]);
- int /*long*/[] aTop = new int /*long*/[1];
- rc = domWindow.GetTop(aTop);
- if (rc != XPCOM.NS_OK) error(rc);
- if (aTop[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
- domWindow.Release();
-
- nsIDOMWindow topWindow = new nsIDOMWindow(aTop[0]);
- topWindow.Release();
-
- nsIURI location = new nsIURI(aLocation);
- int /*long*/ aSpec = XPCOM.nsEmbedCString_new();
- location.GetSpec(aSpec);
- int length = XPCOM.nsEmbedCString_Length(aSpec);
- int /*long*/ buffer = XPCOM.nsEmbedCString_get(aSpec);
- byte[] dest = new byte[length];
- XPCOM.memmove(dest, buffer, length);
- XPCOM.nsEmbedCString_delete(aSpec);
-
- LocationEvent event = new LocationEvent(this);
- event.display = getDisplay();
- event.widget = this;
- event.location = new String(dest);
- if (event.location.equals (URI_FROMMEMORY)) {
- /*
- * If the URI indicates that the page is being rendered from memory
- * (ie.- via setText()) then set the event location to about:blank
- * to be consistent with win32.
- */
- event.location = ABOUT_BLANK;
- }
- event.top = aTop[0] == aDOMWindow[0];
- for (int i = 0; i < locationListeners.length; i++)
- locationListeners[i].changed(event);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ OnStatusChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aStatus, int /*long*/ aMessage) {
- /*
- * Feature in Mozilla. Navigating to an HTTPS link without a user profile
- * set causes a crash. The workaround is to abort attempts to navigate to
- * HTTPS pages if a profile is not being used.
- *
- * Most navigation requests for HTTPS pages are handled in OnStartURIOpen.
- * However, https page requests that do not initially specify https as their
- * protocol will get past this check since they are resolved afterwards.
- * The workaround is to check the url whenever there is a status change, and
- * to abort any detected https requests if a profile is not being used.
- */
- nsIRequest request = new nsIRequest(aRequest);
- int /*long*/ aName = XPCOM.nsEmbedCString_new();
- request.GetName(aName);
- int length = XPCOM.nsEmbedCString_Length(aName);
- int /*long*/ buffer = XPCOM.nsEmbedCString_get(aName);
- byte[] bytes = new byte[length];
- XPCOM.memmove(bytes, buffer, length);
- XPCOM.nsEmbedCString_delete(aName);
- String value = new String(bytes);
- if (!usingProfile && value.startsWith(XPCOM.HTTPS_PROTOCOL)) {
- request.Cancel(XPCOM.NS_BINDING_ABORTED);
- return XPCOM.NS_OK;
- }
-
- if (statusTextListeners.length == 0) return XPCOM.NS_OK;
-
- StatusTextEvent event = new StatusTextEvent(this);
- event.display = getDisplay();
- event.widget = this;
- length = XPCOM.strlen_PRUnichar(aMessage);
- char[] dest = new char[length];
- XPCOM.memmove(dest, aMessage, length * 2);
- event.text = new String(dest);
- for (int i = 0; i < statusTextListeners.length; i++)
- statusTextListeners[i].changed(event);
-
- return XPCOM.NS_OK;
-}
-
-int /*long*/ OnSecurityChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ state) {
- return XPCOM.NS_OK;
-}
-
-/* nsIWebBrowserChrome */
-
-int /*long*/ SetStatus(int /*long*/ statusType, int /*long*/ status) {
- StatusTextEvent event = new StatusTextEvent(this);
- event.display = getDisplay();
- event.widget = this;
- int length = XPCOM.strlen_PRUnichar(status);
- char[] dest = new char[length];
- XPCOM.memmove(dest, status, length * 2);
- String string = new String(dest);
- if (string == null) string = ""; //$NON-NLS-1$
- event.text = string;
- for (int i = 0; i < statusTextListeners.length; i++)
- statusTextListeners[i].changed(event);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ GetWebBrowser(int /*long*/ aWebBrowser) {
- int /*long*/[] ret = new int /*long*/[1];
- if (webBrowser != null) {
- webBrowser.AddRef();
- ret[0] = webBrowser.getAddress();
- }
- XPCOM.memmove(aWebBrowser, ret, OS.PTR_SIZEOF);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ SetWebBrowser(int /*long*/ aWebBrowser) {
- if (webBrowser != null) webBrowser.Release();
- webBrowser = aWebBrowser != 0 ? new nsIWebBrowser(aWebBrowser) : null;
- return XPCOM.NS_OK;
-}
-
-int /*long*/ GetChromeFlags(int /*long*/ aChromeFlags) {
- int[] ret = new int[1];
- ret[0] = chromeFlags;
- /* aChromeFlags is a pointer to a type of size 4 */
- XPCOM.memmove(aChromeFlags, ret, 4);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ SetChromeFlags(int /*long*/ aChromeFlags) {
- chromeFlags = (int)/*64*/aChromeFlags;
- return XPCOM.NS_OK;
-}
-
-int /*long*/ DestroyBrowserWindow() {
- WindowEvent newEvent = new WindowEvent(this);
- newEvent.display = getDisplay();
- newEvent.widget = this;
- for (int i = 0; i < closeWindowListeners.length; i++)
- closeWindowListeners[i].close(newEvent);
- /*
- * Note on Mozilla. The DestroyBrowserWindow notification cannot be cancelled.
- * The browser widget cannot be used after this notification has been received.
- * The application is advised to close the window hosting the browser widget.
- * The browser widget must be disposed in all cases.
- */
- dispose();
- return XPCOM.NS_OK;
-}
-
-int /*long*/ SizeBrowserTo(int /*long*/ aCX, int /*long*/ aCY) {
- size = new Point((int)/*64*/aCX, (int)/*64*/aCY);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ ShowAsModal() {
- return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
-}
-
-int /*long*/ IsWindowModal(int /*long*/ retval) {
- // no modal loop
- /* Note. boolean remains of size 4 on 64 bit machine */
- XPCOM.memmove(retval, new int[] {0}, 4);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ ExitModalEventLoop(int /*long*/ aStatus) {
- return XPCOM.NS_OK;
-}
-
-/* nsIEmbeddingSiteWindow */
-
-int /*long*/ SetDimensions(int /*long*/ flags, int /*long*/ x, int /*long*/ y, int /*long*/ cx, int /*long*/ cy) {
- if (flags == nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) location = new Point((int)/*64*/x, (int)/*64*/y);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ GetDimensions(int /*long*/ flags, int /*long*/ x, int /*long*/ y, int /*long*/ cx, int /*long*/ cy) {
- return XPCOM.NS_OK;
-}
-
-int /*long*/ SetFocus() {
- int /*long*/[] result = new int /*long*/[1];
- int rc = webBrowser.QueryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE);
-
- nsIBaseWindow baseWindow = new nsIBaseWindow(result[0]);
- rc = baseWindow.SetFocus();
- if (rc != XPCOM.NS_OK) error(rc);
- baseWindow.Release();
-
- /*
- * Note. Mozilla notifies here that one of the children took
- * focus. This could or should be used to fire an SWT.FOCUS_IN
- * event on Browser focus listeners.
- */
- return XPCOM.NS_OK;
-}
-
-int /*long*/ GetVisibility(int /*long*/ aVisibility) {
- /* Note. boolean remains of size 4 on 64 bit machine */
- XPCOM.memmove(aVisibility, new int[] {isVisible() ? 1 : 0}, 4);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ SetVisibility(int /*long*/ aVisibility) {
- WindowEvent event = new WindowEvent(this);
- event.display = getDisplay();
- event.widget = this;
- if (aVisibility == 1) {
- /*
- * Bug in Mozilla. When the JavaScript window.open is executed, Mozilla
- * fires multiple SetVisibility 1 notifications. The workaround is
- * to ignore subsequent notifications.
- */
- if (!visible) {
- visible = true;
- event.location = location;
- event.size = size;
- event.addressBar = addressBar;
- event.menuBar = menuBar;
- event.statusBar = statusBar;
- event.toolBar = toolBar;
- for (int i = 0; i < visibilityWindowListeners.length; i++)
- visibilityWindowListeners[i].show(event);
- location = null;
- size = null;
- }
- } else {
- visible = false;
- for (int i = 0; i < visibilityWindowListeners.length; i++)
- visibilityWindowListeners[i].hide(event);
- }
- return XPCOM.NS_OK;
-}
-
-int /*long*/ GetTitle(int /*long*/ aTitle) {
- return XPCOM.NS_OK;
-}
-
-int /*long*/ SetTitle(int /*long*/ aTitle) {
- if (titleListeners.length == 0) return XPCOM.NS_OK;
- TitleEvent event = new TitleEvent(this);
- event.display = getDisplay();
- event.widget = this;
- int length = XPCOM.strlen_PRUnichar(aTitle);
- char[] dest = new char[length];
- XPCOM.memmove(dest, aTitle, length * 2);
- event.title = new String(dest);
- for (int i = 0; i < titleListeners.length; i++)
- titleListeners[i].changed(event);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ GetSiteWindow(int /*long*/ aSiteWindow) {
- /*
- * Note. The handle is expected to be an HWND on Windows and
- * a GtkWidget* on GTK. This callback is invoked on Windows
- * when the javascript window.print is invoked and the print
- * dialog comes up. If no handle is returned, the print dialog
- * does not come up on this platform.
- */
- XPCOM.memmove(aSiteWindow, new int /*long*/[] {embedHandle}, OS.PTR_SIZEOF);
- return XPCOM.NS_OK;
-}
-
-/* nsIWebBrowserChromeFocus */
-
-int /*long*/ FocusNextElement() {
- /*
- * Bug in Mozilla embedding API. Mozilla takes back the focus after sending
- * this event. This prevents tabbing out of Mozilla. This behaviour can be reproduced
- * with the Mozilla application TestGtkEmbed. The workaround is to
- * send the traversal notification after this callback returns.
- */
- getDisplay().asyncExec(new Runnable() {
- public void run() {
- traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- });
- return XPCOM.NS_OK;
-}
-
-int /*long*/ FocusPrevElement() {
- /*
- * Bug in Mozilla embedding API. Mozilla takes back the focus after sending
- * this event. This prevents tabbing out of Mozilla. This behaviour can be reproduced
- * with the Mozilla application TestGtkEmbed. The workaround is to
- * send the traversal notification after this callback returns.
- */
- getDisplay().asyncExec(new Runnable() {
- public void run() {
- traverse(SWT.TRAVERSE_TAB_PREVIOUS);
- }
- });
- return XPCOM.NS_OK;
-}
-
-/* nsIContextMenuListener */
-
-int /*long*/ OnShowContextMenu(int /*long*/ aContextFlags, int /*long*/ aEvent, int /*long*/ aNode) {
- nsIDOMEvent domEvent = new nsIDOMEvent(aEvent);
- int /*long*/[] result = new int /*long*/[1];
- int rc = domEvent.QueryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID, result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent(result[0]);
- int[] aScreenX = new int[1], aScreenY = new int[1];
- rc = domMouseEvent.GetScreenX(aScreenX);
- if (rc != XPCOM.NS_OK) error(rc);
- rc = domMouseEvent.GetScreenY(aScreenY);
- if (rc != XPCOM.NS_OK) error(rc);
- domMouseEvent.Release();
-
- Event event = new Event();
- event.x = aScreenX[0];
- event.y = aScreenY[0];
- notifyListeners(SWT.MenuDetect, event);
- if (!event.doit) return XPCOM.NS_OK;
- Menu menu = getMenu();
- if (menu != null && !menu.isDisposed ()) {
- if (aScreenX[0] != event.x || aScreenY[0] != event.y) {
- menu.setLocation (event.x, event.y);
- }
- menu.setVisible (true);
- }
- return XPCOM.NS_OK;
-}
-
-/* nsIURIContentListener */
-
-int /*long*/ OnStartURIOpen(int /*long*/ aURI, int /*long*/ retval) {
- nsIURI location = new nsIURI(aURI);
- int /*long*/ aSpec = XPCOM.nsEmbedCString_new();
- location.GetSpec(aSpec);
- int length = XPCOM.nsEmbedCString_Length(aSpec);
- int /*long*/ buffer = XPCOM.nsEmbedCString_get(aSpec);
- buffer = XPCOM.nsEmbedCString_get(aSpec);
- byte[] dest = new byte[length];
- XPCOM.memmove(dest, buffer, length);
- XPCOM.nsEmbedCString_delete(aSpec);
- String value = new String(dest);
- /*
- * Feature in Mozilla. Navigating to an HTTPS link without a user profile
- * set causes a crash. The workaround is to abort attempts to navigate to
- * HTTPS pages if a profile is not being used.
- */
- boolean isHttps = value.startsWith(XPCOM.HTTPS_PROTOCOL);
- if (locationListeners.length == 0) {
- XPCOM.memmove(retval, new int[] {isHttps && !usingProfile ? 1 : 0}, 4);
- return XPCOM.NS_OK;
- }
- boolean doit = !isHttps || usingProfile;
- if (request == 0) {
- LocationEvent event = new LocationEvent(this);
- event.display = getDisplay();
- event.widget = this;
- event.location = value;
- if (event.location.equals (URI_FROMMEMORY)) {
- /*
- * If the URI indicates that the page is being rendered from memory
- * (ie.- via setText()) then set the event location to about:blank
- * to be consistent with win32.
- */
- event.location = ABOUT_BLANK;
- }
- event.doit = doit;
- for (int i = 0; i < locationListeners.length; i++)
- locationListeners[i].changing(event);
- if (!isHttps || usingProfile) doit = event.doit;
- }
- /* Note. boolean remains of size 4 on 64 bit machine */
- XPCOM.memmove(retval, new int[] {doit ? 0 : 1}, 4);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ DoContent(int /*long*/ aContentType, int /*long*/ aIsContentPreferred, int /*long*/ aRequest, int /*long*/ aContentHandler, int /*long*/ retval) {
- return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
-}
-
-int /*long*/ IsPreferred(int /*long*/ aContentType, int /*long*/ aDesiredContentType, int /*long*/ retval) {
- boolean preferred = false;
- int size = XPCOM.strlen(aContentType);
- if (size > 0) {
- byte[] typeBytes = new byte[size + 1];
- XPCOM.memmove(typeBytes, aContentType, size);
- String contentType = new String(typeBytes);
-
- /* do not attempt to handle known problematic content types */
- if (!contentType.equals(XPCOM.CONTENT_MAYBETEXT) && !contentType.equals(XPCOM.CONTENT_MULTIPART)) {
- /* determine whether browser can handle the content type */
- int /*long*/[] result = new int /*long*/[1];
- int rc = XPCOM.NS_GetServiceManager(result);
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- nsIServiceManager serviceManager = new nsIServiceManager(result[0]);
- result[0] = 0;
- rc = serviceManager.GetService(XPCOM.NS_CATEGORYMANAGER_CID, nsICategoryManager.NS_ICATEGORYMANAGER_IID, result);
- serviceManager.Release();
- if (rc != XPCOM.NS_OK) error(rc);
- if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
-
- nsICategoryManager categoryManager = new nsICategoryManager(result[0]);
- result[0] = 0;
- byte[] categoryBytes = Converter.wcsToMbcs(null, "Gecko-Content-Viewers", true); //$NON-NLS-1$
- rc = categoryManager.GetCategoryEntry(categoryBytes, typeBytes, result);
- categoryManager.Release();
- /* if no viewer for the content type is registered then rc == XPCOM.NS_ERROR_NOT_AVAILABLE */
- preferred = rc == XPCOM.NS_OK;
- }
- }
-
- /* note that boolean remains of size 4 on 64 bit machines */
- XPCOM.memmove(retval, new int[] {preferred ? 1 : 0}, 4);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ CanHandleContent(int /*long*/ aContentType, int /*long*/ aIsContentPreferred, int /*long*/ aDesiredContentType, int /*long*/ retval) {
- return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
-}
-
-int /*long*/ GetLoadCookie(int /*long*/ aLoadCookie) {
- return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
-}
-
-int /*long*/ SetLoadCookie(int /*long*/ aLoadCookie) {
- return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
-}
-
-int /*long*/ GetParentContentListener(int /*long*/ aParentContentListener) {
- return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
-}
-
-int /*long*/ SetParentContentListener(int /*long*/ aParentContentListener) {
- return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* nsITooltipListener */
-
-int /*long*/ OnShowTooltip(int /*long*/ aXCoords, int /*long*/ aYCoords, int /*long*/ aTipText) {
- int length = XPCOM.strlen_PRUnichar(aTipText);
- char[] dest = new char[length];
- XPCOM.memmove(dest, aTipText, length * 2);
- String text = new String(dest);
- if (tip != null && !tip.isDisposed()) tip.dispose();
- Display display = getDisplay();
- Shell parent = getShell();
- tip = new Shell(parent, SWT.ON_TOP);
- tip.setLayout(new FillLayout());
- Label label = new Label(tip, SWT.CENTER);
- label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- label.setText(text);
- /*
- * Bug in Mozilla embedded API. Tooltip coordinates are wrong for
- * elements inside an inline frame (IFrame tag). The workaround is
- * to position the tooltip based on the mouse cursor location.
- */
- Point point = display.getCursorLocation();
- /* Assuming cursor is 21x21 because this is the size of
- * the arrow cursor on Windows
- */
- point.y += 21;
- tip.setLocation(point);
- tip.pack();
- tip.setVisible(true);
- return XPCOM.NS_OK;
-}
-
-int /*long*/ OnHideTooltip() {
- if (tip != null && !tip.isDisposed()) tip.dispose();
- tip = null;
- return XPCOM.NS_OK;
-}
-}
diff --git a/dev/linux/src/org/eclipse/swt/internal/Library.java b/dev/linux/src/org/eclipse/swt/internal/Library.java
deleted file mode 100644
index 35900e3..0000000
--- a/dev/linux/src/org/eclipse/swt/internal/Library.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.internal;
-
-public class Library {
-
- /* SWT Version - Mmmm (M=major, mmm=minor) */
-
- /**
- * SWT Major version number (must be >= 0)
- */
- static int MAJOR_VERSION = 3;
-
- /**
- * SWT Minor version number (must be in the range 0..999)
- */
- static int MINOR_VERSION = 235;
-
- /**
- * SWT revision number (must be >= 0)
- */
- static int REVISION = 0;
-
- /**
- * The JAVA and SWT versions
- */
- public static final int JAVA_VERSION, SWT_VERSION;
-
-static {
- JAVA_VERSION = parseVersion(System.getProperty("java.version"));
- SWT_VERSION = SWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
-}
-
-static int parseVersion(String version) {
- if (version == null) return 0;
- int major = 0, minor = 0, micro = 0;
- int length = version.length(), index = 0, start = 0;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) major = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- start = ++index;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) minor = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- start = ++index;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) micro = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- return JAVA_VERSION(major, minor, micro);
-}
-
-/**
- * Returns the Java version number as an integer.
- *
- * @param major
- * @param minor
- * @param micro
- * @return the version
- */
-public static int JAVA_VERSION (int major, int minor, int micro) {
- return (major << 16) + (minor << 8) + micro;
-}
-
-/**
- * Returns the SWT version number as an integer.
- *
- * @param major
- * @param minor
- * @return the version
- */
-public static int SWT_VERSION (int major, int minor) {
- return major * 1000 + minor;
-}
-
-/**
- * Loads the shared library that matches the version of the
- * Java code which is currently running. SWT shared libraries
- * follow an encoding scheme where the major, minor and revision
- * numbers are embedded in the library name and this along with
- * <code>name</code> is used to load the library. If this fails,
- * <code>name</code> is used in another attempt to load the library,
- * this time ignoring the SWT version encoding scheme.
- *
- * @param name the name of the library to load
- */
-public static void loadLibrary (String name) {
- /*
- * Include platform name to support different windowing systems
- * on same operating system.
- */
- String platform = Platform.PLATFORM;
-
- /*
- * Get version qualifier.
- */
- String version = System.getProperty ("swt.version"); //$NON-NLS-1$
- if (version == null) {
- version = "" + MAJOR_VERSION; //$NON-NLS-1$
- /* Force 3 digits in minor version number */
- if (MINOR_VERSION < 10) {
- version += "00"; //$NON-NLS-1$
- } else {
- if (MINOR_VERSION < 100) version += "0"; //$NON-NLS-1$
- }
- version += MINOR_VERSION;
- /* No "r" until first revision */
- if (REVISION > 0) version += "r" + REVISION; //$NON-NLS-1$
- }
-
- /*
- * GOOGLE: Since we're bundling our own version of SWT, we need to be
- * able to tell SWT where its dynamic libraries live. Otherwise we'd
- * have to force our users to always specify a -Djava.library.path
- * on the command line.
- */
- String swtLibraryPath = System.getProperty ("swt.library.path");
- try {
- String newName = name + "-" + platform + "-" + version; //$NON-NLS-1$ //$NON-NLS-2$
- if (swtLibraryPath != null)
- System.load(swtLibraryPath + System.mapLibraryName(newName));
- else
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e1) {
- try {
- String newName = name + "-" + platform; //$NON-NLS-1$
- if (swtLibraryPath != null)
- System.load(swtLibraryPath + System.mapLibraryName(newName));
- else
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e2) {
- throw e1;
- }
- }
-}
-
-}
diff --git a/dev/mac/build.xml b/dev/mac/build.xml
deleted file mode 100755
index 715aa21..0000000
--- a/dev/mac/build.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<project name="dev-mac" default="build" basedir=".">
- <property name="project.tail" value="dev/mac" />
- <property name="gwt.dev.swt.jar" value="org.eclipse.swt.carbon-macosx-3.2.1.jar"/>
- <import file="../common.ant.xml" />
-</project>
diff --git a/dev/mac/src/com/google/gwt/dev/BootStrapPlatform.java b/dev/mac/src/com/google/gwt/dev/BootStrapPlatform.java
deleted file mode 100644
index 164a4a6..0000000
--- a/dev/mac/src/com/google/gwt/dev/BootStrapPlatform.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-import com.google.gwt.dev.shell.mac.LowLevelSaf;
-
-import java.awt.GraphicsEnvironment;
-import java.awt.Toolkit;
-
-/**
- * Initializes the low level libraries for Mac.
- */
-public class BootStrapPlatform {
-
- public static void applyPlatformHacks() {
- setSystemProperties();
- fixContextClassLoaderOnMainThread();
- }
-
- /**
- *
- * This works around a complicated set of OS X SWT/AWT compatibilities.
- * {@link #setSystemProperties()} will typically need to be called first to
- * ensure that CocoaComponent compatibility mode is disabled. The constraints
- * of using SWT and AWT together are:
- *
- * <p>
- * 1 - The SWT event dispatch needs to be running on the main application
- * thread (only possible with -XstartOnFirstThread VM arg).
- * </p>
- * <p>
- * 2 - The first call into AWT must be from the main thread after a SWT
- * display has been initialized.
- * </p>
- *
- * This method allows the compiler to have a tree logger in a SWT window and
- * allow generators to use AWT for image generation.
- *
- * <p>
- * NOTE: In GUI applications, {@link #setSystemProperties()} and
- * {@link #initGui()} will both be called during the bootstrap process.
- * Command line applications (like
- *
- * @{link com.google.gwt.dev.GWTCompiler}) avoid eagerly initializing AWT and
- * only call {@link #setSystemProperties()} allowing AWT to be
- * initialized on demand.
- * </p>
- */
- public static void initGui() {
- GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
- Toolkit.getDefaultToolkit();
- }
-
- public static void initHostedMode() {
- /*
- * The following check must be made before attempting to initialize Safari,
- * or we'll fail with an less-than-helpful UnsatisfiedLinkError.
- */
- if (!isJava5()) {
- System.err.println("You must use a Java 1.5 runtime to use GWT Hosted Mode on Mac OS X.");
- System.exit(-1);
- }
-
- LowLevelSaf.init();
- // Ensure we were started with -XstartOnFirstThread
- if (!hasStartOnFirstThreadFlag(LowLevelSaf.getProcessArgs())) {
- System.err.println("Invalid launch configuration: -XstartOnFirstThread not specified.");
- System.err.println();
- System.err.println("On Mac OS X, GWT requires that the Java virtual machine be invoked with the");
- System.err.println("-XstartOnFirstThread VM argument.");
- System.err.println();
- System.err.println("Example:");
- System.err.println(" java -XstartOnFirstThread -cp gwt-dev-mac.jar com.google.gwt.dev.GWTShell");
- System.exit(-1);
- }
- }
-
- /**
- * This works around apple radr:5569300. When -XstartOnFirstThread is passed
- * as a jvm argument, the main thread returns null for
- * {@link Thread#getContextClassLoader()}.
- */
- private static void fixContextClassLoaderOnMainThread() {
- final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if (classLoader == null) {
- Thread.currentThread().setContextClassLoader(
- BootStrapPlatform.class.getClassLoader());
- }
- }
-
- private static boolean hasStartOnFirstThreadFlag(String[] args) {
- for (int i = 0; i < args.length; ++i) {
- if (args[i].equalsIgnoreCase("-xstartonfirstthread")) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Determine if we're using the Java 1.5 runtime, since the 1.6 runtime is
- * 64-bit.
- */
- private static boolean isJava5() {
- return System.getProperty("java.version").startsWith("1.5");
- }
-
- /**
- * Sets platform specific system properties. Currently, this disables
- * CocoaComponent CompatibilityMode.
- *
- * <p>
- * NOTE: In GUI applications, {@link #setSystemProperties()} and
- * {@link #initGui()} will both be called during the bootstrap process.
- * Command line applications (like
- *
- * @{link com.google.gwt.dev.GWTCompiler}) avoid eagerly initializing AWT and
- * only call {@link #setSystemProperties()} allowing AWT to be
- * initialized on demand.
- * </p>
- */
- private static void setSystemProperties() {
- // Disable CocoaComponent compatibility mode.
- System.setProperty("com.apple.eawt.CocoaComponent.CompatibilityMode",
- "false");
- }
-}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/BrowserWidgetSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/BrowserWidgetSaf.java
deleted file mode 100644
index 94daea4..0000000
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/BrowserWidgetSaf.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.mac;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.shell.BrowserWidget;
-import com.google.gwt.dev.shell.BrowserWidgetHost;
-import com.google.gwt.dev.shell.HostedHtmlVersion;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.shell.ModuleSpaceHost;
-import com.google.gwt.dev.shell.mac.LowLevelSaf.DispatchMethod;
-import com.google.gwt.dev.shell.mac.LowLevelSaf.DispatchObject;
-
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.widgets.Shell;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents an individual browser window and all of its controls.
- */
-public class BrowserWidgetSaf extends BrowserWidget {
- private class ExternalObject implements DispatchObject {
-
- public int getField(int jsContext, String name) {
- if ("gwtonload".equalsIgnoreCase(name)) {
- return LowLevelSaf.wrapDispatchMethod(jsContext, "gwtOnload",
- new GwtOnLoad());
- } else if ("initmodule".equalsIgnoreCase(name)) {
- return LowLevelSaf.wrapDispatchMethod(jsContext, "initModule",
- new InitModule());
- }
- // Native code eats the same ref it gave us.
- return LowLevelSaf.getJsUndefined(jsContext);
- }
-
- public Object getTarget() {
- return this;
- }
-
- public boolean gwtOnLoad(int scriptObject, String moduleName, String version) {
- if (moduleName == null) {
- // Indicates one or more modules are being unloaded.
- return handleUnload(scriptObject);
- }
-
- TreeLogger logger = getHost().getLogger().branch(TreeLogger.DEBUG,
- "Loading an instance of module '" + moduleName + "'");
- try {
- if (!HostedHtmlVersion.validHostedHtmlVersion(logger, version)) {
- return false;
- }
-
- // Attach a new ModuleSpace to make it programmable.
- //
- Integer key = new Integer(scriptObject);
- ModuleSpaceHost msh = getHost().createModuleSpaceHost(logger,
- BrowserWidgetSaf.this, moduleName);
-
- /*
- * The global context for each window object is recorded during the
- * windowScriptObjectAvailable event. Now that we know which window
- * belongs to this module, we can resolve the correct global context.
- */
- final int globalContext = globalContexts.get(scriptObject).intValue();
-
- ModuleSpace moduleSpace = new ModuleSpaceSaf(logger, msh, scriptObject,
- globalContext, moduleName, key);
- attachModuleSpace(logger, moduleSpace);
- return true;
- } catch (Throwable e) {
- // We do catch Throwable intentionally because there are a ton of things
- // that can go wrong trying to load a module, including Error-dervied
- // things like NoClassDefFoundError.
- //
- logger.log(TreeLogger.ERROR, "Failure to load module '" + moduleName
- + "'", e);
- return false;
- }
- }
-
- /**
- * Causes a link to occur for the specified module.
- *
- * @param moduleName the module name to link
- * @return <code>true</code> if this module is stale and should be
- * reloaded
- */
- public boolean initModule(String moduleName) {
- return getHost().initModule(moduleName);
- }
-
- public void setField(int jsContext, String name, int value) {
- try {
- // TODO (knorton): This should produce an error. The SetProperty
- // callback on the native side should be changed to pass an exception
- // array.
- } finally {
- LowLevelSaf.gcUnprotect(jsContext, value);
- }
- }
-
- /**
- * Unload one or more modules.
- *
- * @param scriptObject window to unload, 0 if all
- */
- protected boolean handleUnload(int scriptObject) {
- try {
- Integer key = null;
- if (scriptObject != 0) {
- key = new Integer(scriptObject);
- }
- doUnload(key);
- return true;
- } catch (Throwable e) {
- getHost().getLogger().log(TreeLogger.ERROR,
- "Failure to unload modules", e);
- return false;
- }
- }
- }
-
- private final class GwtOnLoad implements DispatchMethod {
-
- public int invoke(int jsContext, int jsthis, int[] jsargs, int[] exception) {
- int jsFalse = LowLevelSaf.toJsBoolean(jsContext, false);
- LowLevelSaf.pushJsContext(jsContext);
- try {
- if (!LowLevelSaf.isDispatchObject(jsContext, jsthis)) {
- return jsFalse;
- }
-
- Object thisObj = LowLevelSaf.unwrapDispatchObject(jsContext, jsthis);
- if (!(thisObj instanceof ExternalObject)) {
- return jsFalse;
- }
-
- if (jsargs.length < 3) {
- reportIncorrectInvocation("gwtOnLoad", 3, jsargs.length);
- return jsFalse;
- }
-
- if (!LowLevelSaf.isJsObject(jsContext, jsargs[0])) {
- return jsFalse;
- }
- if (!LowLevelSaf.isJsNull(jsContext, jsargs[1])
- && !LowLevelSaf.isJsString(jsContext, jsargs[1])) {
- return jsFalse;
- }
- String moduleName = LowLevelSaf.toString(jsContext, jsargs[1]);
-
- if (!LowLevelSaf.isJsString(jsContext, jsargs[2])) {
- return jsFalse;
- }
- String version = LowLevelSaf.toString(jsContext, jsargs[2]);
-
- boolean result = ((ExternalObject) thisObj).gwtOnLoad(jsargs[0],
- moduleName, version);
- // Native code eats the same ref it gave us.
- return LowLevelSaf.toJsBoolean(jsContext, result);
- } catch (Throwable e) {
- return jsFalse;
- } finally {
- for (int jsarg : jsargs) {
- LowLevelSaf.gcUnprotect(jsContext, jsarg);
- }
- LowLevelSaf.gcUnprotect(jsContext, jsthis);
- LowLevelSaf.popJsContext(jsContext);
- }
- }
- }
-
- private final class InitModule implements DispatchMethod {
-
- public int invoke(int jsContext, int jsthis, int[] jsargs, int[] exception) {
- int jsFalse = LowLevelSaf.toJsBoolean(jsContext, false);
- LowLevelSaf.pushJsContext(jsContext);
- try {
- if (!LowLevelSaf.isDispatchObject(jsContext, jsthis)) {
- return jsFalse;
- }
-
- Object thisObj = LowLevelSaf.unwrapDispatchObject(jsContext, jsthis);
- if (!(thisObj instanceof ExternalObject)) {
- return jsFalse;
- }
-
- if (jsargs.length < 1) {
- reportIncorrectInvocation("initModule", 1, jsargs.length);
- return jsFalse;
- }
-
- if (!LowLevelSaf.isJsString(jsContext, jsargs[0])) {
- return jsFalse;
- }
- String moduleName = LowLevelSaf.toString(jsContext, jsargs[0]);
-
- boolean result = ((ExternalObject) thisObj).initModule(moduleName);
- // Native code eats the same ref it gave us.
- return LowLevelSaf.toJsBoolean(jsContext, result);
- } catch (Throwable e) {
- return jsFalse;
- } finally {
- for (int jsarg : jsargs) {
- LowLevelSaf.gcUnprotect(jsContext, jsarg);
- }
- LowLevelSaf.gcUnprotect(jsContext, jsthis);
- LowLevelSaf.popJsContext(jsContext);
- }
- }
- }
-
- private static final int REDRAW_PERIOD = 250;
-
- static {
- LowLevelSaf.init();
- }
-
- private final Map<Integer, Integer> globalContexts = new HashMap<Integer, Integer>();
-
- public BrowserWidgetSaf(Shell shell, BrowserWidgetHost host) {
- super(shell, host);
-
- Browser.setWebInspectorEnabled(true);
- browser.addWindowScriptObjectListener(new Browser.WindowScriptObjectListener() {
-
- public void windowScriptObjectAvailable(int windowScriptObject) {
- /*
- * When GwtOnLoad fires we may not be able to get to the JSGlobalContext
- * that corresponds to our module frame (since the call to GwtOnLoad
- * could originate in the main page. So as each frame fires a
- * windowScriptObjectAvailable event, we must store all window,
- * globalContext pairs in a HashMap so we can later look up the global
- * context by window object when GwtOnLoad is called.
- */
- int jsGlobalContext = browser.getGlobalContextForWindowObject(windowScriptObject);
- int jsGlobalObject = LowLevelSaf.getGlobalJsObject(jsGlobalContext);
- LowLevelSaf.pushJsContext(jsGlobalContext);
-
- try {
- globalContexts.put(Integer.valueOf(jsGlobalObject),
- Integer.valueOf(jsGlobalContext));
-
- int external = LowLevelSaf.wrapDispatchObject(jsGlobalContext,
- new ExternalObject());
- LowLevelSaf.executeScript(jsGlobalContext,
- "function __defineExternal(x) {" + " window.external = x;" + "}");
- int ignoredResult = LowLevelSaf.invoke(jsGlobalContext,
- jsGlobalObject, "__defineExternal", jsGlobalObject,
- new int[] {external});
- LowLevelSaf.gcUnprotect(jsGlobalContext, ignoredResult);
- } finally {
- LowLevelSaf.popJsContext(jsGlobalContext);
- }
- }
-
- });
-
- /*
- * HACK (knorton) - SWT wrapper on WebKit seems to cause unreliable repaints
- * when the DOM changes inside of WebView. To compensate for this, every
- * quarter second, we tell WebView to repaint itself fully.
- */
- getDisplay().timerExec(REDRAW_PERIOD, new Runnable() {
- public void run() {
- if (browser.isDisposed() || isDisposed()) {
- // stop running if we're disposed
- return;
- }
- // Force the browser to refresh
- browser.setNeedsDisplay(true);
- // Reschedule this object to run again
- getDisplay().timerExec(REDRAW_PERIOD, this);
- }
- });
- }
-
- @Override
- public String getUserAgent() {
- // See UserAgent.gwt.xml
- return "safari";
- }
-}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/JsValueSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/JsValueSaf.java
deleted file mode 100644
index de7b7b6..0000000
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/JsValueSaf.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.mac;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.mac.LowLevelSaf.DispatchObject;
-
-/**
- * Represents a Safari JavaScript value.
- *
- * The basic rule is that any JSValue passed to Java code from native code will
- * always be GC-protected in the native code and Java will always unprotect it
- * when the value is finalized. It should always be stored in a JsValue object
- * immediately to make sure it is cleaned up properly when it is no longer
- * needed. This approach is required to avoid a race condition where the value
- * is allocated in JNI code but could be garbage collected before Java takes
- * ownership of the value. Java values passed into JavaScript store a GlobalRef
- * of a WebKitDispatchAdapter or MethodDispatch objects, which are freed when
- * the JS value is finalized.
- */
-public class JsValueSaf extends JsValue {
-
- private static class JsCleanupSaf implements JsCleanup {
- private final int jsval;
-
- /**
- * Create a cleanup object which takes care of cleaning up the underlying JS
- * object.
- *
- * @param jsval JSValue pointer as an integer
- */
- public JsCleanupSaf(int jsval) {
- this.jsval = jsval;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue.JsCleanup#doCleanup()
- */
- public void doCleanup() {
- LowLevelSaf.gcUnprotect(LowLevelSaf.getCurrentJsContext(), jsval);
- }
- }
-
- /*
- * Underlying JSValue* as an integer.
- */
- private int jsval;
-
- /**
- * Create a Java wrapper around an undefined JSValue.
- */
- public JsValueSaf() {
- init(LowLevelSaf.getJsUndefined(LowLevelSaf.getCurrentJsContext()));
- }
-
- /**
- * Create a Java wrapper around the underlying JSValue.
- *
- * @param jsval a pointer to the underlying JSValue object as an integer
- */
- public JsValueSaf(int jsval) {
- init(jsval);
- }
-
- @Override
- public boolean getBoolean() {
- int curJsContext = LowLevelSaf.getCurrentJsContext();
- return LowLevelSaf.toBoolean(curJsContext, jsval);
- }
-
- @Override
- public int getInt() {
- int currentJsContext = LowLevelSaf.getCurrentJsContext();
- return LowLevelSaf.toInt(currentJsContext, jsval);
- }
-
- @Override
- public int getJavaScriptObjectPointer() {
- assert isJavaScriptObject();
- return jsval;
- }
-
- public int getJsValue() {
- return jsval;
- }
-
- @Override
- public double getNumber() {
- int currentJsContext = LowLevelSaf.getCurrentJsContext();
- return LowLevelSaf.toDouble(currentJsContext, jsval);
- }
-
- @Override
- public String getString() {
- final int currentJsContext = LowLevelSaf.getCurrentJsContext();
- return LowLevelSaf.toString(currentJsContext, jsval);
- }
-
- @Override
- public String getTypeString() {
- return LowLevelSaf.getTypeString(LowLevelSaf.getCurrentJsContext(), jsval);
- }
-
- @Override
- public Object getWrappedJavaObject() {
- DispatchObject obj = LowLevelSaf.unwrapDispatchObject(
- LowLevelSaf.getCurrentJsContext(), jsval);
- return obj.getTarget();
- }
-
- @Override
- public boolean isBoolean() {
- return LowLevelSaf.isJsBoolean(LowLevelSaf.getCurrentJsContext(), jsval);
- }
-
- @Override
- public boolean isInt() {
- // Safari doesn't have integers, so this is always false
- return false;
- }
-
- @Override
- public boolean isJavaScriptObject() {
- final int currentJsContext = LowLevelSaf.getCurrentJsContext();
- return LowLevelSaf.isJsObject(currentJsContext, jsval)
- && !LowLevelSaf.isDispatchObject(currentJsContext, jsval);
- }
-
- @Override
- public boolean isNull() {
- return LowLevelSaf.isJsNull(LowLevelSaf.getCurrentJsContext(), jsval);
- }
-
- @Override
- public boolean isNumber() {
- return LowLevelSaf.isJsNumber(LowLevelSaf.getCurrentJsContext(), jsval);
- }
-
- @Override
- public boolean isString() {
- return LowLevelSaf.isJsString(LowLevelSaf.getCurrentJsContext(), jsval);
- }
-
- @Override
- public boolean isUndefined() {
- return LowLevelSaf.isJsUndefined(LowLevelSaf.getCurrentJsContext(), jsval);
- }
-
- @Override
- public boolean isWrappedJavaObject() {
- return LowLevelSaf.isDispatchObject(LowLevelSaf.getCurrentJsContext(),
- jsval);
- }
-
- @Override
- public void setBoolean(boolean val) {
- setJsVal(LowLevelSaf.toJsBoolean(LowLevelSaf.getCurrentJsContext(), val));
- }
-
- @Override
- public void setByte(byte val) {
- setJsVal(LowLevelSaf.toJsNumber(LowLevelSaf.getCurrentJsContext(), val));
- }
-
- @Override
- public void setChar(char val) {
- setJsVal(LowLevelSaf.toJsNumber(LowLevelSaf.getCurrentJsContext(), val));
- }
-
- @Override
- public void setDouble(double val) {
- setJsVal(LowLevelSaf.toJsNumber(LowLevelSaf.getCurrentJsContext(), val));
- }
-
- @Override
- public void setInt(int val) {
- setJsVal(LowLevelSaf.toJsNumber(LowLevelSaf.getCurrentJsContext(), val));
- }
-
- @Override
- public void setNull() {
- setJsVal(LowLevelSaf.getJsNull(LowLevelSaf.getCurrentJsContext()));
- }
-
- @Override
- public void setShort(short val) {
- setJsVal(LowLevelSaf.toJsNumber(LowLevelSaf.getCurrentJsContext(), val));
- }
-
- @Override
- public void setString(String val) {
- setJsVal(LowLevelSaf.toJsString(LowLevelSaf.getCurrentJsContext(), val));
- }
-
- @Override
- public void setUndefined() {
- setJsVal(LowLevelSaf.getJsUndefined(LowLevelSaf.getCurrentJsContext()));
- }
-
- @Override
- public void setValue(JsValue other) {
- int jsvalOther = ((JsValueSaf) other).jsval;
- /*
- * Add another lock to this jsval, since both the other object and this one
- * will eventually release it.
- */
- LowLevelSaf.gcProtect(LowLevelSaf.getCurrentJsContext(), jsvalOther);
- setJsVal(jsvalOther);
- }
-
- @Override
- public <T> void setWrappedJavaObject(CompilingClassLoader cl, T val) {
- DispatchObject dispObj;
- if (val == null) {
- setNull();
- return;
- } else if (val instanceof DispatchObject) {
- dispObj = (DispatchObject) val;
- } else {
- dispObj = (DispatchObject) cl.getWrapperForObject(val);
- if (dispObj == null) {
- dispObj = new WebKitDispatchAdapter(cl, val);
- cl.putWrapperForObject(val, dispObj);
- }
- }
- setJsVal(LowLevelSaf.wrapDispatchObject(LowLevelSaf.getCurrentJsContext(),
- dispObj));
- }
-
- @Override
- protected JsCleanup createCleanupObject() {
- return new JsCleanupSaf(jsval);
- }
-
- /**
- * Initialization helper method.
- *
- * @param jsval underlying JSValue*
- */
- private void init(int jsval) {
- this.jsval = jsval;
-
- // If protection checking is enabled, we check to see if the value we are
- // accepting is protected as it should be.
- if (LowLevelSaf.isJsValueProtectionCheckingEnabled()
- && !LowLevelSaf.isGcProtected(jsval)) {
- throw new RuntimeException("Cannot accepted unprotected JSValue ("
- + Integer.toHexString(jsval) + ", "
- + LowLevelSaf.getTypeString(LowLevelSaf.getCurrentJsContext(), jsval)
- + ")");
- }
- }
-
- /**
- * Set a new value. Unlock the previous value, but do *not* lock the new value
- * (see class comment).
- *
- * @param jsval the new value to set
- */
- private void setJsVal(int jsval) {
- LowLevelSaf.gcUnprotect(LowLevelSaf.getCurrentJsContext(), this.jsval);
- init(jsval);
- }
-
-}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/LowLevelSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/LowLevelSaf.java
deleted file mode 100644
index 3787e90..0000000
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/LowLevelSaf.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.mac;
-
-import com.google.gwt.dev.shell.LowLevel;
-
-import java.io.File;
-import java.util.IdentityHashMap;
-import java.util.Map;
-import java.util.Stack;
-
-/**
- * Implements all native / low-level functions for Mac/Safari hosted mode.
- *
- * TODO (knorton): Consider changing the APIs to not have to take a jsContext;
- * instead the context could always be pulled from top-of-stack in the wrapper
- * functions and passed into the native functions.
- */
-public class LowLevelSaf {
-
- /**
- * Interface by which the native code interacts with a Java Method.
- */
- public interface DispatchMethod {
- int invoke(int jsContext, int jsthis, int[] jsargs, int[] exception);
- }
-
- /**
- * Interface by which the native code interacts with a Java Object.
- *
- * TODO (knorton): Add additional argument for an exception array (like in
- * {@link DispatchMethod#invoke(int, int, int[], int[])}). An example of
- * where this would be immediately helpful is in {@link BrowserWidgetSaf}.
- */
- public interface DispatchObject {
- int getField(int jsContext, String name);
-
- Object getTarget();
-
- void setField(int jsContext, String name, int value);
- }
-
- /**
- * Stores a map from DispatchObject/DispatchMethod to the live underlying
- * jsval. This is used to both preserve identity for the same Java Object and
- * also prevent GC.
- *
- * Access must be synchronized because WebKit can finalize on a foreign
- * thread.
- */
- static Map<Object, Integer> sObjectToJsval = new IdentityHashMap<Object, Integer>();
-
- private static boolean initialized = false;
-
- private static final ThreadLocal<Stack<Integer>> jsContextStack = new ThreadLocal<Stack<Integer>>();
-
- private static boolean jsValueProtectionCheckingEnabled;
-
- public static int executeScript(int jsContext, String script) {
- final int[] rval = new int[1];
- if (!executeScriptWithInfoImpl(jsContext, script, null, 0, rval)) {
- throw new RuntimeException("Failed to execute script: " + script);
- }
- return rval[0];
- }
-
- public static int executeScriptWithInfo(int jsContext, String script,
- String url, int line) {
- final int[] rval = new int[1];
- if (!executeScriptWithInfoImpl(jsContext, script, url, line, rval)) {
- throw new RuntimeException(url + "(" + line
- + "): Failed to execute script: " + script);
- }
- return rval[0];
- }
-
- public static native void gcProtect(int jsContext, int jsValue);
-
- public static native void gcUnprotect(int jsContext, int jsValue);
-
- public static native int getArgc();
-
- public static native String getArgv(int ix);
-
- public static int getCurrentJsContext() {
- Stack<Integer> stack = jsContextStack.get();
- if (stack == null) {
- throw new RuntimeException("No JSContext stack on this thread.");
- }
- return stack.peek().intValue();
- }
-
- public static int getGlobalJsObject(int jsContext) {
- final int rval[] = new int[1];
- if (!getGlobalJsObjectImpl(jsContext, rval)) {
- throw new RuntimeException("Unable to get JavaScript global object.");
- }
- return rval[0];
- }
-
- public static native int getJsNull(int jsContext);
-
- public static native int getJsUndefined(int jsContext);
-
- public static String[] getProcessArgs() {
- int argc = getArgc();
- String[] result = new String[argc];
- for (int i = 0; i < argc; ++i) {
- result[i] = getArgv(i);
- }
- return result;
- }
-
- public static native String getTypeString(int jsContext, int jsValue);
-
- public static synchronized void init() {
- if (initialized) {
- return;
- }
-
- try {
- LowLevel.init();
- } catch (UnsatisfiedLinkError e) {
- // Try to provide some additional context
- System.err.println("On Mac OS X, ensure that you have Safari 3 installed.");
- if (!(new File("/System/Library/Frameworks/JavaScriptCore.framework")).isDirectory()) {
- System.err.println("Could not find JavaScriptCore in the expected location.");
- }
- throw e;
- }
-
- if (!initImpl(DispatchObject.class, DispatchMethod.class, LowLevelSaf.class)) {
- throw new RuntimeException("Unable to initialize LowLevelSaf");
- }
-
- jsValueProtectionCheckingEnabled = isJsValueProtectionCheckingEnabledImpl();
-
- initialized = true;
- }
-
- public static int invoke(int jsContext, int jsScriptObject,
- String methodName, int thisObj, int[] args) {
-
- final int[] rval = new int[1];
- if (!invokeImpl(jsContext, jsScriptObject, methodName, thisObj, args,
- args.length, rval)) {
- throw new RuntimeException("Failed to invoke native method: "
- + methodName + " with " + args.length + " arguments.");
- }
- return rval[0];
- }
-
- public static boolean isDispatchObject(int jsContext, int jsValue) {
- final boolean[] rval = new boolean[1];
- if (!isDispatchObjectImpl(jsContext, jsValue, rval)) {
- throw new RuntimeException("Failed isDispatchObject.");
- }
- return rval[0];
- }
-
- public static native boolean isJsBoolean(int jsContext, int jsValue);
-
- public static native boolean isJsNull(int jsContext, int jsValue);
-
- public static native boolean isJsNumber(int jsContext, int jsValue);
-
- public static native boolean isJsObject(int jsContext, int jsValue);
-
- public static boolean isJsString(int jsContext, int jsValue) {
- final boolean rval[] = new boolean[1];
- if (!isJsStringImpl(jsContext, jsValue, rval)) {
- throw new RuntimeException("Failed isJsString.");
- }
- return rval[0];
- }
-
- public static native boolean isJsUndefined(int jsContext, int jsValue);
-
- public static void popJsContext(int expectedJsContext) {
- final Stack<Integer> stack = jsContextStack.get();
- if (stack == null) {
- throw new RuntimeException("No JSContext stack on this thread.");
- }
- if (stack.pop().intValue() != expectedJsContext) {
- throw new RuntimeException(
- "Popping JSContext returned an unxpected value.");
- }
- }
-
- public static void pushJsContext(int jsContext) {
- Stack<Integer> stack = jsContextStack.get();
- if (stack == null) {
- stack = new Stack<Integer>();
- jsContextStack.set(stack);
- }
- stack.push(Integer.valueOf(jsContext));
- }
-
- public static native void releaseJsGlobalContext(int jsContext);
-
- public static native void retainJsGlobalContext(int jsContext);
-
- public static boolean toBoolean(int jsContext, int jsValue) {
- boolean[] rval = new boolean[1];
- if (!toBooleanImpl(jsContext, jsValue, rval)) {
- throw new RuntimeException("Failed to coerce to boolean value.");
- }
- return rval[0];
- }
-
- public static byte toByte(int jsContext, int jsValue) {
- return (byte) toNumber(jsContext, jsValue, "byte");
- }
-
- public static char toChar(int jsContext, int jsValue) {
- return (char) toNumber(jsContext, jsValue, "char");
- }
-
- public static double toDouble(int jsContext, int jsValue) {
- return toNumber(jsContext, jsValue, "double");
- }
-
- public static float toFloat(int jsContext, int jsValue) {
- return (float) toNumber(jsContext, jsValue, "float");
- }
-
- public static int toInt(int jsContext, int jsValue) {
- return (int) toNumber(jsContext, jsValue, "int");
- }
-
- public static int toJsBoolean(int jsContext, boolean value) {
- final int[] rval = new int[1];
- if (!toJsBooleanImpl(jsContext, value, rval)) {
- throw new RuntimeException("Failed to convert Boolean value: "
- + String.valueOf(value));
- }
- return rval[0];
- }
-
- public static int toJsNumber(int jsContext, double value) {
- final int[] rval = new int[1];
- if (!toJsNumberImpl(jsContext, value, rval)) {
- throw new RuntimeException("Failed to convert Double value: "
- + String.valueOf(value));
- }
- return rval[0];
- }
-
- public static int toJsString(int jsContext, String value) {
- final int[] rval = new int[1];
- if (!toJsStringImpl(jsContext, value, rval)) {
- throw new RuntimeException("Failed to convert String value: "
- + String.valueOf(value));
- }
- return rval[0];
- }
-
- public static long toLong(int jsContext, int jsValue) {
- return (long) toNumber(jsContext, jsValue, "long");
- }
-
- public static short toShort(int jsContext, int jsValue) {
- return (short) toNumber(jsContext, jsValue, "short");
- }
-
- public static String toString(int jsContext, int jsValue) {
- final String[] rval = new String[1];
- if (!toStringImpl(jsContext, jsValue, rval)) {
- throw new RuntimeException("Failed to coerce to String value");
- }
- return rval[0];
- }
-
- public static DispatchObject unwrapDispatchObject(int jsContext, int jsValue) {
- final DispatchObject[] rval = new DispatchObject[1];
- if (!unwrapDispatchObjectImpl(jsContext, jsValue, rval)) {
- throw new RuntimeException("Failed to unwrap DispatchObject.");
- }
- return rval[0];
- }
-
- public static int wrapDispatchMethod(int jsContext, String name,
- DispatchMethod dispatch) {
- synchronized (sObjectToJsval) {
- Integer cached = LowLevelSaf.sObjectToJsval.get(dispatch);
- if (cached != null) {
- /*
- * Add another lock to the cached jsval, since it will not have any.
- */
- LowLevelSaf.gcProtect(LowLevelSaf.getCurrentJsContext(), cached);
- return cached;
- } else {
- final int[] rval = new int[1];
- if (!wrapDispatchMethodImpl(jsContext, name, dispatch, rval)) {
- throw new RuntimeException("Failed to wrap DispatchMethod.");
- }
- LowLevelSaf.sObjectToJsval.put(dispatch, rval[0]);
- return rval[0];
- }
- }
- }
-
- public static int wrapDispatchObject(int jsContext, DispatchObject dispatcher) {
- synchronized (sObjectToJsval) {
-
- Integer cached = LowLevelSaf.sObjectToJsval.get(dispatcher);
- if (cached != null) {
- /*
- * Add another lock to the cached jsval, since it will not have any.
- */
- LowLevelSaf.gcProtect(LowLevelSaf.getCurrentJsContext(), cached);
- return cached;
- } else {
- final int[] rval = new int[1];
- if (!wrapDispatchObjectImpl(jsContext, dispatcher, rval)) {
- throw new RuntimeException("Failed to wrap DispatchObject.");
- }
- LowLevelSaf.sObjectToJsval.put(dispatcher, rval[0]);
- return rval[0];
- }
- }
- }
-
- static native boolean isGcProtected(int jsValue);
-
- /**
- * Enables checking of JSValueRef protect/unprotect calls to ensure calls are
- * properly matched. See ENABLE_JSVALUE_PROTECTION_CHECKING in trace.h to
- * enable this feature.
- *
- * @return whether JSValue protection checking is enabled
- */
- static boolean isJsValueProtectionCheckingEnabled() {
- return jsValueProtectionCheckingEnabled;
- }
-
- /**
- * Native code accessor to remove the mapping upon GC.
- */
- static void releaseObject(Object o) {
- synchronized (sObjectToJsval) {
- sObjectToJsval.remove(o);
- }
- }
-
- private static native boolean executeScriptWithInfoImpl(int jsContext,
- String script, String url, int line, int[] rval);
-
- private static native boolean getGlobalJsObjectImpl(int jsContext, int[] rval);
-
- private static native boolean initImpl(
- Class<DispatchObject> dispatchObjectClass,
- Class<DispatchMethod> dispatchMethodClass,
- Class<LowLevelSaf> lowLevelSafClass);
-
- private static native boolean invokeImpl(int jsContext, int jsScriptObject,
- String methodName, int thisObj, int[] args, int argsLength, int[] rval);
-
- private static native boolean isDispatchObjectImpl(int jsContext,
- int jsValue, boolean[] rval);
-
- private static native boolean isJsStringImpl(int jsContext, int jsValue,
- boolean[] rval);
-
- private static native boolean isJsValueProtectionCheckingEnabledImpl();
-
- private static native boolean toBooleanImpl(int jsContext, int jsValue,
- boolean[] rval);
-
- private static native boolean toDoubleImpl(int jsContext, int jsValue,
- double[] rval);
-
- private static native boolean toJsBooleanImpl(int jsContext, boolean value,
- int[] rval);
-
- private static native boolean toJsNumberImpl(int jsContext, double value,
- int[] rval);
-
- private static native boolean toJsStringImpl(int jsContext, String value,
- int[] rval);
-
- private static double toNumber(int jsContext, int jsValue, String typeName) {
- double[] rval = new double[1];
- if (!toDoubleImpl(jsContext, jsValue, rval)) {
- throw new RuntimeException("Failed to coerce to " + typeName + " value");
- }
- return rval[0];
- }
-
- private static native boolean toStringImpl(int jsContext, int jsValue,
- String[] rval);
-
- private static native boolean unwrapDispatchObjectImpl(int jsContext,
- int jsValue, DispatchObject[] rval);
-
- private static native boolean wrapDispatchMethodImpl(int jsContext,
- String name, DispatchMethod dispatch, int[] rval);
-
- private static native boolean wrapDispatchObjectImpl(int jsContext,
- DispatchObject obj, int[] rval);
-}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/MethodDispatch.java b/dev/mac/src/com/google/gwt/dev/shell/mac/MethodDispatch.java
deleted file mode 100644
index f8bf37e..0000000
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/MethodDispatch.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.mac;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.MethodAdaptor;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.shell.mac.LowLevelSaf.DispatchMethod;
-
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Wraps an arbitrary Java Method as a Dispatchable component. The class was
- * motivated by the need to expose Java objects into JavaScript.
- */
-class MethodDispatch implements DispatchMethod {
-
- private final CompilingClassLoader classLoader;
-
- private final MethodAdaptor method;
-
- public MethodDispatch(CompilingClassLoader classLoader, MethodAdaptor method) {
- this.classLoader = classLoader;
- this.method = method;
- }
-
- public int invoke(int jsContext, int jsthisInt, int[] jsargsInt,
- int[] exception) {
- LowLevelSaf.pushJsContext(jsContext);
- JsValue jsthis = new JsValueSaf(jsthisInt);
- JsValue jsargs[] = new JsValue[jsargsInt.length];
- for (int i = 0; i < jsargsInt.length; ++i) {
- jsargs[i] = new JsValueSaf(jsargsInt[i]);
- }
- JsValueSaf returnValue = new JsValueSaf();
- try {
- Class<?>[] paramTypes = method.getParameterTypes();
- int argc = paramTypes.length;
- Object args[] = new Object[argc];
- // too many arguments are ok: the extra will be silently ignored
- if (jsargs.length < argc) {
- throw new RuntimeException("Not enough arguments to " + method);
- }
- Object jthis = null;
- if (method.needsThis()) {
- jthis = JsValueGlue.get(jsthis, classLoader,
- method.getDeclaringClass(), "invoke this");
- }
- for (int i = 0; i < argc; ++i) {
- args[i] = JsValueGlue.get(jsargs[i], classLoader, paramTypes[i],
- "invoke args");
- }
- try {
- Object result;
- try {
- result = method.invoke(jthis, args);
- } catch (IllegalAccessException e) {
- // should never, ever happen
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- JsValueGlue.set(returnValue, classLoader, method.getReturnType(),
- result);
- int jsResult = returnValue.getJsValue();
- // Native code will eat an extra ref.
- LowLevelSaf.gcProtect(jsContext, jsResult);
- return jsResult;
- } catch (InstantiationException e) {
- // If we get here, it means an exception is being thrown from
- // Java back into JavaScript
- ModuleSpace.setThrownJavaException(e.getCause());
- // Native code eats the same ref it gave us.
- exception[0] = LowLevelSaf.getJsNull(jsContext);
- // Native code eats the same ref it gave us.
- return LowLevelSaf.getJsUndefined(jsContext);
- } catch (InvocationTargetException e) {
- // If we get here, it means an exception is being thrown from
- // Java back into JavaScript
- Throwable t = e.getTargetException();
- ModuleSpace.setThrownJavaException(t);
- // Native code eats the same ref it gave us.
- exception[0] = LowLevelSaf.getJsNull(jsContext);
- // Native code eats the same ref it gave us.
- return LowLevelSaf.getJsUndefined(jsContext);
- }
- } finally {
- LowLevelSaf.popJsContext(jsContext);
- }
- }
-}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
deleted file mode 100644
index 07d6408..0000000
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.mac;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.javac.JsniMethod;
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.DispatchIdOracle;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.Jsni;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.shell.ModuleSpaceHost;
-
-import java.util.List;
-
-/**
- * An implementation of {@link com.google.gwt.dev.shell.ModuleSpace} for Safari.
- */
-public class ModuleSpaceSaf extends ModuleSpace {
-
- private final int globalObject;
-
- private final int globalContext;
-
- /**
- * Constructs a browser interface for use with a global window object.
- *
- * @param moduleName name of the module
- * @param key unique key for this instance of the module
- */
- public ModuleSpaceSaf(TreeLogger logger, ModuleSpaceHost host,
- int scriptGlobalObject, int scriptGlobalContext, String moduleName,
- Object key) {
- super(logger, host, moduleName, key);
-
- // Hang on to the global execution state.
- //
- this.globalObject = scriptGlobalObject;
- this.globalContext = scriptGlobalContext;
- LowLevelSaf.gcProtect(LowLevelSaf.getCurrentJsContext(), scriptGlobalObject);
- LowLevelSaf.retainJsGlobalContext(scriptGlobalContext);
- }
-
- public void createNativeMethods(TreeLogger logger,
- List<JsniMethod> jsniMethods, DispatchIdOracle dispatchIdOracle) {
- for (JsniMethod jsniMethod : jsniMethods) {
- String body = Jsni.getJavaScriptForHostedMode(logger, dispatchIdOracle,
- jsniMethod);
- if (body == null) {
- // The error has been logged; just ignore it for now.
- continue;
- }
- createNative(jsniMethod.location(), jsniMethod.line(), jsniMethod.name(),
- jsniMethod.paramNames(), body);
- }
- }
-
- @Override
- public void dispose() {
- LowLevelSaf.gcUnprotect(LowLevelSaf.getCurrentJsContext(), globalObject);
- LowLevelSaf.releaseJsGlobalContext(globalContext);
- super.dispose();
- }
-
- @Override
- protected void createStaticDispatcher(TreeLogger logger) {
- createNative("initializeStaticDispatcher", 0, "__defineStatic",
- new String[] {"__arg0"}, "window.__static = __arg0;");
- }
-
- /**
- * Invokes a native JavaScript function.
- *
- * @param name the name of the function to invoke
- * @param jthis the function's 'this' context
- * @param types the type of each argument
- * @param args the arguments to be passed
- * @return the return value as a Object.
- */
- @Override
- protected JsValue doInvoke(String name, Object jthis, Class<?>[] types,
- Object[] args) {
- CompilingClassLoader isolatedClassLoader = getIsolatedClassLoader();
-
- JsValueSaf jsValueThis = new JsValueSaf();
- Class<?> jthisType = (jthis == null) ? Object.class : jthis.getClass();
- JsValueGlue.set(jsValueThis, isolatedClassLoader, jthisType, jthis);
- int jsthis = jsValueThis.getJsValue();
-
- int argc = args.length;
- int[] argv = new int[argc];
- // GC protect passed arguments on the Java stack for call duration.
- JsValueSaf[] jsValueArgs = new JsValueSaf[argc];
- for (int i = 0; i < argc; ++i) {
- JsValueSaf jsValue = jsValueArgs[i] = new JsValueSaf();
- JsValueGlue.set(jsValue, isolatedClassLoader, types[i], args[i]);
- argv[i] = jsValue.getJsValue();
- }
-
- final int curJsContext = LowLevelSaf.getCurrentJsContext();
-
- int result = LowLevelSaf.invoke(curJsContext, globalObject, name, jsthis,
- argv);
- return new JsValueSaf(result);
- }
-
- @Override
- protected Object getStaticDispatcher() {
- return new WebKitDispatchAdapter(getIsolatedClassLoader());
- }
-
- private void createNative(String file, int line, String jsniSignature,
- String[] paramNames, String js) {
- // Execute the function definition within the browser, which will define
- // a new top-level function.
- //
- String newScript = createNativeMethodInjector(jsniSignature, paramNames, js);
- LowLevelSaf.executeScriptWithInfo(globalContext, newScript, file, line);
- }
-}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/WebKitDispatchAdapter.java b/dev/mac/src/com/google/gwt/dev/shell/mac/WebKitDispatchAdapter.java
deleted file mode 100644
index 69a0240..0000000
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/WebKitDispatchAdapter.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.mac;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JavaDispatch;
-import com.google.gwt.dev.shell.JavaDispatchImpl;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.MethodAdaptor;
-import com.google.gwt.dev.shell.mac.LowLevelSaf.DispatchMethod;
-import com.google.gwt.dev.shell.mac.LowLevelSaf.DispatchObject;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-
-/**
- * Wraps an arbitrary Java Object as a Dispatch component. The class was
- * motivated by the need to expose Java objects into JavaScript.
- *
- * An instance of this class with no target is used to globally access all
- * static methods or fields.
- */
-class WebKitDispatchAdapter implements DispatchObject {
-
- private final CompilingClassLoader classLoader;
-
- private final JavaDispatch javaDispatch;
-
- /**
- * This constructor initializes as the static dispatcher, which handles only
- * static method calls and field references.
- *
- * @param cl this class's classLoader
- */
- WebKitDispatchAdapter(CompilingClassLoader cl) {
- javaDispatch = new JavaDispatchImpl(cl);
- this.classLoader = cl;
- }
-
- /**
- * This constructor initializes a dispatcher, around a particular instance.
- *
- * @param cl this class's classLoader
- * @param target the object being wrapped as an IDispatch
- */
- WebKitDispatchAdapter(CompilingClassLoader cl, Object target) {
- javaDispatch = new JavaDispatchImpl(cl, target);
- this.classLoader = cl;
- }
-
- public int getField(int jsContext, String name) {
- LowLevelSaf.pushJsContext(jsContext);
- try {
- int dispId = classLoader.getDispId(name);
- if (dispId < 0) {
- return LowLevelSaf.getJsUndefined(jsContext);
- }
- if (javaDispatch.isField(dispId)) {
- Field field = javaDispatch.getField(dispId);
- JsValueSaf jsValue = new JsValueSaf();
- JsValueGlue.set(jsValue, classLoader, field.getType(),
- javaDispatch.getFieldValue(dispId));
- int jsval = jsValue.getJsValue();
- // Native code will eat an extra ref.
- LowLevelSaf.gcProtect(jsContext, jsval);
- return jsval;
- } else {
- MethodAdaptor method = javaDispatch.getMethod(dispId);
- AccessibleObject obj = method.getUnderlyingObject();
- DispatchMethod dispMethod = (DispatchMethod) classLoader.getWrapperForObject(obj);
- if (dispMethod == null) {
- dispMethod = new MethodDispatch(classLoader, method);
- classLoader.putWrapperForObject(obj, dispMethod);
- }
- // Native code eats the same ref it gave us.
- return LowLevelSaf.wrapDispatchMethod(jsContext, method.toString(),
- dispMethod);
- }
- } finally {
- LowLevelSaf.popJsContext(jsContext);
- }
- }
-
- public Object getTarget() {
- return javaDispatch.getTarget();
- }
-
- public void setField(int jsContext, String name, int value) {
- LowLevelSaf.pushJsContext(jsContext);
- try {
- JsValue jsValue = new JsValueSaf(value);
- int dispId = classLoader.getDispId(name);
- if (dispId < 0) {
- // TODO (knorton): We could allow expandos, but should we?
- throw new RuntimeException("No such field " + name);
- }
- if (javaDispatch.isMethod(dispId)) {
- throw new RuntimeException("Cannot reassign method " + name);
- }
- Field field = javaDispatch.getField(dispId);
- Object val = JsValueGlue.get(jsValue, classLoader, field.getType(),
- "setField");
- javaDispatch.setFieldValue(dispId, val);
- } finally {
- LowLevelSaf.popJsContext(jsContext);
- }
- }
-
- @Override
- public String toString() {
- return getTarget().toString();
- }
-
-}
diff --git a/dev/mac/src/org/eclipse/COPYING.html b/dev/mac/src/org/eclipse/COPYING.html
deleted file mode 100644
index 5bfebd8..0000000
--- a/dev/mac/src/org/eclipse/COPYING.html
+++ /dev/null
@@ -1,256 +0,0 @@
-<html>
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<title>Eclipse Public License - Version 1.0</title>
-</head>
-
-<body>
-
-<div>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span>1. DEFINITIONS</span></b> </p>
-
-<p><span>"Contribution" means:</span> </p>
-
-<p><span>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p><span>i)
-changes to the Program, and</span></p>
-
-<p><span>ii)
-additions to the Program;</span></p>
-
-<p><span>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span>"Contributor" means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span>"Licensed Patents " mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span>"Program" means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span>"Recipient" means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span>2. GRANT OF RIGHTS</span></b> </p>
-
-<p><span>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p><span>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p><span>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p><span>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span>3. REQUIREMENTS</span></b> </p>
-
-<p><span>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p><span>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p><span>b)
-its license agreement:</span></p>
-
-<p><span>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p><span>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p><span>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p><span>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span>When the Program is made available in source
-code form:</span> </p>
-
-<p><span>a)
-it must be made available under this Agreement; and </span></p>
-
-<p><span>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor ("Commercial
-Contributor") hereby agrees to defend and indemnify every other
-Contributor ("Indemnified Contributor") against any losses, damages and
-costs (collectively "Losses") arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span>5. NO WARRANTY</span></b> </p>
-
-<p><span>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span>7. GENERAL</span></b> </p>
-
-<p><span>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/dev/mac/src/org/eclipse/swt/browser/Browser.java b/dev/mac/src/org/eclipse/swt/browser/Browser.java
deleted file mode 100644
index 21ca0e3..0000000
--- a/dev/mac/src/org/eclipse/swt/browser/Browser.java
+++ /dev/null
@@ -1,1951 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.browser;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.Callback;
-import org.eclipse.swt.internal.carbon.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class implement the browser user interface
- * metaphor. It allows the user to visualize and navigate through
- * HTML documents.
- * <p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @since 3.0
- */
-public class Browser extends Composite {
-
- /* Package Name */
- static final String PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
- static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; //$NON-NLS-1$
- // GOOGLE: patched in from https://bugs.eclipse.org/bugs/show_bug.cgi?id=161259
- static final String CLEAR_GRAB_BIT = "org.eclipse.swt.internal.carbon.clearGrabBit"; //$NON-NLS-1$
- static final String BROWSER_WINDOW = "org.eclipse.swt.browser.Browser.Window"; //$NON-NLS-1$
- static final int MAX_PROGRESS = 100;
-
- /* External Listener management */
- CloseWindowListener[] closeWindowListeners = new CloseWindowListener[0];
- LocationListener[] locationListeners = new LocationListener[0];
- OpenWindowListener[] openWindowListeners = new OpenWindowListener[0];
- ProgressListener[] progressListeners = new ProgressListener[0];
- StatusTextListener[] statusTextListeners = new StatusTextListener[0];
- TitleListener[] titleListeners = new TitleListener[0];
- VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0];
-
- static Callback Callback3, Callback7;
-
- /* Objective-C WebView delegate */
- int delegate;
-
- /* Carbon HIView handle */
- int webViewHandle;
-
- boolean changingLocation;
- String html;
- int identifier;
- int resourceCount;
- String url = "";
- Point location;
- Point size;
- boolean statusBar = true, toolBar = true, ignoreDispose;
- //TEMPORARY CODE
-// boolean doit;
-
- static final int MIN_SIZE = 16;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li>
- * </ul>
- *
- * @see Widget#getStyle
- *
- * @since 3.0
- */
-public Browser(Composite parent, int style) {
- super(parent, style);
-
- /*
- * Note. Loading the webkit bundle on Jaguar causes a crash.
- * The workaround is to detect any OS prior to 10.30 and fail
- * without crashing.
- */
- if (OS.VERSION < 0x1030) {
- dispose();
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
- int outControl[] = new int[1];
- try {
- WebKit.HIWebViewCreate(outControl);
- } catch (UnsatisfiedLinkError e) {
- dispose();
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
- webViewHandle = outControl[0];
- if (webViewHandle == 0) {
- dispose();
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
- Display display = getDisplay();
- display.setData(ADD_WIDGET_KEY, new Object[] {new Integer(webViewHandle), this});
- // GOOGLE: patched in from https://bugs.eclipse.org/bugs/show_bug.cgi?id=161259
- setData(CLEAR_GRAB_BIT, null);
-
- /*
- * Bug in Safari. For some reason, every application must contain
- * a visible window that has never had a WebView or mouse move events
- * are not delivered. This seems to happen after a browser has been
- * either hidden or disposed in any window. The fix is to create a
- * single transparent overlay window that is disposed when the display
- * is disposed.
- */
- if (display.getData(BROWSER_WINDOW) == null) {
- Rect bounds = new Rect ();
- OS.SetRect (bounds, (short) 0, (short) 0, (short) 1, (short) 1);
- final int[] outWindow = new int[1];
- OS.CreateNewWindow(OS.kOverlayWindowClass, 0, bounds, outWindow);
- OS.ShowWindow(outWindow[0]);
- display.disposeExec(new Runnable() {
- public void run() {
- if (outWindow[0] != 0) {
- OS.DisposeWindow(outWindow[0]);
- }
- outWindow[0] = 0;
- }
- });
- display.setData(BROWSER_WINDOW, outWindow);
- }
-
- /*
- * Bug in Safari. The WebView does not receive mouse and key events when it is added
- * to a visible top window. It is assumed that Safari hooks its own event listener
- * when the top window emits the kEventWindowShown event. The workaround is to send a
- * fake kEventWindowShown event to the top window after the WebView has been added
- * to the HIView (after the top window is visible) to give Safari a chance to hook
- * events.
- */
- int window = OS.GetControlOwner(handle);
- if (OS.HIVIEW) {
- int[] contentView = new int[1];
- OS.HIViewFindByID(OS.HIViewGetRoot(window), OS.kHIViewWindowContentID(), contentView);
- OS.HIViewAddSubview(contentView[0], webViewHandle);
- OS.HIViewChangeFeatures(webViewHandle, OS.kHIViewFeatureIsOpaque, 0);
- } else {
- OS.HIViewAddSubview(handle, webViewHandle);
- }
- OS.HIViewSetVisible(webViewHandle, true);
- if (getShell().isVisible()) {
- int[] showEvent = new int[1];
- OS.CreateEvent(0, OS.kEventClassWindow, OS.kEventWindowShown, 0.0, OS.kEventAttributeUserEvent, showEvent);
- OS.SetEventParameter(showEvent[0], OS.kEventParamDirectObject, OS.typeWindowRef, 4, new int[] {OS.GetControlOwner(handle)});
- OS.SendEventToEventTarget(showEvent[0], OS.GetWindowEventTarget(window));
- if (showEvent[0] != 0) OS.ReleaseEvent(showEvent[0]);
- }
-
- final int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- /*
- * This code is intentionally commented. Setting a group name is the right thing
- * to do in order to avoid multiple open window requests. For some reason, Safari
- * crashes when requested to reopen the same window if that window was previously
- * closed. This may be because that window was not correctly closed.
- */
-// String groupName = "MyDocument"; //$NON-NLS-1$
-// int length = groupName.length();
-// char[] buffer = new char[length];
-// groupName.getChars(0, length, buffer, 0);
-// int groupNameString = OS.CFStringCreateWithCharacters(0, buffer, length);
-// // [webView setGroupName:@"MyDocument"];
-// WebKit.objc_msgSend(webView, WebKit.S_setGroupName, groupNameString);
-// OS.CFRelease(groupNameString);
-
- final int notificationCenter = WebKit.objc_msgSend(WebKit.C_NSNotificationCenter, WebKit.S_defaultCenter);
-
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Dispose: {
- /* make this handler run after other dispose listeners */
- if (ignoreDispose) {
- ignoreDispose = false;
- break;
- }
- ignoreDispose = true;
- notifyListeners (e.type, e);
- e.type = SWT.NONE;
-
- Shell shell = getShell();
- shell.removeListener(SWT.Resize, this);
- shell.removeListener(SWT.Show, this);
- shell.removeListener(SWT.Hide, this);
- Control c = Browser.this;
- do {
- c.removeListener(SWT.Show, this);
- c.removeListener(SWT.Hide, this);
- c = c.getParent();
- } while (c != shell);
-
- e.display.setData(ADD_WIDGET_KEY, new Object[] {new Integer(webViewHandle), null});
-
- WebKit.objc_msgSend(webView, WebKit.S_setFrameLoadDelegate, 0);
- WebKit.objc_msgSend(webView, WebKit.S_setResourceLoadDelegate, 0);
- WebKit.objc_msgSend(webView, WebKit.S_setUIDelegate, 0);
- WebKit.objc_msgSend(webView, WebKit.S_setPolicyDelegate, 0);
- WebKit.objc_msgSend(notificationCenter, WebKit.S_removeObserver, delegate);
-
- WebKit.objc_msgSend(delegate, WebKit.S_release);
- if (OS.HIVIEW) OS.DisposeControl(webViewHandle);
- html = null;
- break;
- }
- case SWT.Hide: {
- /*
- * Bug on Safari. The web view cannot be obscured by other views above it.
- * This problem is specified in the apple documentation for HiWebViewCreate.
- * The workaround is to hook Hide and Show events on the browser's parents
- * and set its size to 0 in Hide and to restore its size in Show.
- */
- CGRect bounds = new CGRect();
- bounds.x = bounds.y = -MIN_SIZE;
- bounds.width = bounds.height = MIN_SIZE;
- OS.HIViewSetFrame(webViewHandle, bounds);
- break;
- }
- case SWT.Show: {
- /*
- * Do not update size when it is not visible. Note that isVisible()
- * cannot be used because SWT.Show is sent before the widget is
- * actually visible.
- */
- Shell shell = getShell();
- Composite parent = Browser.this;
- while (parent != shell && (parent.getVisible() || parent == e.widget)) {
- parent = parent.getParent();
- }
- if (!(parent.getVisible() || parent == e.widget)) return;
-
- /*
- * Bug on Safari. The web view cannot be obscured by other views above it.
- * This problem is specified in the apple documentation for HiWebViewCreate.
- * The workaround is to hook Hide and Show events on the browser's parents
- * and set its size to 0 in Hide and to restore its size in Show.
- */
- CGRect bounds = new CGRect();
- if (OS.HIVIEW) {
- OS.HIViewGetBounds(handle, bounds);
- int[] contentView = new int[1];
- OS.HIViewFindByID(OS.HIViewGetRoot(OS.GetControlOwner(handle)), OS.kHIViewWindowContentID(), contentView);
- OS.HIViewConvertRect(bounds, handle, contentView[0]);
- } else {
- OS.HIViewGetFrame(handle, bounds);
- }
- /*
- * Bug in Safari. For some reason, the web view will display incorrectly or
- * blank depending on its contents, if its size is set to a value smaller than
- * MIN_SIZE. It will not display properly even after the size is made larger.
- * The fix is to avoid setting sizes smaller than MIN_SIZE.
- */
- if (bounds.width <= MIN_SIZE) bounds.width = MIN_SIZE;
- if (bounds.height <= MIN_SIZE) bounds.height = MIN_SIZE;
- OS.HIViewSetFrame(webViewHandle, bounds);
- break;
- }
- case SWT.Resize: {
- /* Do not update size when it is not visible */
- if (!isVisible()) return;
- /*
- * Bug on Safari. Resizing the height of a Shell containing a Browser at
- * a fixed location causes the Browser to redraw at a wrong location.
- * The web view is a HIView container that internally hosts
- * a Cocoa NSView that uses a coordinates system with the origin at the
- * bottom left corner of a window instead of the coordinates system used
- * in Carbon that starts at the top left corner. The workaround is to
- * reposition the web view every time the Shell of the Browser is resized.
- */
- CGRect bounds = new CGRect();
- if (OS.HIVIEW) {
- OS.HIViewGetBounds(handle, bounds);
- int[] contentView = new int[1];
- OS.HIViewFindByID(OS.HIViewGetRoot(OS.GetControlOwner(handle)), OS.kHIViewWindowContentID(), contentView);
- OS.HIViewConvertRect(bounds, handle, contentView[0]);
- } else {
- OS.HIViewGetFrame(handle, bounds);
- }
- /*
- * Bug in Safari. For some reason, the web view will display incorrectly or
- * blank depending on its contents, if its size is set to a value smaller than
- * MIN_SIZE. It will not display properly even after the size is made larger.
- * The fix is to avoid setting sizes smaller than MIN_SIZE.
- */
- if (bounds.width <= MIN_SIZE) bounds.width = MIN_SIZE;
- if (bounds.height <= MIN_SIZE) bounds.height = MIN_SIZE;
- if (e.widget == getShell()) {
- bounds.x++;
- /* Note that the bounds needs to change */
- OS.HIViewSetFrame(webViewHandle, bounds);
- bounds.x--;
- }
- OS.HIViewSetFrame(webViewHandle, bounds);
- break;
- }
- }
- }
- };
- addListener(SWT.Dispose, listener);
- addListener(SWT.Resize, listener);
- Shell shell = getShell();
- shell.addListener(SWT.Resize, listener);
- shell.addListener(SWT.Show, listener);
- shell.addListener(SWT.Hide, listener);
- Control c = this;
- do {
- c.addListener(SWT.Show, listener);
- c.addListener(SWT.Hide, listener);
- c = c.getParent();
- } while (c != shell);
-
- if (Callback3 == null) Callback3 = new Callback(this.getClass(), "eventProc3", 3); //$NON-NLS-1$
- int callback3Address = Callback3.getAddress();
- if (callback3Address == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
-
- int[] mask = new int[] {
- OS.kEventClassKeyboard, OS.kEventRawKeyDown,
- OS.kEventClassControl, OS.kEventControlDraw,
- OS.kEventClassTextInput, OS.kEventTextInputUnicodeForKeyEvent,
- };
- int controlTarget = OS.GetControlEventTarget(webViewHandle);
- OS.InstallEventHandler(controlTarget, callback3Address, mask.length / 2, mask, webViewHandle, null);
-
- if (Callback7 == null) Callback7 = new Callback(this.getClass(), "eventProc7", 7); //$NON-NLS-1$
- int callback7Address = Callback7.getAddress();
- if (callback7Address == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
-
- // delegate = [[WebResourceLoadDelegate alloc] init eventProc];
- delegate = WebKit.objc_msgSend(WebKit.C_WebKitDelegate, WebKit.S_alloc);
- delegate = WebKit.objc_msgSend(delegate, WebKit.S_initWithProc, callback7Address, webViewHandle);
-
- // [webView setFrameLoadDelegate:delegate];
- WebKit.objc_msgSend(webView, WebKit.S_setFrameLoadDelegate, delegate);
-
- // [webView setResourceLoadDelegate:delegate];
- WebKit.objc_msgSend(webView, WebKit.S_setResourceLoadDelegate, delegate);
-
- // [webView setUIDelegate:delegate];
- WebKit.objc_msgSend(webView, WebKit.S_setUIDelegate, delegate);
-
- /* register delegate for all notifications sent out from webview */
- WebKit.objc_msgSend(notificationCenter, WebKit.S_addObserver_selector_name_object, delegate, WebKit.S_handleNotification, 0, webView);
-
- // [webView setPolicyDelegate:delegate];
- WebKit.objc_msgSend(webView, WebKit.S_setPolicyDelegate, delegate);
-
- // [webView setDownloadDelegate:delegate];
- WebKit.objc_msgSend(webView, WebKit.S_setDownloadDelegate, delegate);
-}
-
-/**
- * Clears all session cookies from all current Browser instances.
- *
- * @since 3.2
- */
-public static void clearSessions () {
- int storage = WebKit.objc_msgSend (WebKit.C_NSHTTPCookieStorage, WebKit.S_sharedHTTPCookieStorage);
- int cookies = WebKit.objc_msgSend (storage, WebKit.S_cookies);
- int count = WebKit.objc_msgSend (cookies, WebKit.S_count);
- for (int i = 0; i < count; i++) {
- int cookie = WebKit.objc_msgSend (cookies, WebKit.S_objectAtIndex, i);
- boolean isSession = WebKit.objc_msgSend (cookie, WebKit.S_isSessionOnly) != 0;
- if (isSession) {
- WebKit.objc_msgSend (storage, WebKit.S_deleteCookie, cookie);
- }
- }
-}
-
-static int eventProc3(int nextHandler, int theEvent, int userData) {
- Widget widget = Display.getCurrent().findWidget(userData);
- if (widget instanceof Browser)
- return ((Browser)widget).handleCallback(nextHandler, theEvent);
- return OS.eventNotHandledErr;
-}
-
-static int eventProc7(int webview, int userData, int selector, int arg0, int arg1, int arg2, int arg3) {
- Widget widget = Display.getCurrent().findWidget(userData);
- if (widget instanceof Browser)
- return ((Browser)widget).handleCallback(selector, arg0, arg1, arg2, arg3);
- return 0;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the window hosting the receiver should be closed.
- * <p>
- * This notification occurs when a javascript command such as
- * <code>window.close</code> gets executed by a <code>Browser</code>.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addCloseWindowListener(CloseWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length + 1];
- System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, closeWindowListeners.length);
- closeWindowListeners = newCloseWindowListeners;
- closeWindowListeners[closeWindowListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the current location has changed or is about to change.
- * <p>
- * This notification typically occurs when the application navigates
- * to a new location with {@link #setUrl(String)} or when the user
- * activates a hyperlink.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addLocationListener(LocationListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- LocationListener[] newLocationListeners = new LocationListener[locationListeners.length + 1];
- System.arraycopy(locationListeners, 0, newLocationListeners, 0, locationListeners.length);
- locationListeners = newLocationListeners;
- locationListeners[locationListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when a new window needs to be created.
- * <p>
- * This notification occurs when a javascript command such as
- * <code>window.open</code> gets executed by a <code>Browser</code>.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addOpenWindowListener(OpenWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length + 1];
- System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, openWindowListeners.length);
- openWindowListeners = newOpenWindowListeners;
- openWindowListeners[openWindowListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when a progress is made during the loading of the current
- * URL or when the loading of the current URL has been completed.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addProgressListener(ProgressListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length + 1];
- System.arraycopy(progressListeners, 0, newProgressListeners, 0, progressListeners.length);
- progressListeners = newProgressListeners;
- progressListeners[progressListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the status text is changed.
- * <p>
- * The status text is typically displayed in the status bar of
- * a browser application.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addStatusTextListener(StatusTextListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length + 1];
- System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, statusTextListeners.length);
- statusTextListeners = newStatusTextListeners;
- statusTextListeners[statusTextListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the title of the current document is available
- * or has changed.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addTitleListener(TitleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- TitleListener[] newTitleListeners = new TitleListener[titleListeners.length + 1];
- System.arraycopy(titleListeners, 0, newTitleListeners, 0, titleListeners.length);
- titleListeners = newTitleListeners;
- titleListeners[titleListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when a window hosting the receiver needs to be displayed
- * or hidden.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addVisibilityWindowListener(VisibilityWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length + 1];
- System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, visibilityWindowListeners.length);
- visibilityWindowListeners = newVisibilityWindowListeners;
- visibilityWindowListeners[visibilityWindowListeners.length - 1] = listener;
-}
-
-/**
- * Navigate to the previous session history item.
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #forward
- *
- * @since 3.0
- */
-public boolean back() {
- checkWidget();
- html = null;
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- return WebKit.objc_msgSend(webView, WebKit.S_goBack) != 0;
-}
-
-protected void checkSubclass () {
- String name = getClass().getName();
- int index = name.lastIndexOf('.');
- if (!name.substring(0, index + 1).equals(PACKAGE_PREFIX)) {
- SWT.error(SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-
-/**
- * Execute the specified script.
- *
- * <p>
- * Execute a script containing javascript commands in the context of the current document.
- *
- * @param script the script with javascript commands
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the script is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public boolean execute(String script) {
- checkWidget();
- if (script == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- int length = script.length();
- char[] buffer = new char[length];
- script.getChars(0, length, buffer, 0);
- int string = OS.CFStringCreateWithCharacters(0, buffer, length);
-
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- int value = WebKit.objc_msgSend(webView, WebKit.S_stringByEvaluatingJavaScriptFromString, string);
- OS.CFRelease(string);
- return value != 0;
-}
-
-/**
- * Navigate to the next session history item.
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #back
- *
- * @since 3.0
- */
-public boolean forward() {
- checkWidget();
- html = null;
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- return WebKit.objc_msgSend(webView, WebKit.S_goForward) != 0;
-}
-
-/**
- * Returns the current URL.
- *
- * @return the current URL or an empty <code>String</code> if there is no current URL
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #setUrl
- *
- * @since 3.0
- */
-public String getUrl() {
- checkWidget();
- return url;
-}
-
-int handleCallback(int nextHandler, int theEvent) {
- int eventKind = OS.GetEventKind(theEvent);
- switch (eventKind) {
- case OS.kEventControlDraw: {
- /*
- * Bug on Safari. The web view cannot be obscured by other views above it.
- * This problem is specified in the apple documentation for HiWebViewCreate.
- * The workaround is to don't draw the web view when it is not visible.
- */
- if (!isVisible ()) return OS.noErr;
-
- /*
- * GOOGLE: HACK - SWT does not properly push repaint events back to
- * WebKit, so we actually naively tell webkit to repaint it's entire
- * client area.
- */
- setNeedsDisplay(true);
-
- break;
- }
- case OS.kEventRawKeyDown: {
- /*
- * Bug in Safari. The WebView blocks the propagation of certain Carbon events
- * such as kEventRawKeyDown. On the Mac, Carbon events propagate from the
- * Focus Target Handler to the Control Target Handler, Window Target and finally
- * the Application Target Handler. It is assumed that WebView hooks its events
- * on the Window Target and does not pass kEventRawKeyDown to the next handler.
- * Since kEventRawKeyDown events never make it to the Application Target Handler,
- * the Application Target Handler never gets to emit kEventTextInputUnicodeForKeyEvent
- * used by SWT to send a SWT.KeyDown event.
- * The workaround is to hook kEventRawKeyDown on the Control Target Handler which gets
- * called before the WebView hook on the Window Target Handler. Then, forward this event
- * directly to the Application Target Handler. Note that if in certain conditions Safari
- * does not block the kEventRawKeyDown, then multiple kEventTextInputUnicodeForKeyEvent
- * events might be generated as a result of this workaround.
- */
- //TEMPORARY CODE
-// doit = false;
-// OS.SendEventToEventTarget(theEvent, OS.GetApplicationEventTarget());
-// if (!doit) return OS.noErr;
- break;
- }
- case OS.kEventTextInputUnicodeForKeyEvent: {
- /*
- * Note. This event is received from the Window Target therefore after it was received
- * by the Focus Target. The SWT.KeyDown event is sent by SWT on the Focus Target. If it
- * is received here, then the SWT.KeyDown doit flag must have been left to the value
- * true. For package visibility reasons we cannot access the doit flag directly.
- *
- * Sequence of events when the user presses a key down
- *
- * .Control Target - kEventRawKeyDown
- * .forward to ApplicationEventTarget
- * .Focus Target kEventTextInputUnicodeForKeyEvent - SWT emits SWT.KeyDown -
- * blocks further propagation if doit false. Browser does not know directly about
- * the doit flag value.
- * .Window Target kEventTextInputUnicodeForKeyEvent - if received, Browser knows
- * SWT.KeyDown is not blocked and event should be sent to WebKit
- * Return from Control Target - kEventRawKeyDown: let the event go to WebKit if doit true
- * (eventNotHandledErr) or stop it (noErr).
- */
- //TEMPORARY CODE
-// doit = true;
- break;
- }
- }
- return OS.eventNotHandledErr;
-}
-
-/* Here we dispatch all WebView upcalls. */
-int handleCallback(int selector, int arg0, int arg1, int arg2, int arg3) {
- int ret = 0;
- // for meaning of selector see WebKitDelegate methods in webkit.c
- switch (selector) {
- case 1: didFailProvisionalLoadWithError(arg0, arg1); break;
- case 2: didFinishLoadForFrame(arg0); break;
- case 3: didReceiveTitle(arg0, arg1); break;
- case 4: didStartProvisionalLoadForFrame(arg0); break;
- case 5: didFinishLoadingFromDataSource(arg0, arg1); break;
- case 6: didFailLoadingWithError(arg0, arg1, arg2); break;
- case 7: ret = identifierForInitialRequest(arg0, arg1); break;
- case 8: ret = willSendRequest(arg0, arg1, arg2, arg3); break;
- case 9: handleNotification(arg0); break;
- case 10: didCommitLoadForFrame(arg0); break;
- case 11: ret = createWebViewWithRequest(arg0); break;
- case 12: webViewShow(arg0); break;
- case 13: setFrame(arg0); break;
- case 14: webViewClose(); break;
- case 15: ret = contextMenuItemsForElement(arg0, arg1); break;
- case 16: setStatusBarVisible(arg0); break;
- case 17: setResizable(arg0); break;
- case 18: setToolbarsVisible(arg0); break;
- case 19: decidePolicyForMIMEType(arg0, arg1, arg2, arg3); break;
- case 20: decidePolicyForNavigationAction(arg0, arg1, arg2, arg3); break;
- case 21: decidePolicyForNewWindowAction(arg0, arg1, arg2, arg3); break;
- case 22: unableToImplementPolicyWithError(arg0, arg1); break;
- case 23: setStatusText(arg0); break;
- case 24: webViewFocus(); break;
- case 25: webViewUnfocus(); break;
- case 26: runJavaScriptAlertPanelWithMessage(arg0); break;
- case 27: ret = runJavaScriptConfirmPanelWithMessage(arg0); break;
- case 28: runOpenPanelForFileButtonWithResultListener(arg0); break;
- case 29: decideDestinationWithSuggestedFilename(arg0, arg1); break;
- // GOOGLE
- case 99: fireWindowScriptObjectListeners(arg0); break;
- }
- return ret;
-}
-
-/**
- * Returns <code>true</code> if the receiver can navigate to the
- * previous session history item, and <code>false</code> otherwise.
- *
- * @return the receiver's back command enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #back
- */
-public boolean isBackEnabled() {
- checkWidget();
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- return WebKit.objc_msgSend(webView, WebKit.S_canGoBack) != 0;
-}
-
-/**
- * Returns <code>true</code> if the receiver can navigate to the
- * next session history item, and <code>false</code> otherwise.
- *
- * @return the receiver's forward command enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #forward
- */
-public boolean isForwardEnabled() {
- checkWidget();
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- return WebKit.objc_msgSend(webView, WebKit.S_canGoForward) != 0;
-}
-
-/**
- * Refresh the current page.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void refresh() {
- checkWidget();
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- WebKit.objc_msgSend(webView, WebKit.S_reload, 0);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the window hosting the receiver should be closed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeCloseWindowListener(CloseWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (closeWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < closeWindowListeners.length; i++) {
- if (listener == closeWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (closeWindowListeners.length == 1) {
- closeWindowListeners = new CloseWindowListener[0];
- return;
- }
- CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length - 1];
- System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, index);
- System.arraycopy(closeWindowListeners, index + 1, newCloseWindowListeners, index, closeWindowListeners.length - index - 1);
- closeWindowListeners = newCloseWindowListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the current location is changed or about to be changed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeLocationListener(LocationListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (locationListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < locationListeners.length; i++) {
- if (listener == locationListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (locationListeners.length == 1) {
- locationListeners = new LocationListener[0];
- return;
- }
- LocationListener[] newLocationListeners = new LocationListener[locationListeners.length - 1];
- System.arraycopy(locationListeners, 0, newLocationListeners, 0, index);
- System.arraycopy(locationListeners, index + 1, newLocationListeners, index, locationListeners.length - index - 1);
- locationListeners = newLocationListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a new window needs to be created.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeOpenWindowListener(OpenWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (openWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < openWindowListeners.length; i++) {
- if (listener == openWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (openWindowListeners.length == 1) {
- openWindowListeners = new OpenWindowListener[0];
- return;
- }
- OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length - 1];
- System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, index);
- System.arraycopy(openWindowListeners, index + 1, newOpenWindowListeners, index, openWindowListeners.length - index - 1);
- openWindowListeners = newOpenWindowListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a progress is made during the loading of the current
- * URL or when the loading of the current URL has been completed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeProgressListener(ProgressListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (progressListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < progressListeners.length; i++) {
- if (listener == progressListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (progressListeners.length == 1) {
- progressListeners = new ProgressListener[0];
- return;
- }
- ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length - 1];
- System.arraycopy(progressListeners, 0, newProgressListeners, 0, index);
- System.arraycopy(progressListeners, index + 1, newProgressListeners, index, progressListeners.length - index - 1);
- progressListeners = newProgressListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the status text is changed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeStatusTextListener(StatusTextListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (statusTextListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < statusTextListeners.length; i++) {
- if (listener == statusTextListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (statusTextListeners.length == 1) {
- statusTextListeners = new StatusTextListener[0];
- return;
- }
- StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length - 1];
- System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, index);
- System.arraycopy(statusTextListeners, index + 1, newStatusTextListeners, index, statusTextListeners.length - index - 1);
- statusTextListeners = newStatusTextListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the title of the current document is available
- * or has changed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeTitleListener(TitleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (titleListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < titleListeners.length; i++) {
- if (listener == titleListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (titleListeners.length == 1) {
- titleListeners = new TitleListener[0];
- return;
- }
- TitleListener[] newTitleListeners = new TitleListener[titleListeners.length - 1];
- System.arraycopy(titleListeners, 0, newTitleListeners, 0, index);
- System.arraycopy(titleListeners, index + 1, newTitleListeners, index, titleListeners.length - index - 1);
- titleListeners = newTitleListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a window hosting the receiver needs to be displayed
- * or hidden.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeVisibilityWindowListener(VisibilityWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (visibilityWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < visibilityWindowListeners.length; i++) {
- if (listener == visibilityWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (visibilityWindowListeners.length == 1) {
- visibilityWindowListeners = new VisibilityWindowListener[0];
- return;
- }
- VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length - 1];
- System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, index);
- System.arraycopy(visibilityWindowListeners, index + 1, newVisibilityWindowListeners, index, visibilityWindowListeners.length - index - 1);
- visibilityWindowListeners = newVisibilityWindowListeners;
-}
-
-/**
- * Renders HTML.
- *
- * <p>
- * The html parameter is Unicode encoded since it is a java <code>String</code>.
- * As a result, the HTML meta tag charset should not be set. The charset is implied
- * by the <code>String</code> itself.
- *
- * @param html the HTML content to be rendered
- *
- * @return true if the operation was successful and false otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the html is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #setUrl
- *
- * @since 3.0
- */
-public boolean setText(String html) {
- checkWidget();
- if (html == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- /*
- * Bug in Safari. The web view segment faults in some circunstances
- * when the text changes during the location changing callback. The
- * fix is to defer the work until the callback is done.
- */
- if (changingLocation) {
- this.html = html;
- } else {
- _setText(html);
- }
- return true;
-}
-
-void _setText(String html) {
- int length = html.length();
- char[] buffer = new char[length];
- html.getChars(0, length, buffer, 0);
- int string = OS.CFStringCreateWithCharacters(0, buffer, length);
-
- String baseURL = "about:blank"; //$NON-NLS-1$
- length = baseURL.length();
- buffer = new char[length];
- baseURL.getChars(0, length, buffer, 0);
- int URLString = OS.CFStringCreateWithCharacters(0, buffer, length);
-
- /*
- * Note. URLWithString uses autorelease. The resulting URL
- * does not need to be released.
- * URL = [NSURL URLWithString:(NSString *)URLString]
- */
- int URL = WebKit.objc_msgSend(WebKit.C_NSURL, WebKit.S_URLWithString, URLString);
- OS.CFRelease(URLString);
-
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
-
- //mainFrame = [webView mainFrame];
- int mainFrame = WebKit.objc_msgSend(webView, WebKit.S_mainFrame);
-
- //[mainFrame loadHTMLString:(NSString *) string baseURL:(NSURL *)URL];
- WebKit.objc_msgSend(mainFrame, WebKit.S_loadHTMLStringbaseURL, string, URL);
- OS.CFRelease(string);
-}
-
-/**
- * Loads a URL.
- *
- * @param url the URL to be loaded
- *
- * @return true if the operation was successful and false otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the url is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #getUrl
- *
- * @since 3.0
- */
-public boolean setUrl(String url) {
- checkWidget();
- if (url == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- html = null;
-
- StringBuffer buffer = new StringBuffer();
- if (url.indexOf('/') == 0) buffer.append("file://"); //$NON-NLS-1$ //$NON-NLS-2$
- else if (url.indexOf(':') == -1) buffer.append("http://"); //$NON-NLS-1$
- for (int i = 0; i < url.length(); i++) {
- char c = url.charAt(i);
- if (c == ' ') buffer.append("%20"); //$NON-NLS-1$ //$NON-NLS-2$
- else buffer.append(c);
- }
-
- int length = buffer.length();
- char[] chars = new char[length];
- buffer.getChars(0, length, chars, 0);
- int sHandle = OS.CFStringCreateWithCharacters(0, chars, length);
-
- /*
- * Note. URLWithString uses autorelease. The resulting URL
- * does not need to be released.
- * inURL = [NSURL URLWithString:(NSString *)sHandle]
- */
- int inURL= WebKit.objc_msgSend(WebKit.C_NSURL, WebKit.S_URLWithString, sHandle);
- OS.CFRelease(sHandle);
-
- //request = [NSURLRequest requestWithURL:(NSURL*)inURL];
- int request= WebKit.objc_msgSend(WebKit.C_NSURLRequest, WebKit.S_requestWithURL, inURL);
-
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
-
- //mainFrame = [webView mainFrame];
- int mainFrame= WebKit.objc_msgSend(webView, WebKit.S_mainFrame);
-
- //[mainFrame loadRequest:request];
- WebKit.objc_msgSend(mainFrame, WebKit.S_loadRequest, request);
-
- return true;
-}
-
-/**
- * Stop any loading and rendering activity.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void stop() {
- checkWidget();
- html = null;
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- WebKit.objc_msgSend(webView, WebKit.S_stopLoading, 0);
-}
-
-/* WebFrameLoadDelegate */
-
-void didFailProvisionalLoadWithError(int error, int frame) {
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- if (frame == WebKit.objc_msgSend(webView, WebKit.S_mainFrame)) {
- /*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. Howeever, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- identifier = 0;
- }
-}
-
-void didFinishLoadForFrame(int frame) {
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- if (frame == WebKit.objc_msgSend(webView, WebKit.S_mainFrame)) {
- final Display display= getDisplay();
- final ProgressEvent progress = new ProgressEvent(this);
- progress.display = getDisplay();
- progress.widget = this;
- progress.current = MAX_PROGRESS;
- progress.total = MAX_PROGRESS;
- for (int i = 0; i < progressListeners.length; i++) {
- final ProgressListener listener = progressListeners[i];
- /*
- * Note on WebKit. Running the event loop from a Browser
- * delegate callback breaks the WebKit (stop loading or
- * crash). The widget ProgressBar currently touches the
- * event loop every time the method setSelection is called.
- * The workaround is to invoke Display.asyncexec so that
- * the Browser does not crash when the user updates the
- * selection of the ProgressBar.
- */
- display.asyncExec(
- new Runnable() {
- public void run() {
- if (!display.isDisposed() && !isDisposed())
- listener.completed(progress);
- }
- }
- );
- }
- /*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. Howeever, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- identifier = 0;
- }
-}
-
-void didReceiveTitle(int title, int frame) {
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- if (frame == WebKit.objc_msgSend(webView, WebKit.S_mainFrame)) {
- int length = OS.CFStringGetLength(title);
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(title, range, buffer);
- String newTitle = new String(buffer);
- TitleEvent newEvent = new TitleEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = this;
- newEvent.title = newTitle;
- for (int i = 0; i < titleListeners.length; i++)
- titleListeners[i].changed(newEvent);
- }
-}
-
-void didStartProvisionalLoadForFrame(int frame) {
- /*
- * This code is intentionally commented. WebFrameLoadDelegate:didStartProvisionalLoadForFrame is
- * called before WebResourceLoadDelegate:willSendRequest and
- * WebFrameLoadDelegate:didCommitLoadForFrame. The resource count is reset when didCommitLoadForFrame
- * is received for the top frame.
- */
-// int webView = WebKit.HIWebViewGetWebView(webViewHandle);
-// if (frame == WebKit.objc_msgSend(webView, WebKit.S_mainFrame)) {
-// /* reset resource status variables */
-// resourceCount= 0;
-// }
-}
-
-void didCommitLoadForFrame(int frame) {
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- //id url= [[[[frame provisionalDataSource] request] URL] absoluteString];
- int dataSource = WebKit.objc_msgSend(frame, WebKit.S_dataSource);
- int request = WebKit.objc_msgSend(dataSource, WebKit.S_request);
- int url = WebKit.objc_msgSend(request, WebKit.S_URL);
- int s = WebKit.objc_msgSend(url, WebKit.S_absoluteString);
- int length = OS.CFStringGetLength(s);
- if (length == 0) return;
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(s, range, buffer);
- String url2 = new String(buffer);
- final Display display = getDisplay();
-
- boolean top = frame == WebKit.objc_msgSend(webView, WebKit.S_mainFrame);
- if (top) {
- /* reset resource status variables */
- resourceCount = 0;
- this.url = url2;
-
- final ProgressEvent progress = new ProgressEvent(this);
- progress.display = display;
- progress.widget = this;
- progress.current = 1;
- progress.total = MAX_PROGRESS;
- for (int i = 0; i < progressListeners.length; i++) {
- final ProgressListener listener = progressListeners[i];
- /*
- * Note on WebKit. Running the event loop from a Browser
- * delegate callback breaks the WebKit (stop loading or
- * crash). The widget ProgressBar currently touches the
- * event loop every time the method setSelection is called.
- * The workaround is to invoke Display.asyncexec so that
- * the Browser does not crash when the user updates the
- * selection of the ProgressBar.
- */
- display.asyncExec(
- new Runnable() {
- public void run() {
- if (!display.isDisposed() && !isDisposed())
- listener.changed(progress);
- }
- }
- );
- }
-
- StatusTextEvent statusText = new StatusTextEvent(this);
- statusText.display = display;
- statusText.widget = this;
- statusText.text = url2;
- for (int i = 0; i < statusTextListeners.length; i++)
- statusTextListeners[i].changed(statusText);
- }
- LocationEvent location = new LocationEvent(Browser.this);
- location.display = display;
- location.widget = this;
- location.location = url2;
- location.top = top;
- for (int i = 0; i < locationListeners.length; i++)
- locationListeners[i].changed(location);
-}
-
-/* WebResourceLoadDelegate */
-
-void didFinishLoadingFromDataSource(int identifier, int dataSource) {
- /*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. Howeever, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- // this code is intentionally commented
- //if (this.identifier == identifier) this.identifier = 0;
-}
-
-void didFailLoadingWithError(int identifier, int error, int dataSource) {
- /*
- * Feature on Safari. The identifier is used here as a marker for the events
- * related to the top frame and the URL changes related to that top frame as
- * they should appear on the location bar of a browser. It is expected to reset
- * the identifier to 0 when the event didFinishLoadingFromDataSource related to
- * the identifierForInitialRequest event is received. Howeever, Safari fires
- * the didFinishLoadingFromDataSource event before the entire content of the
- * top frame is loaded. It is possible to receive multiple willSendRequest
- * events in this interval, causing the Browser widget to send unwanted
- * Location.changing events. For this reason, the identifier is reset to 0
- * when the top frame has either finished loading (didFinishLoadForFrame
- * event) or failed (didFailProvisionalLoadWithError).
- */
- // this code is intentionally commented
- //if (this.identifier == identifier) this.identifier = 0;
-}
-
-int identifierForInitialRequest(int request, int dataSource) {
- final Display display = getDisplay();
- final ProgressEvent progress = new ProgressEvent(this);
- progress.display = display;
- progress.widget = this;
- progress.current = resourceCount;
- progress.total = Math.max(resourceCount, MAX_PROGRESS);
- for (int i = 0; i < progressListeners.length; i++) {
- final ProgressListener listener = progressListeners[i];
- /*
- * Note on WebKit. Running the event loop from a Browser
- * delegate callback breaks the WebKit (stop loading or
- * crash). The widget ProgressBar currently touches the
- * event loop every time the method setSelection is called.
- * The workaround is to invoke Display.asyncexec so that
- * the Browser does not crash when the user updates the
- * selection of the ProgressBar.
- */
- display.asyncExec(
- new Runnable() {
- public void run() {
- if (!display.isDisposed() && !isDisposed())
- listener.changed(progress);
- }
- }
- );
- }
-
- /*
- * Note. numberWithInt uses autorelease. The resulting object
- * does not need to be released.
- * identifier = [NSNumber numberWithInt: resourceCount++]
- */
- int identifier = WebKit.objc_msgSend(WebKit.C_NSNumber, WebKit.S_numberWithInt, resourceCount++);
-
- if (this.identifier == 0) {
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- int frame = WebKit.objc_msgSend(dataSource, WebKit.S_webFrame);
- if (frame == WebKit.objc_msgSend(webView, WebKit.S_mainFrame)) this.identifier = identifier;
- }
- return identifier;
-
-}
-
-int willSendRequest(int identifier, int request, int redirectResponse, int dataSource) {
- return request;
-}
-
-/* handleNotification */
-
-void handleNotification(int notification) {
-}
-
-/* UIDelegate */
-int createWebViewWithRequest(int request) {
- WindowEvent newEvent = new WindowEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = this;
- newEvent.required = true;
- if (openWindowListeners != null) {
- for (int i = 0; i < openWindowListeners.length; i++)
- openWindowListeners[i].open(newEvent);
- }
- int webView = 0;
- Browser browser = newEvent.browser;
- if (browser != null && !browser.isDisposed()) {
- webView = WebKit.HIWebViewGetWebView(browser.webViewHandle);
-
- if (request != 0) {
- //mainFrame = [webView mainFrame];
- int mainFrame= WebKit.objc_msgSend(webView, WebKit.S_mainFrame);
-
- //[mainFrame loadRequest:request];
- WebKit.objc_msgSend(mainFrame, WebKit.S_loadRequest, request);
- }
- }
- return webView;
-}
-
-void webViewShow(int sender) {
- /*
- * Feature on WebKit. The Safari WebKit expects the application
- * to create a new Window using the Objective C Cocoa API in response
- * to UIDelegate.createWebViewWithRequest. The application is then
- * expected to use Objective C Cocoa API to make this window visible
- * when receiving the UIDelegate.webViewShow message. For some reason,
- * a window created with the Carbon API hosting the new browser instance
- * does not redraw until it has been resized. The fix is to increase the
- * size of the Shell and restore it to its initial size.
- */
- Shell parent = getShell();
- Point pt = parent.getSize();
- parent.setSize(pt.x+1, pt.y);
- parent.setSize(pt.x, pt.y);
- WindowEvent newEvent = new WindowEvent(this);
- newEvent.display = getDisplay();
- newEvent.widget = this;
- if (location != null) newEvent.location = location;
- if (size != null) newEvent.size = size;
- /*
- * Feature in Safari. Safari's tool bar contains
- * the address bar. The address bar is displayed
- * if the tool bar is displayed. There is no separate
- * notification for the address bar.
- * Feature in Safari. The menu bar is always
- * displayed. There is no notification to hide
- * the menu bar.
- */
- newEvent.addressBar = toolBar;
- newEvent.menuBar = true;
- newEvent.statusBar = statusBar;
- newEvent.toolBar = toolBar;
- for (int i = 0; i < visibilityWindowListeners.length; i++)
- visibilityWindowListeners[i].show(newEvent);
- location = null;
- size = null;
-}
-
-void setFrame(int frame) {
- float[] dest = new float[4];
- OS.memcpy(dest, frame, 16);
- /* convert to SWT system coordinates */
- Rectangle bounds = getDisplay().getBounds();
- location = new Point((int)dest[0], bounds.height - (int)dest[1] - (int)dest[3]);
- size = new Point((int)dest[2], (int)dest[3]);
-}
-
-void webViewFocus() {
-}
-
-void webViewUnfocus() {
-}
-
-void runJavaScriptAlertPanelWithMessage(int message) {
- int length = OS.CFStringGetLength(message);
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(message, range, buffer);
- String text = new String(buffer);
-
- MessageBox messageBox = new MessageBox(getShell(), SWT.OK | SWT.ICON_WARNING);
- messageBox.setText("Javascript"); //$NON-NLS-1$
- messageBox.setMessage(text);
- messageBox.open();
-}
-
-int runJavaScriptConfirmPanelWithMessage(int message) {
- int length = OS.CFStringGetLength(message);
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(message, range, buffer);
- String text = new String(buffer);
-
- MessageBox messageBox = new MessageBox(getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION);
- messageBox.setText("Javascript"); //$NON-NLS-1$
- messageBox.setMessage(text);
- return messageBox.open() == SWT.OK ? 1 : 0;
-}
-
-void runOpenPanelForFileButtonWithResultListener(int resultListener) {
- FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
- String result = dialog.open();
- if (result == null) {
- WebKit.objc_msgSend(resultListener, WebKit.S_cancel);
- return;
- }
- int length = result.length();
- char[] buffer = new char[length];
- result.getChars(0, length, buffer, 0);
- int filename = OS.CFStringCreateWithCharacters(0, buffer, length);
- WebKit.objc_msgSend(resultListener, WebKit.S_chooseFilename, filename);
- OS.CFRelease(filename);
-}
-void webViewClose() {
- Shell parent = getShell();
- WindowEvent newEvent = new WindowEvent(this);
- newEvent.display = getDisplay();
- newEvent.widget = this;
- for (int i = 0; i < closeWindowListeners.length; i++)
- closeWindowListeners[i].close(newEvent);
- dispose();
- if (parent.isDisposed()) return;
- /*
- * Feature on WebKit. The Safari WebKit expects the application
- * to create a new Window using the Objective C Cocoa API in response
- * to UIDelegate.createWebViewWithRequest. The application is then
- * expected to use Objective C Cocoa API to make this window visible
- * when receiving the UIDelegate.webViewShow message. For some reason,
- * a window created with the Carbon API hosting the new browser instance
- * does not redraw until it has been resized. The fix is to increase the
- * size of the Shell and restore it to its initial size.
- */
- Point pt = parent.getSize();
- parent.setSize(pt.x+1, pt.y);
- parent.setSize(pt.x, pt.y);
-}
-
-int contextMenuItemsForElement(int element, int defaultMenuItems) {
- org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point();
- OS.GetGlobalMouse(pt);
- Event event = new Event();
- event.x = pt.h;
- event.y = pt.v;
- notifyListeners(SWT.MenuDetect, event);
- Menu menu = getMenu();
- if (!event.doit) return 0;
- if (menu != null && !menu.isDisposed()) {
- if (event.x != pt.h || event.y != pt.v) {
- menu.setLocation(event.x, event.y);
- }
- menu.setVisible(true);
- return 0;
- }
- return defaultMenuItems;
-}
-
-void setStatusBarVisible(int visible) {
- /* Note. Webkit only emits the notification when the status bar should be hidden. */
- statusBar = visible != 0;
-}
-
-void setStatusText(int text) {
- int length = OS.CFStringGetLength(text);
- if (length == 0) return;
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(text, range, buffer);
-
- StatusTextEvent statusText = new StatusTextEvent(this);
- statusText.display = getDisplay();
- statusText.widget = this;
- statusText.text = new String(buffer);
- for (int i = 0; i < statusTextListeners.length; i++)
- statusTextListeners[i].changed(statusText);
-}
-
-void setResizable(int visible) {
-}
-
-void setToolbarsVisible(int visible) {
- /* Note. Webkit only emits the notification when the tool bar should be hidden. */
- toolBar = visible != 0;
-}
-
-/* PolicyDelegate */
-
-void decidePolicyForMIMEType(int type, int request, int frame, int listener) {
- boolean canShow = WebKit.objc_msgSend(WebKit.C_WebView, WebKit.S_canShowMIMEType, type) != 0;
- WebKit.objc_msgSend(listener, canShow ? WebKit.S_use : WebKit.S_download);
-}
-
-void decidePolicyForNavigationAction(int actionInformation, int request, int frame, int listener) {
- int url = WebKit.objc_msgSend(request, WebKit.S_URL);
- if (url == 0) {
- /* indicates that a URL with an invalid format was specified */
- WebKit.objc_msgSend(listener, WebKit.S_ignore);
- return;
- }
- int s = WebKit.objc_msgSend(url, WebKit.S_absoluteString);
- int length = OS.CFStringGetLength(s);
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(s, range, buffer);
- String url2 = new String(buffer);
-
- LocationEvent newEvent = new LocationEvent(this);
- newEvent.display = getDisplay();
- newEvent.widget = this;
- newEvent.location = url2;
- newEvent.doit = true;
- if (locationListeners != null) {
- changingLocation = true;
- for (int i = 0; i < locationListeners.length; i++)
- locationListeners[i].changing(newEvent);
- changingLocation = false;
- }
-
- WebKit.objc_msgSend(listener, newEvent.doit ? WebKit.S_use : WebKit.S_ignore);
-
- if (html != null && !isDisposed()) {
- String html = this.html;
- this.html = null;
- _setText(html);
- }
-}
-
-void decidePolicyForNewWindowAction(int actionInformation, int request, int frameName, int listener) {
- WebKit.objc_msgSend(listener, WebKit.S_use);
-}
-
-void unableToImplementPolicyWithError(int error, int frame) {
-}
-
-/* WebDownload */
-
-void decideDestinationWithSuggestedFilename (int download, int filename) {
- int length = OS.CFStringGetLength(filename);
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(filename, range, buffer);
- String name = new String(buffer);
- FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
- dialog.setText(SWT.getMessage ("SWT_FileDownload")); //$NON-NLS-1$
- dialog.setFileName(name);
- String path = dialog.open();
- if (path == null) {
- /* cancel pressed */
- WebKit.objc_msgSend(download, WebKit.S_release);
- return;
- }
- length = path.length();
- char[] chars = new char[length];
- path.getChars(0, length, chars, 0);
- int result = OS.CFStringCreateWithCharacters(0, chars, length);
- WebKit.objc_msgSend(download, WebKit.S_setDestinationAllowOverwrite, result, 1);
- OS.CFRelease(result);
-}
-
-// GOOGLE: we need a notification when the window object is available so we can
-// setup our own hooks before any JavaScript runs.
-public interface WindowScriptObjectListener {
- public void windowScriptObjectAvailable(int windowScriptObject);
-}
-
-public void addWindowScriptObjectListener(WindowScriptObjectListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- WindowScriptObjectListener[] newWindowScriptObjectListeners = new WindowScriptObjectListener[windowScriptObjectListeners.length + 1];
- System.arraycopy(windowScriptObjectListeners, 0, newWindowScriptObjectListeners, 0, windowScriptObjectListeners.length);
- windowScriptObjectListeners = newWindowScriptObjectListeners;
- windowScriptObjectListeners[windowScriptObjectListeners.length - 1] = listener;
-}
-
-public void removeWindowScriptObjectListener(WindowScriptObjectListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (windowScriptObjectListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < windowScriptObjectListeners.length; i++) {
- if (listener == windowScriptObjectListeners[i]) {
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (windowScriptObjectListeners.length == 1) {
- windowScriptObjectListeners = new WindowScriptObjectListener[0];
- return;
- }
- WindowScriptObjectListener[] newWindowScriptObjectListeners = new WindowScriptObjectListener[windowScriptObjectListeners.length - 1];
- System.arraycopy(windowScriptObjectListeners, 0, newWindowScriptObjectListeners, 0, index);
- System.arraycopy(windowScriptObjectListeners, index + 1, newWindowScriptObjectListeners, index, windowScriptObjectListeners.length - index - 1);
- windowScriptObjectListeners = newWindowScriptObjectListeners;
-}
-
-void fireWindowScriptObjectListeners(int windowScriptObject) {
- for (int i = 0; i < windowScriptObjectListeners.length; i++) {
- windowScriptObjectListeners[i].windowScriptObjectAvailable(windowScriptObject);
- }
-}
-
-public static void setWebInspectorEnabled(boolean isEnabled) {
- char[] name = "WebKitDeveloperExtras".toCharArray();
- int clsId = WebKit.objc_getClass("NSUserDefaults");
- if (clsId == 0) return;
- int sel_sud = WebKit.sel_registerName("standardUserDefaults");
- if (sel_sud == 0) return;
- int objId = WebKit.objc_msgSend(clsId, sel_sud);
- if (objId == 0) return;
- int sel_sbfk = WebKit.sel_registerName("setBool:forKey:");
- if (sel_sbfk == 0) return;
- int cfName = OS.CFStringCreateWithCharacters(0,name,name.length);
- if (cfName == 0) return;
- try {
- WebKit.objc_msgSend(objId, sel_sbfk, isEnabled ? 1 : 0, cfName);
- } finally {
- OS.CFRelease(cfName);
- }
-}
-
-public void setNeedsDisplay(boolean value) {
- int webView = WebKit.HIWebViewGetWebView(webViewHandle);
- if (webView == 0) return;
- int sel = WebKit.sel_registerName("setNeedsDisplay:");
- if (sel == 0) return;
- WebKit.objc_msgSend(webView, sel, (value)?1:0);
-}
-
-private static int getGlobalContextForWindowObject(int frame,
- int windowObject, int childFramesSel, int countSel, int windowObjectSel,
- int objectAtIndexSel) {
- int frameWindowObject = WebKit.objc_msgSend(frame, windowObjectSel);
- if (frameWindowObject == 0) return 0;
- if (frameWindowObject == windowObject) return frame;
-
- int childFrames = WebKit.objc_msgSend(frame, childFramesSel);
- int count = WebKit.objc_msgSend(childFrames, countSel);
- for (int i = 0; i < count; ++i) {
- int child = WebKit.objc_msgSend(childFrames, objectAtIndexSel, i);
- if (child == 0) continue;
- int foundFrame = getGlobalContextForWindowObject(child, windowObject,
- childFramesSel, countSel, windowObjectSel, objectAtIndexSel);
- if (foundFrame != 0) return foundFrame;
- }
- return 0;
-}
-
-// Finds a JSGlobalContextRef by searching the WebFrame tree for
-// a particular WebScriptObject (objective-c wrapper around the
-// global object).
-public int getGlobalContextForWindowObject(int windowObject) {
- int childFramesSel = WebKit.sel_registerName("childFrames");
- int countSel = WebKit.sel_registerName("count");
- int windowObjectSel = WebKit.sel_registerName("windowObject");
- int objectAtIndexSel = WebKit.sel_registerName("objectAtIndex:");
- int mainFrameSel = WebKit.sel_registerName("mainFrame");
- int globalContextSel = WebKit.sel_registerName("globalContext");
- if (childFramesSel == 0 || countSel == 0 || windowObjectSel == 0
- || objectAtIndexSel == 0 || mainFrameSel == 0 || globalContextSel == 0)
- return 0;
- int webViewRef = WebKit.HIWebViewGetWebView(webViewHandle);
- if (webViewRef == 0) return 0;
- int mainFrame = WebKit.objc_msgSend(webViewRef, mainFrameSel);
- if (mainFrame == 0) return 0;
- int frame = getGlobalContextForWindowObject(mainFrame, windowObject, childFramesSel,
- countSel, windowObjectSel, objectAtIndexSel);
- if (frame == 0) return 0;
- return WebKit.objc_msgSend(frame, globalContextSel);
-}
-
-WindowScriptObjectListener[] windowScriptObjectListeners = new WindowScriptObjectListener[0];
-// end GOOGLE
-}
diff --git a/dev/mac/src/org/eclipse/swt/browser/WebKit.java b/dev/mac/src/org/eclipse/swt/browser/WebKit.java
deleted file mode 100644
index 0bff1a3..0000000
--- a/dev/mac/src/org/eclipse/swt/browser/WebKit.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.browser;
-
-import org.eclipse.swt.internal.*;
-
-// GOOGLE: make this public
-public class WebKit {
-
-static {
- Library.loadLibrary("swt-webkit"); //$NON-NLS-1$
- WebInitForCarbon();
-}
-
-/* Objective-C class ids */
-static final int C_NSHTTPCookieStorage = WebKit.objc_getClass("NSHTTPCookieStorage"); //$NON-NLS-1$
-static final int C_NSNotificationCenter = WebKit.objc_getClass("NSNotificationCenter"); //$NON-NLS-1$
-static final int C_NSNumber = WebKit.objc_getClass("NSNumber"); //$NON-NLS-1$
-static final int C_NSURL = WebKit.objc_getClass("NSURL"); //$NON-NLS-1$
-static final int C_NSURLRequest = WebKit.objc_getClass("NSURLRequest"); //$NON-NLS-1$
-static final int C_WebKitDelegate = WebKit.objc_getClass("WebKitDelegate"); //$NON-NLS-1$
-static final int C_WebDownload = WebKit.objc_getClass("WebDownload"); //$NON-NLS-1$
-static final int C_WebView = WebKit.objc_getClass("WebView"); //$NON-NLS-1$
-
-/* Objective-C method selectors */
-static final int S_absoluteString = WebKit.sel_registerName("absoluteString"); //$NON-NLS-1$
-static final int S_addObserver_selector_name_object = WebKit.sel_registerName("addObserver:selector:name:object:"); //$NON-NLS-1$
-static final int S_alloc = WebKit.sel_registerName("alloc"); //$NON-NLS-1$
-static final int S_autorelease = WebKit.sel_registerName("autorelease"); //$NON-NLS-1$
-static final int S_cancel = WebKit.sel_registerName("cancel"); //$NON-NLS-1$
-static final int S_canGoBack = WebKit.sel_registerName("canGoBack"); //$NON-NLS-1$
-static final int S_canGoForward = WebKit.sel_registerName("canGoForward"); //$NON-NLS-1$
-static final int S_canShowMIMEType = WebKit.sel_registerName("canShowMIMEType:"); //$NON-NLS-1$
-static final int S_chooseFilename = WebKit.sel_registerName("chooseFilename:"); //$NON-NLS-1$
-static final int S_cookies = WebKit.sel_registerName("cookies"); //$NON-NLS-1$
-static final int S_count = WebKit.sel_registerName("count"); //$NON-NLS-1$
-static final int S_dataSource = WebKit.sel_registerName("dataSource"); //$NON-NLS-1$
-static final int S_defaultCenter = WebKit.sel_registerName("defaultCenter"); //$NON-NLS-1$
-static final int S_deleteCookie = WebKit.sel_registerName("deleteCookie:"); //$NON-NLS-1$
-static final int S_download = WebKit.sel_registerName("download"); //$NON-NLS-1$
-static final int S_goBack = WebKit.sel_registerName("goBack:"); //$NON-NLS-1$
-static final int S_goForward = WebKit.sel_registerName("goForward:"); //$NON-NLS-1$
-static final int S_handleNotification = WebKit.sel_registerName("handleNotification:"); //$NON-NLS-1$
-static final int S_ignore = WebKit.sel_registerName("ignore"); //$NON-NLS-1$
-static final int S_initialRequest = WebKit.sel_registerName("initialRequest"); //$NON-NLS-1$
-static final int S_initWithProc = WebKit.sel_registerName("initWithProc:user_data:"); //$NON-NLS-1$
-static final int S_isSessionOnly = WebKit.sel_registerName("isSessionOnly"); //$NON-NLS-1$
-static final int S_loadHTMLStringbaseURL = WebKit.sel_registerName("loadHTMLString:baseURL:"); //$NON-NLS-1$
-static final int S_loadRequest = WebKit.sel_registerName("loadRequest:"); //$NON-NLS-1$
-static final int S_mainFrame = WebKit.sel_registerName("mainFrame"); //$NON-NLS-1$
-static final int S_name = WebKit.sel_registerName("name"); //$NON-NLS-1$
-static final int S_numberWithInt = WebKit.sel_registerName("numberWithInt:"); //$NON-NLS-1$
-static final int S_objectAtIndex = WebKit.sel_registerName("objectAtIndex:"); //$NON-NLS-1$
-static final int S_provisionalDataSource = WebKit.sel_registerName("provisionalDataSource"); //$NON-NLS-1$
-static final int S_release = WebKit.sel_registerName("release"); //$NON-NLS-1$
-static final int S_reload = WebKit.sel_registerName("reload:"); //$NON-NLS-1$
-static final int S_retain = WebKit.sel_registerName("retain"); //$NON-NLS-1$
-static final int S_removeObserver_name_object = WebKit.sel_registerName("removeObserver:name:object:"); //$NON-NLS-1$
-static final int S_removeObserver = WebKit.sel_registerName("removeObserver:"); //$NON-NLS-1$
-static final int S_requestWithURL = WebKit.sel_registerName("requestWithURL:"); //$NON-NLS-1$
-static final int S_request = WebKit.sel_registerName("request"); //$NON-NLS-1$
-static final int S_retainCount = WebKit.sel_registerName("retainCount"); //$NON-NLS-1$
-static final int S_setDestinationAllowOverwrite = WebKit.sel_registerName("setDestination:allowOverwrite:"); //$NON-NLS-1$
-static final int S_setDownloadDelegate = WebKit.sel_registerName("setDownloadDelegate:"); //$NON-NLS-1$
-static final int S_setFrameLoadDelegate = WebKit.sel_registerName("setFrameLoadDelegate:"); //$NON-NLS-1$
-static final int S_setGroupName = WebKit.sel_registerName("setGroupName:"); //$NON-NLS-1$
-static final int S_setPolicyDelegate = WebKit.sel_registerName("setPolicyDelegate:"); //$NON-NLS-1$
-static final int S_setResourceLoadDelegate = WebKit.sel_registerName("setResourceLoadDelegate:"); //$NON-NLS-1$
-static final int S_setStatusText = WebKit.sel_registerName("setStatusText:"); //$NON-NLS-1$
-static final int S_setUIDelegate = WebKit.sel_registerName("setUIDelegate:"); //$NON-NLS-1$
-static final int S_sharedHTTPCookieStorage = WebKit.sel_registerName("sharedHTTPCookieStorage"); //$NON-NLS-1$
-static final int S_stopLoading = WebKit.sel_registerName("stopLoading:"); //$NON-NLS-1$
-static final int S_stringByEvaluatingJavaScriptFromString = WebKit.sel_registerName("stringByEvaluatingJavaScriptFromString:"); //$NON-NLS-1$
-static final int S_takeStringURLFrom = WebKit.sel_registerName("takeStringURLFrom:"); //$NON-NLS-1$
-static final int S_use = WebKit.sel_registerName("use"); //$NON-NLS-1$
-static final int S_webFrame = WebKit.sel_registerName("webFrame"); //$NON-NLS-1$
-static final int S_URL = WebKit.sel_registerName("URL"); //$NON-NLS-1$
-static final int S_URLWithString = WebKit.sel_registerName("URLWithString:"); //$NON-NLS-1$
-
-/* WebKit */
-static final native int HIWebViewCreate(int[] outView);
-static final native int HIWebViewGetWebView(int inView);
-static final native void WebInitForCarbon();
-
-/* OBJ-C runtime primitives */
-static final native int objc_getClass(byte[] className);
-//GOOGLE: make this public
-public static final native int objc_msgSend(int object, int selector);
-static final native int objc_msgSend(int object, int selector, int arg0);
-static final native int objc_msgSend(int object, int selector, int arg0, int arg1);
-static final native int objc_msgSend(int object, int selector, int arg0, int arg1, int arg2);
-static final native int objc_msgSend(int object, int selector, int arg0, int arg1, int arg2, int arg3);
-static final native int sel_registerName(byte[] selectorName);
-
-static byte [] ascii (String name) {
- int length = name.length ();
- char [] chars = new char [length];
- name.getChars (0, length, chars, 0);
- byte [] buffer = new byte [length + 1];
- for (int i=0; i<length; i++) {
- buffer [i] = (byte) chars [i];
- }
- return buffer;
-}
-
-// GOOGLE: make this public
-public static int sel_registerName(String selector) {
- return WebKit.sel_registerName(ascii(selector));
-}
-
-static int objc_getClass(String className) {
- return WebKit.objc_getClass(ascii(className));
-}
-}
diff --git a/dev/mac/src/org/eclipse/swt/internal/Library.java b/dev/mac/src/org/eclipse/swt/internal/Library.java
deleted file mode 100644
index 35900e3..0000000
--- a/dev/mac/src/org/eclipse/swt/internal/Library.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.internal;
-
-public class Library {
-
- /* SWT Version - Mmmm (M=major, mmm=minor) */
-
- /**
- * SWT Major version number (must be >= 0)
- */
- static int MAJOR_VERSION = 3;
-
- /**
- * SWT Minor version number (must be in the range 0..999)
- */
- static int MINOR_VERSION = 235;
-
- /**
- * SWT revision number (must be >= 0)
- */
- static int REVISION = 0;
-
- /**
- * The JAVA and SWT versions
- */
- public static final int JAVA_VERSION, SWT_VERSION;
-
-static {
- JAVA_VERSION = parseVersion(System.getProperty("java.version"));
- SWT_VERSION = SWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
-}
-
-static int parseVersion(String version) {
- if (version == null) return 0;
- int major = 0, minor = 0, micro = 0;
- int length = version.length(), index = 0, start = 0;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) major = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- start = ++index;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) minor = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- start = ++index;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) micro = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- return JAVA_VERSION(major, minor, micro);
-}
-
-/**
- * Returns the Java version number as an integer.
- *
- * @param major
- * @param minor
- * @param micro
- * @return the version
- */
-public static int JAVA_VERSION (int major, int minor, int micro) {
- return (major << 16) + (minor << 8) + micro;
-}
-
-/**
- * Returns the SWT version number as an integer.
- *
- * @param major
- * @param minor
- * @return the version
- */
-public static int SWT_VERSION (int major, int minor) {
- return major * 1000 + minor;
-}
-
-/**
- * Loads the shared library that matches the version of the
- * Java code which is currently running. SWT shared libraries
- * follow an encoding scheme where the major, minor and revision
- * numbers are embedded in the library name and this along with
- * <code>name</code> is used to load the library. If this fails,
- * <code>name</code> is used in another attempt to load the library,
- * this time ignoring the SWT version encoding scheme.
- *
- * @param name the name of the library to load
- */
-public static void loadLibrary (String name) {
- /*
- * Include platform name to support different windowing systems
- * on same operating system.
- */
- String platform = Platform.PLATFORM;
-
- /*
- * Get version qualifier.
- */
- String version = System.getProperty ("swt.version"); //$NON-NLS-1$
- if (version == null) {
- version = "" + MAJOR_VERSION; //$NON-NLS-1$
- /* Force 3 digits in minor version number */
- if (MINOR_VERSION < 10) {
- version += "00"; //$NON-NLS-1$
- } else {
- if (MINOR_VERSION < 100) version += "0"; //$NON-NLS-1$
- }
- version += MINOR_VERSION;
- /* No "r" until first revision */
- if (REVISION > 0) version += "r" + REVISION; //$NON-NLS-1$
- }
-
- /*
- * GOOGLE: Since we're bundling our own version of SWT, we need to be
- * able to tell SWT where its dynamic libraries live. Otherwise we'd
- * have to force our users to always specify a -Djava.library.path
- * on the command line.
- */
- String swtLibraryPath = System.getProperty ("swt.library.path");
- try {
- String newName = name + "-" + platform + "-" + version; //$NON-NLS-1$ //$NON-NLS-2$
- if (swtLibraryPath != null)
- System.load(swtLibraryPath + System.mapLibraryName(newName));
- else
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e1) {
- try {
- String newName = name + "-" + platform; //$NON-NLS-1$
- if (swtLibraryPath != null)
- System.load(swtLibraryPath + System.mapLibraryName(newName));
- else
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e2) {
- throw e1;
- }
- }
-}
-
-}
diff --git a/dev/mac/src/org/eclipse/swt/widgets/Display.java b/dev/mac/src/org/eclipse/swt/widgets/Display.java
deleted file mode 100644
index c37a38c..0000000
--- a/dev/mac/src/org/eclipse/swt/widgets/Display.java
+++ /dev/null
@@ -1,4041 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.carbon.CFRange;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.CGPoint;
-import org.eclipse.swt.internal.carbon.CGRect;
-import org.eclipse.swt.internal.carbon.GDevice;
-import org.eclipse.swt.internal.carbon.HICommand;
-import org.eclipse.swt.internal.carbon.Rect;
-import org.eclipse.swt.internal.carbon.RGBColor;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-// GOOGLE: special hacks to allow Browser to function normally
-import org.eclipse.swt.browser.Browser;
-
-/**
- * Instances of this class are responsible for managing the
- * connection between SWT and the underlying operating
- * system. Their most important function is to implement
- * the SWT event loop in terms of the platform event model.
- * They also provide various methods for accessing information
- * about the operating system, and have overall control over
- * the operating system resources which SWT allocates.
- * <p>
- * Applications which are built with SWT will <em>almost always</em>
- * require only a single display. In particular, some platforms
- * which SWT supports will not allow more than one <em>active</em>
- * display. In other words, some platforms do not support
- * creating a new display if one already exists that has not been
- * sent the <code>dispose()</code> message.
- * <p>
- * In SWT, the thread which creates a <code>Display</code>
- * instance is distinguished as the <em>user-interface thread</em>
- * for that display.
- * </p>
- * The user-interface thread for a particular display has the
- * following special attributes:
- * <ul>
- * <li>
- * The event loop for that display must be run from the thread.
- * </li>
- * <li>
- * Some SWT API methods (notably, most of the public methods in
- * <code>Widget</code> and its subclasses), may only be called
- * from the thread. (To support multi-threaded user-interface
- * applications, class <code>Display</code> provides inter-thread
- * communication methods which allow threads other than the
- * user-interface thread to request that it perform operations
- * on their behalf.)
- * </li>
- * <li>
- * The thread is not allowed to construct other
- * <code>Display</code>s until that display has been disposed.
- * (Note that, this is in addition to the restriction mentioned
- * above concerning platform support for multiple displays. Thus,
- * the only way to have multiple simultaneously active displays,
- * even on platforms which support it, is to have multiple threads.)
- * </li>
- * </ul>
- * Enforcing these attributes allows SWT to be implemented directly
- * on the underlying operating system's event model. This has
- * numerous benefits including smaller footprint, better use of
- * resources, safer memory management, clearer program logic,
- * better performance, and fewer overall operating system threads
- * required. The down side however, is that care must be taken
- * (only) when constructing multi-threaded applications to use the
- * inter-thread communication mechanisms which this class provides
- * when required.
- * </p><p>
- * All SWT API methods which may only be called from the user-interface
- * thread are distinguished in their documentation by indicating that
- * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
- * SWT exception.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Close, Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- * @see #syncExec
- * @see #asyncExec
- * @see #wake
- * @see #readAndDispatch
- * @see #sleep
- * @see Device#dispose
- */
-public class Display extends Device {
-
- /* Windows and Events */
- static final int WAKE_CLASS = 'S' << 24 | 'W' << 16 | 'T' << 8 | '-';
- static final int WAKE_KIND = 1;
- Event [] eventQueue;
- Callback actionCallback, appleEventCallback, commandCallback, controlCallback, accessibilityCallback, appearanceCallback;
- Callback drawItemCallback, itemDataCallback, itemNotificationCallback, itemCompareCallback;
- Callback hitTestCallback, keyboardCallback, menuCallback, mouseHoverCallback, helpCallback;
- Callback mouseCallback, trackingCallback, windowCallback, colorCallback, textInputCallback;
- int actionProc, appleEventProc, commandProc, controlProc, appearanceProc, accessibilityProc;
- int drawItemProc, itemDataProc, itemNotificationProc, itemCompareProc, helpProc;
- int hitTestProc, keyboardProc, menuProc, mouseHoverProc;
- int mouseProc, trackingProc, windowProc, colorProc, textInputProc;
- EventTable eventTable, filterTable;
- int queue, lastModifiers;
- boolean closing;
-
- boolean inPaint, needsPaint;
-
- /* GC */
- int gcWindow;
-
- /* Deferred dispose window */
- int disposeWindow;
- int [] disposeWindowList;
-
- /* Sync/Async Widget Communication */
- Synchronizer synchronizer = new Synchronizer (this);
- Thread thread;
-
- /* Widget Table */
- int freeSlot;
- int [] indexTable, property;
- Widget [] widgetTable;
- static final int GROW_SIZE = 1024;
- static final int SWT0 = ('s'<<24) + ('w'<<16) + ('t'<<8) + '0';
-
- /* Focus */
- int focusEvent;
- Control focusControl;
- Combo focusCombo;
- boolean ignoreFocus;
-
- /* Menus */
- Menu menuBar;
- Menu [] menus, popups;
- static final int ID_TEMPORARY = 1000;
- static final int ID_START = 1001;
-
- /* Display Shutdown */
- Runnable [] disposeList;
-
- /* System Tray */
- Tray tray;
-
- /* Timers */
- int [] timerIds;
- Runnable [] timerList;
- Callback timerCallback;
- int timerProc;
- boolean allowTimers = true;
-
- /* Current caret */
- Caret currentCaret;
- Callback caretCallback;
- int caretID, caretProc;
-
- /* Grabs */
- Control grabControl, mouseUpControl;
- boolean grabbing;
-
- /* Hover Help */
- int helpString;
- Widget helpWidget;
- int lastHelpX, lastHelpY;
-
- /* Mouse DoubleClick */
- int clickCount, clickCountButton;
-
- /* Mouse Enter/Exit/Hover */
- Control currentControl;
- int mouseHoverID;
- org.eclipse.swt.internal.carbon.Point dragMouseStart = null;
- boolean dragging, mouseMoved;
-
- /* Insets */
- Rect buttonInset, tabFolderNorthInset, tabFolderSouthInset, comboInset, editTextInset;
-
- /* Fonts */
- boolean smallFonts;
- boolean noFocusRing;
-
- /* Keyboard */
- int kchrPtr;
- int [] kchrState = new int [1];
-
- /* System Resources */
- Image errorImage, infoImage, warningImage;
- Cursor [] cursors = new Cursor [SWT.CURSOR_HAND + 1];
-
- /* System Settings */
- boolean runSettings;
- RGBColor highlightColor;
-
- /* Dock icon */
- int dockImage, dockImageData;
-
- /* Key Mappings. */
- static int [] [] KeyTable = {
-
- /* Keyboard and Mouse Masks */
- {58, SWT.ALT},
- {56, SWT.SHIFT},
- {59, SWT.CONTROL},
- {55, SWT.COMMAND},
-
- /* Non-Numeric Keypad Keys */
- {126, SWT.ARROW_UP},
- {125, SWT.ARROW_DOWN},
- {123, SWT.ARROW_LEFT},
- {124, SWT.ARROW_RIGHT},
- {116, SWT.PAGE_UP},
- {121, SWT.PAGE_DOWN},
- {115, SWT.HOME},
- {119, SWT.END},
-// {??, SWT.INSERT},
-
- /* Virtual and Ascii Keys */
- {51, SWT.BS},
- {36, SWT.CR},
- {117, SWT.DEL},
- {53, SWT.ESC},
- {76, SWT.LF},
- {48, SWT.TAB},
-
- /* Functions Keys */
- {122, SWT.F1},
- {120, SWT.F2},
- {99, SWT.F3},
- {118, SWT.F4},
- {96, SWT.F5},
- {97, SWT.F6},
- {98, SWT.F7},
- {100, SWT.F8},
- {101, SWT.F9},
- {109, SWT.F10},
- {103, SWT.F11},
- {111, SWT.F12},
- {105, SWT.F13},
- {107, SWT.F14},
- {113, SWT.F15},
-
- /* Numeric Keypad Keys */
- {67, SWT.KEYPAD_MULTIPLY},
- {69, SWT.KEYPAD_ADD},
- {76, SWT.KEYPAD_CR},
- {78, SWT.KEYPAD_SUBTRACT},
- {65, SWT.KEYPAD_DECIMAL},
- {75, SWT.KEYPAD_DIVIDE},
- {82, SWT.KEYPAD_0},
- {83, SWT.KEYPAD_1},
- {84, SWT.KEYPAD_2},
- {85, SWT.KEYPAD_3},
- {86, SWT.KEYPAD_4},
- {87, SWT.KEYPAD_5},
- {88, SWT.KEYPAD_6},
- {89, SWT.KEYPAD_7},
- {91, SWT.KEYPAD_8},
- {92, SWT.KEYPAD_9},
- {81, SWT.KEYPAD_EQUAL},
-
- /* Other keys */
-// {??, SWT.CAPS_LOCK},
- {71, SWT.NUM_LOCK},
-// {??, SWT.SCROLL_LOCK},
-// {??, SWT.PAUSE},
-// {??, SWT.BREAK},
-// {??, SWT.PRINT_SCREEN},
- {114, SWT.HELP},
-
- };
-
- static String APP_NAME = "SWT";
- static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget";
-
- /* Multiple Displays. */
- static Display Default;
- static Display [] Displays = new Display [4];
-
- /* Package Name */
- static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets.";
-
- /* Display Data */
- Object data;
- String [] keys;
- Object [] values;
-
- /*
- * TEMPORARY CODE. Install the runnable that
- * gets the current display. This code will
- * be removed in the future.
- */
- static {
- DeviceFinder = new Runnable () {
- public void run () {
- Device device = getCurrent ();
- if (device == null) {
- device = getDefault ();
- }
- setDevice (device);
- }
- };
- }
-
-/*
-* TEMPORARY CODE.
-*/
-static void setDevice (Device device) {
- CurrentDevice = device;
-}
-
-static byte [] ascii (String name) {
- int length = name.length ();
- char [] chars = new char [length];
- name.getChars (0, length, chars, 0);
- byte [] buffer = new byte [length + 1];
- for (int i=0; i<length; i++) {
- buffer [i] = (byte) chars [i];
- }
- return buffer;
-}
-
-static int translateKey (int key) {
- for (int i=0; i<KeyTable.length; i++) {
- if (KeyTable [i] [0] == key) return KeyTable [i] [1];
- }
- return 0;
-}
-
-static int untranslateKey (int key) {
- for (int i=0; i<KeyTable.length; i++) {
- if (KeyTable [i] [1] == key) return KeyTable [i] [0];
- }
- return 0;
-}
-
-int actionProc (int theControl, int partCode) {
- Widget widget = getWidget (theControl);
- if (widget != null) return widget.actionProc (theControl, partCode);
- return OS.noErr;
-}
-
-int appearanceProc (int theAppleEvent, int reply, int handlerRefcon) {
- runSettings = true;
- wakeThread ();
- return OS.eventNotHandledErr;
-}
-
-int appleEventProc (int nextHandler, int theEvent, int userData) {
- int eventClass = OS.GetEventClass (theEvent);
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventClass) {
- case OS.kEventClassApplication:
- switch (eventKind) {
- case OS.kEventAppAvailableWindowBoundsChanged: {
- /* Reset the dock image in case the dock has been restarted */
- if (dockImage != 0) {
- int [] reason = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamReason, OS.typeUInt32, null, 4, null, reason);
- if (reason [0] == OS.kAvailBoundsChangedForDock) {
- OS.SetApplicationDockTileImage (dockImage);
- }
- }
- break;
- }
- }
- break;
- case OS.kEventClassAppleEvent:
- int [] aeEventID = new int [1];
- if (OS.GetEventParameter (theEvent, OS.kEventParamAEEventID, OS.typeType, null, 4, null, aeEventID) == OS.noErr) {
- if (aeEventID [0] == OS.kAEQuitApplication) {
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit) {
- /*
- * When the application is closing, no SWT program can continue
- * to run. In order to avoid running code after the display has
- * been disposed, exit from Java.
- */
- dispose ();
- System.exit (0);
- }
- return OS.userCanceledErr;
- }
- }
- break;
- }
- return OS.eventNotHandledErr;
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when an event of the given type occurs anywhere
- * in a widget. The event type is one of the event constants
- * defined in class <code>SWT</code>. When the event does occur,
- * the listener is notified by sending it the <code>handleEvent()</code>
- * message.
- * <p>
- * Setting the type of an event to <code>SWT.None</code> from
- * within the <code>handleEvent()</code> method can be used to
- * change the event type and stop subsequent Java listeners
- * from running. Because event filters run before other listeners,
- * event filters can both block other listeners and set arbitrary
- * fields within an event. For this reason, event filters are both
- * powerful and dangerous. They should generally be avoided for
- * performance, debugging and code maintenance reasons.
- * </p>
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #removeFilter
- * @see #removeListener
- *
- * @since 3.0
- */
-public void addFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) filterTable = new EventTable ();
- filterTable.hook (eventType, listener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when an event of the given type occurs. The event
- * type is one of the event constants defined in class <code>SWT</code>.
- * When the event does occur in the display, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #removeListener
- *
- * @since 2.0
- */
-public void addListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, listener);
-}
-
-void addMenu (Menu menu) {
- if (menus == null) menus = new Menu [12];
- for (int i=0; i<menus.length; i++) {
- if (menus [i] == null) {
- menu.id = (short)(ID_START + i);
- menus [i] = menu;
- return;
- }
- }
- Menu [] newMenus = new Menu [menus.length + 12];
- menu.id = (short)(ID_START + menus.length);
- newMenus [menus.length] = menu;
- System.arraycopy (menus, 0, newMenus, 0, menus.length);
- menus = newMenus;
-}
-
-void addPopup (Menu menu) {
- if (popups == null) popups = new Menu [4];
- int length = popups.length;
- for (int i=0; i<length; i++) {
- if (popups [i] == menu) return;
- }
- int index = 0;
- while (index < length) {
- if (popups [index] == null) break;
- index++;
- }
- if (index == length) {
- Menu [] newPopups = new Menu [length + 4];
- System.arraycopy (popups, 0, newPopups, 0, length);
- popups = newPopups;
- }
- popups [index] = menu;
-}
-
-void addToDisposeWindow (int control) {
- int [] root = new int [1];
- if (disposeWindow == 0) {
- int [] outWindow = new int [1];
- OS.CreateNewWindow (OS.kOverlayWindowClass, 0, new Rect(), outWindow);
- disposeWindow = outWindow [0];
- OS.CreateRootControl (disposeWindow, root);
- } else {
- OS.GetRootControl (disposeWindow, root);
- }
- OS.EmbedControl (control, root [0]);
-}
-
-void addWidget (int handle, Widget widget) {
- if (handle == 0) return;
- if (freeSlot == -1) {
- int length = (freeSlot = indexTable.length) + GROW_SIZE;
- int [] newIndexTable = new int [length];
- Widget [] newWidgetTable = new Widget [length];
- System.arraycopy (indexTable, 0, newIndexTable, 0, freeSlot);
- System.arraycopy (widgetTable, 0, newWidgetTable, 0, freeSlot);
- for (int i=freeSlot; i<length-1; i++) {
- newIndexTable [i] = i + 1;
- }
- newIndexTable [length - 1] = -1;
- indexTable = newIndexTable;
- widgetTable = newWidgetTable;
- }
- property [0] = freeSlot + 1;
- OS.SetControlProperty (handle, SWT0, SWT0, 4, property);
- int oldSlot = freeSlot;
- freeSlot = indexTable [oldSlot];
- indexTable [oldSlot] = -2;
- widgetTable [oldSlot] = widget;
-}
-
-void addDisposeWindow (int window) {
- if (disposeWindowList == null) disposeWindowList = new int [4];
- int length = disposeWindowList.length;
- for (int i=0; i<length; i++) {
- if (disposeWindowList [i] == window) return;
- }
- int index = 0;
- while (index < length) {
- if (disposeWindowList [index] == 0) break;
- index++;
- }
- if (index == length) {
- int [] newList = new int [length + 4];
- System.arraycopy (disposeWindowList, 0, newList, 0, length);
- disposeWindowList = newList;
- }
- disposeWindowList [index] = window;
-}
-
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The caller of this method continues
- * to run in parallel, and is not notified when the
- * runnable has completed. Specifying <code>null</code> as the
- * runnable simply wakes the user-interface thread when run.
- * <p>
- * Note that at the time the runnable is invoked, widgets
- * that have the receiver as their display may have been
- * disposed. Therefore, it is necessary to check for this
- * case inside the runnable before accessing the widget.
- * </p>
- *
- * @param runnable code to run on the user-interface thread or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #syncExec
- */
-public void asyncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.asyncExec (runnable);
-}
-
-/**
- * Causes the system hardware to emit a short sound
- * (if it supports this capability).
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void beep () {
- checkDevice ();
- OS.SysBeep ((short) 100);
-}
-
-int caretProc (int id, int clientData) {
- if (currentCaret == null || currentCaret.isDisposed()) return 0;
- if (currentCaret.blinkCaret ()) {
- int blinkRate = currentCaret.blinkRate;
- if (blinkRate == 0) return 0;
- OS.SetEventLoopTimerNextFireTime (id, blinkRate / 1000.0);
- } else {
- currentCaret = null;
- }
- return 0;
-}
-
-protected void checkDevice () {
- if (thread == null) error (SWT.ERROR_WIDGET_DISPOSED);
- if (thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
-}
-
-/**
- * Checks that this class can be subclassed.
- * <p>
- * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Widget#checkSubclass
- */
-protected void checkSubclass () {
- if (!Display.isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-int[] createImage (int type) {
- int[] ref = new int [1];
- int result = OS.GetIconRef (OS.kOnSystemDisk, OS.kSystemIconsCreator, type, ref);
- if (result != OS.noErr) return null;
- int[] family = new int [1];
- result = OS.IconRefToIconFamily (ref [0], OS.kSelectorAlLAvailableData, family);
- OS.ReleaseIconRef (ref [0]);
- if (result != OS.noErr) return null;
- int[] image = createImageFromFamily (family [0], OS.kLarge32BitData, OS.kLarge8BitMask, 32, 32);
- OS.DisposeHandle (family [0]);
- return image;
-}
-
-int[] createImageFromFamily (int family, int type, int maskType, int width, int height) {
- int dataHandle = OS.NewHandle (0);
- int result = OS.GetIconFamilyData (family, type, dataHandle);
- if (result != OS.noErr) {
- OS.DisposeHandle (dataHandle);
- return null;
- }
- int maskHandle = OS.NewHandle (0);
- result = OS.GetIconFamilyData (family, maskType, maskHandle);
- if (result != OS.noErr) {
- OS.DisposeHandle (maskHandle);
- OS.DisposeHandle (dataHandle);
- return null;
- }
- int bpr = width * 4;
- int dataSize = OS.GetHandleSize (dataHandle);
- int data = OS.NewPtrClear (dataSize);
- if (data == 0) {
- OS.DisposeHandle (maskHandle);
- OS.DisposeHandle (dataHandle);
- return null;
- }
- OS.HLock (dataHandle);
- OS.HLock (maskHandle);
- int[] iconPtr = new int [1];
- int[] maskPtr = new int [1];
- OS.memcpy (iconPtr, dataHandle, 4);
- OS.memcpy (maskPtr, maskHandle, 4);
- OS.memcpy (data, iconPtr [0], dataSize);
- int pixelCount = dataSize / 4;
- for (int i = 0; i < pixelCount; i++) {
- OS.memcpy (data + (i * 4), maskPtr [0] + i, 1);
- }
- OS.HUnlock (maskHandle);
- OS.HUnlock (dataHandle);
- OS.DisposeHandle (maskHandle);
- OS.DisposeHandle (dataHandle);
-
- int provider = OS.CGDataProviderCreateWithData (0, data, dataSize, 0);
- if (provider == 0) {
- OS.DisposePtr (data);
- return null;
- }
- int colorspace = OS.CGColorSpaceCreateDeviceRGB ();
- if (colorspace == 0) {
- OS.CGDataProviderRelease (provider);
- OS.DisposePtr (data);
- return null;
- }
- int cgImage = OS.CGImageCreate (width, height, 8, 32, bpr, colorspace, OS.kCGImageAlphaFirst, provider, null, true, 0);
- OS.CGColorSpaceRelease (colorspace);
- OS.CGDataProviderRelease (provider);
-
- return new int[] {cgImage, data};
-}
-
-int createOverlayWindow () {
- int gdevice = OS.GetMainDevice ();
- int [] ptr = new int [1];
- OS.memcpy (ptr, gdevice, 4);
- GDevice device = new GDevice ();
- OS.memcpy (device, ptr [0], GDevice.sizeof);
- Rect rect = new Rect ();
- OS.SetRect (rect, device.left, device.top, device.right, device.bottom);
- int [] outWindow = new int [1];
- OS.CreateNewWindow (OS.kOverlayWindowClass, 0, rect, outWindow);
- if (outWindow [0] == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- return outWindow [0];
-}
-
-/**
- * Constructs a new instance of this class.
- * <p>
- * Note: The resulting display is marked as the <em>current</em>
- * display. If this is the first display which has been
- * constructed since the application started, it is also
- * marked as the <em>default</em> display.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if called from a thread that already created an existing display</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see #getCurrent
- * @see #getDefault
- * @see Widget#checkSubclass
- * @see Shell
- */
-public Display () {
- this (null);
-}
-
-/**
- * Constructs a new instance of this class using the parameter.
- *
- * @param data the device data
- */
-public Display (DeviceData data) {
- super (data);
-}
-
-static synchronized void checkDisplay (Thread thread, boolean multiple) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] != null) {
- if (!multiple) SWT.error (SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]");
- if (Displays [i].thread == thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- }
-}
-
-int colorProc (int inControl, int inMessage, int inDrawDepth, int inDrawInColor) {
- Widget widget = getWidget (inControl);
- if (widget != null) return widget.colorProc (inControl, inMessage, inDrawDepth, inDrawInColor);
- return OS.eventNotHandledErr;
-}
-
-int commandProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- HICommand command = new HICommand ();
- OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeHICommand, null, HICommand.sizeof, null, command);
- switch (eventKind) {
- case OS.kEventProcessCommand: {
- if (command.commandID == OS.kAEQuitApplication) {
- if (!closing) close ();
- return OS.noErr;
- }
- if ((command.attributes & OS.kHICommandFromMenu) != 0) {
- if (userData != 0) {
- Widget widget = getWidget (userData);
- if (widget != null) return widget.commandProc (nextHandler, theEvent, userData);
- } else {
- int result = OS.eventNotHandledErr;
- int menuRef = command.menu_menuRef;
- short menuID = OS.GetMenuID (menuRef);
- Menu menu = getMenu (menuID);
- if (menu != null) {
- /*
- * Feature in the Macintosh. When a menu item is selected by the
- * user, the Macintosh sends kEventMenuOpening, remembers the index
- * of the item the user selected, sends kEventMenuClosed and then
- * sends kEventProcessCommand. If application code modifies the menu
- * inside of kEventMenuClosed by adding or removing items, the index
- * of the item that the user selected is invalid. The fix is to detect
- * that a menu has been modified during kEventMenuClosed and use the
- * last target item remembered kEventMenuTargetItem.
- */
- MenuItem item = null;
- if (menu.closed && menu.modified) {
- item = menu.lastTarget;
- } else {
- item = menu.getItem (command.menu_menuItemIndex - 1);
- }
- if (item != null) {
- result = item.kEventProcessCommand (nextHandler, theEvent, userData);
- }
- }
- OS.HiliteMenu ((short) 0);
- return result;
- }
- }
- }
- }
- return OS.eventNotHandledErr;
-}
-
-Rect computeInset (int control) {
- int tempRgn = OS.NewRgn ();
- Rect rect = new Rect ();
- OS.GetControlRegion (control, (short) OS.kControlStructureMetaPart, tempRgn);
- OS.GetControlBounds (control, rect);
- Rect rgnRect = new Rect ();
- OS.GetRegionBounds (tempRgn, rgnRect);
- OS.DisposeRgn (tempRgn);
- rect.left -= rgnRect.left;
- rect.top -= rgnRect.top;
- rect.right = (short) (rgnRect.right - rect.right);
- rect.bottom = (short) (rgnRect.bottom - rect.bottom);
- return rect;
-}
-
-int controlProc (int nextHandler, int theEvent, int userData) {
- Widget widget = getWidget (userData);
- if (widget != null) return widget.controlProc (nextHandler, theEvent, userData);
- return OS.eventNotHandledErr;
-}
-
-int accessibilityProc (int nextHandler, int theEvent, int userData) {
- Widget widget = getWidget (userData);
- if (widget != null) return widget.accessibilityProc (nextHandler, theEvent, userData);
- return OS.eventNotHandledErr;
-}
-
-static String convertToLf(String text) {
- char Cr = '\r';
- char Lf = '\n';
- int length = text.length ();
- if (length == 0) return text;
-
- /* Check for an LF or CR/LF. Assume the rest of the string
- * is formated that way. This will not work if the string
- * contains mixed delimiters. */
- int i = text.indexOf (Lf, 0);
- if (i == -1 || i == 0) return text;
- if (text.charAt (i - 1) != Cr) return text;
-
- /* The string is formatted with CR/LF.
- * Create a new string with the LF line delimiter. */
- i = 0;
- StringBuffer result = new StringBuffer ();
- while (i < length) {
- int j = text.indexOf (Cr, i);
- if (j == -1) j = length;
- String s = text.substring (i, j);
- result.append (s);
- i = j + 2;
- result.append (Lf);
- }
- return result.toString ();
-}
-
-void clearMenuFlags () {
- if (menus == null) return;
- for (int i=0; i<menus.length; i++) {
- Menu menu = menus [i];
- if (menu != null) {
- menu.modified = menu.closed = false;
- menu.lastTarget = null;
- }
- }
-}
-
-/**
- * Requests that the connection between SWT and the underlying
- * operating system be closed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Device#dispose
- *
- * @since 2.0
- */
-public void close () {
- checkDevice ();
- closing = true;
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit) dispose ();
-}
-
-/**
- * Creates the device in the operating system. If the device
- * does not have a handle, this method may do nothing depending
- * on the device.
- * <p>
- * This method is called before <code>init</code>.
- * </p>
- *
- * @param data the DeviceData which describes the receiver
- *
- * @see #init
- */
-protected void create (DeviceData data) {
- checkSubclass ();
- checkDisplay (thread = Thread.currentThread (), false);
- createDisplay (data);
- register (this);
- if (Default == null) Default = this;
-}
-
-void createDisplay (DeviceData data) {
- /*
- * Feature in the Macintosh. On OS 10.2, it is necessary
- * to explicitly check in with the Process Manager and set
- * the current process to be the front process in order for
- * windows to come to the front by default. The fix is call
- * both GetCurrentProcess() and SetFrontProcess().
- *
- * NOTE: It is not actually necessary to use the process
- * serial number returned by GetCurrentProcess() in the
- * call to SetFrontProcess() (ie. kCurrentProcess can be
- * used) but both functions must be called in order for
- * windows to come to the front.
- */
- int [] psn = new int [2];
- if (OS.GetCurrentProcess (psn) == OS.noErr) {
- int pid = OS.getpid ();
- byte [] buffer = null;
- int ptr = OS.getenv (ascii ("APP_NAME_" + pid));
- if (ptr != 0) {
- buffer = new byte [OS.strlen (ptr) + 1];
- OS.memcpy (buffer, ptr, buffer.length);
- } else {
- if (APP_NAME != null) {
- char [] chars = new char [APP_NAME.length ()];
- APP_NAME.getChars (0, chars.length, chars, 0);
- int cfstring = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length);
- if (cfstring != 0) {
- CFRange range = new CFRange ();
- range.length = chars.length;
- int encoding = OS.CFStringGetSystemEncoding ();
- int [] size = new int [1];
- int numChars = OS.CFStringGetBytes (cfstring, range, encoding, (byte) '?', true, null, 0, size);
- if (numChars != 0) {
- buffer = new byte [size [0] + 1];
- numChars = OS.CFStringGetBytes (cfstring, range, encoding, (byte) '?', true, buffer, size [0], size);
- }
- OS.CFRelease (cfstring);
- }
- }
- }
- if (buffer != null) OS.CPSSetProcessName (psn, buffer);
- OS.CPSEnableForegroundOperation (psn, 0x03, 0x3C, 0x2C, 0x1103);
- OS.SetFrontProcess (psn);
- ptr = OS.getenv (ascii ("APP_ICON_" + pid));
- if (ptr != 0) {
- int [] image = readImageRef (ptr);
- if (image != null) {
- dockImage = image [0];
- dockImageData = image [1];
- OS.SetApplicationDockTileImage (dockImage);
- }
- }
- }
- /*
- * Feature in the Macintosh. In order to get the standard
- * application menu to appear on the menu bar, an application
- * must manipulate the menu bar. If the application does not
- * install a menu bar, the application menu will not appear.
- * The fix is to use ClearMenuBar() to manipulate the menu
- * bar before any application has had a chance install a menu
- * bar.
- */
- OS.ClearMenuBar ();
- queue = OS.GetCurrentEventQueue ();
- OS.TXNInitTextension (0, 0, 0);
-
- /* Save the current highlight color */
- OS.RegisterAppearanceClient ();
- highlightColor = new RGBColor ();
- OS.GetThemeBrushAsColor ((short) OS.kThemeBrushPrimaryHighlightColor, (short) getDepth(), true, highlightColor);
-}
-
-synchronized static void deregister (Display display) {
- for (int i=0; i<Displays.length; i++) {
- if (display == Displays [i]) Displays [i] = null;
- }
-}
-
-/**
- * Destroys the device in the operating system and releases
- * the device's handle. If the device does not have a handle,
- * this method may do nothing depending on the device.
- * <p>
- * This method is called after <code>release</code>.
- * </p>
- * @see Device#dispose
- * @see #release
- */
-protected void destroy () {
- if (this == Default) Default = null;
- deregister (this);
- destroyDisplay ();
-}
-
-void destroyDisplay () {
-}
-
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread just before the
- * receiver is disposed. Specifying a <code>null</code> runnable
- * is ignored.
- *
- * @param runnable code to run at dispose time.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void disposeExec (Runnable runnable) {
- checkDevice ();
- if (disposeList == null) disposeList = new Runnable [4];
- for (int i=0; i<disposeList.length; i++) {
- if (disposeList [i] == null) {
- disposeList [i] = runnable;
- return;
- }
- }
- Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
- System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
- newDisposeList [disposeList.length] = runnable;
- disposeList = newDisposeList;
-}
-
-void dragDetect (Control control) {
- if (!dragging && control.hooks (SWT.DragDetect) && dragMouseStart != null) {
- if (OS.WaitMouseMoved (dragMouseStart)) {
- dragging = true;
- Rect rect = new Rect ();
- int window = OS.GetControlOwner (control.handle);
- int x, y;
- if (OS.HIVIEW) {
- CGPoint pt = new CGPoint ();
- pt.x = dragMouseStart.h;
- pt.y = dragMouseStart.v;
- OS.HIViewConvertPoint (pt, 0, control.handle);
- x = (int) pt.x;
- y = (int) pt.y;
- OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
- } else {
- OS.GetControlBounds (control.handle, rect);
- x = dragMouseStart.h - rect.left;
- y = dragMouseStart.v - rect.top;
- OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
- }
- x -= rect.left;
- y -= rect.top;
- control.sendDragEvent (x, y);
- dragMouseStart = null;
- }
- }
-}
-
-int drawItemProc (int browser, int item, int property, int itemState, int theRect, int gdDepth, int colorDevice) {
- Widget widget = getWidget (browser);
- if (widget != null) return widget.drawItemProc (browser, item, property, itemState, theRect, gdDepth, colorDevice);
- return OS.noErr;
-}
-
-void disposeWindows () {
- if (disposeWindow != 0) {
- OS.DisposeWindow (disposeWindow);
- disposeWindow = 0;
- }
- if (disposeWindowList != null) {
- for (int i = 0; i < disposeWindowList.length; i++) {
- if (disposeWindowList [i] != 0) {
- OS.DisposeWindow (disposeWindowList [i]);
- }
- }
- disposeWindowList = null;
- }
-}
-
-void error (int code) {
- SWT.error(code);
-}
-
-boolean filterEvent (Event event) {
- if (filterTable != null) filterTable.sendEvent (event);
- return false;
-}
-
-boolean filters (int eventType) {
- if (filterTable == null) return false;
- return filterTable.hooks (eventType);
-}
-
-/**
- * Given the operating system handle for a widget, returns
- * the instance of the <code>Widget</code> subclass which
- * represents it in the currently running application, if
- * such exists, or null if no matching widget can be found.
- * <p>
- * <b>IMPORTANT:</b> This method should not be called from
- * application code. The arguments are platform-specific.
- * </p>
- *
- * @param handle the handle for the widget
- * @return the SWT widget that the handle represents
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Widget findWidget (int handle) {
- checkDevice ();
- return getWidget (handle);
-}
-
-/**
- * Given the operating system handle for a widget,
- * and widget-specific id, returns the instance of
- * the <code>Widget</code> subclass which represents
- * the handle/id pair in the currently running application,
- * if such exists, or null if no matching widget can be found.
- * <p>
- * <b>IMPORTANT:</b> This method should not be called from
- * application code. The arguments are platform-specific.
- * </p>
- *
- * @param handle the handle for the widget
- * @param id the id for the subwidget (usually an item)
- * @return the SWT widget that the handle/id pair represents
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public Widget findWidget (int handle, int id) {
- return null;
-}
-
-/**
- * Returns the display which the given thread is the
- * user-interface thread for, or null if the given thread
- * is not a user-interface thread for any display. Specifying
- * <code>null</code> as the thread will return <code>null</code>
- * for the display.
- *
- * @param thread the user-interface thread
- * @return the display for the given thread
- */
-public static synchronized Display findDisplay (Thread thread) {
- for (int i=0; i<Displays.length; i++) {
- Display display = Displays [i];
- if (display != null && display.thread == thread) {
- return display;
- }
- }
- return null;
-}
-
-/**
- * Returns the currently active <code>Shell</code>, or null
- * if no shell belonging to the currently running application
- * is active.
- *
- * @return the active shell or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Shell getActiveShell () {
- checkDevice ();
- for (int i=0; i<widgetTable.length; i++) {
- Widget widget = widgetTable [i];
- if (widget != null && widget instanceof Shell) {
- Shell shell = (Shell) widget;
- if (OS.IsWindowActive (shell.shellHandle)) return shell;
- }
- }
- return null;
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location.
- *
- * @return the bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Rectangle getBounds () {
- checkDevice ();
- int gdevice = OS.GetDeviceList();
- if (gdevice == 0 || OS.GetNextDevice (gdevice) == 0) {
- return super.getBounds ();
- }
- Monitor [] monitors = getMonitors ();
- Rectangle rect = monitors [0].getBounds ();
- for (int i=1; i<monitors.length; i++) {
- rect = rect.union (monitors [i].getBounds ());
- }
- return rect;
-}
-
-/**
- * Returns the display which the currently running thread is
- * the user-interface thread for, or null if the currently
- * running thread is not a user-interface thread for any display.
- *
- * @return the current display
- */
-public static synchronized Display getCurrent () {
- return findDisplay (Thread.currentThread ());
-}
-
-int getCaretBlinkTime () {
-// checkDevice ();
- return OS.GetCaretTime () * 1000 / 60;
-}
-
-/**
- * Returns a rectangle which describes the area of the
- * receiver which is capable of displaying data.
- *
- * @return the client area
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #getBounds
- */
-public Rectangle getClientArea () {
- checkDevice ();
- int gdevice = OS.GetDeviceList();
- if (gdevice == 0 || OS.GetNextDevice (gdevice) == 0) {
- return super.getClientArea ();
- }
- Monitor [] monitors = getMonitors ();
- Rectangle rect = monitors [0].getBounds ();
- for (int i=1; i<monitors.length; i++) {
- rect = rect.union (monitors [i].getBounds ());
- }
- return rect;
-}
-
-/**
- * Returns the control which the on-screen pointer is currently
- * over top of, or null if it is not currently over one of the
- * controls built by the currently running application.
- *
- * @return the control under the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Control getCursorControl () {
- org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point ();
- OS.GetGlobalMouse (where);
- int [] theWindow = new int [1];
- if (OS.FindWindow (where, theWindow) != OS.inContent) return null;
- if (theWindow [0] == 0) return null;
- Rect rect = new Rect ();
- OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, rect);
- CGPoint inPoint = new CGPoint ();
- inPoint.x = where.h - rect.left;
- inPoint.y = where.v - rect.top;
- int [] theRoot = new int [1];
- OS.GetRootControl (theWindow [0], theRoot);
- int [] theControl = new int [1];
- OS.HIViewGetSubviewHit (theRoot [0], inPoint, true, theControl);
- while (theControl [0] != 0 && !OS.IsControlEnabled (theControl [0])) {
- OS.GetSuperControl (theControl [0], theControl);
- }
- if (theControl [0] != 0) {
- do {
- Widget widget = getWidget (theControl [0]);
- if (widget != null) {
- if (widget instanceof Control) {
- Control control = (Control) widget;
- if (control.isEnabled ()) {
- return control.isEnabledModal () ? control : null;
- }
- }
- }
- OS.GetSuperControl (theControl [0], theControl);
- } while (theControl [0] != 0);
- }
- Widget widget = getWidget (theRoot [0]);
- if (widget != null && widget instanceof Control) return (Control) widget;
- return null;
-}
-
-/**
- * Returns the location of the on-screen pointer relative
- * to the top left corner of the screen.
- *
- * @return the cursor location
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Point getCursorLocation () {
- checkDevice ();
- org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point ();
- OS.GetGlobalMouse (pt);
- return new Point (pt.h, pt.v);
-}
-
-/**
- * Returns an array containing the recommended cursor sizes.
- *
- * @return the array of cursor sizes
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public Point [] getCursorSizes () {
- checkDevice ();
- return new Point [] {new Point (16, 16)};
-}
-
-/**
- * Returns the default display. One is created (making the
- * thread that invokes this method its user-interface thread)
- * if it did not already exist.
- *
- * @return the default display
- */
-public static synchronized Display getDefault () {
- if (Default == null) Default = new Display ();
- return Default;
-}
-
-/**
- * Returns the application defined property of the receiver
- * with the specified name, or null if it has not been set.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility to provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @return the value of the property or null if it has not been set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #setData(String, Object)
- * @see #disposeExec(Runnable)
- */
-public Object getData (String key) {
- checkDevice ();
- if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (keys == null) return null;
- for (int i=0; i<keys.length; i++) {
- if (keys [i].equals (key)) return values [i];
- }
- return null;
-}
-
-/**
- * Returns the application defined, display specific data
- * associated with the receiver, or null if it has not been
- * set. The <em>display specific data</em> is a single,
- * unnamed field that is stored with every display.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the display specific data needs to
- * be notified when the display is disposed of, it is the
- * application's responsibility to provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @return the display specific data
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #setData(Object)
- * @see #disposeExec(Runnable)
- */
-public Object getData () {
- checkDevice ();
- return data;
-}
-
-/**
- * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>.
- * The button dismissal alignment is the ordering that should be used when positioning the
- * default dismissal button for a dialog. For example, in a dialog that contains an OK and
- * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the
- * button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>,
- * the button ordering should be CANCEL/OK.
- *
- * @return the button dismissal order
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1
- */
-public int getDismissalAlignment () {
- checkDevice ();
- return SWT.RIGHT;
-}
-
-/**
- * Returns the longest duration, in milliseconds, between
- * two mouse button clicks that will be considered a
- * <em>double click</em> by the underlying operating system.
- *
- * @return the double click time
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getDoubleClickTime () {
- checkDevice ();
- return OS.GetDblTime () * 1000 / 60;
-}
-
-/**
- * Returns the control which currently has keyboard focus,
- * or null if keyboard events are not currently going to
- * any of the controls built by the currently running
- * application.
- *
- * @return the control under the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Control getFocusControl () {
- checkDevice ();
- if (focusControl != null && !focusControl.isDisposed ()) {
- return focusControl;
- }
- int theWindow = OS.GetUserFocusWindow ();
- if (theWindow == 0) return null;
- return getFocusControl (theWindow);
-}
-
-Control getFocusControl (int window) {
- int [] theControl = new int [1];
- OS.GetKeyboardFocus (window, theControl);
- if (theControl [0] == 0) return null;
- do {
- Widget widget = getWidget (theControl [0]);
- if (widget != null && widget instanceof Control) {
- Control control = (Control) widget;
- return control.isEnabled () ? control : null;
- }
- OS.GetSuperControl (theControl [0], theControl);
- } while (theControl [0] != 0);
- return null;
-}
-
-/**
- * Returns true when the high contrast mode is enabled.
- * Otherwise, false is returned.
- * <p>
- * Note: This operation is a hint and is not supported on
- * platforms that do not have this concept.
- * </p>
- *
- * @return the high contrast mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public boolean getHighContrast () {
- checkDevice ();
- return false;
-}
-
-/**
- * Returns the maximum allowed depth of icons on this display, in bits per pixel.
- * On some platforms, this may be different than the actual depth of the display.
- *
- * @return the maximum icon depth
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Device#getDepth
- */
-public int getIconDepth () {
- return getDepth ();
-}
-
-/**
- * Returns an array containing the recommended icon sizes.
- *
- * @return the array of icon sizes
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Decorations#setImages(Image[])
- *
- * @since 3.0
- */
-public Point [] getIconSizes () {
- checkDevice ();
- return new Point [] {
- new Point (16, 16), new Point (32, 32),
- new Point (64, 64), new Point (128, 128)};
-}
-
-int getLastEventTime () {
- /*
- * This code is intentionally commented. Event time is
- * in seconds and we need an accurate time in milliseconds.
- */
-// return (int) (OS.GetLastUserEventTime () * 1000.0);
- return (int) System.currentTimeMillis ();
-}
-
-Menu [] getMenus (Decorations shell) {
- if (menus == null) return new Menu [0];
- int count = 0;
- for (int i = 0; i < menus.length; i++) {
- Menu menu = menus[i];
- if (menu != null && menu.parent == shell) count++;
- }
- int index = 0;
- Menu[] result = new Menu[count];
- for (int i = 0; i < menus.length; i++) {
- Menu menu = menus[i];
- if (menu != null && menu.parent == shell) {
- result[index++] = menu;
- }
- }
- return result;
-}
-
-Menu getMenu (int id) {
- if (menus == null) return null;
- int index = id - ID_START;
- if (0 <= index && index < menus.length) return menus [index];
- return null;
-}
-
-Menu getMenuBar () {
- return menuBar;
-}
-
-int getMessageCount () {
- return synchronizer.getMessageCount ();
-}
-
-/**
- * Returns an array of monitors attached to the device.
- *
- * @return the array of monitors
- *
- * @since 3.0
- */
-public Monitor [] getMonitors () {
- checkDevice ();
- int count = 0;
- Monitor [] monitors = new Monitor [1];
- Rect rect = new Rect ();
- GDevice device = new GDevice ();
- int gdevice = OS.GetDeviceList ();
- while (gdevice != 0) {
- if (count >= monitors.length) {
- Monitor [] newMonitors = new Monitor [monitors.length + 4];
- System.arraycopy (monitors, 0, newMonitors, 0, monitors.length);
- monitors = newMonitors;
- }
- Monitor monitor = new Monitor ();
- monitor.handle = gdevice;
- int [] ptr = new int [1];
- OS.memcpy (ptr, gdevice, 4);
- OS.memcpy (device, ptr [0], GDevice.sizeof);
- monitor.x = device.left;
- monitor.y = device.top;
- monitor.width = device.right - device.left;
- monitor.height = device.bottom - device.top;
- OS.GetAvailableWindowPositioningBounds (gdevice, rect);
- monitor.clientX = rect.left;
- monitor.clientY = rect.top;
- monitor.clientWidth = rect.right - rect.left;
- monitor.clientHeight = rect.bottom - rect.top;
- monitors [count++] = monitor;
- gdevice = OS.GetNextDevice (gdevice);
- }
- if (count < monitors.length) {
- Monitor [] newMonitors = new Monitor [count];
- System.arraycopy (monitors, 0, newMonitors, 0, count);
- monitors = newMonitors;
- }
- return monitors;
-}
-
-/**
- * Returns the primary monitor for that device.
- *
- * @return the primary monitor
- *
- * @since 3.0
- */
-public Monitor getPrimaryMonitor () {
- checkDevice ();
- int gdevice = OS.GetMainDevice ();
- Monitor monitor = new Monitor ();
- monitor.handle = gdevice;
- int [] ptr = new int [1];
- OS.memcpy (ptr, gdevice, 4);
- GDevice device = new GDevice ();
- OS.memcpy (device, ptr [0], GDevice.sizeof);
- monitor.x = device.left;
- monitor.y = device.top;
- monitor.width = device.right - device.left;
- monitor.height = device.bottom - device.top;
- Rect rect = new Rect ();
- OS.GetAvailableWindowPositioningBounds (gdevice, rect);
- monitor.clientX = rect.left;
- monitor.clientY = rect.top;
- monitor.clientWidth = rect.right - rect.left;
- monitor.clientHeight = rect.bottom - rect.top;
- return monitor;
-}
-
-/**
- * Returns a (possibly empty) array containing all shells which have
- * not been disposed and have the receiver as their display.
- *
- * @return the receiver's shells
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Shell [] getShells () {
- checkDevice ();
- int index = 0;
- Shell [] result = new Shell [16];
- for (int i = 0; i < widgetTable.length; i++) {
- Widget widget = widgetTable [i];
- if (widget != null && widget instanceof Shell) {
- int j = 0;
- while (j < index) {
- if (result [j] == widget) break;
- j++;
- }
- if (j == index) {
- if (index == result.length) {
- Shell [] newResult = new Shell [index + 16];
- System.arraycopy (result, 0, newResult, 0, index);
- result = newResult;
- }
- result [index++] = (Shell) widget;
- }
- }
- }
- if (index == result.length) return result;
- Shell [] newResult = new Shell [index];
- System.arraycopy (result, 0, newResult, 0, index);
- return newResult;
-}
-
-/**
- * Returns the thread that has invoked <code>syncExec</code>
- * or null if no such runnable is currently being invoked by
- * the user-interface thread.
- * <p>
- * Note: If a runnable invoked by asyncExec is currently
- * running, this method will return null.
- * </p>
- *
- * @return the receiver's sync-interface thread
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Thread getSyncThread () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- return synchronizer.syncThread;
-}
-
-/**
- * Returns the matching standard color for the given
- * constant, which should be one of the color constants
- * specified in class <code>SWT</code>. Any value other
- * than one of the SWT color constants which is passed
- * in will result in the color black. This color should
- * not be free'd because it was allocated by the system,
- * not the application.
- *
- * @param id the color constant
- * @return the matching color
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see SWT
- */
-public Color getSystemColor (int id) {
- checkDevice ();
- RGBColor rgb = new RGBColor ();
- switch (id) {
- case SWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
- case SWT.COLOR_INFO_BACKGROUND: return Color.carbon_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1});
- case SWT.COLOR_TITLE_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorDocumentWindowTitleActive, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_TITLE_BACKGROUND: OS.GetThemeBrushAsColor((short)-5/*undocumented darker highlight color*/, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: OS.GetThemeBrushAsColor((short)OS.kThemeBrushPrimaryHighlightColor, (short)getDepth(), true, rgb) ; break;
- case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorDocumentWindowTitleInactive, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushSecondaryHighlightColor, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: OS.GetThemeBrushAsColor((short)OS.kThemeBrushSecondaryHighlightColor, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_WIDGET_DARK_SHADOW: return Color.carbon_new (this, new float [] {0x33 / 255f, 0x33 / 255f, 0x33 / 255f, 1});
- case SWT.COLOR_WIDGET_NORMAL_SHADOW: return Color.carbon_new (this, new float [] {0x66 / 255f, 0x66 / 255f, 0x66 / 255f, 1});
- case SWT.COLOR_WIDGET_LIGHT_SHADOW: return Color.carbon_new (this, new float [] {0x99 / 255f, 0x99 / 255f, 0x99 / 255f, 1});
- case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: return Color.carbon_new (this, new float [] {0xCC / 255f, 0xCC / 255f, 0xCC / 255f, 1});
- case SWT.COLOR_WIDGET_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushButtonFaceActive, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_WIDGET_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorPushButtonActive, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_WIDGET_BORDER: return super.getSystemColor (SWT.COLOR_BLACK);
- case SWT.COLOR_LIST_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorListView, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_LIST_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushListViewBackground, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_LIST_SELECTION_TEXT: OS.GetThemeTextColor((short)OS.kThemeTextColorListView, (short)getDepth(), true, rgb); break;
- case SWT.COLOR_LIST_SELECTION: OS.GetThemeBrushAsColor((short)OS.kThemeBrushPrimaryHighlightColor, (short)getDepth(), true, rgb); break;
- default:
- return super.getSystemColor (id);
- }
- float red = ((rgb.red >> 8) & 0xFF) / 255f;
- float green = ((rgb.green >> 8) & 0xFF) / 255f;
- float blue = ((rgb.blue >> 8) & 0xFF) / 255f;
- return Color.carbon_new (this, new float[]{red, green, blue, 1});
-}
-
-/**
- * Returns the matching standard platform cursor for the given
- * constant, which should be one of the cursor constants
- * specified in class <code>SWT</code>. This cursor should
- * not be free'd because it was allocated by the system,
- * not the application. A value of <code>null</code> will
- * be returned if the supplied constant is not an SWT cursor
- * constant.
- *
- * @param id the SWT cursor constant
- * @return the corresponding cursor or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see SWT#CURSOR_ARROW
- * @see SWT#CURSOR_WAIT
- * @see SWT#CURSOR_CROSS
- * @see SWT#CURSOR_APPSTARTING
- * @see SWT#CURSOR_HELP
- * @see SWT#CURSOR_SIZEALL
- * @see SWT#CURSOR_SIZENESW
- * @see SWT#CURSOR_SIZENS
- * @see SWT#CURSOR_SIZENWSE
- * @see SWT#CURSOR_SIZEWE
- * @see SWT#CURSOR_SIZEN
- * @see SWT#CURSOR_SIZES
- * @see SWT#CURSOR_SIZEE
- * @see SWT#CURSOR_SIZEW
- * @see SWT#CURSOR_SIZENE
- * @see SWT#CURSOR_SIZESE
- * @see SWT#CURSOR_SIZESW
- * @see SWT#CURSOR_SIZENW
- * @see SWT#CURSOR_UPARROW
- * @see SWT#CURSOR_IBEAM
- * @see SWT#CURSOR_NO
- * @see SWT#CURSOR_HAND
- *
- * @since 3.0
- */
-public Cursor getSystemCursor (int id) {
- checkDevice ();
- if (!(0 <= id && id < cursors.length)) return null;
- if (cursors [id] == null) {
- cursors [id] = new Cursor (this, id);
- }
- return cursors [id];
-}
-
-/**
- * Returns the matching standard platform image for the given
- * constant, which should be one of the icon constants
- * specified in class <code>SWT</code>. This image should
- * not be free'd because it was allocated by the system,
- * not the application. A value of <code>null</code> will
- * be returned either if the supplied constant is not an
- * SWT icon constant or if the platform does not define an
- * image that corresponds to the constant.
- *
- * @param id the SWT icon constant
- * @return the corresponding image or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see SWT#ICON_ERROR
- * @see SWT#ICON_INFORMATION
- * @see SWT#ICON_QUESTION
- * @see SWT#ICON_WARNING
- * @see SWT#ICON_WORKING
- *
- * @since 3.0
- */
-public Image getSystemImage (int id) {
- checkDevice ();
- switch (id) {
- case SWT.ICON_ERROR: {
- if (errorImage != null) return errorImage;
- int [] image = createImage (OS.kAlertStopIcon);
- if (image == null) break;
- return errorImage = Image.carbon_new (this, SWT.ICON, image [0], image [1]);
- }
- case SWT.ICON_INFORMATION:
- case SWT.ICON_QUESTION:
- case SWT.ICON_WORKING: {
- if (infoImage != null) return infoImage;
- int [] image = createImage (OS.kAlertNoteIcon);
- if (image == null) break;
- return infoImage = Image.carbon_new (this, SWT.ICON, image [0], image [1]);
- }
- case SWT.ICON_WARNING: {
- if (warningImage != null) return warningImage;
- int [] image = createImage (OS.kAlertCautionIcon);
- if (image == null) break;
- return warningImage = Image.carbon_new (this, SWT.ICON, image [0], image [1]);
- }
- }
- return null;
-}
-
-/**
- * Returns the single instance of the system tray or null
- * when there is no system tray available for the platform.
- *
- * @return the system tray or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public Tray getSystemTray () {
- checkDevice ();
- return null;
-}
-
-/**
- * Returns the user-interface thread for the receiver.
- *
- * @return the receiver's user-interface thread
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Thread getThread () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- return thread;
-}
-
-Widget getWidget (int handle) {
- if (handle == 0) return null;
- property [0] = 0;
- OS.GetControlProperty (handle, SWT0, SWT0, 4, null, property);
- int index = property [0] - 1;
- if (0 <= index && index < widgetTable.length) return widgetTable [index];
- return null;
-}
-
-int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) {
- Widget widget = getWidget (inControl);
- if (widget != null) return widget.helpProc (inControl, inGlobalMouse, inRequest, outContentProvided, ioHelpContent);
- return OS.eventNotHandledErr;
-}
-
-int hitTestProc (int browser, int item, int property, int theRect, int mouseRect) {
- Widget widget = getWidget (browser);
- if (widget != null) return widget.hitTestProc (browser, item, property, theRect, mouseRect);
- return OS.noErr;
-}
-
-/**
- * Initializes any internal resources needed by the
- * device.
- * <p>
- * This method is called after <code>create</code>.
- * </p>
- *
- * @see #create
- */
-protected void init () {
- super.init ();
- initializeCallbacks ();
- initializeInsets ();
- initializeWidgetTable ();
- initializeFonts ();
-}
-
-void initializeCallbacks () {
- /* Create Callbacks */
- actionCallback = new Callback (this, "actionProc", 2);
- actionProc = actionCallback.getAddress ();
- if (actionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- appleEventCallback = new Callback (this, "appleEventProc", 3);
- appleEventProc = appleEventCallback.getAddress ();
- if (appleEventProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- caretCallback = new Callback(this, "caretProc", 2);
- caretProc = caretCallback.getAddress();
- if (caretProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- commandCallback = new Callback (this, "commandProc", 3);
- commandProc = commandCallback.getAddress ();
- if (commandProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- controlCallback = new Callback (this, "controlProc", 3);
- controlProc = controlCallback.getAddress ();
- if (controlProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- accessibilityCallback = new Callback (this, "accessibilityProc", 3);
- accessibilityProc = accessibilityCallback.getAddress ();
- if (accessibilityProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- drawItemCallback = new Callback (this, "drawItemProc", 7);
- drawItemProc = drawItemCallback.getAddress ();
- if (drawItemProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- itemCompareCallback = new Callback (this, "itemCompareProc", 4);
- itemCompareProc = itemCompareCallback.getAddress ();
- if (itemCompareProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- itemDataCallback = new Callback (this, "itemDataProc", 5);
- itemDataProc = itemDataCallback.getAddress ();
- if (itemDataProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- itemNotificationCallback = new Callback (this, "itemNotificationProc", 3);
- itemNotificationProc = itemNotificationCallback.getAddress ();
- if (itemNotificationProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- helpCallback = new Callback (this, "helpProc", 5);
- helpProc = helpCallback.getAddress ();
- if (helpProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- hitTestCallback = new Callback (this, "hitTestProc", 5);
- hitTestProc = hitTestCallback.getAddress ();
- if (hitTestProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- keyboardCallback = new Callback (this, "keyboardProc", 3);
- keyboardProc = keyboardCallback.getAddress ();
- if (keyboardProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- menuCallback = new Callback (this, "menuProc", 3);
- menuProc = menuCallback.getAddress ();
- if (menuProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- mouseHoverCallback = new Callback (this, "mouseHoverProc", 2);
- mouseHoverProc = mouseHoverCallback.getAddress ();
- if (mouseHoverProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- mouseCallback = new Callback (this, "mouseProc", 3);
- mouseProc = mouseCallback.getAddress ();
- if (mouseProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- timerCallback = new Callback (this, "timerProc", 2);
- timerProc = timerCallback.getAddress ();
- if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- trackingCallback = new Callback (this, "trackingProc", 6);
- trackingProc = trackingCallback.getAddress ();
- if (trackingProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- windowCallback = new Callback (this, "windowProc", 3);
- windowProc = windowCallback.getAddress ();
- if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- colorCallback = new Callback (this, "colorProc", 4);
- colorProc = colorCallback.getAddress ();
- if (colorProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- textInputCallback = new Callback (this, "textInputProc", 3);
- textInputProc = textInputCallback.getAddress ();
- if (textInputProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- appearanceCallback = new Callback (this, "appearanceProc", 3);
- appearanceProc = appearanceCallback.getAddress ();
- if (appearanceProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
-
- /* Install Event Handlers */
- int[] mask1 = new int[] {
- OS.kEventClassCommand, OS.kEventProcessCommand,
- };
- int appTarget = OS.GetApplicationEventTarget ();
- OS.InstallEventHandler (appTarget, commandProc, mask1.length / 2, mask1, 0, null);
- int[] mask2 = new int[] {
- OS.kEventClassMouse, OS.kEventMouseDown,
- OS.kEventClassMouse, OS.kEventMouseDragged,
-// OS.kEventClassMouse, OS.kEventMouseEntered,
-// OS.kEventClassMouse, OS.kEventMouseExited,
- OS.kEventClassMouse, OS.kEventMouseMoved,
- OS.kEventClassMouse, OS.kEventMouseUp,
- OS.kEventClassMouse, OS.kEventMouseWheelMoved,
- };
- OS.InstallEventHandler (appTarget, mouseProc, mask2.length / 2, mask2, 0, null);
- int [] mask3 = new int[] {
- OS.kEventClassApplication, OS.kEventAppAvailableWindowBoundsChanged,
- OS.kEventClassAppleEvent, OS.kEventAppleEvent,
- };
- OS.InstallEventHandler (appTarget, appleEventProc, mask3.length / 2, mask3, 0, null);
- int [] mask4 = new int[] {
- OS.kEventClassKeyboard, OS.kEventRawKeyDown,
- OS.kEventClassKeyboard, OS.kEventRawKeyModifiersChanged,
- OS.kEventClassKeyboard, OS.kEventRawKeyRepeat,
- OS.kEventClassKeyboard, OS.kEventRawKeyUp,
- };
- int focusTarget = OS.GetUserFocusEventTarget ();
- OS.InstallEventHandler (focusTarget, keyboardProc, mask4.length / 2, mask4, 0, null);
- int [] mask5 = new int[] {
- OS.kEventClassTextInput, OS.kEventTextInputUnicodeForKeyEvent,
- };
- OS.InstallEventHandler (focusTarget, textInputProc, mask5.length / 2, mask5, 0, null);
- OS.AEInstallEventHandler (OS.kAppearanceEventClass, OS.kAEAppearanceChanged, appearanceProc, 0, false);
- OS.AEInstallEventHandler (OS.kAppearanceEventClass, OS.kAESmallSystemFontChanged, appearanceProc, 0, false);
- OS.AEInstallEventHandler (OS.kAppearanceEventClass, OS.kAESystemFontChanged, appearanceProc, 0, false);
- OS.AEInstallEventHandler (OS.kAppearanceEventClass, OS.kAEViewsFontChanged, appearanceProc, 0, false);
-}
-
-void initializeFonts () {
- //TEMPORARY CODE
- smallFonts = System.getProperty("org.eclipse.swt.internal.carbon.smallFonts") != null;
- noFocusRing = System.getProperty("org.eclipse.swt.internal.carbon.noFocusRing") != null;
-}
-
-void initializeInsets () {
- int [] outControl = new int [1];
- Rect rect = new Rect ();
- rect.right = rect.bottom = (short) 200;
-
- OS.CreatePushButtonControl (0, rect, 0, outControl);
- buttonInset = computeInset (outControl [0]);
- OS.DisposeControl (outControl [0]);
-
- OS.CreateTabsControl (0, rect, (short)OS.kControlTabSizeLarge, (short)OS.kControlTabDirectionNorth, (short) 0, 0, outControl);
- tabFolderNorthInset = computeInset (outControl [0]);
- OS.DisposeControl (outControl [0]);
-
- OS.CreateTabsControl (0, rect, (short)OS.kControlTabSizeLarge, (short)OS.kControlTabDirectionSouth, (short) 0, 0, outControl);
- tabFolderSouthInset = computeInset (outControl [0]);
- OS.DisposeControl (outControl [0]);
-
- /* For some reason, this code calculates insets too big. */
-// OS.CreateEditUnicodeTextControl (0, rect, 0, false, null, outControl);
-// editTextInset = computeInset (outControl [0]);
-// OS.DisposeControl (outControl [0]);
- editTextInset = new Rect ();
- int [] outMetric = new int [1];
- OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric);
- int inset = outMetric [0];
- OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric);
- inset += outMetric [0];
- editTextInset.left = editTextInset.top = editTextInset.right = editTextInset.bottom = (short) inset;
-
- CGRect cgRect = new CGRect ();
- cgRect.width = cgRect.height = 200;
- int inAttributes = OS.kHIComboBoxAutoCompletionAttribute | OS.kHIComboBoxAutoSizeListAttribute;
- OS.HIComboBoxCreate (cgRect, 0, null, 0, inAttributes, outControl);
- comboInset = computeInset (outControl [0]);
- //FIXME -
- comboInset.bottom = comboInset.top;
- OS.DisposeControl (outControl [0]);
-}
-
-void initializeWidgetTable () {
- property = new int [1];
- indexTable = new int [GROW_SIZE];
- widgetTable = new Widget [GROW_SIZE];
- for (int i=0; i<GROW_SIZE-1; i++) indexTable [i] = i + 1;
- indexTable [GROW_SIZE - 1] = -1;
-}
-
-/**
- * Invokes platform specific functionality to allocate a new GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Display</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
- * </ul>
- */
-public int internal_new_GC (GCData data) {
- if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- //TODO - multiple monitors
- int window = gcWindow;
- if (window == 0) {
- window = gcWindow = createOverlayWindow ();
- } else {
- int gdevice = OS.GetMainDevice ();
- int [] ptr = new int [1];
- OS.memcpy (ptr, gdevice, 4);
- GDevice device = new GDevice ();
- OS.memcpy (device, ptr [0], GDevice.sizeof);
- Rect rect = new Rect ();
- OS.SetRect (rect, device.left, device.top, device.right, device.bottom);
- OS.SetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
- }
- int port = OS.GetWindowPort (window);
- int [] buffer = new int [1];
- OS.CreateCGContextForPort (port, buffer);
- int context = buffer [0];
- if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- Rect portRect = new Rect ();
- OS.GetPortBounds (port, portRect);
- OS.CGContextScaleCTM (context, 1, -1);
- OS.CGContextTranslateCTM (context, 0, portRect.top - portRect.bottom);
- if (data != null) {
- int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- if ((data.style & mask) == 0) {
- data.style |= SWT.LEFT_TO_RIGHT;
- }
- data.device = this;
- data.window = window;
- data.background = getSystemColor (SWT.COLOR_WHITE).handle;
- data.foreground = getSystemColor (SWT.COLOR_BLACK).handle;
- data.font = getSystemFont ();
- data.updateClip = true;
- } else {
- OS.ShowWindow (window);
- }
- return context;
-}
-
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Display</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param hDC the platform specific GC handle
- * @param data the platform specific GC data
- */
-public void internal_dispose_GC (int context, GCData data) {
- if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- if (data != null) {
- int window = data.window;
- if (gcWindow == window) {
- OS.HideWindow (window);
- } else {
- OS.DisposeWindow (window);
- }
- data.window = 0;
- }
-
- /*
- * This code is intentionaly commented. Use CGContextSynchronize
- * instead of CGContextFlush to improve performance.
- */
-// OS.CGContextFlush (context);
- OS.CGContextSynchronize (context);
- OS.CGContextRelease (context);
-}
-
-static boolean isValidClass (Class clazz) {
- String name = clazz.getName ();
- int index = name.lastIndexOf ('.');
- return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
-}
-
-boolean isValidThread () {
- return thread == Thread.currentThread ();
-}
-
-int itemCompareProc (int browser, int itemOne, int itemTwo, int sortProperty) {
- Widget widget = getWidget (browser);
- if (widget != null) return widget.itemCompareProc (browser, itemOne, itemTwo, sortProperty);
- return OS.noErr;
-}
-
-int itemDataProc (int browser, int item, int property, int itemData, int setValue) {
- Widget widget = getWidget (browser);
- if (widget != null) return widget.itemDataProc (browser, item, property, itemData, setValue);
- return OS.noErr;
-}
-
-int itemNotificationProc (int browser, int item, int message) {
- Widget widget = getWidget (browser);
- if (widget != null) return widget.itemNotificationProc (browser, item, message);
- return OS.noErr;
-}
-
-int keyboardProc (int nextHandler, int theEvent, int userData) {
- int theWindow = OS.GetUserFocusWindow ();
- if (theWindow != 0) {
- int [] theControl = new int [1];
- OS.GetKeyboardFocus (theWindow, theControl);
- Widget widget = getWidget (theControl [0]);
- if (widget != null) return widget.keyboardProc (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-/**
- * Generate a low level system event.
- *
- * <code>post</code> is used to generate low level keyboard
- * and mouse events. The intent is to enable automated UI
- * testing by simulating the input from the user. Most
- * SWT applications should never need to call this method.
- * <p>
- * Note that this operation can fail when the operating system
- * fails to generate the event for any reason. For example,
- * this can happen when there is no such key or mouse button
- * or when the system event queue is full.
- * </p>
- * <p>
- * <b>Event Types:</b>
- * <p>KeyDown, KeyUp
- * <p>The following fields in the <code>Event</code> apply:
- * <ul>
- * <li>(in) type KeyDown or KeyUp</li>
- * <p> Either one of:
- * <li>(in) character a character that corresponds to a keyboard key</li>
- * <li>(in) keyCode the key code of the key that was typed,
- * as defined by the key code constants in class <code>SWT</code></li>
- * </ul>
- * <p>MouseDown, MouseUp</p>
- * <p>The following fields in the <code>Event</code> apply:
- * <ul>
- * <li>(in) type MouseDown or MouseUp
- * <li>(in) button the button that is pressed or released
- * </ul>
- * <p>MouseMove</p>
- * <p>The following fields in the <code>Event</code> apply:
- * <ul>
- * <li>(in) type MouseMove
- * <li>(in) x the x coordinate to move the mouse pointer to in screen coordinates
- * <li>(in) y the y coordinate to move the mouse pointer to in screen coordinates
- * </ul>
- * </dl>
- *
- * @param event the event to be generated
- *
- * @return true if the event was generated or false otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the event is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- *
- */
-public boolean post(Event event) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- int type = event.type;
- switch (type) {
- case SWT.KeyDown:
- case SWT.KeyUp: {
- int vKey = Display.untranslateKey (event.keyCode);
- if (vKey != 0) {
- return OS.CGPostKeyboardEvent (0, vKey, type == SWT.KeyDown) == 0;
- } else {
- vKey = -1;
- int kchrPtr = OS.GetScriptManagerVariable ((short) OS.smKCHRCache);
- int key = -1;
- int [] state = new int [1];
- int [] encoding = new int [1];
- short keyScript = (short) OS.GetScriptManagerVariable ((short) OS.smKeyScript);
- short regionCode = (short) OS.GetScriptManagerVariable ((short) OS.smRegionCode);
- if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, regionCode, null, encoding) == OS.paramErr) {
- if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, (short) OS.kTextRegionDontCare, null, encoding) == OS.paramErr) {
- encoding [0] = OS.kTextEncodingMacRoman;
- }
- }
- int [] encodingInfo = new int [1];
- OS.CreateUnicodeToTextInfoByEncoding (encoding [0], encodingInfo);
- if (encodingInfo [0] != 0) {
- char [] input = {event.character};
- byte [] buffer = new byte [2];
- OS.ConvertFromUnicodeToPString (encodingInfo [0], 2, input, buffer);
- OS.DisposeUnicodeToTextInfo (encodingInfo);
- key = buffer [1] & 0x7f;
- }
- if (key == -1) return false;
- for (int i = 0 ; i <= 0x7F ; i++) {
- int result1 = OS.KeyTranslate (kchrPtr, (short) (i | 512), state);
- int result2 = OS.KeyTranslate (kchrPtr, (short) i, state);
- if ((result1 & 0x7f) == key || (result2 & 0x7f) == key) {
- vKey = i;
- break;
- }
- }
- if (vKey == -1) return false;
- return OS.CGPostKeyboardEvent (key, vKey, type == SWT.KeyDown) == 0;
- }
- }
- case SWT.MouseDown:
- case SWT.MouseMove:
- case SWT.MouseUp: {
- CGPoint mouseCursorPosition = new CGPoint ();
- int chord = OS.GetCurrentEventButtonState ();
- if (type == SWT.MouseMove) {
- mouseCursorPosition.x = event.x;
- mouseCursorPosition.y = event.y;
- return OS.CGPostMouseEvent (mouseCursorPosition, true, 3, (chord & 0x1) != 0, (chord & 0x2) != 0, (chord & 0x4) != 0) == 0;
- } else {
- int button = event.button;
- if (button < 1 || button > 3) return false;
- boolean button1 = false, button2 = false, button3 = false;
- switch (button) {
- case 1: {
- button1 = type == SWT.MouseDown;
- button2 = (chord & 0x4) != 0;
- button3 = (chord & 0x2) != 0;
- break;
- }
- case 2: {
- button1 = (chord & 0x1) != 0;
- button2 = type == SWT.MouseDown;
- button3 = (chord & 0x2) != 0;
- break;
- }
- case 3: {
- button1 = (chord & 0x1) != 0;
- button2 = (chord & 0x4) != 0;
- button3 = type == SWT.MouseDown;
- break;
- }
- }
- org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point ();
- OS.GetGlobalMouse (pt);
- mouseCursorPosition.x = pt.h;
- mouseCursorPosition.y = pt.v;
- return OS.CGPostMouseEvent (mouseCursorPosition, true, 3, button1, button3, button2) == 0;
- }
- }
- }
- return false;
-}
-
-void postEvent (Event event) {
- /*
- * Place the event at the end of the event queue.
- * This code is always called in the Display's
- * thread so it must be re-enterant but does not
- * need to be synchronized.
- */
- if (eventQueue == null) eventQueue = new Event [4];
- int index = 0;
- int length = eventQueue.length;
- while (index < length) {
- if (eventQueue [index] == null) break;
- index++;
- }
- if (index == length) {
- Event [] newQueue = new Event [length + 4];
- System.arraycopy (eventQueue, 0, newQueue, 0, length);
- eventQueue = newQueue;
- }
- eventQueue [index] = event;
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param point to be mapped
- * @return point with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Point map (Control from, Control to, Point point) {
- checkDevice ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, point.x, point.y);
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param x coordinates to be mapped
- * @param y coordinates to be mapped
- * @return point with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Point map (Control from, Control to, int x, int y) {
- checkDevice ();
- if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- Point point = new Point (x, y);
- Rect rect = new Rect ();
- if (from != null) {
- int window = OS.GetControlOwner (from.handle);
- if (OS.HIVIEW) {
- CGPoint pt = new CGPoint ();
- OS.HIViewConvertPoint (pt, from.handle, 0);
- point.x += (int) pt.x;
- point.y += (int) pt.y;
- OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
- } else {
- OS.GetControlBounds (from.handle, rect);
- point.x += rect.left;
- point.y += rect.top;
- OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
- }
- point.x += rect.left;
- point.y += rect.top;
- Rect inset = from.getInset ();
- point.x -= inset.left;
- point.y -= inset.top;
- }
- if (to != null) {
- int window = OS.GetControlOwner (to.handle);
- if (OS.HIVIEW) {
- CGPoint pt = new CGPoint ();
- OS.HIViewConvertPoint (pt, to.handle, 0);
- point.x -= (int) pt.x;
- point.y -= (int) pt.y;
- OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
- } else {
- OS.GetControlBounds (to.handle, rect);
- point.x -= rect.left;
- point.y -= rect.top;
- OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
- }
- point.x -= rect.left;
- point.y -= rect.top;
- Rect inset = to.getInset ();
- point.x += inset.left;
- point.y += inset.top;
- }
- return point;
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param rectangle to be mapped
- * @return rectangle with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Rectangle map (Control from, Control to, Rectangle rectangle) {
- checkDevice ();
- if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param x coordinates to be mapped
- * @param y coordinates to be mapped
- * @param width coordinates to be mapped
- * @param height coordinates to be mapped
- * @return rectangle with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
- checkDevice ();
- if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- Rectangle rectangle = new Rectangle (x, y, width, height);
- Rect rect = new Rect ();
- if (from != null) {
- int window = OS.GetControlOwner (from.handle);
- if (OS.HIVIEW) {
- CGPoint pt = new CGPoint ();
- OS.HIViewConvertPoint (pt, from.handle, 0);
- rectangle.x += (int) pt.x;
- rectangle.y += (int) pt.y;
- OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
- } else {
- OS.GetControlBounds (from.handle, rect);
- rectangle.x += rect.left;
- rectangle.y += rect.top;
- OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
- }
- rectangle.x += rect.left;
- rectangle.y += rect.top;
- Rect inset = from.getInset ();
- rectangle.x -= inset.left;
- rectangle.y -= inset.top;
- }
- if (to != null) {
- int window = OS.GetControlOwner (to.handle);
- if (OS.HIVIEW) {
- CGPoint pt = new CGPoint ();
- OS.HIViewConvertPoint (pt, to.handle, 0);
- rectangle.x -= (int) pt.x;
- rectangle.y -= (int) pt.y;
- OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
- } else {
- OS.GetControlBounds (to.handle, rect);
- rectangle.x -= rect.left;
- rectangle.y -= rect.top;
- OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
- }
- rectangle.x -= rect.left;
- rectangle.y -= rect.top;
- Rect inset = to.getInset ();
- rectangle.x += inset.left;
- rectangle.y += inset.top;
- }
- return rectangle;
-}
-
-int menuProc (int nextHandler, int theEvent, int userData) {
- short menuID = 0;
- if (userData != 0) {
- menuID = OS.GetMenuID (userData);
- } else {
- int [] theMenu = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeMenuRef, null, 4, null, theMenu);
- menuID = OS.GetMenuID (theMenu [0]);
- }
- Menu menu = getMenu (menuID);
- if (menu != null) return menu.menuProc (nextHandler, theEvent, userData);
- return OS.eventNotHandledErr;
-}
-
-int mouseProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventMouseDown:
- short [] buttonData = new short [1];
- OS.GetEventParameter (theEvent, OS.kEventParamMouseButton, OS.typeMouseButton, null, 2, null, buttonData);
- int [] clickCountData = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamClickCount, OS.typeUInt32, null, 4, null, clickCountData);
- clickCount = clickCountButton == buttonData [0] ? clickCountData [0] : 1;
- clickCountButton = buttonData [0];
- break;
- case OS.kEventMouseDragged:
- case OS.kEventMouseMoved:
- mouseMoved = true;
- }
- if (mouseUpControl != null && eventKind == OS.kEventMouseUp) {
- if (!mouseUpControl.isDisposed ()) {
- mouseUpControl.mouseProc (nextHandler, theEvent, userData);
- mouseUpControl = null;
- return OS.noErr;
- }
- mouseUpControl = null;
- }
- int sizeof = org.eclipse.swt.internal.carbon.Point.sizeof;
- org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point ();
- OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, sizeof, null, where);
- int [] theWindow = new int [1];
- int part = OS.FindWindow (where, theWindow);
- switch (part) {
- case OS.inMenuBar: {
- if (eventKind == OS.kEventMouseDown) {
- clearMenuFlags ();
- if (menuBar == null || menuBar.isEnabled ()) {
- OS.MenuSelect (where);
- }
- clearMenuFlags ();
- return OS.noErr;
- }
- break;
- }
- case OS.inContent: {
- Rect windowRect = new Rect ();
- OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, windowRect);
- CGPoint inPoint = new CGPoint ();
- inPoint.x = where.h - windowRect.left;
- inPoint.y = where.v - windowRect.top;
- if (OS.HIVIEW) {
- int root = OS.HIViewGetRoot (theWindow [0]);
- int [] buffer = new int [1];
- OS.HIViewGetViewForMouseEvent (root, theEvent, buffer);
- int view = buffer [0];
- OS.HIViewFindByID (root, OS.kHIViewWindowContentID (), buffer);
- int contentView = buffer [0];
- while (view != 0 && view != contentView && !OS.IsControlEnabled (view)) {
- view = OS.HIViewGetSuperview (view);
- }
- Widget widget = null;
- boolean consume = false;
- do {
- widget = getWidget (view);
- if (widget != null) {
- if (widget.isEnabled ()) break;
- consume = true;
- }
- view = OS.HIViewGetSuperview (view);
- } while (view != 0 && view != contentView);
- if (widget != null) {
- if (widget.contains ((int) inPoint.x, (int) inPoint.y)) {
- int result = userData != 0 ? widget.mouseProc (nextHandler, theEvent, userData) : OS.eventNotHandledErr;
- return consume ? OS.noErr : result;
- }
- }
- } else {
- int [] theRoot = new int [1];
- OS.GetRootControl (theWindow [0], theRoot);
- int [] theControl = new int [1];
- OS.HIViewGetSubviewHit (theRoot [0], inPoint, true, theControl);
- while (theControl [0] != 0 && !OS.IsControlEnabled (theControl [0])) {
- OS.GetSuperControl (theControl [0], theControl);
- }
- Widget widget = null;
- boolean consume = false;
- if (theControl [0] == 0) theControl [0] = theRoot [0];
- do {
- widget = getWidget (theControl [0]);
- if (widget != null) {
- if (widget.isEnabled ()) break;
- consume = true;
- }
- OS.GetSuperControl (theControl [0], theControl);
- } while (theControl [0] != 0);
- if (theControl [0] == 0) widget = getWidget (theRoot [0]);
- if (widget != null) {
- if (widget.contains ((int) inPoint.x, (int) inPoint.y)) {
- int result = userData != 0 ? widget.mouseProc (nextHandler, theEvent, userData) : OS.eventNotHandledErr;
- return consume ? OS.noErr : result;
- }
- }
- }
- break;
- }
- }
- switch (eventKind) {
- case OS.kEventMouseDragged:
- case OS.kEventMouseMoved: OS.InitCursor ();
- }
- return OS.eventNotHandledErr;
-}
-
-int mouseHoverProc (int id, int handle) {
- OS.RemoveEventLoopTimer (id);
- mouseHoverID = 0;
- mouseMoved = false;
- if (currentControl != null && !currentControl.isDisposed ()) {
- //OPTIMIZE - use OS calls
- int chord = OS.GetCurrentEventButtonState ();
- int modifiers = OS.GetCurrentEventKeyModifiers ();
- Point pt = currentControl.toControl (getCursorLocation ());
- currentControl.sendMouseEvent (SWT.MouseHover, (short)0, true, chord, (short)pt.x, (short)pt.y, modifiers);
- }
- return 0;
-}
-
-int[] readImageRef(int path) {
- int[] image = null;
- int url = OS.CFURLCreateFromFileSystemRepresentation(OS.kCFAllocatorDefault, path, OS.strlen(path), false);
- if (url != 0) {
- int extention = OS.CFURLCopyPathExtension(url);
- if (extention != 0) {
- int length = OS.CFStringGetLength(extention);
- char[] buffer = new char[length];
- CFRange range = new CFRange();
- range.length = length;
- OS.CFStringGetCharacters(extention, range, buffer);
- String ext = new String(buffer);
- if (ext.equalsIgnoreCase("png")) {
- int provider = OS.CGDataProviderCreateWithURL(url);
- if (provider != 0) {
- image = new int[]{OS.CGImageCreateWithPNGDataProvider(provider, null, true, OS.kCGRenderingIntentDefault), 0};
- OS.CGDataProviderRelease(provider);
- }
- } else if (ext.equalsIgnoreCase("jpeg") || ext.equals("jpg")) {
- int provider = OS.CGDataProviderCreateWithURL(url);
- if (provider != 0) {
- image = new int[]{OS.CGImageCreateWithJPEGDataProvider(provider, null, true, OS.kCGRenderingIntentDefault), 0};
- OS.CGDataProviderRelease(provider);
- }
- } else if (ext.equalsIgnoreCase("icns")) {
- byte[] fsRef = new byte[80];
- if (OS.CFURLGetFSRef(url, fsRef)) {
- byte[] fsSpec = new byte[70];
- if (OS.FSGetCatalogInfo(fsRef, 0, null, null, fsSpec, null) == OS.noErr) {
- int[] iconFamily = new int[1];
- OS.ReadIconFile(fsSpec, iconFamily);
- if (iconFamily[0] != 0) {
- image = createImageFromFamily(iconFamily[0], OS.kThumbnail32BitData, OS.kThumbnail8BitMask, 128, 128);
- OS.DisposeHandle(iconFamily[0]);
- }
- }
- }
- }
- OS.CFRelease(extention);
- }
- OS.CFRelease(url);
- }
- return image;
-}
-
-
-/**
- * Reads an event from the operating system's event queue,
- * dispatches it appropriately, and returns <code>true</code>
- * if there is potentially more work to do, or <code>false</code>
- * if the caller can sleep until another event is placed on
- * the event queue.
- * <p>
- * In addition to checking the system event queue, this method also
- * checks if any inter-thread messages (created by <code>syncExec()</code>
- * or <code>asyncExec()</code>) are waiting to be processed, and if
- * so handles them before returning.
- * </p>
- *
- * @return <code>false</code> if the caller can sleep upon return from this method
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
- * </ul>
- *
- * @see #sleep
- * @see #wake
- */
-public boolean readAndDispatch () {
- checkDevice ();
- boolean events = false;
- events |= runSettings ();
- events |= runTimers ();
- events |= runEnterExit ();
- events |= runPopups ();
- events |= runGrabs ();
- int [] outEvent = new int [1];
- int status = OS.ReceiveNextEvent (0, null, OS.kEventDurationNoWait, true, outEvent);
- if (status == OS.noErr) {
- events = true;
- int eventClass = OS.GetEventClass (outEvent [0]);
- int eventKind = OS.GetEventKind (outEvent [0]);
- OS.SendEventToEventTarget (outEvent [0], OS.GetEventDispatcherTarget ());
- OS.ReleaseEvent (outEvent [0]);
-
- /*
- * Feature in the Macintosh. HIComboBox does not send any
- * notification when the selection changes. The fix is to
- * detect if the combo text has changed after every event
- * has been dispatched. This is only necessary when the
- * combo has focus.
- */
- if (focusCombo != null && !focusCombo.isDisposed ()) {
- focusCombo.checkSelection ();
- }
-
- /*
- * Feature in the Macintosh. When an indeterminate progress
- * bar is running, it floods the event queue with messages in
- * order to show the animation. This means that async messages
- * will never run because there are always messages from the
- * operating system. The fix is to run async messages when ever
- * there is a wake message.
- *
- * NOTE: This is not the correct behavior. Operating system
- * messages are supposed to have priority over async messages.
- */
- if (eventClass == WAKE_CLASS && eventKind == WAKE_KIND) {
- runAsyncMessages (false);
- }
- }
- events |= runPaint ();
- if (events) {
- runDeferredEvents ();
- return true;
- }
- return runAsyncMessages (false);
-}
-
-static synchronized void register (Display display) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] == null) {
- Displays [i] = display;
- return;
- }
- }
- Display [] newDisplays = new Display [Displays.length + 4];
- System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
- newDisplays [Displays.length] = display;
- Displays = newDisplays;
-}
-
-/**
- * Releases any internal resources back to the operating
- * system and clears all fields except the device handle.
- * <p>
- * Disposes all shells which are currently open on the display.
- * After this method has been invoked, all related related shells
- * will answer <code>true</code> when sent the message
- * <code>isDisposed()</code>.
- * </p><p>
- * When a device is destroyed, resources that were acquired
- * on behalf of the programmer need to be returned to the
- * operating system. For example, if the device allocated a
- * font to be used as the system font, this font would be
- * freed in <code>release</code>. Also,to assist the garbage
- * collector and minimize the amount of memory that is not
- * reclaimed when the programmer keeps a reference to a
- * disposed device, all fields except the handle are zero'd.
- * The handle is needed by <code>destroy</code>.
- * </p>
- * This method is called before <code>destroy</code>.
- *
- * @see Device#dispose
- * @see #destroy
- */
-protected void release () {
- sendEvent (SWT.Dispose, new Event ());
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) shell.dispose ();
- }
- if (tray != null) tray.dispose ();
- tray = null;
- while (readAndDispatch ()) {}
- if (disposeList != null) {
- for (int i=0; i<disposeList.length; i++) {
- if (disposeList [i] != null) disposeList [i].run ();
- }
- }
- disposeList = null;
- synchronizer.releaseSynchronizer ();
- synchronizer = null;
- releaseDisplay ();
- super.release ();
-}
-
-void releaseDisplay () {
- disposeWindows ();
-
- if (gcWindow != 0) OS.DisposeWindow (gcWindow);
- gcWindow = 0;
-
- /* Release Timers */
- if (caretID != 0) OS.RemoveEventLoopTimer (caretID);
- if (mouseHoverID != 0) OS.RemoveEventLoopTimer (mouseHoverID);
- caretID = mouseHoverID = 0;
- if (timerIds != null) {
- for (int i=0; i<timerIds.length; i++) {
- if (timerIds [i] != 0 && timerIds [i] != -1) {
- OS.RemoveEventLoopTimer (timerIds [i]);
- }
- }
- }
- timerIds = null;
-
- actionCallback.dispose ();
- appleEventCallback.dispose ();
- caretCallback.dispose ();
- commandCallback.dispose ();
- controlCallback.dispose ();
- accessibilityCallback.dispose ();
- drawItemCallback.dispose ();
- itemCompareCallback.dispose ();
- itemDataCallback.dispose ();
- itemNotificationCallback.dispose ();
- helpCallback.dispose ();
- hitTestCallback.dispose ();
- keyboardCallback.dispose ();
- menuCallback.dispose ();
- mouseHoverCallback.dispose ();
- mouseCallback.dispose ();
- trackingCallback.dispose ();
- windowCallback.dispose ();
- colorCallback.dispose ();
- textInputCallback.dispose ();
- appearanceCallback.dispose ();
- actionCallback = appleEventCallback = caretCallback = commandCallback = appearanceCallback = null;
- accessibilityCallback = controlCallback = drawItemCallback = itemDataCallback = itemNotificationCallback = null;
- helpCallback = hitTestCallback = keyboardCallback = menuCallback = itemCompareCallback = null;
- mouseHoverCallback = mouseCallback = trackingCallback = windowCallback = colorCallback = null;
- textInputCallback = null;
- actionProc = appleEventProc = caretProc = commandProc = appearanceProc = 0;
- accessibilityProc = controlProc = drawItemProc = itemDataProc = itemNotificationProc = itemCompareProc = 0;
- helpProc = hitTestProc = keyboardProc = menuProc = 0;
- mouseHoverProc = mouseProc = trackingProc = windowProc = colorProc = 0;
- textInputProc = 0;
- timerCallback.dispose ();
- timerCallback = null;
- timerProc = 0;
- grabControl = currentControl = mouseUpControl = focusControl = focusCombo = null;
- helpWidget = null;
- if (helpString != 0) OS.CFRelease (helpString);
- helpString = 0;
- menus = popups = null;
- menuBar = null;
-
- /* Release the System Images */
- if (errorImage != null) errorImage.dispose ();
- if (infoImage != null) infoImage.dispose ();
- if (warningImage != null) warningImage.dispose ();
- errorImage = infoImage = warningImage = null;
-
- /* Release the System Cursors */
- for (int i = 0; i < cursors.length; i++) {
- if (cursors [i] != null) cursors [i].dispose ();
- }
- cursors = null;
-
- /* Release Dock image */
- if (dockImage != 0) OS.CGImageRelease (dockImage);
- if (dockImageData != 0) OS.DisposePtr (dockImageData);
- dockImage = dockImageData = 0;
-
- //NOT DONE - call terminate TXN if this is the last display
- //NOTE: - display create and dispose needs to be synchronized on all platforms
-// TXNTerminateTextension ();
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when an event of the given type occurs anywhere in
- * a widget. The event type is one of the event constants defined
- * in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #addFilter
- * @see #addListener
- *
- * @since 3.0
- */
-public void removeFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) return;
- filterTable.unhook (eventType, listener);
- if (filterTable.size () == 0) filterTable = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when an event of the given type occurs. The event type
- * is one of the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #addListener
- *
- * @since 2.0
- */
-public void removeListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, listener);
-}
-
-void removeMenu (Menu menu) {
- if (menus == null) return;
- menus [menu.id - ID_START] = null;
-}
-
-void removePopup (Menu menu) {
- if (popups == null) return;
- for (int i=0; i<popups.length; i++) {
- if (popups [i] == menu) {
- popups [i] = null;
- return;
- }
- }
-}
-
-Widget removeWidget (int handle) {
- if (handle == 0) return null;
- Widget widget = null;
- property [0] = 0;
- OS.GetControlProperty (handle, SWT0, SWT0, 4, null, property);
- int index = property [0] - 1;
- if (0 <= index && index < widgetTable.length) {
- widget = widgetTable [index];
- widgetTable [index] = null;
- indexTable [index] = freeSlot;
- freeSlot = index;
- OS.RemoveControlProperty (handle, SWT0, SWT0);
-
- }
- return widget;
-}
-
-boolean runAsyncMessages (boolean all) {
- return synchronizer.runAsyncMessages (all);
-}
-
-boolean runEnterExit () {
- //OPTIMIZE - no garbage, widget hit tested again in mouse move
- boolean eventSent = false;
- Control control = null;
- int [] theControl = new int [1];
- org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point ();
- OS.GetGlobalMouse (where);
- int [] theWindow = new int [1];
- if (OS.FindWindow (where, theWindow) == OS.inContent) {
- if (theWindow [0] != 0) {
- Rect rect = new Rect ();
- OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, rect);
- CGPoint inPoint = new CGPoint ();
- inPoint.x = where.h - rect.left;
- inPoint.y = where.v - rect.top;
- int [] theRoot = new int [1];
- OS.GetRootControl (theWindow [0], theRoot);
- OS.HIViewGetSubviewHit (theRoot [0], inPoint, true, theControl);
- while (theControl [0] != 0 && !OS.IsControlEnabled (theControl [0])) {
- OS.GetSuperControl (theControl [0], theControl);
- }
- boolean propagate = true;
- if (theControl [0] != 0) {
- do {
- Widget widget = getWidget (theControl [0]);
- if (widget != null) {
- if (widget instanceof Control) {
- Control cursorControl = (Control) widget;
- if (cursorControl.isEnabled ()) {
- if (cursorControl.isEnabledModal ()) {
- if (widget.isTrimHandle (theControl [0])) {
- propagate = false;
- break;
- }
- control = cursorControl;
- }
- break;
- }
- }
- }
- OS.GetSuperControl (theControl [0], theControl);
- } while (theControl [0] != 0);
- }
- if (control == null && propagate) {
- theControl [0] = theRoot [0];
- Widget widget = getWidget (theControl [0]);
- if (widget != null && widget instanceof Control) {
- Control cursorControl = (Control) widget;
- if (cursorControl.isEnabled ()) {
- if (cursorControl.isEnabledModal ()) {
- control = cursorControl;
- theControl[0] = control.handle;
- }
- }
- }
- }
- if (control != null && !control.contains ((int) inPoint.x, (int) inPoint.y)) {
- control = null;
- }
- }
- }
- if (control != currentControl) {
- if (currentControl != null && !currentControl.isDisposed ()) {
- eventSent = true;
- int chord = OS.GetCurrentEventButtonState ();
- int modifiers = OS.GetCurrentEventKeyModifiers ();
- Point pt = currentControl.toControl (where.h, where.v);
- currentControl.sendMouseEvent (SWT.MouseExit, (short)0, true, chord, (short)pt.x, (short)pt.y, modifiers);
- if (mouseHoverID != 0) OS.RemoveEventLoopTimer (mouseHoverID);
- mouseHoverID = 0;
- mouseMoved = false;
- }
- // widget could be disposed at this point
- if (control != null && control.isDisposed()) control = null;
- if ((currentControl = control) != null) {
- eventSent = true;
- int chord = OS.GetCurrentEventButtonState ();
- int modifiers = OS.GetCurrentEventKeyModifiers ();
- Point pt = currentControl.toControl (where.h, where.v);
- currentControl.sendMouseEvent (SWT.MouseEnter, (short)0, true, chord, (short)pt.x, (short)pt.y, modifiers);
- }
- }
- if (control != null && mouseMoved) {
- int [] outDelay = new int [1];
- OS.HMGetTagDelay (outDelay);
- if (mouseHoverID != 0) {
- OS.SetEventLoopTimerNextFireTime (mouseHoverID, outDelay [0] / 1000.0);
- } else {
- int eventLoop = OS.GetCurrentEventLoop ();
- int [] id = new int [1];
- OS.InstallEventLoopTimer (eventLoop, outDelay [0] / 1000.0, 0.0, mouseHoverProc, 0, id);
- mouseHoverID = id [0];
- }
- mouseMoved = false;
- }
- if (!OS.StillDown () && theWindow [0] != 0 && theControl [0] != 0) {
- Rect rect = new Rect ();
- OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, rect);
- where.h -= rect.left;
- where.v -= rect.top;
- int modifiers = OS.GetCurrentEventKeyModifiers ();
- boolean [] cursorWasSet = new boolean [1];
- OS.HandleControlSetCursor (theControl [0], where, (short) modifiers, cursorWasSet);
- //GOOGLE: Allow WebKit to maintain it's own cursor state.
- if (!cursorWasSet [0] && !(control instanceof Browser)) OS.SetThemeCursor (OS.kThemeArrowCursor);
- }
- return eventSent;
-}
-
-boolean runDeferredEvents () {
- /*
- * Run deferred events. This code is always
- * called in the Display's thread so it must
- * be re-enterant need not be synchronized.
- */
- while (eventQueue != null) {
-
- /* Take an event off the queue */
- Event event = eventQueue [0];
- if (event == null) break;
- int length = eventQueue.length;
- System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
- eventQueue [length] = null;
-
- /* Run the event */
- Widget widget = event.widget;
- if (widget != null && !widget.isDisposed ()) {
- Widget item = event.item;
- if (item == null || !item.isDisposed ()) {
- widget.notifyListeners (event.type, event);
- }
- }
-
- /*
- * At this point, the event queue could
- * be null due to a recursive invokation
- * when running the event.
- */
- }
-
- /* Clear the queue */
- eventQueue = null;
- return true;
-}
-
-boolean runEventLoopTimers () {
- allowTimers = false;
- boolean result = OS.ReceiveNextEvent (0, null, OS.kEventDurationNoWait, false, null) == OS.noErr;
- allowTimers = true;
- return result;
-}
-
-boolean runGrabs () {
- if (grabControl == null || grabbing) return false;
- if (!OS.StillDown ()) {
- grabControl = null;
- return false;
- }
- Rect rect = new Rect ();
- int [] outModifiers = new int [1];
- short [] outResult = new short [1];
- CGPoint pt = new CGPoint ();
- org.eclipse.swt.internal.carbon.Point outPt = new org.eclipse.swt.internal.carbon.Point ();
- grabbing = true;
- mouseUpControl = null;
- try {
- while (grabControl != null && !grabControl.isDisposed () && outResult [0] != OS.kMouseTrackingMouseUp) {
- if (!OS.HIVIEW) grabControl.getShell().update (true);
- lastModifiers = OS.GetCurrentEventKeyModifiers ();
- int oldState = OS.GetCurrentEventButtonState ();
- int handle = grabControl.handle;
- int window = OS.GetControlOwner (handle);
- int port = OS.HIVIEW ? -1 : OS.GetWindowPort (window);
- OS.TrackMouseLocationWithOptions (port, OS.kTrackMouseLocationOptionDontConsumeMouseUp, 10 / 1000.0, outPt, outModifiers, outResult);
- int type = 0, button = 0;
- switch ((int) outResult [0]) {
- case OS.kMouseTrackingTimedOut: {
- runAsyncMessages (false);
- break;
- }
- case OS.kMouseTrackingMouseDown: {
- type = SWT.MouseDown;
- int newState = OS.GetCurrentEventButtonState ();
- if ((oldState & 0x1) == 0 && (newState & 0x1) != 0) button = 1;
- if ((oldState & 0x2) == 0 && (newState & 0x2) != 0) button = 2;
- if ((oldState & 0x4) == 0 && (newState & 0x4) != 0) button = 3;
- break;
- }
- case OS.kMouseTrackingMouseUp: {
- type = SWT.MouseUp;
- int newState = OS.GetCurrentEventButtonState ();
- if ((oldState & 0x1) != 0 && (newState & 0x1) == 0) button = 1;
- if ((oldState & 0x2) != 0 && (newState & 0x2) == 0) button = 2;
- if ((oldState & 0x4) != 0 && (newState & 0x4) == 0) button = 3;
- break;
- }
-// case OS.kMouseTrackingMouseExited: type = SWT.MouseExit; break;
-// case OS.kMouseTrackingMouseEntered: type = SWT.MouseEnter; break;
- case OS.kMouseTrackingMouseDragged: {
- mouseMoved = true;
- type = SWT.MouseMove;
- dragDetect (grabControl);
- break;
- }
- case OS.kMouseTrackingMouseKeyModifiersChanged: break;
- case OS.kMouseTrackingUserCancelled: break;
- case OS.kMouseTrackingMouseMoved: {
- mouseMoved = true;
- type = SWT.MouseMove;
- break;
- }
- }
- boolean events = type != 0;
- if (type != 0) {
- int x = outPt.h;
- int y = outPt.v;
- if (OS.HIVIEW) {
- OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
- pt.x = x - rect.left;
- pt.y = y - rect.top;
- OS.HIViewConvertPoint (pt, 0, handle);
- x = (int) pt.x;
- y = (int) pt.y;
- } else {
- OS.GetControlBounds (handle, rect);
- x -= rect.left;
- y -= rect.top;
- }
- int chord = OS.GetCurrentEventButtonState ();
- if (grabControl != null && !grabControl.isDisposed ()) {
- if (type == SWT.MouseUp) {
- mouseUpControl = grabControl;
- } else {
- grabControl.sendMouseEvent (type, (short)button, true, chord, (short)x, (short)y, outModifiers [0]);
- }
- }
- }
- if (events) runDeferredEvents ();
- }
- } finally {
- grabbing = false;
- grabControl = null;
- }
- return true;
-}
-
-boolean runPaint () {
- if (!needsPaint) return false;
- needsPaint = false;
- for (int i = 0; i < widgetTable.length; i++) {
- Widget widget = widgetTable [i];
- if (widget != null && widget instanceof Shell) {
- Shell shell = (Shell) widget;
- if (shell.invalRgn != 0) {
- int invalRgn = shell.invalRgn;
- shell.invalRgn = 0;
- shell.redrawChildren (OS.HIViewGetRoot (shell.shellHandle), invalRgn);
- OS.DisposeRgn (invalRgn);
- }
- }
- }
- return true;
-}
-
-boolean runPopups () {
- if (popups == null) return false;
- grabControl = null;
- boolean result = false;
- while (popups != null) {
- Menu menu = popups [0];
- if (menu == null) break;
- int length = popups.length;
- System.arraycopy (popups, 1, popups, 0, --length);
- popups [length] = null;
- clearMenuFlags ();
- runDeferredEvents ();
- menu._setVisible (true);
- clearMenuFlags ();
- result = true;
- }
- popups = null;
- return result;
-}
-
-boolean runSettings () {
- if (!runSettings) return false;
- runSettings = false;
- initializeInsets ();
- sendEvent (SWT.Settings, null);
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) {
- shell.redraw (true);
- shell.layout (true, true);
- }
- }
- return true;
-}
-
-boolean runTimers () {
- if (timerList == null) return false;
- boolean result = false;
- for (int i=0; i<timerList.length; i++) {
- if (timerIds [i] == -1) {
- Runnable runnable = timerList [i];
- timerList [i] = null;
- timerIds [i] = 0;
- if (runnable != null) {
- result = true;
- runnable.run ();
- }
- }
- }
- return result;
-}
-
-void sendEvent (int eventType, Event event) {
- if (eventTable == null && filterTable == null) {
- return;
- }
- if (event == null) event = new Event ();
- event.display = this;
- event.type = eventType;
- if (event.time == 0) event.time = getLastEventTime ();
- if (!filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-/**
- * On platforms which support it, sets the application name
- * to be the argument. On Motif, for example, this can be used
- * to set the name used for resource lookup. Specifying
- * <code>null</code> for the name clears it.
- *
- * @param name the new app name or <code>null</code>
- */
-public static void setAppName (String name) {
- APP_NAME = name;
-}
-
-void setCurrentCaret (Caret caret) {
- if (caretID != 0) OS.RemoveEventLoopTimer (caretID);
- caretID = 0;
- currentCaret = caret;
- if (currentCaret != null) {
- int blinkRate = currentCaret.blinkRate;
- int [] timerId = new int [1];
- double time = blinkRate / 1000.0;
- int eventLoop = OS.GetCurrentEventLoop ();
- OS.InstallEventLoopTimer (eventLoop, time, time, caretProc, 0, timerId);
- caretID = timerId [0];
- }
-}
-
-void setCursor (int cursor) {
- switch (cursor) {
- case OS.kThemePointingHandCursor:
- case OS.kThemeArrowCursor:
- case OS.kThemeSpinningCursor:
- case OS.kThemeCrossCursor:
- case OS.kThemeWatchCursor:
- case OS.kThemeIBeamCursor:
- case OS.kThemeNotAllowedCursor:
- case OS.kThemeResizeLeftRightCursor:
- case OS.kThemeResizeLeftCursor:
- case OS.kThemeResizeRightCursor:
- OS.SetThemeCursor (cursor);
- break;
- default:
- OS.SetCursor (cursor);
- }
-}
-
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param x the new x coordinate for the cursor
- * @param y the new y coordinate for the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setCursorLocation (int x, int y) {
- checkDevice ();
- CGPoint pt = new CGPoint ();
- pt.x = x; pt.y = y;
- OS.CGWarpMouseCursorPosition (pt);
-}
-
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param point new position
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_NULL_ARGUMENT - if the point is null
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.0
- */
-public void setCursorLocation (Point point) {
- checkDevice ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- setCursorLocation (point.x, point.y);
-}
-
-/**
- * Sets the application defined property of the receiver
- * with the specified name to the given argument.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #getData(String)
- * @see #disposeExec(Runnable)
- */
-public void setData (String key, Object value) {
- checkDevice ();
- if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
-
- if (key.equals (ADD_WIDGET_KEY)) {
- Object [] data = (Object [])value;
- int handle = ((Integer)data [0]).intValue ();
- Widget widget = (Widget)data [1];
- if (widget == null) removeWidget (handle);
- else addWidget (handle, widget);
- }
-
- /* Remove the key/value pair */
- if (value == null) {
- if (keys == null) return;
- int index = 0;
- while (index < keys.length && !keys [index].equals (key)) index++;
- if (index == keys.length) return;
- if (keys.length == 1) {
- keys = null;
- values = null;
- } else {
- String [] newKeys = new String [keys.length - 1];
- Object [] newValues = new Object [values.length - 1];
- System.arraycopy (keys, 0, newKeys, 0, index);
- System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
- System.arraycopy (values, 0, newValues, 0, index);
- System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
- keys = newKeys;
- values = newValues;
- }
- return;
- }
-
- /* Add the key/value pair */
- if (keys == null) {
- keys = new String [] {key};
- values = new Object [] {value};
- return;
- }
- for (int i=0; i<keys.length; i++) {
- if (keys [i].equals (key)) {
- values [i] = value;
- return;
- }
- }
- String [] newKeys = new String [keys.length + 1];
- Object [] newValues = new Object [values.length + 1];
- System.arraycopy (keys, 0, newKeys, 0, keys.length);
- System.arraycopy (values, 0, newValues, 0, values.length);
- newKeys [keys.length] = key;
- newValues [values.length] = value;
- keys = newKeys;
- values = newValues;
-}
-
-/**
- * Sets the application defined, display specific data
- * associated with the receiver, to the argument.
- * The <em>display specific data</em> is a single,
- * unnamed field that is stored with every display.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the display specific data needs to
- * be notified when the display is disposed of, it is the
- * application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param data the new display specific data
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #getData()
- * @see #disposeExec(Runnable)
- */
-public void setData (Object data) {
- checkDevice ();
- this.data = data;
-}
-
-/**
- * Sets the synchronizer used by the display to be
- * the argument, which can not be null.
- *
- * @param synchronizer the new synchronizer for the display (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
- * </ul>
- */
-public void setSynchronizer (Synchronizer synchronizer) {
- checkDevice ();
- if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (this.synchronizer != null) {
- this.synchronizer.runAsyncMessages(true);
- }
- this.synchronizer = synchronizer;
-}
-
-void setMenuBar (Menu menu) {
- /*
- * Feature in the Macintosh. SetRootMenu() does not
- * accept NULL to indicate that their should be no
- * menu bar. The fix is to create a temporary empty
- * menu, set that to be the menu bar, clear the menu
- * bar and then delete the temporary menu.
- */
- if (menu == menuBar) return;
- int theMenu = 0;
- if (menu == null) {
- int outMenuRef [] = new int [1];
- OS.CreateNewMenu ((short) ID_TEMPORARY, 0, outMenuRef);
- theMenu = outMenuRef [0];
- } else {
- theMenu = menu.handle;
- }
- OS.SetRootMenu (theMenu);
- if (menu == null) {
- OS.ClearMenuBar ();
- OS.DisposeMenu (theMenu);
- }
- menuBar = menu;
-}
-
-/**
- * Causes the user-interface thread to <em>sleep</em> (that is,
- * to be put in a state where it does not consume CPU cycles)
- * until an event is received or it is otherwise awakened.
- *
- * @return <code>true</code> if an event requiring dispatching was placed on the queue.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #wake
- */
-public boolean sleep () {
- checkDevice ();
- if (getMessageCount () != 0) return true;
- disposeWindows ();
- if (eventTable != null && eventTable.hooks (SWT.Settings)) {
- RGBColor color = new RGBColor ();
- int status = OS.noErr, depth = getDepth ();
- do {
- allowTimers = false;
- status = OS.ReceiveNextEvent (0, null, 0.5, false, null);
- allowTimers = true;
- if (status == OS.eventLoopTimedOutErr) {
- OS.GetThemeBrushAsColor ((short) OS.kThemeBrushPrimaryHighlightColor, (short) depth, true, color);
- if (highlightColor.red != color.red || highlightColor.green != color.green || highlightColor.blue != color.blue) {
- highlightColor = color;
- runSettings = true;
- return true;
- }
- }
- } while (status == OS.eventLoopTimedOutErr);
- return status == OS.noErr;
- }
- allowTimers = false;
- int status = OS.ReceiveNextEvent (0, null, OS.kEventDurationForever, false, null);
- allowTimers = true;
- return status == OS.noErr;
-}
-
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The thread which calls this method
- * is suspended until the runnable completes. Specifying <code>null</code>
- * as the runnable simply wakes the user-interface thread.
- * <p>
- * Note that at the time the runnable is invoked, widgets
- * that have the receiver as their display may have been
- * disposed. Therefore, it is necessary to check for this
- * case inside the runnable before accessing the widget.
- * </p>
- *
- * @param runnable code to run on the user-interface thread or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #asyncExec
- */
-public void syncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.syncExec (runnable);
-}
-
-int textInputProc (int nextHandler, int theEvent, int userData) {
- int theWindow = OS.GetUserFocusWindow ();
- if (theWindow != 0) {
- int [] theControl = new int [1];
- OS.GetKeyboardFocus (theWindow, theControl);
- Widget widget = getWidget (theControl [0]);
- if (widget != null) {
- /* Stop the default event handler from activating the default button */
- OS.GetWindowDefaultButton (theWindow, theControl);
- OS.SetWindowDefaultButton (theWindow, 0);
- int result = widget.textInputProc (nextHandler, theEvent, userData);
- if (result == OS.eventNotHandledErr) {
- result = OS.CallNextEventHandler (nextHandler, theEvent);
- }
- OS.SetWindowDefaultButton (theWindow, theControl [0]);
- return result;
- }
- }
- return OS.eventNotHandledErr;
-}
-
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread after the specified
- * number of milliseconds have elapsed. If milliseconds is less
- * than zero, the runnable is not executed.
- * <p>
- * Note that at the time the runnable is invoked, widgets
- * that have the receiver as their display may have been
- * disposed. Therefore, it is necessary to check for this
- * case inside the runnable before accessing the widget.
- * </p>
- *
- * @param milliseconds the delay before running the runnable
- * @param runnable code to run on the user-interface thread
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #asyncExec
- */
-public void timerExec (int milliseconds, Runnable runnable) {
- checkDevice ();
- if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (timerList == null) timerList = new Runnable [4];
- if (timerIds == null) timerIds = new int [4];
- int index = 0;
- while (index < timerList.length) {
- if (timerList [index] == runnable) break;
- index++;
- }
- if (index != timerList.length) {
- int timerId = timerIds [index];
- if (milliseconds < 0) {
- OS.RemoveEventLoopTimer (timerId);
- timerList [index] = null;
- timerIds [index] = 0;
- } else {
- OS.SetEventLoopTimerNextFireTime (timerId, milliseconds / 1000.0);
- }
- return;
- }
- if (milliseconds < 0) return;
- index = 0;
- while (index < timerList.length) {
- if (timerList [index] == null) break;
- index++;
- }
- if (index == timerList.length) {
- Runnable [] newTimerList = new Runnable [timerList.length + 4];
- System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
- timerList = newTimerList;
- int [] newTimerIds = new int [timerIds.length + 4];
- System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
- timerIds = newTimerIds;
- }
- int [] timerId = new int [1];
- int eventLoop = OS.GetCurrentEventLoop ();
- OS.InstallEventLoopTimer (eventLoop, milliseconds / 1000.0, 0.0, timerProc, index, timerId);
- if (timerId [0] != 0) {
- timerIds [index] = timerId [0];
- timerList [index] = runnable;
- }
-}
-
-int timerProc (int id, int index) {
- OS.RemoveEventLoopTimer (id);
- if (timerList == null) return 0;
- if (0 <= index && index < timerList.length) {
- if (allowTimers) {
- Runnable runnable = timerList [index];
- timerList [index] = null;
- timerIds [index] = 0;
- if (runnable != null) runnable.run ();
- } else {
- timerIds [index] = -1;
- wakeThread ();
- }
- }
- return 0;
-}
-
-int trackingProc (int browser, int itemID, int property, int theRect, int startPt, int modifiers) {
- Widget widget = getWidget (browser);
- if (widget != null) return widget.trackingProc (browser, itemID, property, theRect, startPt, modifiers);
- return OS.noErr;
-}
-
-/**
- * Forces all outstanding paint requests for the display
- * to be processed before this method returns.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Control#update()
- */
-public void update () {
- checkDevice ();
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) shell.update (true);
- }
- /*
- * This code is intentionally commented.
- */
-// int [] outEvent = new int [1];
-// int [] mask = new int [] {OS.kEventClassWindow, OS.kEventWindowUpdate};
-// while (OS.ReceiveNextEvent (mask.length / 2, mask, OS.kEventDurationNoWait, true, outEvent) == OS.noErr) {
-// /*
-// * Bug in the Macintosh. For some reason, when a hierarchy of
-// * windows is disposed from kEventWindowClose, despite the fact
-// * that DisposeWindow() has been called, the window is not
-// * disposed and there are outstandings kEventWindowUpdate events
-// * in the event queue. Dispatching these events will cause a
-// * segment fault. The fix is to dispatch events to visible
-// * windows only.
-// */
-// int [] theWindow = new int [1];
-// OS.GetEventParameter (outEvent [0], OS.kEventParamDirectObject, OS.typeWindowRef, null, 4, null, theWindow);
-// if (OS.IsWindowVisible (theWindow [0])) OS.SendEventToEventTarget (outEvent [0], OS.GetEventDispatcherTarget ());
-// OS.ReleaseEvent (outEvent [0]);
-// }
-}
-
-void updateQuitMenu () {
- boolean enabled = true;
- Shell [] shells = getShells ();
- int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if ((shell.style & mask) != 0 && shell.isVisible ()) {
- enabled = false;
- break;
- }
- }
- if (enabled) {
- OS.EnableMenuCommand (0, OS.kHICommandQuit);
- } else {
- OS.DisableMenuCommand (0, OS.kHICommandQuit);
- }
-}
-
-/**
- * If the receiver's user-interface thread was <code>sleep</code>ing,
- * causes it to be awakened and start running again. Note that this
- * method may be called from any thread.
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #sleep
- */
-public void wake () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- if (thread == Thread.currentThread ()) return;
- wakeThread ();
-}
-
-void wakeThread () {
- int [] wakeEvent = new int [1];
- OS.CreateEvent (0, WAKE_CLASS, WAKE_KIND, 0.0, OS.kEventAttributeUserEvent, wakeEvent);
- OS.PostEventToQueue (queue, wakeEvent [0], (short) OS.kEventPriorityStandard);
- if (wakeEvent [0] != 0) OS.ReleaseEvent (wakeEvent [0]);
-}
-
-int windowProc (int nextHandler, int theEvent, int userData) {
- Widget widget = getWidget (userData);
- if (widget == null) {
- int [] theWindow = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeWindowRef, null, 4, null, theWindow);
- int [] theRoot = new int [1];
- OS.GetRootControl (theWindow [0], theRoot);
- widget = getWidget (theRoot [0]);
- }
- if (widget != null) return widget.windowProc (nextHandler, theEvent, userData);
- return OS.eventNotHandledErr;
-}
-
-}
diff --git a/dev/mac/src/org/eclipse/swt/widgets/Widget.java b/dev/mac/src/org/eclipse/swt/widgets/Widget.java
deleted file mode 100644
index a87a118..0000000
--- a/dev/mac/src/org/eclipse/swt/widgets/Widget.java
+++ /dev/null
@@ -1,2062 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.carbon.CGRect;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.RGBColor;
-import org.eclipse.swt.internal.carbon.Rect;
-import org.eclipse.swt.internal.carbon.PixMap;
-import org.eclipse.swt.internal.carbon.BitMap;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
-/**
- * This class is the abstract superclass of all user interface objects.
- * Widgets are created, disposed and issue notification to listeners
- * when events occur which affect them.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation. However, it has not been marked
- * final to allow those outside of the SWT development team to implement
- * patched versions of the class in order to get around specific
- * limitations in advance of when those limitations can be addressed
- * by the team. Any class built using subclassing to access the internals
- * of this class will likely fail to compile or run between releases and
- * may be strongly platform specific. Subclassing should not be attempted
- * without an intimate and detailed understanding of the workings of the
- * hierarchy. No support is provided for user-written classes which are
- * implemented as subclasses of this class.
- * </p>
- *
- * @see #checkSubclass
- */
-public abstract class Widget {
- int style, state;
- Display display;
- EventTable eventTable;
- Object data;
-
- /* Global state flags */
- static final int DISPOSED = 1 << 0;
- static final int CANVAS = 1 << 1;
- static final int KEYED_DATA = 1 << 2;
- static final int DISABLED = 1 << 3;
- static final int HIDDEN = 1 << 4;
- static final int GRAB = 1 << 5;
- static final int MOVED = 1 << 6;
- static final int RESIZED = 1 << 7;
- static final int EXPANDING = 1 << 8;
- static final int IGNORE_WHEEL = 1 << 9;
- static final int PARENT_BACKGROUND = 1 << 10;
- static final int THEME_BACKGROUND = 1 << 11;
-
- /* A layout was requested on this widget */
- static final int LAYOUT_NEEDED = 1<<12;
-
- /* The preferred size of a child has changed */
- static final int LAYOUT_CHANGED = 1<<13;
-
- /* A layout was requested in this widget hierachy */
- static final int LAYOUT_CHILD = 1<<14;
-
- /* More global state flags */
- static final int RELEASED = 1<<15;
- static final int DISPOSE_SENT = 1<<16;
-
- /* Default size for widgets */
- static final int DEFAULT_WIDTH = 64;
- static final int DEFAULT_HEIGHT = 64;
-
- static final Rect EMPTY_RECT = new Rect ();
-
- // GOOGLE: patched in from https://bugs.eclipse.org/bugs/show_bug.cgi?id=161259
- static final String CLEAR_GRAB_BIT = "org.eclipse.swt.internal.carbon.clearGrabBit";
-
-Widget () {
- /* Do nothing */
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see #checkSubclass
- * @see #getStyle
- */
-public Widget (Widget parent, int style) {
- checkSubclass ();
- checkParent (parent);
- this.style = style;
- display = parent.display;
-}
-
-int actionProc (int theControl, int partCode) {
- return OS.noErr;
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when an event of the given type occurs. When the
- * event does occur in the widget, the listener is notified by
- * sending it the <code>handleEvent()</code> message. The event
- * type is one of the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #removeListener
- * @see #notifyListeners
- */
-public void addListener (int eventType, Listener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- _addListener (eventType, listener);
-}
-
-void _addListener (int eventType, Listener listener) {
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, listener);
-}
-
-int callPaintEventHandler (int control, int damageRgn, int visibleRgn, int theEvent, int nextHandler) {
- return OS.CallNextEventHandler (nextHandler, theEvent);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the widget is disposed. When the widget is
- * disposed, the listener is notified by sending it the
- * <code>widgetDisposed()</code> message.
- *
- * @param listener the listener which should be notified when the receiver is disposed
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DisposeListener
- * @see #removeDisposeListener
- */
-public void addDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Dispose, typedListener);
-}
-
-static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
- int mask = int0 | int1 | int2 | int3 | int4 | int5;
- if ((style & mask) == 0) style |= int0;
- if ((style & int0) != 0) style = (style & ~mask) | int0;
- if ((style & int1) != 0) style = (style & ~mask) | int1;
- if ((style & int2) != 0) style = (style & ~mask) | int2;
- if ((style & int3) != 0) style = (style & ~mask) | int3;
- if ((style & int4) != 0) style = (style & ~mask) | int4;
- if ((style & int5) != 0) style = (style & ~mask) | int5;
- return style;
-}
-
-void calculateVisibleRegion (int control, int visibleRgn, boolean clipChildren) {
- int tempRgn = OS.NewRgn ();
- if (OS.IsControlVisible (control)) {
- int childRgn = OS.NewRgn ();
- int window = OS.GetControlOwner (control);
- short [] count = new short [1];
- int [] outControl = new int [1];
- OS.GetRootControl (window, outControl);
- int root = outControl [0];
- OS.GetControlRegion (root, (short) OS.kControlStructureMetaPart, visibleRgn);
- int tempControl = control, lastControl = 0;
- while (tempControl != root) {
- OS.GetControlRegion (tempControl, (short) OS.kControlStructureMetaPart, tempRgn);
- if (OS.HIVIEW) OS.HIViewConvertRegion (tempRgn, tempControl, root);
- OS.SectRgn (tempRgn, visibleRgn, visibleRgn);
- if (OS.EmptyRgn (visibleRgn)) break;
- if (clipChildren || tempControl != control) {
- OS.CountSubControls (tempControl, count);
- for (int i = 0; i < count [0]; i++) {
- OS.GetIndexedSubControl (tempControl, (short)(OS.HIVIEW ? count [0] - i : i + 1), outControl);
- int child = outControl [0];
- if (child == lastControl) break;
- if (!OS.IsControlVisible (child)) continue;
- OS.GetControlRegion (child, (short) OS.kControlStructureMetaPart, tempRgn);
- if (OS.HIVIEW) OS.HIViewConvertRegion (tempRgn, child, root);
- OS.UnionRgn (tempRgn, childRgn, childRgn);
- }
- }
- lastControl = tempControl;
- OS.GetSuperControl (tempControl, outControl);
- tempControl = outControl [0];
- }
- OS.DiffRgn (visibleRgn, childRgn, visibleRgn);
- OS.DisposeRgn (childRgn);
- } else {
- OS.CopyRgn (tempRgn, visibleRgn);
- }
- OS.DisposeRgn (tempRgn);
-}
-
-void checkOpen () {
- /* Do nothing */
-}
-
-void checkOrientation (Widget parent) {
- style &= ~SWT.MIRRORED;
- if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
- if (parent != null) {
- if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
- if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
- }
- }
- style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
-}
-
-void checkParent (Widget parent) {
- if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (parent.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- parent.checkWidget ();
- parent.checkOpen ();
-}
-
-/**
- * Checks that this class can be subclassed.
- * <p>
- * The SWT class library is intended to be subclassed
- * only at specific, controlled points (most notably,
- * <code>Composite</code> and <code>Canvas</code> when
- * implementing new widgets). This method enforces this
- * rule unless it is overridden.
- * </p><p>
- * <em>IMPORTANT:</em> By providing an implementation of this
- * method that allows a subclass of a class which does not
- * normally allow subclassing to be created, the implementer
- * agrees to be fully responsible for the fact that any such
- * subclass will likely fail between SWT releases and will be
- * strongly platform specific. No support is provided for
- * user-written classes which are implemented in this fashion.
- * </p><p>
- * The ability to subclass outside of the allowed SWT classes
- * is intended purely to enable those not on the SWT development
- * team to implement patches in order to get around specific
- * limitations in advance of when those limitations can be
- * addressed by the team. Subclassing should not be attempted
- * without an intimate and detailed understanding of the hierarchy.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/**
- * Throws an <code>SWTException</code> if the receiver can not
- * be accessed by the caller. This may include both checks on
- * the state of the receiver and more generally on the entire
- * execution context. This method <em>should</em> be called by
- * widget implementors to enforce the standard SWT invariants.
- * <p>
- * Currently, it is an error to invoke any method (other than
- * <code>isDisposed()</code>) on a widget that has had its
- * <code>dispose()</code> method called. It is also an error
- * to call widget methods from any thread that is different
- * from the thread that created the widget.
- * </p><p>
- * In future releases of SWT, there may be more or fewer error
- * checks and exceptions may be thrown for different reasons.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-protected void checkWidget () {
- Display display = this.display;
- if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED);
-}
-
-int colorProc (int inControl, int inMessage, int inDrawDepth, int inDrawInColor) {
- return OS.eventNotHandledErr;
-}
-
-boolean contains (int shellX, int shellY) {
- return true;
-}
-
-int controlProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventControlActivate: return kEventControlActivate (nextHandler, theEvent, userData);
- case OS.kEventControlApplyBackground: return kEventControlApplyBackground (nextHandler, theEvent, userData);
- case OS.kEventControlBoundsChanged: return kEventControlBoundsChanged (nextHandler, theEvent, userData);
- case OS.kEventControlClick: return kEventControlClick (nextHandler, theEvent, userData);
- case OS.kEventControlContextualMenuClick: return kEventControlContextualMenuClick (nextHandler, theEvent, userData);
- case OS.kEventControlDeactivate: return kEventControlDeactivate (nextHandler, theEvent, userData);
- case OS.kEventControlDraw: return kEventControlDraw (nextHandler, theEvent, userData);
- case OS.kEventControlHit: return kEventControlHit (nextHandler, theEvent, userData);
- case OS.kEventControlSetCursor: return kEventControlSetCursor (nextHandler, theEvent, userData);
- case OS.kEventControlSetFocusPart: return kEventControlSetFocusPart (nextHandler, theEvent, userData);
- case OS.kEventControlTrack: return kEventControlTrack (nextHandler, theEvent, userData);
- case OS.kEventControlGetFocusPart: return kEventControlGetFocusPart (nextHandler, theEvent, userData);
- case OS.kEventControlHitTest: return kEventControlHitTest (nextHandler, theEvent, userData);
- case OS.kEventControlGetClickActivation: return kEventControlGetClickActivation (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-int accessibilityProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventAccessibleGetChildAtPoint: return kEventAccessibleGetChildAtPoint (nextHandler, theEvent, userData);
- case OS.kEventAccessibleGetAllAttributeNames: return kEventAccessibleGetAllAttributeNames (nextHandler, theEvent, userData);
- case OS.kEventAccessibleGetNamedAttribute: return kEventAccessibleGetNamedAttribute (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-int createCIcon (Image image) {
- int imageHandle = image.handle;
- int width = OS.CGImageGetWidth(imageHandle);
- int height = OS.CGImageGetHeight(imageHandle);
- int bpr = OS.CGImageGetBytesPerRow(imageHandle);
- int bpp = OS.CGImageGetBitsPerPixel(imageHandle);
- int bpc = OS.CGImageGetBitsPerComponent(imageHandle);
- int alphaInfo = OS.CGImageGetAlphaInfo(imageHandle);
-
- int maskBpl = (((width + 7) / 8) + 3) / 4 * 4;
- int maskSize = height * maskBpl;
- int pixmapSize = height * bpr;
-
- /* Create the icon */
- int iconSize = PixMap.sizeof + BitMap.sizeof * 2 + 4 + maskSize;
- int iconHandle = OS.NewHandle(iconSize);
- if (iconHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.HLock(iconHandle);
- int[] iconPtr = new int[1];
- OS.memcpy(iconPtr, iconHandle, 4);
-
- /* Initialize the pixmap */
- PixMap iconPMap = new PixMap();
- iconPMap.rowBytes = (short)(bpr | 0x8000);
- iconPMap.right = (short)width;
- iconPMap.bottom = (short)height;
- iconPMap.cmpCount = 3;
- iconPMap.cmpSize = (short)bpc;
- iconPMap.pmTable = OS.NewHandle(0);
- iconPMap.hRes = 72 << 16;
- iconPMap.vRes = 72 << 16;
- iconPMap.pixelType = (short)OS.RGBDirect;
- iconPMap.pixelSize = (short)bpp;
- iconPMap.pixelFormat = (short)bpp;
- OS.memcpy(iconPtr[0], iconPMap, PixMap.sizeof);
-
- /* Initialize the mask */
- BitMap iconMask = new BitMap();
- iconMask.rowBytes = (short)maskBpl;
- iconMask.right = (short)width;
- iconMask.bottom = (short)height;
- OS.memcpy(iconPtr[0] + PixMap.sizeof, iconMask, BitMap.sizeof);
-
- /* Initialize the icon data */
- int iconData = OS.NewHandle(pixmapSize);
- OS.HLock(iconData);
- int[] iconDataPtr = new int[1];
- OS.memcpy(iconDataPtr, iconData, 4);
- OS.memcpy(iconDataPtr[0], image.data, pixmapSize);
- OS.HUnlock(iconData);
- OS.memcpy(iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof, new int[]{iconData}, 4);
-
- /* Initialize the mask data */
- if (alphaInfo != OS.kCGImageAlphaFirst) {
- OS.memset(iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof + 4, -1, maskSize);
- } else {
- byte[] srcData = new byte[pixmapSize];
- OS.memcpy(srcData, image.data, pixmapSize);
- byte[] maskData = new byte[maskSize];
- int offset = 0, maskOffset = 0;
- for (int y = 0; y<height; y++) {
- for (int x = 0; x<width; x++) {
- if ((srcData[offset] & 0xFF) > 128) {
- maskData[maskOffset + (x >> 3)] |= (1 << (7 - (x & 0x7)));
- } else {
- maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
- }
- offset += 4;
- }
- maskOffset += maskBpl;
- }
- OS.memcpy(iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof + 4, maskData, maskData.length);
- }
-
- OS.HUnlock(iconHandle);
- return iconHandle;
-}
-
-void createHandle () {
-}
-
-int createIconRef (Image image) {
- int imageHandle = image.handle;
- int imageData = image.data;
- int width = OS.CGImageGetWidth(imageHandle);
- int height = OS.CGImageGetHeight(imageHandle);
- int bpr = OS.CGImageGetBytesPerRow(imageHandle);
- int alphaInfo = OS.CGImageGetAlphaInfo(imageHandle);
-
- int type = 0, maskType = 0;
- if (width == 16 && height == 16) {
- type = OS.kSmall32BitData;
- maskType = OS.kSmall8BitMask;
- } else if (width == 32 && height == 32) {
- type = OS.kLarge32BitData;
- maskType = OS.kLarge8BitMask;
- } else if (width == 48 && height == 48) {
- type = OS.kHuge32BitData;
- maskType = OS.kHuge8BitMask;
- } else if (width == 128 && height == 128) {
- type = OS.kThumbnail32BitData;
- maskType = OS.kThumbnail8BitMask;
- } else {
- type = OS.kSmall32BitData;
- maskType = OS.kSmall8BitMask;
- int size = 16;
- if (width > 16 || height > 16) {
- type = OS.kHuge32BitData;
- maskType = OS.kHuge8BitMask;
- size = 32;
- }
- if (width > 32 || height > 32) {
- type = OS.kHuge32BitData;
- maskType = OS.kHuge8BitMask;
- size = 48;
- }
- if (width > 48 || height > 48) {
- type = OS.kThumbnail32BitData;
- maskType = OS.kThumbnail8BitMask;
- size = 128;
- }
- width = height = size;
- bpr = width * 4;
- int dataSize = height * bpr;
- imageData = OS.NewPtr(dataSize);
- if (imageData == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int colorspace = OS.CGColorSpaceCreateDeviceRGB();
- if (colorspace == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int context = OS.CGBitmapContextCreate(imageData, width, height, 8, bpr, colorspace, OS.kCGImageAlphaNoneSkipFirst);
- OS.CGColorSpaceRelease(colorspace);
- if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- CGRect rect = new CGRect();
- rect.width = width;
- rect.height = height;
- OS.CGContextDrawImage(context, rect, imageHandle);
- OS.CGContextRelease(context);
- }
- if (type == 0) return 0;
-
- int iconFamily = OS.NewHandle(0);
- if (iconFamily == 0) SWT.error(SWT.ERROR_NO_HANDLES);
-
- int dataSize = height * bpr;
- int dataHandle = OS.NewHandle(dataSize);
- if (dataHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int[] dataPtr = new int[1];
- OS.HLock(dataHandle);
- OS.memcpy(dataPtr, dataHandle, 4);
- OS.memcpy(dataPtr[0], imageData, dataSize);
- OS.HUnlock(dataHandle);
- OS.SetIconFamilyData(iconFamily, type, dataHandle);
- OS.DisposeHandle(dataHandle);
-
- /* Initialize the mask data */
- int maskSize = width * height;
- int maskHandle = OS.NewHandle (maskSize);
- if (maskHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.HLock(maskHandle);
- int[] maskPtr = new int[1];
- OS.memcpy(maskPtr, maskHandle, 4);
- if (alphaInfo != OS.kCGImageAlphaFirst) {
- OS.memset(maskPtr[0], 0xFF, maskSize);
- } else {
- byte[] srcData = new byte[dataSize];
- OS.memcpy(srcData, imageData, dataSize);
- byte[] maskData = new byte[maskSize];
- int offset = 0, maskOffset = 0;
- for (int y = 0; y<height; y++) {
- for (int x = 0; x<width; x++) {
- maskData[maskOffset++] = srcData[offset];
- offset += 4;
- }
- }
- OS.memcpy(maskPtr[0], maskData, maskData.length);
- }
- OS.HUnlock(maskHandle);
- OS.SetIconFamilyData(iconFamily, maskType, maskHandle);
- OS.DisposeHandle(maskHandle);
-
- if (imageData != image.data) OS.DisposePtr(imageData);
-
- /* Create the icon ref */
- int[] iconRef = new int[1];
- OS.HLock(iconFamily);
- int[] iconPtr = new int[1];
- OS.memcpy(iconPtr, iconFamily, 4);
- OS.GetIconRefFromIconFamilyPtr(iconPtr[0], OS.GetHandleSize(iconFamily), iconRef);
- OS.HUnlock(iconFamily);
- OS.DisposeHandle(iconFamily);
- return iconRef[0];
-}
-
-void createWidget () {
- createHandle ();
- register ();
- hookEvents ();
-}
-
-int commandProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventProcessCommand: return kEventProcessCommand (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-void deregister () {
-}
-
-void destroyWidget () {
- releaseHandle ();
-}
-
-void destroyCIcon (int iconHandle) {
- OS.HLock(iconHandle);
-
- /* Dispose the ColorTable */
- int[] iconPtr = new int[1];
- OS.memcpy(iconPtr, iconHandle, 4);
- PixMap iconPMap = new PixMap();
- OS.memcpy(iconPMap, iconPtr[0], PixMap.sizeof);
- if (iconPMap.pmTable != 0) OS.DisposeHandle(iconPMap.pmTable);
-
- /* Dispose the icon data */
- int[] iconData = new int[1];
- OS.memcpy(iconData, iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof, 4);
- if (iconData[0] != 0) OS.DisposeHandle(iconData[0]);
-
- OS.HUnlock(iconHandle);
-
- /* Dispose the icon */
- OS.DisposeHandle(iconHandle);
-}
-
-int drawItemProc (int browser, int item, int property, int itemState, int theRect, int gdDepth, int colorDevice) {
- return OS.noErr;
-}
-
-/**
- * Disposes of the operating system resources associated with
- * the receiver and all its descendents. After this method has
- * been invoked, the receiver and all descendents will answer
- * <code>true</code> when sent the message <code>isDisposed()</code>.
- * Any internal connections between the widgets in the tree will
- * have been removed to facilitate garbage collection.
- * <p>
- * NOTE: This method is not called recursively on the descendents
- * of the receiver. This means that, widget implementers can not
- * detect when a widget is being disposed of by re-implementing
- * this method, but should instead listen for the <code>Dispose</code>
- * event.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #addDisposeListener
- * @see #removeDisposeListener
- * @see #checkWidget
- */
-public void dispose () {
- /*
- * Note: It is valid to attempt to dispose a widget
- * more than once. If this happens, fail silently.
- */
- if (isDisposed ()) return;
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- release (true);
-}
-
-void drawBackground (int control, int context) {
- /* Do nothing */
-}
-
-void drawWidget (int control, int context, int damageRgn, int visibleRgn, int theEvent) {
-}
-
-void error (int code) {
- SWT.error(code);
-}
-
-boolean filters (int eventType) {
- return display.filters (eventType);
-}
-
-int fixMnemonic (char [] buffer) {
- int i=0, j=0;
- while (i < buffer.length) {
- if ((buffer [j++] = buffer [i++]) == '&') {
- if (i == buffer.length) {continue;}
- if (buffer [i] == '&') {i++; continue;}
- j--;
- }
- }
- return j;
-}
-
-Rectangle getControlBounds (int control) {
- if (OS.HIVIEW) {
- CGRect rect = new CGRect ();
- OS.HIViewGetFrame (control, rect);
- Rect inset = getInset ();
- rect.x -= inset.left;
- rect.y -= inset.top;
- rect.width += inset.right + inset.left;
- rect.height += inset.bottom + inset.top;
- return new Rectangle ((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
- }
- Rect rect = new Rect();
- OS.GetControlBounds (control, rect);
- int window = OS.GetControlOwner (control);
- int [] theRoot = new int [1];
- OS.GetRootControl (window, theRoot);
- int [] parentHandle = new int [1];
- OS.GetSuperControl (control, parentHandle);
- if (parentHandle [0] != theRoot [0]) {
- Rect parentRect = new Rect ();
- OS.GetControlBounds (parentHandle [0], parentRect);
- OS.OffsetRect (rect, (short) -parentRect.left, (short) -parentRect.top);
- }
- Rect inset = getInset ();
- rect.left -= inset.left;
- rect.top -= inset.top;
- rect.right += inset.right;
- rect.bottom += inset.bottom;
- return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
-}
-
-Point getControlSize (int control) {
- if (OS.HIVIEW) {
- CGRect rect = new CGRect ();
- OS.HIViewGetFrame (control, rect);
- Rect inset = getInset ();
- int width = (int) rect.width + inset.left + inset.right;
- int height = (int) rect.height + inset.top + inset.bottom;
- return new Point (width, height);
- }
- Rect rect = new Rect ();
- OS.GetControlBounds (control, rect);
- Rect inset = getInset ();
- rect.left -= inset.left;
- rect.top -= inset.top;
- rect.right += inset.right;
- rect.bottom += inset.bottom;
- return new Point (rect.right - rect.left, rect.bottom - rect.top);
-}
-
-/**
- * Returns the application defined widget data associated
- * with the receiver, or null if it has not been set. The
- * <em>widget data</em> is a single, unnamed field that is
- * stored with every widget.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the widget data needs to be notified
- * when the widget is disposed of, it is the application's
- * responsibility to hook the Dispose event on the widget and
- * do so.
- * </p>
- *
- * @return the widget data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- *
- * @see #setData(Object)
- */
-public Object getData () {
- checkWidget();
- return (state & KEYED_DATA) != 0 ? ((Object []) data) [0] : data;
-}
-
-/**
- * Returns the application defined property of the receiver
- * with the specified name, or null if it has not been set.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the widget is disposed
- * of, it is the application's responsibility to hook the
- * Dispose event on the widget and do so.
- * </p>
- *
- * @param key the name of the property
- * @return the value of the property or null if it has not been set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setData(String, Object)
- */
-public Object getData (String key) {
- checkWidget();
- if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((state & KEYED_DATA) != 0) {
- Object [] table = (Object []) data;
- for (int i=1; i<table.length; i+=2) {
- if (key.equals (table [i])) return table [i+1];
- }
- }
- return null;
-}
-
-/**
- * Returns the <code>Display</code> that is associated with
- * the receiver.
- * <p>
- * A widget's display is either provided when it is created
- * (for example, top level <code>Shell</code>s) or is the
- * same as its parent's display.
- * </p>
- *
- * @return the receiver's display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Display getDisplay () {
- Display display = this.display;
- if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return display;
-}
-
-int getDrawCount (int control) {
- return 0;
-}
-
-Rect getInset () {
- return EMPTY_RECT;
-}
-
-String getName () {
- String string = getClass ().getName ();
- int index = string.lastIndexOf ('.');
- if (index == -1) return string;
- return string.substring (index + 1, string.length ());
-}
-
-String getNameText () {
- return "";
-}
-
-/**
- * Returns the receiver's style information.
- * <p>
- * Note that the value which is returned by this method <em>may
- * not match</em> the value which was provided to the constructor
- * when the receiver was created. This can occur when the underlying
- * operating system does not support a particular combination of
- * requested styles. For example, if the platform widget used to
- * implement a particular SWT widget always has scroll bars, the
- * result of calling this method would always have the
- * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set.
- * </p>
- *
- * @return the style bits
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getStyle () {
- checkWidget();
- return style;
-}
-
-int getVisibleRegion (int control, boolean clipChildren) {
- int visibleRgn = OS.NewRgn ();
- calculateVisibleRegion (control, visibleRgn, clipChildren);
- return visibleRgn;
-}
-
-int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) {
- return OS.eventNotHandledErr;
-}
-
-int hitTestProc (int browser, int item, int property, int theRect, int mouseRect) {
- /* Return true to indicate that the item can be selected */
- return 1;
-}
-
-void hookEvents () {
-}
-
-boolean hooks (int eventType) {
- if (eventTable == null) return false;
- return eventTable.hooks (eventType);
-}
-
-void invalidateVisibleRegion (int control) {
-}
-
-void invalWindowRgn (int window, int rgn) {
- OS.InvalWindowRgn (window, rgn);
-}
-
-/**
- * Returns <code>true</code> if the widget has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the widget.
- * When a widget has been disposed, it is an error to
- * invoke any other method using the widget.
- * </p>
- *
- * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
- */
-public boolean isDisposed () {
- return (state & DISPOSED) != 0;
-}
-
-boolean isDrawing (int control) {
- return OS.IsControlVisible (control) && getDrawCount (control) == 0;
-}
-
-boolean isEnabled () {
- return true;
-}
-
-/**
- * Returns <code>true</code> if there are any listeners
- * for the specified event type associated with the receiver,
- * and <code>false</code> otherwise. The event type is one of
- * the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event
- * @return true if the event is hooked
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- */
-public boolean isListening (int eventType) {
- checkWidget();
- return hooks (eventType);
-}
-
-boolean isTrimHandle (int trimHandle) {
- return false;
-}
-
-boolean isValidSubclass () {
- return Display.isValidClass (getClass ());
-}
-
-boolean isValidThread () {
- return getDisplay ().isValidThread ();
-}
-
-int itemCompareProc (int browser, int itemOne, int itemTwo, int sortProperty) {
- return OS.noErr;
-}
-
-int itemDataProc (int browser, int item, int property, int itemData, int setValue) {
- return OS.noErr;
-}
-
-int itemNotificationProc (int browser, int item, int message) {
- return OS.noErr;
-}
-
-int kEventAccessibleGetChildAtPoint (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventAccessibleGetAllAttributeNames (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventAccessibleGetNamedAttribute (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventProcessCommand (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlApplyBackground (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlActivate (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlBoundsChanged (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlClick (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlContextualMenuClick (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlDeactivate (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlDraw (int nextHandler, int theEvent, int userData) {
- int [] theControl = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeControlRef, null, 4, null, theControl);
- int [] region = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle, OS.typeQDRgnHandle, null, 4, null, region);
- if (OS.HIVIEW) {
- boolean oldInPaint = display.inPaint;
- display.inPaint = true;
- int[] context = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamCGContextRef, OS.typeCGContextRef, null, 4, null, context);
- int visibleRgn = region [0];
- drawBackground (theControl [0], context [0]);
- callPaintEventHandler (theControl [0], region [0], visibleRgn, theEvent, nextHandler);
- drawWidget (theControl [0], context [0], region [0], visibleRgn, theEvent);
- display.inPaint = oldInPaint;
- } else {
- if (getDrawCount (theControl [0]) > 0) return OS.noErr;
- int visibleRgn = getVisibleRegion (theControl [0], true);
- OS.SectRgn(region [0], visibleRgn, visibleRgn);
- if (!OS.EmptyRgn (visibleRgn)) {
- int [] port = new int [1];
- OS.GetPort (port);
- OS.LockPortBits (port [0]);
-// OS.QDSetDirtyRegion (port, visibleRgn);
- int oldClip = OS.NewRgn ();
- OS.GetClip (oldClip);
- OS.SetClip (visibleRgn);
- drawBackground (theControl [0], 0);
- callPaintEventHandler (theControl [0], region [0], visibleRgn, theEvent, nextHandler);
- drawWidget (theControl [0], 0, region [0], visibleRgn, theEvent);
- OS.SetClip (oldClip);
- OS.DisposeRgn (oldClip);
- OS.UnlockPortBits (port [0]);
- }
- OS.DisposeRgn (visibleRgn);
- }
- return OS.noErr;
-}
-
-int kEventControlGetClickActivation (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlGetFocusPart (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlHit (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlHitTest (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlSetCursor (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventControlTrack (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuCalculateSize (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuClosed (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuCreateFrameView (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuDrawItem (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuDrawItemContent (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuGetFrameBounds (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuMeasureItemWidth (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuOpening (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMenuTargetItem (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMouseDown (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMouseDragged (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMouseMoved (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMouseUp (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventMouseWheelMoved (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventRawKeyDown (int nextHandler, int theEvent, int userData) {
- return kEventRawKeyPressed (nextHandler, theEvent, userData);
-}
-
-int kEventRawKeyModifiersChanged (int nextHandler, int theEvent, int userData) {
- Display display = this.display;
- int [] modifiers = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, modifiers.length * 4, null, modifiers);
- int lastModifiers = display.lastModifiers;
- int chord = OS.GetCurrentEventButtonState ();
- int type = SWT.KeyUp;
- if ((modifiers [0] & OS.alphaLock) != 0 && (lastModifiers & OS.alphaLock) == 0) type = SWT.KeyDown;
- if ((modifiers [0] & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) type = SWT.KeyDown;
- if ((modifiers [0] & OS.controlKey) != 0 && (lastModifiers & OS.controlKey) == 0) type = SWT.KeyDown;
- if ((modifiers [0] & OS.cmdKey) != 0 && (lastModifiers & OS.cmdKey) == 0) type = SWT.KeyDown;
- if ((modifiers [0] & OS.optionKey) != 0 && (lastModifiers & OS.optionKey) == 0) type = SWT.KeyDown;
- if (type == SWT.KeyUp && (modifiers [0] & OS.alphaLock) == 0 && (lastModifiers & OS.alphaLock) != 0) {
- Event event = new Event ();
- event.keyCode = SWT.CAPS_LOCK;
- setInputState (event, SWT.KeyDown, chord, modifiers [0]);
- sendKeyEvent (SWT.KeyDown, event);
- }
- Event event = new Event ();
- setInputState (event, type, chord, modifiers [0]);
- if (event.keyCode == 0 && event.character == 0) return OS.eventNotHandledErr;
- boolean result = sendKeyEvent (type, event);
- if (type == SWT.KeyDown && (modifiers [0] & OS.alphaLock) != 0 && (lastModifiers & OS.alphaLock) == 0) {
- event = new Event ();
- event.keyCode = SWT.CAPS_LOCK;
- setInputState (event, SWT.KeyUp, chord, modifiers [0]);
- sendKeyEvent (SWT.KeyUp, event);
- }
- display.lastModifiers = modifiers [0];
- return result ? OS.eventNotHandledErr : OS.noErr;
-}
-
-int kEventRawKeyPressed (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventRawKeyRepeat (int nextHandler, int theEvent, int userData) {
- return kEventRawKeyPressed (nextHandler, theEvent, userData);
-}
-
-int kEventRawKeyUp (int nextHandler, int theEvent, int userData) {
- if (!sendKeyEvent (SWT.KeyUp, theEvent)) return OS.noErr;
- return OS.eventNotHandledErr;
-}
-
-int kEventTextInputUnicodeForKeyEvent (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowActivated (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowBoundsChanged (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowClose (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowCollapsed (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowDeactivated (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowDrawContent (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowExpanded (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowGetClickModality (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowGetRegion (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowHidden (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowHitTest (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowShown (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int kEventWindowUpdate (int nextHandler, int theEvent, int userData) {
- return OS.eventNotHandledErr;
-}
-
-int keyboardProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventRawKeyDown: return kEventRawKeyDown (nextHandler, theEvent, userData);
- case OS.kEventRawKeyModifiersChanged: return kEventRawKeyModifiersChanged (nextHandler, theEvent, userData);
- case OS.kEventRawKeyRepeat: return kEventRawKeyRepeat (nextHandler, theEvent, userData);
- case OS.kEventRawKeyUp: return kEventRawKeyUp (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-int menuProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventMenuCalculateSize: return kEventMenuCalculateSize (nextHandler, theEvent, userData);
- case OS.kEventMenuClosed: return kEventMenuClosed (nextHandler, theEvent, userData);
- case OS.kEventMenuCreateFrameView: return kEventMenuCreateFrameView (nextHandler, theEvent, userData);
- case OS.kEventMenuDrawItem: return kEventMenuDrawItem (nextHandler, theEvent, userData);
- case OS.kEventMenuDrawItemContent: return kEventMenuDrawItemContent (nextHandler, theEvent, userData);
- case OS.kEventMenuGetFrameBounds: return kEventMenuGetFrameBounds (nextHandler, theEvent, userData);
- case OS.kEventMenuMeasureItemWidth: return kEventMenuMeasureItemWidth (nextHandler, theEvent, userData);
- case OS.kEventMenuOpening: return kEventMenuOpening (nextHandler, theEvent, userData);
- case OS.kEventMenuTargetItem: return kEventMenuTargetItem (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-int mouseProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventMouseDown: return kEventMouseDown (nextHandler, theEvent, userData);
- case OS.kEventMouseUp: return kEventMouseUp (nextHandler, theEvent, userData);
- case OS.kEventMouseDragged: return kEventMouseDragged (nextHandler, theEvent, userData);
-// case OS.kEventMouseEntered: return kEventMouseEntered (nextHandler, theEvent, userData);
-// case OS.kEventMouseExited: return kEventMouseExited (nextHandler, theEvent, userData);
- case OS.kEventMouseMoved: return kEventMouseMoved (nextHandler, theEvent, userData);
- case OS.kEventMouseWheelMoved: return kEventMouseWheelMoved (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-/**
- * Notifies all of the receiver's listeners for events
- * of the given type that one such event has occurred by
- * invoking their <code>handleEvent()</code> method. The
- * event type is one of the event constants defined in class
- * <code>SWT</code>.
- *
- * @param eventType the type of event which has occurred
- * @param event the event data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- * @see #addListener
- * @see #removeListener
- */
-public void notifyListeners (int eventType, Event event) {
- checkWidget();
- if (event == null) event = new Event ();
- sendEvent (eventType, event);
-}
-
-void postEvent (int eventType) {
- sendEvent (eventType, null, false);
-}
-
-void postEvent (int eventType, Event event) {
- sendEvent (eventType, event, false);
-}
-
-void redrawChildren (int control) {
- int child = OS.HIViewGetFirstSubview (control);
- while (child != 0) {
- OS.HIViewSetNeedsDisplay (child, true);
- redrawChildren (child);
- child = OS.HIViewGetNextView (child);
- }
-}
-
-void redrawChildren (int control, int rgn) {
- int child = OS.HIViewGetFirstSubview (control);
- while (child != 0) {
- OS.HIViewConvertRegion(rgn, control, child);
- OS.HIViewSetNeedsDisplayInRegion (child, rgn, true);
- redrawChildren (child, rgn);
- OS.HIViewConvertRegion(rgn, child, control);
- child = OS.HIViewGetNextView (child);
- }
-}
-
-void redrawWidget (int control, boolean children) {
- if (OS.HIVIEW) {
- if (display.inPaint) {
- int rgn = OS.NewRgn ();
- Rect rect = new Rect ();
- OS.GetControlBounds (control, rect);
- rect.right += rect.left;
- rect.bottom += rect.top;
- rect.top = rect.left = 0;
- OS.RectRgn (rgn, rect);
- OS.HIViewConvertRegion (rgn, control, 0);
- invalWindowRgn (0, rgn);
- OS.DisposeRgn (rgn);
- } else {
- OS.HIViewSetNeedsDisplay (control, true);
- if (children) redrawChildren (control);
- }
- return;
- }
- if (!isDrawing (control)) return;
- int window = OS.GetControlOwner (control);
- int visibleRgn = getVisibleRegion (control, !children);
- invalWindowRgn (window, visibleRgn);
- OS.DisposeRgn (visibleRgn);
-}
-
-void redrawWidget (int control, int x, int y, int width, int height, boolean children) {
- if (OS.HIVIEW) {
- int rgn = OS.NewRgn ();
- Rect rect = new Rect ();
- OS.SetRect (rect, (short) x, (short) y, (short) (x + width), (short) (y + height));
- OS.RectRgn (rgn, rect);
- if (display.inPaint) {
- OS.HIViewConvertRegion (rgn, control, 0);
- invalWindowRgn (0, rgn);
- } else {
- OS.HIViewSetNeedsDisplayInRegion (control, rgn, true);
- if (children) redrawChildren (control, rgn);
- }
- OS.DisposeRgn (rgn);
- return;
- }
- if (!isDrawing (control)) return;
- Rect rect = new Rect ();
- OS.GetControlBounds (control, rect);
- x += rect.left;
- y += rect.top;
- OS.SetRect (rect, (short) x, (short) y, (short) (x + width), (short) (y + height));
- int rectRgn = OS.NewRgn();
- OS.RectRgn (rectRgn, rect);
- int visibleRgn = getVisibleRegion (control, !children);
- OS.SectRgn (rectRgn, visibleRgn, visibleRgn);
- int window = OS.GetControlOwner (control);
- invalWindowRgn (window, visibleRgn);
- OS.DisposeRgn (rectRgn);
- OS.DisposeRgn (visibleRgn);
-}
-
-void register () {
-}
-
-void release (boolean destroy) {
- if ((state & DISPOSE_SENT) == 0) {
- state |= DISPOSE_SENT;
- sendEvent (SWT.Dispose);
- }
- if ((state & DISPOSED) == 0) {
- releaseChildren (destroy);
- }
- if ((state & RELEASED) == 0) {
- state |= RELEASED;
- if (destroy) {
- releaseParent ();
- releaseWidget ();
- destroyWidget ();
- } else {
- releaseWidget ();
- releaseHandle ();
- }
- }
-}
-
-void releaseChildren (boolean destroy) {
-}
-
-void releaseHandle () {
- state |= DISPOSED;
- display = null;
-}
-
-void releaseParent () {
- /* Do nothing */
-}
-
-void releaseWidget () {
- deregister ();
- eventTable = null;
- data = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when an event of the given type occurs. The event
- * type is one of the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #addListener
- * @see #notifyListeners
- */
-public void removeListener (int eventType, Listener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when an event of the given type occurs.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
- * public API. It is marked public only so that it can be shared
- * within the packages provided by SWT. It should never be
- * referenced from application code.
- * </p>
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- */
-protected void removeListener (int eventType, SWTEventListener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the widget is disposed.
- *
- * @param listener the listener which should no longer be notified when the receiver is disposed
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DisposeListener
- * @see #addDisposeListener
- */
-public void removeDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Dispose, listener);
-}
-
-void sendEvent (Event event) {
- Display display = event.display;
- if (!display.filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-void sendEvent (int eventType) {
- sendEvent (eventType, null, true);
-}
-
-void sendEvent (int eventType, Event event) {
- sendEvent (eventType, event, true);
-}
-
-void sendEvent (int eventType, Event event, boolean send) {
- if (eventTable == null && !display.filters (eventType)) {
- return;
- }
- if (event == null) event = new Event ();
- event.type = eventType;
- event.display = display;
- event.widget = this;
- if (event.time == 0) {
- event.time = display.getLastEventTime ();
- }
- if (send) {
- sendEvent (event);
- } else {
- display.postEvent (event);
- }
-}
-
-
-boolean sendKeyEvent (int type, int theEvent) {
- int [] length = new int [1];
- int status = OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, 4, length, (char[])null);
- if (status == OS.noErr && length [0] > 2) {
- int count = 0;
- int [] chord = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
- int [] modifiers = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
- char [] chars = new char [length [0] / 2];
- OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, chars.length * 2, null, chars);
- for (int i=0; i<chars.length; i++) {
- Event event = new Event ();
- event.character = chars [i];
- setInputState (event, type, chord [0], modifiers [0]);
- if (sendKeyEvent (type, event)) chars [count++] = chars [i];
- }
- if (count == 0) return false;
- if (count != chars.length - 1) {
- OS.SetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, count * 2, chars);
- }
- return true;
- } else {
- Event event = new Event ();
- if (!setKeyState (event, type, theEvent)) return true;
- return sendKeyEvent (type, event);
- }
-}
-
-boolean sendKeyEvent (int type, Event event) {
- sendEvent (type, event);
- // widget could be disposed at this point
-
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the key
- * events. If this happens, end the processing of
- * the key by returning false.
- */
- if (isDisposed ()) return false;
- return event.doit;
-}
-
-int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- boolean sameOrigin = true, sameExtent = true;
- if (OS.HIVIEW) {
- CGRect oldBounds = new CGRect ();
- OS.HIViewGetFrame (control, oldBounds);
- Rect inset = getInset ();
- oldBounds.x -= inset.left;
- oldBounds.y -= inset.top;
- oldBounds.width += inset.left + inset.right;
- oldBounds.height += inset.top + inset.bottom;
- if (!move) {
- x = (int) oldBounds.x;
- y = (int) oldBounds.y;
- }
- if (!resize) {
- width = (int) oldBounds.width;
- height = (int) oldBounds.height;
- }
- CGRect newBounds = new CGRect ();
- newBounds.x = x + inset.left;
- newBounds.y = y + inset.top;
- newBounds.width = width - inset.right - inset.left;
- newBounds.height = height - inset.bottom - inset.top;
- sameOrigin = newBounds.x == oldBounds.x && newBounds.y == oldBounds.y;
- sameExtent = newBounds.width == oldBounds.width && newBounds.height == oldBounds.height;
- if (sameOrigin && sameExtent) return 0;
- OS.HIViewSetFrame (control, newBounds);
- invalidateVisibleRegion (control);
- } else {
- /* Compute the old bounds */
- Rect oldBounds = new Rect ();
- OS.GetControlBounds (control, oldBounds);
- int [] theRoot = new int [1];
- int window = OS.GetControlOwner (control);
- OS.GetRootControl (window, theRoot);
- int [] parentHandle = new int [1];
- OS.GetSuperControl (control, parentHandle);
- Rect parentRect = new Rect ();
- if (parentHandle [0] != theRoot [0]) {
- OS.GetControlBounds (parentHandle [0], parentRect);
- OS.OffsetRect (oldBounds, (short) -parentRect.left, (short) -parentRect.top);
- }
- Rect inset = getInset ();
- oldBounds.left -= inset.left;
- oldBounds.top -= inset.top;
- oldBounds.right += inset.right;
- oldBounds.bottom += inset.bottom;
-
- /* Compute the new bounds */
- if (!move) {
- x = oldBounds.left;
- y = oldBounds.top;
- }
- if (!resize) {
- width = oldBounds.right - oldBounds.left;
- height = oldBounds.bottom - oldBounds.top;
- }
- Rect newBounds = new Rect ();
- newBounds.left = (short) (parentRect.left + x + inset.left);
- newBounds.top = (short) (parentRect.top + y + inset.top);
- newBounds.right = (short) (newBounds.left + width - inset.right - inset.left);
- newBounds.bottom = (short) (newBounds.top + height - inset.bottom - inset.top);
- if (newBounds.bottom < newBounds.top) newBounds.bottom = newBounds.top;
- if (newBounds.right < newBounds.left) newBounds.right = newBounds.left;
-
- /* Get bounds again, since the one above is in SWT coordinates */
- OS.GetControlBounds (control, oldBounds);
-
- /* Check if anything changed */
- sameOrigin = newBounds.left == oldBounds.left && newBounds.top == oldBounds.top;
- sameExtent = (newBounds.right - newBounds.left) == (oldBounds.right - oldBounds.left) && (newBounds.bottom - newBounds.top) == (oldBounds.bottom - oldBounds.top);
- if (sameOrigin && sameExtent) return 0;
-
- /* Apply changes and invalidate appropriate rectangles */
- int tempRgn = 0;
- boolean visible = OS.IsControlVisible (control);
- if (visible) {
- tempRgn = OS.NewRgn ();
- OS.GetControlRegion (control, (short) OS.kControlStructureMetaPart, tempRgn);
- invalWindowRgn (window, tempRgn);
- }
- OS.SetControlBounds (control, newBounds);
- invalidateVisibleRegion (control);
- if (visible) {
- OS.GetControlRegion (control, (short) OS.kControlStructureMetaPart, tempRgn);
- invalWindowRgn (window, tempRgn);
- OS.DisposeRgn(tempRgn);
- }
- }
-
- /* Send events */
- int result = 0;
- if (move && !sameOrigin) {
- if (events) sendEvent (SWT.Move);
- result |= MOVED;
- }
- if (resize && !sameExtent) {
- if (events) sendEvent (SWT.Resize);
- result |= RESIZED;
- }
- return result;
-}
-
-/**
- * Sets the application defined widget data associated
- * with the receiver to be the argument. The <em>widget
- * data</em> is a single, unnamed field that is stored
- * with every widget.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the widget data needs to be notified
- * when the widget is disposed of, it is the application's
- * responsibility to hook the Dispose event on the widget and
- * do so.
- * </p>
- *
- * @param data the widget data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- *
- * @see #getData()
- */
-public void setData (Object data) {
- checkWidget();
- if ((state & KEYED_DATA) != 0) {
- ((Object []) this.data) [0] = data;
- } else {
- this.data = data;
- }
-}
-
-/**
- * Sets the application defined property of the receiver
- * with the specified name to the given value.
- * <p>
- * Applications may associate arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the widget is disposed
- * of, it is the application's responsibility to hook the
- * Dispose event on the widget and do so.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getData(String)
- */
-public void setData (String key, Object value) {
- checkWidget();
- if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
- // GOOGLE: patched in from https://bugs.eclipse.org/bugs/show_bug.cgi?id=161259
- if (key.equals (CLEAR_GRAB_BIT)) {
- state &= ~GRAB;
- return;
- }
- int index = 1;
- Object [] table = null;
- if ((state & KEYED_DATA) != 0) {
- table = (Object []) data;
- while (index < table.length) {
- if (key.equals (table [index])) break;
- index += 2;
- }
- }
- if (value != null) {
- if ((state & KEYED_DATA) != 0) {
- if (index == table.length) {
- Object [] newTable = new Object [table.length + 2];
- System.arraycopy (table, 0, newTable, 0, table.length);
- data = table = newTable;
- }
- } else {
- table = new Object [3];
- table [0] = data;
- data = table;
- state |= KEYED_DATA;
- }
- table [index] = key;
- table [index + 1] = value;
- } else {
- if ((state & KEYED_DATA) != 0) {
- if (index != table.length) {
- int length = table.length - 2;
- if (length == 1) {
- data = table [0];
- state &= ~KEYED_DATA;
- } else {
- Object [] newTable = new Object [length];
- System.arraycopy (table, 0, newTable, 0, index);
- System.arraycopy (table, index + 2, newTable, index, length - index);
- data = newTable;
- }
- }
- }
- }
-}
-
-boolean setInputState (Event event, int type, int chord, int modifiers) {
- if ((chord & 0x01) != 0) event.stateMask |= SWT.BUTTON1;
- if ((chord & 0x02) != 0) event.stateMask |= SWT.BUTTON3;
- if ((chord & 0x04) != 0) event.stateMask |= SWT.BUTTON2;
- if ((chord & 0x08) != 0) event.stateMask |= SWT.BUTTON4;
- if ((chord & 0x10) != 0) event.stateMask |= SWT.BUTTON5;
-
- if ((modifiers & OS.optionKey) != 0) event.stateMask |= SWT.ALT;
- if ((modifiers & OS.shiftKey) != 0) event.stateMask |= SWT.SHIFT;
- if ((modifiers & OS.controlKey) != 0) event.stateMask |= SWT.CONTROL;
- if ((modifiers & OS.cmdKey) != 0) event.stateMask |= SWT.COMMAND;
- switch (type) {
- case SWT.MouseDown:
- case SWT.MouseDoubleClick:
- if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
- if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
- if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
- if (event.button == 4) event.stateMask &= ~SWT.BUTTON4;
- if (event.button == 5) event.stateMask &= ~SWT.BUTTON5;
- break;
- case SWT.MouseUp:
- if (event.button == 1) event.stateMask |= SWT.BUTTON1;
- if (event.button == 2) event.stateMask |= SWT.BUTTON2;
- if (event.button == 3) event.stateMask |= SWT.BUTTON3;
- if (event.button == 4) event.stateMask |= SWT.BUTTON4;
- if (event.button == 5) event.stateMask |= SWT.BUTTON5;
- break;
- case SWT.KeyDown:
- case SWT.Traverse: {
- if (event.keyCode != 0 || event.character != 0) return true;
- int lastModifiers = display.lastModifiers;
- if ((modifiers & OS.alphaLock) != 0 && (lastModifiers & OS.alphaLock) == 0) {
- event.keyCode = SWT.CAPS_LOCK;
- return true;
- }
- if ((modifiers & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) {
- event.stateMask &= ~SWT.SHIFT;
- event.keyCode = SWT.SHIFT;
- return true;
- }
- if ((modifiers & OS.controlKey) != 0 && (lastModifiers & OS.controlKey) == 0) {
- event.stateMask &= ~SWT.CONTROL;
- event.keyCode = SWT.CONTROL;
- return true;
- }
- if ((modifiers & OS.cmdKey) != 0 && (lastModifiers & OS.cmdKey) == 0) {
- event.stateMask &= ~SWT.COMMAND;
- event.keyCode = SWT.COMMAND;
- return true;
- }
- if ((modifiers & OS.optionKey) != 0 && (lastModifiers & OS.optionKey) == 0) {
- event.stateMask &= ~SWT.ALT;
- event.keyCode = SWT.ALT;
- return true;
- }
- break;
- }
- case SWT.KeyUp: {
- if (event.keyCode != 0 || event.character != 0) return true;
- int lastModifiers = display.lastModifiers;
- if ((modifiers & OS.alphaLock) == 0 && (lastModifiers & OS.alphaLock) != 0) {
- event.keyCode = SWT.CAPS_LOCK;
- return true;
- }
- if ((modifiers & OS.shiftKey) == 0 && (lastModifiers & OS.shiftKey) != 0) {
- event.stateMask |= SWT.SHIFT;
- event.keyCode = SWT.SHIFT;
- return true;
- }
- if ((modifiers & OS.controlKey) == 0 && (lastModifiers & OS.controlKey) != 0) {
- event.stateMask |= SWT.CONTROL;
- event.keyCode = SWT.CONTROL;
- return true;
- }
- if ((modifiers & OS.cmdKey) == 0 && (lastModifiers & OS.cmdKey) != 0) {
- event.stateMask |= SWT.COMMAND;
- event.keyCode = SWT.COMMAND;
- return true;
- }
- if ((modifiers & OS.optionKey) == 0 && (lastModifiers & OS.optionKey) != 0) {
- event.stateMask |= SWT.ALT;
- event.keyCode = SWT.ALT;
- return true;
- }
- break;
- }
- }
- return true;
-}
-
-boolean setKeyState (Event event, int type, int theEvent) {
- boolean isNull = false;
- int [] keyCode = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode);
- event.keyCode = Display.translateKey (keyCode [0]);
- switch (event.keyCode) {
- case SWT.LF: {
- /*
- * Feature in the Macintosh. When the numeric key pad
- * Enter key is pressed, it generates '\n'. This is the
- * correct platform behavior but is not portable. The
- * fix is to convert the '\n' into '\r'.
- */
- event.keyCode = SWT.KEYPAD_CR;
- event.character = '\r';
- break;
- }
- case SWT.BS: event.character = '\b'; break;
- case SWT.CR: event.character = '\r'; break;
- case SWT.DEL: event.character = 0x7F; break;
- case SWT.ESC: event.character = 0x1B; break;
- case SWT.TAB: event.character = '\t'; break;
- default: {
- if (event.keyCode == 0 || (SWT.KEYPAD_MULTIPLY <= event.keyCode && event.keyCode <= SWT.KEYPAD_CR)) {
- int [] length = new int [1];
- int status = OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, 4, length, (char[])null);
- if (status == OS.noErr && length [0] != 0) {
- char [] chars = new char [1];
- OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, 2, null, chars);
- event.character = chars [0];
- }
- /*
- * Bug in the Mactonish. For some reason, Ctrl+Shift+'2' and Ctrl+Shift+'6'
- * fail to give 0x0 (^@ or ASCII NUL) and 0x1e (^^). Other control character
- * key sequences such as ^A or even Ctrl+Shift+'-' (^_ or 0x1f) are correctly
- * translated to control characters. Since it is not possible to know which
- * key combination gives '@' on an international keyboard, there is no way to
- * test for either character and convert it to a control character (Shift+'2'
- * gives '@' only on an English keyboard) to work around the problem.
- *
- * There is no fix at this time.
- */
- }
- if (event.keyCode == 0) {
- int kchrPtr = OS.GetScriptManagerVariable ((short) OS.smKCHRCache);
- if (display.kchrPtr != kchrPtr) {
- display.kchrPtr = kchrPtr;
- display.kchrState [0] = 0;
- }
- int result = OS.KeyTranslate (display.kchrPtr, (short)keyCode [0], display.kchrState);
- if (result <= 0x7f) {
- event.keyCode = result & 0x7f;
- } else {
- int [] encoding = new int [1];
- short keyScript = (short) OS.GetScriptManagerVariable ((short) OS.smKeyScript);
- short regionCode = (short) OS.GetScriptManagerVariable ((short) OS.smRegionCode);
- if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, regionCode, null, encoding) == OS.paramErr) {
- if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, (short) OS.kTextRegionDontCare, null, encoding) == OS.paramErr) {
- encoding [0] = OS.kTextEncodingMacRoman;
- }
- }
- int [] encodingInfo = new int [1];
- OS.CreateTextToUnicodeInfoByEncoding (encoding [0], encodingInfo);
- if (encodingInfo [0] != 0) {
- char [] chars = new char [1];
- int [] nchars = new int [1];
- byte [] buffer = new byte [2];
- buffer [0] = 1;
- buffer [1] = (byte) (result & 0xFF);
- OS.ConvertFromPStringToUnicode (encodingInfo [0], buffer, chars.length * 2, nchars, chars);
- OS.DisposeTextToUnicodeInfo (encodingInfo);
- event.keyCode = chars [0];
- }
- }
- }
- break;
- }
- }
- if (event.keyCode == 0 && event.character == 0) {
- if (!isNull) return false;
- }
- int [] chord = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
- int [] modifiers = new int [1];
- OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
- return setInputState (event, type, chord [0], modifiers [0]);
-}
-
-void setVisible (int control, boolean visible) {
- if (OS.HIVIEW) {
- OS.HIViewSetVisible (control, visible);
- invalidateVisibleRegion (control);
- } else {
- int visibleRgn = 0;
- boolean drawing = getDrawCount (control) == 0;
- if (drawing && !visible) visibleRgn = getVisibleRegion (control, false);
- OS.SetControlVisibility (control, visible, false);
- invalidateVisibleRegion (control);
- if (drawing && visible) visibleRgn = getVisibleRegion (control, false);
- if (drawing) {
- int window = OS.GetControlOwner (control);
- invalWindowRgn (window, visibleRgn);
- OS.DisposeRgn (visibleRgn);
- }
- }
-}
-
-void setZOrder (int control, int otheControl, boolean above) {
- if (OS.HIVIEW) {
- int inOp = above ? OS.kHIViewZOrderAbove : OS.kHIViewZOrderBelow;
- OS.HIViewSetZOrder (control, inOp, otheControl);
- invalidateVisibleRegion (control);
- } else {
- int inOp = above ? OS.kHIViewZOrderBelow : OS.kHIViewZOrderAbove;
- int oldRgn = 0;
- boolean drawing = isDrawing (control);
- if (drawing) oldRgn = getVisibleRegion (control, false);
- OS.HIViewSetZOrder (control, inOp, otheControl);
- invalidateVisibleRegion (control);
- if (drawing) {
- int newRgn = getVisibleRegion (control, false);
- if (above) {
- OS.DiffRgn (newRgn, oldRgn, newRgn);
- } else {
- OS.DiffRgn (oldRgn, newRgn, newRgn);
- }
- int window = OS.GetControlOwner (control);
- invalWindowRgn (window, newRgn);
- OS.DisposeRgn (oldRgn);
- OS.DisposeRgn (newRgn);
- }
- }
-}
-
-int textInputProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventTextInputUnicodeForKeyEvent: return kEventTextInputUnicodeForKeyEvent (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-RGBColor toRGBColor (float [] color) {
- RGBColor rgb = new RGBColor ();
- rgb.red = (short) (color [0] * 0xffff);
- rgb.green = (short) (color [1] * 0xffff);
- rgb.blue = (short) (color [2] * 0xffff);
- return rgb;
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
-public String toString () {
- String string = "*Disposed*";
- if (!isDisposed ()) {
- string = "*Wrong Thread*";
- if (isValidThread ()) string = getNameText ();
- }
- return getName () + " {" + string + "}";
-}
-
-int trackingProc (int browser, int itemID, int property, int theRect, int startPt, int modifiers) {
- /* Return one to indicate that the data browser should process the click */
- return 1;
-}
-
-int windowProc (int nextHandler, int theEvent, int userData) {
- int eventKind = OS.GetEventKind (theEvent);
- switch (eventKind) {
- case OS.kEventWindowActivated: return kEventWindowActivated (nextHandler, theEvent, userData);
- case OS.kEventWindowBoundsChanged: return kEventWindowBoundsChanged (nextHandler, theEvent, userData);
- case OS.kEventWindowClose: return kEventWindowClose (nextHandler, theEvent, userData);
- case OS.kEventWindowCollapsed: return kEventWindowCollapsed (nextHandler, theEvent, userData);
- case OS.kEventWindowDeactivated: return kEventWindowDeactivated (nextHandler, theEvent, userData);
- case OS.kEventWindowDrawContent: return kEventWindowDrawContent (nextHandler, theEvent, userData);
- case OS.kEventWindowExpanded: return kEventWindowExpanded (nextHandler, theEvent, userData);
- case OS.kEventWindowGetRegion: return kEventWindowGetRegion (nextHandler, theEvent, userData);
- case OS.kEventWindowHidden: return kEventWindowHidden (nextHandler, theEvent, userData);
- case OS.kEventWindowHitTest: return kEventWindowHitTest (nextHandler, theEvent, userData);
- case OS.kEventWindowShown: return kEventWindowShown (nextHandler, theEvent, userData);
- case OS.kEventWindowUpdate: return kEventWindowUpdate (nextHandler, theEvent, userData);
- case OS.kEventWindowGetClickModality: return kEventWindowGetClickModality (nextHandler, theEvent, userData);
- }
- return OS.eventNotHandledErr;
-}
-
-}
diff --git a/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java b/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java
index 22afde9..b5c34f3 100644
--- a/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java
+++ b/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java
@@ -22,7 +22,6 @@
import com.google.gwt.dev.GWTCompiler.GWTCompilerOptionsImpl;
import com.google.gwt.dev.cfg.ModuleDef;
import com.google.gwt.dev.shell.ArtifactAcceptor;
-import com.google.gwt.dev.shell.BrowserWidget;
import com.google.gwt.dev.shell.WorkDirs;
import com.google.gwt.dev.shell.tomcat.EmbeddedTomcatServer;
import com.google.gwt.dev.util.Util;
@@ -190,11 +189,6 @@
return WebServerRestart.NONE;
}
- @Override
- public BrowserWidget openNewBrowserWindow() throws UnableToCompleteException {
- throw new UnableToCompleteException();
- }
-
public void restartServer(TreeLogger logger) throws UnableToCompleteException {
// Unimplemented.
}
diff --git a/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java b/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java
index 908a578..43bbc2e 100644
--- a/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java
+++ b/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java
@@ -21,7 +21,6 @@
import com.google.gwt.dev.WebServerPanel.RestartAction;
import com.google.gwt.dev.cfg.ModuleDef;
import com.google.gwt.dev.shell.BrowserListener;
-import com.google.gwt.dev.shell.BrowserWidget;
import com.google.gwt.dev.shell.BrowserWidgetHost;
import com.google.gwt.dev.shell.ModuleSpaceHost;
import com.google.gwt.dev.shell.OophmSessionHandler;
@@ -105,7 +104,7 @@
}
}
- interface OptionPortHosted {
+ protected interface OptionPortHosted {
int getPortHosted();
void setPortHosted(int portHosted);
@@ -114,7 +113,7 @@
/**
* Handles the -portHosted command line flag.
*/
- private static class ArgHandlerPortHosted extends ArgHandlerString {
+ protected static class ArgHandlerPortHosted extends ArgHandlerString {
private final OptionPortHosted options;
@@ -162,13 +161,6 @@
private final Map<ModuleSpaceHost, ModulePanel> moduleTabs = new IdentityHashMap<ModuleSpaceHost, ModulePanel>();
private final Map<DevelModeTabKey, ModuleTabPanel> tabPanels = new HashMap<DevelModeTabKey, ModuleTabPanel>();
- @Override
- public ModuleSpaceHost createModuleSpaceHost(TreeLogger logger,
- BrowserWidget widget, String moduleName)
- throws UnableToCompleteException {
- throw new UnsupportedOperationException();
- }
-
public ModuleSpaceHost createModuleSpaceHost(TreeLogger mainLogger,
String moduleName, String userAgent, String url, String tabKey,
String sessionKey, String remoteSocket)
@@ -358,6 +350,8 @@
private AbstractTreeLogger topLogger;
+ protected int codeServerPort;
+
public OophmHostedModeBase() {
super();
}
@@ -429,10 +423,6 @@
"Waiting for browser connection to " + url, null);
}
- public BrowserWidget openNewBrowserWindow() throws UnableToCompleteException {
- throw new UnableToCompleteException();
- }
-
/**
* @throws UnableToCompleteException
*/
@@ -508,17 +498,15 @@
}
@Override
- protected void loadRequiredNativeLibs() {
- // no native libraries are needed with OOPHM
- }
-
- @Override
protected synchronized boolean notDone() {
return !mainWindowClosed;
}
@Override
protected void openAppWindow() {
+ if (isHeadless()) {
+ return;
+ }
ImageIcon gwtIcon = loadImageIcon("icon24.png");
frame = new JFrame("GWT Development Mode");
tabs = new JTabbedPane();
@@ -566,9 +554,16 @@
private void ensureOophmListener() {
if (listener == null) {
- listener = new BrowserListener(getTopLogger(), options.getPortHosted(),
+ codeServerPort = options.getPortHosted();
+ listener = new BrowserListener(getTopLogger(), codeServerPort,
new OophmSessionHandler(browserHost));
listener.start();
+ try {
+ // save the port we actually used if it was auto
+ codeServerPort = listener.getSocketPort();
+ } catch (UnableToCompleteException e) {
+ // ignore errors listening, we will catch them later
+ }
}
}
}
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/BrowserListener.java b/dev/oophm/src/com/google/gwt/dev/shell/BrowserListener.java
index 66d9421..8a553be 100644
--- a/dev/oophm/src/com/google/gwt/dev/shell/BrowserListener.java
+++ b/dev/oophm/src/com/google/gwt/dev/shell/BrowserListener.java
@@ -102,6 +102,14 @@
}
}
+ public int getSocketPort() throws UnableToCompleteException {
+ if (listenSocket == null) {
+ // If we failed to initialize our socket, just bail here.
+ throw new UnableToCompleteException();
+ }
+ return listenSocket.getLocalPort();
+ }
+
public void start() {
if (listenThread != null) {
listenThread.start();
diff --git a/dev/windows/build.xml b/dev/windows/build.xml
deleted file mode 100755
index c504aca..0000000
--- a/dev/windows/build.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<project name="dev-windows" default="build" basedir=".">
- <property name="project.tail" value="dev/windows" />
- <property name="gwt.dev.swt.jar" value="org.eclipse.swt.win32-win32-3.2.1.jar"/>
- <import file="../common.ant.xml" />
-</project>
diff --git a/dev/windows/src/com/google/gwt/dev/BootStrapPlatform.java b/dev/windows/src/com/google/gwt/dev/BootStrapPlatform.java
deleted file mode 100644
index 7e261dc..0000000
--- a/dev/windows/src/com/google/gwt/dev/BootStrapPlatform.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev;
-
-/**
- * Placeholder platform bootstrap class.
- */
-public class BootStrapPlatform {
-
- public static void applyPlatformHacks() {
- // nothing to do
- }
-
- public static void initGui() {
- // nothing to do
- }
-
- public static void initHostedMode() {
- // nothing to do
- }
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/BrowserWidgetIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/BrowserWidgetIE6.java
deleted file mode 100644
index 8cfb7c4..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/BrowserWidgetIE6.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.shell.BrowserWidget;
-import com.google.gwt.dev.shell.BrowserWidgetHost;
-import com.google.gwt.dev.shell.HostedHtmlVersion;
-import com.google.gwt.dev.shell.MethodAdaptor;
-import com.google.gwt.dev.shell.ModuleSpaceHost;
-
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.ole.win32.IDispatch;
-import org.eclipse.swt.ole.win32.OleAutomation;
-import org.eclipse.swt.ole.win32.Variant;
-import org.eclipse.swt.widgets.Shell;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Represents an individual browser window and all of its controls.
- */
-public class BrowserWidgetIE6 extends BrowserWidget {
-
- /**
- * IDispatch implementation of the window.external object.
- */
- public class External extends IDispatchImpl {
-
- /**
- * Called by the loaded HTML page to activate a new module.
- *
- * @param frameWnd a reference to the IFRAME in which the module's injected
- * JavaScript will live
- * @param moduleName the name of the module to load, null if this is being
- * unloaded
- */
- public boolean gwtOnLoad(IDispatch frameWnd, String moduleName,
- String version) {
- if (moduleName == null) {
- // Indicates one or more modules are being unloaded.
- return handleUnload(frameWnd);
- }
-
- TreeLogger logger = getHost().getLogger().branch(TreeLogger.DEBUG,
- "Loading an instance of module '" + moduleName + "'");
- try {
- if (!HostedHtmlVersion.validHostedHtmlVersion(logger, version)) {
- throw new HResultException(COM.E_INVALIDARG);
- }
-
- // set the module ID
- int moduleID = ++nextModuleID;
- Integer key = new Integer(moduleID);
- setIntProperty(frameWnd, "__gwt_module_id", moduleID);
-
- // Attach a new ModuleSpace to make it programmable.
- //
- ModuleSpaceHost msh = getHost().createModuleSpaceHost(logger,
- BrowserWidgetIE6.this, moduleName);
- ModuleSpaceIE6 moduleSpace = new ModuleSpaceIE6(logger, msh, frameWnd,
- moduleName, key);
- attachModuleSpace(logger, moduleSpace);
- return true;
- } catch (Throwable e) {
- // We do catch Throwable intentionally because there are a ton of things
- // that can go wrong trying to load a module, including Error-derived
- // things like NoClassDefFoundError.
- //
- logger.log(TreeLogger.ERROR, "Failure to load module '" + moduleName
- + "'", e);
- return false;
- }
- }
-
- /**
- * Causes a link to occur for the specified module.
- *
- * @param moduleName the module name to link
- * @return <code>true</code> if this module is stale and should be
- * reloaded
- */
- public boolean initModule(String moduleName) {
- return getHost().initModule(moduleName);
- }
-
- @Override
- protected void getIDsOfNames(String[] names, int[] ids)
- throws HResultException {
-
- if (names.length >= 2) {
- throw new HResultException(DISP_E_UNKNOWNNAME);
- }
-
- String name = names[0].toLowerCase();
- if (name.equals("gwtonload")) {
- ids[0] = 1;
- return;
- } else if (name.equals("initmodule")) {
- ids[0] = 2;
- return;
- }
-
- throw new HResultException(DISP_E_UNKNOWNNAME);
- }
-
- /**
- * Unload one or more modules.
- *
- * @param frameWnd window to unload, null if all
- */
- protected boolean handleUnload(IDispatch frameWnd) {
- try {
- Integer key = null;
- if (frameWnd != null) {
- key = new Integer(getIntProperty(frameWnd, "__gwt_module_id"));
- }
- doUnload(key);
- return true;
- } catch (Throwable e) {
- getHost().getLogger().log(TreeLogger.ERROR,
- "Failure to unload modules", e);
- return false;
- }
- }
-
- @Override
- protected Variant invoke(int dispId, int flags, Variant[] params)
- throws HResultException, InvocationTargetException {
-
- if (dispId == 0 && (flags & COM.DISPATCH_PROPERTYGET) != 0) {
- // MAGIC: this is the default property, let's just do toString()
- return new Variant(toString());
- } else if (dispId == 1) {
- if ((flags & COM.DISPATCH_METHOD) != 0) {
- try {
- if (params.length < 3) {
- reportIncorrectInvocation("gwtOnLoad", 3, params.length);
- throw new HResultException(COM.E_INVALIDARG);
- }
- IDispatch frameWnd = (params[0].getType() == COM.VT_DISPATCH)
- ? params[0].getDispatch() : null;
- String moduleName = (params[1].getType() == COM.VT_BSTR)
- ? params[1].getString() : null;
- String version = (params[2].getType() == COM.VT_BSTR)
- ? params[2].getString() : null;
- boolean success = gwtOnLoad(frameWnd, moduleName, version);
-
- // boolean return type
- return new Variant(success);
- } catch (SWTException e) {
- throw new HResultException(COM.E_INVALIDARG);
- }
- } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
- // property get on the method itself
- try {
- Method gwtOnLoadMethod = getClass().getMethod("gwtOnLoad",
- new Class[] {IDispatch.class, String.class, String.class});
- MethodAdaptor methodAdaptor = new MethodAdaptor(gwtOnLoadMethod);
- IDispatchImpl funcObj = new MethodDispatch(null, methodAdaptor);
- IDispatch disp = new IDispatch(funcObj.getAddress());
- disp.AddRef();
- return new Variant(disp);
- } catch (Exception e) {
- // just return VT_EMPTY
- return new Variant();
- }
- }
- throw new HResultException(COM.E_NOTSUPPORTED);
- } else if (dispId == 2) {
- if ((flags & COM.DISPATCH_METHOD) != 0) {
- try {
- if (params.length < 1) {
- reportIncorrectInvocation("initModule", 1, params.length);
- throw new HResultException(COM.E_INVALIDARG);
- }
- String moduleName = (params[0].getType() == COM.VT_BSTR)
- ? params[0].getString() : null;
- boolean reload = initModule(moduleName);
-
- // boolean return type
- return new Variant(reload);
- } catch (SWTException e) {
- throw new HResultException(COM.E_INVALIDARG);
- }
- } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
- // property get on the method itself
- try {
- Method gwtOnLoadMethod = getClass().getMethod("initModule",
- new Class[] {String.class});
- MethodAdaptor methodAdaptor = new MethodAdaptor(gwtOnLoadMethod);
- IDispatchImpl funcObj = new MethodDispatch(null, methodAdaptor);
- IDispatch disp = new IDispatch(funcObj.getAddress());
- disp.AddRef();
- return new Variant(disp);
- } catch (Exception e) {
- // just return VT_EMPTY
- return new Variant();
- }
- }
- throw new HResultException(COM.E_NOTSUPPORTED);
- }
-
- // The specified member id is out of range.
- throw new HResultException(COM.DISP_E_MEMBERNOTFOUND);
- }
- }
-
- // counter to generate unique module IDs
- private static int nextModuleID = 0;
-
- /**
- * Get a property off a window object as an integer.
- *
- * @param frameWnd inner code frame
- * @param propName name of the property to get
- * @return the property value as an integer
- * @throws RuntimeException if the property does not exist
- */
- private static int getIntProperty(IDispatch frameWnd, String propName) {
- OleAutomation window = null;
- try {
- window = new OleAutomation(frameWnd);
- int[] dispID = window.getIDsOfNames(new String[] {propName});
- if (dispID == null) {
- throw new RuntimeException("No such property " + propName);
- }
- Variant value = null;
- try {
- value = window.getProperty(dispID[0]);
- return value.getInt();
- } finally {
- if (value != null) {
- value.dispose();
- }
- }
- } finally {
- if (window != null) {
- window.dispose();
- }
- }
- }
-
- /**
- * Set a property off a window object from an integer value.
- *
- * @param frameWnd inner code frame
- * @param propName name of the property to set
- * @param intValue the value to set
- * @throws RuntimeException if the property does not exist
- */
- private static void setIntProperty(IDispatch frameWnd, String propName,
- int intValue) {
- OleAutomation window = null;
- try {
- window = new OleAutomation(frameWnd);
- int[] dispID = window.getIDsOfNames(new String[] {propName});
- if (dispID == null) {
- throw new RuntimeException("No such property " + propName);
- }
- Variant value = null;
- try {
- value = new Variant(intValue);
- window.setProperty(dispID[0], value);
- } finally {
- if (value != null) {
- value.dispose();
- }
- }
- } finally {
- if (window != null) {
- window.dispose();
- }
- }
- }
-
- public BrowserWidgetIE6(Shell shell, BrowserWidgetHost host) {
- super(shell, host);
-
- // Expose a 'window.external' object. This object's onLoad() method will
- // be called when a hosted mode application's wrapper HTML is done loading.
- //
- SwtOleGlue.injectBrowserScriptExternalObject(browser, new External());
-
- // Make sure that the LowLevelIE6 magic is properly initialized.
- //
- LowLevelIE6.init();
- }
-
- @Override
- public String getUserAgent() {
- // See UserAgent.gwt.xml
- return "ie6";
- }
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/COMObjectProxy.java b/dev/windows/src/com/google/gwt/dev/shell/ie/COMObjectProxy.java
deleted file mode 100644
index 01fc8ce..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/COMObjectProxy.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.dev.shell.LowLevel;
-
-import org.eclipse.swt.internal.ole.win32.COMObject;
-
-import java.util.Map;
-
-/**
- * A proxy object that allows you to override behavior in an existing COM
- * object. This is used primarily for fixing up the
- * {@link org.eclipse.swt.browser.Browser} object's 'window.external' handling.
- */
-class COMObjectProxy extends COMObject {
-
- private static final int MAX_METHODS_WRAPPED = 23;
-
- private COMObject target;
-
- /**
- * Construct a proxy object.
- *
- * @param argCounts must be the same array of argCounts used to contruct the
- * wrapped object.
- */
- public COMObjectProxy(int[] argCounts) {
- // Construct myself as a COMObject, even though my vtbl will never
- // actually be used, I need to castable to a COMObject when I injected
- // myself into the ObjectMap.
- super(argCounts);
-
- // Because I will never be called through my vtbl, I can free my OS
- // memory created in the superclass ctor and remove myself from the
- // ObjectMap. If this didn't work, we'd be leaking memory when
- // the last release is called (unless we assume that method index 2 was
- // Release(), which actually is likely a safe assumption.)
- dispose();
-
- // Make sure the interface isn't too big.
- if (argCounts != null && argCounts.length >= MAX_METHODS_WRAPPED) {
- throw new IllegalArgumentException("No more than " + MAX_METHODS_WRAPPED
- + " methods can be wrapped right now.");
- }
- }
-
- /**
- * Interpose this object in front of an existing object.
- */
- public void interpose(COMObject victim) {
- if (this.target != null) {
- throw new IllegalStateException("interpose() can only be called once");
- }
-
- // Hang onto the object we're wrapping so that we can delegate later.
- this.target = victim;
-
- // Get the COMObject ObjectMap so that we can hijack the target's slot.
- Map<Integer, COMObject> objectMap = LowLevel.snatchFieldObjectValue(
- COMObject.class, null, "ObjectMap");
- Integer ppVtableTarget = new Integer(target.getAddress());
-
- // First, make sure that the target is still actually in the map.
- // If it isn't still in there, then the caller is using me incorrectly.
- COMObject currValue = objectMap.get(ppVtableTarget);
- if (currValue != target) {
- throw new IllegalStateException("target object is not currently mapped");
- }
-
- // Replace target's entry in COMObject's (vtbl -> instance) map with
- // a reference to this object instead. Calls still come in on the
- // target's vtbl, but COMObject will route them to me instead,
- // so that I can hook/delegate them.
- objectMap.put(ppVtableTarget, this);
- }
-
- @Override
- public int method0(int[] args) {
- return target.method0(args);
- }
-
- @Override
- public int method1(int[] args) {
- return target.method1(args);
- }
-
- @Override
- public int method10(int[] args) {
- return target.method10(args);
- }
-
- @Override
- public int method11(int[] args) {
- return target.method11(args);
- }
-
- @Override
- public int method12(int[] args) {
- return target.method12(args);
- }
-
- @Override
- public int method13(int[] args) {
- return target.method13(args);
- }
-
- @Override
- public int method14(int[] args) {
- return target.method14(args);
- }
-
- @Override
- public int method15(int[] args) {
- return target.method15(args);
- }
-
- @Override
- public int method16(int[] args) {
- return target.method16(args);
- }
-
- @Override
- public int method17(int[] args) {
- return target.method17(args);
- }
-
- @Override
- public int method18(int[] args) {
- return target.method18(args);
- }
-
- @Override
- public int method19(int[] args) {
- return target.method19(args);
- }
-
- @Override
- public int method2(int[] args) {
- return target.method2(args);
- }
-
- @Override
- public int method20(int[] args) {
- return target.method20(args);
- }
-
- @Override
- public int method21(int[] args) {
- return target.method21(args);
- }
-
- @Override
- public int method22(int[] args) {
- return target.method22(args);
- }
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/CheckForUpdatesIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/CheckForUpdatesIE6.java
deleted file mode 100644
index cdd1637..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/CheckForUpdatesIE6.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.shell.CheckForUpdates;
-
-/**
- * IE6 implementation of the update checker.
- */
-public class CheckForUpdatesIE6 extends CheckForUpdates {
-
- public CheckForUpdatesIE6(TreeLogger logger, String entryPoint) {
- super(logger, entryPoint);
- LowLevelIE6.init();
- }
-
- @Override
- protected byte[] doHttpGet(TreeLogger branch, String userAgent, String url) {
- byte[] response = LowLevelIE6.httpGet(branch, userAgent, url,
- System.getProperty(PROPERTY_DEBUG_HTTP_GET) != null);
- return response;
- }
-
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchImpl.java b/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchImpl.java
deleted file mode 100644
index 9223168..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchImpl.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.MethodAdaptor;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
-
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.ole.win32.COMObject;
-import org.eclipse.swt.internal.ole.win32.DISPPARAMS;
-import org.eclipse.swt.internal.ole.win32.GUID;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.ole.win32.OleAutomation;
-import org.eclipse.swt.ole.win32.Variant;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-
-/**
- * Basic IDispatch implementation for use by
- * {@link com.google.gwt.shell.ie.IDispatchProxy} and
- * {@link com.google.gwt.shell.ie.IDispatchStatic}.
- */
-abstract class IDispatchImpl extends COMObject {
-
- /**
- * An exception for wrapping bad HR's.
- */
- protected static class HResultException extends Exception {
- private int hr;
-
- private String source;
-
- /**
- * Constructs a standard bad HR exception.
- */
- public HResultException(int hr) {
- super(Integer.toString(hr));
- this.hr = hr;
- source = "Java";
- }
-
- /**
- * Constructs a DISP_E_EXCEPTION bad HR.
- */
- public HResultException(String message) {
- super(message);
- hr = COM.DISP_E_EXCEPTION;
- source = "Java";
- }
-
- /**
- * Constructs a DISP_E_EXCEPTION bad HR.
- */
- public HResultException(Throwable e) {
- super(AbstractTreeLogger.getStackTraceAsString(e), e);
- hr = COM.DISP_E_EXCEPTION;
- source = "Java";
- }
-
- /**
- * If the HR is DISP_E_EXCEPTION, this method will fill in the EXCEPINFO
- * structure. Otherwise, it does nothing.
- */
- public void fillExcepInfo(int pExcepInfo) {
- if (hr == COM.DISP_E_EXCEPTION) {
- String desc = getMessage();
- // 0: wCode (size = 2)
- // 4: bstrSource (size = 4)
- // 8: bstrDescription (size = 4)
- // 28: scode (size = 4)
- //
- OS.MoveMemory(pExcepInfo + 0, new short[] {(short) hr}, 2);
-
- if (source != null) {
- int bstrSource = SwtOleGlue.sysAllocString(source);
- OS.MoveMemory(pExcepInfo + 4, new int[] {bstrSource}, 4);
- }
-
- if (desc != null) {
- int bstrDesc = SwtOleGlue.sysAllocString(desc);
- OS.MoveMemory(pExcepInfo + 8, new int[] {bstrDesc}, 4);
- }
-
- OS.MoveMemory(pExcepInfo + 28, new int[] {0}, 4);
- }
- }
-
- /**
- * Gets the HR.
- */
- public int getHResult() {
- return hr;
- }
- }
-
- // This one isn't defined in SWT for some reason.
- protected static final int DISP_E_UNKNOWNNAME = 0x80020006;
-
- protected static Variant callMethod(CompilingClassLoader cl, Object jthis,
- Variant[] params, MethodAdaptor method) throws InstantiationException,
- InvocationTargetException, HResultException {
- // TODO: make sure we have enough args! It's okay if there are too many.
- Object[] javaParams = SwtOleGlue.convertVariantsToObjects(cl,
- method.getParameterTypes(), params, "Calling method '"
- + method.getName() + "'");
-
- Object result = null;
- try {
- try {
- result = method.invoke(jthis, javaParams);
- } catch (IllegalAccessException e) {
- // should never, ever happen
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- } catch (NullPointerException e) {
- /*
- * The JavaScript expected the method to be static, having forgotten an
- * instance reference (most often "this.").
- */
- StringBuffer sb = new StringBuffer();
- sb.append("Instance method '");
- sb.append(method.getName());
- sb.append("' needed a qualifying instance ");
- sb.append("(did you forget to prefix the call with 'this.'?)");
- throw new HResultException(sb.toString());
- } finally {
- for (int i = 0; i < javaParams.length; i++) {
- if (javaParams[i] instanceof OleAutomation) {
- OleAutomation tmp = (OleAutomation) javaParams[i];
- tmp.dispose();
- }
- }
- }
-
- return SwtOleGlue.convertObjectToVariant(cl, method.getReturnType(), result);
- }
-
- protected int refCount;
-
- public IDispatchImpl() {
- super(new int[] {2, 0, 0, 1, 3, 5, 8});
- }
-
- // CHECKSTYLE_OFF
- public int AddRef() {
- return ++refCount;
- }
-
- // CHECKSTYLE_ON
-
- @Override
- public int method0(int[] args) {
- return QueryInterface(args[0], args[1]);
- }
-
- @Override
- public int method1(int[] args) {
- return AddRef();
- }
-
- // method3 GetTypeInfoCount - not implemented
-
- // method4 GetTypeInfo - not implemented
-
- @Override
- public int method2(int[] args) {
- return Release();
- }
-
- @Override
- public int method5(int[] args) {
- return GetIDsOfNames(args[0], args[1], args[2], args[3], args[4]);
- }
-
- @Override
- public int method6(int[] args) {
- return Invoke(args[0], args[1], args[2], args[3], args[4], args[5],
- args[6], args[7]);
- }
-
- // CHECKSTYLE_OFF
- public int QueryInterface(int riid, int ppvObject) {
- if (riid == 0 || ppvObject == 0) {
- return COM.E_NOINTERFACE;
- }
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
-
- if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
- OS.MoveMemory(ppvObject, new int[] {getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
-
- if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) {
- OS.MoveMemory(ppvObject, new int[] {getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
-
- OS.MoveMemory(ppvObject, new int[] {0}, 4);
- return COM.E_NOINTERFACE;
- }
-
- public int Release() {
- if (--refCount == 0) {
- dispose();
- }
- return refCount;
- }
-
- // CHECKSTYLE_ON
-
- /**
- * Override this method to implement GetIDsOfNames().
- */
- protected abstract void getIDsOfNames(String[] names, int[] ids)
- throws HResultException;
-
- /**
- * Override this method to implement Invoke().
- */
- protected abstract Variant invoke(int dispId, int flags, Variant[] params)
- throws HResultException, InstantiationException,
- InvocationTargetException;
-
- private Variant[] extractVariantArrayFromDispParamsPtr(int pDispParams) {
- DISPPARAMS dispParams = new DISPPARAMS();
- COM.MoveMemory(dispParams, pDispParams, DISPPARAMS.sizeof);
- Variant[] variants = new Variant[dispParams.cArgs];
- // Reverse the order as we pull the variants in.
- for (int i = 0, n = dispParams.cArgs; i < n; ++i) {
- int varArgAddr = dispParams.rgvarg + Variant.sizeof * i;
- variants[n - i - 1] = Variant.win32_new(varArgAddr);
- }
- return variants;
- }
-
- // CHECKSTYLE_OFF
- @SuppressWarnings("unused")
- private final int GetIDsOfNames(int riid, int rgszNames, int cNames,
- int lcid, int rgDispId) {
-
- try {
- if (cNames < 1) {
- return COM.E_INVALIDARG;
- }
-
- // Extract the requested names and build an answer array init'ed with -1.
- //
- String[] names = SwtOleGlue.extractStringArrayFromOleCharPtrPtr(
- rgszNames, cNames);
- int[] ids = new int[names.length];
- Arrays.fill(ids, -1);
-
- getIDsOfNames(names, ids);
- OS.MoveMemory(rgDispId, ids, ids.length * 4);
- } catch (HResultException e) {
- return e.getHResult();
- } catch (Throwable e) {
- e.printStackTrace();
- return COM.E_FAIL;
- }
-
- return COM.S_OK;
- }
-
- @SuppressWarnings("unused")
- private int Invoke(int dispIdMember, int riid, int lcid, int dwFlags,
- int pDispParams, int pVarResult, int pExcepInfo, int pArgErr) {
-
- HResultException ex = null;
- Variant[] vArgs = null;
- Variant result = null;
- try {
- vArgs = extractVariantArrayFromDispParamsPtr(pDispParams);
- result = invoke(dispIdMember, dwFlags, vArgs);
- if (pVarResult != 0) {
- Variant.win32_copy(pVarResult, result);
- }
- } catch (HResultException e) {
- // Log to the console for detailed examination.
- //
- e.printStackTrace();
- ex = e;
-
- } catch (InvocationTargetException e) {
- // If we get here, it means an exception is being thrown from
- // Java back into JavaScript
-
- Throwable t = e.getTargetException();
- ex = new HResultException(t);
- ModuleSpace.setThrownJavaException(t);
- } catch (Exception e) {
- // Log to the console for detailed examination.
- //
- e.printStackTrace();
- ex = new HResultException(e);
- } finally {
- // We allocated variants for all arguments, so we must dispose them all.
- //
- for (int i = 0; i < vArgs.length; ++i) {
- if (vArgs[i] != null) {
- vArgs[i].dispose();
- }
- }
-
- if (result != null) {
- result.dispose();
- }
- }
-
- if (ex != null) {
- // Set up an exception for IE to throw.
- //
- ex.fillExcepInfo(pExcepInfo);
- return ex.getHResult();
- }
-
- return COM.S_OK;
- }
- // CHECKSTYLE_ON
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchProxy.java b/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchProxy.java
deleted file mode 100644
index f23df9d..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchProxy.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JavaDispatch;
-import com.google.gwt.dev.shell.JavaDispatchImpl;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.LowLevel;
-import com.google.gwt.dev.shell.MethodAdaptor;
-
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.ole.win32.IDispatch;
-import org.eclipse.swt.ole.win32.Variant;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Wraps an arbitrary Java Object as an Automation-compatible server. The class
- * was motivated by the need to expose Java objects into JavaScript.
- *
- * <p>
- * <b>Features</b>
- * </p>
- * <ul>
- * <li>Implements the <code>IDispatch</code> interface for you</li>
- * <li>If the COM client keeps a reference to this object, this object is
- * prevented from being garbage collected</li>
- * <li>Manages a JNI global ref on the target object so that it can be
- * reliabily passed back and forth between Java and external code </li>
- * <li>An instance of this class with no target is used to globally access all
- * static methods or fields.</li>
- * </ul>
- *
- * <p>
- * <b>Limitations</b>
- * </p>
- * <ul>
- * <li>Only late-bound dispatch is supported</li>
- * <li>Named arguments are not supported (see {@link #GetIDsOfNames})).</li>
- * </ul>
- */
-class IDispatchProxy extends IDispatchImpl {
-
- // A magic dispid for getting a global ref to this object.
- public static final int DISPID_MAGIC_GETGLOBALREF = 0xC131FB56;
-
- private final CompilingClassLoader classLoader;
-
- private boolean isDisposed = false;
-
- private final JavaDispatch javaDispatch;
-
- private final int myGlobalRef;
-
- /**
- * This constructor initializes as the static dispatcher, which handles only
- * static method calls and field references.
- *
- * @param cl this class's classLoader
- */
- IDispatchProxy(CompilingClassLoader cl) {
- javaDispatch = new JavaDispatchImpl(cl);
- classLoader = cl;
- myGlobalRef = 0;
- }
-
- /**
- * This constructor initializes a dispatcher, around a particular instance.
- *
- * @param cl this class's classLoader
- * @param target the object being wrapped as an IDispatch
- */
- IDispatchProxy(CompilingClassLoader cl, Object target) {
- javaDispatch = new JavaDispatchImpl(cl, target);
- classLoader = cl;
- myGlobalRef = LowLevel.newGlobalRefInt(this);
- }
-
- /**
- * Must be called when the object is no longer needed (to release the global
- * reference on the target object).
- */
- @Override
- public void dispose() {
- // Release the global ref on myself.
- if (myGlobalRef != 0) {
- LowLevel.deleteGlobalRefInt(myGlobalRef);
- }
- super.dispose();
- isDisposed = true;
- }
-
- public Object getTarget() {
- return javaDispatch.getTarget();
- }
-
- /**
- * Determine whether the proxy has already been disposed (this shouldn't be
- * necessary, but is needed by ModuleSpaceIE6 to workaround a bug in IE).
- */
- public boolean isDisposed() {
- return isDisposed;
- }
-
- @Override
- protected void getIDsOfNames(String[] names, int[] ids)
- throws HResultException {
- ids[0] = classLoader.getDispId(names[0]);
- if (ids[0] == -1 || names.length >= 2) {
- throw new HResultException(DISP_E_UNKNOWNNAME);
- }
- }
-
- @Override
- protected Variant invoke(int dispId, int flags, Variant[] params)
- throws HResultException, InstantiationException,
- InvocationTargetException {
- try {
- // Whatever the caller asks for, try to find it via reflection.
- //
- if (dispId == DISPID_MAGIC_GETGLOBALREF && myGlobalRef != 0) {
- // Handle specially.
- //
- return new Variant(myGlobalRef);
- } else if (dispId == 0) {
- if ((flags & COM.DISPATCH_METHOD) != 0) {
- // implicit call -- "m()"
- // not supported -- fall through to unsupported failure
- } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
- // implicit toString -- "'foo' + m"
- return new Variant(getTarget().toString());
- }
-
- } else if (dispId > 0) {
- if (javaDispatch.isMethod(dispId)) {
- MethodAdaptor method = javaDispatch.getMethod(dispId);
- if ((flags & COM.DISPATCH_METHOD) != 0) {
- // This is a method call.
- return callMethod(classLoader, getTarget(), params, method);
- } else if (flags == COM.DISPATCH_PROPERTYGET) {
- // The function is being accessed as a property.
- AccessibleObject obj = method.getUnderlyingObject();
- IDispatchImpl dispMethod = (IDispatchImpl) classLoader.getWrapperForObject(obj);
- if (dispMethod == null || dispMethod.refCount < 1) {
- dispMethod = new MethodDispatch(classLoader, method);
- classLoader.putWrapperForObject(obj, dispMethod);
- }
- IDispatch disp = new IDispatch(dispMethod.getAddress());
- disp.AddRef();
- return new Variant(disp);
- }
- } else if (javaDispatch.isField(dispId)) {
- Field field = javaDispatch.getField(dispId);
- if (flags == COM.DISPATCH_PROPERTYGET) {
- return SwtOleGlue.convertObjectToVariant(classLoader,
- field.getType(), javaDispatch.getFieldValue(dispId));
- } else if ((flags & (COM.DISPATCH_PROPERTYPUT | COM.DISPATCH_PROPERTYPUTREF)) != 0) {
- javaDispatch.setFieldValue(dispId, JsValueGlue.get(new JsValueIE6(
- params[0]), classLoader, field.getType(), "Setting field '"
- + field.getName() + "'"));
- return new Variant();
- }
- }
- } else {
- // The specified member id is out of range.
- throw new HResultException(COM.DISP_E_MEMBERNOTFOUND);
- }
- } catch (IllegalArgumentException e) {
- // should never, ever happen
- e.printStackTrace();
- throw new HResultException(e);
- }
-
- System.err.println("IDispatchProxy cannot be invoked with flags: "
- + Integer.toHexString(flags));
- throw new HResultException(COM.E_NOTSUPPORTED);
- }
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
deleted file mode 100644
index 89cded6..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.LowLevel;
-
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.ole.win32.DISPPARAMS;
-import org.eclipse.swt.internal.ole.win32.EXCEPINFO;
-import org.eclipse.swt.internal.ole.win32.GUID;
-import org.eclipse.swt.internal.ole.win32.IDispatch;
-import org.eclipse.swt.internal.ole.win32.IUnknown;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.ole.win32.Variant;
-
-/**
- * Represents an IE JavaScript value.
- */
-public class JsValueIE6 extends JsValue {
-
- private static class JsCleanupIE6 implements JsCleanup {
- private Variant variant;
-
- public JsCleanupIE6(Variant variant) {
- this.variant = variant;
- }
-
- public void doCleanup() {
- if (variant != null) {
- variant.dispose();
- }
- }
- }
-
- private static Variant maybeCopyVariant(Variant variant) {
- if (variant == null) {
- return new Variant();
- }
- switch (variant.getType()) {
- case COM.VT_DISPATCH: {
- IDispatch dispatch = variant.getDispatch();
- dispatch.AddRef();
- return new Variant(dispatch);
- }
- case COM.VT_UNKNOWN: {
- IUnknown unknown = variant.getUnknown();
- unknown.AddRef();
- return new Variant(unknown);
- }
- }
- return variant;
- }
-
- /**
- * Copied with modification from OleAutomation.getIDsOfNames(). The reason we
- * don't use that method directly is that querying for typeInfo that occurs in
- * the OleAutomation(IDispatch) constructor will cause a VM crash on some
- * kinds of JavaScript objects, such as the window.alert function. So we do it
- * by hand.
- */
- private static int[] oleAutomationGetIdsOfNames(IDispatch dispatch) {
- String[] names = new String[] {"valueOf"};
- int[] ids = new int[names.length];
- int result = dispatch.GetIDsOfNames(new GUID(), names, names.length,
- COM.LOCALE_USER_DEFAULT, ids);
- if (result != COM.S_OK) {
- return null;
- }
- return ids;
- }
-
- /**
- * Copied with modification from OleAutomation.invoke(). The reason we don't
- * use that method directly is that querying for typeInfo that occurs in the
- * OleAutomation(IDispatch) constructor will cause a VM crash on some kinds of
- * JavaScript objects, such as the window.alert function. So we do it by hand.
- */
- private static Variant oleAutomationInvoke(IDispatch dispatch, int dispId) {
- int pVarResultAddress = 0;
- try {
- pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT,
- Variant.sizeof);
- int[] pArgErr = new int[1];
- int hr = dispatch.Invoke(dispId, new GUID(), COM.LOCALE_USER_DEFAULT,
- COM.DISPATCH_METHOD, new DISPPARAMS(), pVarResultAddress,
- new EXCEPINFO(), pArgErr);
-
- if (hr >= COM.S_OK) {
- return Variant.win32_new(pVarResultAddress);
- }
- } finally {
- if (pVarResultAddress != 0) {
- COM.VariantClear(pVarResultAddress);
- OS.GlobalFree(pVarResultAddress);
- }
- }
- return null;
- }
-
- // a null variant means the JsValue is undefined (void)
- private Variant variant;
-
- /**
- * Create a null JsValue.
- */
- public JsValueIE6() {
- this.variant = null;
- }
-
- /**
- * Create a JsValue given a variant.
- *
- * @param variant JS value
- */
- public JsValueIE6(Variant variant) {
- this.variant = maybeCopyVariant(variant);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getBoolean()
- */
- @Override
- public boolean getBoolean() {
- return variant.getBoolean();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getInt()
- */
- @Override
- public int getInt() {
- return variant.getInt();
- }
-
- @Override
- public int getJavaScriptObjectPointer() {
- if (isJavaScriptObject()) {
- // The canonical pointer is obtained by QI'ing for IUnknown.
- int[] ppvObject = new int[1];
- variant.getDispatch().QueryInterface(COM.IIDIUnknown, ppvObject);
- int pvObject = ppvObject[0];
- // Release the returned pointer.
- COM.VtblCall(2, pvObject);
- return pvObject;
- } else {
- return 0;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getNumber()
- */
- @Override
- public double getNumber() {
- return variant.getDouble();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getString()
- */
- @Override
- public String getString() {
- return variant.getString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getTypeString()
- */
- @Override
- public String getTypeString() {
- switch (variant.getType()) {
- case COM.VT_BOOL:
- return "boolean";
- case COM.VT_I1:
- case COM.VT_I2:
- case COM.VT_I4:
- case COM.VT_I8:
- case COM.VT_UI1:
- case COM.VT_UI2:
- case COM.VT_UI4:
- case COM.VT_R4:
- case COM.VT_R8:
- return "number";
- case COM.VT_BSTR:
- return "string";
- case COM.VT_EMPTY:
- return "undefined";
- case COM.VT_NULL:
- return "null";
- case COM.VT_DISPATCH:
- return isWrappedJavaObject() ? "Java Object" : "JavaScript object";
- default:
- return "unexpected Variant type";
- }
- }
-
- /**
- * Return the underlying Variant object. PLATFORM-SPECIFIC.
- */
- public Variant getVariant() {
- return maybeCopyVariant(variant);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#getWrappedJavaObject()
- */
- @Override
- public Object getWrappedJavaObject() {
- return tryToUnwrapWrappedJavaObject();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isBoolean()
- */
- @Override
- public boolean isBoolean() {
- return variant != null && variant.getType() == COM.VT_BOOL;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isInt()
- */
- @Override
- public boolean isInt() {
- if (variant == null) {
- return false;
- }
- switch (variant.getType()) {
- case COM.VT_I1:
- case COM.VT_I2:
- case COM.VT_I4:
- case COM.VT_UI1:
- case COM.VT_UI2:
- // note that VT_UI4 is excluded since it may not fit in an int
- return true;
- default:
- return false;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isJavaScriptObject()
- */
- @Override
- public boolean isJavaScriptObject() {
- if (variant == null) {
- return false;
- }
- if (variant.getType() != COM.VT_DISPATCH) {
- return false;
- }
- return tryToUnwrapWrappedJavaObject() == null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isNull()
- */
- @Override
- public boolean isNull() {
- return variant != null && variant.getType() == COM.VT_NULL;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isNumber()
- */
- @Override
- public boolean isNumber() {
- if (variant == null) {
- return false;
- }
- switch (variant.getType()) {
- case COM.VT_I1:
- case COM.VT_I2:
- case COM.VT_I4:
- case COM.VT_I8:
- case COM.VT_UI1:
- case COM.VT_UI2:
- case COM.VT_UI4:
- case COM.VT_R4:
- case COM.VT_R8:
- return true;
- default:
- return false;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isString()
- */
- @Override
- public boolean isString() {
- if (variant == null) {
- return false;
- }
- if (variant.getType() == COM.VT_BSTR) {
- return true;
- }
- // see if the variant is a wrapper object
- if (variant.getType() != COM.VT_DISPATCH) {
- return false;
- }
-
- // see if it has a valueOf method
- IDispatch dispatch = variant.getDispatch();
- int[] ids = oleAutomationGetIdsOfNames(dispatch);
- if (ids == null) {
- return false;
- }
- Variant result = null;
- try {
- result = oleAutomationInvoke(dispatch, ids[0]);
- /*
- * If the return type of the valueOf method is string, we assume it is a
- * String wrapper object.
- */
- return result.getType() == COM.VT_BSTR;
- } finally {
- if (result != null) {
- result.dispose();
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isUndefined()
- */
- @Override
- public boolean isUndefined() {
- return variant == null || variant.getType() == COM.VT_EMPTY;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#isWrappedJavaObject()
- */
- @Override
- public boolean isWrappedJavaObject() {
- if (variant == null) {
- return false;
- }
- if (variant.getType() != COM.VT_DISPATCH) {
- return false;
- }
- return tryToUnwrapWrappedJavaObject() != null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setBoolean(boolean)
- */
- @Override
- public void setBoolean(boolean val) {
- setVariant(new Variant(val));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setByte(byte)
- */
- @Override
- public void setByte(byte val) {
- setVariant(new Variant(val));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setChar(char)
- */
- @Override
- public void setChar(char val) {
- setVariant(new Variant(val));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setDouble(double)
- */
- @Override
- public void setDouble(double val) {
- setVariant(new Variant(val));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setInt(int)
- */
- @Override
- public void setInt(int val) {
- setVariant(new Variant(val));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setNull()
- */
- @Override
- public void setNull() {
- setVariant(new Variant(0, COM.VT_NULL));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setShort(short)
- */
- @Override
- public void setShort(short val) {
- setVariant(new Variant(val));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setString(java.lang.String)
- */
- @Override
- public void setString(String val) {
- setVariant(new Variant(val));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setUndefined()
- */
- @Override
- public void setUndefined() {
- setVariant(null);
- }
-
- @Override
- public void setValue(JsValue other) {
- setVariant(maybeCopyVariant(((JsValueIE6) other).variant));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#setWrappedJavaObject(com.google.gwt.dev.shell.CompilingClassLoader,
- * java.lang.Object)
- */
- @Override
- public <T> void setWrappedJavaObject(CompilingClassLoader cl, T val) {
- IDispatchImpl dispObj;
- if (val == null) {
- setNull();
- return;
- } else if (val instanceof IDispatchImpl) {
- dispObj = (IDispatchImpl) val;
- } else {
- dispObj = (IDispatchImpl) cl.getWrapperForObject(val);
- if (dispObj == null || dispObj.refCount < 1) {
- dispObj = new IDispatchProxy(cl, val);
- cl.putWrapperForObject(val, dispObj);
- }
- }
- IDispatch disp = new IDispatch(dispObj.getAddress());
- disp.AddRef();
- setVariant(new Variant(disp));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.dev.shell.JsValue#createCleanupObject()
- */
- @Override
- protected JsCleanup createCleanupObject() {
- return new JsCleanupIE6(variant);
- }
-
- /**
- * Reset the underlying variant, freeing the old one if necessary.
- *
- * @param val the new Variant to store
- */
- protected void setVariant(Variant val) {
- if (variant != null) {
- variant.dispose();
- }
- variant = val;
- }
-
- private Object tryToUnwrapWrappedJavaObject() {
- int globalRef = 0;
- Variant result = null;
- try {
- result = oleAutomationInvoke(variant.getDispatch(),
- IDispatchProxy.DISPID_MAGIC_GETGLOBALREF);
- if (result != null) {
- globalRef = result.getInt();
- if (globalRef != 0) {
- // This is really a Java object being passed back via an
- // IDispatchProxy.
- IDispatchProxy proxy = (IDispatchProxy) LowLevel.objFromGlobalRefInt(globalRef);
- return proxy.getTarget();
- }
- }
- return null;
- } finally {
- if (result != null) {
- result.dispose();
- }
- }
- }
-
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/LowLevelIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/LowLevelIE6.java
deleted file mode 100644
index 19b0613..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/LowLevelIE6.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.shell.LowLevel;
-
-/**
- * Various low-level helper methods for dealing with COM and such.
- */
-class LowLevelIE6 {
-
- /**
- * Does an HTTP GET that works with Windows proxy settings. Set the system
- * property <code>gwt.debugLowLevelHttpGet</code> to print failure status
- * codes to stderr.
- *
- * @param userAgent the user-agent to specify for the GET
- * @param url the absolute URL to GET
- * @return the bytes of the full response (including headers), or
- * <code>null</code> if there's a problem
- */
- public static byte[] httpGet(TreeLogger branch, String userAgent, String url,
- boolean debugFlag) {
- init();
- byte[][] out = new byte[1][];
- int status = _httpGet(userAgent, url, out);
- if (status == 0) {
- return out[0];
- } else {
- if (debugFlag) {
- branch.log(TreeLogger.ERROR, "GET failed with status " + status
- + " for " + url);
- }
- return null;
- }
- }
-
- public static synchronized void init() {
- // Force LowLevel initialization to load gwt-ll
- LowLevel.init();
- }
-
- // CHECKSTYLE_OFF
- // out must be an array of size 1 to receive the array answer
- private static native int _httpGet(String userAgent, String url, byte[][] out);
-
- // CHECKSTYLE_ON
-
- /**
- * Not instantiable.
- */
- private LowLevelIE6() {
- }
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/MethodDispatch.java b/dev/windows/src/com/google/gwt/dev/shell/ie/MethodDispatch.java
deleted file mode 100644
index b6eeb57..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/MethodDispatch.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.MethodAdaptor;
-
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.ole.win32.IDispatch;
-import org.eclipse.swt.ole.win32.Variant;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Wraps an arbitrary Java Method as an Automation-compatible server. The class
- * was motivated by the need to expose Java objects into JavaScript.
- *
- * <p>
- * <b>Features</b>
- * </p>
- * <ul>
- * <li>Implements the <code>IDispatch</code> interface for you</li>
- * <li>If the COM client keeps a reference to this object, this object is
- * prevented from being garbage collected</li>
- * </ul>
- *
- * <p>
- * <b>Limitations</b>
- * </p>
- * <ul>
- * <li>Only late-bound dispatch is supported</li>
- * <li>Named arguments are not supported (see {@link #GetIDsOfNames})).</li>
- * </ul>
- */
-class MethodDispatch extends IDispatchImpl {
-
- private final CompilingClassLoader classLoader;
-
- private final MethodAdaptor method;
-
- public MethodDispatch(CompilingClassLoader classLoader, MethodAdaptor method) {
- this.classLoader = classLoader;
- this.method = method;
- }
-
- @Override
- public String toString() {
- return "\nfunction " + method.toString() + "(){\n [native code]\n}\n";
- }
-
- /**
- * ID 0 is magic. It can either mean toString or invoke, depending on the
- * flags. So we start with ID 1 for toString. {@link IDispatchProxy} and
- * {@link BrowserWidgetIE6.External} should be fixed to do the same.
- */
- @Override
- protected void getIDsOfNames(String[] names, int[] ids)
- throws HResultException {
- if (names[0].equalsIgnoreCase("toString")) {
- ids[0] = 1;
- } else if (names[0].equalsIgnoreCase("call")) {
- ids[0] = 2;
- } else if (names[0].equalsIgnoreCase("apply")) {
- ids[0] = 3;
- } else {
- throw new HResultException(IDispatchImpl.DISP_E_UNKNOWNNAME);
- }
- }
-
- /*
- * Handles all the things the browser can do to a function object.
- */
- @Override
- protected Variant invoke(int id, int flags, Variant[] params)
- throws HResultException, InstantiationException,
- InvocationTargetException {
- switch (id) {
- case 0:
- // An implicit access.
- if ((flags & COM.DISPATCH_METHOD) != 0) {
- // implicit call -- "m()"
- return callMethod(classLoader, null, params, method);
- } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
- // implicit toString -- "'foo' + m"
- return new Variant(toString());
- }
- break;
- case 1:
- // toString
- if ((flags & COM.DISPATCH_METHOD) != 0) {
- // "m.toString()"
- return new Variant(toString());
- } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
- // "m.toString"
- MethodAdaptor toStringMethod;
- try {
- toStringMethod = new MethodAdaptor(
- Object.class.getDeclaredMethod("toString"));
- } catch (Throwable e) {
- throw new RuntimeException(
- "Failed to get Object.toString() method", e);
- }
- AccessibleObject obj = toStringMethod.getUnderlyingObject();
- IDispatchImpl dispMethod = (IDispatchImpl) classLoader.getWrapperForObject(obj);
- if (dispMethod == null || dispMethod.refCount < 1) {
- dispMethod = new MethodDispatch(classLoader, toStringMethod);
- classLoader.putWrapperForObject(obj, dispMethod);
- }
- IDispatch disp = new IDispatch(dispMethod.getAddress());
- disp.AddRef();
- return new Variant(disp);
- }
- break;
- case 2:
- // call
- if ((flags & COM.DISPATCH_METHOD) != 0) {
- // "m.call(thisObj, arg)"
-
- /*
- * First param must be a this object of the correct type (for instance
- * methods). If method is static, it can be null.
- */
- Object jthis = JsValueGlue.get(new JsValueIE6(params[0]),
- classLoader, method.getDeclaringClass(), "this");
- Variant[] otherParams = new Variant[params.length - 1];
- System.arraycopy(params, 1, otherParams, 0, otherParams.length);
- return callMethod(classLoader, jthis, otherParams, method);
- } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
- // "m.call"
- // TODO: not supported
- }
- break;
- case 3:
- // apply
- // TODO: not supported
- break;
- case IDispatchProxy.DISPID_MAGIC_GETGLOBALREF:
- // We are NOT in fact a "wrapped Java Object", but we don't want to
- // throw an exception for being asked.
- return new Variant(0);
- default:
- // The specified member id is out of range.
- throw new HResultException(COM.DISP_E_MEMBERNOTFOUND);
- }
- throw new HResultException(COM.E_NOTSUPPORTED);
- }
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
deleted file mode 100644
index f86fed0..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.javac.JsniMethod;
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.DispatchIdOracle;
-import com.google.gwt.dev.shell.JsValue;
-import com.google.gwt.dev.shell.Jsni;
-import com.google.gwt.dev.shell.ModuleSpace;
-import com.google.gwt.dev.shell.ModuleSpaceHost;
-import com.google.gwt.dev.shell.ie.IDispatchImpl.HResultException;
-
-import org.eclipse.swt.internal.ole.win32.IDispatch;
-import org.eclipse.swt.ole.win32.OleAutomation;
-import org.eclipse.swt.ole.win32.Variant;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-
-/**
- * An implementation of {@link com.google.gwt.dev.shell.ModuleSpace} for
- * Internet Explorer 6.
- */
-public class ModuleSpaceIE6 extends ModuleSpace {
- /**
- * Invoke a JavaScript function. The static function exists to allow
- * platform-dependent code to make JavaScript calls without having a
- * ModuleSpaceIE6 (and all that entails) if it is not required.
- *
- * @param window the window containing the function
- * @param name the name of the function
- * @param vArgs the array of arguments. vArgs[0] is the this parameter
- * supplied to the function, which must be null if it is static.
- * @return the return value of the JavaScript function
- */
- protected static Variant doInvokeOnWindow(OleAutomation window, String name,
- Variant[] vArgs) {
- OleAutomation funcObj = null;
- Variant funcObjVar = null;
- try {
-
- // Get the function object and its 'call' method.
- //
- int[] ids = window.getIDsOfNames(new String[] {name});
- if (ids == null) {
- throw new RuntimeException(
- "Could not find a native method with the signature '" + name + "'");
- }
- int functionId = ids[0];
- funcObjVar = window.getProperty(functionId);
- funcObj = funcObjVar.getAutomation();
- int callDispId = funcObj.getIDsOfNames(new String[] {"call"})[0];
-
- // Invoke it and return the result.
- //
- return funcObj.invoke(callDispId, vArgs);
-
- } finally {
- if (funcObjVar != null) {
- funcObjVar.dispose();
- }
-
- if (funcObj != null) {
- funcObj.dispose();
- }
- }
- }
-
- private final OleAutomation window;
-
- /**
- * Constructs a browser interface for use with an IE6 'window' automation
- * object.
- *
- * @param moduleName
- */
- public ModuleSpaceIE6(TreeLogger logger, ModuleSpaceHost host,
- IDispatch scriptFrameWindow, String moduleName, Object key) {
- super(logger, host, moduleName, key);
-
- window = new OleAutomation(scriptFrameWindow);
- }
-
- public void createNativeMethods(TreeLogger logger,
- List<JsniMethod> jsniMethods, DispatchIdOracle dispatchIdOracle) {
- for (JsniMethod jsniMethod : jsniMethods) {
- String body = Jsni.getJavaScriptForHostedMode(logger, dispatchIdOracle,
- jsniMethod);
- if (body == null) {
- // The error has been logged; just ignore it for now.
- continue;
- }
- createNative(jsniMethod.location(), jsniMethod.line(), jsniMethod.name(),
- jsniMethod.paramNames(), body);
- }
- }
-
- @Override
- public void dispose() {
- // Dispose everything else.
- if (window != null) {
- window.dispose();
- }
- super.dispose();
- }
-
- @Override
- protected void createStaticDispatcher(TreeLogger logger) {
- createNative("initializeStaticDispatcher", 0, "__defineStatic",
- new String[] {"__arg0"}, "window.__static = __arg0;");
- }
-
- /**
- * Invokes a native javascript function.
- *
- * @param name the name of the function to invoke
- * @param jthis the function's 'this' context
- * @param types the type of each argument
- * @param args the arguments to be passed
- * @return the return value as a Variant.
- */
- @Override
- protected JsValue doInvoke(String name, Object jthis, Class<?>[] types,
- Object[] args) throws Throwable {
- Variant[] vArgs = null;
- try {
- CompilingClassLoader isolatedClassLoader = getIsolatedClassLoader();
-
- // Build the argument list, including 'jthis'.
- //
- int len = args.length;
- vArgs = new Variant[len + 1];
- Class<?> jthisType = (jthis == null) ? Object.class : jthis.getClass();
- vArgs[0] = SwtOleGlue.convertObjectToVariant(isolatedClassLoader,
- jthisType, jthis);
-
- for (int i = 0; i < len; ++i) {
- vArgs[i + 1] = SwtOleGlue.convertObjectToVariant(isolatedClassLoader,
- types[i], args[i]);
- }
-
- Variant result = doInvokeOnWindow(window, name, vArgs);
- try {
- return new JsValueIE6(result);
- } finally {
- if (result != null) {
- result.dispose();
- }
- }
- } finally {
- // We allocated variants for all arguments, so we must dispose them all.
- //
- for (int i = 0; i < vArgs.length; ++i) {
- if (vArgs[i] != null) {
- vArgs[i].dispose();
- }
- }
- }
- }
-
- @Override
- protected Object getStaticDispatcher() {
- return new IDispatchProxy(getIsolatedClassLoader());
- }
-
- /**
- * On IE6, we currently have no way of throwing arbitrary exception objects
- * into JavaScript. What we throw in exception cases is an exception not under
- * our exact control, so the best we can do is match descriptions to indicate
- * a match. In practice this works well.
- */
- @Override
- protected boolean isExceptionSame(Throwable original, Object exception) {
- Throwable caught;
- try {
- HResultException hre = new HResultException(original);
- RuntimeException jse = createJavaScriptException(
- getIsolatedClassLoader(), exception);
- Method method = jse.getClass().getMethod("getDescription");
- String description = (String) method.invoke(jse);
- return hre.getMessage().equals(description);
- } catch (SecurityException e) {
- caught = e;
- } catch (NoSuchMethodException e) {
- caught = e;
- } catch (IllegalArgumentException e) {
- caught = e;
- } catch (IllegalAccessException e) {
- caught = e;
- } catch (InvocationTargetException e) {
- caught = e;
- }
- throw new RuntimeException(
- "Failed to invoke JavaScriptException.getDescription()", caught);
- }
-
- private void createNative(String file, int line, String jsniSignature,
- String[] paramNames, String js) {
- // Execute the function definition within the browser, which will define
- // a new top-level function.
- //
- String newScript = createNativeMethodInjector(jsniSignature, paramNames, js);
- try {
- // TODO: somehow insert file/line info into the script
- Variant result = execute(newScript);
- if (result != null) {
- result.dispose();
- }
- } catch (RuntimeException e) {
- throw new RuntimeException(file + "(" + line
- + "): Failed to create JSNI method with signature '" + jsniSignature
- + "'", e);
- }
- }
-
- private Variant execute(String code) {
- int[] dispIds = window.getIDsOfNames(new String[] {"execScript", "code"});
- Variant[] vArgs = new Variant[1];
- vArgs[0] = new Variant(code);
- int[] namedArgs = new int[1];
- namedArgs[0] = dispIds[1];
- Variant result = window.invoke(dispIds[0], vArgs, namedArgs);
- vArgs[0].dispose();
- if (result == null) {
- String lastError = window.getLastError();
- throw new RuntimeException("Error (" + lastError
- + ") executing JavaScript:\n" + code);
- }
- return result;
- }
-}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/SwtOleGlue.java b/dev/windows/src/com/google/gwt/dev/shell/ie/SwtOleGlue.java
deleted file mode 100644
index 13e77b7..0000000
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/SwtOleGlue.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.ie;
-
-import com.google.gwt.dev.shell.CompilingClassLoader;
-import com.google.gwt.dev.shell.JsValueGlue;
-import com.google.gwt.dev.shell.LowLevel;
-
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.ole.win32.COMObject;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.ole.win32.Variant;
-
-/**
- * A bag of static helper methods for mucking about with low-level SWT and COM
- * constructs. Much of this is necessary simply to do things that the SWT
- * implementers weren't really thinking about when they wrote the COM layer.
- */
-class SwtOleGlue {
-
- /**
- * Converts a java object to its equivalent variant. A ClassLoader is passed
- * here so that Handles can be manipulated properly.
- */
- public static Variant convertObjectToVariant(CompilingClassLoader cl,
- Class<?> type, Object o) {
- if (type.equals(Variant.class)) {
- return (Variant) o;
- }
- JsValueIE6 jsValue = new JsValueIE6();
- JsValueGlue.set(jsValue, cl, type, o);
- return jsValue.getVariant();
- }
-
- /**
- * Converts an array of variants to their equivalent java objects.
- */
- public static Object[] convertVariantsToObjects(CompilingClassLoader cl,
- Class<?>[] argTypes, Variant[] varArgs, String msgPrefix) {
- Object[] javaArgs = new Object[Math.min(varArgs.length, argTypes.length)];
- for (int i = 0; i < javaArgs.length; i++) {
- try {
- Object javaArg = JsValueGlue.get(new JsValueIE6(varArgs[i]), cl,
- argTypes[i], msgPrefix);
- javaArgs[i] = javaArg;
- } catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("Error converting argument "
- + (i + 1) + ": " + e.getMessage());
- }
- }
-
- return javaArgs;
- }
-
- /**
- * Extracts an array of strings from an (OLECHAR**) type (useful for
- * implementing GetIDsOfNames()).
- */
- public static String[] extractStringArrayFromOleCharPtrPtr(int ppchar,
- int count) {
- String[] strings = new String[count];
- for (int i = 0; i < count; ++i) {
- int[] pchar = new int[1];
- OS.MoveMemory(pchar, ppchar + 4 * i, 4);
- strings[i] = extractStringFromOleCharPtr(pchar[0]);
- }
- return strings;
- }
-
- /**
- * Extracts a string from an (OLECHAR*) type.
- */
- public static String extractStringFromOleCharPtr(int pOleChar) {
- int length = OS.wcslen(pOleChar);
- char[] buffer = new char[length];
- OS.MoveMemory(buffer, pOleChar, length * 2);
- return String.valueOf(buffer);
- }
-
- /**
- * Injects an object into the Browser class that resolves to IE's
- * 'window.external' object.
- */
- public static void injectBrowserScriptExternalObject(Browser browser,
- final IDispatchImpl external) {
- // Grab the browser's 'site.iDocHostUIHandler' field.
- //
- Object webSite = LowLevel.snatchFieldObjectValue(browser, "site");
- COMObject iDocHostUIHandler = (COMObject) LowLevel.snatchFieldObjectValue(
- webSite, "iDocHostUIHandler");
-
- // Create a COMObjectProxy that will override GetExternal().
- //
- COMObjectProxy webSiteProxy = new COMObjectProxy(new int[] {
- 2, 0, 0, 4, 1, 5, 0, 0, 1, 1, 1, 3, 3, 2, 2, 1, 3, 2}) {
-
- {
- // make sure we hold onto a ref on the external object
- external.AddRef();
- }
-
- @Override
- public int method15(int[] args) {
- // GetExternal() is method 15.
- //
- return GetExternal(args[0]);
- }
-
- @Override
- public int method2(int[] args) {
- int result = super.method2(args);
- if (result == 0) {
- external.Release();
- }
- return result;
- }
-
- // CHECKSTYLE_OFF
- int GetExternal(int ppDispatch) {
- // CHECKSTYLE_ON
- if (ppDispatch != 0) {
- try {
- // Return the 'external' object.
- //
- external.AddRef();
- OS.MoveMemory(ppDispatch, new int[] {external.getAddress()}, 4);
- return COM.S_OK;
- } catch (Throwable e) {
- e.printStackTrace();
- return COM.E_FAIL;
- }
- } else {
- OS.MoveMemory(ppDispatch, new int[] {0}, 4);
- return COM.E_NOTIMPL;
- }
- }
-
- };
-
- // Interpose the proxy in front of the browser's iDocHostUiHandler.
- //
- webSiteProxy.interpose(iDocHostUIHandler);
- }
-
- /**
- * Convert a Java string to a COM BSTR.
- *
- * Wrapper for the OS' SysAllocStringLen(), since SysAllocString() is not safe
- * for embedded nulls.
- */
- public static int sysAllocString(String s) {
- return COM.SysAllocStringLen(s.toCharArray(), s.length());
- }
-
-}
diff --git a/dev/windows/src/org/eclipse/COPYING.html b/dev/windows/src/org/eclipse/COPYING.html
deleted file mode 100644
index 5bfebd8..0000000
--- a/dev/windows/src/org/eclipse/COPYING.html
+++ /dev/null
@@ -1,256 +0,0 @@
-<html>
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<title>Eclipse Public License - Version 1.0</title>
-</head>
-
-<body>
-
-<div>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span>1. DEFINITIONS</span></b> </p>
-
-<p><span>"Contribution" means:</span> </p>
-
-<p><span>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p><span>i)
-changes to the Program, and</span></p>
-
-<p><span>ii)
-additions to the Program;</span></p>
-
-<p><span>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span>"Contributor" means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span>"Licensed Patents " mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span>"Program" means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span>"Recipient" means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span>2. GRANT OF RIGHTS</span></b> </p>
-
-<p><span>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p><span>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p><span>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p><span>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span>3. REQUIREMENTS</span></b> </p>
-
-<p><span>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p><span>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p><span>b)
-its license agreement:</span></p>
-
-<p><span>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p><span>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p><span>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p><span>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span>When the Program is made available in source
-code form:</span> </p>
-
-<p><span>a)
-it must be made available under this Agreement; and </span></p>
-
-<p><span>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor ("Commercial
-Contributor") hereby agrees to defend and indemnify every other
-Contributor ("Indemnified Contributor") against any losses, damages and
-costs (collectively "Losses") arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span>5. NO WARRANTY</span></b> </p>
-
-<p><span>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span>7. GENERAL</span></b> </p>
-
-<p><span>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/dev/windows/src/org/eclipse/swt/browser/Browser.java b/dev/windows/src/org/eclipse/swt/browser/Browser.java
deleted file mode 100644
index e501d6e..0000000
--- a/dev/windows/src/org/eclipse/swt/browser/Browser.java
+++ /dev/null
@@ -1,1453 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.browser;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class implement the browser user interface
- * metaphor. It allows the user to visualize and navigate through
- * HTML documents.
- * <p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @since 3.0
- */
-public class Browser extends Composite {
-
- OleFrame frame;
- OleControlSite site;
- OleAutomation auto;
-
- boolean back, forward, navigate, delaySetText, ignoreDispose;
- Point location;
- Point size;
- boolean addressBar = true, menuBar = true, statusBar = true, toolBar = true;
- int info;
-
- int globalDispatch;
- String html;
-
- /* External Listener management */
- CloseWindowListener[] closeWindowListeners = new CloseWindowListener[0];
- LocationListener[] locationListeners = new LocationListener[0];
- OpenWindowListener[] openWindowListeners = new OpenWindowListener[0];
- ProgressListener[] progressListeners = new ProgressListener[0];
- StatusTextListener[] statusTextListeners = new StatusTextListener[0];
- TitleListener[] titleListeners = new TitleListener[0];
- VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0];
-
- static final int BeforeNavigate2 = 0xfa;
- static final int CommandStateChange = 0x69;
- static final int DocumentComplete = 0x103;
- static final int NavigateComplete2 = 0xfc;
- static final int NewWindow2 = 0xfb;
- static final int OnMenuBar = 0x100;
- static final int OnStatusBar = 0x101;
- static final int OnToolBar = 0xff;
- static final int OnVisible = 0xfe;
- static final int ProgressChange = 0x6c;
- static final int RegisterAsBrowser = 0x228;
- static final int StatusTextChange = 0x66;
- static final int TitleChange = 0x71;
- static final int WindowClosing = 0x107;
- static final int WindowSetHeight = 0x10b;
- static final int WindowSetLeft = 0x108;
- static final int WindowSetResizable = 0x106;
- static final int WindowSetTop = 0x109;
- static final int WindowSetWidth = 0x10a;
-
- static final short CSC_NAVIGATEFORWARD = 1;
- static final short CSC_NAVIGATEBACK = 2;
- static final int INET_E_DEFAULT_ACTION = 0x800C0011;
- static final int READYSTATE_COMPLETE = 4;
- static final int URLPOLICY_ALLOW = 0x00;
- static final int URLPOLICY_DISALLOW = 0x03;
- static final int URLZONE_LOCAL_MACHINE = 0;
- static final int URLZONE_INTRANET = 1;
- static final int URLACTION_ACTIVEX_MIN = 0x00001200;
- static final int URLACTION_ACTIVEX_MAX = 0x000013ff;
- static final int URLACTION_ACTIVEX_RUN = 0x00001200;
- static final int URLACTION_JAVA_MIN = 0x00001C00;
- static final int URLPOLICY_JAVA_LOW = 0x00030000;
- static final int URLACTION_JAVA_MAX = 0x00001Cff;
-
- static final int DISPID_AMBIENT_DLCONTROL = -5512;
- static final int DLCTL_DLIMAGES = 0x00000010;
- static final int DLCTL_VIDEOS = 0x00000020;
- static final int DLCTL_BGSOUNDS = 0x00000040;
- static final int DLCTL_NO_SCRIPTS = 0x00000080;
- static final int DLCTL_NO_JAVA = 0x00000100;
- static final int DLCTL_NO_RUNACTIVEXCTLS = 0x00000200;
- static final int DLCTL_NO_DLACTIVEXCTLS = 0x00000400;
- static final int DLCTL_DOWNLOADONLY = 0x00000800;
- static final int DLCTL_NO_FRAMEDOWNLOAD = 0x00001000;
- static final int DLCTL_RESYNCHRONIZE = 0x00002000;
- static final int DLCTL_PRAGMA_NO_CACHE = 0x00004000;
- static final int DLCTL_FORCEOFFLINE = 0x10000000;
- static final int DLCTL_NO_CLIENTPULL = 0x20000000;
- static final int DLCTL_SILENT = 0x40000000;
- static final int DOCHOSTUIFLAG_THEME = 0x00040000;
- static final int DOCHOSTUIFLAG_NO3DBORDER = 0x0000004;
- static final int DOCHOSTUIFLAG_NO3DOUTERBORDER = 0x00200000;
-
- static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
- static final String CLSID_SHELLEXPLORER1 = "{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}";
- static final String URL_DIRECTOR = "http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab"; //$NON-NLS-1$
-
- /* Package Name */
- static final String PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li>
- * </ul>
- *
- * @see Widget#getStyle
- *
- * @since 3.0
- */
-public Browser(Composite parent, int style) {
- super(parent, style &~ SWT.BORDER);
- info = Browser.DOCHOSTUIFLAG_THEME;
- if ((style & SWT.BORDER) == 0) info |= Browser.DOCHOSTUIFLAG_NO3DOUTERBORDER;
- frame = new OleFrame(this, SWT.NONE);
-
- /*
- * Registry entry HKEY_CLASSES_ROOT\Shell.Explorer\CLSID indicates which version of
- * Shell.Explorer to use by default. We usually want to use this value because it
- * typically points at the newest one that is available. However it is possible for
- * this registry entry to be changed by another application to point at some other
- * Shell.Explorer version.
- *
- * The Browser depends on the Shell.Explorer version being at least Shell.Explorer.2.
- * If it is detected in the registry to be Shell.Explorer.1 then change the progId that
- * will be embedded to explicitly specify Shell.Explorer.2.
- */
- String progId = "Shell.Explorer"; //$NON-NLS-1$
- TCHAR key = new TCHAR (0, "Shell.Explorer\\CLSID", true); //$NON-NLS-1$
- int [] phkResult = new int [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) == 0) {
- int [] lpcbData = new int [1];
- int result = OS.RegQueryValueEx (phkResult [0], null, 0, null, (TCHAR) null, lpcbData);
- if (result == 0) {
- TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
- result = OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData);
- if (result == 0) {
- String clsid = lpData.toString (0, lpData.strlen ());
- if (clsid.equals (CLSID_SHELLEXPLORER1)) {
- /* Shell.Explorer.1 is the default, ensure that Shell.Explorer.2 is available */
- key = new TCHAR (0, "Shell.Explorer.2", true); //$NON-NLS-1$
- int [] phkResult2 = new int [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult2) == 0) {
- /* specify that Shell.Explorer.2 is to be used */
- OS.RegCloseKey (phkResult2 [0]);
- progId = "Shell.Explorer.2"; //$NON-NLS-1$
- }
- }
- }
- }
- OS.RegCloseKey (phkResult [0]);
- }
- try {
- site = new WebSite(frame, SWT.NONE, progId); //$NON-NLS-1$
- } catch (SWTException e) {
- dispose();
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
-
- site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
- auto = new OleAutomation(site);
-
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Dispose: {
- /* make this handler run after other dispose listeners */
- if (ignoreDispose) {
- ignoreDispose = false;
- break;
- }
- ignoreDispose = true;
- notifyListeners (e.type, e);
- e.type = SWT.NONE;
- if (auto != null) auto.dispose();
- auto = null;
- break;
- }
- case SWT.Resize: {
- frame.setBounds(getClientArea());
- break;
- }
- case SWT.KeyDown:
- case SWT.KeyUp: {
- notifyListeners(e.type, e);
- break;
- }
- }
- }
- };
- addListener(SWT.Dispose, listener);
- addListener(SWT.Resize, listener);
- site.addListener(SWT.KeyDown, listener);
- site.addListener(SWT.KeyUp, listener);
-
- OleListener oleListener = new OleListener() {
- public void handleEvent(OleEvent event) {
- if (auto == null) return; /* receiver was disposed, callback is asynchronous */
- switch (event.type) {
- case BeforeNavigate2: {
- Variant varResult = event.arguments[1];
- String url = varResult.getString();
- LocationEvent newEvent = new LocationEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = Browser.this;
- newEvent.location = url;
- newEvent.doit = true;
- for (int i = 0; i < locationListeners.length; i++) {
- locationListeners[i].changing(newEvent);
- }
- Variant cancel = event.arguments[6];
- if (cancel != null) {
- int pCancel = cancel.getByRef();
- COM.MoveMemory(pCancel, new short[]{newEvent.doit ? COM.VARIANT_FALSE : COM.VARIANT_TRUE}, 2);
- }
- break;
- }
- case CommandStateChange: {
- boolean enabled = false;
- Variant varResult = event.arguments[0];
- int command = varResult.getInt();
- varResult = event.arguments[1];
- enabled = varResult.getBoolean();
- switch (command) {
- case CSC_NAVIGATEBACK : back = enabled; break;
- case CSC_NAVIGATEFORWARD : forward = enabled; break;
- }
- break;
- }
- case DocumentComplete: {
- Variant varResult = event.arguments[0];
- IDispatch dispatch = varResult.getDispatch();
-
- varResult = event.arguments[1];
- String url = varResult.getString();
- if (html != null && url.equals(ABOUT_BLANK)) {
- Runnable runnable = new Runnable () {
- public void run() {
- if (isDisposed() || html == null) return;
- int charCount = html.length();
- char[] chars = new char[charCount];
- html.getChars(0, charCount, chars, 0);
- html = null;
- int byteCount = OS.WideCharToMultiByte(OS.CP_UTF8, 0, chars, charCount, null, 0, null, null);
- /*
- * Note. Internet Explorer appears to treat the data loaded with
- * nsIPersistStreamInit.Load as if it were encoded using the default
- * local charset. There does not seem to be an API to set the
- * desired charset explicitely in this case. The fix is to
- * prepend the UTF-8 Byte Order Mark signature to the data.
- */
- byte[] UTF8BOM = {(byte)0xEF, (byte)0xBB, (byte)0xBF};
- int hGlobal = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, UTF8BOM.length + byteCount);
- if (hGlobal != 0) {
- OS.MoveMemory(hGlobal, UTF8BOM, UTF8BOM.length);
- OS.WideCharToMultiByte(OS.CP_UTF8, 0, chars, charCount, hGlobal + UTF8BOM.length, byteCount, null, null);
- int[] ppstm = new int[1];
- /*
- * Note. CreateStreamOnHGlobal is called with the flag fDeleteOnRelease.
- * If the call succeeds the buffer hGlobal is freed automatically
- * when the IStream object is released. If the call fails, free the buffer
- * hGlobal.
- */
- if (OS.CreateStreamOnHGlobal(hGlobal, true, ppstm) == OS.S_OK) {
- int[] rgdispid = auto.getIDsOfNames(new String[] {"Document"}); //$NON-NLS-1$
- Variant pVarResult = auto.getProperty(rgdispid[0]);
- IDispatch dispatchDocument = pVarResult.getDispatch();
- int[] ppvObject = new int[1];
- int result = dispatchDocument.QueryInterface(COM.IIDIPersistStreamInit, ppvObject);
- if (result == OS.S_OK) {
- IPersistStreamInit persistStreamInit = new IPersistStreamInit(ppvObject[0]);
- if (persistStreamInit.InitNew() == OS.S_OK) {
- persistStreamInit.Load(ppstm[0]);
- }
- persistStreamInit.Release();
- }
- pVarResult.dispose();
- /*
- * This code is intentionally commented. The IDispatch obtained from a Variant
- * did not increase the reference count for the enclosed interface.
- */
- //dispatchDocument.Release();
- IUnknown stream = new IUnknown(ppstm[0]);
- stream.Release();
- } else {
- OS.GlobalFree(hGlobal);
- }
- }
- }
- };
- if (delaySetText) {
- delaySetText = false;
- getDisplay().asyncExec(runnable);
- } else {
- runnable.run();
- }
- } else {
- Variant variant = new Variant(auto);
- IDispatch top = variant.getDispatch();
- LocationEvent locationEvent = new LocationEvent(Browser.this);
- locationEvent.display = getDisplay();
- locationEvent.widget = Browser.this;
- locationEvent.location = url;
- locationEvent.top = top.getAddress() == dispatch.getAddress();
- for (int i = 0; i < locationListeners.length; i++) {
- locationListeners[i].changed(locationEvent);
- }
- /*
- * This code is intentionally commented. A Variant constructed from an
- * OleAutomation object does not increase its reference count. The IDispatch
- * obtained from this Variant did not increase the reference count for the
- * OleAutomation instance either.
- */
- //top.Release();
- //variant.dispose();
- /*
- * Note. The completion of the page loading is detected as
- * described in the MSDN article "Determine when a page is
- * done loading in WebBrowser Control".
- */
- if (globalDispatch != 0 && dispatch.getAddress() == globalDispatch) {
- /* final document complete */
- globalDispatch = 0;
- ProgressEvent progressEvent = new ProgressEvent(Browser.this);
- progressEvent.display = getDisplay();
- progressEvent.widget = Browser.this;
- for (int i = 0; i < progressListeners.length; i++) {
- progressListeners[i].completed(progressEvent);
- }
- }
- }
-
- /*
- * This code is intentionally commented. This IDispatch was received
- * as an argument from the OleEvent and it will be disposed along with
- * the other arguments.
- */
- //dispatch.Release();
- break;
- }
- case NavigateComplete2: {
- Variant varResult = event.arguments[0];
- IDispatch dispatch = varResult.getDispatch();
- if (globalDispatch == 0) globalDispatch = dispatch.getAddress();
- break;
- }
- case NewWindow2: {
- Variant cancel = event.arguments[1];
- int pCancel = cancel.getByRef();
- WindowEvent newEvent = new WindowEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = Browser.this;
- newEvent.required = false;
- for (int i = 0; i < openWindowListeners.length; i++) {
- openWindowListeners[i].open(newEvent);
- }
- Browser browser = newEvent.browser;
- boolean doit = browser != null && !browser.isDisposed();
- if (doit) {
- Variant variant = new Variant(browser.auto);
- IDispatch iDispatch = variant.getDispatch();
- Variant ppDisp = event.arguments[0];
- int byref = ppDisp.getByRef();
- if (byref != 0) COM.MoveMemory(byref, new int[] {iDispatch.getAddress()}, 4);
- /*
- * This code is intentionally commented. A Variant constructed from an
- * OleAutomation object does not increase its reference count. The IDispatch
- * obtained from this Variant did not increase the reference count for the
- * OleAutomation instance either.
- */
- //variant.dispose();
- //iDispatch.Release();
- }
- if (newEvent.required) {
- COM.MoveMemory(pCancel, new short[]{doit ? COM.VARIANT_FALSE : COM.VARIANT_TRUE}, 2);
- }
- break;
- }
- case OnMenuBar: {
- Variant arg0 = event.arguments[0];
- menuBar = arg0.getBoolean();
- break;
- }
- case OnStatusBar: {
- Variant arg0 = event.arguments[0];
- statusBar = arg0.getBoolean();
- break;
- }
- case OnToolBar: {
- Variant arg0 = event.arguments[0];
- toolBar = arg0.getBoolean();
- /*
- * Feature in Internet Explorer. OnToolBar FALSE is emitted
- * when both tool bar, address bar and menu bar must not be visible.
- * OnToolBar TRUE is emitted when either of tool bar, address bar
- * or menu bar is visible.
- */
- if (!toolBar) {
- addressBar = false;
- menuBar = false;
- }
- break;
- }
- case OnVisible: {
- Variant arg1 = event.arguments[0];
- boolean visible = arg1.getBoolean();
- WindowEvent newEvent = new WindowEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = Browser.this;
- if (visible) {
- if (addressBar) {
- /*
- * Bug in Internet Explorer. There is no distinct notification for
- * the address bar. If neither address, menu or tool bars are visible,
- * OnToolBar FALSE is emitted. For some reason, querying the value of
- * AddressBar in this case returns true even though it should not be
- * set visible. The workaround is to only query the value of AddressBar
- * when OnToolBar FALSE has not been emitted.
- */
- int[] rgdispid = auto.getIDsOfNames(new String[] { "AddressBar" }); //$NON-NLS-1$
- Variant pVarResult = auto.getProperty(rgdispid[0]);
- if (pVarResult != null && pVarResult.getType() == OLE.VT_BOOL) addressBar = pVarResult.getBoolean();
- }
- newEvent.addressBar = addressBar;
- newEvent.menuBar = menuBar;
- newEvent.statusBar = statusBar;
- newEvent.toolBar = toolBar;
- newEvent.location = location;
- newEvent.size = size;
- for (int i = 0; i < visibilityWindowListeners.length; i++) {
- visibilityWindowListeners[i].show(newEvent);
- }
- location = null;
- size = null;
- } else {
- for (int i = 0; i < visibilityWindowListeners.length; i++) {
- visibilityWindowListeners[i].hide(newEvent);
- }
- }
- break;
- }
- case ProgressChange: {
- Variant arg1 = event.arguments[0];
- int nProgress = arg1.getType() != OLE.VT_I4 ? 0 : arg1.getInt(); // may be -1
- Variant arg2 = event.arguments[1];
- int nProgressMax = arg2.getType() != OLE.VT_I4 ? 0 : arg2.getInt();
- ProgressEvent newEvent = new ProgressEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = Browser.this;
- newEvent.current = nProgress;
- newEvent.total = nProgressMax;
- if (nProgress != -1) {
- for (int i = 0; i < progressListeners.length; i++) {
- progressListeners[i].changed(newEvent);
- }
- }
- break;
- }
- case StatusTextChange: {
- Variant arg1 = event.arguments[0];
- if (arg1.getType() == OLE.VT_BSTR) {
- String text = arg1.getString();
- StatusTextEvent newEvent = new StatusTextEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = Browser.this;
- newEvent.text = text;
- for (int i = 0; i < statusTextListeners.length; i++) {
- statusTextListeners[i].changed(newEvent);
- }
- }
- break;
- }
- case TitleChange: {
- Variant arg1 = event.arguments[0];
- if (arg1.getType() == OLE.VT_BSTR) {
- String title = arg1.getString();
- TitleEvent newEvent = new TitleEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = Browser.this;
- newEvent.title = title;
- for (int i = 0; i < titleListeners.length; i++) {
- titleListeners[i].changed(newEvent);
- }
- }
- break;
- }
- case WindowClosing: {
- WindowEvent newEvent = new WindowEvent(Browser.this);
- newEvent.display = getDisplay();
- newEvent.widget = Browser.this;
- for (int i = 0; i < closeWindowListeners.length; i++) {
- closeWindowListeners[i].close(newEvent);
- }
- Variant cancel = event.arguments[1];
- int pCancel = cancel.getByRef();
- Variant arg1 = event.arguments[0];
- boolean isChildWindow = arg1.getBoolean();
- COM.MoveMemory(pCancel, new short[]{isChildWindow ? COM.VARIANT_FALSE : COM.VARIANT_TRUE}, 2);
- dispose();
- break;
- }
- case WindowSetHeight: {
- if (size == null) size = new Point(0, 0);
- Variant arg1 = event.arguments[0];
- size.y = arg1.getInt();
- break;
- }
- case WindowSetLeft: {
- if (location == null) location = new Point(0, 0);
- Variant arg1 = event.arguments[0];
- location.x = arg1.getInt();
- break;
- }
- case WindowSetTop: {
- if (location == null) location = new Point(0, 0);
- Variant arg1 = event.arguments[0];
- location.y = arg1.getInt();
- break;
- }
- case WindowSetWidth: {
- if (size == null) size = new Point(0, 0);
- Variant arg1 = event.arguments[0];
- size.x = arg1.getInt();
- break;
- }
- }
- /*
- * Dispose all arguments passed in the OleEvent. This must be
- * done to properly release any IDispatch reference that was
- * automatically addRef'ed when constructing the OleEvent.
- */
- Variant[] arguments = event.arguments;
- for (int i = 0; i < arguments.length; i++) arguments[i].dispose();
- }
- };
- site.addEventListener(BeforeNavigate2, oleListener);
- site.addEventListener(CommandStateChange, oleListener);
- site.addEventListener(DocumentComplete, oleListener);
- site.addEventListener(NavigateComplete2, oleListener);
- site.addEventListener(NewWindow2, oleListener);
- site.addEventListener(OnMenuBar, oleListener);
- site.addEventListener(OnStatusBar, oleListener);
- site.addEventListener(OnToolBar, oleListener);
- site.addEventListener(OnVisible, oleListener);
- site.addEventListener(ProgressChange, oleListener);
- site.addEventListener(StatusTextChange, oleListener);
- site.addEventListener(TitleChange, oleListener);
- site.addEventListener(WindowClosing, oleListener);
- site.addEventListener(WindowSetHeight, oleListener);
- site.addEventListener(WindowSetLeft, oleListener);
- site.addEventListener(WindowSetTop, oleListener);
- site.addEventListener(WindowSetWidth, oleListener);
-
- Variant variant = new Variant(true);
- auto.setProperty(RegisterAsBrowser, variant);
- variant.dispose();
-
- variant = new Variant(false);
- int[] rgdispid = auto.getIDsOfNames(new String[] {"RegisterAsDropTarget"}); //$NON-NLS-1$
- if (rgdispid != null) auto.setProperty(rgdispid[0], variant);
- variant.dispose();
-
- // GOOGLE: Load Google Gears if we can.
- ((WebSite)site).startGears();
-}
-
-/**
- * Clears all session cookies from all current Browser instances.
- *
- * @since 3.2
- */
-public static void clearSessions () {
- OS.InternetSetOption (0, OS.INTERNET_OPTION_END_BROWSER_SESSION, 0, 0);
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the window hosting the receiver should be closed.
- * <p>
- * This notification occurs when a javascript command such as
- * <code>window.close</code> gets executed by a <code>Browser</code>.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addCloseWindowListener(CloseWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length + 1];
- System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, closeWindowListeners.length);
- closeWindowListeners = newCloseWindowListeners;
- closeWindowListeners[closeWindowListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the current location has changed or is about to change.
- * <p>
- * This notification typically occurs when the application navigates
- * to a new location with {@link #setUrl(String)} or when the user
- * activates a hyperlink.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addLocationListener(LocationListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- LocationListener[] newLocationListeners = new LocationListener[locationListeners.length + 1];
- System.arraycopy(locationListeners, 0, newLocationListeners, 0, locationListeners.length);
- locationListeners = newLocationListeners;
- locationListeners[locationListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when a new window needs to be created.
- * <p>
- * This notification occurs when a javascript command such as
- * <code>window.open</code> gets executed by a <code>Browser</code>.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addOpenWindowListener(OpenWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length + 1];
- System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, openWindowListeners.length);
- openWindowListeners = newOpenWindowListeners;
- openWindowListeners[openWindowListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when a progress is made during the loading of the current
- * URL or when the loading of the current URL has been completed.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addProgressListener(ProgressListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length + 1];
- System.arraycopy(progressListeners, 0, newProgressListeners, 0, progressListeners.length);
- progressListeners = newProgressListeners;
- progressListeners[progressListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the status text is changed.
- * <p>
- * The status text is typically displayed in the status bar of
- * a browser application.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addStatusTextListener(StatusTextListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length + 1];
- System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, statusTextListeners.length);
- statusTextListeners = newStatusTextListeners;
- statusTextListeners[statusTextListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when the title of the current document is available
- * or has changed.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addTitleListener(TitleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- TitleListener[] newTitleListeners = new TitleListener[titleListeners.length + 1];
- System.arraycopy(titleListeners, 0, newTitleListeners, 0, titleListeners.length);
- titleListeners = newTitleListeners;
- titleListeners[titleListeners.length - 1] = listener;
-}
-
-/**
- * Adds the listener to the collection of listeners who will be
- * notified when a window hosting the receiver needs to be displayed
- * or hidden.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void addVisibilityWindowListener(VisibilityWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length + 1];
- System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, visibilityWindowListeners.length);
- visibilityWindowListeners = newVisibilityWindowListeners;
- visibilityWindowListeners[visibilityWindowListeners.length - 1] = listener;
-}
-
-/**
- * Navigate to the previous session history item.
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #forward
- *
- * @since 3.0
- */
-public boolean back() {
- checkWidget();
- if (!back) return false;
- int[] rgdispid = auto.getIDsOfNames(new String[] { "GoBack" }); //$NON-NLS-1$
- Variant pVarResult = auto.invoke(rgdispid[0]);
- return pVarResult != null && pVarResult.getType() == OLE.VT_EMPTY;
-}
-
-protected void checkSubclass() {
- String name = getClass().getName();
- int index = name.lastIndexOf('.');
- if (!name.substring(0, index + 1).equals(PACKAGE_PREFIX)) {
- SWT.error(SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-
-/**
- * Execute the specified script.
- *
- * <p>
- * Execute a script containing javascript commands in the context of the current document.
- *
- * @param script the script with javascript commands
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the script is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public boolean execute(String script) {
- checkWidget();
- if (script == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- /* get IHTMLDocument2 */
- int[] rgdispid = auto.getIDsOfNames(new String[]{"Document"}); //$NON-NLS-1$
- int dispIdMember = rgdispid[0];
- Variant pVarResult = auto.getProperty(dispIdMember);
- if (pVarResult == null || pVarResult.getType() == COM.VT_EMPTY) return false;
- OleAutomation document = pVarResult.getAutomation();
- pVarResult.dispose();
-
- /* get IHTMLWindow2 */
- rgdispid = document.getIDsOfNames(new String[]{"parentWindow"}); //$NON-NLS-1$
- if (rgdispid == null) {
- /* implies that browser's content is not a IHTMLDocument2 (eg.- acrobat reader) */
- document.dispose();
- return false;
- }
- dispIdMember = rgdispid[0];
- pVarResult = document.getProperty(dispIdMember);
- OleAutomation ihtmlWindow2 = pVarResult.getAutomation();
- pVarResult.dispose();
- document.dispose();
-
- rgdispid = ihtmlWindow2.getIDsOfNames(new String[] { "execScript", "code" }); //$NON-NLS-1$ //$NON-NLS-2$
- Variant[] rgvarg = new Variant[1];
- rgvarg[0] = new Variant(script);
- int[] rgdispidNamedArgs = new int[1];
- rgdispidNamedArgs[0] = rgdispid[1];
- pVarResult = ihtmlWindow2.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs);
- rgvarg[0].dispose();
- ihtmlWindow2.dispose();
- if (pVarResult == null) return false;
- pVarResult.dispose();
- return true;
-}
-
-/**
- * Navigate to the next session history item.
- *
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #back
- *
- * @since 3.0
- */
-public boolean forward() {
- checkWidget();
- if (!forward) return false;
- int[] rgdispid = auto.getIDsOfNames(new String[] { "GoForward" }); //$NON-NLS-1$
- Variant pVarResult = auto.invoke(rgdispid[0]);
- return pVarResult != null && pVarResult.getType() == OLE.VT_EMPTY;
-}
-
-/**
- * Returns <code>true</code> if the receiver can navigate to the
- * previous session history item, and <code>false</code> otherwise.
- *
- * @return the receiver's back command enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #back
- */
-public boolean isBackEnabled() {
- checkWidget();
- return back;
-}
-
-/**
- * Returns <code>true</code> if the receiver can navigate to the
- * next session history item, and <code>false</code> otherwise.
- *
- * @return the receiver's forward command enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #forward
- */
-public boolean isForwardEnabled() {
- checkWidget();
- return forward;
-}
-
-/**
- * Returns the current URL.
- *
- * @return the current URL or an empty <code>String</code> if there is no current URL
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #setUrl
- *
- * @since 3.0
- */
-public String getUrl() {
- checkWidget();
- int[] rgdispid = auto.getIDsOfNames(new String[] { "LocationURL" }); //$NON-NLS-1$
- Variant pVarResult = auto.getProperty(rgdispid[0]);
- if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR)
- return "";
- String result = pVarResult.getString();
- pVarResult.dispose();
- return result;
-}
-
-public boolean isFocusControl () {
- checkWidget();
- if (site.isFocusControl() || frame.isFocusControl()) return true;
- return super.isFocusControl();
-}
-
-/**
- * Refresh the current page.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void refresh() {
- checkWidget();
- int[] rgdispid = auto.getIDsOfNames(new String[] { "Refresh" }); //$NON-NLS-1$
- auto.invoke(rgdispid[0]);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the window hosting the receiver should be closed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeCloseWindowListener(CloseWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (closeWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < closeWindowListeners.length; i++) {
- if (listener == closeWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (closeWindowListeners.length == 1) {
- closeWindowListeners = new CloseWindowListener[0];
- return;
- }
- CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length - 1];
- System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, index);
- System.arraycopy(closeWindowListeners, index + 1, newCloseWindowListeners, index, closeWindowListeners.length - index - 1);
- closeWindowListeners = newCloseWindowListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the current location is changed or about to be changed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeLocationListener(LocationListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (locationListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < locationListeners.length; i++) {
- if (listener == locationListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (locationListeners.length == 1) {
- locationListeners = new LocationListener[0];
- return;
- }
- LocationListener[] newLocationListeners = new LocationListener[locationListeners.length - 1];
- System.arraycopy(locationListeners, 0, newLocationListeners, 0, index);
- System.arraycopy(locationListeners, index + 1, newLocationListeners, index, locationListeners.length - index - 1);
- locationListeners = newLocationListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a new window needs to be created.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeOpenWindowListener(OpenWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (openWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < openWindowListeners.length; i++) {
- if (listener == openWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (openWindowListeners.length == 1) {
- openWindowListeners = new OpenWindowListener[0];
- return;
- }
- OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length - 1];
- System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, index);
- System.arraycopy(openWindowListeners, index + 1, newOpenWindowListeners, index, openWindowListeners.length - index - 1);
- openWindowListeners = newOpenWindowListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a progress is made during the loading of the current
- * URL or when the loading of the current URL has been completed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeProgressListener(ProgressListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (progressListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < progressListeners.length; i++) {
- if (listener == progressListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (progressListeners.length == 1) {
- progressListeners = new ProgressListener[0];
- return;
- }
- ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length - 1];
- System.arraycopy(progressListeners, 0, newProgressListeners, 0, index);
- System.arraycopy(progressListeners, index + 1, newProgressListeners, index, progressListeners.length - index - 1);
- progressListeners = newProgressListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the status text is changed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeStatusTextListener(StatusTextListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (statusTextListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < statusTextListeners.length; i++) {
- if (listener == statusTextListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (statusTextListeners.length == 1) {
- statusTextListeners = new StatusTextListener[0];
- return;
- }
- StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length - 1];
- System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, index);
- System.arraycopy(statusTextListeners, index + 1, newStatusTextListeners, index, statusTextListeners.length - index - 1);
- statusTextListeners = newStatusTextListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the title of the current document is available
- * or has changed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeTitleListener(TitleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (titleListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < titleListeners.length; i++) {
- if (listener == titleListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (titleListeners.length == 1) {
- titleListeners = new TitleListener[0];
- return;
- }
- TitleListener[] newTitleListeners = new TitleListener[titleListeners.length - 1];
- System.arraycopy(titleListeners, 0, newTitleListeners, 0, index);
- System.arraycopy(titleListeners, index + 1, newTitleListeners, index, titleListeners.length - index - 1);
- titleListeners = newTitleListeners;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a window hosting the receiver needs to be displayed
- * or hidden.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void removeVisibilityWindowListener(VisibilityWindowListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (visibilityWindowListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < visibilityWindowListeners.length; i++) {
- if (listener == visibilityWindowListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (visibilityWindowListeners.length == 1) {
- visibilityWindowListeners = new VisibilityWindowListener[0];
- return;
- }
- VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length - 1];
- System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, index);
- System.arraycopy(visibilityWindowListeners, index + 1, newVisibilityWindowListeners, index, visibilityWindowListeners.length - index - 1);
- visibilityWindowListeners = newVisibilityWindowListeners;
-}
-
-/**
- * Renders HTML.
- *
- * <p>
- * The html parameter is Unicode encoded since it is a java <code>String</code>.
- * As a result, the HTML meta tag charset should not be set. The charset is implied
- * by the <code>String</code> itself.
- *
- * @param html the HTML content to be rendered
- *
- * @return true if the operation was successful and false otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the html is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #setUrl
- *
- * @since 3.0
- */
-public boolean setText(String html) {
- checkWidget();
- if (html == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- /*
- * If the html field is non-null then the about:blank page is already being
- * loaded, so no Stop or Navigate is required. Just set the html that is to
- * be shown.
- */
- boolean blankLoading = this.html != null;
- this.html = html;
- if (blankLoading) return true;
-
- /*
- * Navigate to the blank page and insert the given html when
- * receiving the next DocumentComplete notification. See the
- * MSDN article "Loading HTML content from a Stream".
- *
- * Note. Stop any pending request. This is required to avoid displaying a
- * blank page as a result of consecutive calls to setUrl and/or setText.
- * The previous request would otherwise render the new html content and
- * reset the html field before the browser actually navigates to the blank
- * page as requested below.
- *
- * Feature in Internet Explorer. Stopping pending requests when no request
- * is pending causes a default page 'Action cancelled' to be displayed. The
- * workaround is to not invoke 'stop' when no request has been set since
- * that instance was created.
- */
- int[] rgdispid;
- if (navigate) {
- /*
- * Stopping the loading of a page causes DocumentComplete events from previous
- * requests to be received before the DocumentComplete for this page. In such
- * cases we must be sure to not set the html into the browser too soon, since
- * doing so could result in its page being cleared out by a subsequent
- * DocumentComplete. The Browser's ReadyState can be used to determine whether
- * these extra events will be received or not.
- */
- rgdispid = auto.getIDsOfNames(new String[] { "ReadyState" }); //$NON-NLS-1$
- Variant pVarResult = auto.getProperty(rgdispid[0]);
- if (pVarResult == null) return false;
- delaySetText = pVarResult.getInt() != READYSTATE_COMPLETE;
- pVarResult.dispose();
- rgdispid = auto.getIDsOfNames(new String[] { "Stop" }); //$NON-NLS-1$
- auto.invoke(rgdispid[0]);
- }
- rgdispid = auto.getIDsOfNames(new String[] { "Navigate", "URL" }); //$NON-NLS-1$ //$NON-NLS-2$
- navigate = true;
- Variant[] rgvarg = new Variant[1];
- rgvarg[0] = new Variant(ABOUT_BLANK);
- int[] rgdispidNamedArgs = new int[1];
- rgdispidNamedArgs[0] = rgdispid[1];
- Variant pVarResult = auto.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs);
- rgvarg[0].dispose();
- if (pVarResult == null) return false;
- boolean result = pVarResult.getType() == OLE.VT_EMPTY;
- pVarResult.dispose();
- return result;
-}
-
-/**
- * Loads a URL.
- *
- * @param url the URL to be loaded
- *
- * @return true if the operation was successful and false otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the url is null</li>
- * </ul>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @see #getUrl
- *
- * @since 3.0
- */
-public boolean setUrl(String url) {
- checkWidget();
- if (url == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- html = null;
-
- /*
- * Bug in Internet Explorer. For some reason, Navigating to an xml document before
- * a previous Navigate has completed will leave the Browser in a bad state if the
- * Navigate to the xml document does not complete. This bad state causes a GP when
- * the parent window is eventually disposed. The workaround is to issue a Stop before
- * navigating to any xml document.
- */
- if (url.endsWith(".xml")) { //$NON-NLS-1$
- /*
- * Feature in Internet Explorer. Stopping pending requests when no request has been
- * issued causes a default 'Action cancelled' page to be displayed. Since Stop must
- * be issued here, the workaround is to first Navigate to the about:blank page before
- * issuing Stop so that the 'Action cancelled' page is not displayed.
- */
- if (!navigate) {
- int[] rgdispid = auto.getIDsOfNames(new String[] { "Navigate", "URL" }); //$NON-NLS-1$ //$NON-NLS-2$
- Variant[] rgvarg = new Variant[1];
- rgvarg[0] = new Variant(ABOUT_BLANK);
- int[] rgdispidNamedArgs = new int[1];
- rgdispidNamedArgs[0] = rgdispid[1];
- auto.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs);
- rgvarg[0].dispose();
- }
- int[] rgdispid = auto.getIDsOfNames(new String[] { "Stop" }); //$NON-NLS-1$
- auto.invoke(rgdispid[0]);
- }
-
- int[] rgdispid = auto.getIDsOfNames(new String[] { "Navigate", "URL" }); //$NON-NLS-1$ //$NON-NLS-2$
- navigate = true;
- Variant[] rgvarg = new Variant[1];
- rgvarg[0] = new Variant(url);
- int[] rgdispidNamedArgs = new int[1];
- rgdispidNamedArgs[0] = rgdispid[1];
- Variant pVarResult = auto.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs);
- rgvarg[0].dispose();
- if (pVarResult == null) return false;
- boolean result = pVarResult.getType() == OLE.VT_EMPTY;
- pVarResult.dispose();
- return result;
-}
-
-/**
- * Stop any loading and rendering activity.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void stop() {
- checkWidget();
- int[] rgdispid = auto.getIDsOfNames(new String[] { "Stop" }); //$NON-NLS-1$
- auto.invoke(rgdispid[0]);
-}
-}
diff --git a/dev/windows/src/org/eclipse/swt/browser/WebSite.java b/dev/windows/src/org/eclipse/swt/browser/WebSite.java
deleted file mode 100644
index 824a3ed..0000000
--- a/dev/windows/src/org/eclipse/swt/browser/WebSite.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.browser;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.*;
-
-class WebSite extends OleControlSite {
- COMObject iDocHostUIHandler;
- COMObject iDocHostShowUI;
- COMObject iServiceProvider;
- COMObject iInternetSecurityManager;
- COMObject iOleCommandTarget;
-
- static final int OLECMDID_SHOWSCRIPTERROR = 40;
-
-public WebSite(Composite parent, int style, String progId) {
- super(parent, style, progId);
-}
-
-// GOOGLE: attempt to load Gears
-/**
- * Load the Google Gears BHO if possible.
- *
- * @return true if Gears was successfully loaded and initialized
- */
-public boolean startGears() {
- // Get the classID of the Gears BHO.
- GUID appClsid = null;
- try {
- appClsid = getClassID("gears.BHO");
- if (appClsid == null) {
- return false;
- }
- } catch(SWTException e) {
- return false;
- }
-
- // Create an instance of the Gears BHO.
- int[] address = new int[1];
- if (COM.CoCreateInstance(appClsid, 0, COM.CLSCTX_INPROC_SERVER,
- COM.IIDIUnknown, address) != COM.S_OK) {
- return false;
- }
-
- // Get the IObjectWithSite interface and call SetSite.
- IUnknown obj = new IUnknown(address[0]);
- int[] ppvObject = new int[1];
- if (obj.QueryInterface(COM.IIDIObjectWithSite, ppvObject) == COM.S_OK) {
- IObjectWithSite objectWithSite = new IObjectWithSite(ppvObject[0]);
- /*
- * TODO: Gears currently does not check the parameter passed other than
- * to see if it is non-null. If Gears ever changes to actually use the
- * passed object, we will need to make sure that this works as expected.
- */
- objectWithSite.SetSite(objIUnknown);
- objectWithSite.Release();
- return true;
- }
- return false;
-}
-
-protected void createCOMInterfaces () {
- super.createCOMInterfaces();
- iDocHostUIHandler = new COMObject(new int[]{2, 0, 0, 4, 1, 5, 0, 0, 1, 1, 1, 3, 3, 2, 2, 1, 3, 2}){
- public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
- public int method1(int[] args) {return AddRef();}
- public int method2(int[] args) {return Release();}
- public int method3(int[] args) {return ShowContextMenu(args[0], args[1], args[2], args[3]);}
- public int method4(int[] args) {return GetHostInfo(args[0]);}
- public int method5(int[] args) {return ShowUI(args[0], args[1], args[2], args[3], args[4]);}
- public int method6(int[] args) {return HideUI();}
- public int method7(int[] args) {return UpdateUI();}
- public int method8(int[] args) {return EnableModeless(args[0]);}
- public int method9(int[] args) {return OnDocWindowActivate(args[0]);}
- public int method10(int[] args) {return OnFrameWindowActivate(args[0]);}
- public int method11(int[] args) {return ResizeBorder(args[0], args[1], args[2]);}
- public int method12(int[] args) {return TranslateAccelerator(args[0], args[1], args[2]);}
- public int method13(int[] args) {return GetOptionKeyPath(args[0], args[1]);}
- public int method14(int[] args) {return GetDropTarget(args[0], args[1]);}
- public int method15(int[] args) {return GetExternal(args[0]);}
- public int method16(int[] args) {return TranslateUrl(args[0], args[1], args[2]);}
- public int method17(int[] args) {return FilterDataObject(args[0], args[1]);}
- };
- iDocHostShowUI = new COMObject(new int[]{2, 0, 0, 7, 7}){
- public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
- public int method1(int[] args) {return AddRef();}
- public int method2(int[] args) {return Release();}
- public int method3(int[] args) {return ShowMessage(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
- public int method4(int[] args) {return ShowHelp(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
- };
- iServiceProvider = new COMObject(new int[]{2, 0, 0, 3}){
- public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
- public int method1(int[] args) {return AddRef();}
- public int method2(int[] args) {return Release();}
- public int method3(int[] args) {return QueryService(args[0], args[1], args[2]);}
- };
- iInternetSecurityManager = new COMObject(new int[]{2, 0, 0, 1, 1, 3, 4, 8, 7, 3, 3}){
- public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
- public int method1(int[] args) {return AddRef();}
- public int method2(int[] args) {return Release();}
- public int method3(int[] args) {return SetSecuritySite(args[0]);}
- public int method4(int[] args) {return GetSecuritySite(args[0]);}
- public int method5(int[] args) {return MapUrlToZone(args[0], args[1], args[2]);}
- public int method6(int[] args) {return GetSecurityId(args[0], args[1], args[2], args[3]);}
- public int method7(int[] args) {return ProcessUrlAction(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
- public int method8(int[] args) {return QueryCustomPolicy(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
- public int method9(int[] args) {return SetZoneMapping(args[0], args[1], args[2]);}
- public int method10(int[] args) {return GetZoneMappings(args[0], args[1], args[2]);}
- };
- iOleCommandTarget = new COMObject(new int[]{2, 0, 0, 4, 5}) {
- public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
- public int method1(int[] args) {return AddRef();}
- public int method2(int[] args) {return Release();}
- public int method3(int[] args) {return QueryStatus(args[0], args[1], args[2], args[3]);}
- public int method4(int[] args) {return Exec(args[0], args[1], args[2], args[3], args[4]);}
- };
-}
-
-protected void disposeCOMInterfaces() {
- super.disposeCOMInterfaces();
- if (iDocHostUIHandler != null) {
- iDocHostUIHandler.dispose();
- iDocHostUIHandler = null;
- }
- if (iDocHostShowUI != null) {
- iDocHostShowUI.dispose();
- iDocHostShowUI = null;
- }
- if (iServiceProvider != null) {
- iServiceProvider.dispose();
- iServiceProvider = null;
- }
- if (iInternetSecurityManager != null) {
- iInternetSecurityManager.dispose();
- iInternetSecurityManager = null;
- }
- if (iOleCommandTarget != null) {
- iOleCommandTarget.dispose();
- iOleCommandTarget = null;
- }
-}
-
-protected int AddRef() {
- /* Workaround for javac 1.1.8 bug */
- return super.AddRef();
-}
-
-protected int QueryInterface(int riid, int ppvObject) {
- int result = super.QueryInterface(riid, ppvObject);
- if (result == COM.S_OK) return result;
- if (riid == 0 || ppvObject == 0) return COM.E_INVALIDARG;
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
- if (COM.IsEqualGUID(guid, COM.IIDIDocHostUIHandler)) {
- COM.MoveMemory(ppvObject, new int[] {iDocHostUIHandler.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIDocHostShowUI)) {
- COM.MoveMemory(ppvObject, new int[] {iDocHostShowUI.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIServiceProvider)) {
- COM.MoveMemory(ppvObject, new int[] {iServiceProvider.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIInternetSecurityManager)) {
- COM.MoveMemory(ppvObject, new int[] {iInternetSecurityManager.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIOleCommandTarget)) {
- COM.MoveMemory(ppvObject, new int[] {iOleCommandTarget.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
- COM.MoveMemory(ppvObject, new int[] {0}, 4);
- return COM.E_NOINTERFACE;
-}
-
-/* IDocHostUIHandler */
-
-int EnableModeless(int EnableModeless) {
- return COM.E_NOTIMPL;
-}
-
-int FilterDataObject(int pDO, int ppDORet) {
- return COM.E_NOTIMPL;
-}
-
-int GetDropTarget(int pDropTarget, int ppDropTarget) {
- return COM.E_NOTIMPL;
-}
-
-int GetExternal(int ppDispatch) {
- OS.MoveMemory(ppDispatch, new int[] {0}, 4);
- return COM.S_FALSE;
-}
-
-int GetHostInfo(int pInfo) {
- Browser browser = (Browser)getParent().getParent();
- OS.MoveMemory(pInfo + 4, new int[] {browser.info}, 4);
- return COM.S_OK;
-}
-
-int GetOptionKeyPath(int pchKey, int dw) {
- return COM.E_NOTIMPL;
-}
-
-int HideUI() {
- return COM.E_NOTIMPL;
-}
-
-int OnDocWindowActivate(int fActivate) {
- return COM.E_NOTIMPL;
-}
-
-int OnFrameWindowActivate(int fActivate) {
- return COM.E_NOTIMPL;
-}
-
-protected int Release() {
- /* Workaround for javac 1.1.8 bug */
- return super.Release();
-}
-
-int ResizeBorder(int prcBorder, int pUIWindow, int fFrameWindow) {
- return COM.E_NOTIMPL;
-}
-
-int ShowContextMenu(int dwID, int ppt, int pcmdtReserved, int pdispReserved) {
- Browser browser = (Browser)getParent().getParent();
- Event event = new Event();
- POINT pt = new POINT();
- OS.MoveMemory(pt, ppt, POINT.sizeof);
- event.x = pt.x;
- event.y = pt.y;
- browser.notifyListeners(SWT.MenuDetect, event);
- if (!event.doit) return COM.S_OK;
- Menu menu = browser.getMenu();
- if (menu != null && !menu.isDisposed ()) {
- if (pt.x != event.x || pt.y != event.y) {
- menu.setLocation (event.x, event.y);
- }
- menu.setVisible (true);
- return COM.S_OK;
- }
- /* Show default IE popup menu */
- return COM.S_FALSE;
-}
-
-int ShowUI(int dwID, int pActiveObject, int pCommandTarget, int pFrame, int pDoc) {
- return COM.E_NOTIMPL;
-}
-
-int TranslateAccelerator(int lpMsg, int pguidCmdGroup, int nCmdID) {
- /*
- * Feature on Internet Explorer. By default the embedded Internet Explorer control runs
- * the Internet Explorer shortcuts (e.g. F5 for refresh). This overrides the shortcuts
- * defined by SWT. The workaround is to forward the accelerator keys to the parent window
- * and have Internet Explorer ignore the ones handled by the parent window.
- */
- Menu menubar = getShell().getMenuBar();
- if (menubar != null && !menubar.isDisposed() && menubar.isEnabled()) {
- Shell shell = menubar.getShell();
- int hwnd = shell.handle;
- int hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0);
- if (hAccel != 0) {
- MSG msg = new MSG();
- OS.MoveMemory(msg, lpMsg, MSG.sizeof);
- if (OS.TranslateAccelerator(hwnd, hAccel, msg) != 0) return COM.S_OK;
- }
- }
- /*
- * Feature on Internet Explorer. By default the embedded Internet Explorer control runs
- * the Internet Explorer shortcuts. F5 causes refresh. CTRL-N opens a standalone Internet
- * Explorer. These behaviours are undesired when rendering HTML in memory.
- * The workaround is to block the default CTRL-N and F5 handling by IE when the URL is about:blank.
- */
- OleAutomation auto = new OleAutomation(this);
- int[] rgdispid = auto.getIDsOfNames(new String[] { "LocationURL" }); //$NON-NLS-1$
- Variant pVarResult = auto.getProperty(rgdispid[0]);
- auto.dispose();
- int result = COM.S_FALSE;
- if (pVarResult != null) {
- if (pVarResult.getType() == OLE.VT_BSTR) {
- String url = pVarResult.getString();
- if (url.equals(Browser.ABOUT_BLANK)) {
- MSG msg = new MSG();
- OS.MoveMemory(msg, lpMsg, MSG.sizeof);
- if (msg.message == OS.WM_KEYDOWN && msg.wParam == OS.VK_F5) result = COM.S_OK;
- if (msg.message == OS.WM_KEYDOWN && msg.wParam == OS.VK_N && OS.GetKeyState (OS.VK_CONTROL) < 0) result = COM.S_OK;
- }
- }
- pVarResult.dispose();
- }
- return result;
-}
-
-int TranslateUrl(int dwTranslate, int pchURLIn, int ppchURLOut) {
- return COM.E_NOTIMPL;
-}
-
-int UpdateUI() {
- return COM.E_NOTIMPL;
-}
-
-/* IDocHostShowUI */
-
-int ShowMessage(int hwnd, int lpstrText, int lpstrCaption, int dwType, int lpstrHelpFile, int dwHelpContext, int plResult) {
- /*
- * Feature on IE. When IE navigates to a website that contains an ActiveX that is prevented from
- * being executed, IE displays a message "Your current security settings prohibit running ActiveX
- * controls on this page ...". The workaround is to selectively block this alert as indicated
- * in the MSDN article "WebBrowser customization".
- */
- /* resource identifier in shdoclc.dll for window caption "Your current security settings prohibit
- * running ActiveX controls on this page ..."
- */
- int IDS_MESSAGE_BOX_CAPTION = 8033;
- if (lpstrText != 0) {
- TCHAR lpLibFileName = new TCHAR (0, "SHDOCLC.DLL", true); //$NON-NLS-1$
- int hModule = OS.LoadLibrary(lpLibFileName);
- if (hModule != 0) {
- /*
- * Note. lpstrText is a LPOLESTR, i.e. a null terminated unicode string LPWSTR, i.e. a WCHAR*.
- * It is not a BSTR. A BSTR is a null terminated unicode string that contains its length
- * at the beginning.
- */
- int cnt = OS.wcslen(lpstrText);
- char[] buffer = new char[cnt];
- /*
- * Note. lpstrText is unicode on both unicode and ansi platforms.
- * The nbr of chars is multiplied by the constant 2 and not by TCHAR.sizeof since
- * TCHAR.sizeof returns 1 on ansi platforms.
- */
- OS.MoveMemory(buffer, lpstrText, cnt * 2);
- String text = new String(buffer);
- /* provide a buffer large enough to hold the string to compare to and a null terminated character */
- int length = (OS.IsUnicode ? cnt : OS.WideCharToMultiByte (OS.CP_ACP, 0, buffer, cnt, 0, 0, null, null)) + 1;
-
- TCHAR lpBuffer = new TCHAR(0, length);
- int result = OS.LoadString(hModule, IDS_MESSAGE_BOX_CAPTION, lpBuffer, length);
- OS.FreeLibrary(hModule);
- return result > 0 && text.equals(lpBuffer.toString(0, result)) ? COM.S_OK : COM.S_FALSE;
- }
- }
- return COM.S_FALSE;
-}
-
-/* Note. One of the arguments of ShowHelp is a POINT struct and not a pointer to a POINT struct. Because
- * of the way Callback gets int parameters from a va_list of C arguments 2 integer arguments must be declared,
- * ptMouse_x and ptMouse_y. Otherwise the Browser crashes when the user presses F1 to invoke
- * the help.
- */
-int ShowHelp(int hwnd, int pszHelpFile, int uCommand, int dwData, int ptMouse_x, int ptMouse_y, int pDispatchObjectHit) {
- Browser browser = (Browser)getParent().getParent();
- Event event = new Event();
- event.type = SWT.Help;
- event.display = getDisplay();
- event.widget = browser;
- Shell shell = browser.getShell();
- Control control = browser;
- do {
- if (control.isListening(SWT.Help)) {
- control.notifyListeners(SWT.Help, event);
- break;
- }
- if (control == shell) break;
- control = control.getParent();
- } while (true);
- return COM.S_OK;
-}
-
-/* IServiceProvider */
-
-int QueryService(int guidService, int riid, int ppvObject) {
- if (riid == 0 || ppvObject == 0) return COM.E_INVALIDARG;
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
- if (COM.IsEqualGUID(guid, COM.IIDIInternetSecurityManager)) {
- COM.MoveMemory(ppvObject, new int[] {iInternetSecurityManager.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
- COM.MoveMemory(ppvObject, new int[] {0}, 4);
- return COM.E_NOINTERFACE;
-}
-
-/* IInternetSecurityManager */
-
-int SetSecuritySite(int pSite) {
- return Browser.INET_E_DEFAULT_ACTION;
-}
-
-int GetSecuritySite(int ppSite) {
- return Browser.INET_E_DEFAULT_ACTION;
-}
-
-int MapUrlToZone(int pwszUrl, int pdwZone, int dwFlags) {
- /*
- * Feature in IE 6 sp1. HTML rendered in memory
- * does not enable local links but the exact same
- * HTML document loaded through a local file is
- * permitted to follow local links. The workaround is
- * to return URLZONE_INTRANET instead of the default
- * value URLZONE_LOCAL_MACHINE.
- */
- COM.MoveMemory(pdwZone, new int[] {Browser.URLZONE_INTRANET}, 4);
- return COM.S_OK;
-}
-
-int GetSecurityId(int pwszUrl, int pbSecurityId, int pcbSecurityId, int dwReserved) {
- return Browser.INET_E_DEFAULT_ACTION;
-}
-
-int ProcessUrlAction(int pwszUrl, int dwAction, int pPolicy, int cbPolicy, int pContext, int cbContext, int dwFlags, int dwReserved) {
- /*
- * Feature in IE 6 sp1. HTML rendered in memory
- * containing an OBJECT tag referring to a local file
- * brings up a warning dialog asking the user whether
- * it should proceed or not. The workaround is to
- * set the policy to URLPOLICY_ALLOW in this case (dwAction
- * value of 0x1406).
- *
- * Feature in IE. Security Patches and user settings
- * affect the way the embedded web control behaves. The current
- * approach is to consider the content trusted and allow
- * all URLs by default.
- */
- int policy = Browser.URLPOLICY_ALLOW;
- /*
- * Note. The URLACTION_JAVA flags refer to the applet tag that normally resolve to
- * the Microsoft VM, not to the java OBJECT tag that resolves to the
- * Sun plugin. Return URLPOLICY_JAVA_LOW to authorize applets instead of
- * URLPOLICY_ALLOW that is interpreted as URLPOLICY_JAVA_PROHIBIT in this
- * context.
- */
- if (dwAction >= Browser.URLACTION_JAVA_MIN && dwAction <= Browser.URLACTION_JAVA_MAX) {
- policy = Browser.URLPOLICY_JAVA_LOW;
- }
- /*
- * Note. Some ActiveX plugins crash when executing
- * inside the embedded explorer itself running into
- * a JVM. The current workaround is to detect when
- * such ActiveX is about to be started and refuse
- * to execute it.
- */
- if (dwAction == Browser.URLACTION_ACTIVEX_RUN) {
- GUID guid = new GUID();
- COM.MoveMemory(guid, pContext, GUID.sizeof);
- if (COM.IsEqualGUID(guid, COM.IIDJavaBeansBridge) || COM.IsEqualGUID(guid, COM.IIDShockwaveActiveXControl)) {
- policy = Browser.URLPOLICY_DISALLOW;
- }
- }
- if (cbPolicy >= 4) COM.MoveMemory(pPolicy, new int[] {policy}, 4);
- return COM.S_OK;
-}
-
-int QueryCustomPolicy(int pwszUrl, int guidKey, int ppPolicy, int pcbPolicy, int pContext, int cbContext, int dwReserved) {
- return Browser.INET_E_DEFAULT_ACTION;
-}
-
-int SetZoneMapping(int dwZone, int lpszPattern, int dwFlags) {
- return Browser.INET_E_DEFAULT_ACTION;
-}
-
-int GetZoneMappings(int dwZone, int ppenumString, int dwFlags) {
- return COM.E_NOTIMPL;
-}
-
-/* IOleCommandTarget */
-int QueryStatus(int pguidCmdGroup, int cCmds, int prgCmds, int pCmdText) {
- return COM.E_NOTSUPPORTED;
-}
-
-int Exec(int pguidCmdGroup, int nCmdID, int nCmdExecOpt, int pvaIn, int pvaOut) {
- if (pguidCmdGroup != 0) {
- GUID guid = new GUID();
- COM.MoveMemory(guid, pguidCmdGroup, GUID.sizeof);
-
- /*
- * If a javascript error occurred then suppress IE's default script error dialog.
- */
- if (COM.IsEqualGUID(guid, COM.CGID_DocHostCommandHandler)) {
- if (nCmdID == OLECMDID_SHOWSCRIPTERROR) return COM.S_OK;
- }
-
- /*
- * Bug in Internet Explorer. OnToolBar TRUE is also fired when any of the
- * address bar or menu bar are requested but not the tool bar. A workaround
- * has been posted by a Microsoft developer on the public webbrowser_ctl
- * newsgroup. The workaround is to implement the IOleCommandTarget interface
- * to test the argument of an undocumented command.
- */
- if (nCmdID == 1 && COM.IsEqualGUID(guid, COM.CGID_Explorer) && ((nCmdExecOpt & 0xFFFF) == 0xA)) {
- Browser browser = (Browser)getParent().getParent();
- browser.toolBar = (nCmdExecOpt & 0xFFFF0000) != 0;
- }
- }
- return COM.E_NOTSUPPORTED;
-}
-
-}
diff --git a/dev/windows/src/org/eclipse/swt/internal/Library.java b/dev/windows/src/org/eclipse/swt/internal/Library.java
deleted file mode 100644
index 35900e3..0000000
--- a/dev/windows/src/org/eclipse/swt/internal/Library.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.internal;
-
-public class Library {
-
- /* SWT Version - Mmmm (M=major, mmm=minor) */
-
- /**
- * SWT Major version number (must be >= 0)
- */
- static int MAJOR_VERSION = 3;
-
- /**
- * SWT Minor version number (must be in the range 0..999)
- */
- static int MINOR_VERSION = 235;
-
- /**
- * SWT revision number (must be >= 0)
- */
- static int REVISION = 0;
-
- /**
- * The JAVA and SWT versions
- */
- public static final int JAVA_VERSION, SWT_VERSION;
-
-static {
- JAVA_VERSION = parseVersion(System.getProperty("java.version"));
- SWT_VERSION = SWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
-}
-
-static int parseVersion(String version) {
- if (version == null) return 0;
- int major = 0, minor = 0, micro = 0;
- int length = version.length(), index = 0, start = 0;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) major = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- start = ++index;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) minor = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- start = ++index;
- while (index < length && Character.isDigit(version.charAt(index))) index++;
- try {
- if (start < length) micro = Integer.parseInt(version.substring(start, index));
- } catch (NumberFormatException e) {}
- return JAVA_VERSION(major, minor, micro);
-}
-
-/**
- * Returns the Java version number as an integer.
- *
- * @param major
- * @param minor
- * @param micro
- * @return the version
- */
-public static int JAVA_VERSION (int major, int minor, int micro) {
- return (major << 16) + (minor << 8) + micro;
-}
-
-/**
- * Returns the SWT version number as an integer.
- *
- * @param major
- * @param minor
- * @return the version
- */
-public static int SWT_VERSION (int major, int minor) {
- return major * 1000 + minor;
-}
-
-/**
- * Loads the shared library that matches the version of the
- * Java code which is currently running. SWT shared libraries
- * follow an encoding scheme where the major, minor and revision
- * numbers are embedded in the library name and this along with
- * <code>name</code> is used to load the library. If this fails,
- * <code>name</code> is used in another attempt to load the library,
- * this time ignoring the SWT version encoding scheme.
- *
- * @param name the name of the library to load
- */
-public static void loadLibrary (String name) {
- /*
- * Include platform name to support different windowing systems
- * on same operating system.
- */
- String platform = Platform.PLATFORM;
-
- /*
- * Get version qualifier.
- */
- String version = System.getProperty ("swt.version"); //$NON-NLS-1$
- if (version == null) {
- version = "" + MAJOR_VERSION; //$NON-NLS-1$
- /* Force 3 digits in minor version number */
- if (MINOR_VERSION < 10) {
- version += "00"; //$NON-NLS-1$
- } else {
- if (MINOR_VERSION < 100) version += "0"; //$NON-NLS-1$
- }
- version += MINOR_VERSION;
- /* No "r" until first revision */
- if (REVISION > 0) version += "r" + REVISION; //$NON-NLS-1$
- }
-
- /*
- * GOOGLE: Since we're bundling our own version of SWT, we need to be
- * able to tell SWT where its dynamic libraries live. Otherwise we'd
- * have to force our users to always specify a -Djava.library.path
- * on the command line.
- */
- String swtLibraryPath = System.getProperty ("swt.library.path");
- try {
- String newName = name + "-" + platform + "-" + version; //$NON-NLS-1$ //$NON-NLS-2$
- if (swtLibraryPath != null)
- System.load(swtLibraryPath + System.mapLibraryName(newName));
- else
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e1) {
- try {
- String newName = name + "-" + platform; //$NON-NLS-1$
- if (swtLibraryPath != null)
- System.load(swtLibraryPath + System.mapLibraryName(newName));
- else
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e2) {
- throw e1;
- }
- }
-}
-
-}
diff --git a/dev/windows/src/org/eclipse/swt/internal/ole/win32/COM.java b/dev/windows/src/org/eclipse/swt/internal/ole/win32/COM.java
deleted file mode 100644
index 769cb8a..0000000
--- a/dev/windows/src/org/eclipse/swt/internal/ole/win32/COM.java
+++ /dev/null
@@ -1,607 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.internal.ole.win32;
-
-import org.eclipse.swt.internal.win32.*;
-
-public class COM extends OS {
- /** GUID Constants */
- public static final GUID IIDJavaBeansBridge = COM.IIDFromString("{8AD9C840-044E-11D1-B3E9-00805F499D93}"); //$NON-NLS-1$
- public static final GUID IIDShockwaveActiveXControl = COM.IIDFromString("{166B1BCA-3F9C-11CF-8075-444553540000}"); //$NON-NLS-1$
- public static final GUID IIDIEditorSiteTime = IIDFromString("{6BD2AEFE-7876-45e6-A6E7-3BFCDF6540AA}"); //$NON-NLS-1$
- public static final GUID IIDIEditorSiteProperty = IIDFromString("{D381A1F4-2326-4f3c-AFB9-B7537DB9E238}"); //$NON-NLS-1$
- public static final GUID IIDIEditorBaseProperty = IIDFromString("{61E55B0B-2647-47c4-8C89-E736EF15D636}"); //$NON-NLS-1$
- public static final GUID IIDIEditorSite = IIDFromString("{CDD88AB9-B01D-426E-B0F0-30973E9A074B}"); //$NON-NLS-1$
- public static final GUID IIDIEditorService = IIDFromString("{BEE283FE-7B42-4FF3-8232-0F07D43ABCF1}"); //$NON-NLS-1$
- public static final GUID IIDIEditorManager = IIDFromString("{EFDE08C4-BE87-4B1A-BF84-15FC30207180}"); //$NON-NLS-1$
- public static final GUID IIDIAccessible = IIDFromString("{618736E0-3C3D-11CF-810C-00AA00389B71}"); //$NON-NLS-1$
- //public static final GUID IIDIAccessibleHandler = IIDFromString("{03022430-ABC4-11D0-BDE2-00AA001A1953}"); //$NON-NLS-1$
- //public static final GUID IIDIAccessor = IIDFromString("{0C733A8C-2A1C-11CE-ADE5-00AA0044773D}"); //$NON-NLS-1$
- public static final GUID IIDIAdviseSink = IIDFromString("{0000010F-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIAdviseSink2 = IIDFromString("{00000125-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIBindCtx = IIDFromString("{0000000E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIClassFactory = IIDFromString("{00000001-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIClassFactory2 = IIDFromString("{B196B28F-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIConnectionPoint = IIDFromString("{B196B286-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIConnectionPointContainer = IIDFromString("{B196B284-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDICreateErrorInfo = IIDFromString("{22F03340-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
- //public static final GUID IIDICreateTypeInfo = IIDFromString("{00020405-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDICreateTypeLib = IIDFromString("{00020406-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIDataAdviseHolder = IIDFromString("{00000110-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDataObject = IIDFromString("{0000010E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDocHostUIHandler = IIDFromString("{BD3F23C0-D43E-11CF-893B-00AA00BDCE1A}"); //$NON-NLS-1$
- public static final GUID IIDIDocHostShowUI = IIDFromString("{C4D244B0-D43E-11CF-893B-00AA00BDCE1A}"); //$NON-NLS-1$
- public static final GUID IIDIDropSource = IIDFromString("{00000121-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDropTarget = IIDFromString("{00000122-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumConnectionPoints = IIDFromString("{B196B285-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumConnections = IIDFromString("{B196B287-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIEnumFORMATETC = IIDFromString("{00000103-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumMoniker = IIDFromString("{00000102-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumOLEVERB = IIDFromString("{00000104-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumSTATDATA = IIDFromString("{00000105-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumSTATSTG = IIDFromString("{0000000D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumString = IIDFromString("{00000101-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumUnknown = IIDFromString("{00000100-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIEnumVARIANT = IIDFromString("{00020404-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIErrorInfo = IIDFromString("{1CF2B120-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
- //public static final GUID IIDIErrorLog = IIDFromString("{3127CA40-446E-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
- //public static final GUID IIDIExternalConnection = IIDFromString("{00000019-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIFont = IIDFromString("{BEF6E002-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$
- //public static final GUID IIDIFontDisp = IIDFromString("{BEF6E003-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$
- public static final GUID IIDIInternetSecurityManager = IIDFromString("{79eac9ee-baf9-11ce-8c82-00aa004ba90b}"); //$NON-NLS-1$
- //public static final GUID IIDILockBytes = IIDFromString("{0000000A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMalloc = IIDFromString("{00000002-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMallocSpy = IIDFromString("{0000001D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMarshal = IIDFromString("{00000003-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMessageFilter = IIDFromString("{00000016-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMoniker = IIDFromString("{0000000F-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIObjectWithSite = IIDFromString("{FC4801A3-2BA9-11CF-A229-00AA003D7352}"); //$NON-NLS-1$ // GOOGLE
- //public static final GUID IIDIOleAdviseHolder = IIDFromString("{00000111-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleCache = IIDFromString("{0000011E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleCache2 = IIDFromString("{00000128-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleCacheControl = IIDFromString("{00000129-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleClientSite = IIDFromString("{00000118-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleCommandTarget = IIDFromString("{B722BCCB-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
- public static final GUID IIDIOleContainer = IIDFromString("{0000011B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleControl = IIDFromString("{B196B288-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIOleControlSite = IIDFromString("{B196B289-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIOleDocument = IIDFromString("{B722BCC5-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
- public static final GUID IIDIOleDocumentSite = IIDFromString("{B722BCC7-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceActiveObject = IIDFromString("{00000117-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceFrame = IIDFromString("{00000116-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceObject = IIDFromString("{00000113-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceSite = IIDFromString("{00000119-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceUIWindow = IIDFromString("{00000115-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleItemContainer = IIDFromString("{0000011C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleLink = IIDFromString("{0000011D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleObject = IIDFromString("{00000112-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleWindow = IIDFromString("{00000114-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIParseDisplayName = IIDFromString("{0000011A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIPerPropertyBrowsing = IIDFromString("{376BD3AA-3845-101B-84ED-08002B2EC713}"); //$NON-NLS-1$
- public static final GUID IIDIPersist = IIDFromString("{0000010C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIPersistFile = IIDFromString("{0000010B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIPersistMemory = IIDFromString("{BD1AE5E0-A6AE-11CE-BD37-504200C10000}"); //$NON-NLS-1$
- //public static final GUID IIDIPersistPropertyBag = IIDFromString("{37D84F60-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
- public static final GUID IIDIPersistStorage = IIDFromString("{0000010A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIPersistStream = IIDFromString("{00000109-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIPersistStreamInit = IIDFromString("{7FD52380-4E07-101B-AE2D-08002B2EC713}"); //$NON-NLS-1$
- //public static final GUID IIDIPicture = IIDFromString("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$
- //public static final GUID IIDIPictureDisp = IIDFromString("{7BF80981-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyBag = IIDFromString("{55272A00-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
- public static final GUID IIDIPropertyNotifySink = IIDFromString("{9BFBBC02-EFF1-101A-84ED-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyPage = IIDFromString("{B196B28D-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyPage2 = IIDFromString("{01E44665-24AC-101B-84ED-08002B2EC713}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyPageSite = IIDFromString("{B196B28C-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIProvideClassInfo = IIDFromString("{B196B283-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIProvideClassInfo2 = IIDFromString("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}"); //$NON-NLS-1$
- //public static final GUID IIDIPSFactoryBuffer = IIDFromString("{D5F569D0-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRootStorage = IIDFromString("{00000012-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIROTData = IIDFromString("{F29F6BC0-5021-11CE-AA15-00006901293F}"); //$NON-NLS-1$
- //public static final GUID IIDIRpcChannelBuffer = IIDFromString("{D5F56B60-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRpcProxyBuffer = IIDFromString("{D5F56A34-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRpcStubBuffer = IIDFromString("{D5F56AFC-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRunnableObject = IIDFromString("{00000126-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIRunningObjectTable = IIDFromString("{00000010-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDISimpleFrameSite = IIDFromString("{742B0E01-14E6-101B-914E-00AA00300CAB}"); //$NON-NLS-1$
- public static final GUID IIDIServiceProvider = IIDFromString("{6d5140c1-7436-11ce-8034-00aa006009fa}"); //$NON-NLS-1$
- public static final GUID IIDISpecifyPropertyPages = IIDFromString("{B196B28B-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIStdMarshalInfo = IIDFromString("{00000018-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIStorage = IIDFromString("{0000000B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIStream = IIDFromString("{0000000C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDISupportErrorInfo = IIDFromString("{DF0B3D60-548F-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
- //public static final GUID IIDITypeComp = IIDFromString("{00020403-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDITypeLib = IIDFromString("{00020402-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIUnknown = IIDFromString("{00000000-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIViewObject = IIDFromString("{0000010D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIViewObject2 = IIDFromString("{00000127-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID CGID_DocHostCommandHandler = IIDFromString("{f38bc242-b950-11d1-8918-00c04fc2c836}"); //$NON-NLS-1$
- public static final GUID CGID_Explorer = IIDFromString("{000214D0-0000-0000-C000-000000000046}"); //$NON-NLS-1$
-
-
- /** Constants */
- //public static final int ADVF_DATAONSTOP = 64;
- //public static final int ADVF_NODATA = 1;
- //public static final int ADVF_ONLYONCE = 2;
- //public static final int ADVF_PRIMEFIRST = 4;
- //public static final int ADVFCACHE_FORCEBUILTIN = 16;
- //public static final int ADVFCACHE_NOHANDLER = 8;
- //public static final int ADVFCACHE_ONSAVE = 32;
- public static final int CF_TEXT = 1;
- public static final int CF_BITMAP = 2;
- public static final int CF_METAFILEPICT = 3;
- public static final int CF_SYLK = 4;
- public static final int CF_DIF = 5;
- public static final int CF_TIFF = 6;
- public static final int CF_OEMTEXT = 7;
- public static final int CF_DIB = 8;
- public static final int CF_PALETTE = 9;
- public static final int CF_PENDATA = 10;
- public static final int CF_RIFF = 11;
- public static final int CF_WAVE = 12;
- public static final int CF_UNICODETEXT = 13;
- public static final int CF_ENHMETAFILE = 14;
- public static final int CF_HDROP = 15;
- public static final int CF_LOCALE = 16;
- public static final int CF_MAX = 17;
- public static final int CLSCTX_INPROC_HANDLER = 2;
- public static final int CLSCTX_INPROC_SERVER = 1;
- public static final int CLSCTX_LOCAL_SERVER = 4;
- public static final int CLSCTX_REMOTE_SERVER = 16;
- public static final int CO_E_CLASSSTRING = -2147221005;
- //public static final int COINIT_APARTMENTTHREADED = 2;
- //public static final int COINIT_DISABLE_OLE1DDE = 4;
- //public static final int COINIT_MULTITHREADED = 0;
- //public static final int COINIT_SPEED_OVER_MEMORY = 8;
- public static final int DATADIR_GET = 1;
- public static final int DATADIR_SET = 2;
- public static final int DISP_E_EXCEPTION = 0x80020009;
- public static final int DISP_E_MEMBERNOTFOUND = -2147352573;
- public static final int DISP_E_UNKNOWNINTERFACE = 0x80020001;
- //public static final int DISPID_AMBIENT_APPEARANCE = -716;
- //public static final int DISPID_AMBIENT_AUTOCLIP = -715;
- public static final int DISPID_AMBIENT_BACKCOLOR = -701;
- //public static final int DISPID_AMBIENT_CHARSET = -727;
- //public static final int DISPID_AMBIENT_CODEPAGE = -725;
- //public static final int DISPID_AMBIENT_DISPLAYASDEFAULT = -713;
- //public static final int DISPID_AMBIENT_DISPLAYNAME = -702;
- public static final int DISPID_AMBIENT_FONT = -703;
- public static final int DISPID_AMBIENT_FORECOLOR = -704;
- public static final int DISPID_AMBIENT_LOCALEID = -705;
- public static final int DISPID_AMBIENT_MESSAGEREFLECT = -706;
- public static final int DISPID_AMBIENT_OFFLINEIFNOTCONNECTED = -5501;
- //public static final int DISPID_AMBIENT_PALETTE = -726;
- //public static final int DISPID_AMBIENT_RIGHTTOLEFT = -732;
- //public static final int DISPID_AMBIENT_SCALEUNITS = -707;
- public static final int DISPID_AMBIENT_SHOWGRABHANDLES = -711;
- public static final int DISPID_AMBIENT_SHOWHATCHING = -712;
- public static final int DISPID_AMBIENT_SILENT = -5502;
- public static final int DISPID_AMBIENT_SUPPORTSMNEMONICS = -714;
- //public static final int DISPID_AMBIENT_TEXTALIGN = -708;
- //public static final int DISPID_AMBIENT_TOPTOBOTTOM = -733;
- //public static final int DISPID_AMBIENT_TRANSFERPRIORITY = -728;
- public static final int DISPID_AMBIENT_UIDEAD = -710;
- public static final int DISPID_AMBIENT_USERMODE = -709;
- public static final int DISPID_BACKCOLOR = -501;
- public static final int DISPID_FONT = -512;
- public static final int DISPID_FONT_BOLD = 3;
- public static final int DISPID_FONT_CHARSET = 8;
- public static final int DISPID_FONT_ITALIC = 4;
- public static final int DISPID_FONT_NAME = 0;
- public static final int DISPID_FONT_SIZE = 2;
- public static final int DISPID_FONT_STRIKE = 6;
- public static final int DISPID_FONT_UNDER = 5;
- public static final int DISPID_FONT_WEIGHT = 7;
- public static final int DISPID_FORECOLOR = -513;
- //public static final int DISPID_READYSTATE = -525;
- //public static final int DISPID_READYSTATECHANGE = -609;
- public static final int DRAGDROP_S_DROP = 0x00040100;
- public static final int DRAGDROP_S_CANCEL = 0x00040101;
- public static final int DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102;
- public static final int DROPEFFECT_NONE = 0;
- public static final int DROPEFFECT_COPY = 1;
- public static final int DROPEFFECT_MOVE = 2;
- public static final int DROPEFFECT_LINK = 4;
- public static final int DROPEFFECT_SCROLL = 0x80000000;
- public static final int DV_E_FORMATETC = -2147221404;
- public static final int DV_E_STGMEDIUM = -2147221402;
- public static final int DV_E_TYMED = -2147221399;
- public static final int DVASPECT_CONTENT = 1;
- //public static final int DVASPECT_DOCPRINT = 8;
- //public static final int DVASPECT_ICON = 4;
- //public static final int DVASPECT_THUMBNAIL = 2;
- public static final int E_FAIL = -2147467259;
- public static final int E_INVALIDARG = -2147024809;
- public static final int E_NOINTERFACE = -2147467262;
- public static final int E_NOTIMPL = -2147467263;
- public static final int E_NOTSUPPORTED = 0x80040100;
- //public static final int E_NOTLICENSED = -2147221230;
- //public static final int E_OUTOFMEMORY = -2147024882;
- //public static final int E_POINTER = -2147467261;
- public static final int GMEM_FIXED = 0;
- //public static final int GMEM_MOVABLE = 2;
- //public static final int GMEM_NODISCARD = 32;
- public static final int GMEM_ZEROINIT = 64;
- public static final int GUIDKIND_DEFAULT_SOURCE_DISP_IID = 1;
- public static final int IMPLTYPEFLAG_FDEFAULT = 1;
- //public static final int IMPLTYPEFLAG_FDEFAULTVTABLE = 2048;
- public static final int IMPLTYPEFLAG_FRESTRICTED = 4;
- public static final int IMPLTYPEFLAG_FSOURCE = 2;
- public static final int LOCALE_SYSTEM_DEFAULT = 1024;
- public static final int LOCALE_USER_DEFAULT = 2048;
- //public static final int MEMCTX_TASK = 1;
- //public static final int OLEACTIVATEAUTO = 3;
- //public static final int OLEACTIVATEDOUBLECLICK = 2;
- //public static final int OLEACTIVATEGETFOCUS = 1;
- //public static final int OLEACTIVATEMANUAL = 0;
- //public static final int OLEAUTOMATIC = 0;
- //public static final int OLECHANGED = 0;
- public static final int OLECLOSE_NOSAVE = 1;
- //public static final int OLECLOSE_PROMPTSAVE = 2;
- public static final int OLECLOSE_SAVEIFDIRTY = 0;
- //public static final int OLECLOSED = 2;
- //public static final int OLECONTF_EMBEDDINGS = 1;
- //public static final int OLECONTF_LINKS = 2;
- //public static final int OLECONTF_ONLYIFRUNNING = 16;
- //public static final int OLECONTF_ONLYUSER = 8;
- //public static final int OLECONTF_OTHERS = 4;
- //public static final int OLEDEACTIVATEMANUAL = 1;
- //public static final int OLEDEACTIVATEONLOSEFOCUS = 0;
- //public static final int OLEDECBORDER = 1;
- //public static final int OLEDECBORDERANDNIBS = 3;
- //public static final int OLEDECNIBS = 2;
- //public static final int OLEDECNONE = 0;
- //public static final int OLEDISPLAYCONTENT = 0;
- //public static final int OLEDISPLAYICON = 1;
- //public static final int OLEEITHER = 2;
- public static final int OLEEMBEDDED = 1;
- //public static final int OLEFROZEN = 1;
- public static final int OLEIVERB_DISCARDUNDOSTATE = -6;
- //public static final int OLEIVERB_HIDE = -3;
- public static final int OLEIVERB_INPLACEACTIVATE = -5;
- //public static final int OLEIVERB_OPEN = -2;
- public static final int OLEIVERB_PRIMARY = 0;
- //public static final int OLEIVERB_PROPERTIES = -7;
- //public static final int OLEIVERB_SHOW = -1;
- //public static final int OLEIVERB_UIACTIVATE = -4;
- public static final int OLELINKED = 0;
- //public static final int OLEMANUAL = 2;
- //public static final int OLEMISC_ACTIVATEWHENVISIBLE = 256;
- //public static final int OLEMISC_ACTSLIKEBUTTON = 4096;
- //public static final int OLEMISC_ACTSLIKELABEL = 8192;
- //public static final int OLEMISC_ALIGNABLE = 32768;
- //public static final int OLEMISC_ALWAYSRUN = 2048;
- //public static final int OLEMISC_CANLINKBYOLE1 = 32;
- //public static final int OLEMISC_CANTLINKINSIDE = 16;
- //public static final int OLEMISC_IGNOREACTIVATEWHENVISIBLE = 524288;
- //public static final int OLEMISC_IMEMODE = 262144;
- //public static final int OLEMISC_INSERTNOTREPLACE = 4;
- //public static final int OLEMISC_INSIDEOUT = 128;
- //public static final int OLEMISC_INVISIBLEATRUNTIME = 1024;
- //public static final int OLEMISC_ISLINKOBJECT = 64;
- //public static final int OLEMISC_NOUIACTIVATE = 16384;
- //public static final int OLEMISC_ONLYICONIC = 2;
- //public static final int OLEMISC_RECOMPOSEONRESIZE = 1;
- //public static final int OLEMISC_RENDERINGISDEVICEINDEPENDENT = 512;
- //public static final int OLEMISC_SETCLIENTSITEFIRST = 131072;
- //public static final int OLEMISC_SIMPLEFRAME = 65536;
- //public static final int OLEMISC_STATIC = 8;
- //public static final int OLEMISC_SUPPORTSMULTILEVELUNDO = 2097152;
- //public static final int OLEMISC_WANTSTOMENUMERGE = 1048576;
- //public static final int OLENONE = 3;
- //public static final int OLERENAMED = 3;
- //public static final int OLERENDER_ASIS = 3;
- public static final int OLERENDER_DRAW = 1;
- //public static final int OLERENDER_FORMAT = 2;
- //public static final int OLERENDER_NONE = 0;
- //public static final int OLESAVED = 1;
- //public static final int OLESIZEAUTOSIZE = 2;
- //public static final int OLESIZECLIP = 0;
- //public static final int OLESIZESTRETCH = 1;
- //public static final int OLESIZEZOOM = 3;
- //public static final int OLEWHICHMK_CONTAINER = 1;
- //public static final int OLEWHICHMK_OBJFULL = 3;
- //public static final int OLEWHICHMK_OBJREL = 2;
- public static final int S_FALSE = 1;
- public static final int S_OK = 0;
- public static final int STG_E_FILENOTFOUND = 0x80030002;
- public static final int STG_S_CONVERTED = 0x00030200;
- //public static final int STGC_CONSOLIDATE = 8;
- //public static final int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4;
- public static final int STGC_DEFAULT = 0;
- //public static final int STGC_ONLYIFCURRENT = 2;
- //public static final int STGC_OVERWRITE = 1;
- public static final int STGM_CONVERT = 0x00020000;
- public static final int STGM_CREATE = 0x00001000;
- public static final int STGM_DELETEONRELEASE = 0x04000000;
- public static final int STGM_DIRECT = 0x00000000;
- public static final int STGM_DIRECT_SWMR = 0x00400000;
- public static final int STGM_FAILIFTHERE = 0x00000000;
- public static final int STGM_NOSCRATCH = 0x00100000;
- public static final int STGM_NOSNAPSHOT = 0x00200000;
- public static final int STGM_PRIORITY = 0x00040000;
- public static final int STGM_READ = 0x00000000;
- public static final int STGM_READWRITE = 0x00000002;
- public static final int STGM_SHARE_DENY_NONE = 0x00000040;
- public static final int STGM_SHARE_DENY_READ = 0x00000030;
- public static final int STGM_SHARE_DENY_WRITE = 0x00000020;
- public static final int STGM_SHARE_EXCLUSIVE = 0x00000010;
- public static final int STGM_SIMPLE = 0x08000000;
- public static final int STGM_TRANSACTED = 0x00010000;
- public static final int STGM_WRITE = 0x00000001;
- public static final int STGTY_STORAGE = 1;
- public static final int STGTY_STREAM = 2;
- public static final int STGTY_LOCKBYTES = 3;
- public static final int STGTY_PROPERTY = 4;
- //public static final int TYMED_ENHMF = 64;
- //public static final int TYMED_FILE = 2;
- //public static final int TYMED_GDI = 16;
- public static final int TYMED_HGLOBAL = 1;
- //public static final int TYMED_ISTORAGE = 8;
- //public static final int TYMED_ISTREAM = 4;
- //public static final int TYMED_MFPICT = 32;
- //public static final int TYMED_NULL = 0;
- public static final short DISPATCH_METHOD = 0x1;
- public static final short DISPATCH_PROPERTYGET = 0x2;
- public static final short DISPATCH_PROPERTYPUT = 0x4;
- public static final short DISPATCH_PROPERTYPUTREF = 0x8;
- //public static final short DISPID_CONSTRUCTOR = -6;
- //public static final short DISPID_DESTRUCTOR = -7;
- //public static final short DISPID_EVALUATE = -5;
- //public static final short DISPID_NEWENUM = -4;
- public static final short DISPID_PROPERTYPUT = -3;
- //public static final short DISPID_UNKNOWN = -1;
- //public static final short DISPID_VALUE = 0;
- public static final short VT_BOOL = 11;
- public static final short VT_BSTR = 8;
- public static final short VT_BYREF = 16384;
- public static final short VT_CY = 6;
- public static final short VT_DATE = 7;
- public static final short VT_DISPATCH = 9;
- public static final short VT_EMPTY = 0;
- public static final short VT_ERROR = 10;
- public static final short VT_I1 = 16;
- public static final short VT_I2 = 2;
- public static final short VT_I4 = 3;
- public static final short VT_I8 = 20;
- public static final short VT_NULL = 1;
- public static final short VT_R4 = 4;
- public static final short VT_R8 = 5;
- public static final short VT_UI1 = 17;
- public static final short VT_UI2 = 18;
- public static final short VT_UI4 = 19;
- public static final short VT_UNKNOWN = 13;
- public static final short VT_VARIANT = 12;
- /*
- * GOOGLE: IE7 returns a variant of type 130 from the name field
- * of a JavaScript exception, and we can't find documentation of it
- * anywhere. It appears to contain a pointer to a string constant
- * that behaves like a VT_BSTR, so we are treating it the same way.
- * Note that this is a gross hack using a totally undocumented
- * feature, and Microsoft may break these assumptions at any time.
- */
- public static final short VT_WEIRD_IE7_BSTR = 130;
- public static final short VARIANT_TRUE = -1;
- public static final short VARIANT_FALSE = 0;
-
-private static GUID IIDFromString(String lpsz) {
- int length = lpsz.length();
- char[] buffer = new char[length + 1];
- lpsz.getChars(0, length, buffer, 0);
- GUID lpiid = new GUID();
- if (COM.IIDFromString(buffer, lpiid) == COM.S_OK) return lpiid;
- return null;
-}
-
-/** Natives */
-public static final native int CLSIDFromProgID(char[] lpszProgID, GUID pclsid);
-public static final native int CLSIDFromString(char[] lpsz, GUID pclsid);
-public static final native int CoCreateInstance(GUID rclsid, int pUnkOuter, int dwClsContext, GUID riid, int[] ppv);
-public static final native void CoFreeUnusedLibraries();
-public static final native int CoGetClassObject(GUID rclsid, int dwClsContext, int pServerInfo, GUID riid, int[] ppv);
-public static final native int CoLockObjectExternal(int pUnk, boolean fLock, boolean fLastUnlockReleases);
-public static final native int CoTaskMemAlloc(int cb);
-public static final native void CoTaskMemFree(int pv);
-public static final native int DoDragDrop(int pDataObject, int pDropSource, int dwOKEffect, int[] pdwEffect);
-public static final native int GetClassFile(char[] szFileName, GUID clsid);
-public static final native int IIDFromString(char[] lpsz, GUID lpiid);
-public static final native boolean IsEqualGUID(GUID rguid1, GUID rguid2);
-public static final native void MoveMemory(int Destination, FORMATETC Source, int Length);
-public static final native void MoveMemory(int DestinationPtr, GUID Source, int Length);
-public static final native void MoveMemory(int DestinationPtr, OLEINPLACEFRAMEINFO Source, int Length);
-public static final native void MoveMemory(int Destination, STATSTG Source, int Length);
-public static final native void MoveMemory(int Destination, STGMEDIUM Source, int Length);
-public static final native void MoveMemory(STGMEDIUM Destination, int SourcePtr, int Length);
-public static final native void MoveMemory(DISPPARAMS Destination, int SourcePtr, int Length);
-public static final native void MoveMemory(FORMATETC Destination, int Source, int Length);
-public static final native void MoveMemory(GUID Destination, int SourcePtr, int Length);
-public static final native void MoveMemory(STATSTG Destination, int Source, int Length);
-public static final native void MoveMemory(TYPEATTR Destination, int SourcePtr, int Length);
-public static final native void MoveMemory(RECT Destination, int Source, int Length);
-public static final native void MoveMemory(FUNCDESC Destination, int Source, int Length);
-public static final native void MoveMemory(VARDESC Destination, int Source, int Length);
-public static final native int OleCreate(GUID rclsid, GUID riid, int renderopt, FORMATETC pFormatEtc, int pClientSite, int pStg, int[] ppvObject);
-public static final native int OleCreateFromFile(GUID rclsid, char[] lpszFileName, GUID riid, int renderopt, FORMATETC pFormatEtc, int pClientSite, int pStg, int[] ppvObj);
-public static final native int OleCreatePropertyFrame(int hwndOwner,int x, int y, char[] lpszCaption, int cObjects, int[] lplpUnk, int cPages, int lpPageClsID, int lcid, int dwReserved, int lpvReserved);
-public static final native int OleDraw(int pUnk, int dwAspect, int hdcDraw, int lprcBounds);
-public static final native int OleFlushClipboard();
-public static final native int OleGetClipboard(int[] ppDataObject);
-public static final native int OleIsCurrentClipboard(int pDataObject);
-public static final native boolean OleIsRunning(int pObject);
-public static final native int OleLoad(int pStg, GUID riid, int pClientSite, int[] ppvObj);
-public static final native int OleRun(int pUnknown);
-public static final native int OleSave(int pPS, int pStg,boolean fSameAsLoad);
-public static final native int OleSetClipboard(int pDataObject);
-public static final native int OleSetContainedObject(int pUnk, boolean fContained);
-public static final native int OleSetMenuDescriptor(int holemenu, int hwndFrame, int hwndActiveObject, int lpFrame, int lpActiveObj);
-public static final native int OleTranslateColor(int clr, int hpal, int[] pcolorref);
-public static final native int ProgIDFromCLSID(GUID clsid, int[] lplpszProgID);
-public static final native int RegisterDragDrop(int hwnd, int pDropTarget);
-public static final native void ReleaseStgMedium(int pmedium);
-public static final native int RevokeDragDrop(int hwnd);
-public static final native int StgCreateDocfile(char[] pwcsName, int grfMode, int reserved, int[] ppstgOpen);
-public static final native int StgIsStorageFile(char[] pwcsName);
-public static final native int StgOpenStorage(char[] pwcsName, int pstgPriority, int grfMode, int snbExclude, int reserved, int[] ppstgOpen);
-public static final native int StringFromCLSID(GUID rclsid, int[] ppsz);
-public static final native int SysAllocString(char [] sz);
-public static final native int SysAllocStringLen(char [] sz, int len); // GOOGLE
-public static final native void SysFreeString(int bstr);
-public static final native int SysStringByteLen(int bstr);
-public static final native int VariantChangeType(int pvargDest, int pvarSrc, short wFlags, short vt);
-public static final native int VariantClear(int pvarg);
-public static final native void VariantInit(int pvarg);
-public static final native int VtblCall(int fnNumber, int ppVtbl, char[] arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, char[] arg0, char[] arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, char[] arg0, int arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, char[] arg0, int arg1, int arg2, int arg3, int[] arg4);
-public static final native int VtblCall(int fnNumber, int ppVtbl, char[] arg0, int arg1, int arg2, int arg3, int arg4, int[] arg5);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int[] arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int[] arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int[] arg2);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, DVTARGETDEVICE arg2, SIZE arg3);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, GUID arg2, int arg3, int[] arg4);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, FORMATETC arg1, int[] arg2);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, GUID arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, GUID arg1, int arg2, int arg3);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, GUID arg1, int arg2, int arg3, DISPPARAMS arg4, int arg5, EXCEPINFO arg6, int[] arg7);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, STATSTG arg1, int[] arg2);
-public static final native int VtblCall(int fnNumber, int ppVtbl, MSG arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, MSG arg1, int arg2, int arg3, int arg4, RECT arg5);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, SIZE arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, boolean arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, CAUUID arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, CONTROLINFO arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, FORMATETC arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, FORMATETC arg0, STGMEDIUM arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, FORMATETC arg0, STGMEDIUM arg1, boolean arg2);
-public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int[] arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int arg1, int arg2, int arg3, int[] arg4);
-public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int arg1, int arg2, int arg3, int arg4);
-public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int arg1, OLECMD arg2, OLECMDTEXT arg3);
-public static final native int VtblCall(int fnNumber, int ppVtbl, LICINFO arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, RECT arg0, int arg1, boolean arg2);
-public static final native int VtblCall(int fnNumber, int ppVtbl, RECT arg0, RECT arg1);
-public static final native int VtblCall(int fnNumber, int ppVtbl, RECT arg0);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int[] arg1, int[] arg2, int[] arg3, int[] arg4);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int[] arg1, int arg2, int[] arg3);
-public static final native int WriteClassStg(int pStg, GUID rclsid);
-
-/** Accessibility constants */
-public static final int CHILDID_SELF = 0;
-public static final int CO_E_OBJNOTCONNECTED = 0x800401FD;
-//public static final int ROLE_SYSTEM_TITLEBAR = 0x1;
-public static final int ROLE_SYSTEM_MENUBAR = 0x2;
-public static final int ROLE_SYSTEM_SCROLLBAR = 0x3;
-//public static final int ROLE_SYSTEM_GRIP = 0x4;
-//public static final int ROLE_SYSTEM_SOUND = 0x5;
-//public static final int ROLE_SYSTEM_CURSOR = 0x6;
-//public static final int ROLE_SYSTEM_CARET = 0x7;
-//public static final int ROLE_SYSTEM_ALERT = 0x8;
-public static final int ROLE_SYSTEM_WINDOW = 0x9;
-public static final int ROLE_SYSTEM_CLIENT = 0xa;
-public static final int ROLE_SYSTEM_MENUPOPUP = 0xb;
-public static final int ROLE_SYSTEM_MENUITEM = 0xc;
-public static final int ROLE_SYSTEM_TOOLTIP = 0xd;
-//public static final int ROLE_SYSTEM_APPLICATION = 0xe;
-//public static final int ROLE_SYSTEM_DOCUMENT = 0xf;
-//public static final int ROLE_SYSTEM_PANE = 0x10;
-//public static final int ROLE_SYSTEM_CHART = 0x11;
-public static final int ROLE_SYSTEM_DIALOG = 0x12;
-//public static final int ROLE_SYSTEM_BORDER = 0x13;
-//public static final int ROLE_SYSTEM_GROUPING = 0x14;
-public static final int ROLE_SYSTEM_SEPARATOR = 0x15;
-public static final int ROLE_SYSTEM_TOOLBAR = 0x16;
-//public static final int ROLE_SYSTEM_STATUSBAR = 0x17;
-public static final int ROLE_SYSTEM_TABLE = 0x18;
-public static final int ROLE_SYSTEM_COLUMNHEADER = 0x19;
-public static final int ROLE_SYSTEM_ROWHEADER = 0x1a;
-//public static final int ROLE_SYSTEM_COLUMN = 0x1b;
-//public static final int ROLE_SYSTEM_ROW = 0x1c;
-public static final int ROLE_SYSTEM_CELL = 0x1d;
-public static final int ROLE_SYSTEM_LINK = 0x1e;
-//public static final int ROLE_SYSTEM_HELPBALLOON = 0x1f;
-//public static final int ROLE_SYSTEM_CHARACTER = 0x20;
-public static final int ROLE_SYSTEM_LIST = 0x21;
-public static final int ROLE_SYSTEM_LISTITEM = 0x22;
-public static final int ROLE_SYSTEM_OUTLINE = 0x23;
-public static final int ROLE_SYSTEM_OUTLINEITEM = 0x24;
-public static final int ROLE_SYSTEM_PAGETAB = 0x25;
-//public static final int ROLE_SYSTEM_PROPERTYPAGE = 0x26;
-//public static final int ROLE_SYSTEM_INDICATOR = 0x27;
-//public static final int ROLE_SYSTEM_GRAPHIC = 0x28;
-public static final int ROLE_SYSTEM_STATICTEXT = 0x29;
-public static final int ROLE_SYSTEM_TEXT = 0x2a;
-public static final int ROLE_SYSTEM_PUSHBUTTON = 0x2b;
-public static final int ROLE_SYSTEM_CHECKBUTTON = 0x2c;
-public static final int ROLE_SYSTEM_RADIOBUTTON = 0x2d;
-public static final int ROLE_SYSTEM_COMBOBOX = 0x2e;
-//public static final int ROLE_SYSTEM_DROPLIST = 0x2f;
-public static final int ROLE_SYSTEM_PROGRESSBAR = 0x30;
-//public static final int ROLE_SYSTEM_DIAL = 0x31;
-//public static final int ROLE_SYSTEM_HOTKEYFIELD = 0x32;
-public static final int ROLE_SYSTEM_SLIDER = 0x33;
-//public static final int ROLE_SYSTEM_SPINBUTTON = 0x34;
-//public static final int ROLE_SYSTEM_DIAGRAM = 0x35;
-//public static final int ROLE_SYSTEM_ANIMATION = 0x36;
-//public static final int ROLE_SYSTEM_EQUATION = 0x37;
-//public static final int ROLE_SYSTEM_BUTTONDROPDOWN = 0x38;
-//public static final int ROLE_SYSTEM_BUTTONMENU = 0x39;
-//public static final int ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a;
-//public static final int ROLE_SYSTEM_WHITESPACE = 0x3b;
-public static final int ROLE_SYSTEM_PAGETABLIST = 0x3c;
-//public static final int ROLE_SYSTEM_CLOCK = 0x3d;
-public static final int STATE_SYSTEM_NORMAL = 0;
-//public static final int STATE_SYSTEM_UNAVAILABLE = 0x1;
-public static final int STATE_SYSTEM_SELECTED = 0x2;
-public static final int STATE_SYSTEM_FOCUSED = 0x4;
-public static final int STATE_SYSTEM_PRESSED = 0x8;
-public static final int STATE_SYSTEM_CHECKED = 0x10;
-//public static final int STATE_SYSTEM_MIXED = 0x20;
-//public static final int STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED;
-public static final int STATE_SYSTEM_READONLY = 0x40;
-public static final int STATE_SYSTEM_HOTTRACKED = 0x80;
-//public static final int STATE_SYSTEM_DEFAULT = 0x100;
-public static final int STATE_SYSTEM_EXPANDED = 0x200;
-public static final int STATE_SYSTEM_COLLAPSED = 0x400;
-public static final int STATE_SYSTEM_BUSY = 0x800;
-//public static final int STATE_SYSTEM_FLOATING = 0x1000;
-//public static final int STATE_SYSTEM_MARQUEED = 0x2000;
-//public static final int STATE_SYSTEM_ANIMATED = 0x4000;
-public static final int STATE_SYSTEM_INVISIBLE = 0x8000;
-public static final int STATE_SYSTEM_OFFSCREEN = 0x10000;
-public static final int STATE_SYSTEM_SIZEABLE = 0x20000;
-//public static final int STATE_SYSTEM_MOVEABLE = 0x40000;
-//public static final int STATE_SYSTEM_SELFVOICING = 0x80000;
-public static final int STATE_SYSTEM_FOCUSABLE = 0x100000;
-public static final int STATE_SYSTEM_SELECTABLE = 0x200000;
-public static final int STATE_SYSTEM_LINKED = 0x400000;
-//public static final int STATE_SYSTEM_TRAVERSED = 0x800000;
-public static final int STATE_SYSTEM_MULTISELECTABLE = 0x1000000;
-//public static final int STATE_SYSTEM_EXTSELECTABLE = 0x2000000;
-//public static final int STATE_SYSTEM_ALERT_LOW = 0x4000000;
-//public static final int STATE_SYSTEM_ALERT_MEDIUM = 0x8000000;
-//public static final int STATE_SYSTEM_ALERT_HIGH = 0x10000000;
-//public static final int STATE_SYSTEM_PROTECTED = 0x20000000;
-//public static final int STATE_SYSTEM_VALID = 0x3fffffff;
-
-/** Accessibility natives */
-public static final native int CreateStdAccessibleObject (int hwnd, int idObject, GUID riidInterface, int[] ppvObject);
-public static final native int LresultFromObject (GUID riid, int wParam, int pAcc);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);
-
-}
diff --git a/dev/windows/src/org/eclipse/swt/internal/ole/win32/IObjectWithSite.java b/dev/windows/src/org/eclipse/swt/internal/ole/win32/IObjectWithSite.java
deleted file mode 100644
index 90beaec..0000000
--- a/dev/windows/src/org/eclipse/swt/internal/ole/win32/IObjectWithSite.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.eclipse.swt.internal.ole.win32;
-
-/**
- * Provide the interface IObjectWithSite, a lighter-weight siting mechanism
- * than IOleObject.
- *
- * This interface is used by IE Browser Helper Objects, such as Google Gears.
- * See http://msdn2.microsoft.com/en-us/library/aa768220.aspx
- */
-public class IObjectWithSite extends IUnknown {
- public IObjectWithSite(int address) {
- super(address);
- }
-
- /**
- * Return the last site set with SetSite.
- *
- * @param riid IID of the interface to be returned
- * @param ppvObject return value of the IObjectWithSite interface
- * @return COM.S_OK on success, COM.E_FAIL if no site has been set, or
- * COM.E_NOINTERFACE if the requested interface is not supported
- */
- public int GetSite(GUID riid, int ppvObject[]) {
- return COM.VtblCall(4, address, riid, ppvObject);
- }
-
- /**
- * Sets the IUnknown interface of the site managing this object.
- *
- * @param site an IUnknown interface to the browser object
- * @return COM.S_OK always
- */
- public int SetSite(IUnknown site) {
- return COM.VtblCall(3, address, site.getAddress());
- }
-}
diff --git a/dev/windows/src/org/eclipse/swt/ole/win32/OleAutomation.java b/dev/windows/src/org/eclipse/swt/ole/win32/OleAutomation.java
deleted file mode 100644
index cc76d5d..0000000
--- a/dev/windows/src/org/eclipse/swt/ole/win32/OleAutomation.java
+++ /dev/null
@@ -1,669 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.ole.win32;
-
-
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-
-/**
- * OleAutomation provides a generic mechanism for accessing functionality that is
- * specific to a particular ActiveX Control or OLE Document.
- *
- * <p>The OLE Document or ActiveX Control must support the IDispatch interface in order to provide
- * OleAutomation support. The additional functionality provided by the OLE Object is specified in
- * its IDL file. The additional methods can either be to get property values (<code>getProperty</code>),
- * to set property values (<code>setProperty</code>) or to invoke a method (<code>invoke</code> or
- * <code>invokeNoReply</code>). Arguments are passed around in the form of <code>Variant</code>
- * objects.
- *
- * <p>Here is a sample IDL fragment:
- *
- * <pre>
- * interface IMyControl : IDispatch
- * {
- * [propget, id(0)] HRESULT maxFileCount([retval, out] int *c);
- * [propput, id(0)] HRESULT maxFileCount([in] int c);
- * [id(1)] HRESULT AddFile([in] BSTR fileName);
- * };
- * </pre>
- *
- * <p>An example of how to interact with this extended functionality is shown below:
- *
- * <code><pre>
- * OleAutomation automation = new OleAutomation(myControlSite);
- *
- * // Look up the ID of the maxFileCount parameter
- * int[] rgdispid = automation.getIDsOfNames(new String[]{"maxFileCount"});
- * int maxFileCountID = rgdispid[0];
- *
- * // Set the property maxFileCount to 100:
- * if (automation.setProperty(maxFileCountID, new Variant(100))) {
- * System.out.println("Max File Count was successfully set.");
- * }
- *
- * // Get the new value of the maxFileCount parameter:
- * Variant pVarResult = automation.getProperty(maxFileCountID);
- * if (pVarResult != null) {
- * System.out.println("Max File Count is "+pVarResult.getInt());
- * }
- *
- * // Invoke the AddFile method
- * // Look up the IDs of the AddFile method and its parameter
- * rgdispid = automation.getIDsOfNames(new String[]{"AddFile", "fileName"});
- * int dispIdMember = rgdispid[0];
- * int[] rgdispidNamedArgs = new int[] {rgdispid[1]};
- *
- * // Convert arguments to Variant objects
- * Variant[] rgvarg = new Variant[1];
- * String fileName = "C:\\testfile";
- * rgvarg[0] = new Variant(fileName);
- *
- * // Call the method
- * Variant pVarResult = automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
- *
- * // Check the return value
- * if (pVarResult == null || pVarResult.getInt() != OLE.S_OK){
- * System.out.println("Failed to add file "+fileName);
- * }
- *
- * automation.dispose();
- *
- * </pre></code>
- */
-public final class OleAutomation {
- private IDispatch objIDispatch;
- private String exceptionDescription;
- private ITypeInfo objITypeInfo;
-
-public // GOOGLE: make this public so we can instantiate our own
-OleAutomation(IDispatch idispatch) {
- if (idispatch == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
- objIDispatch = idispatch;
- objIDispatch.AddRef();
-
- int[] ppv = new int[1];
- int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv);
- if (result == OLE.S_OK) {
- objITypeInfo = new ITypeInfo(ppv[0]);
- /*
- * GOOGLE: According to MSDN, typeInfo is an [out,retval] param, which
- * means the callee will have already called AddRef on the returned
- * pointer. An additional AddRef here would cause a leak.
- */
- //objITypeInfo.AddRef();
- }
-}
-/**
- * Creates an OleAutomation object for the specified client.
- *
- * @param clientSite the site for the OLE Document or ActiveX Control whose additional functionality
- * you need to access
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_INTERFACE_ADDRESS when called with an invalid client site
- * </ul>
- */
- public OleAutomation(OleClientSite clientSite) {
- if (clientSite == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
- objIDispatch = clientSite.getAutomationObject();
-
- int[] ppv = new int[1];
- int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv);
- if (result == OLE.S_OK) {
- objITypeInfo = new ITypeInfo(ppv[0]);
- /*
- * GOOGLE: According to MSDN, typeInfo is an [out,retval] param, which
- * means the callee will have already called AddRef on the returned
- * pointer. An additional AddRef would cause a leak.
- */
- //objITypeInfo.AddRef();
- }
- }
-/**
- * Disposes the automation object.
- * <p>
- * This method releases the IDispatch interface on the OLE Document or ActiveX Control.
- * Do not use the OleAutomation object after it has been disposed.
- */
-public void dispose() {
-
- if (objIDispatch != null){
- objIDispatch.Release();
- }
- objIDispatch = null;
-
- if (objITypeInfo != null){
- objITypeInfo.Release();
- }
- objITypeInfo = null;
-
-}
-int getAddress() {
- return objIDispatch.getAddress();
-}
-public String getHelpFile(int dispId) {
- if (objITypeInfo == null) return null;
- String[] file = new String[1];
- int rc = objITypeInfo.GetDocumentation(dispId, null, null, null, file );
- if (rc == OLE.S_OK) return file[0];
- return null;
-}
-public String getDocumentation(int dispId) {
- if (objITypeInfo == null) return null;
- String[] doc = new String[1];
- int rc = objITypeInfo.GetDocumentation(dispId, null, doc, null, null );
- if (rc == OLE.S_OK) return doc[0];
- return null;
-}
-public OlePropertyDescription getPropertyDescription(int index) {
- if (objITypeInfo == null) return null;
- int[] ppVarDesc = new int[1];
- int rc = objITypeInfo.GetVarDesc(index, ppVarDesc);
- if (rc != OLE.S_OK) return null;
- VARDESC vardesc = new VARDESC();
- COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC.sizeof);
-
- OlePropertyDescription data = new OlePropertyDescription();
- data.id = vardesc.memid;
- data.name = getName(vardesc.memid);
- data.type = vardesc.elemdescVar_tdesc_vt;
- if (data.type == OLE.VT_PTR) {
- short[] vt = new short[1];
- COM.MoveMemory(vt, vardesc.elemdescVar_tdesc_union + 4, 2);
- data.type = vt[0];
- }
- data.flags = vardesc.wVarFlags;
- data.kind = vardesc.varkind;
- data.description = getDocumentation(vardesc.memid);
- data.helpFile = getHelpFile(vardesc.memid);
-
- objITypeInfo.ReleaseVarDesc(ppVarDesc[0]);
- return data;
-}
-public OleFunctionDescription getFunctionDescription(int index) {
- if (objITypeInfo == null) return null;
- int[] ppFuncDesc = new int[1];
- int rc = objITypeInfo.GetFuncDesc(index, ppFuncDesc);
- if (rc != OLE.S_OK) return null;
- FUNCDESC funcdesc = new FUNCDESC();
- COM.MoveMemory(funcdesc, ppFuncDesc[0], FUNCDESC.sizeof);
-
- OleFunctionDescription data = new OleFunctionDescription();
-
- data.id = funcdesc.memid;
- data.optionalArgCount = funcdesc.cParamsOpt;
- data.invokeKind = funcdesc.invkind;
- data.funcKind = funcdesc.funckind;
- data.flags = funcdesc.wFuncFlags;
- data.callingConvention = funcdesc.callconv;
- data.documentation = getDocumentation(funcdesc.memid);
- data.helpFile = getHelpFile(funcdesc.memid);
-
- String[] names = getNames(funcdesc.memid, funcdesc.cParams + 1);
- if (names.length > 0) {
- data.name = names[0];
- }
- data.args = new OleParameterDescription[funcdesc.cParams];
- for (int i = 0; i < data.args.length; i++) {
- data.args[i] = new OleParameterDescription();
- if (names.length > i + 1) {
- data.args[i].name = names[i + 1];
- }
- short[] vt = new short[1];
- COM.MoveMemory(vt, funcdesc.lprgelemdescParam + i * 16 + 4, 2);
- if (vt[0] == OLE.VT_PTR) {
- int[] pTypedesc = new int[1];
- COM.MoveMemory(pTypedesc, funcdesc.lprgelemdescParam + i * 16, 4);
- short[] vt2 = new short[1];
- COM.MoveMemory(vt2, pTypedesc[0] + 4, 2);
- vt[0] = (short)(vt2[0] | COM.VT_BYREF);
- }
- data.args[i].type = vt[0];
- short[] wParamFlags = new short[1];
- COM.MoveMemory(wParamFlags, funcdesc.lprgelemdescParam + i * 16 + 12, 2);
- data.args[i].flags = wParamFlags[0];
- }
-
- data.returnType = funcdesc.elemdescFunc_tdesc_vt;
- if (data.returnType == OLE.VT_PTR) {
- short[] vt = new short[1];
- COM.MoveMemory(vt, funcdesc.elemdescFunc_tdesc_union + 4, 2);
- data.returnType = vt[0];
- }
-
- objITypeInfo.ReleaseFuncDesc(ppFuncDesc[0]);
- return data;
-}
-public TYPEATTR getTypeInfoAttributes() {
- if (objITypeInfo == null) return null;
- int[] ppTypeAttr = new int[1];
- int rc = objITypeInfo.GetTypeAttr(ppTypeAttr);
- if (rc != OLE.S_OK) return null;
- TYPEATTR typeattr = new TYPEATTR();
- COM.MoveMemory(typeattr, ppTypeAttr[0], TYPEATTR.sizeof);
- objITypeInfo.ReleaseTypeAttr(ppTypeAttr[0]);
- return typeattr;
-}
-public String getName(int dispId) {
- if (objITypeInfo == null) return null;
- String[] name = new String[1];
- int rc = objITypeInfo.GetDocumentation(dispId, name, null, null, null );
- if (rc == OLE.S_OK) return name[0];
- return null;
-}
-public String[] getNames(int dispId, int maxSize) {
- if (objITypeInfo == null) return new String[0];
- String[] names = new String[maxSize];
- int[] count = new int[1];
- int rc = objITypeInfo.GetNames(dispId, names, maxSize, count);
- if (rc == OLE.S_OK) {
- String[] newNames = new String[count[0]];
- System.arraycopy(names, 0, newNames, 0, count[0]);
- return newNames;
- }
- return new String[0];
-}
-/**
- * Returns the positive integer values (IDs) that are associated with the specified names by the
- * IDispatch implementor. If you are trying to get the names of the parameters in a method, the first
- * String in the names array must be the name of the method followed by the names of the parameters.
- *
- * @param names an array of names for which you require the identifiers
- *
- * @return positive integer values that are associated with the specified names in the same
- * order as the names where provided; or null if the names are unknown
- */
-public int[] getIDsOfNames(String[] names) {
-
- int[] rgdispid = new int[names.length];
- int result = objIDispatch.GetIDsOfNames(new GUID(), names, names.length, COM.LOCALE_USER_DEFAULT, rgdispid);
- if (result != COM.S_OK) return null;
-
- return rgdispid;
-}
-/**
- * Returns a description of the last error encountered.
- *
- * @return a description of the last error encountered
- */
-public String getLastError() {
-
- return exceptionDescription;
-
-}
-/**
- * Returns the value of the property specified by the dispIdMember.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @return the value of the property specified by the dispIdMember or null
- */
-public Variant getProperty(int dispIdMember) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, null, null, pVarResult);
-
- // GOOGLE: better success test
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- if (result >= COM.S_OK)
- return pVarResult;
- else {
- pVarResult.dispose();
- return null;
- }
-}
-/**
- * Returns the value of the property specified by the dispIdMember.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @return the value of the property specified by the dispIdMember or null
- *
- * @since 2.0
- */
-public Variant getProperty(int dispIdMember, Variant[] rgvarg) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, null, pVarResult);
-
- // GOOGLE: better success test
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- if (result >= COM.S_OK)
- return pVarResult;
- else {
- pVarResult.dispose();
- return null;
- }
-}
-/**
- * Returns the value of the property specified by the dispIdMember.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
- * parameter IDs must be in the same order as their corresponding values;
- * all arguments must have an identifier - identifiers can be obtained using
- * OleAutomation.getIDsOfNames
- *
- * @return the value of the property specified by the dispIdMember or null
- *
- * @since 2.0
- */
-public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, rgdispidNamedArgs, pVarResult);
-
- // GOOGLE: better success test
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- if (result >= COM.S_OK)
- return pVarResult;
- else {
- pVarResult.dispose();
- return null;
- }
-}
-
-/**
- * Invokes a method on the OLE Object; the method has no parameters.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @return the result of the method or null if the method failed to give result information
- */
-public Variant invoke(int dispIdMember) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, pVarResult);
-
- // GOOGLE: better success test
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- if (result >= COM.S_OK)
- return pVarResult;
- else {
- pVarResult.dispose();
- return null;
- }
-}
-/**
- * Invokes a method on the OLE Object; the method has no optional parameters.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @return the result of the method or null if the method failed to give result information
- */
-public Variant invoke(int dispIdMember, Variant[] rgvarg) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, pVarResult);
-
- // GOOGLE: better success test
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- if (result >= COM.S_OK)
- return pVarResult;
- else {
- pVarResult.dispose();
- return null;
- }
-}
-/**
- * Invokes a method on the OLE Object; the method has optional parameters. It is not
- * necessary to specify all the optional parameters, only include the parameters for which
- * you are providing values.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
- * parameter IDs must be in the same order as their corresponding values;
- * all arguments must have an identifier - identifiers can be obtained using
- * OleAutomation.getIDsOfNames
- *
- * @return the result of the method or null if the method failed to give result information
- */
-public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, pVarResult);
-
- // GOOGLE: better success test
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- if (result >= COM.S_OK)
- return pVarResult;
- else {
- pVarResult.dispose();
- return null;
- }
-}
-private int invoke(int dispIdMember, int wFlags, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult) {
-
- // get the IDispatch interface for the control
- if (objIDispatch == null) return COM.E_FAIL;
-
- // create a DISPPARAMS structure for the input parameters
- DISPPARAMS pDispParams = new DISPPARAMS();
- // store arguments in rgvarg
- if (rgvarg != null && rgvarg.length > 0) {
- pDispParams.cArgs = rgvarg.length;
- pDispParams.rgvarg = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, Variant.sizeof * rgvarg.length);
- int offset = 0;
- for (int i = rgvarg.length - 1; i >= 0 ; i--) {
- rgvarg[i].getData(pDispParams.rgvarg + offset);
- offset += Variant.sizeof;
- }
- }
-
- // if arguments have ids, store the ids in rgdispidNamedArgs
- if (rgdispidNamedArgs != null && rgdispidNamedArgs.length > 0) {
- pDispParams.cNamedArgs = rgdispidNamedArgs.length;
- pDispParams.rgdispidNamedArgs = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * rgdispidNamedArgs.length);
- int offset = 0;
- for (int i = rgdispidNamedArgs.length; i > 0; i--) {
- COM.MoveMemory(pDispParams.rgdispidNamedArgs + offset, new int[] {rgdispidNamedArgs[i-1]}, 4);
- offset += 4;
- }
- }
-
- // invoke the method
- EXCEPINFO excepInfo = new EXCEPINFO();
- int[] pArgErr = new int[1];
- int pVarResultAddress = 0;
- if (pVarResult != null) pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
- int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, wFlags, pDispParams, pVarResultAddress, excepInfo, pArgErr);
-
- if (pVarResultAddress != 0){
- pVarResult.setData(pVarResultAddress);
- COM.VariantClear(pVarResultAddress);
- OS.GlobalFree(pVarResultAddress);
- }
-
- // free the Dispparams resources
- if (pDispParams.rgdispidNamedArgs != 0){
- OS.GlobalFree(pDispParams.rgdispidNamedArgs);
- }
- if (pDispParams.rgvarg != 0) {
- int offset = 0;
- for (int i = 0, length = rgvarg.length; i < length; i++){
- COM.VariantClear(pDispParams.rgvarg + offset);
- offset += Variant.sizeof;
- }
- OS.GlobalFree(pDispParams.rgvarg);
- }
-
- // save error string and cleanup EXCEPINFO
- manageExcepinfo(result, excepInfo);
-
- return result;
-}
-/**
- * Invokes a method on the OLE Object; the method has no parameters. In the early days of OLE,
- * the IDispatch interface was not well defined and some applications (mainly Word) did not support
- * a return value. For these applications, call this method instead of calling
- * <code>public void invoke(int dispIdMember)</code>.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @exception SWTException <ul>
- * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
- * </ul>
- */
-public void invokeNoReply(int dispIdMember) {
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, null);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
-}
-/**
- * Invokes a method on the OLE Object; the method has no optional parameters. In the early days of OLE,
- * the IDispatch interface was not well defined and some applications (mainly Word) did not support
- * a return value. For these applications, call this method instead of calling
- * <code>public void invoke(int dispIdMember, Variant[] rgvarg)</code>.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @exception SWTException <ul>
- * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
- * </ul>
- */
-public void invokeNoReply(int dispIdMember, Variant[] rgvarg) {
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, null);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
-}
-/**
- * Invokes a method on the OLE Object; the method has optional parameters. It is not
- * necessary to specify all the optional parameters, only include the parameters for which
- * you are providing values. In the early days of OLE, the IDispatch interface was not well
- * defined and some applications (mainly Word) did not support a return value. For these
- * applications, call this method instead of calling
- * <code>public void invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)</code>.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
- * parameter IDs must be in the same order as their corresponding values;
- * all arguments must have an identifier - identifiers can be obtained using
- * OleAutomation.getIDsOfNames
- *
- * @exception SWTException <ul>
- * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
- * </ul>
- */
-public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, null);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
-}
-private void manageExcepinfo(int hResult, EXCEPINFO excepInfo) {
-
- // GOOGLE: better success test
- if (hResult >= COM.S_OK){
- exceptionDescription = "No Error"; //$NON-NLS-1$
- return;
- }
-
- // extract exception info
- if (hResult == COM.DISP_E_EXCEPTION) {
- if (excepInfo.bstrDescription != 0){
- int size = COM.SysStringByteLen(excepInfo.bstrDescription);
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, excepInfo.bstrDescription, size);
- exceptionDescription = new String(buffer);
- } else {
- exceptionDescription = "OLE Automation Error Exception "; //$NON-NLS-1$
- if (excepInfo.wCode != 0){
- exceptionDescription += "code = "+excepInfo.wCode; //$NON-NLS-1$
- } else if (excepInfo.scode != 0){
- exceptionDescription += "code = "+excepInfo.scode; //$NON-NLS-1$
- }
- }
- } else {
- exceptionDescription = "OLE Automation Error HResult : " + hResult; //$NON-NLS-1$
- }
-
- // cleanup EXCEPINFO struct
- if (excepInfo.bstrDescription != 0)
- COM.SysFreeString(excepInfo.bstrDescription);
- if (excepInfo.bstrHelpFile != 0)
- COM.SysFreeString(excepInfo.bstrHelpFile);
- if (excepInfo.bstrSource != 0)
- COM.SysFreeString(excepInfo.bstrSource);
-}
-/**
- * Sets the property specified by the dispIdMember to a new value.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- * @param rgvarg the new value of the property
- *
- * @return true if the operation was successful
- */
-public boolean setProperty(int dispIdMember, Variant rgvarg) {
- Variant[] rgvarg2 = new Variant[] {rgvarg};
- int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
- int dwFlags = COM.DISPATCH_PROPERTYPUT;
- if ((rgvarg.getType() & COM.VT_BYREF) == COM.VT_BYREF)
- dwFlags = COM.DISPATCH_PROPERTYPUTREF;
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult);
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- pVarResult.dispose();
- // GOOGLE: better success test
- return (result >= COM.S_OK);
-}
-/**
- * Sets the property specified by the dispIdMember to a new value.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @return true if the operation was successful
- *
- * @since 2.0
- */
-public boolean setProperty(int dispIdMember, Variant[] rgvarg) {
- int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
- int dwFlags = COM.DISPATCH_PROPERTYPUT;
- for (int i = 0; i < rgvarg.length; i++) {
- if ((rgvarg[i].getType() & COM.VT_BYREF) == COM.VT_BYREF)
- dwFlags = COM.DISPATCH_PROPERTYPUTREF;
- }
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult);
- // GOOGLE: force a dispose on the dangling Variant to prevent leaks.
- pVarResult.dispose();
- // GOOGLE: better success test
- return (result >= COM.S_OK);
-}
-}
diff --git a/dev/windows/src/org/eclipse/swt/ole/win32/Variant.java b/dev/windows/src/org/eclipse/swt/ole/win32/Variant.java
deleted file mode 100644
index d2ba5c1..0000000
--- a/dev/windows/src/org/eclipse/swt/ole/win32/Variant.java
+++ /dev/null
@@ -1,1078 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Modified by Google
-package org.eclipse.swt.ole.win32;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-/**
- *
- * A Variant is a generic OLE mechanism for passing data of different types via a common interface.
- *
- * <p>It is used within the OleAutomation object for getting a property, setting a property or invoking
- * a method on an OLE Control or OLE Document.
- *
- */
-public final class Variant
-{
- /**
- * A variant always takes up 16 bytes, no matter what you
- * store in it. Objects, strings, and arrays are not physically
- * stored in the Variant; in these cases, four bytes of the
- * Variant are used to hold either an object reference, or a
- * pointer to the string or array. The actual data are stored elsewhere.
- */
- public static final int sizeof = 16;
- private short type; // OLE.VT_* type
-
- private boolean booleanData;
- private byte byteData;
- private char charData;
- private double doubleData;
- private int intData;
- private float floatData;
- private long longData;
- private short shortData;
- private String stringData;
- private int byRefPtr;
- private IDispatch dispatchData;
- private IUnknown unknownData;
-
-
-/**
- * Invokes platform specific functionality to wrap a variant.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>GC</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param pVariant pointer to a variant
- *
- * @return a new <code>GC</code>
- *
- * @since 3.3
- */
-public static Variant win32_new (int pVariant) {
- Variant variant = new Variant ();
- variant.setData (pVariant);
- return variant;
-}
-
-/**
- * Invokes platform specific functionality to copy a variant
- * into operating system memory.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Variant</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param pVarDest destination pointer to a variant
- * @param varSrc source <code>Variant</code>
- *
- * @since 3.3
- */
-public static void win32_copy (int pVarDest, Variant varSrc) {
- varSrc.getData (pVarDest);
-}
-
-/**
- * Create an empty Variant object with type VT_EMPTY.
- *
- * @since 2.0
- */
-public Variant(){
- type = COM.VT_EMPTY;
-}
-/**
- * Create a Variant object which represents a Java float as a VT_R4.
- *
- * @param val the Java float value that this Variant represents
- *
- */
-public Variant(float val) {
- type = COM.VT_R4;
- floatData = val;
-
-}
-/**
- * Create a Variant object which represents a Java double as a VT_R8.
- *
- * @param val the Java double value that this Variant represents
- *
- * @since 3.2
- */
-public Variant(double val) {
- type = COM.VT_R8;
- doubleData = val;
-}
-/**
- * Create a Variant object which represents a Java int as a VT_I4.
- *
- * @param val the Java int value that this Variant represents
- *
- */
- public Variant(int val) {
- type = COM.VT_I4;
- intData = val;
-}
-/**
- * Create a Variant object which contains a reference to the data being transferred.
- *
- * <p>When creating a VT_BYREF Variant, you must give the full Variant type
- * including VT_BYREF such as
- *
- * <pre><code>short byRefType = OLE.VT_BSTR | OLE.VT_BYREF</code></pre>.
- *
- * @param ptr a pointer to the data being transferred.
- * @param byRefType the type of the data being transferred such as OLE.VT_BSTR | OLE.VT_BYREF
- *
- */
-public Variant(int ptr, short byRefType) {
- type = byRefType;
- byRefPtr = ptr;
-}
-/**
- * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
- *
- * @param automation the OleAutomation object that this Variant represents
- *
- */
-public Variant(OleAutomation automation) {
- type = COM.VT_DISPATCH;
- dispatchData = new IDispatch(automation.getAddress());
-}
-/**
- * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
- * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating
- * this Variant.
- *
- * @since 2.0
- *
- * @param idispatch the IDispatch object that this Variant represents
- *
- */
-public Variant(IDispatch idispatch) {
- type = COM.VT_DISPATCH;
- dispatchData = idispatch;
-}
-/**
- * Create a Variant object which represents an IUnknown interface as a VT_UNKNOWN.
- *
- * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating
- * this Variant.
- *
- * @param unknown the IUnknown object that this Variant represents
- *
- */
-public Variant(IUnknown unknown) {
- type = COM.VT_UNKNOWN;
- unknownData = unknown;
-}
-/**
- * Create a Variant object which represents a Java long as a VT_I8.
- *
- * @param val the Java long value that this Variant represents
- *
- *@since 3.2
- */
- public Variant(long val) {
- type = COM.VT_I8;
- longData = val;
-}
-/**
- * Create a Variant object which represents a Java String as a VT_BSTR.
- *
- * @param string the Java String value that this Variant represents
- *
- */
-public Variant(String string) {
- type = COM.VT_BSTR;
- stringData = string;
-}
-/**
- * Create a Variant object which represents a Java short as a VT_I2.
- *
- * @param val the Java short value that this Variant represents
- *
- */
-public Variant(short val) {
- type = COM.VT_I2;
- shortData = val;
-}
-/**
- * Create a Variant object which represents a Java boolean as a VT_BOOL.
- *
- * @param val the Java boolean value that this Variant represents
- *
- */
-public Variant(boolean val) {
- type = COM.VT_BOOL;
- booleanData = val;
-}
-
-/**
- * Calling dispose will release resources associated with this Variant.
- * If the resource is an IDispatch or IUnknown interface, Release will be called.
- * If the resource is a ByRef pointer, nothing is released.
- *
- * @since 2.1
- */
-public void dispose() {
- if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
- return;
- }
-
- switch (type) {
- case COM.VT_DISPATCH :
- dispatchData.Release();
- break;
- case COM.VT_UNKNOWN :
- unknownData.Release();
- break;
- }
-
-}
-/**
- * Returns the OleAutomation object represented by this Variant.
- *
- * <p>If this Variant does not contain an OleAutomation object, an attempt is made to
- * coerce the Variant type into an OleAutomation object. If this fails, an error is
- * thrown. Note that OleAutomation objects must be disposed when no longer
- * needed.
- *
- * @return the OleAutomation object represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an OleAutomation object</li>
- * </ul>
- */
-public OleAutomation getAutomation() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_DISPATCH) {
- return new OleAutomation(dispatchData);
- }
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- Variant autoVar = null; // GOOGLE: prevent memory leaks
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_DISPATCH);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- autoVar = new Variant();
- autoVar.setData(newPtr);
- return autoVar.getAutomation();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
- // OleAutomation object is created as Variant Clear
- // will result in a Release being performed on the
- // Dispatch object
- OS.GlobalFree(newPtr);
- // GOOGLE: prevent memory leaks
- if (autoVar != null)
- autoVar.dispose();
- }
-}
-/**
- * Returns the IDispatch object represented by this Variant.
- *
- * <p>If this Variant does not contain an IDispatch object, an attempt is made to
- * coerce the Variant type into an IDIspatch object. If this fails, an error is
- * thrown.
- *
- * @since 2.0
- *
- * @return the IDispatch object represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an IDispatch object</li>
- * </ul>
- */
-public IDispatch getDispatch() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_DISPATCH) {
- return dispatchData;
- }
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- Variant autoVar = null; // GOOGLE: prevent memory leaks
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_DISPATCH);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- autoVar = new Variant();
- autoVar.setData(newPtr);
- return autoVar.getDispatch();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
- // OleAutomation object is created as Variant Clear
- // will result in a Release being performed on the
- // Dispatch object
- OS.GlobalFree(newPtr);
- // GOOGLE: prevent memory leaks
- if (autoVar != null)
- autoVar.dispose();
- }
-}
-/**
- * Returns the Java boolean represented by this Variant.
- *
- * <p>If this Variant does not contain a Java boolean, an attempt is made to
- * coerce the Variant type into a Java boolean. If this fails, an error is thrown.
- *
- * @return the Java boolean represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a boolean</li>
- * </ul>
- *
- */
-public boolean getBoolean() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_BOOL) {
- return booleanData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_BOOL);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant boolVar = new Variant();
- boolVar.setData(newPtr);
- return boolVar.getBoolean();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns a pointer to the referenced data represented by this Variant.
- *
- * <p>If this Variant does not contain a reference to data, zero is returned.
- *
- * @return a pointer to the referenced data represented by this Variant or 0
- *
- */
-public int getByRef() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if ((type & COM.VT_BYREF)== COM.VT_BYREF) {
- return byRefPtr;
- }
-
- return 0;
-}
-/**
- * Returns the Java byte represented by this Variant.
- *
- * <p>If this Variant does not contain a Java byte, an attempt is made to
- * coerce the Variant type into a Java byte. If this fails, an error is thrown.
- *
- * @return the Java byte represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a byte</li>
- * </ul>
- *
- * @since 3.3
- */
-public byte getByte() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I1) {
- return byteData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I1);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant byteVar = new Variant();
- byteVar.setData(newPtr);
- return byteVar.getByte();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the Java char represented by this Variant.
- *
- * <p>If this Variant does not contain a Java char, an attempt is made to
- * coerce the Variant type into a Java char. If this fails, an error is thrown.
- *
- * @return the Java char represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a char</li>
- * </ul>
- *
- * @since 3.3
- */
-public char getChar() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_UI2) {
- return charData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_UI2);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant charVar = new Variant();
- charVar.setData(newPtr);
- return charVar.getChar();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-void getData(int pData){
- if (pData == 0) OLE.error(OLE.ERROR_OUT_OF_MEMORY);
-
- COM.VariantInit(pData);
-
- if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int[]{byRefPtr}, 4);
- return;
- }
-
- switch (type) {
- case COM.VT_EMPTY :
- case COM.VT_NULL :
- COM.MoveMemory(pData, new short[] {type}, 2);
- break;
- case COM.VT_BOOL :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int[]{(booleanData) ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 2);
- break;
- case COM.VT_I1 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new byte[]{byteData}, 1);
- break;
- case COM.VT_I2 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new short[]{shortData}, 2);
- break;
- case COM.VT_I4 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int[]{intData}, 4);
- break;
- case COM.VT_I8 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new long[]{longData}, 8);
- case COM.VT_UI2 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new char[]{charData}, 2);
- break;
- case COM.VT_R4 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new float[]{floatData}, 4);
- break;
- case COM.VT_R8 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new double[]{doubleData}, 8);
- break;
- case COM.VT_DISPATCH :
- dispatchData.AddRef();
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int[]{dispatchData.getAddress()}, 4);
- break;
- case COM.VT_UNKNOWN :
- unknownData.AddRef();
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int[]{unknownData.getAddress()}, 4);
- break;
- case COM.VT_BSTR :
- COM.MoveMemory(pData, new short[] {type}, 2);
- int ptr = COM.SysAllocStringLen(stringData.toCharArray(),
- stringData.length()); // GOOGLE
- COM.MoveMemory(pData + 8, new int[] {ptr}, 4);
- break;
-
- default :
- OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
- }
-}
-/**
- * Returns the Java double represented by this Variant.
- *
- * <p>If this Variant does not contain a Java double, an attempt is made to
- * coerce the Variant type into a Java double. If this fails, an error is thrown.
- *
- * @return the Java double represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a double</li>
- * </ul>
- *
- * @since 3.2
- */
-public double getDouble() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_R8) {
- return doubleData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_R8);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant doubleVar = new Variant();
- doubleVar.setData(newPtr);
- return doubleVar.getDouble();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-
-/**
- * Returns the Java float represented by this Variant.
- *
- * <p>If this Variant does not contain a Java float, an attempt is made to
- * coerce the Variant type into a Java float. If this fails, an error is thrown.
- *
- * @return the Java float represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a float</li>
- * </ul>
- */
-public float getFloat() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_R4) {
- return floatData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_R4);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant floatVar = new Variant();
- floatVar.setData(newPtr);
- return floatVar.getFloat();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-
-}
-/**
- * Returns the Java int represented by this Variant.
- *
- * <p>If this Variant does not contain a Java int, an attempt is made to
- * coerce the Variant type into a Java int. If this fails, an error is thrown.
- *
- * @return the Java int represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a int</li>
- * </ul>
- */
-public int getInt() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I4) {
- return intData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I4);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant intVar = new Variant();
- intVar.setData(newPtr);
- return intVar.getInt();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the Java long represented by this Variant.
- *
- * <p>If this Variant does not contain a Java long, an attempt is made to
- * coerce the Variant type into a Java long. If this fails, an error is thrown.
- *
- * @return the Java long represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a long</li>
- * </ul>
- *
- * @since 3.2
- */
-public long getLong() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I8) {
- return longData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I8);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant longVar = new Variant();
- longVar.setData(newPtr);
- return longVar.getLong();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the Java short represented by this Variant.
- *
- * <p>If this Variant does not contain a Java short, an attempt is made to
- * coerce the Variant type into a Java short. If this fails, an error is thrown.
- *
- * @return the Java short represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a short</li>
- * </ul>
- */
-public short getShort() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I2) {
- return shortData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I2);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant shortVar = new Variant();
- shortVar.setData(newPtr);
- return shortVar.getShort();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-
-}
-/**
- * Returns the Java String represented by this Variant.
- *
- * <p>If this Variant does not contain a Java String, an attempt is made to
- * coerce the Variant type into a Java String. If this fails, an error is thrown.
- *
- * @return the Java String represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a String</li>
- * </ul>
- */
-public String getString() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_BSTR) {
- return stringData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_BSTR);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
-
- Variant stringVar = new Variant();
- stringVar.setData(newPtr);
- return stringVar.getString();
-
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the type of the variant type. This will be an OLE.VT_* value or
- * a bitwise combination of OLE.VT_* values as in the case of
- * OLE.VT_BSTR | OLE.VT_BYREF.
- *
- * @return the type of the variant data
- *
- * @since 2.0
- */
-public short getType() {
- return type;
-}
-/**
- * Returns the IUnknown object represented by this Variant.
- *
- * <p>If this Variant does not contain an IUnknown object, an attempt is made to
- * coerce the Variant type into an IUnknown object. If this fails, an error is
- * thrown.
- *
- * @return the IUnknown object represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into
- * an IUnknown object</li>
- * </ul>
- */
-public IUnknown getUnknown() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_UNKNOWN) {
- return unknownData;
- }
-
- // try to coerce the value to the desired type
- int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- Variant unknownVar = null; // GOOGLE: prevent memory leaks
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_UNKNOWN);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- unknownVar = new Variant();
- unknownVar.setData(newPtr);
- return unknownVar.getUnknown();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
- // IUnknown object is created as Variant Clear
- // will result in a Release being performed on the
- // Dispatch object
- OS.GlobalFree(newPtr);
- // GOOGLE: prevent memory leaks
- if (unknownVar != null)
- unknownVar.dispose();
- }
-}
-/**
- * Update the by reference value of this variant with a new boolean value.
- *
- * @param val the new boolean value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_BOOL) object</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(boolean val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_BOOL) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new short[]{val ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 2);
-}
-/**
- * Update the by reference value of this variant with a new float value.
- *
- * @param val the new float value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_R4) object</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(float val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_R4) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new float[]{val}, 4);
-}
-/**
- * Update the by reference value of this variant with a new integer value.
- *
- * @param val the new integer value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not a (VT_BYREF | VT_I4) object</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(int val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I4) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new int[]{val}, 4);
-}
-/**
- * Update the by reference value of this variant with a new short value.
- *
- * @param val the new short value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not a (VT_BYREF | VT_I2) object
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(short val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I2) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new short[]{val}, 2);
-}
-
-void setData(int pData){
- if (pData == 0) OLE.error(OLE.ERROR_INVALID_ARGUMENT);
-
- short[] dataType = new short[1];
- COM.MoveMemory(dataType, pData, 2);
- type = dataType[0];
-
- if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
- int[] newByRefPtr = new int[1];
- OS.MoveMemory(newByRefPtr, pData + 8, 4);
- byRefPtr = newByRefPtr[0];
- return;
- }
-
- switch (type) {
- case COM.VT_EMPTY :
- case COM.VT_NULL :
- break;
- case COM.VT_BOOL :
- short[] newBooleanData = new short[1];
- COM.MoveMemory(newBooleanData, pData + 8, 2);
- booleanData = (newBooleanData[0] != COM.VARIANT_FALSE);
- break;
- case COM.VT_I1 :
- byte[] newByteData = new byte[1];
- COM.MoveMemory(newByteData, pData + 8, 1);
- byteData = newByteData[0];
- break;
- case COM.VT_I2 :
- short[] newShortData = new short[1];
- COM.MoveMemory(newShortData, pData + 8, 2);
- shortData = newShortData[0];
- break;
- case COM.VT_I4 :
- int[] newIntData = new int[1];
- OS.MoveMemory(newIntData, pData + 8, 4);
- intData = newIntData[0];
- break;
- case COM.VT_I8 :
- long[] newLongData = new long[1];
- OS.MoveMemory(newLongData, pData + 8, 8);
- longData = newLongData[0];
- break;
- case COM.VT_UI2 :
- char[] newCharData = new char[1];
- COM.MoveMemory(newCharData, pData + 8, 2);
- charData = newCharData[0];
- break;
- case COM.VT_R4 :
- float[] newFloatData = new float[1];
- COM.MoveMemory(newFloatData, pData + 8, 4);
- floatData = newFloatData[0];
- break;
- case COM.VT_R8 :
- double[] newDoubleData = new double[1];
- COM.MoveMemory(newDoubleData, pData + 8, 8);
- doubleData = newDoubleData[0];
- break;
- case COM.VT_DISPATCH : {
- int[] ppvObject = new int[1];
- OS.MoveMemory(ppvObject, pData + 8, 4);
- if (ppvObject[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- dispatchData = new IDispatch(ppvObject[0]);
- dispatchData.AddRef();
- break;
- }
- case COM.VT_UNKNOWN : {
- int[] ppvObject = new int[1];
- OS.MoveMemory(ppvObject, pData + 8, 4);
- if (ppvObject[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- unknownData = new IUnknown(ppvObject[0]);
- unknownData.AddRef();
- break;
- }
-
- // GOOGLE: map exception name in IE7 to BSTR
- case COM.VT_WEIRD_IE7_BSTR :
- type = COM.VT_BSTR;
- // intentional fall-through to VT_BSTR case
- case COM.VT_BSTR :
- // get the address of the memory in which the string resides
- int[] hMem = new int[1];
- OS.MoveMemory(hMem, pData + 8, 4);
- if (hMem[0] == 0) {
- // A VT_BSTR with a null pointer is equivalent to an empty string
- stringData = ""; //$NON-NLS-1$
- break;
- }
- // Get the size of the string from the OS - the size is expressed in number
- // of bytes - each unicode character is 2 bytes.
- int size = COM.SysStringByteLen(hMem[0]);
- if (size > 0){
- // get the unicode character array from the global memory and create a String
- char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
- COM.MoveMemory(buffer, hMem[0], size);
- stringData = new String(buffer);
- } else {
- stringData = ""; //$NON-NLS-1$
- }
- break;
-
- default :
- // try coercing it into one of the known forms
- int newPData = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
- if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_R4) == COM.S_OK) {
- setData(newPData);
- } else if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_I4) == COM.S_OK) {
- setData(newPData);
- } else if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_BSTR) == COM.S_OK) {
- setData(newPData);
- }
- COM.VariantClear(newPData);
- OS.GlobalFree(newPData);
- break;
- }
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the Variant
- */
-public String toString () {
- switch (type) {
- case COM.VT_BOOL :
- return "VT_BOOL{"+booleanData+"}";
- case COM.VT_I1 :
- return "VT_I1{"+byteData+"}";
- case COM.VT_I2 :
- return "VT_I2{"+shortData+"}";
- case COM.VT_I4 :
- return "VT_I4{"+intData+"}";
- case COM.VT_I8 :
- return "VT_I8{"+longData+"}";
- case COM.VT_UI2 :
- return "VT_UI2{"+charData+"}";
- case COM.VT_R4 :
- return "VT_R4{"+floatData+"}";
- case COM.VT_R8 :
- return "VT_R8{"+doubleData+"}";
- case COM.VT_BSTR :
- return "VT_BSTR{"+stringData+"}";
- case COM.VT_DISPATCH :
- return "VT_DISPATCH{"+(dispatchData == null ? 0 : dispatchData.getAddress())+"}";
- case COM.VT_UNKNOWN :
- return "VT_UNKNOWN{"+(unknownData == null ? 0 : unknownData.getAddress())+"}";
- case COM.VT_EMPTY :
- return "VT_EMPTY";
- case COM.VT_NULL :
- return "VT_NULL";
- }
- if ((type & COM.VT_BYREF) != 0) {
- return "VT_BYREF|"+(type & ~COM.VT_BYREF)+"{"+byRefPtr+"}";
- }
- return "Unsupported Type "+type;
-}
-}
diff --git a/dev/windows/src/org/eclipse/swt/program/Program.java b/dev/windows/src/org/eclipse/swt/program/Program.java
deleted file mode 100644
index 7d09233..0000000
--- a/dev/windows/src/org/eclipse/swt/program/Program.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.program;
-
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-import java.io.IOException;
-
-/**
- * Instances of this class represent programs and
- * their associated file extensions in the operating
- * system.
- */
-public final class Program {
- String name;
- String command;
- String iconName;
-
-/**
- * Prevents uninitialized instances from being created outside the package.
- */
-Program () {
-}
-
-/**
- * Finds the program that is associated with an extension.
- * The extension may or may not begin with a '.'. Note that
- * a <code>Display</code> must already exist to guarantee that
- * this method returns an appropriate result.
- *
- * @param extension the program extension
- * @return the program or <code>null</code>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when extension is null</li>
- * </ul>
- */
-public static Program findProgram (String extension) {
- if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (extension.length () == 0) return null;
- if (extension.charAt (0) != '.') extension = "." + extension; //$NON-NLS-1$
- /* Use the character encoding for the default locale */
- TCHAR key = new TCHAR (0, extension, true);
- int [] phkResult = new int [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
- return null;
- }
- Program program = null;
- int [] lpcbData = new int [1];
- int result = OS.RegQueryValueEx (phkResult [0], null, 0, null, (TCHAR) null, lpcbData);
- if (result == 0) {
- TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
- result = OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData);
- if (result == 0) program = getProgram (lpData.toString (0, lpData.strlen ()));
- }
- OS.RegCloseKey (phkResult [0]);
- return program;
-}
-
-/**
- * Answer all program extensions in the operating system. Note
- * that a <code>Display</code> must already exist to guarantee
- * that this method returns an appropriate result.
- *
- * @return an array of extensions
- */
-public static String [] getExtensions () {
- String [] extensions = new String [1024];
- /* Use the character encoding for the default locale */
- TCHAR lpName = new TCHAR (0, 1024);
- int [] lpcName = new int [] {lpName.length ()};
- FILETIME ft = new FILETIME ();
- int dwIndex = 0, count = 0;
- while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String extension = lpName.toString (0, lpcName [0]);
- lpcName [0] = lpName.length ();
- if (extension.length () > 0 && extension.charAt (0) == '.') {
- if (count == extensions.length) {
- String [] newExtensions = new String [extensions.length + 1024];
- System.arraycopy (extensions, 0, newExtensions, 0, extensions.length);
- extensions = newExtensions;
- }
- extensions [count++] = extension;
- }
- dwIndex++;
- }
- if (count != extensions.length) {
- String [] newExtension = new String [count];
- System.arraycopy (extensions, 0, newExtension, 0, count);
- extensions = newExtension;
- }
- return extensions;
-}
-
-static String getKeyValue (String string, boolean expand) {
- /* Use the character encoding for the default locale */
- TCHAR key = new TCHAR (0, string, true);
- int [] phkResult = new int [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
- return null;
- }
- String result = null;
- int [] lpcbData = new int [1];
- if (OS.RegQueryValueEx (phkResult [0], (TCHAR) null, 0, null, (TCHAR) null, lpcbData) == 0) {
- result = "";
- int length = lpcbData [0] / TCHAR.sizeof;
- if (length != 0) {
- /* Use the character encoding for the default locale */
- TCHAR lpData = new TCHAR (0, length);
- if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
- if (!OS.IsWinCE && expand) {
- length = OS.ExpandEnvironmentStrings (lpData, null, 0);
- if (length != 0) {
- TCHAR lpDst = new TCHAR (0, length);
- OS.ExpandEnvironmentStrings (lpData, lpDst, length);
- result = lpDst.toString (0, Math.max (0, length - 1));
- }
- } else {
- length = Math.max (0, lpData.length () - 1);
- result = lpData.toString (0, length);
- }
- }
- }
- }
- if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
- return result;
-}
-
-static Program getProgram (String key) {
-
- /* Name */
- String name = getKeyValue (key, false);
- if (name == null || name.length () == 0) {
- name = key;
- }
-
- /* Command */
- String DEFAULT_COMMAND = "\\shell"; //$NON-NLS-1$
- String defaultCommand = getKeyValue (key + DEFAULT_COMMAND, true);
- if (defaultCommand == null || defaultCommand.length() == 0) defaultCommand = "open"; //$NON-NLS-1$
- String COMMAND = "\\shell\\" + defaultCommand + "\\command"; //$NON-NLS-1$
- String command = getKeyValue (key + COMMAND, true);
- if (command == null || command.length () == 0) return null;
-
- /* Icon */
- String DEFAULT_ICON = "\\DefaultIcon"; //$NON-NLS-1$
- String iconName = getKeyValue (key + DEFAULT_ICON, true);
- if (iconName == null) iconName = ""; //$NON-NLS-1$
-
- Program program = new Program ();
- program.name = name;
- program.command = command;
- program.iconName = iconName;
- return program;
-}
-
-/**
- * Answers all available programs in the operating system. Note
- * that a <code>Display</code> must already exist to guarantee
- * that this method returns an appropriate result.
- *
- * @return an array of programs
- */
-public static Program [] getPrograms () {
- Program [] programs = new Program [1024];
- /* Use the character encoding for the default locale */
- TCHAR lpName = new TCHAR (0, 1024);
- int [] lpcName = new int [] {lpName.length ()};
- FILETIME ft = new FILETIME ();
- int dwIndex = 0, count = 0;
- while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String path = lpName.toString (0, lpcName [0]);
- lpcName [0] = lpName.length ();
- Program program = getProgram (path);
- if (program != null) {
- if (count == programs.length) {
- Program [] newPrograms = new Program [programs.length + 1024];
- System.arraycopy (programs, 0, newPrograms, 0, programs.length);
- programs = newPrograms;
- }
- programs [count++] = program;
- }
- dwIndex++;
- }
- if (count != programs.length) {
- Program [] newPrograms = new Program [count];
- System.arraycopy (programs, 0, newPrograms, 0, count);
- programs = newPrograms;
- }
- return programs;
-}
-
-/**
- * Launches the executable associated with the file in
- * the operating system. If the file is an executable,
- * then the executable is launched. Note that a <code>Display</code>
- * must already exist to guarantee that this method returns
- * an appropriate result.
- *
- * @param fileName the file or program name
- * @return <code>true</code> if the file is launched, otherwise <code>false</code>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
- * </ul>
- */
-public static boolean launch (String fileName) {
- if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
-
- /* Use the character encoding for the default locale */
- int hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (0, fileName, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- int lpFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (lpFile, buffer, byteCount);
- SHELLEXECUTEINFO info = new SHELLEXECUTEINFO ();
- info.cbSize = SHELLEXECUTEINFO.sizeof;
- info.lpFile = lpFile;
- info.nShow = OS.SW_SHOW;
- boolean result = OS.ShellExecuteEx (info);
- if (lpFile != 0) OS.HeapFree (hHeap, 0, lpFile);
- return result;
-}
-
-/**
- * Executes the program with the file as the single argument
- * in the operating system. It is the responsibility of the
- * programmer to ensure that the file contains valid data for
- * this program.
- *
- * @param fileName the file or program name
- * @return <code>true</code> if the file is launched, otherwise <code>false</code>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
- * </ul>
- */
-public boolean execute (String fileName) {
- if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- boolean quote = true;
- String prefix = command, suffix = ""; //$NON-NLS-1$
- int index = command.indexOf ("%1"); //$NON-NLS-1$
- if (index != -1) {
- int count=0;
- int i=index + 2, length = command.length ();
- while (i < length) {
- if (command.charAt (i) == '"') count++;
- i++;
- }
- quote = count % 2 == 0;
- prefix = command.substring (0, index);
- suffix = command.substring (index + 2, length);
- }
- if (quote) fileName = " \"" + fileName + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- try {
- Compatibility.exec(prefix + fileName + suffix);
- } catch (IOException e) {
- return false;
- }
- return true;
-}
-
-/**
- * Returns the receiver's image data. This is the icon
- * that is associated with the receiver in the operating
- * system.
- *
- * @return the image data for the program, may be null
- */
-public ImageData getImageData () {
- int nIconIndex = 0;
- String fileName = iconName;
- int index = iconName.indexOf (',');
- if (index != -1) {
- fileName = iconName.substring (0, index);
- String iconIndex = iconName.substring (index + 1, iconName.length ()).trim ();
- try {
- nIconIndex = Integer.parseInt (iconIndex);
- } catch (NumberFormatException e) {}
- }
- /* Use the character encoding for the default locale */
- TCHAR lpszFile = new TCHAR (0, fileName, true);
- int [] phiconSmall = new int[1], phiconLarge = null;
- OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);
- if (phiconSmall [0] == 0) return null;
- Image image = Image.win32_new (null, SWT.ICON, phiconSmall[0]);
- ImageData imageData = image.getImageData ();
- image.dispose ();
- return imageData;
-}
-
-/**
- * Returns the receiver's name. This is as short and
- * descriptive a name as possible for the program. If
- * the program has no descriptive name, this string may
- * be the executable name, path or empty.
- *
- * @return the name of the program
- */
-public String getName () {
- return name;
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param other the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode()
- */
-public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Program) {
- final Program program = (Program) other;
- return name.equals(program.name) && command.equals(program.command)
- && iconName.equals(program.iconName);
- }
- return false;
-}
-
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals(Object)
- */
-public int hashCode() {
- return name.hashCode() ^ command.hashCode() ^ iconName.hashCode();
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the program
- */
-public String toString () {
- return "Program {" + name + "}"; //$NON-NLS-1$ //$NON-NLS-2$
-}
-
-}
diff --git a/distro-source/build.xml b/distro-source/build.xml
index 26a338c..2a83261 100755
--- a/distro-source/build.xml
+++ b/distro-source/build.xml
@@ -3,8 +3,57 @@
<property name="project.tail" value="distro-source" />
<import file="${gwt.root}/platforms.ant.xml" />
+ <import file="common.ant.xml" />
+
+ <property name="project.dist" location="${gwt.build.dist}/${project.distname}.zip" />
+
<target name="clean" description="Cleans this project's intermediate and output files">
<delete dir="${gwt.build.dist}" failonerror="false" />
<delete dir="${gwt.build.staging}" failonerror="false" />
+ <delete file="${project.dist}" failonerror="false" />
+ </target>
+
+ <target name="build" depends="filter" description="Packages the distro">
+ <!-- TODO: figure out how to share most of this across platforms -->
+ <mkdir dir="${gwt.build.dist}" />
+ <mkdir dir="${gwt.build.out}/samples-scripts"/>
+ <zip destfile="${project.dist}">
+ <!-- jars -->
+ <zipfileset file="${gwt.build.lib}/gwt-dev.jar" prefix="${project.distname}" />
+ <zipfileset file="${gwt.build.lib}/gwt-user.jar" prefix="${project.distname}" />
+ <zipfileset file="${gwt.build.lib}/gwt-servlet.jar" prefix="${project.distname}" />
+ <zipfileset file="${gwt.build.lib}/gwt-benchmark-viewer.war" prefix="${project.distname}" />
+ <zipfileset file="${gwt.build.lib}/gwt-soyc-vis.jar" prefix="${project.distname}" />
+ <zipfileset file="${gwt.build.lib}/gwt-api-checker.jar" prefix="${project.distname}" />
+
+ <!-- raw files -->
+ <zipfileset dir="${dist.resources}" prefix="${project.distname}" />
+ <zipfileset dir="src" prefix="${project.distname}" />
+
+ <!-- doc -->
+ <zipfileset dir="${gwt.build.out}" prefix="${project.distname}">
+ <include name="doc" />
+ <include name="doc/html/**" />
+ <include name="doc/css/**" />
+ <include name="doc/javadoc/**" />
+ </zipfileset>
+
+ <!-- samples -->
+ <zipfileset dir="${gwt.build.out}" prefix="${project.distname}">
+ <include name="samples" />
+ <include name="samples/*" />
+ <include name="samples/*/src/**" />
+ <include name="samples/*/war/**" />
+ </zipfileset>
+ <zipfileset dir="${gwt.build.out}/samples-scripts" prefix="${project.distname}/samples">
+ <include name="*/*" />
+ </zipfileset>
+ </zip>
+
+ <!--
+ Unzip distro into the staging directory.
+ -->
+ <mkdir dir="${gwt.build.staging}" />
+ <unzip src="${project.dist}" dest="${gwt.build.staging}" />
</target>
</project>
diff --git a/distro-source/common.ant.xml b/distro-source/common.ant.xml
index 7a99364..cef80ec 100755
--- a/distro-source/common.ant.xml
+++ b/distro-source/common.ant.xml
@@ -3,7 +3,7 @@
<property name="project.tail" value="distro-source/${dist.platform}" />
<import file="${gwt.root}/common.ant.xml" />
- <property name="project.distname" value="gwt-${dist.platform}-${gwt.version}" />
+ <property name="project.distname" value="gwt-${gwt.version}" />
<property name="project.staging" location="${gwt.build.staging}/${project.distname}" />
<property name="dist.resources" location="${project.build}/resources" />
@@ -23,7 +23,7 @@
<and>
<available file="${filter.sentinel}" />
<uptodate>
- <srcfiles dir="../core/src" />
+ <srcfiles dir="core/src" />
<globmapper from="*" to="${dist.resources}/*" />
</uptodate>
</and>
@@ -33,7 +33,7 @@
<target name="-filter.props" unless="filter.uptodate">
<gwt.revfilter todir="${dist.resources}" >
- <fileset dir="../core/src" />
+ <fileset dir="core/src" />
</gwt.revfilter>
<touch file="${filter.sentinel}" />
</target>
diff --git a/distro-source/linux/src/benchmarkViewer b/distro-source/linux/src/benchmarkViewer
deleted file mode 100755
index d7759b4..0000000
--- a/distro-source/linux/src/benchmarkViewer
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-APPDIR=`dirname $0`;
-java -Dcom.google.gwt.junit.reportPath="$1" -cp "$APPDIR/gwt-dev-linux.jar" com.google.gwt.dev.RunWebApp -port auto $APPDIR/gwt-benchmark-viewer.war;
diff --git a/distro-source/linux/src/i18nCreator b/distro-source/linux/src/i18nCreator
deleted file mode 100755
index 0e05618..0000000
--- a/distro-source/linux/src/i18nCreator
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-HOMEDIR=`dirname $0`;
-java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar com.google.gwt.i18n.tools.I18NCreator "$@";
diff --git a/distro-source/linux/src/junitCreator b/distro-source/linux/src/junitCreator
deleted file mode 100644
index 9775188..0000000
--- a/distro-source/linux/src/junitCreator
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-HOMEDIR=`dirname $0`;
-java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar com.google.gwt.junit.tools.JUnitCreator "$@";
diff --git a/distro-source/linux/src/webAppCreator b/distro-source/linux/src/webAppCreator
deleted file mode 100755
index 91c4613..0000000
--- a/distro-source/linux/src/webAppCreator
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-HOMEDIR=`dirname $0`;
-java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar com.google.gwt.user.tools.WebAppCreator "$@";
diff --git a/distro-source/src/benchmarkViewer b/distro-source/src/benchmarkViewer
new file mode 100755
index 0000000..8672c6f
--- /dev/null
+++ b/distro-source/src/benchmarkViewer
@@ -0,0 +1,3 @@
+#!/bin/sh
+APPDIR=`dirname $0`;
+java -Dcom.google.gwt.junit.reportPath="$1" -cp "$APPDIR/gwt-dev.jar" com.google.gwt.dev.RunWebApp -port auto $APPDIR/gwt-benchmark-viewer.war;
diff --git a/distro-source/src/benchmarkViewer.cmd b/distro-source/src/benchmarkViewer.cmd
new file mode 100755
index 0000000..beef709
--- /dev/null
+++ b/distro-source/src/benchmarkViewer.cmd
@@ -0,0 +1 @@
+@java -Dcom.google.gwt.junit.reportPath="%1" -cp "%~dp0/gwt-dev.jar" com.google.gwt.dev.RunWebApp -port auto %~dp0/gwt-benchmark-viewer.war
diff --git a/distro-source/src/i18nCreator b/distro-source/src/i18nCreator
new file mode 100755
index 0000000..f4d4a33
--- /dev/null
+++ b/distro-source/src/i18nCreator
@@ -0,0 +1,3 @@
+#!/bin/sh
+HOMEDIR=`dirname $0`;
+java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev.jar com.google.gwt.i18n.tools.I18NCreator "$@";
diff --git a/distro-source/src/i18nCreator.cmd b/distro-source/src/i18nCreator.cmd
new file mode 100755
index 0000000..39128df
--- /dev/null
+++ b/distro-source/src/i18nCreator.cmd
@@ -0,0 +1 @@
+@java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev.jar" com.google.gwt.i18n.tools.I18NCreator %*
diff --git a/distro-source/src/junitCreator b/distro-source/src/junitCreator
new file mode 100755
index 0000000..df2655f
--- /dev/null
+++ b/distro-source/src/junitCreator
@@ -0,0 +1,3 @@
+#!/bin/sh
+HOMEDIR=`dirname $0`;
+java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev.jar com.google.gwt.junit.tools.JUnitCreator "$@";
diff --git a/distro-source/src/junitCreator.cmd b/distro-source/src/junitCreator.cmd
new file mode 100755
index 0000000..b8cebe8
--- /dev/null
+++ b/distro-source/src/junitCreator.cmd
@@ -0,0 +1 @@
+@java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev.jar" com.google.gwt.junit.tools.JUnitCreator %*
diff --git a/distro-source/src/webAppCreator b/distro-source/src/webAppCreator
new file mode 100755
index 0000000..782ab69
--- /dev/null
+++ b/distro-source/src/webAppCreator
@@ -0,0 +1,3 @@
+#!/bin/sh
+HOMEDIR=`dirname $0`;
+java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev.jar com.google.gwt.user.tools.WebAppCreator "$@";
diff --git a/distro-source/src/webAppCreator.cmd b/distro-source/src/webAppCreator.cmd
new file mode 100755
index 0000000..ccf8393
--- /dev/null
+++ b/distro-source/src/webAppCreator.cmd
@@ -0,0 +1 @@
+@java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev.jar" com.google.gwt.user.tools.WebAppCreator %*
diff --git a/distro-source/windows/src/benchmarkViewer.cmd b/distro-source/windows/src/benchmarkViewer.cmd
deleted file mode 100755
index 7bf3ee2..0000000
--- a/distro-source/windows/src/benchmarkViewer.cmd
+++ /dev/null
@@ -1 +0,0 @@
-@java -Dcom.google.gwt.junit.reportPath="%1" -cp "%~dp0/gwt-dev-windows.jar" com.google.gwt.dev.RunWebApp -port auto %~dp0/gwt-benchmark-viewer.war
\ No newline at end of file
diff --git a/distro-source/windows/src/i18nCreator.cmd b/distro-source/windows/src/i18nCreator.cmd
deleted file mode 100755
index 6772530..0000000
--- a/distro-source/windows/src/i18nCreator.cmd
+++ /dev/null
@@ -1 +0,0 @@
-@java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev-windows.jar" com.google.gwt.i18n.tools.I18NCreator %*
diff --git a/distro-source/windows/src/junitCreator.cmd b/distro-source/windows/src/junitCreator.cmd
deleted file mode 100755
index 21c7f04..0000000
--- a/distro-source/windows/src/junitCreator.cmd
+++ /dev/null
@@ -1 +0,0 @@
-@java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev-windows.jar" com.google.gwt.junit.tools.JUnitCreator %*
diff --git a/distro-source/windows/src/webAppCreator.cmd b/distro-source/windows/src/webAppCreator.cmd
deleted file mode 100755
index b16d7a8..0000000
--- a/distro-source/windows/src/webAppCreator.cmd
+++ /dev/null
@@ -1 +0,0 @@
-@java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev-windows.jar" com.google.gwt.user.tools.WebAppCreator %*
diff --git a/doc/build.xml b/doc/build.xml
index 5ce1b14..8e2f84a 100644
--- a/doc/build.xml
+++ b/doc/build.xml
@@ -7,7 +7,7 @@
<property.ensure name="gwt.user.jar" location="${gwt.build.lib}/gwt-user.jar" />
<!-- Platform shouldn't matter here, just picking one -->
- <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-${build.host.platform}.jar" />
+ <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev.jar" />
<property name="USER_PKGS"
value="com.google.gwt.animation.client;com.google.gwt.benchmarks.client;com.google.gwt.core.client;com.google.gwt.core.ext;com.google.gwt.core.ext.soyc;com.google.gwt.core.ext.linker;com.google.gwt.core.ext.typeinfo;com.google.gwt.debug.client;com.google.gwt.dom.client;com.google.gwt.event.dom.client;com.google.gwt.event.logical.shared;com.google.gwt.event.shared;com.google.gwt.http.client;com.google.gwt.i18n.client;com.google.gwt.i18n.client.constants;com.google.gwt.i18n.rebind.format;com.google.gwt.i18n.rebind.keygen;com.google.gwt.json.client;com.google.gwt.junit.client;com.google.gwt.benchmarks.client;com.google.gwt.user.client;com.google.gwt.user.client.rpc;com.google.gwt.user.client.ui;com.google.gwt.user.datepicker.client;com.google.gwt.user.server.rpc;com.google.gwt.xml.client"/>
diff --git a/eclipse/build-tools/doctool/.project b/eclipse/build-tools/doctool/.project
index 7cae441..f998847 100644
--- a/eclipse/build-tools/doctool/.project
+++ b/eclipse/build-tools/doctool/.project
@@ -24,7 +24,7 @@
<link>
<name>core</name>
<type>2</type>
- <location>GWT_ROOT/build-tools/doctool</location>
+ <locationURI>GWT_ROOT/build-tools/doctool</locationURI>
</link>
</linkedResources>
</projectDescription>
diff --git a/eclipse/dev/linux/.checkstyle b/eclipse/dev/.checkstyle
similarity index 100%
rename from eclipse/dev/linux/.checkstyle
rename to eclipse/dev/.checkstyle
diff --git a/eclipse/dev/linux/.classpath b/eclipse/dev/.classpath
similarity index 84%
rename from eclipse/dev/linux/.classpath
rename to eclipse/dev/.classpath
index 88ad728..b133bac 100644
--- a/eclipse/dev/linux/.classpath
+++ b/eclipse/dev/.classpath
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="core/src"/>
+ <classpathentry kind="src" path="core/oophm-test"/>
+ <classpathentry kind="src" path="core/oophm"/>
+ <classpathentry kind="src" path="core/overlay"/>
<classpathentry kind="src" path="core/test"/>
- <classpathentry kind="src" path="linux/src"/>
<classpathentry excluding="com/google/gwt/dev/jjs/intrinsic/" kind="src" path="core/super"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/org.eclipse.swt.gtk-linux-3.2.1.jar" sourcepath="/GWT_TOOLS/lib/eclipse/org.eclipse.swt.gtk-linux-3.2.1.src.zip"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/apache/ant-1.6.5.jar" sourcepath="/GWT_TOOLS/lib/apache/ant-1.6.5-src.zip"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2.jar" sourcepath="/GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2-src.zip"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdt-3.4.2.jar" sourcepath="/GWT_TOOLS/lib/eclipse/jdt-3.4.2-src.zip"/>
@@ -35,8 +36,11 @@
<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-default-1.0.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-invoker-1.0.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-coyote-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-http11-1.0.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-http11-1.0.jar" sourcepath="/GWT_TOOLS/lib/tomcat/tomcat-http11-1.0.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-jk2-2.1.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-util-5.1.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/sun/swingworker/swing-worker-1.1.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-core-js-2.5.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-core-js-2.5-sources.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-2.5.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-2.5-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/dev/.project b/eclipse/dev/.project
new file mode 100644
index 0000000..ab97556
--- /dev/null
+++ b/eclipse/dev/.project
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>gwt-dev</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>core</name>
+ <type>2</type>
+ <locationURI>GWT_ROOT/dev/core</locationURI>
+ </link>
+ <link>
+ <name>core/oophm</name>
+ <type>2</type>
+ <locationURI>GWT_ROOT/dev/oophm/src</locationURI>
+ </link>
+ <link>
+ <name>core/oophm-test</name>
+ <type>2</type>
+ <locationURI>GWT_ROOT/dev/oophm/test</locationURI>
+ </link>
+ <link>
+ <name>core/overlay</name>
+ <type>2</type>
+ <locationURI>GWT_ROOT/dev/oophm/overlay</locationURI>
+ </link>
+ </linkedResources>
+</projectDescription>
diff --git a/eclipse/dev/linux/.project b/eclipse/dev/linux/.project
deleted file mode 100644
index 4f73f6e..0000000
--- a/eclipse/dev/linux/.project
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>gwt-dev-linux</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>linux</name>
- <type>2</type>
- <location>GWT_ROOT/dev/linux</location>
- </link>
- <link>
- <name>core</name>
- <type>2</type>
- <location>GWT_ROOT/dev/core</location>
- </link>
- </linkedResources>
-</projectDescription>
diff --git a/eclipse/dev/mac/.checkstyle b/eclipse/dev/mac/.checkstyle
deleted file mode 100644
index d7aff3c..0000000
--- a/eclipse/dev/mac/.checkstyle
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<fileset-config file-format-version="1.2.0" simple-config="false">
- <fileset name="all" enabled="true" check-config-name="GWT Checks" local="false">
- <file-match-pattern match-pattern="core[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/].*\.java$" include-pattern="true"/>
- <file-match-pattern match-pattern="core[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/]dev[\\/]asm[\\/]" include-pattern="false"/>
- <file-match-pattern match-pattern="core[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/]dev[\\/]js[\\/]rhino[\\/]" include-pattern="false"/>
- <file-match-pattern match-pattern="mac[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/].*\.java$" include-pattern="true"/>
- </fileset>
- <filter name="NonSrcDirs" enabled="true"/>
-</fileset-config>
diff --git a/eclipse/dev/mac/.classpath b/eclipse/dev/mac/.classpath
deleted file mode 100644
index c713315..0000000
--- a/eclipse/dev/mac/.classpath
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="core/src"/>
- <classpathentry kind="src" path="core/test"/>
- <classpathentry kind="src" path="mac/src"/>
- <classpathentry excluding="com/google/gwt/dev/jjs/intrinsic/" kind="src" path="core/super"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/org.eclipse.swt.carbon-macosx-3.2.1.jar" sourcepath="/GWT_TOOLS/lib/eclipse/org.eclipse.swt.carbon-macosx-3.2.1.src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/apache/ant-1.6.5.jar" sourcepath="/GWT_TOOLS/lib/apache/ant-1.6.5-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2.jar" sourcepath="/GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdt-3.4.2.jar" sourcepath="/GWT_TOOLS/lib/eclipse/jdt-3.4.2-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/jetty/jetty-6.1.11.jar" sourcepath="/GWT_TOOLS/lib/jetty/jetty-6.1.11-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/junit/junit-3.8.1.jar" sourcepath="/GWT_TOOLS/lib/junit/junit-3.8.1-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/ant-launcher-1.6.5.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/catalina-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/catalina-optional-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-beanutils-1.6.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-collections-3.1.jar" sourcepath="/GWT_TOOLS/lib/tomcat/commons-collections-3.1-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-digester-1.5.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-el-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-logging-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-modeler-1.1.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jakarta-regexp-1.3.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jasper-compiler-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jasper-runtime-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jsp-api-2.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/mx4j-jmx-1.1.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-common-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-factory-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-java-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-resources-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlet-api-2.5.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlet-api-2.4.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-common-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-default-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-invoker-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-coyote-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-http11-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-jk2-2.1.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-util-5.1.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/eclipse/dev/mac/.project b/eclipse/dev/mac/.project
deleted file mode 100644
index 0aa2722..0000000
--- a/eclipse/dev/mac/.project
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>gwt-dev-mac</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>core</name>
- <type>2</type>
- <location>GWT_ROOT/dev/core</location>
- </link>
- <link>
- <name>mac</name>
- <type>2</type>
- <location>GWT_ROOT/dev/mac</location>
- </link>
- </linkedResources>
-</projectDescription>
diff --git a/eclipse/dev/windows/.checkstyle b/eclipse/dev/windows/.checkstyle
deleted file mode 100644
index 7699b83..0000000
--- a/eclipse/dev/windows/.checkstyle
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<fileset-config file-format-version="1.2.0" simple-config="false">
- <fileset name="all" enabled="true" check-config-name="GWT Checks" local="false">
- <file-match-pattern match-pattern="core[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/].*\.java$" include-pattern="true"/>
- <file-match-pattern match-pattern="core[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/]dev[\\/]asm[\\/]" include-pattern="false"/>
- <file-match-pattern match-pattern="core[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/]dev[\\/]js[\\/]rhino[\\/]" include-pattern="false"/>
- <file-match-pattern match-pattern="windows[\\/]src[\\/]com[\\/]google[\\/]gwt[\\/].*\.java$" include-pattern="true"/>
- </fileset>
- <filter name="NonSrcDirs" enabled="true"/>
-</fileset-config>
diff --git a/eclipse/dev/windows/.classpath b/eclipse/dev/windows/.classpath
deleted file mode 100644
index 5a6ea2a..0000000
--- a/eclipse/dev/windows/.classpath
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="core/src"/>
- <classpathentry kind="src" path="core/test"/>
- <classpathentry kind="src" path="windows/src"/>
- <classpathentry excluding="com/google/gwt/dev/jjs/intrinsic/" kind="src" path="core/super"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/org.eclipse.swt.win32-win32-3.2.1.jar" sourcepath="/GWT_TOOLS/lib/eclipse/org.eclipse.swt.win32-win32-3.2.1.src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/apache/ant-1.6.5.jar" sourcepath="/GWT_TOOLS/lib/apache/ant-1.6.5-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2.jar" sourcepath="/GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdt-3.4.2.jar" sourcepath="/GWT_TOOLS/lib/eclipse/jdt-3.4.2-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/jetty/jetty-6.1.11.jar" sourcepath="/GWT_TOOLS/lib/jetty/jetty-6.1.11-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/junit/junit-3.8.1.jar" sourcepath="/GWT_TOOLS/lib/junit/junit-3.8.1-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/ant-launcher-1.6.5.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/catalina-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/catalina-optional-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-beanutils-1.6.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-collections-3.1.jar" sourcepath="/GWT_TOOLS/lib/tomcat/commons-collections-3.1-src.zip"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-digester-1.5.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-el-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-logging-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-modeler-1.1.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jakarta-regexp-1.3.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jasper-compiler-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jasper-runtime-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/jsp-api-2.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/mx4j-jmx-1.1.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-common-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-factory-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-java-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/naming-resources-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlet-api-2.5.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlet-api-2.4.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-common-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-default-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlets-invoker-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-coyote-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-http11-1.0.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-jk2-2.1.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-util-5.1.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/eclipse/dev/windows/.project b/eclipse/dev/windows/.project
deleted file mode 100644
index 1e51a22..0000000
--- a/eclipse/dev/windows/.project
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>gwt-dev-windows</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>windows</name>
- <type>2</type>
- <location>GWT_ROOT/dev/windows</location>
- </link>
- <link>
- <name>core</name>
- <type>2</type>
- <location>GWT_ROOT/dev/core</location>
- </link>
- </linkedResources>
-</projectDescription>
diff --git a/eclipse/doc/.project b/eclipse/doc/.project
index 6b3709c..8634a60 100644
--- a/eclipse/doc/.project
+++ b/eclipse/doc/.project
@@ -18,7 +18,7 @@
<link>
<name>core</name>
<type>2</type>
- <location>GWT_ROOT/doc</location>
+ <locationURI>GWT_ROOT/doc</locationURI>
</link>
</linkedResources>
</projectDescription>
diff --git a/eclipse/samples/I18N/.project b/eclipse/samples/I18N/.project
index d1230cb..0f52eed 100644
--- a/eclipse/samples/I18N/.project
+++ b/eclipse/samples/I18N/.project
@@ -24,7 +24,7 @@
<link>
<name>core</name>
<type>2</type>
- <location>GWT_ROOT/samples/i18n</location>
+ <locationURI>GWT_ROOT/samples/i18n</locationURI>
</link>
</linkedResources>
</projectDescription>
diff --git a/eclipse/samples/Showcase/.classpath b/eclipse/samples/Showcase/.classpath
index 9ced56b..c904bcf 100644
--- a/eclipse/samples/Showcase/.classpath
+++ b/eclipse/samples/Showcase/.classpath
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="core/src"/>
- <classpathentry kind="src" output="war" path="core/war"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/gwt-dev"/>
<classpathentry combineaccessrules="false" kind="src" path="/gwt-user"/>
- <classpathentry combineaccessrules="false" kind="src" path="/gwt-dev-windows"/>
- <classpathentry kind="output" path="war/WEB-INF/classes"/>
+ <classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/samples/Showcase/Showcase-gwtc.launch b/eclipse/samples/Showcase/Showcase-gwtc.launch
index cc73877..4dafdd7 100644
--- a/eclipse/samples/Showcase/Showcase-gwtc.launch
+++ b/eclipse/samples/Showcase/Showcase-gwtc.launch
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/gwt-dev-linux/core/src/com/google/gwt/dev/Compiler.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="Showcase" path="1" type="4"/> "/>
diff --git a/eclipse/samples/Showcase/Showcase.launch b/eclipse/samples/Showcase/Showcase.launch
index 7c7f985..fb5ffcd 100644
--- a/eclipse/samples/Showcase/Showcase.launch
+++ b/eclipse/samples/Showcase/Showcase.launch
@@ -1,13 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/gwt-dev/core/overlay/com/google/gwt/dev/HostedMode.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="Showcase" path="1" type="4"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/Showcase/core/src" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/src" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/super" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-dev-windows/core/super" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="Showcase"/> </runtimeClasspathEntry> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="Showcase" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/Showcase/core/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/super" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-dev/core/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-dev/core/super" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="Showcase"/> </runtimeClasspathEntry> "/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.HostedMode"/>
diff --git a/eclipse/servlet/.classpath b/eclipse/servlet/.classpath
index 918629d..3b49c80 100644
--- a/eclipse/servlet/.classpath
+++ b/eclipse/servlet/.classpath
@@ -4,5 +4,7 @@
<classpathentry excluding="**/rebind/|**/tools/|com/google/gwt/json/|com/google/gwt/junit/*.java|com/google/gwt/junit/benchmarks/|com/google/gwt/junit/client/Benchmark.java|com/google/gwt/junit/client/GWTTestCase.java|com/google/gwt/junit/remote/|com/google/gwt/junit/server/" kind="src" path="core/src"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/junit/junit-3.8.1.jar" sourcepath="/GWT_TOOLS/lib/junit/junit-3.8.1-src.zip"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/servlet-api-2.4.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/gwt-dev-linux"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/gwt-user"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/servlet/.project b/eclipse/servlet/.project
index 6f52bb3..e5a773f 100644
--- a/eclipse/servlet/.project
+++ b/eclipse/servlet/.project
@@ -18,7 +18,7 @@
<link>
<name>core</name>
<type>2</type>
- <location>GWT_ROOT/user</location>
+ <locationURI>GWT_ROOT/user</locationURI>
</link>
</linkedResources>
</projectDescription>
diff --git a/eclipse/user/.classpath b/eclipse/user/.classpath
index 35baf69..6a60584 100644
--- a/eclipse/user/.classpath
+++ b/eclipse/user/.classpath
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="core/src"/>
+ <classpathentry kind="src" path="core/test_i18n_dollar"/>
+ <classpathentry kind="src" path="core/test_i18n_bar"/>
<classpathentry kind="src" path="core/javadoc"/>
<classpathentry kind="src" path="core/test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
@@ -13,18 +15,17 @@
<classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-lang-2.4.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/commons-logging-1.0.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-io-1.4.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/cssparser/cssparser-0.9.5.jar" />
- <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-2.5.jar" />
- <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-core-js-2.5.jar" />
- <classpathentry kind="var" path="GWT_TOOLS/lib/nekohtml/nekohtml-1.9.12.jar" />
+ <classpathentry kind="var" path="GWT_TOOLS/lib/cssparser/cssparser-0.9.5.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/nekohtml/nekohtml-1.9.12.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/selenium/selenium-java-client-driver.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/xalan/xalan-2.7.1.jar" />
- <classpathentry kind="var" path="GWT_TOOLS/lib/xerces/xerces-2_9_1/serializer.jar" />
- <classpathentry kind="var" path="GWT_TOOLS/lib/xerces/xerces-2_9_1/xercesImpl-NoMetaInf.jar" />
- <classpathentry kind="var" path="GWT_TOOLS/lib/xerces/xerces-2_9_1/xml-apis.jar" />
+ <classpathentry kind="var" path="GWT_TOOLS/lib/xalan/xalan-2.7.1.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/xerces/xerces-2_9_1/serializer.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/xerces/xerces-2_9_1/xercesImpl-NoMetaInf.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/xerces/xerces-2_9_1/xml-apis.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/w3c/sac/sac-1.3.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/w3c/flute/flute-1.3.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/gwt-dev-oophm"/>
- <classpathentry combineaccessrules="false" kind="src" path="/gwt-dev-windows"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/gwt-dev"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-2.5.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-2.5-sources.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-core-js-2.5.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-core-js-2.5-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/platforms.ant.xml b/platforms.ant.xml
index 7f8c32e..72a03c9 100755
--- a/platforms.ant.xml
+++ b/platforms.ant.xml
@@ -1,10 +1,6 @@
<project name="platforms">
<import file="${gwt.root}/common.ant.xml" />
- <condition property="oophm.exists" value="true">
- <available file="oophm" />
- </condition>
-
<!-- "build" is the default when subprojects are directly targetted -->
<property name="target" value="build" />
@@ -13,24 +9,7 @@
<gwt.ant dir="core" />
</target>
- <target name="linux" depends="core" description="Run linux">
- <gwt.ant dir="linux" />
- </target>
-
- <target name="oophm" depends="core" description="OOPHM overlay"
- if="oophm.exists">
- <gwt.ant dir="oophm" />
- </target>
-
- <target name="windows" depends="core" description="Run windows">
- <gwt.ant dir="windows" />
- </target>
-
- <target name="mac" depends="core" description="Run mac">
- <gwt.ant dir="mac" />
- </target>
-
- <target name="-do" depends="linux, windows, mac, oophm" description="Run all platforms" />
+ <target name="-do" depends="core" description="Run all platforms" />
<target name="build" description="Build each platforms">
<antcall target="-do">
diff --git a/samples/common.ant.xml b/samples/common.ant.xml
index b540783..fcf8035 100755
--- a/samples/common.ant.xml
+++ b/samples/common.ant.xml
@@ -15,8 +15,7 @@
<property name="sample.upper" value="${sample.module}" />
<property.ensure name="gwt.user.jar" location="${gwt.build.lib}/gwt-user.jar" />
- <!-- Platform shouldn't matter here, just picking one -->
- <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-${build.host.platform}.jar" />
+ <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev.jar" />
<!-- Mirror directory for scripts; makes building distro easier -->
<property name="samples.scripts" value="${gwt.build.out}/samples-scripts" />
diff --git a/tools/api-checker/build.xml b/tools/api-checker/build.xml
index f7998b5..2a99552 100755
--- a/tools/api-checker/build.xml
+++ b/tools/api-checker/build.xml
@@ -8,8 +8,7 @@
<property name="gwt.junit.testcase.apichecker.includes" value="**/*Test.class" />
<property name="gwt.junit.testcase.apichecker.excludes" value="" />
- <!-- Platform shouldn't matter here, just picking one -->
- <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-${build.host.platform}.jar" />
+ <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev.jar" />
<property.ensure name="gwt.user.jar" location="${gwt.build.lib}/gwt-user.jar" />
<target name="compile" description="Compile all class files">
diff --git a/tools/benchmark-viewer/build.xml b/tools/benchmark-viewer/build.xml
index af933eb..788b090 100755
--- a/tools/benchmark-viewer/build.xml
+++ b/tools/benchmark-viewer/build.xml
@@ -15,7 +15,7 @@
<import file="${gwt.root}/common.ant.xml" />
<!-- Platform shouldn't matter here, just picking one -->
- <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-${build.host.platform}.jar" />
+ <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev.jar" />
<property.ensure name="gwt.user.jar" location="${gwt.build.lib}/gwt-user.jar" />
<property.ensure name="gwt.servlet.jar" location="${gwt.build.lib}/gwt-servlet.jar" />
diff --git a/tools/soyc-vis/build.xml b/tools/soyc-vis/build.xml
index d6d4caa..51b8833 100644
--- a/tools/soyc-vis/build.xml
+++ b/tools/soyc-vis/build.xml
@@ -6,8 +6,7 @@
<property name="project.tail" value="tools/soyc-vis" />
<import file="${gwt.root}/common.ant.xml" />
- <!-- Platform shouldn't matter here, just picking one -->
- <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-${build.host.platform}.jar" />
+ <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev.jar" />
<target name="clean">
<delete dir="build"/>
diff --git a/user/build.xml b/user/build.xml
index 87bf4c8..27f2272 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -37,7 +37,7 @@
</path>
<!-- Platform shouldn't matter here, just picking one -->
- <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-${build.host.platform}.jar" />
+ <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev.jar" />
<target name="compile" description="Compile all class files">
<mkdir dir="${javac.out}" />
@@ -49,7 +49,6 @@
<pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
<pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
<pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3.jar" />
- <pathelement location="${gwt.build.lib}/gwt-dev-oophm.jar" />
<pathelement location="${gwt.dev.jar}" />
</classpath>
</gwt.javac>
@@ -108,7 +107,7 @@
<target name="test.remoteweb" description="Run a remoteweb test at the given host and path" if="gwt.remote.browsers">
<echo message="Performing remote browser testing at ${gwt.remote.browsers}" />
<fileset id="test.remoteweb.tests" dir="${javac.junit.out}" includes="${gwt.junit.testcase.web.includes}" excludes="${gwt.junit.testcase.web.excludes}" />
- <gwt.junit test.args="${test.args} -out www -remoteweb ${gwt.remote.browsers} -batch module" test.out="${junit.out}/remoteweb" test.cases="test.remoteweb.tests" >
+ <gwt.junit test.args="${test.args} -out www -runStyle RemoteWeb:${gwt.remote.browsers} -batch module" test.out="${junit.out}/remoteweb" test.cases="test.remoteweb.tests" >
<extraclasspaths>
<path refid="test.extraclasspath" />
</extraclasspaths>
@@ -122,7 +121,7 @@
<target name="test.selenium" description="Run a remote test using Selenium RC test at the given host and path" if="gwt.selenium.hosts">
<echo message="Performing remote browser testing using Selenium RC at ${gwt.selenium.hosts}" />
<fileset id="test.selenium.tests" dir="${javac.junit.out}" includes="${gwt.junit.testcase.web.includes}" excludes="${gwt.junit.testcase.web.excludes}" />
- <gwt.junit test.args="${test.args} -out www -selenium ${gwt.selenium.hosts} -batch module" test.out="${junit.out}/selenium" test.cases="test.selenium.tests" >
+ <gwt.junit test.args="${test.args} -out www -runStyle Selenium:${gwt.selenium.hosts} -batch module" test.out="${junit.out}/selenium" test.cases="test.selenium.tests" >
<extraclasspaths>
<path refid="test.extraclasspath" />
</extraclasspaths>
@@ -157,7 +156,7 @@
<target name="test.noserver" depends="compile, compile.tests" description="Run noserver hosted-mode tests for this project.">
<fileset id="test.noserver.tests" dir="${javac.junit.out}" includes="${gwt.junit.testcase.noserver.includes}" excludes="${gwt.junit.testcase.noserver.excludes}" />
- <gwt.junit test.args="${test.args} -noserver -batch module" test.out="${junit.out}/${build.host.platform}-noserver-mode" test.cases="test.noserver.tests">
+ <gwt.junit test.args="${test.args} -web -noserver -batch module" test.out="${junit.out}/${build.host.platform}-noserver-mode" test.cases="test.noserver.tests">
<extraclasspaths>
<path refid="test.extraclasspath" />
</extraclasspaths>
@@ -173,16 +172,6 @@
</gwt.junit>
</target>
- <target name="test.web.htmlunit" depends="compile, compile.tests" description="Run htmlunit web-mode tests for this project.">
- <!-- TODO: add more browsers later -->
- <fileset id="test.web.htmlunit.tests" dir="${javac.junit.out}" includes="${gwt.junit.testcase.web.includes}" excludes="${gwt.junit.testcase.web.excludes}" />
- <gwt.junit test.args="${test.args} -htmlunit FF3" test.out="${junit.out}/${build.host.platform}-htmlunit-web-mode" test.cases="test.web.htmlunit.tests" >
- <extraclasspaths>
- <path refid="test.extraclasspath" />
- </extraclasspaths>
- </gwt.junit>
- </target>
-
<target name="test.web.disableClassMetadata" depends="compile, compile.tests" description="Run only web-mode tests for this project.">
<fileset id="test.web.disableClassMetadata.tests" dir="${javac.junit.out}" includes="${gwt.junit.testcase.web.includes}" excludes="${gwt.junit.testcase.web.excludes}" />
<gwt.junit test.args="${test.args} -XdisableClassMetadata -out www -web -batch module" test.out="${junit.out}/${build.host.platform}-web-mode-disableClassMetadata" test.cases="test.web.disableClassMetadata.tests" >
diff --git a/user/src/com/google/gwt/i18n/tools/I18NCreator.java b/user/src/com/google/gwt/i18n/tools/I18NCreator.java
index 96f2d23..5d5c582 100755
--- a/user/src/com/google/gwt/i18n/tools/I18NCreator.java
+++ b/user/src/com/google/gwt/i18n/tools/I18NCreator.java
@@ -133,7 +133,7 @@
// Figure out the installation directory
String installPath = Utility.getInstallPath();
String gwtUserPath = installPath + '/' + "gwt-user.jar";
- String gwtDevPath = installPath + '/' + Utility.getDevJarName();
+ String gwtDevPath = installPath + '/' + "gwt-dev.jar";
// Figure out what platform we're on
//
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index 22c28e1..43e8779 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -35,7 +35,6 @@
import com.google.gwt.junit.client.impl.GWTRunner;
import com.google.gwt.junit.client.impl.JUnitResult;
import com.google.gwt.junit.client.impl.JUnitHost.TestInfo;
-import com.google.gwt.util.tools.ArgHandler;
import com.google.gwt.util.tools.ArgHandlerFlag;
import com.google.gwt.util.tools.ArgHandlerString;
@@ -43,8 +42,11 @@
import junit.framework.TestCase;
import junit.framework.TestResult;
-import java.awt.GraphicsEnvironment;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
@@ -98,6 +100,7 @@
void processResult(TestCase testCase, JUnitResult result);
}
+ @SuppressWarnings("deprecation")
class ArgProcessor extends GWTShell.ArgProcessor {
public ArgProcessor() {
@@ -111,6 +114,14 @@
}
});
+ // Override port to set auto by default.
+ registerHandler(new ArgHandlerPortHosted(options) {
+ @Override
+ public String[] getDefaultArgs() {
+ return new String[] {"-portHosted", "auto"};
+ }
+ });
+
// Override log level to set WARN by default..
registerHandler(new ArgHandlerLogLevel(options) {
@Override
@@ -132,8 +143,7 @@
@Override
public boolean setFlag() {
- runStyle = new RunStyleNoServerHosted(JUnitShell.this);
- numClients = 1;
+ shouldAutoGenerateResources = false;
return true;
}
});
@@ -151,8 +161,7 @@
@Override
public boolean setFlag() {
- runStyle = new RunStyleLocalWeb(JUnitShell.this);
- numClients = 1;
+ developmentMode = false;
return true;
}
});
@@ -160,144 +169,65 @@
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
- return "Runs web mode via RMI to a set of BrowserManagerServers; "
- + "e.g. rmi://localhost/ie6,rmi://localhost/firefox";
+ return "Selects the runstyle to use for this test. The name is "
+ + "a suffix of com.google.gwt.junit.RunStyle or is a fully "
+ + "qualified class name, and may be followed with a colon and "
+ + "an argument for this runstyle.";
}
@Override
public String getTag() {
- return "-remoteweb";
+ return "-runStyle";
}
@Override
public String[] getTagArgs() {
- return new String[] {"rmiUrl"};
+ return new String[] {"runstyle[:args]"};
}
@Override
public boolean isUndocumented() {
- return true;
+ return false;
}
@Override
- public boolean setString(String str) {
- String[] urls = str.split(",");
- runStyle = RunStyleRemoteWeb.create(JUnitShell.this, urls);
- numClients = urls.length;
- return runStyle != null;
- }
- });
-
- registerHandler(new ArgHandlerString() {
- @Override
- public String getPurpose() {
- return "Runs web mode via HTTP to a set of Selenium servers; "
- + "e.g. localhost:4444/*firefox,remotehost:4444/*iexplore";
- }
-
- @Override
- public String getTag() {
- return "-selenium";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"seleniumHost"};
- }
-
- @Override
- public boolean setString(String str) {
- String[] targets = str.split(",");
- numClients = targets.length;
- runStyle = RunStyleSelenium.create(JUnitShell.this, targets);
- return runStyle != null;
- }
- });
-
- registerHandler(new ArgHandlerString() {
- @Override
- public String getPurpose() {
- return "Runs hosted mode via HTMLUnit given a list of browsers; "
- + "e.g. IE6,IE7,FF2,FF3...";
- }
-
- @Override
- public String getTag() {
- return "-htmlunithosted";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"browserNames"};
- }
-
- @Override
- public boolean setString(String str) {
- String[] targets = str.split(",");
- runStyle = new RunStyleHtmlUnitHosted(JUnitShell.this, targets);
- numClients = ((RunStyleHtmlUnit) runStyle).numBrowsers();
- return runStyle != null;
- }
- });
-
- registerHandler(new ArgHandlerString() {
- @Override
- public String getPurpose() {
- return "Runs web mode via HTMLUnit given a list of browsers; "
- + "e.g. " + RunStyleHtmlUnit.getBrowserList();
- }
-
- @Override
- public String getTag() {
- return "-htmlunit";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"browserNames"};
- }
-
- @Override
- public boolean setString(String str) {
- String[] targets = str.split(",");
- try {
- runStyle = new RunStyleHtmlUnit(JUnitShell.this, targets);
- numClients = ((RunStyleHtmlUnit) runStyle).numBrowsers();
- return true;
- } catch (IllegalArgumentException ex) {
- System.err.println(ex.getMessage());
- return false;
+ public boolean setString(String runStyleArg) {
+ String runStyleName = runStyleArg;
+ String args = null;
+ int colon = runStyleArg.indexOf(':');
+ if (colon >= 0) {
+ runStyleName = runStyleArg.substring(0, colon);
+ args = runStyleArg.substring(colon + 1);
}
- }
- });
-
- registerHandler(new ArgHandlerString() {
- @Override
- public String getPurpose() {
- return "Run external browsers in web mode (pass a comma separated list of executables.)";
- }
-
- @Override
- public String getTag() {
- return "-externalbrowser";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"browserPaths"};
- }
-
- @Override
- public boolean isUndocumented() {
- return true;
- }
-
- @Override
- public boolean setString(String str) {
- String[] paths = str.split(",");
- runStyle = new RunStyleExternalBrowser(JUnitShell.this, paths);
- numClients = paths.length;
- return runStyle != null;
+ if (runStyleName.indexOf('.') < 0) {
+ runStyleName = RunStyle.class.getName() + runStyleName;
+ }
+ Throwable caught = null;
+ try {
+ Class<?> clazz = Class.forName(runStyleName);
+ Class<? extends RunStyle> runStyleClass = clazz.asSubclass(
+ RunStyle.class);
+ Constructor<? extends RunStyle> ctor = runStyleClass.getConstructor(
+ JUnitShell.class);
+ runStyle = ctor.newInstance(JUnitShell.this);
+ return runStyle.initialize(args);
+ } catch (ClassNotFoundException e) {
+ caught = e;
+ } catch (SecurityException e) {
+ caught = e;
+ } catch (NoSuchMethodException e) {
+ caught = e;
+ } catch (IllegalArgumentException e) {
+ caught = e;
+ } catch (InstantiationException e) {
+ caught = e;
+ } catch (IllegalAccessException e) {
+ caught = e;
+ } catch (InvocationTargetException e) {
+ caught = e;
+ }
+ throw new RuntimeException("Unable to create runStyle " + runStyleArg,
+ caught);
}
});
@@ -332,52 +262,6 @@
}
});
- registerHandler(new ArgHandler() {
- @Override
- public String[] getDefaultArgs() {
- return null;
- }
-
- @Override
- public String getPurpose() {
- return "Causes the system to wait for a remote browser to connect";
- }
-
- @Override
- public String getTag() {
- return "-manual";
- }
-
- @Override
- public String[] getTagArgs() {
- return new String[] {"[numClients]"};
- }
-
- @Override
- public int handle(String[] args, int tagIndex) {
- int value = 1;
- if (tagIndex + 1 < args.length) {
- try {
- // See if the next item is an integer.
- value = Integer.parseInt(args[tagIndex + 1]);
- if (value >= 1) {
- setInt(value);
- return 1;
- }
- } catch (NumberFormatException e) {
- // fall-through
- }
- }
- setInt(1);
- return 0;
- }
-
- public void setInt(int value) {
- runStyle = new RunStyleManual(JUnitShell.this, value);
- numClients = value;
- }
- });
-
registerHandler(new ArgHandlerFlag() {
@Override
public String getPurpose() {
@@ -417,12 +301,6 @@
private static final String PROP_GWT_ARGS = "gwt.args";
/**
- * This legacy system property, when set, causes us to run in web mode.
- * (Superceded by passing "-web" into gwt.args).
- */
- private static final String PROP_JUNIT_HYBRID_MODE = "gwt.hybrid";
-
- /**
* The amount of time to wait for all clients to have contacted the server and
* begin running the test. "Contacted" does not necessarily mean "the test has
* begun," e.g. for linker errors stopping the test initialization.
@@ -524,6 +402,7 @@
if (!argProcessor.processArgs(args)) {
throw new JUnitFatalLaunchException("Error processing shell arguments");
}
+ unitTestShell.finalizeArguments();
unitTestShell.messageQueue = new JUnitMessageQueue(
unitTestShell.numClients);
@@ -588,7 +467,12 @@
/**
* What type of test we're running; Local hosted, local web, or remote web.
*/
- private RunStyle runStyle = new RunStyleLocalHosted(this);
+ private RunStyle runStyle = null;
+
+ /**
+ * True if we are running the test in hosted mode
+ */
+ private boolean developmentMode = true;
/**
* The time the test actually began.
@@ -611,17 +495,28 @@
private Map<TestInfo, Map<String, JUnitResult>> cachedResults = new HashMap<TestInfo, Map<String, JUnitResult>>();
+ private boolean shouldAutoGenerateResources = true;
+
/**
* Enforce the singleton pattern. The call to {@link GWTShell}'s ctor forces
* server mode and disables processing extra arguments as URLs to be shown.
*/
private JUnitShell() {
setRunTomcat(true);
- setHeadless(GraphicsEnvironment.isHeadless());
+ setHeadless(true);
+ }
- // Legacy: -Dgwt.hybrid runs web mode
- if (System.getProperty(PROP_JUNIT_HYBRID_MODE) != null) {
- runStyle = new RunStyleLocalWeb(this);
+ public String getModuleUrl(String moduleName) {
+ try {
+ String localhost = InetAddress.getLocalHost().getHostAddress();
+ String url = "http://" + localhost + ":" + getPort() + "/"
+ + moduleName + "/junit.html";
+ if (developmentMode) {
+ url += "?gwt.hosted=localhost:" + codeServerPort;
+ }
+ return url;
+ } catch (UnknownHostException e) {
+ throw new RuntimeException("Unable to determine my ip address", e);
}
}
@@ -643,6 +538,21 @@
}
@Override
+ protected boolean doStartup() {
+ // TODO(jat): refactor so we can avoid startup up the OOPHM listener if we
+ // aren't running in development mode
+ if (!super.doStartup()) {
+ return false;
+ }
+ if (!runStyle.setupMode(getTopLogger(), developmentMode)) {
+ getTopLogger().log(TreeLogger.ERROR, "Run style does not support "
+ + (developmentMode ? "development" : "production") + " mode");
+ return false;
+ }
+ return true;
+ }
+
+ @Override
protected void initializeLogger() {
if (isHeadless()) {
consoleLogger = new PrintWriterTreeLogger();
@@ -711,9 +621,8 @@
return !messageQueue.hasResult();
}
- // TODO (amitmanjhi): GwtShell overlay fix, removed Override.
protected boolean shouldAutoGenerateResources() {
- return runStyle.shouldAutoGenerateResources();
+ return shouldAutoGenerateResources;
}
void compileForWebMode(String moduleName, String... userAgents)
@@ -734,6 +643,17 @@
}
/**
+ * Finish processing command line arguments.
+ */
+ private void finalizeArguments() {
+ if (runStyle == null) {
+ // Default to HtmlUnit runstyle with no args
+ runStyle = new RunStyleHtmlUnit(this);
+ runStyle.initialize(null);
+ }
+ }
+
+ /**
* returns the set of banned {@code Platform} for a test method.
*/
private Set<Platform> getBannedPlatforms(TestCase testCase) {
@@ -758,7 +678,7 @@
return bannedSet;
}
- private boolean mostNotExecuteTest(Set<Platform> bannedPlatforms) {
+ private boolean mustNotExecuteTest(Set<Platform> bannedPlatforms) {
// TODO (amitmanjhi): Remove this hard-coding. A RunStyle somehow needs to
// specify how it interacts with the platforms.
return runStyle instanceof RunStyleHtmlUnit
@@ -775,7 +695,7 @@
*/
private boolean mustNotExecuteTest(TestCase testCase) {
// TODO: collect stats on tests that were not run
- return mostNotExecuteTest(getBannedPlatforms(testCase));
+ return mustNotExecuteTest(getBannedPlatforms(testCase));
}
private void processTestResult(TestInfo testInfo, TestCase testCase,
@@ -859,7 +779,9 @@
ConfigurationProperty moduleNameProp = currentModule.getProperties().createConfiguration(
"junit.moduleName", false);
moduleNameProp.setValue(moduleName);
- runStyle.maybeCompileModule(syntheticModuleName);
+ if (!developmentMode || !shouldAutoGenerateResources) {
+ compileForWebMode(syntheticModuleName);
+ }
}
JUnitFatalLaunchException launchException = checkTestClassInCurrentModule(
diff --git a/user/src/com/google/gwt/junit/RunStyle.java b/user/src/com/google/gwt/junit/RunStyle.java
index 9757ad4..95fa4f2 100644
--- a/user/src/com/google/gwt/junit/RunStyle.java
+++ b/user/src/com/google/gwt/junit/RunStyle.java
@@ -29,16 +29,29 @@
protected final JUnitShell shell;
/**
+ * Constructor for RunStyle. Any subclass must provide a constructor with
+ * the same signature since this will be how the RunStyle is created via
+ * reflection.
+ *
+ * @param logger TreeLogger instance
* @param shell the containing shell
+ * @param args arguments (after the colon in the argument to -runStyle)
+ * may be null if no argument is supplied
*/
public RunStyle(JUnitShell shell) {
this.shell = shell;
}
/**
- * Returns whether or not the local UI event loop needs to be pumped.
+ * Initialize the runstyle with any supplied arguments.
+ *
+ * @param args arguments passed in -runStyle option, null if none supplied
+ * @return true if this runstyle is initialized successfully, false if it
+ * was unsuccessful
*/
- public abstract boolean isLocal();
+ public boolean initialize(String args) {
+ return true;
+ }
/**
* Requests initial launch of the browser. This should only be called once per
@@ -51,13 +64,17 @@
throws UnableToCompleteException;
/**
- * Possibly causes a compilation on the specified module.
+ * Setup this RunStyle for the selected mode.
*
- * @param moduleName the module to compile
- * @throws UnableToCompleteException
+ * @param logger TreeLogger to use for any messages
+ * @param developmentMode true if we are running in development mode
+ * rather that web/production mode
+ * @return false if we should abort processing due to an unsupported mode
+ * or an error setting up for that mode
*/
- public abstract void maybeCompileModule(String moduleName)
- throws UnableToCompleteException;
+ public boolean setupMode(TreeLogger logger, boolean developmentMode) {
+ return true;
+ }
/**
* Whether the embedded server should ever generate resources. Hosted mode
@@ -84,13 +101,4 @@
return shell.getTopLogger();
}
- /**
- * Gets the suffix of the URL to load.
- *
- * @param moduleName the module to run
- * @return a URL suffix that should be loaded
- */
- protected String getUrlSuffix(String moduleName) {
- return moduleName + "/junit.html";
- }
}
diff --git a/user/src/com/google/gwt/junit/RunStyleExternalBrowser.java b/user/src/com/google/gwt/junit/RunStyleExternalBrowser.java
index e3c1eea..9656891 100644
--- a/user/src/com/google/gwt/junit/RunStyleExternalBrowser.java
+++ b/user/src/com/google/gwt/junit/RunStyleExternalBrowser.java
@@ -45,14 +45,24 @@
}
}
- private final ExternalBrowser[] externalBrowsers;
+ private ExternalBrowser[] externalBrowsers;
/**
* @param shell the containing shell
* @param browsers an array of path names pointing to browser executables.
*/
- public RunStyleExternalBrowser(JUnitShell shell, String browsers[]) {
+ public RunStyleExternalBrowser(JUnitShell shell) {
super(shell);
+ }
+
+ @Override
+ public boolean initialize(String args) {
+ if (args == null || args.length() == 0) {
+ throw new IllegalArgumentException("ExternalBrowser runstyle requires an "
+ + "argument listing one or more executables of external browsers to "
+ + "launch");
+ }
+ String browsers[] = args.split(",");
synchronized (this) {
this.externalBrowsers = new ExternalBrowser[browsers.length];
for (int i = 0; i < browsers.length; ++i) {
@@ -60,11 +70,7 @@
}
}
Runtime.getRuntime().addShutdownHook(new ShutdownCb());
- }
-
- @Override
- public boolean isLocal() {
- return false;
+ return true;
}
@Override
@@ -72,8 +78,7 @@
throws UnableToCompleteException {
String commandArray[] = new String[2];
// construct the URL for the browser to hit
- commandArray[1] = "http://" + "localhost" + ":" + shell.getPort() + "/"
- + getUrlSuffix(moduleName);
+ commandArray[1] = shell.getModuleUrl(moduleName);
Process child = null;
for (ExternalBrowser browser : externalBrowsers) {
@@ -129,11 +134,4 @@
}
}
}
-
- @Override
- public void maybeCompileModule(String moduleName)
- throws UnableToCompleteException {
- shell.compileForWebMode(moduleName, null);
- }
-
}
diff --git a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
index af5c022..dcf5d63 100644
--- a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
+++ b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
@@ -16,7 +16,7 @@
package com.google.gwt.junit;
import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.shell.HostedModePluginObject;
import com.gargoylesoftware.htmlunit.AlertHandler;
import com.gargoylesoftware.htmlunit.BrowserVersion;
@@ -25,7 +25,12 @@
import com.gargoylesoftware.htmlunit.OnbeforeunloadHandler;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
+import com.gargoylesoftware.htmlunit.javascript.host.Window;
+
+import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -40,7 +45,7 @@
/**
* Launches a web-mode test via HTMLUnit.
*/
-public class RunStyleHtmlUnit extends RunStyleRemote {
+public class RunStyleHtmlUnit extends RunStyle {
/**
* Runs HTMLUnit in a separate thread.
@@ -52,13 +57,15 @@
private final String url;
private Object waitForUnload = new Object();
private final TreeLogger treeLogger;
+ private final boolean developmentMode;
public HtmlUnitThread(BrowserVersion browser, String url,
- TreeLogger treeLogger) {
+ TreeLogger treeLogger, boolean developmentMode) {
this.browser = browser;
this.url = url;
this.treeLogger = treeLogger;
this.setName("htmlUnit client thread");
+ this.developmentMode = developmentMode;
}
public void handleAlert(Page page, String message) {
@@ -109,11 +116,34 @@
}
}
- /**
- * Additional setup of the WebClient before starting test. Hook necessary
- * for plugging in HtmlUnitHosted.
- */
protected void setupWebClient(WebClient webClient) {
+ if (developmentMode) {
+ JavaScriptEngine hostedEngine = new HostedJavaScriptEngine(webClient);
+ webClient.setJavaScriptEngine(hostedEngine);
+ }
+ }
+}
+
+ /**
+ * JavaScriptEngine subclass that provides a hook of initializing the
+ * __gwt_HostedModePlugin property on any new window, so it acts just like
+ * Firefox with the XPCOM plugin installed.
+ */
+ private static class HostedJavaScriptEngine extends JavaScriptEngine {
+
+ private static final long serialVersionUID = 3594816610842448691L;
+
+ public HostedJavaScriptEngine(WebClient webClient) {
+ super(webClient);
+ }
+
+ @Override
+ public void initialize(WebWindow webWindow) {
+ // Hook in the hosted-mode plugin after initializing the JS engine.
+ super.initialize(webWindow);
+ Window window = (Window) webWindow.getScriptObject();
+ window.defineProperty("__gwt_HostedModePlugin",
+ new HostedModePluginObject(), ScriptableObject.READONLY);
}
}
@@ -144,21 +174,40 @@
return Collections.unmodifiableMap(browserMap);
}
- private final Set<BrowserVersion> browsers;
+ private Set<BrowserVersion> browsers = new HashSet<BrowserVersion>();
private final List<Thread> threads = new ArrayList<Thread>();
+ private boolean developmentMode;
/**
* Create a RunStyle instance with the passed-in browser targets.
*/
- public RunStyleHtmlUnit(JUnitShell shell, String[] targetsIn) {
+ public RunStyleHtmlUnit(JUnitShell shell) {
super(shell);
- this.browsers = getBrowserSet(targetsIn);
}
-
+
+ @Override
+ public boolean initialize(String args) {
+ if (args == null || args.length() == 0) {
+ // If no browsers specified, default to Firefox 3.
+ args = "FF3";
+ }
+ Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>();
+ for (String browserName : args.split(",")) {
+ BrowserVersion browser = BROWSER_MAP.get(browserName);
+ if (browser == null) {
+ throw new IllegalArgumentException("Expected browser name: one of "
+ + BROWSER_MAP.keySet() + ", actual name: " + browserName);
+ }
+ browserSet.add(browser);
+ }
+ browsers = Collections.unmodifiableSet(browserSet);
+ return true;
+ }
+
@Override
public void launchModule(String moduleName) {
for (BrowserVersion browser : browsers) {
- String url = getMyUrl(moduleName);
+ String url = shell.getModuleUrl(moduleName);
HtmlUnitThread hut = createHtmlUnitThread(browser, url);
shell.getTopLogger().log(TreeLogger.INFO,
"Starting " + url + " on browser " + browser.getNickname());
@@ -171,47 +220,19 @@
}
}
- @Override
- public void maybeCompileModule(String moduleName)
- throws UnableToCompleteException {
- shell.compileForWebMode(moduleName, getUserAgents());
- }
-
public int numBrowsers() {
return browsers.size();
}
+ @Override
+ public boolean setupMode(TreeLogger logger, boolean developmentMode) {
+ this.developmentMode = developmentMode;
+ return true;
+ }
+
protected HtmlUnitThread createHtmlUnitThread(BrowserVersion browser,
String url) {
return new HtmlUnitThread(browser, url, shell.getTopLogger().branch(
- TreeLogger.SPAM, "logging for HtmlUnit thread"));
- }
-
- private Set<BrowserVersion> getBrowserSet(String[] targetsIn) {
- Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>();
- for (String browserName : targetsIn) {
- BrowserVersion browser = BROWSER_MAP.get(browserName);
- if (browser == null) {
- throw new IllegalArgumentException("Expected browser name: one of "
- + BROWSER_MAP.keySet() + ", actual name: " + browserName);
- }
- browserSet.add(browser);
- }
- return Collections.unmodifiableSet(browserSet);
- }
-
- private String[] getUserAgents() {
- Map<BrowserVersion, String> userAgentMap = new HashMap<BrowserVersion, String>();
- userAgentMap.put(BrowserVersion.FIREFOX_2, "gecko1_8");
- userAgentMap.put(BrowserVersion.FIREFOX_3, "gecko");
- userAgentMap.put(BrowserVersion.INTERNET_EXPLORER_6, "ie6");
- userAgentMap.put(BrowserVersion.INTERNET_EXPLORER_7, "ie6");
-
- String userAgents[] = new String[numBrowsers()];
- int index = 0;
- for (BrowserVersion browser : browsers) {
- userAgents[index++] = userAgentMap.get(browser);
- }
- return userAgents;
+ TreeLogger.SPAM, "logging for HtmlUnit thread"), developmentMode);
}
}
diff --git a/user/src/com/google/gwt/junit/RunStyleHtmlUnitHosted.java b/user/src/com/google/gwt/junit/RunStyleHtmlUnitHosted.java
deleted file mode 100644
index 4d14581..0000000
--- a/user/src/com/google/gwt/junit/RunStyleHtmlUnitHosted.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2009 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.junit;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.shell.HostedModePluginObject;
-import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-
-import com.gargoylesoftware.htmlunit.BrowserVersion;
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.WebWindow;
-import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
-import com.gargoylesoftware.htmlunit.javascript.host.Window;
-
-import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
-
-/**
- * Runstyle for HTMLUnit in hosted mode.
- */
-public class RunStyleHtmlUnitHosted extends RunStyleHtmlUnit {
-
- /**
- * Run HMTLUnit in a separate thread, replacing the default JavaScriptEngine
- * with one that has the necessary hosted mode hooks.
- */
- protected static class HtmlUnitHostedThread extends HtmlUnitThread {
-
- public HtmlUnitHostedThread(BrowserVersion browser, String url,
- TreeLogger treeLogger) {
- super(browser, url, treeLogger);
- }
-
- @Override
- protected void setupWebClient(WebClient webClient) {
- JavaScriptEngine hostedEngine = new HostedJavaScriptEngine(webClient);
- webClient.setJavaScriptEngine(hostedEngine);
- }
- }
-
- /**
- * JavaScriptEngine subclass that provides a hook of initializing the
- * __gwt_HostedModePlugin property on any new window, so it acts just like
- * Firefox with the XPCOM plugin installed.
- */
- private static class HostedJavaScriptEngine extends JavaScriptEngine {
-
- private static final long serialVersionUID = 3594816610842448691L;
-
- public HostedJavaScriptEngine(WebClient webClient) {
- super(webClient);
- }
-
- @Override
- public void initialize(WebWindow webWindow) {
- // Hook in the hosted-mode plugin after initializing the JS engine.
- super.initialize(webWindow);
- Window window = (Window) webWindow.getScriptObject();
- window.defineProperty("__gwt_HostedModePlugin",
- new HostedModePluginObject(), ScriptableObject.READONLY);
- }
- }
-
- public static HtmlUnitThread createHtmlUnitThread(BrowserVersion browser,
- String url, TreeLogger treeLogger) {
- return new HtmlUnitHostedThread(browser, url, treeLogger);
- }
-
- public static void startHtmlUnitThread(String url) {
- PrintWriterTreeLogger pw = new PrintWriterTreeLogger();
- // TODO(amitmanjhi): get the correct browser emulation
- HtmlUnitThread thread = createHtmlUnitThread(
- BrowserVersion.FIREFOX_3, url, pw);
- thread.start();
- }
-
- public RunStyleHtmlUnitHosted(JUnitShell unitShell, String[] targets) {
- super(unitShell, targets);
- }
-
- @Override
- public void maybeCompileModule(String moduleName) {
- // No compilation needed for hosted mode
- }
-
- @Override
- protected HtmlUnitThread createHtmlUnitThread(BrowserVersion browser,
- String url) {
- return RunStyleHtmlUnitHosted.createHtmlUnitThread(browser, url,
- shell.getTopLogger());
- }
-
- @Override
- protected String getMyUrl(String moduleName) {
- // TODO(jat): get the correct address/port
- return super.getMyUrl(moduleName) + "?gwt.hosted=localhost:9997";
- }
-}
diff --git a/user/src/com/google/gwt/junit/RunStyleLocalHosted.java b/user/src/com/google/gwt/junit/RunStyleLocalHosted.java
deleted file mode 100644
index 5861c45..0000000
--- a/user/src/com/google/gwt/junit/RunStyleLocalHosted.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.junit;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.shell.BrowserWidget;
-
-/**
- * Runs locally in hosted mode.
- */
-class RunStyleLocalHosted extends RunStyle {
-
- /**
- * A browser window to host local tests.
- */
- private BrowserWidget browserWindow;
-
- RunStyleLocalHosted(JUnitShell shell) {
- super(shell);
- }
-
- @Override
- public boolean isLocal() {
- return true;
- }
-
- @Override
- public void launchModule(String moduleName) throws UnableToCompleteException {
- launchUrl(getUrlSuffix(moduleName));
- }
-
- @Override
- public void maybeCompileModule(String moduleName)
- throws UnableToCompleteException {
- // nothing to do
- }
-
- protected BrowserWidget getBrowserWindow() throws UnableToCompleteException {
- if (browserWindow == null) {
- browserWindow = shell.openNewBrowserWindow();
- }
- return browserWindow;
- }
-
- /**
- * Launches a URL in the browser window.
- *
- * @param url The URL to launch.
- * @throws UnableToCompleteException
- */
- protected void launchUrl(String url) throws UnableToCompleteException {
- getBrowserWindow().go(url);
- }
-}
diff --git a/user/src/com/google/gwt/junit/RunStyleLocalWeb.java b/user/src/com/google/gwt/junit/RunStyleLocalWeb.java
deleted file mode 100644
index 84c9159..0000000
--- a/user/src/com/google/gwt/junit/RunStyleLocalWeb.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.junit;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.shell.BrowserWidget;
-
-/**
- * Runs locally in web mode.
- */
-class RunStyleLocalWeb extends RunStyleLocalHosted {
-
- /**
- * This query parameter forces web mode in a hosted browser.
- */
- private static final String PROP_GWT_HYBRID_MODE = "gwt.hybrid";
-
- /**
- * @param shell the containing shell
- */
- RunStyleLocalWeb(JUnitShell shell) {
- super(shell);
- }
-
- @Override
- public void launchModule(String moduleName) throws UnableToCompleteException {
- launchUrl(getUrlSuffix(moduleName) + "?" + PROP_GWT_HYBRID_MODE);
- }
-
- @Override
- public void maybeCompileModule(String moduleName)
- throws UnableToCompleteException {
- BrowserWidget browserWindow = getBrowserWindow();
- shell.compileForWebMode(moduleName, browserWindow.getUserAgent());
- }
-}
diff --git a/user/src/com/google/gwt/junit/RunStyleManual.java b/user/src/com/google/gwt/junit/RunStyleManual.java
index 1b36d16..f19a739 100644
--- a/user/src/com/google/gwt/junit/RunStyleManual.java
+++ b/user/src/com/google/gwt/junit/RunStyleManual.java
@@ -21,18 +21,26 @@
* Runs in web mode waiting for the user to contact the server with their own
* browser.
*/
-class RunStyleManual extends RunStyleRemote {
+class RunStyleManual extends RunStyle {
- private final int numClients;
+ private int numClients;
- public RunStyleManual(JUnitShell shell, int numClients) {
+ public RunStyleManual(JUnitShell shell) {
super(shell);
- this.numClients = numClients;
}
@Override
- public boolean isLocal() {
- return false;
+ public boolean initialize(String args) {
+ numClients = 1;
+ if (args != null) {
+ try {
+ numClients = Integer.parseInt(args);
+ } catch (NumberFormatException e) {
+ throw new RuntimeException("Error parsing argument \"" + args + "\"",
+ e);
+ }
+ }
+ return true;
}
@Override
@@ -43,14 +51,6 @@
System.out.println("Please navigate " + numClients
+ " browsers to this URL:");
}
- System.out.println(getMyUrl(moduleName));
- }
-
- @Override
- public void maybeCompileModule(String moduleName)
- throws UnableToCompleteException {
- System.out.print("Compiling " + moduleName + "...");
- super.maybeCompileModule(moduleName);
- System.out.println(" success.");
+ System.out.println(shell.getModuleUrl(moduleName));
}
}
diff --git a/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java b/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java
deleted file mode 100644
index 5f54989..0000000
--- a/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.junit;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.shell.BrowserWidget;
-
-/**
- * <p>
- * This run style simulates -noserver hosted mode. It is the same as hosted mode
- * except for two differences:
- * </p>
- *
- * <ol>
- * <li>The program is compiled for web mode.
- * <li>The embedded server does not do any GWT-specific resource generation.
- * </ol>
- *
- * <p>
- * In effect, the built-in web server gets used as a dumb web server to serve up
- * the compiled files.
- * </p>
- */
-public class RunStyleNoServerHosted extends RunStyleLocalHosted {
- RunStyleNoServerHosted(JUnitShell shell) {
- super(shell);
- }
-
- @Override
- public void maybeCompileModule(String moduleName)
- throws UnableToCompleteException {
- BrowserWidget browserWindow = getBrowserWindow();
- shell.compileForWebMode(moduleName, browserWindow.getUserAgent());
- }
-
- @Override
- public boolean shouldAutoGenerateResources() {
- // pretend to be a web server that knows nothing about GWT
- return false;
- }
-}
diff --git a/user/src/com/google/gwt/junit/RunStyleRemote.java b/user/src/com/google/gwt/junit/RunStyleRemote.java
deleted file mode 100644
index 927b303..0000000
--- a/user/src/com/google/gwt/junit/RunStyleRemote.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.junit;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * Runs remotely in web mode. This feature is experimental and is not officially
- * supported.
- */
-abstract class RunStyleRemote extends RunStyle {
-
- public RunStyleRemote(JUnitShell shell) {
- super(shell);
- }
-
- @Override
- public boolean isLocal() {
- return false;
- }
-
- @Override
- public void maybeCompileModule(String moduleName)
- throws UnableToCompleteException {
- shell.compileForWebMode(moduleName, null);
- }
-
- protected String getMyUrl(String moduleName) {
- try {
- String localhost = InetAddress.getLocalHost().getHostAddress();
- return "http://" + localhost + ":" + shell.getPort() + "/"
- + getUrlSuffix(moduleName);
- } catch (UnknownHostException e) {
- throw new RuntimeException("Unable to determine my ip address", e);
- }
- }
-}
diff --git a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
index 6aa714a..e4c61a9 100644
--- a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
+++ b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
@@ -32,7 +32,7 @@
* Runs in web mode via browsers managed over RMI. This feature is experimental
* and is not officially supported.
*/
-class RunStyleRemoteWeb extends RunStyleRemote {
+class RunStyleRemoteWeb extends RunStyle {
static class RMISocketFactoryWithTimeouts extends RMISocketFactory {
private static boolean initialized;
@@ -197,14 +197,9 @@
}
@Override
- public boolean isLocal() {
- return false;
- }
-
- @Override
public synchronized void launchModule(String moduleName)
throws UnableToCompleteException {
- String url = getMyUrl(moduleName);
+ String url = shell.getModuleUrl(moduleName);
for (RemoteBrowser remoteBrowser : remoteBrowsers) {
long callStart = System.currentTimeMillis();
diff --git a/user/src/com/google/gwt/junit/RunStyleSelenium.java b/user/src/com/google/gwt/junit/RunStyleSelenium.java
index c58a6a8..13c7723 100644
--- a/user/src/com/google/gwt/junit/RunStyleSelenium.java
+++ b/user/src/com/google/gwt/junit/RunStyleSelenium.java
@@ -30,7 +30,7 @@
/**
* Runs in web mode via browsers managed by Selenium.
*/
-public class RunStyleSelenium extends RunStyleRemote {
+public class RunStyleSelenium extends RunStyle {
private static class RCSelenium {
final String browser;
@@ -138,11 +138,12 @@
// Startup all the selenia and point them at the module url.
for (RCSelenium remote : remotes) {
try {
+ String url = shell.getModuleUrl(moduleName);
shell.getTopLogger().log(TreeLogger.TRACE,
- "Starting with domain: " + domain + " Opening URL: " + getMyUrl(moduleName));
+ "Starting with domain: " + domain + " Opening URL: " + url);
remote.createSelenium(domain);
remote.getSelenium().start();
- remote.getSelenium().open(getMyUrl(moduleName));
+ remote.getSelenium().open(url);
} catch (Exception e) {
shell.getTopLogger().log(TreeLogger.ERROR,
"Error launching browser via Selenium-RC at " + remote.getHost(), e);
diff --git a/user/src/com/google/gwt/junit/tools/JUnitCreator.java b/user/src/com/google/gwt/junit/tools/JUnitCreator.java
index 2dc7f4c..281a104 100644
--- a/user/src/com/google/gwt/junit/tools/JUnitCreator.java
+++ b/user/src/com/google/gwt/junit/tools/JUnitCreator.java
@@ -132,7 +132,7 @@
// Figure out the installation directory
String installPath = Utility.getInstallPath();
String gwtUserPath = installPath + '/' + "gwt-user.jar";
- String gwtDevPath = installPath + '/' + Utility.getDevJarName();
+ String gwtDevPath = installPath + '/' + "gwt-dev.jar";
// Check to see that the passed extra path/module arguments are valid.
if (!CreatorUtilities.validatePathsAndModules(gwtUserPath, extraClassPaths,
diff --git a/user/src/com/google/gwt/user/tools/WebAppCreator.java b/user/src/com/google/gwt/user/tools/WebAppCreator.java
index 572bef1..b07261a 100644
--- a/user/src/com/google/gwt/user/tools/WebAppCreator.java
+++ b/user/src/com/google/gwt/user/tools/WebAppCreator.java
@@ -213,7 +213,7 @@
// Figure out the installation directory
String installPath = Utility.getInstallPath();
String gwtUserPath = installPath + '/' + "gwt-user.jar";
- String gwtDevPath = installPath + '/' + Utility.getDevJarName();
+ String gwtDevPath = installPath + '/' + "gwt-dev.jar";
String gwtServletPath = installPath + '/' + "gwt-servlet.jar";
String gwtOophmPath = installPath + '/' + "gwt-dev-oophm.jar";