minimal component and build setup for graphview;
authorwenzelm
Mon Sep 24 21:16:33 2012 +0200 (2012-09-24)
changeset 49558af7b652180d5
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
     1.1 --- a/etc/components	Mon Sep 24 20:22:58 2012 +0200
     1.2 +++ b/etc/components	Mon Sep 24 21:16:33 2012 +0200
     1.3 @@ -1,5 +1,6 @@
     1.4  src/Tools/Code
     1.5  src/Tools/jEdit
     1.6 +src/Tools/Graphview
     1.7  src/Tools/WWW_Find
     1.8  src/HOL/Mirabelle
     1.9  src/HOL/Mutabelle
     2.1 --- a/src/Pure/build-jars	Mon Sep 24 20:22:58 2012 +0200
     2.2 +++ b/src/Pure/build-jars	Mon Sep 24 21:16:33 2012 +0200
     2.3 @@ -126,8 +126,7 @@
     2.4  [ "$#" -ne 0 ] && usage
     2.5  
     2.6  
     2.7 -
     2.8 -# build
     2.9 +## build
    2.10  
    2.11  TARGET_DIR="$ISABELLE_HOME/lib/classes"
    2.12  TARGET="$TARGET_DIR/ext/Pure.jar"
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/Tools/Graphview/etc/settings	Mon Sep 24 21:16:33 2012 +0200
     3.3 @@ -0,0 +1,6 @@
     3.4 +# -*- shell-script -*- :mode=shellscript:
     3.5 +
     3.6 +GRAPHVIEW_HOME="$COMPONENT"
     3.7 +
     3.8 +ISABELLE_TOOLS="$ISABELLE_TOOLS:$GRAPHVIEW_HOME/lib/Tools"
     3.9 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/Tools/Graphview/lib/Tools/graphview	Mon Sep 24 21:16:33 2012 +0200
     4.3 @@ -0,0 +1,177 @@
     4.4 +#!/usr/bin/env bash
     4.5 +#
     4.6 +# Author: Markus Kaiser, TU Muenchen
     4.7 +# Author: Makarius
     4.8 +#
     4.9 +# DESCRIPTION: graphview command-line tool wrapper
    4.10 +
    4.11 +## sources
    4.12 +
    4.13 +declare -a SOURCES=(
    4.14 +#  "src/dockable.scala"
    4.15 +  "src/floating_dialog.scala"
    4.16 +  "src/frame.scala"
    4.17 +  "src/graph_panel.scala"
    4.18 +  "src/graph_xml.scala"
    4.19 +  "src/layout_pendulum.scala"
    4.20 +  "src/main_panel.scala"
    4.21 +  "src/model.scala"
    4.22 +  "src/mutator_dialog.scala"
    4.23 +  "src/mutator_event.scala"
    4.24 +  "src/mutator.scala"
    4.25 +  "src/parameters.scala"
    4.26 +  "src/popups.scala"
    4.27 +  "src/shapes.scala"
    4.28 +  "src/tooltips.scala"
    4.29 +  "src/visualizer.scala"
    4.30 +  "../jEdit/src/html_panel.scala"
    4.31 +)
    4.32 +
    4.33 +
    4.34 +## diagnostics
    4.35 +
    4.36 +PRG="$(basename "$0")"
    4.37 +
    4.38 +function usage()
    4.39 +{
    4.40 +  echo
    4.41 +  echo "Usage: isabelle $PRG [OPTIONS] GRAPH_FILE"
    4.42 +  echo
    4.43 +  echo "  Options are:"
    4.44 +  echo "    -b           build only"
    4.45 +  echo "    -f           fresh build"
    4.46 +  echo
    4.47 +  exit 1
    4.48 +}
    4.49 +
    4.50 +function fail()
    4.51 +{
    4.52 +  echo "$1" >&2
    4.53 +  exit 2
    4.54 +}
    4.55 +
    4.56 +function failed()
    4.57 +{
    4.58 +  fail "Failed!"
    4.59 +}
    4.60 +
    4.61 +
    4.62 +## process command line
    4.63 +
    4.64 +# options
    4.65 +
    4.66 +BUILD_ONLY=false
    4.67 +BUILD_JARS="jars"
    4.68 +
    4.69 +while getopts "bf" OPT
    4.70 +do
    4.71 +  case "$OPT" in
    4.72 +    b)
    4.73 +      BUILD_ONLY=true
    4.74 +      ;;
    4.75 +    f)
    4.76 +      BUILD_JARS="jars_fresh"
    4.77 +      ;;
    4.78 +    \?)
    4.79 +      usage
    4.80 +      ;;
    4.81 +  esac
    4.82 +done
    4.83 +
    4.84 +
    4.85 +# args
    4.86 +
    4.87 +GRAPH_FILE=""
    4.88 +
    4.89 +if [ "$#" -eq 0 -a "$BUILD_ONLY" = false ]; then
    4.90 +  usage
    4.91 +elif [ "$#" -eq 1 ]; then
    4.92 +  GRAPH_FILE="$1"
    4.93 +  shift
    4.94 +else
    4.95 +  usage
    4.96 +fi
    4.97 +
    4.98 +
    4.99 +## build
   4.100 +
   4.101 +[ -e "$ISABELLE_HOME/Admin/build" ] && \
   4.102 +  { "$ISABELLE_HOME/Admin/build" "$BUILD_JARS" || exit $?; }
   4.103 +
   4.104 +pushd "$GRAPHVIEW_HOME" >/dev/null || failed
   4.105 +
   4.106 +PURE_JAR="$ISABELLE_HOME/lib/classes/ext/Pure.jar"
   4.107 +COBRA_JAR="$ISABELLE_JEDIT_BUILD_HOME/contrib/cobra.jar"
   4.108 +
   4.109 +TARGET_DIR="$ISABELLE_HOME/lib/classes"
   4.110 +TARGET="$TARGET_DIR/ext/Graphview.jar"
   4.111 +
   4.112 +declare -a UPDATED=()
   4.113 +
   4.114 +if [ "$BUILD_JARS" = jars_fresh ]; then
   4.115 +  OUTDATED=true
   4.116 +else
   4.117 +  OUTDATED=false
   4.118 +  if [ ! -e "$TARGET" ]; then
   4.119 +    OUTDATED=true
   4.120 +  else
   4.121 +    if [ -n "$ISABELLE_JEDIT_BUILD_HOME" ]; then
   4.122 +      declare -a DEPS=("$COBRA_JAR" "$PURE_JAR" "${SOURCES[@]}")
   4.123 +    elif [ -e "$ISABELLE_HOME/Admin/build" ]; then
   4.124 +      declare -a DEPS=("$PURE_JAR" "${SOURCES[@]}")
   4.125 +    else
   4.126 +      declare -a DEPS=()
   4.127 +    fi
   4.128 +    for DEP in "${DEPS[@]}"
   4.129 +    do
   4.130 +      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   4.131 +      [ "$DEP" -nt "$TARGET" ] && {
   4.132 +        OUTDATED=true
   4.133 +        UPDATED["${#UPDATED[@]}"]="$DEP"
   4.134 +      }
   4.135 +    done
   4.136 +  fi
   4.137 +fi
   4.138 +
   4.139 +if [ "$OUTDATED" = true ]
   4.140 +then
   4.141 +  echo "### Building Isabelle/Graphview ..."
   4.142 +
   4.143 +  [ "${#UPDATED[@]}" -gt 0 ] && {
   4.144 +    echo "Changed files:"
   4.145 +    for FILE in "${UPDATED[@]}"
   4.146 +    do
   4.147 +      echo "  $FILE"
   4.148 +    done
   4.149 +  }
   4.150 +
   4.151 +  [ -z "$ISABELLE_JEDIT_BUILD_HOME" ] && \
   4.152 +    fail "Unknown ISABELLE_JEDIT_BUILD_HOME -- missing auxiliary component"
   4.153 +
   4.154 +  rm -rf classes && mkdir classes
   4.155 +
   4.156 +  cp -p -R -f "$COBRA_JAR" "$TARGET_DIR/ext" || failed
   4.157 +
   4.158 +  (
   4.159 +    for JAR in "$COBRA_JAR" "$PURE_JAR"
   4.160 +    do
   4.161 +      CLASSPATH="$CLASSPATH:$JAR"
   4.162 +    done
   4.163 +    CLASSPATH="$(jvmpath "$CLASSPATH")"
   4.164 +    exec "$SCALA_HOME/bin/scalac" $ISABELLE_SCALA_BUILD_OPTIONS -d classes "${SOURCES[@]}"
   4.165 +  ) || fail "Failed to compile sources"
   4.166 +
   4.167 +  cd classes
   4.168 +  isabelle_jdk jar cf "$TARGET" * || failed
   4.169 +  cd ..
   4.170 +  rm -rf classes
   4.171 +fi
   4.172 +
   4.173 +popd >/dev/null
   4.174 +
   4.175 +
   4.176 +## run
   4.177 +
   4.178 +[ "$BUILD_ONLY" = true ] || {
   4.179 +  exec "$ISABELLE_TOOL" java isabelle.graphview.Graphview_Frame "$(jvmpath "$GRAPH_FILE")"
   4.180 +}
     5.1 --- a/src/Tools/Graphview/src/floating_dialog.scala	Mon Sep 24 20:22:58 2012 +0200
     5.2 +++ b/src/Tools/Graphview/src/floating_dialog.scala	Mon Sep 24 21:16:33 2012 +0200
     5.3 @@ -8,7 +8,7 @@
     5.4  
     5.5  
     5.6  import isabelle._
     5.7 -import isabelle.jedit._
     5.8 +import isabelle.jedit.HTML_Panel
     5.9  
    5.10  import scala.swing.{Dialog, BorderPanel, Component}
    5.11  import java.awt.{Point, Dimension}
     6.1 --- a/src/Tools/Graphview/src/graph_panel.scala	Mon Sep 24 20:22:58 2012 +0200
     6.2 +++ b/src/Tools/Graphview/src/graph_panel.scala	Mon Sep 24 21:16:33 2012 +0200
     6.3 @@ -6,6 +6,7 @@
     6.4  
     6.5  package isabelle.graphview
     6.6  
     6.7 +import isabelle._
     6.8  
     6.9  import java.awt.{Dimension, Graphics2D, Point, Rectangle}
    6.10  import java.awt.geom.{AffineTransform, Point2D}
     7.1 --- a/src/Tools/Graphview/src/mutator.scala	Mon Sep 24 20:22:58 2012 +0200
     7.2 +++ b/src/Tools/Graphview/src/mutator.scala	Mon Sep 24 21:16:33 2012 +0200
     7.3 @@ -7,7 +7,8 @@
     7.4  package isabelle.graphview
     7.5  
     7.6  
     7.7 -import isabelle.Graph
     7.8 +import isabelle._
     7.9 +
    7.10  import java.awt.Color
    7.11  import scala.collection.immutable.SortedSet
    7.12  
     8.1 --- a/src/Tools/Graphview/src/mutator_dialog.scala	Mon Sep 24 20:22:58 2012 +0200
     8.2 +++ b/src/Tools/Graphview/src/mutator_dialog.scala	Mon Sep 24 21:16:33 2012 +0200
     8.3 @@ -6,6 +6,7 @@
     8.4  
     8.5  package isabelle.graphview
     8.6  
     8.7 +import isabelle._
     8.8  
     8.9  import java.awt.Color
    8.10  import java.awt.FocusTraversalPolicy
     9.1 --- a/src/Tools/Graphview/src/parameters.scala	Mon Sep 24 20:22:58 2012 +0200
     9.2 +++ b/src/Tools/Graphview/src/parameters.scala	Mon Sep 24 21:16:33 2012 +0200
     9.3 @@ -6,27 +6,15 @@
     9.4  
     9.5  package isabelle.graphview
     9.6  
     9.7 +import isabelle._
     9.8  
     9.9 -import isabelle._
    9.10 -import isabelle.jedit._
    9.11  import java.awt.Color
    9.12  
    9.13  
    9.14 -//LocaleBrowser may or may not run within jEdit, so all jEdit specific options
    9.15 -//have to have fallbacks.
    9.16  object Parameters
    9.17  {
    9.18 -  def font_family(): String =
    9.19 -    try {
    9.20 -      Isabelle.font_family()
    9.21 -    }
    9.22 -    catch { case _ => "IsabelleText" }
    9.23 -
    9.24 -  def font_size(): Int =
    9.25 -    try {
    9.26 -      scala.math.round(Isabelle.font_size())
    9.27 -    }
    9.28 -    catch { case _ => 16 }
    9.29 +  val font_family: String = "IsabelleText"
    9.30 +  val font_size: Int = 16
    9.31  
    9.32    //Should not fail since this is in the isabelle environment.
    9.33    def tooltip_css(): String =
    10.1 --- a/src/Tools/Graphview/src/popups.scala	Mon Sep 24 20:22:58 2012 +0200
    10.2 +++ b/src/Tools/Graphview/src/popups.scala	Mon Sep 24 21:16:33 2012 +0200
    10.3 @@ -10,7 +10,7 @@
    10.4  import isabelle._
    10.5  import isabelle.graphview.Mutators._
    10.6  import javax.swing.JPopupMenu
    10.7 -import scala.swing.{Action, Menu, MenuItem, Seperator}
    10.8 +import scala.swing.{Action, Menu, MenuItem, Separator}
    10.9  
   10.10  
   10.11  object Popups {