81309
|
1 |
/* Title: Tools/jEdit/src/tree_text_area.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
GUI component for tree view with pretty-printed text area.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle.jedit
|
|
8 |
|
|
9 |
|
|
10 |
import isabelle._
|
|
11 |
|
|
12 |
import java.awt.{BorderLayout, Dimension}
|
|
13 |
import java.awt.event.{ComponentEvent, ComponentAdapter, KeyEvent, FocusAdapter, FocusEvent,
|
|
14 |
MouseEvent, MouseAdapter}
|
|
15 |
import javax.swing.{JTree, JMenuItem}
|
|
16 |
import javax.swing.tree.{DefaultMutableTreeNode, DefaultTreeModel, TreeSelectionModel}
|
|
17 |
import javax.swing.event.{TreeSelectionEvent, TreeSelectionListener}
|
|
18 |
|
|
19 |
import scala.collection.immutable.SortedMap
|
|
20 |
import scala.swing.{Button, Label, Component, ScrollPane, SplitPane, Orientation, BorderPanel}
|
|
21 |
import scala.swing.event.ButtonClicked
|
|
22 |
|
|
23 |
import org.gjt.sp.jedit.{jEdit, View}
|
|
24 |
import org.gjt.sp.jedit.menu.EnhancedMenuItem
|
|
25 |
import org.gjt.sp.jedit.textarea.JEditTextArea
|
|
26 |
|
|
27 |
|
|
28 |
class Tree_Text_Area(view: View, root_name: String = "Overview") {
|
|
29 |
GUI_Thread.require {}
|
|
30 |
|
|
31 |
|
|
32 |
/* tree view */
|
|
33 |
|
|
34 |
val root: DefaultMutableTreeNode = new DefaultMutableTreeNode(root_name)
|
|
35 |
|
|
36 |
val tree: JTree = new JTree(root)
|
|
37 |
tree.setRowHeight(0)
|
|
38 |
tree.getSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION)
|
|
39 |
|
|
40 |
def clear(): Unit = {
|
|
41 |
tree.clearSelection()
|
|
42 |
root.removeAllChildren()
|
|
43 |
}
|
|
44 |
|
|
45 |
def reload(): Unit =
|
|
46 |
tree.getModel.asInstanceOf[DefaultTreeModel].reload(root)
|
|
47 |
|
|
48 |
|
|
49 |
/* text area */
|
|
50 |
|
|
51 |
val pretty_text_area: Pretty_Text_Area = new Pretty_Text_Area(view)
|
|
52 |
|
|
53 |
def handle_resize(): Unit = ()
|
|
54 |
def handle_update(): Unit = ()
|
|
55 |
|
|
56 |
|
|
57 |
/* main pane */
|
|
58 |
|
|
59 |
val tree_pane: ScrollPane = new ScrollPane(Component.wrap(tree))
|
|
60 |
tree_pane.horizontalScrollBarPolicy = ScrollPane.BarPolicy.Always
|
|
61 |
tree_pane.verticalScrollBarPolicy = ScrollPane.BarPolicy.Always
|
|
62 |
tree_pane.minimumSize = new Dimension(200, 100)
|
|
63 |
|
|
64 |
val main_pane: SplitPane = new SplitPane(Orientation.Vertical) {
|
|
65 |
oneTouchExpandable = true
|
|
66 |
leftComponent = tree_pane
|
|
67 |
rightComponent = Component.wrap(pretty_text_area)
|
|
68 |
}
|
|
69 |
}
|