author | wenzelm |
Mon, 10 Sep 2012 19:56:08 +0200 | |
changeset 49248 | bff772033a97 |
parent 49247 | ffd9ad9dc35b |
child 49252 | 9e10481dd3c4 |
permissions | -rw-r--r-- |
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/jedit_options.scala |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
3 |
|
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
4 |
Options for Isabelle/jEdit. |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
5 |
*/ |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
6 |
|
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
7 |
package isabelle.jedit |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
8 |
|
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
9 |
|
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
10 |
import isabelle._ |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
11 |
|
49246 | 12 |
import javax.swing.{InputVerifier, JComponent} |
13 |
import javax.swing.text.JTextComponent |
|
14 |
import scala.swing.{Component, CheckBox, TextArea} |
|
15 |
||
16 |
||
17 |
trait Option_Component extends Component |
|
18 |
{ |
|
19 |
val title: String |
|
49247 | 20 |
def load(): Unit |
49246 | 21 |
def save(): Unit |
22 |
} |
|
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
23 |
|
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
24 |
class JEdit_Options extends Options_Variable |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
25 |
{ |
49246 | 26 |
def title(opt_name: String): String = value.title("jedit", opt_name) |
27 |
||
28 |
def make_component(opt_name: String): Option_Component = |
|
29 |
{ |
|
30 |
Swing_Thread.require() |
|
31 |
||
32 |
val opt = value.check_name(opt_name) |
|
33 |
val opt_title = title(opt_name) |
|
34 |
||
35 |
val component = |
|
36 |
if (opt.typ == Options.Bool) |
|
37 |
new CheckBox with Option_Component { |
|
38 |
val title = opt_title |
|
49247 | 39 |
def load = selected = bool(opt_name) |
49246 | 40 |
def save = bool(opt_name) = selected |
41 |
} |
|
42 |
else { |
|
43 |
val text_area = |
|
44 |
new TextArea with Option_Component { |
|
45 |
val title = opt_title |
|
49247 | 46 |
def load = text = value.check_name(opt_name).value |
49246 | 47 |
def save = update(value + (opt_name, text)) |
48 |
} |
|
49 |
text_area.peer.setInputVerifier(new InputVerifier { |
|
50 |
def verify(jcomponent: JComponent): Boolean = |
|
51 |
jcomponent match { |
|
52 |
case text: JTextComponent => |
|
53 |
try { value + (opt_name, text.getText); true } |
|
54 |
catch { case ERROR(_) => false } |
|
55 |
case _ => true |
|
56 |
} |
|
57 |
}) |
|
58 |
text_area |
|
59 |
} |
|
49247 | 60 |
component.load() |
49248 | 61 |
component.tooltip = Isabelle.tooltip(opt.print) |
49246 | 62 |
component |
63 |
} |
|
49245
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
64 |
} |
cb70157293c0
manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff
changeset
|
65 |