1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dishevelled.curate.impl;
25
26 import java.awt.event.ActionEvent;
27
28 import javax.swing.AbstractAction;
29 import javax.swing.Action;
30 import javax.swing.JButton;
31 import javax.swing.JDialog;
32 import javax.swing.JPanel;
33
34 import org.dishevelled.iconbundle.tango.TangoProject;
35
36 import org.dishevelled.identify.IdButton;
37 import org.dishevelled.identify.IdentifiableAction;
38
39 import org.dishevelled.layout.ButtonPanel;
40
41
42
43
44
45
46
47 public abstract class AbstractCurateDialog
48 extends JDialog
49 {
50
51 private final Action cancel;
52
53
54 private final IdentifiableAction help;
55
56
57 private final Action ok;
58
59
60
61
62
63 protected AbstractCurateDialog()
64 {
65 super();
66
67
68 cancel = new AbstractAction("Cancel")
69 {
70
71 public void actionPerformed(final ActionEvent event)
72 {
73 cancel();
74 }
75 };
76
77 help = new IdentifiableAction("Help", TangoProject.HELP_BROWSER)
78 {
79
80 public void actionPerformed(final ActionEvent event)
81 {
82 help();
83 }
84 };
85 help.setEnabled(false);
86
87
88 ok = new AbstractAction("OK")
89 {
90
91 public void actionPerformed(final ActionEvent event)
92 {
93 ok();
94 }
95 };
96 }
97
98
99
100
101
102
103 protected final JPanel createButtonPanel()
104 {
105 ButtonPanel buttonPanel = new ButtonPanel();
106 JButton okButton = buttonPanel.add(ok);
107 JButton cancelButton = buttonPanel.add(cancel);
108 buttonPanel.add(new IdButton(help));
109
110
111 okButton.setPreferredSize(cancelButton.getPreferredSize());
112 getRootPane().setDefaultButton(okButton);
113
114 return buttonPanel;
115 }
116
117
118
119
120
121
122
123
124 protected final Action getCancelAction()
125 {
126 return cancel;
127 }
128
129
130
131
132
133
134
135
136 protected final Action getHelpAction()
137 {
138 return help;
139 }
140
141
142
143
144
145
146
147
148 protected final Action getOKAction()
149 {
150 return ok;
151 }
152
153
154
155
156
157
158 protected abstract void cancel();
159
160
161
162
163
164
165 protected abstract void help();
166
167
168
169
170
171
172 protected abstract void ok();
173 }