aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schweinsberg <[email protected]>2009-05-22 02:30:27 +0000
committerDavid Schweinsberg <[email protected]>2009-05-22 02:30:27 +0000
commit7905081559e0b4167363bc5c2a7ffc9d3a3b0f0e (patch)
tree1defe0097e8be9346fd03691759f217dbfccb2e4
parentadea4488ba39ab3fd80a9064d1839a998e445b31 (diff)
Modified handling of Mac-specific menus and removed references to Apple packages.
-rw-r--r--nbproject/build-impl.xml449
-rw-r--r--nbproject/genfiles.properties4
-rw-r--r--nbproject/project.properties21
-rw-r--r--src/net/java/dev/typecast/app/editor/EditorMenu.java23
-rw-r--r--src/net/java/dev/typecast/app/editor/MacOSMenuHandler.java56
-rw-r--r--src/net/java/dev/typecast/app/editor/Main.java12
-rw-r--r--src/net/java/dev/typecast/app/editor/OSXAdapter.java207
7 files changed, 529 insertions, 243 deletions
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
index 318b453..c1944c3 100644
--- a/nbproject/build-impl.xml
+++ b/nbproject/build-impl.xml
@@ -18,32 +18,35 @@ is divided into following sections:
- applet
- cleanup
--->
-<project name="typecast-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
- <target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
+ -->
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="typecast-impl">
+ <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
<!--
- ======================
- INITIALIZATION SECTION
- ======================
- -->
+ ======================
+ INITIALIZATION SECTION
+ ======================
+ -->
<target name="-pre-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-init-private" depends="-pre-init">
+ <target depends="-pre-init" name="-init-private">
+ <property file="nbproject/private/config.properties"/>
+ <property file="nbproject/private/configs/${config}.properties"/>
<property file="nbproject/private/private.properties"/>
</target>
- <target name="-init-user" depends="-pre-init,-init-private">
+ <target depends="-pre-init,-init-private" name="-init-user">
<property file="${user.properties.file}"/>
<!-- The two properties below are usually overridden -->
<!-- by the active platform. Just a fallback. -->
<property name="default.javac.source" value="1.4"/>
<property name="default.javac.target" value="1.4"/>
</target>
- <target name="-init-project" depends="-pre-init,-init-private,-init-user">
+ <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+ <property file="nbproject/configs/${config}.properties"/>
<property file="nbproject/project.properties"/>
</target>
- <target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
<available file="${manifest.file}" property="manifest.available"/>
<condition property="manifest.available+main.class">
<and>
@@ -77,7 +80,10 @@ is divided into following sections:
</and>
</condition>
<condition property="no.javadoc.preview">
- <isfalse value="${javadoc.preview}"/>
+ <and>
+ <isset property="javadoc.preview"/>
+ <isfalse value="${javadoc.preview}"/>
+ </and>
</condition>
<property name="run.jvmargs" value=""/>
<property name="javac.compilerargs" value=""/>
@@ -89,12 +95,35 @@ is divided into following sections:
</condition>
<property name="javac.debug" value="true"/>
<property name="javadoc.preview" value="true"/>
+ <property name="application.args" value=""/>
+ <property name="source.encoding" value="${file.encoding}"/>
+ <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+ <and>
+ <isset property="javadoc.encoding"/>
+ <not>
+ <equals arg1="${javadoc.encoding}" arg2=""/>
+ </not>
+ </and>
+ </condition>
+ <property name="javadoc.encoding.used" value="${source.encoding}"/>
+ <property name="includes" value="**"/>
+ <property name="excludes" value=""/>
+ <property name="do.depend" value="false"/>
+ <condition property="do.depend.true">
+ <istrue value="${do.depend}"/>
+ </condition>
+ <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
+ <and>
+ <isset property="jaxws.endorsed.dir"/>
+ <available file="nbproject/jaxws-build.xml"/>
+ </and>
+ </condition>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
<fail unless="src.dir">Must set src.dir</fail>
<fail unless="test.src.dir">Must set test.src.dir</fail>
<fail unless="build.dir">Must set build.dir</fail>
@@ -117,36 +146,70 @@ is divided into following sections:
</target>
<target name="-init-macrodef-javac">
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute name="srcdir" default="${src.dir}"/>
- <attribute name="destdir" default="${build.classes.dir}"/>
- <attribute name="classpath" default="${javac.classpath}"/>
- <attribute name="debug" default="${javac.debug}"/>
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}" name="classpath"/>
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="${javac.debug}" name="debug"/>
+ <attribute default="/does/not/exist" name="sourcepath"/>
<element name="customize" optional="true"/>
<sequential>
- <javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
<classpath>
<path path="@{classpath}"/>
</classpath>
- <compilerarg line="${javac.compilerargs}"/>
+ <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
<customize/>
</javac>
</sequential>
</macrodef>
+ <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}" name="classpath"/>
+ <sequential>
+ <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ </depend>
+ </sequential>
+ </macrodef>
+ <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <sequential>
+ <fail unless="javac.includes">Must set javac.includes</fail>
+ <pathconvert pathsep="," property="javac.includes.binary">
+ <path>
+ <filelist dir="@{destdir}" files="${javac.includes}"/>
+ </path>
+ <globmapper from="*.java" to="*.class"/>
+ </pathconvert>
+ <delete>
+ <files includes="${javac.includes.binary}"/>
+ </delete>
+ </sequential>
+ </macrodef>
</target>
<target name="-init-macrodef-junit">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute name="includes" default="**/*Test.java"/>
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="**" name="testincludes"/>
<sequential>
- <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
<batchtest todir="${build.test.results.dir}">
- <fileset dir="${test.src.dir}" includes="@{includes}"/>
+ <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+ <filename name="@{testincludes}"/>
+ </fileset>
</batchtest>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
- <mapper type="glob" from="test-sys-prop.*" to="*"/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
@@ -155,13 +218,13 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
- <target name="-init-macrodef-nbjpda">
+ <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="name" default="${main.class}"/>
- <attribute name="classpath" default="${debug.classpath}"/>
- <attribute name="stopclassname" default=""/>
+ <attribute default="${main.class}" name="name"/>
+ <attribute default="${debug.classpath}" name="classpath"/>
+ <attribute default="" name="stopclassname"/>
<sequential>
- <nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
+ <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
<classpath>
<path path="@{classpath}"/>
</classpath>
@@ -169,32 +232,52 @@ is divided into following sections:
</sequential>
</macrodef>
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="dir" default="${build.classes.dir}"/>
+ <attribute default="${build.classes.dir}" name="dir"/>
<sequential>
<nbjpdareload>
- <fileset includes="${fix.includes}*.class" dir="@{dir}"/>
+ <fileset dir="@{dir}" includes="${fix.classes}">
+ <include name="${fix.includes}*.class"/>
+ </fileset>
</nbjpdareload>
</sequential>
</macrodef>
</target>
- <target name="-init-macrodef-debug">
+ <target name="-init-debug-args">
+ <property name="version-output" value="java version &quot;${ant.java.version}"/>
+ <condition property="have-jdk-older-than-1.4">
+ <or>
+ <contains string="${version-output}" substring="java version &quot;1.0"/>
+ <contains string="${version-output}" substring="java version &quot;1.1"/>
+ <contains string="${version-output}" substring="java version &quot;1.2"/>
+ <contains string="${version-output}" substring="java version &quot;1.3"/>
+ </or>
+ </condition>
+ <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+ <istrue value="${have-jdk-older-than-1.4}"/>
+ </condition>
+ <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+ <os family="windows"/>
+ </condition>
+ <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+ <isset property="debug.transport"/>
+ </condition>
+ </target>
+ <target depends="-init-debug-args" name="-init-macrodef-debug">
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute name="classname" default="${main.class}"/>
- <attribute name="classpath" default="${debug.classpath}"/>
+ <attribute default="${main.class}" name="classname"/>
+ <attribute default="${debug.classpath}" name="classpath"/>
<element name="customize" optional="true"/>
<sequential>
- <java fork="true" classname="@{classname}" dir="${work.dir}">
- <jvmarg value="-Xdebug"/>
- <jvmarg value="-Xnoagent"/>
- <jvmarg value="-Djava.compiler=none"/>
- <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
+ <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <jvmarg line="${debug-args-line}"/>
+ <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="@{classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
- <mapper type="glob" from="run-sys-prop.*" to="*"/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<customize/>
</java>
@@ -203,17 +286,17 @@ is divided into following sections:
</target>
<target name="-init-macrodef-java">
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="classname" default="${main.class}"/>
+ <attribute default="${main.class}" name="classname"/>
<element name="customize" optional="true"/>
<sequential>
- <java fork="true" classname="@{classname}" dir="${work.dir}">
+ <java classname="@{classname}" dir="${work.dir}" fork="true">
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="${run.classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
- <mapper type="glob" from="run-sys-prop.*" to="*"/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<customize/>
</java>
@@ -222,102 +305,109 @@ is divided into following sections:
</target>
<target name="-init-presetdef-jar">
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
- <jar jarfile="${dist.jar}" compress="${jar.compress}">
+ <jar compress="${jar.compress}" jarfile="${dist.jar}">
<j2seproject1:fileset dir="${build.classes.dir}"/>
</jar>
</presetdef>
</target>
- <target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
<!--
- ===================
- COMPILATION SECTION
- ===================
- -->
- <target name="deps-jar" depends="init" unless="no.deps"/>
- <target name="-pre-pre-compile" depends="init,deps-jar">
+ ===================
+ COMPILATION SECTION
+ ===================
+ -->
+ <target depends="init" name="deps-jar" unless="no.deps"/>
+ <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+ <target depends="init" name="-check-automatic-build">
+ <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+ </target>
+ <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+ <antcall target="clean"/>
+ </target>
+ <target depends="init,deps-jar" name="-pre-pre-compile">
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="-pre-compile">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
+ <target if="do.depend.true" name="-compile-depend">
+ <j2seproject3:depend/>
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
<j2seproject3:javac/>
<copy todir="${build.classes.dir}">
- <fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
+ <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
<target name="-post-compile">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
+ <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
<target name="-pre-compile-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
+ <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:javac>
- <customize>
- <patternset includes="${javac.includes}"/>
- </customize>
- </j2seproject3:javac>
+ <j2seproject3:force-recompile/>
+ <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
</target>
<target name="-post-compile-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
+ <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
<!--
- ====================
- JAR BUILDING SECTION
- ====================
- -->
- <target name="-pre-pre-jar" depends="init">
- <dirname property="dist.jar.dir" file="${dist.jar}"/>
+ ====================
+ JAR BUILDING SECTION
+ ====================
+ -->
+ <target depends="init" name="-pre-pre-jar">
+ <dirname file="${dist.jar}" property="dist.jar.dir"/>
<mkdir dir="${dist.jar.dir}"/>
</target>
<target name="-pre-jar">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
<j2seproject1:jar/>
</target>
- <target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
<j2seproject1:jar manifest="${manifest.file}"/>
</target>
- <target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
<j2seproject1:jar manifest="${manifest.file}">
<j2seproject1:manifest>
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
</j2seproject1:manifest>
</j2seproject1:jar>
<echo>To run this application from the command line without Ant, try:</echo>
- <property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
- <property name="dist.jar.resolved" location="${dist.jar}"/>
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+ <property location="${dist.jar}" name="dist.jar.resolved"/>
<pathconvert property="run.classpath.with.dist.jar">
<path path="${run.classpath}"/>
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
</pathconvert>
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
</target>
- <target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
- <property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
<pathconvert property="run.classpath.without.build.classes.dir">
<path path="${run.classpath}"/>
<map from="${build.classes.dir.resolved}" to=""/>
</pathconvert>
- <pathconvert property="jar.classpath" pathsep=" ">
+ <pathconvert pathsep=" " property="jar.classpath">
<path path="${run.classpath.without.build.classes.dir}"/>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</pathconvert>
- <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
- <copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
+ <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+ <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
@@ -325,183 +415,194 @@ is divided into following sections:
</manifest>
</copylibs>
<echo>To run this application from the command line without Ant, try:</echo>
- <property name="dist.jar.resolved" location="${dist.jar}"/>
+ <property location="${dist.jar}" name="dist.jar.resolved"/>
<echo>java -jar "${dist.jar.resolved}"</echo>
</target>
<target name="-post-jar">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
+ <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
<!--
- =================
- EXECUTION SECTION
- =================
- -->
- <target name="run" depends="init,compile" description="Run a main class.">
+ =================
+ EXECUTION SECTION
+ =================
+ -->
+ <target depends="init,compile" description="Run a main class." name="run">
<j2seproject1:java>
<customize>
<arg line="${application.args}"/>
</customize>
</j2seproject1:java>
</target>
- <target name="run-single" depends="init,compile-single">
+ <target name="-do-not-recompile">
+ <property name="javac.includes.binary" value=""/>
+ </target>
+ <target depends="init,-do-not-recompile,compile-single" name="run-single">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<j2seproject1:java classname="${run.class}"/>
</target>
<!--
- =================
- DEBUGGING SECTION
- =================
- -->
- <target name="-debug-start-debugger" if="netbeans.home" depends="init">
+ =================
+ DEBUGGING SECTION
+ =================
+ -->
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger">
<j2seproject1:nbjpdastart name="${debug.class}"/>
</target>
- <target name="-debug-start-debuggee" depends="init,compile">
+ <target depends="init,compile" name="-debug-start-debuggee">
<j2seproject3:debug>
<customize>
<arg line="${application.args}"/>
</customize>
</j2seproject3:debug>
</target>
- <target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
- <target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
+ <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
</target>
- <target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
- <target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
+ <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
+ <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
<j2seproject3:debug classname="${debug.class}"/>
</target>
- <target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
- <target name="-pre-debug-fix" depends="init">
+ <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+ <target depends="init" name="-pre-debug-fix">
<fail unless="fix.includes">Must set fix.includes</fail>
<property name="javac.includes" value="${fix.includes}.java"/>
</target>
- <target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
+ <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
<j2seproject1:nbjpdareload/>
</target>
- <target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
+ <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
<!--
- ===============
- JAVADOC SECTION
- ===============
- -->
- <target name="-javadoc-build" depends="init">
+ ===============
+ JAVADOC SECTION
+ ===============
+ -->
+ <target depends="init" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/>
- <javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
+ <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath>
<path path="${javac.classpath}"/>
</classpath>
- <sourcepath>
- <pathelement location="${src.dir}"/>
- </sourcepath>
- <packageset dir="${src.dir}" includes="*/**"/>
- <fileset dir="${src.dir}" includes="*.java"/>
+ <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+ <filename name="**/*.java"/>
+ </fileset>
</javadoc>
</target>
- <target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
+ <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
</target>
- <target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
+ <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
<!--
- =========================
- JUNIT COMPILATION SECTION
- =========================
- -->
- <target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
+ =========================
+ JUNIT COMPILATION SECTION
+ =========================
+ -->
+ <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
<mkdir dir="${build.test.classes.dir}"/>
</target>
<target name="-pre-compile-test">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
- <j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
+ <target if="do.depend.true" name="-compile-test-depend">
+ <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+ <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
<copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="**/*.java"/>
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
<target name="-post-compile-test">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
<target name="-pre-compile-test-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
- <customize>
- <patternset includes="${javac.includes}"/>
- </customize>
- </j2seproject3:javac>
+ <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
+ <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
<copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="**/*.java"/>
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
<target name="-post-compile-test-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
<!--
- =======================
- JUNIT EXECUTION SECTION
- =======================
- -->
- <target name="-pre-test-run" if="have.tests" depends="init">
+ =======================
+ JUNIT EXECUTION SECTION
+ =======================
+ -->
+ <target depends="init" if="have.tests" name="-pre-test-run">
<mkdir dir="${build.test.results.dir}"/>
</target>
- <target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
- <j2seproject3:junit/>
+ <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+ <j2seproject3:junit testincludes="**/*Test.java"/>
</target>
- <target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
+ <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
<fail if="tests.failed">Some tests failed; see details above.</fail>
</target>
- <target name="test-report" if="have.tests" depends="init"/>
- <target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
- <target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
- <target name="-pre-test-run-single" if="have.tests" depends="init">
+ <target depends="init" if="have.tests" name="test-report"/>
+ <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+ <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+ <target depends="init" if="have.tests" name="-pre-test-run-single">
<mkdir dir="${build.test.results.dir}"/>
</target>
- <target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
+ <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
- <j2seproject3:junit includes="${test.includes}"/>
+ <j2seproject3:junit excludes="" includes="${test.includes}"/>
</target>
- <target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
<fail if="tests.failed">Some tests failed; see details above.</fail>
</target>
- <target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
+ <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
<!--
- =======================
- JUNIT DEBUGGING SECTION
- =======================
- -->
- <target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
+ =======================
+ JUNIT DEBUGGING SECTION
+ =======================
+ -->
+ <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
- <j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
+ <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
+ <delete file="${test.report.file}"/>
+ <mkdir dir="${build.test.results.dir}"/>
+ <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
<customize>
- <arg line="${test.class}"/>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <arg value="${test.class}"/>
+ <arg value="showoutput=true"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
</customize>
</j2seproject3:debug>
</target>
- <target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
- <j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
+ <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+ <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
</target>
- <target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
- <target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
+ <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+ <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
</target>
- <target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
+ <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
<!--
- =========================
- APPLET EXECUTION SECTION
- =========================
- -->
- <target name="run-applet" depends="init,compile-single">
+ =========================
+ APPLET EXECUTION SECTION
+ =========================
+ -->
+ <target depends="init,compile-single" name="run-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject1:java classname="sun.applet.AppletViewer">
<customize>
@@ -510,11 +611,11 @@ is divided into following sections:
</j2seproject1:java>
</target>
<!--
- =========================
- APPLET DEBUGGING SECTION
- =========================
- -->
- <target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
+ =========================
+ APPLET DEBUGGING SECTION
+ =========================
+ -->
+ <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject3:debug classname="sun.applet.AppletViewer">
<customize>
@@ -522,14 +623,14 @@ is divided into following sections:
</customize>
</j2seproject3:debug>
</target>
- <target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
+ <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
<!--
- ===============
- CLEANUP SECTION
- ===============
- -->
- <target name="deps-clean" depends="init" unless="no.deps"/>
- <target name="-do-clean" depends="init">
+ ===============
+ CLEANUP SECTION
+ ===============
+ -->
+ <target depends="init" name="deps-clean" unless="no.deps"/>
+ <target depends="init" name="-do-clean">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
@@ -537,5 +638,5 @@ is divided into following sections:
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
+ <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
</project>
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
index 1eb5de7..de76beb 100644
--- a/nbproject/genfiles.properties
+++ b/nbproject/genfiles.properties
@@ -2,5 +2,5 @@ build.xml.data.CRC32=c32ad9b4
build.xml.script.CRC32=fb22312b
build.xml.stylesheet.CRC32=ba5d3624
nbproject/build-impl.xml.data.CRC32=ca6f3ced
-nbproject/build-impl.xml.script.CRC32=3b54f9f3
-nbproject/build-impl.xml.stylesheet.CRC32=20b9345e
+nbproject/build-impl.xml.script.CRC32=a04da524
+nbproject/build-impl.xml.stylesheet.CRC32=65b8de21
diff --git a/nbproject/project.properties b/nbproject/project.properties
index 9c9368a..afa8dd4 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -1,4 +1,10 @@
application.args=
+application.desc=An OpenType font development environment.
+application.homepage=http://synchroma.org/typecast/
+application.splash=/Users/david/Pictures/Meyke/14012009224.jpg
+application.title=Typecast
+application.vendor=Synchroma Pty Ltd
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@@ -16,11 +22,11 @@ debug.test.classpath=\
dist.dir=dist
dist.jar=${dist.dir}/typecast.jar
dist.javadoc.dir=${dist.dir}/javadoc
-file.reference.AppleJavaExtensions.jar=lib/AppleJavaExtensions.jar
+excludes=
file.reference.jlfgr-1_0.jar=lib/jlfgr-1_0.jar
+includes=**
jar.compress=true
-javac.classpath=\
- ${file.reference.AppleJavaExtensions.jar}
+javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=-Xlint
javac.deprecation=true
@@ -41,6 +47,12 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=Typecast
+jnlp.codebase.type=local
+jnlp.codebase.url=file:/Users/david/sandbox/typecast/dist/
+jnlp.descriptor=application
+jnlp.enabled=false
+jnlp.offline-allowed=false
+jnlp.signed=false
main.class=net.java.dev.typecast.app.editor.Main
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
@@ -49,9 +61,6 @@ run.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${file.reference.jlfgr-1_0.jar}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=-Dapple.laf.useScreenMenuBar=true
run.test.classpath=\
${javac.test.classpath}:\
diff --git a/src/net/java/dev/typecast/app/editor/EditorMenu.java b/src/net/java/dev/typecast/app/editor/EditorMenu.java
index 2e81561..5f66527 100644
--- a/src/net/java/dev/typecast/app/editor/EditorMenu.java
+++ b/src/net/java/dev/typecast/app/editor/EditorMenu.java
@@ -1,5 +1,5 @@
/*
- * $Id: EditorMenu.java,v 1.3 2007-01-25 23:57:16 davidsch Exp $
+ * $Id: EditorMenu.java,v 1.4 2009-05-22 02:30:27 davidsch Exp $
*
* Typecast - The Font Development Environment
*
@@ -42,7 +42,7 @@ import net.java.dev.typecast.ot.OTFontCollection;
/**
* The application menu bar
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
- * @version $Id: EditorMenu.java,v 1.3 2007-01-25 23:57:16 davidsch Exp $
+ * @version $Id: EditorMenu.java,v 1.4 2009-05-22 02:30:27 davidsch Exp $
*/
public class EditorMenu {
@@ -67,7 +67,7 @@ public class EditorMenu {
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
if (System.getProperty("os.name").equals("Mac OS X")) {
_macPlatform = true;
- new MacOSMenuHandler(_app);
+ registerForMacOSXEvents();
} else {
_macPlatform = false;
}
@@ -606,4 +606,21 @@ public class EditorMenu {
_prefs.addMRU(mru);
buildMRU();
}
+
+ // Generic registration with the Mac OS X application menu
+ // Checks the platform, then attempts to register with the Apple EAWT
+ // See OSXAdapter.java to see how this is done without directly referencing any Apple APIs
+ public void registerForMacOSXEvents() {
+ try {
+ // Generate and register the OSXAdapter, passing it a hash of all the methods we wish to
+ // use as delegates for various com.apple.eawt.ApplicationListener methods
+ OSXAdapter.setQuitHandler(_app, _app.getClass().getDeclaredMethod("close", (Class[])null));
+ OSXAdapter.setAboutHandler(_app, _app.getClass().getDeclaredMethod("showAbout", (Class[])null));
+ OSXAdapter.setPreferencesHandler(_app, _app.getClass().getDeclaredMethod("showPreferences", (Class[])null));
+ //OSXAdapter.setFileHandler(_app, _app.getClass().getDeclaredMethod("loadImageFile", new Class[] { String.class }));
+ } catch (Exception e) {
+ System.err.println("Error while loading the OSXAdapter:");
+ e.printStackTrace();
+ }
+ }
}
diff --git a/src/net/java/dev/typecast/app/editor/MacOSMenuHandler.java b/src/net/java/dev/typecast/app/editor/MacOSMenuHandler.java
deleted file mode 100644
index b9a44b6..0000000
--- a/src/net/java/dev/typecast/app/editor/MacOSMenuHandler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * MacOSMenuHandler.java
- *
- * Created on January 25, 2007, 3:23 PM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package net.java.dev.typecast.app.editor;
-
-import com.apple.eawt.ApplicationAdapter;
-import com.apple.eawt.ApplicationEvent;
-import com.apple.eawt.Application;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-
-/**
- *
- * @author david
- */
-public class MacOSMenuHandler extends Application {
-
- private Main _app;
-
- /** Creates a new instance of MacOSMenuHandler */
- public MacOSMenuHandler(Main app) {
- _app = app;
- setEnabledPreferencesMenu(true);
- addApplicationListener(new AboutBoxHandler());
- }
-
- class AboutBoxHandler extends ApplicationAdapter {
-
- public void handleAbout(ApplicationEvent e) {
- _app.showAbout();
- e.setHandled(true);
- }
-
- public void handleOpenApplication(ApplicationEvent e) {
- }
-
- public void handleOpenFile(ApplicationEvent e) {
- }
-
- public void handlePreferences(ApplicationEvent e) {
- }
-
- public void handlePrintFile(ApplicationEvent e) {
- }
-
- public void handleQuit(ApplicationEvent e) {
- _app.close();
- }
- }
-}
diff --git a/src/net/java/dev/typecast/app/editor/Main.java b/src/net/java/dev/typecast/app/editor/Main.java
index 2810de0..af66537 100644
--- a/src/net/java/dev/typecast/app/editor/Main.java
+++ b/src/net/java/dev/typecast/app/editor/Main.java
@@ -1,5 +1,5 @@
/*
- * $Id: Main.java,v 1.7 2007-02-21 12:23:07 davidsch Exp $
+ * $Id: Main.java,v 1.8 2009-05-22 02:30:27 davidsch Exp $
*
* Typecast - The Font Development Environment
*
@@ -93,7 +93,7 @@ import net.java.dev.typecast.app.framework.EditorView;
/**
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
- * @version $Id: Main.java,v 1.7 2007-02-21 12:23:07 davidsch Exp $
+ * @version $Id: Main.java,v 1.8 2009-05-22 02:30:27 davidsch Exp $
*/
public class Main {
@@ -422,6 +422,14 @@ public class Main {
_rb.getString("Typecast.about.title"),
JOptionPane.INFORMATION_MESSAGE);
}
+
+ protected void showPreferences() {
+ JOptionPane.showMessageDialog(
+ null,
+ "Typecast currently has no preferences page.",
+ "Typecast Preferences",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
protected void close() {
diff --git a/src/net/java/dev/typecast/app/editor/OSXAdapter.java b/src/net/java/dev/typecast/app/editor/OSXAdapter.java
new file mode 100644
index 0000000..6de5aba
--- /dev/null
+++ b/src/net/java/dev/typecast/app/editor/OSXAdapter.java
@@ -0,0 +1,207 @@
+/*
+
+File: OSXAdapter.java
+
+Abstract: Hooks existing preferences/about/quit functionality from an
+ existing Java app into handlers for the Mac OS X application menu.
+ Uses a Proxy object to dynamically implement the
+ com.apple.eawt.ApplicationListener interface and register it with the
+ com.apple.eawt.Application object. This allows the complete project
+ to be both built and run on any platform without any stubs or
+ placeholders. Useful for developers looking to implement Mac OS X
+ features while supporting multiple platforms with minimal impact.
+
+Version: 2.0
+
+Disclaimer: IMPORTANT: This Apple software is supplied to you by
+Apple Inc. ("Apple") in consideration of your agreement to the
+following terms, and your use, installation, modification or
+redistribution of this Apple software constitutes acceptance of these
+terms. If you do not agree with these terms, please do not use,
+install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, Apple grants you a personal, non-exclusive
+license, under Apple's copyrights in this original Apple software (the
+"Apple Software"), to use, reproduce, modify and redistribute the Apple
+Software, with or without modifications, in source and/or binary forms;
+provided that if you redistribute the Apple Software in its entirety and
+without modifications, you must retain this notice and the following
+text and disclaimers in all such redistributions of the Apple Software.
+Neither the name, trademarks, service marks or logos of Apple Inc.
+may be used to endorse or promote products derived from the Apple
+Software without specific prior written permission from Apple. Except
+as expressly stated in this notice, no other rights or licenses, express
+or implied, are granted by Apple herein, including but not limited to
+any patent rights that may be infringed by your derivative works or by
+other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+Copyright � 2003-2007 Apple, Inc., All Rights Reserved
+
+*/
+
+//package apple.dts.samplecode.osxadapter;
+package net.java.dev.typecast.app.editor;
+
+import java.lang.reflect.*;
+import java.util.HashMap;
+
+
+public class OSXAdapter implements InvocationHandler {
+
+ protected Object targetObject;
+ protected Method targetMethod;
+ protected String proxySignature;
+
+ static Object macOSXApplication;
+
+ // Pass this method an Object and Method equipped to perform application shutdown logic
+ // The method passed should return a boolean stating whether or not the quit should occur
+ public static void setQuitHandler(Object target, Method quitHandler) {
+ setHandler(new OSXAdapter("handleQuit", target, quitHandler));
+ }
+
+ // Pass this method an Object and Method equipped to display application info
+ // They will be called when the About menu item is selected from the application menu
+ public static void setAboutHandler(Object target, Method aboutHandler) {
+ boolean enableAboutMenu = (target != null && aboutHandler != null);
+ if (enableAboutMenu) {
+ setHandler(new OSXAdapter("handleAbout", target, aboutHandler));
+ }
+ // If we're setting a handler, enable the About menu item by calling
+ // com.apple.eawt.Application reflectively
+ try {
+ Method enableAboutMethod = macOSXApplication.getClass().getDeclaredMethod("setEnabledAboutMenu", new Class[] { boolean.class });
+ enableAboutMethod.invoke(macOSXApplication, new Object[] { Boolean.valueOf(enableAboutMenu) });
+ } catch (Exception ex) {
+ System.err.println("OSXAdapter could not access the About Menu");
+ ex.printStackTrace();
+ }
+ }
+
+ // Pass this method an Object and a Method equipped to display application options
+ // They will be called when the Preferences menu item is selected from the application menu
+ public static void setPreferencesHandler(Object target, Method prefsHandler) {
+ boolean enablePrefsMenu = (target != null && prefsHandler != null);
+ if (enablePrefsMenu) {
+ setHandler(new OSXAdapter("handlePreferences", target, prefsHandler));
+ }
+ // If we're setting a handler, enable the Preferences menu item by calling
+ // com.apple.eawt.Application reflectively
+ try {
+ Method enablePrefsMethod = macOSXApplication.getClass().getDeclaredMethod("setEnabledPreferencesMenu", new Class[] { boolean.class });
+ enablePrefsMethod.invoke(macOSXApplication, new Object[] { Boolean.valueOf(enablePrefsMenu) });
+ } catch (Exception ex) {
+ System.err.println("OSXAdapter could not access the About Menu");
+ ex.printStackTrace();
+ }
+ }
+
+ // Pass this method an Object and a Method equipped to handle document events from the Finder
+ // Documents are registered with the Finder via the CFBundleDocumentTypes dictionary in the
+ // application bundle's Info.plist
+ public static void setFileHandler(Object target, Method fileHandler) {
+ setHandler(new OSXAdapter("handleOpenFile", target, fileHandler) {
+ // Override OSXAdapter.callTarget to send information on the
+ // file to be opened
+ public boolean callTarget(Object appleEvent) {
+ if (appleEvent != null) {
+ try {
+ Method getFilenameMethod = appleEvent.getClass().getDeclaredMethod("getFilename", (Class[])null);
+ String filename = (String) getFilenameMethod.invoke(appleEvent, (Object[])null);
+ this.targetMethod.invoke(this.targetObject, new Object[] { filename });
+ } catch (Exception ex) {
+
+ }
+ }
+ return true;
+ }
+ });
+ }
+
+ // setHandler creates a Proxy object from the passed OSXAdapter and adds it as an ApplicationListener
+ public static void setHandler(OSXAdapter adapter) {
+ try {
+ Class applicationClass = Class.forName("com.apple.eawt.Application");
+ if (macOSXApplication == null) {
+ macOSXApplication = applicationClass.getConstructor((Class[])null).newInstance((Object[])null);
+ }
+ Class applicationListenerClass = Class.forName("com.apple.eawt.ApplicationListener");
+ Method addListenerMethod = applicationClass.getDeclaredMethod("addApplicationListener", new Class[] { applicationListenerClass });
+ // Create a proxy object around this handler that can be reflectively added as an Apple ApplicationListener
+ Object osxAdapterProxy = Proxy.newProxyInstance(OSXAdapter.class.getClassLoader(), new Class[] { applicationListenerClass }, adapter);
+ addListenerMethod.invoke(macOSXApplication, new Object[] { osxAdapterProxy });
+ } catch (ClassNotFoundException cnfe) {
+ System.err.println("This version of Mac OS X does not support the Apple EAWT. ApplicationEvent handling has been disabled (" + cnfe + ")");
+ } catch (Exception ex) { // Likely a NoSuchMethodException or an IllegalAccessException loading/invoking eawt.Application methods
+ System.err.println("Mac OS X Adapter could not talk to EAWT:");
+ ex.printStackTrace();
+ }
+ }
+
+ // Each OSXAdapter has the name of the EAWT method it intends to listen for (handleAbout, for example),
+ // the Object that will ultimately perform the task, and the Method to be called on that Object
+ protected OSXAdapter(String proxySignature, Object target, Method handler) {
+ this.proxySignature = proxySignature;
+ this.targetObject = target;
+ this.targetMethod = handler;
+ }
+
+ // Override this method to perform any operations on the event
+ // that comes with the various callbacks
+ // See setFileHandler above for an example
+ public boolean callTarget(Object appleEvent) throws InvocationTargetException, IllegalAccessException {
+ Object result = targetMethod.invoke(targetObject, (Object[])null);
+ if (result == null) {
+ return true;
+ }
+ return Boolean.valueOf(result.toString()).booleanValue();
+ }
+
+ // InvocationHandler implementation
+ // This is the entry point for our proxy object; it is called every time an ApplicationListener method is invoked
+ public Object invoke (Object proxy, Method method, Object[] args) throws Throwable {
+ if (isCorrectMethod(method, args)) {
+ boolean handled = callTarget(args[0]);
+ setApplicationEventHandled(args[0], handled);
+ }
+ // All of the ApplicationListener methods are void; return null regardless of what happens
+ return null;
+ }
+
+ // Compare the method that was called to the intended method when the OSXAdapter instance was created
+ // (e.g. handleAbout, handleQuit, handleOpenFile, etc.)
+ protected boolean isCorrectMethod(Method method, Object[] args) {
+ return (targetMethod != null && proxySignature.equals(method.getName()) && args.length == 1);
+ }
+
+ // It is important to mark the ApplicationEvent as handled and cancel the default behavior
+ // This method checks for a boolean result from the proxy method and sets the event accordingly
+ protected void setApplicationEventHandled(Object event, boolean handled) {
+ if (event != null) {
+ try {
+ Method setHandledMethod = event.getClass().getDeclaredMethod("setHandled", new Class[] { boolean.class });
+ // If the target method returns a boolean, use that as a hint
+ setHandledMethod.invoke(event, new Object[] { Boolean.valueOf(handled) });
+ } catch (Exception ex) {
+ System.err.println("OSXAdapter was unable to handle an ApplicationEvent: " + event);
+ ex.printStackTrace();
+ }
+ }
+ }
+} \ No newline at end of file