author | wenzelm |
Fri, 01 Sep 2017 15:15:29 +0200 | |
changeset 66591 | 6efa351190d0 |
parent 56931 | src/Tools/jEdit/src/dockable.scala@9ecf2cbfc80d |
child 71525 | d7b0d078266d |
permissions | -rw-r--r-- |
66591
6efa351190d0
more robust: provide docking framework via base plugin;
wenzelm
parents:
56931
diff
changeset
|
1 |
/* Title: Tools/jEdit/src-base/dockable.scala |
37066 | 2 |
Author: Makarius |
3 |
||
4 |
Generic dockable window. |
|
5 |
*/ |
|
6 |
||
66591
6efa351190d0
more robust: provide docking framework via base plugin;
wenzelm
parents:
56931
diff
changeset
|
7 |
package isabelle.jedit_base |
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) |
e64389fe2d2c
focus on default component according to jEdit window management;
wenzelm
parents:
43282
diff
changeset
|
20 |
extends JPanel(new BorderLayout) with DefaultFocusComponent |
37066 | 21 |
{ |
22 |
if (position == DockableWindowManager.FLOATING) |
|
23 |
setPreferredSize(new Dimension(500, 250)) |
|
24 |
||
56931
9ecf2cbfc80d
always bounce focus back to main text area, unless explicit focus component is given here (see also 7b65f4da136d);
wenzelm
parents:
56906
diff
changeset
|
25 |
def focusOnDefaultComponent { JEdit_Lib.request_focus_view(view) } |
53787
e64389fe2d2c
focus on default component according to jEdit window management;
wenzelm
parents:
43282
diff
changeset
|
26 |
|
37067 | 27 |
def set_content(c: Component) { add(c, BorderLayout.CENTER) } |
28 |
def set_content(c: scala.swing.Component) { add(c.peer, BorderLayout.CENTER) } |
|
37066 | 29 |
|
56906
408b526911f7
some odd tricks to provide "Detach" menu item, via "PIDE" docking framework;
wenzelm
parents:
53787
diff
changeset
|
30 |
def detach_operation: Option[() => Unit] = None |
408b526911f7
some odd tricks to provide "Detach" menu item, via "PIDE" docking framework;
wenzelm
parents:
53787
diff
changeset
|
31 |
|
37066 | 32 |
protected def init() { } |
33 |
protected def exit() { } |
|
34 |
||
35 |
override def addNotify() |
|
36 |
{ |
|
37 |
super.addNotify() |
|
38 |
init() |
|
39 |
} |
|
40 |
||
41 |
override def removeNotify() |
|
42 |
{ |
|
43 |
exit() |
|
44 |
super.removeNotify() |
|
45 |
} |
|
46 |
} |