dockable window for Isabelle documentation;
authorwenzelm
Tue Jun 25 16:55:10 2013 +0200 (2013-06-25 ago)
changeset 5244518a720984855
parent 52444 2cfe6656d6d6
child 52446 c4a70058ff20
dockable window for Isabelle documentation;
NEWS
src/Tools/jEdit/lib/Tools/jedit
src/Tools/jEdit/src/Isabelle.props
src/Tools/jEdit/src/actions.xml
src/Tools/jEdit/src/dockables.xml
src/Tools/jEdit/src/documentation_dockable.scala
src/Tools/jEdit/src/jEdit.props
     1.1 --- a/NEWS	Tue Jun 25 12:17:19 2013 +0200
     1.2 +++ b/NEWS	Tue Jun 25 16:55:10 2013 +0200
     1.3 @@ -39,6 +39,9 @@
     1.4  
     1.5  *** Prover IDE -- Isabelle/Scala/jEdit ***
     1.6  
     1.7 +* Dockable window "Documentation" provides access to Isabelle
     1.8 +documentation.
     1.9 +
    1.10  * Dockable window "Timing" provides an overview of relevant command
    1.11  timing information.
    1.12  
     2.1 --- a/src/Tools/jEdit/lib/Tools/jedit	Tue Jun 25 12:17:19 2013 +0200
     2.2 +++ b/src/Tools/jEdit/lib/Tools/jedit	Tue Jun 25 16:55:10 2013 +0200
     2.3 @@ -12,6 +12,7 @@
     2.4    "src/dockable.scala"
     2.5    "src/document_model.scala"
     2.6    "src/document_view.scala"
     2.7 +  "src/documentation_dockable.scala"
     2.8    "src/fold_handling.scala"
     2.9    "src/graphview_dockable.scala"
    2.10    "src/html_panel.scala"
     3.1 --- a/src/Tools/jEdit/src/Isabelle.props	Tue Jun 25 12:17:19 2013 +0200
     3.2 +++ b/src/Tools/jEdit/src/Isabelle.props	Tue Jun 25 16:55:10 2013 +0200
     3.3 @@ -30,6 +30,7 @@
     3.4  #menu actions
     3.5  plugin.isabelle.jedit.Plugin.menu.label=Isabelle
     3.6  plugin.isabelle.jedit.Plugin.menu= \
     3.7 +  isabelle.documentation-panel \
     3.8    isabelle.monitor-panel \
     3.9    isabelle.output-panel \
    3.10    isabelle.protocol-panel \
    3.11 @@ -39,6 +40,7 @@
    3.12    isabelle.syslog-panel \
    3.13    isabelle.theories-panel \
    3.14    isabelle.timing-panel
    3.15 +isabelle.documentation-panel.label=Documentation panel
    3.16  isabelle.monitor-panel.label=Monitor panel
    3.17  isabelle.output-panel.label=Output panel
    3.18  isabelle.protocol-panel.label=Protocol panel
    3.19 @@ -56,6 +58,7 @@
    3.20  isabelle-output.title=Output
    3.21  isabelle-protocol.title=Protocol
    3.22  isabelle-raw-output.title=Raw Output
    3.23 +isabelle-documentation.title=Documentation
    3.24  isabelle-readme.title=README
    3.25  isabelle-symbols.title=Symbols
    3.26  isabelle-syslog.title=Syslog
     4.1 --- a/src/Tools/jEdit/src/actions.xml	Tue Jun 25 12:17:19 2013 +0200
     4.2 +++ b/src/Tools/jEdit/src/actions.xml	Tue Jun 25 16:55:10 2013 +0200
     4.3 @@ -17,6 +17,11 @@
     4.4  			wm.addDockableWindow("isabelle-syslog");
     4.5  		</CODE>
     4.6  	</ACTION>
     4.7 +	<ACTION NAME="isabelle.documentation-panel">
     4.8 +		<CODE>
     4.9 +			wm.addDockableWindow("isabelle-documentation");
    4.10 +		</CODE>
    4.11 +	</ACTION>
    4.12  	<ACTION NAME="isabelle.readme-panel">
    4.13  		<CODE>
    4.14  			wm.addDockableWindow("isabelle-readme");
     5.1 --- a/src/Tools/jEdit/src/dockables.xml	Tue Jun 25 12:17:19 2013 +0200
     5.2 +++ b/src/Tools/jEdit/src/dockables.xml	Tue Jun 25 16:55:10 2013 +0200
     5.3 @@ -11,6 +11,9 @@
     5.4  	<DOCKABLE NAME="isabelle-syslog" MOVABLE="TRUE">
     5.5  		new isabelle.jedit.Syslog_Dockable(view, position);
     5.6  	</DOCKABLE>
     5.7 +	<DOCKABLE NAME="isabelle-documentation" MOVABLE="TRUE">
     5.8 +		new isabelle.jedit.Documentation_Dockable(view, position);
     5.9 +	</DOCKABLE>
    5.10  	<DOCKABLE NAME="isabelle-readme" MOVABLE="TRUE">
    5.11  		new isabelle.jedit.README_Dockable(view, position);
    5.12  	</DOCKABLE>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/Tools/jEdit/src/documentation_dockable.scala	Tue Jun 25 16:55:10 2013 +0200
     6.3 @@ -0,0 +1,67 @@
     6.4 +/*  Title:      Tools/jEdit/src/documentation_dockable.scala
     6.5 +    Author:     Makarius
     6.6 +
     6.7 +Dockable window for Isabelle documentation.
     6.8 +*/
     6.9 +
    6.10 +package isabelle.jedit
    6.11 +
    6.12 +
    6.13 +import isabelle._
    6.14 +
    6.15 +import java.awt.{Dimension, GridLayout}
    6.16 +import javax.swing.{JTree, JScrollPane}
    6.17 +import javax.swing.tree.{DefaultMutableTreeNode, TreeSelectionModel}
    6.18 +import javax.swing.event.{TreeSelectionEvent, TreeSelectionListener}
    6.19 +
    6.20 +import org.gjt.sp.jedit.{View, OperatingSystem}
    6.21 +
    6.22 +
    6.23 +class Documentation_Dockable(view: View, position: String) extends Dockable(view, position)
    6.24 +{
    6.25 +  Swing_Thread.require()
    6.26 +
    6.27 +  private val docs = Doc.contents()
    6.28 +
    6.29 +  private case class Documentation(name: String, title: String)
    6.30 +  {
    6.31 +    override def toString =
    6.32 +      "<html><b>" + HTML.encode(name) + "</b>:  " + HTML.encode(title) + "</html>"
    6.33 +  }
    6.34 +
    6.35 +  private val root = new DefaultMutableTreeNode
    6.36 +  docs foreach {
    6.37 +    case Doc.Section(text) =>
    6.38 +      root.add(new DefaultMutableTreeNode(text))
    6.39 +    case Doc.Doc(name, title) =>
    6.40 +      root.getLastChild.asInstanceOf[DefaultMutableTreeNode]
    6.41 +        .add(new DefaultMutableTreeNode(Documentation(name, title)))
    6.42 +  }
    6.43 +
    6.44 +  private val tree = new JTree(root)
    6.45 +  if (!OperatingSystem.isMacOSLF)
    6.46 +    tree.putClientProperty("JTree.lineStyle", "Angled")
    6.47 +  tree.getSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION)
    6.48 +  tree.addTreeSelectionListener(
    6.49 +    new TreeSelectionListener {
    6.50 +      override def valueChanged(e: TreeSelectionEvent)
    6.51 +      {
    6.52 +        tree.getLastSelectedPathComponent match {
    6.53 +          case node: DefaultMutableTreeNode =>
    6.54 +            node.getUserObject match {
    6.55 +              case Documentation(name, _) => Doc.view(name)
    6.56 +              case _ =>
    6.57 +            }
    6.58 +          case _ =>
    6.59 +        }
    6.60 +      }
    6.61 +    })
    6.62 +  tree.setRootVisible(false)
    6.63 +  tree.setVisibleRowCount(docs.length)
    6.64 +  (0 until docs.length).foreach(tree.expandRow)
    6.65 +
    6.66 +  private val tree_view = new JScrollPane(tree)
    6.67 +  tree_view.setMinimumSize(new Dimension(100, 50))
    6.68 +
    6.69 +  set_content(tree_view)
    6.70 +}
     7.1 --- a/src/Tools/jEdit/src/jEdit.props	Tue Jun 25 12:17:19 2013 +0200
     7.2 +++ b/src/Tools/jEdit/src/jEdit.props	Tue Jun 25 16:55:10 2013 +0200
     7.3 @@ -181,6 +181,7 @@
     7.4  isabelle-output.dock-position=bottom
     7.5  isabelle-output.height=174
     7.6  isabelle-output.width=412
     7.7 +isabelle-documentation.dock-position=right
     7.8  isabelle-readme.dock-position=bottom
     7.9  isabelle-symbols.dock-position=bottom
    7.10  isabelle-theories.dock-position=right