minimal component and build setup for graphview;
authorwenzelm
Mon, 24 Sep 2012 21:16:33 +0200
changeset 49558 af7b652180d5
parent 49557 61988f9df94d
child 49559 c3a6e110679b
minimal component and build setup for graphview;
etc/components
src/Pure/build-jars
src/Tools/Graphview/etc/settings
src/Tools/Graphview/lib/Tools/graphview
src/Tools/Graphview/src/floating_dialog.scala
src/Tools/Graphview/src/graph_panel.scala
src/Tools/Graphview/src/mutator.scala
src/Tools/Graphview/src/mutator_dialog.scala
src/Tools/Graphview/src/parameters.scala
src/Tools/Graphview/src/popups.scala
--- a/etc/components	Mon Sep 24 20:22:58 2012 +0200
+++ b/etc/components	Mon Sep 24 21:16:33 2012 +0200
@@ -1,5 +1,6 @@
 src/Tools/Code
 src/Tools/jEdit
+src/Tools/Graphview
 src/Tools/WWW_Find
 src/HOL/Mirabelle
 src/HOL/Mutabelle
--- a/src/Pure/build-jars	Mon Sep 24 20:22:58 2012 +0200
+++ b/src/Pure/build-jars	Mon Sep 24 21:16:33 2012 +0200
@@ -126,8 +126,7 @@
 [ "$#" -ne 0 ] && usage
 
 
-
-# build
+## build
 
 TARGET_DIR="$ISABELLE_HOME/lib/classes"
 TARGET="$TARGET_DIR/ext/Pure.jar"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Tools/Graphview/etc/settings	Mon Sep 24 21:16:33 2012 +0200
@@ -0,0 +1,6 @@
+# -*- shell-script -*- :mode=shellscript:
+
+GRAPHVIEW_HOME="$COMPONENT"
+
+ISABELLE_TOOLS="$ISABELLE_TOOLS:$GRAPHVIEW_HOME/lib/Tools"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Tools/Graphview/lib/Tools/graphview	Mon Sep 24 21:16:33 2012 +0200
@@ -0,0 +1,177 @@
+#!/usr/bin/env bash
+#
+# Author: Markus Kaiser, TU Muenchen
+# Author: Makarius
+#
+# DESCRIPTION: graphview command-line tool wrapper
+
+## sources
+
+declare -a SOURCES=(
+#  "src/dockable.scala"
+  "src/floating_dialog.scala"
+  "src/frame.scala"
+  "src/graph_panel.scala"
+  "src/graph_xml.scala"
+  "src/layout_pendulum.scala"
+  "src/main_panel.scala"
+  "src/model.scala"
+  "src/mutator_dialog.scala"
+  "src/mutator_event.scala"
+  "src/mutator.scala"
+  "src/parameters.scala"
+  "src/popups.scala"
+  "src/shapes.scala"
+  "src/tooltips.scala"
+  "src/visualizer.scala"
+  "../jEdit/src/html_panel.scala"
+)
+
+
+## diagnostics
+
+PRG="$(basename "$0")"
+
+function usage()
+{
+  echo
+  echo "Usage: isabelle $PRG [OPTIONS] GRAPH_FILE"
+  echo
+  echo "  Options are:"
+  echo "    -b           build only"
+  echo "    -f           fresh build"
+  echo
+  exit 1
+}
+
+function fail()
+{
+  echo "$1" >&2
+  exit 2
+}
+
+function failed()
+{
+  fail "Failed!"
+}
+
+
+## process command line
+
+# options
+
+BUILD_ONLY=false
+BUILD_JARS="jars"
+
+while getopts "bf" OPT
+do
+  case "$OPT" in
+    b)
+      BUILD_ONLY=true
+      ;;
+    f)
+      BUILD_JARS="jars_fresh"
+      ;;
+    \?)
+      usage
+      ;;
+  esac
+done
+
+
+# args
+
+GRAPH_FILE=""
+
+if [ "$#" -eq 0 -a "$BUILD_ONLY" = false ]; then
+  usage
+elif [ "$#" -eq 1 ]; then
+  GRAPH_FILE="$1"
+  shift
+else
+  usage
+fi
+
+
+## build
+
+[ -e "$ISABELLE_HOME/Admin/build" ] && \
+  { "$ISABELLE_HOME/Admin/build" "$BUILD_JARS" || exit $?; }
+
+pushd "$GRAPHVIEW_HOME" >/dev/null || failed
+
+PURE_JAR="$ISABELLE_HOME/lib/classes/ext/Pure.jar"
+COBRA_JAR="$ISABELLE_JEDIT_BUILD_HOME/contrib/cobra.jar"
+
+TARGET_DIR="$ISABELLE_HOME/lib/classes"
+TARGET="$TARGET_DIR/ext/Graphview.jar"
+
+declare -a UPDATED=()
+
+if [ "$BUILD_JARS" = jars_fresh ]; then
+  OUTDATED=true
+else
+  OUTDATED=false
+  if [ ! -e "$TARGET" ]; then
+    OUTDATED=true
+  else
+    if [ -n "$ISABELLE_JEDIT_BUILD_HOME" ]; then
+      declare -a DEPS=("$COBRA_JAR" "$PURE_JAR" "${SOURCES[@]}")
+    elif [ -e "$ISABELLE_HOME/Admin/build" ]; then
+      declare -a DEPS=("$PURE_JAR" "${SOURCES[@]}")
+    else
+      declare -a DEPS=()
+    fi
+    for DEP in "${DEPS[@]}"
+    do
+      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
+      [ "$DEP" -nt "$TARGET" ] && {
+        OUTDATED=true
+        UPDATED["${#UPDATED[@]}"]="$DEP"
+      }
+    done
+  fi
+fi
+
+if [ "$OUTDATED" = true ]
+then
+  echo "### Building Isabelle/Graphview ..."
+
+  [ "${#UPDATED[@]}" -gt 0 ] && {
+    echo "Changed files:"
+    for FILE in "${UPDATED[@]}"
+    do
+      echo "  $FILE"
+    done
+  }
+
+  [ -z "$ISABELLE_JEDIT_BUILD_HOME" ] && \
+    fail "Unknown ISABELLE_JEDIT_BUILD_HOME -- missing auxiliary component"
+
+  rm -rf classes && mkdir classes
+
+  cp -p -R -f "$COBRA_JAR" "$TARGET_DIR/ext" || failed
+
+  (
+    for JAR in "$COBRA_JAR" "$PURE_JAR"
+    do
+      CLASSPATH="$CLASSPATH:$JAR"
+    done
+    CLASSPATH="$(jvmpath "$CLASSPATH")"
+    exec "$SCALA_HOME/bin/scalac" $ISABELLE_SCALA_BUILD_OPTIONS -d classes "${SOURCES[@]}"
+  ) || fail "Failed to compile sources"
+
+  cd classes
+  isabelle_jdk jar cf "$TARGET" * || failed
+  cd ..
+  rm -rf classes
+fi
+
+popd >/dev/null
+
+
+## run
+
+[ "$BUILD_ONLY" = true ] || {
+  exec "$ISABELLE_TOOL" java isabelle.graphview.Graphview_Frame "$(jvmpath "$GRAPH_FILE")"
+}
--- a/src/Tools/Graphview/src/floating_dialog.scala	Mon Sep 24 20:22:58 2012 +0200
+++ b/src/Tools/Graphview/src/floating_dialog.scala	Mon Sep 24 21:16:33 2012 +0200
@@ -8,7 +8,7 @@
 
 
 import isabelle._
-import isabelle.jedit._
+import isabelle.jedit.HTML_Panel
 
 import scala.swing.{Dialog, BorderPanel, Component}
 import java.awt.{Point, Dimension}
--- a/src/Tools/Graphview/src/graph_panel.scala	Mon Sep 24 20:22:58 2012 +0200
+++ b/src/Tools/Graphview/src/graph_panel.scala	Mon Sep 24 21:16:33 2012 +0200
@@ -6,6 +6,7 @@
 
 package isabelle.graphview
 
+import isabelle._
 
 import java.awt.{Dimension, Graphics2D, Point, Rectangle}
 import java.awt.geom.{AffineTransform, Point2D}
--- a/src/Tools/Graphview/src/mutator.scala	Mon Sep 24 20:22:58 2012 +0200
+++ b/src/Tools/Graphview/src/mutator.scala	Mon Sep 24 21:16:33 2012 +0200
@@ -7,7 +7,8 @@
 package isabelle.graphview
 
 
-import isabelle.Graph
+import isabelle._
+
 import java.awt.Color
 import scala.collection.immutable.SortedSet
 
--- a/src/Tools/Graphview/src/mutator_dialog.scala	Mon Sep 24 20:22:58 2012 +0200
+++ b/src/Tools/Graphview/src/mutator_dialog.scala	Mon Sep 24 21:16:33 2012 +0200
@@ -6,6 +6,7 @@
 
 package isabelle.graphview
 
+import isabelle._
 
 import java.awt.Color
 import java.awt.FocusTraversalPolicy
--- a/src/Tools/Graphview/src/parameters.scala	Mon Sep 24 20:22:58 2012 +0200
+++ b/src/Tools/Graphview/src/parameters.scala	Mon Sep 24 21:16:33 2012 +0200
@@ -6,27 +6,15 @@
 
 package isabelle.graphview
 
+import isabelle._
 
-import isabelle._
-import isabelle.jedit._
 import java.awt.Color
 
 
-//LocaleBrowser may or may not run within jEdit, so all jEdit specific options
-//have to have fallbacks.
 object Parameters
 {
-  def font_family(): String =
-    try {
-      Isabelle.font_family()
-    }
-    catch { case _ => "IsabelleText" }
-
-  def font_size(): Int =
-    try {
-      scala.math.round(Isabelle.font_size())
-    }
-    catch { case _ => 16 }
+  val font_family: String = "IsabelleText"
+  val font_size: Int = 16
 
   //Should not fail since this is in the isabelle environment.
   def tooltip_css(): String =
--- a/src/Tools/Graphview/src/popups.scala	Mon Sep 24 20:22:58 2012 +0200
+++ b/src/Tools/Graphview/src/popups.scala	Mon Sep 24 21:16:33 2012 +0200
@@ -10,7 +10,7 @@
 import isabelle._
 import isabelle.graphview.Mutators._
 import javax.swing.JPopupMenu
-import scala.swing.{Action, Menu, MenuItem, Seperator}
+import scala.swing.{Action, Menu, MenuItem, Separator}
 
 
 object Popups {