merged
authorwenzelm
Mon, 09 Sep 2013 20:24:15 +0200
changeset 53490 c413adedef46
parent 53482 662149d02915 (current diff)
parent 53489 97222a86aec0 (diff)
child 53491 2479b39d9d09
child 53494 c24892032eea
merged
Admin/MacOS/App3/Info.plist
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/Linux/Isabelle	Mon Sep 09 20:24:15 2013 +0200
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+#
+# Author: Makarius
+#
+# Main Isabelle application wrapper.
+
+if [ -L "$0" ]; then
+  TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
+  exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
+fi
+
+
+## settings
+
+PRG="$(basename "$0")"
+
+ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; pwd)"
+source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
+
+
+## main
+
+declare -a JAVA_ARGS
+JAVA_ARGS=({JAVA_ARGS})
+
+exec "$ISABELLE_HOME/bin/isabelle" java "${JAVA_ARGS[@]}" \
+  -classpath "$ISABELLE_HOME/src/Tools/jEdit/dist/jedit.jar" isabelle.Main "$@"
+
--- a/Admin/MacOS/App3/Info.plist	Mon Sep 09 18:14:54 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<?xml version="1.0" ?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-<key>CFBundleDevelopmentRegion</key>
-<string>English</string>
-<key>CFBundleExecutable</key>
-<string>JavaAppLauncher</string>
-<key>CFBundleIconFile</key>
-<string>isabelle.icns</string>
-<key>CFBundleIdentifier</key>
-<string>de.tum.in.isabelle</string>
-<key>CFBundleDisplayName</key>
-<string>{ISABELLE_NAME}</string>
-<key>CFBundleInfoDictionaryVersion</key>
-<string>6.0</string>
-<key>CFBundleName</key>
-<string>{ISABELLE_NAME}</string>
-<key>CFBundlePackageType</key>
-<string>APPL</string>
-<key>CFBundleShortVersionString</key>
-<string>1.0</string>
-<key>CFBundleSignature</key>
-<string>????</string>
-<key>CFBundleVersion</key>
-<string>1</string>
-<key>NSHumanReadableCopyright</key>
-<string></string>
-<key>LSApplicationCategoryType</key>
-<string>public.app-category.developer-tools</string>
-<key>JVMRuntime</key>
-<string>jdk</string>
-<key>JVMMainClassName</key>
-<string>isabelle.Main</string>
-<key>JVMOptions</key>
-<array>
-<string>-Dapple.laf.useScreenMenuBar=true -Xms128m -Xmx1024m -Xss2m -Dactors.corePoolSize=4 -Dactors.enableForkJoin=false</string>
-<string>-Disabelle.home=$APP_ROOT/Contents/Resources/{ISABELLE_NAME}</string>
-</array>
-<key>JVMArguments</key>
-<array>
-</array>
-</dict>
-</plist>
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/MacOS/App3/Info.plist-part1	Mon Sep 09 20:24:15 2013 +0200
@@ -0,0 +1,36 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+<key>CFBundleDevelopmentRegion</key>
+<string>English</string>
+<key>CFBundleExecutable</key>
+<string>JavaAppLauncher</string>
+<key>CFBundleIconFile</key>
+<string>isabelle.icns</string>
+<key>CFBundleIdentifier</key>
+<string>de.tum.in.isabelle</string>
+<key>CFBundleDisplayName</key>
+<string>{ISABELLE_NAME}</string>
+<key>CFBundleInfoDictionaryVersion</key>
+<string>6.0</string>
+<key>CFBundleName</key>
+<string>{ISABELLE_NAME}</string>
+<key>CFBundlePackageType</key>
+<string>APPL</string>
+<key>CFBundleShortVersionString</key>
+<string>1.0</string>
+<key>CFBundleSignature</key>
+<string>????</string>
+<key>CFBundleVersion</key>
+<string>1</string>
+<key>NSHumanReadableCopyright</key>
+<string></string>
+<key>LSApplicationCategoryType</key>
+<string>public.app-category.developer-tools</string>
+<key>JVMRuntime</key>
+<string>jdk</string>
+<key>JVMMainClassName</key>
+<string>isabelle.Main</string>
+<key>JVMOptions</key>
+<array>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/MacOS/App3/Info.plist-part2	Mon Sep 09 20:24:15 2013 +0200
@@ -0,0 +1,7 @@
+<string>-Disabelle.home=$APP_ROOT/Contents/Resources/{ISABELLE_NAME}</string>
+</array>
+<key>JVMArguments</key>
+<array>
+</array>
+</dict>
+</plist>
--- a/Admin/Windows/WinRun4J/Isabelle.ini	Mon Sep 09 18:14:54 2013 +0200
+++ b/Admin/Windows/WinRun4J/Isabelle.ini	Mon Sep 09 20:24:15 2013 +0200
@@ -7,13 +7,5 @@
 classpath.6=lib\classes\ext\scala-reflect.jar
 classpath.7=src\Tools\jEdit\dist\jedit.jar
 vm.location=contrib\jdk\x86-cygwin\jre\bin\server\jvm.dll
-vmarg.1=-Dfile.encoding=UTF-8
-vmarg.2=-server
-vmarg.3=-Xms128m
-vmarg.4=-Xmx1024m
-vmarg.5=-Xss2m
-vmarg.6=-Dactors.corePoolSize=4
-vmarg.7=-Dactors.enableForkJoin=false
-vmarg.8=-Disabelle.home=%INI_DIR%
 splash.image=lib\logo\isabelle.bmp
-
+vmarg.1=-Disabelle.home=%INI_DIR%
--- a/Admin/isatest/settings/at64-poly	Mon Sep 09 18:14:54 2013 +0200
+++ b/Admin/isatest/settings/at64-poly	Mon Sep 09 20:24:15 2013 +0200
@@ -2,11 +2,11 @@
 
 init_components /home/isabelle/contrib "$HOME/admin/components/main"
 
-  POLYML_HOME="/home/polyml/polyml-5.4.1"
-  ML_SYSTEM="polyml-5.4.1"
+  POLYML_HOME="/home/polyml/polyml-svn"
+  ML_SYSTEM="polyml-5.5.1"
   ML_PLATFORM="x86_64-linux"
   ML_HOME="$POLYML_HOME/$ML_PLATFORM"
-  ML_OPTIONS="-H 1000"
+  ML_OPTIONS="-H 1000 --gcthreads 1"
 
 ISABELLE_HOME_USER=~/isabelle-at64-poly
 
--- a/Admin/lib/Tools/makedist_bundle	Mon Sep 09 18:14:54 2013 +0200
+++ b/Admin/lib/Tools/makedist_bundle	Mon Sep 09 20:24:15 2013 +0200
@@ -53,6 +53,8 @@
 
 # bundled components
 
+init_component "$JEDIT_HOME"
+
 mkdir -p "$ARCHIVE_DIR/contrib"
 
 echo "#bundled components" >> "$ISABELLE_TARGET/etc/components"
@@ -121,19 +123,14 @@
 }
 
 
-# platform-specific patches
+# platform-specific setup (inside archive)
 
 case "$PLATFORM_FAMILY" in
   linux)
     purge_contrib '-name "x86*-darwin" -o -name "x86*-cygwin" -o -name "x86*-windows"'
-    cat > "$ISABELLE_TARGET/$ISABELLE_NAME" <<EOF
-#!/usr/bin/env bash
-
-ISABELLE_TOOL="\$(dirname "\$0")"/bin/isabelle
-JEDIT_HOME="\$("\$ISABELLE_TOOL" getenv -b JEDIT_HOME)"
-
-exec "\$ISABELLE_TOOL" java -classpath "\$JEDIT_HOME/dist/jedit.jar" isabelle.Main "\$@"
-EOF
+    cat "$ISABELLE_HOME/Admin/Linux/Isabelle" | \
+      perl -p -e "s,{JAVA_ARGS},$JEDIT_JAVA_OPTIONS $JEDIT_SYSTEM_OPTIONS,g;" \
+        > "$ISABELLE_TARGET/$ISABELLE_NAME"
     chmod +x "$ISABELLE_TARGET/$ISABELLE_NAME"
     ;;
   macos)
@@ -152,8 +149,19 @@
     perl -pi -e "s,lookAndFeel=.*,lookAndFeel=com.sun.java.swing.plaf.windows.WindowsLookAndFeel,g;" \
       "$ISABELLE_TARGET/src/Tools/jEdit/dist/properties/jEdit.props"
 
+    (
+      cat "$ISABELLE_HOME/Admin/Windows/WinRun4J/Isabelle.ini"
+      declare -a JAVA_ARGS=()
+      eval "JAVA_ARGS=($ISABELLE_JAVA_SYSTEM_OPTIONS $JEDIT_JAVA_OPTIONS $JEDIT_SYSTEM_OPTIONS)"
+      A=2
+      for ARG in "${JAVA_ARGS[@]}"
+      do
+        echo -e "vmarg.$A=$ARG\r"
+        A=$[ $A + 1 ]
+      done
+    ) > "$ISABELLE_TARGET/${ISABELLE_NAME}.ini"
+
     cp "$TMP/windows_app/Isabelle.exe" "$ISABELLE_TARGET/${ISABELLE_NAME}.exe"
-    cp "$ISABELLE_HOME/Admin/Windows/WinRun4J/Isabelle.ini" "$ISABELLE_TARGET/${ISABELLE_NAME}.ini"
     cp "$ISABELLE_HOME/Admin/Windows/Cygwin/Cygwin-Setup.bat" \
       "$ISABELLE_HOME/Admin/Windows/Cygwin/Cygwin-Latex-Setup.bat" \
       "$ISABELLE_HOME/Admin/Windows/Cygwin/Cygwin-Terminal.bat" "$ISABELLE_TARGET"
@@ -193,7 +201,7 @@
 tar -C "$TMP" -c -z -f "$BUNDLE_ARCHIVE" "$ISABELLE_NAME" || exit 2
 
 
-# application
+# platform-specific setup (outside archive)
 
 if [ "$ISABELLE_PLATFORM_FAMILY" = linux -a "$PLATFORM_FAMILY" != macos -o "$ISABELLE_PLATFORM_FAMILY" = macos ]
 then
@@ -211,8 +219,19 @@
           mkdir -p "$APP/Contents/$NAME"
         done
 
-        cat "$APP_TEMPLATE/Info.plist" | \
-          perl -p -e "s,{ISABELLE_NAME},${ISABELLE_NAME},g;" > "$APP/Contents/Info.plist"
+        (
+          cat "$APP_TEMPLATE/Info.plist-part1"
+
+          declare -a OPTIONS=()
+          eval "OPTIONS=($ISABELLE_JAVA_SYSTEM_OPTIONS $JEDIT_JAVA_OPTIONS $JEDIT_SYSTEM_OPTIONS)"
+          for OPT in "${OPTIONS[@]}"
+          do
+            echo "<string>$OPT</string>"
+          done
+          echo "<string>-Dapple.awt.application.name={ISABELLE_NAME}</string>"
+
+          cat "$APP_TEMPLATE/Info.plist-part2"
+        ) | perl -p -e "s,{ISABELLE_NAME},${ISABELLE_NAME},g;" > "$APP/Contents/Info.plist"
 
         for NAME in Pure.jar scala-compiler.jar scala-library.jar scala-swing.jar scala-actors.jar scala-reflect.jar
         do
--- a/src/Tools/jEdit/etc/options	Mon Sep 09 18:14:54 2013 +0200
+++ b/src/Tools/jEdit/etc/options	Mon Sep 09 20:24:15 2013 +0200
@@ -27,8 +27,11 @@
 public option jedit_symbols_search_limit : int = 50
   -- "maximum number of symbols in search result"
 
-public option jedit_mac_adapter : bool = true
-  -- "some native Mac OS X support (potential conflict with MacOSX plugin)"
+public option jedit_macos_application : bool = true
+  -- "some native Mac OS X application support (potential conflict with MacOSX plugin)"
+
+public option jedit_macos_preferences : bool = false
+  -- "native Mac OS X preferences menu"
 
 public option jedit_timing_threshold : real = 0.1
   -- "default threshold for timing display"
--- a/src/Tools/jEdit/etc/settings	Mon Sep 09 18:14:54 2013 +0200
+++ b/src/Tools/jEdit/etc/settings	Mon Sep 09 20:24:15 2013 +0200
@@ -7,9 +7,7 @@
 #JEDIT_JAVA_OPTIONS="-Xms128m -Xmx512m -Xss1m -Dactors.corePoolSize=4 -Dactors.enableForkJoin=false"
 JEDIT_JAVA_OPTIONS="-Xms128m -Xmx1024m -Xss2m -Dactors.corePoolSize=4 -Dactors.enableForkJoin=false"
 #JEDIT_JAVA_OPTIONS="-Xms512m -Xmx4096m -Xss8m -Dactors.corePoolSize=4 -Dactors.enableForkJoin=false"
-JEDIT_SYSTEM_OPTIONS="-Dapple.laf.useScreenMenuBar=true
--Dcom.apple.mrj.application.apple.menu.about.name=Isabelle/jEdit
--Dscala.repl.no-threads=true"
+JEDIT_SYSTEM_OPTIONS="-Dapple.laf.useScreenMenuBar=true -Dapple.awt.application.name=Isabelle -Dscala.repl.no-threads=true"
 
 ISABELLE_JEDIT_OPTIONS=""
 
--- a/src/Tools/jEdit/src/osx_adapter.scala	Mon Sep 09 18:14:54 2013 +0200
+++ b/src/Tools/jEdit/src/osx_adapter.scala	Mon Sep 09 20:24:15 2013 +0200
@@ -9,26 +9,41 @@
 
 import isabelle._
 
-import java.lang.{Class, ClassNotFoundException}
+import java.lang.{Class, ClassNotFoundException, NoSuchMethodException}
 import java.lang.reflect.{InvocationHandler, Method, Proxy}
 
 
 object OSX_Adapter
 {
-  def set_quit_handler(target: AnyRef, quit_handler: Method)
+  private lazy val application_class: Class[_] = Class.forName("com.apple.eawt.Application")
+  private lazy val application = application_class.getConstructor().newInstance()
+
+  def init
   {
-    set_handler(new OSX_Adapter("handle_quit", target, quit_handler))
+    if (PIDE.options.bool("jedit_macos_application")) {
+      try {
+        set_handler("handleQuit")
+        set_handler("handleAbout")
+
+        if (PIDE.options.bool("jedit_macos_preferences")) {
+          application_class.getDeclaredMethod("setEnabledPreferencesMenu", classOf[Boolean]).
+            invoke(application, java.lang.Boolean.valueOf(true))
+          set_handler("handlePreferences")
+        }
+      }
+      catch {
+        case exn: ClassNotFoundException =>
+          java.lang.System.err.println(
+            "com.apple.eawt.Application unavailable -- cannot install native OS X handler")
+      }
+    }
   }
 
-  var application: Any = null
-
-  def set_handler(adapter: OSX_Adapter)
+  private def set_handler(name: String)
   {
+    val handler = PIDE.plugin.getClass.getDeclaredMethod(name)
+    val adapter = new OSX_Adapter(name, PIDE.plugin, handler)
     try {
-      val application_class: Class[_] = Class.forName("com.apple.eawt.Application")
-      if (application == null)
-        application = application_class.getConstructor().newInstance()
-
       val application_listener_class: Class[_] =
         Class.forName("com.apple.eawt.ApplicationListener")
       val add_listener_method =
@@ -58,9 +73,12 @@
 
       val event = args(0)
       if (event != null) {
-        val set_handled_method =
-          event.getClass.getDeclaredMethod("setHandled", classOf[java.lang.Boolean])
-        set_handled_method.invoke(event, java.lang.Boolean.valueOf(handled))
+        try {
+          val set_handled_method =
+            event.getClass.getDeclaredMethod("setHandled", classOf[java.lang.Boolean])
+          set_handled_method.invoke(event, java.lang.Boolean.valueOf(handled))
+        }
+        catch { case _: NoSuchMethodException => }
       }
     }
     null
--- a/src/Tools/jEdit/src/plugin.scala	Mon Sep 09 18:14:54 2013 +0200
+++ b/src/Tools/jEdit/src/plugin.scala	Mon Sep 09 20:24:15 2013 +0200
@@ -14,6 +14,8 @@
 import scala.swing.{ListView, ScrollPane}
 
 import org.gjt.sp.jedit.{jEdit, EBMessage, EBPlugin, Buffer, View, Debug}
+import org.jedit.options.CombinedOptions
+import org.gjt.sp.jedit.gui.AboutDialog
 import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea}
 import org.gjt.sp.jedit.syntax.ModeProvider
 import org.gjt.sp.jedit.msg.{EditorStarted, BufferUpdate, EditPaneUpdate, PropertiesChanged}
@@ -222,12 +224,23 @@
 
   /* Mac OS X application hooks */
 
-  def handle_quit(): Boolean =
+  def handleQuit(): Boolean =
   {
     jEdit.exit(jEdit.getActiveView(), true)
     false
   }
 
+  def handlePreferences()
+  {
+    CombinedOptions.combinedOptions(jEdit.getActiveView())
+  }
+
+  def handleAbout(): Boolean =
+  {
+    new AboutDialog(jEdit.getActiveView())
+    true
+  }
+
 
   /* main plugin plumbing */
 
@@ -306,8 +319,7 @@
       PIDE.options.update(Options.init())
       PIDE.completion_history.load()
 
-      if (Platform.is_macos && PIDE.options.bool("jedit_mac_adapter"))
-        OSX_Adapter.set_quit_handler(this, this.getClass.getDeclaredMethod("handle_quit"))
+      if (Platform.is_macos) OSX_Adapter.init
 
       SyntaxUtilities.setStyleExtender(new Token_Markup.Style_Extender)
       if (ModeProvider.instance.isInstanceOf[ModeProvider])