author | wenzelm |
Fri, 15 Nov 2024 13:31:36 +0100 | |
changeset 81448 | 9b2e13b3ee43 |
parent 75393 | 87ebf5a50283 |
permissions | -rw-r--r-- |
73987
fc363a3b690a
build.props for isabelle.jar, including isabelle.jedit;
wenzelm
parents:
73340
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/dockable.scala |
37066 | 2 |
Author: Makarius |
3 |
||
4 |
Generic dockable window. |
|
5 |
*/ |
|
6 |
||
73987
fc363a3b690a
build.props for isabelle.jar, including isabelle.jedit;
wenzelm
parents:
73340
diff
changeset
|
7 |
package isabelle.jedit |
37066 | 8 |
|
9 |
||
10 |
import isabelle._ |
|
11 |
||
12 |
import java.awt.{Dimension, Component, BorderLayout} |
|
13 |
import javax.swing.JPanel |
|
14 |
||
15 |
import org.gjt.sp.jedit.View |
|
53787
e64389fe2d2c
focus on default component according to jEdit window management;
wenzelm
parents:
43282
diff
changeset
|
16 |
import org.gjt.sp.jedit.gui.{DefaultFocusComponent, DockableWindowManager} |
37066 | 17 |
|
18 |
||
53787
e64389fe2d2c
focus on default component according to jEdit window management;
wenzelm
parents:
43282
diff
changeset
|
19 |
class Dockable(view: View, position: String) |
75393 | 20 |
extends JPanel(new BorderLayout) with DefaultFocusComponent { |
37066 | 21 |
if (position == DockableWindowManager.FLOATING) |
22 |
setPreferredSize(new Dimension(500, 250)) |
|
23 |
||
73340 | 24 |
def focusOnDefaultComponent(): Unit = JEdit_Lib.request_focus_view(view) |
53787
e64389fe2d2c
focus on default component according to jEdit window management;
wenzelm
parents:
43282
diff
changeset
|
25 |
|
73340 | 26 |
def set_content(c: Component): Unit = add(c, BorderLayout.CENTER) |
27 |
def set_content(c: scala.swing.Component): Unit = add(c.peer, BorderLayout.CENTER) |
|
37066 | 28 |
|
56906
408b526911f7
some odd tricks to provide "Detach" menu item, via "PIDE" docking framework;
wenzelm
parents:
53787
diff
changeset
|
29 |
def detach_operation: Option[() => Unit] = None |
408b526911f7
some odd tricks to provide "Detach" menu item, via "PIDE" docking framework;
wenzelm
parents:
53787
diff
changeset
|
30 |
|
73340 | 31 |
protected def init(): Unit = {} |
32 |
protected def exit(): Unit = {} |
|
37066 | 33 |
|
75393 | 34 |
override def addNotify(): Unit = { |
37066 | 35 |
super.addNotify() |
36 |
init() |
|
37 |
} |
|
38 |
||
75393 | 39 |
override def removeNotify(): Unit = { |
37066 | 40 |
exit() |
41 |
super.removeNotify() |
|
42 |
} |
|
43 |
} |