blob: b7fa2ebae6fe6d0a0cbbcaf3298d9ba8dffd5d9c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package cuchaz.enigma.gui;
import de.sciss.syntaxpane.SyntaxDocument;
import de.sciss.syntaxpane.actions.DefaultSyntaxAction;
import javax.swing.text.JTextComponent;
import java.awt.event.ActionEvent;
public final class QuickFindAction extends DefaultSyntaxAction {
public QuickFindAction() {
super("quick-find");
}
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument document, int dot, ActionEvent event) {
Data data = Data.get(target);
data.showFindDialog(target);
}
private static class Data {
private static final String KEY = "enigma-find-data";
private EnigmaQuickFindDialog findDialog;
private Data() {
}
public static Data get(JTextComponent target) {
Object o = target.getDocument().getProperty(KEY);
if (o instanceof Data) {
return (Data) o;
}
Data data = new Data();
target.getDocument().putProperty(KEY, data);
return data;
}
public void showFindDialog(JTextComponent target) {
if (findDialog == null) {
findDialog = new EnigmaQuickFindDialog(target);
}
findDialog.showFor(target);
}
}
}
|