|
@@ -52,6 +52,7 @@ import javax.swing.JTextField;
|
52
|
52
|
|
53
|
53
|
import net.miginfocom.swing.MigLayout;
|
54
|
54
|
|
|
55
|
+import uk.co.md87.evetool.ui.ContentPanel.Page;
|
55
|
56
|
import uk.co.md87.evetool.ui.components.ListablePanel;
|
56
|
57
|
import uk.co.md87.evetool.ui.listable.Listable;
|
57
|
58
|
import uk.co.md87.evetool.ui.listable.ListableConfig;
|
|
@@ -60,13 +61,15 @@ import uk.co.md87.evetool.ui.listable.ListableConfig.CompoundConfigElement;
|
60
|
61
|
import uk.co.md87.evetool.ui.listable.ListableConfig.ConfigElement;
|
61
|
62
|
import uk.co.md87.evetool.ui.listable.ListableConfig.LiteralConfigElement;
|
62
|
63
|
import uk.co.md87.evetool.ui.listable.ListableParser;
|
|
64
|
+import uk.co.md87.evetool.ui.pages.SkillPage;
|
63
|
65
|
|
64
|
66
|
/**
|
65
|
67
|
*
|
66
|
68
|
* TODO: Document ListableConfigDialog
|
67
|
69
|
* @author chris
|
68
|
70
|
*/
|
69
|
|
-public class ListableConfigDialog extends JDialog implements ItemListener, KeyListener {
|
|
71
|
+public class ListableConfigDialog extends JDialog implements ActionListener,
|
|
72
|
+ ItemListener, KeyListener {
|
70
|
73
|
|
71
|
74
|
/**
|
72
|
75
|
* A version number for this class. It should be changed whenever the class
|
|
@@ -83,16 +86,21 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
83
|
86
|
private final Map<String, List<JComponent>> components
|
84
|
87
|
= new HashMap<String, List<JComponent>>();
|
85
|
88
|
|
|
89
|
+ private volatile boolean complete = false;
|
|
90
|
+
|
86
|
91
|
private final JPanel configPanel, previewPanel;
|
87
|
92
|
private final ListablePanel panel;
|
88
|
93
|
|
89
|
|
- public ListableConfigDialog(final Window owner, final ListableConfig config,
|
90
|
|
- final Listable sample) {
|
91
|
|
- super(owner, "Display Configuration", ModalityType.APPLICATION_MODAL);
|
|
94
|
+ private final SkillPage page;
|
|
95
|
+
|
|
96
|
+ public ListableConfigDialog(final Window window, final SkillPage page,
|
|
97
|
+ final ListableConfig config, final Listable sample) {
|
|
98
|
+ super(window, "Display Configuration", ModalityType.APPLICATION_MODAL);
|
92
|
99
|
|
93
|
100
|
setLayout(new MigLayout("wrap 1, fill", "[fill]", "[|fill|fill]"));
|
94
|
101
|
|
95
|
|
- this.config = config;
|
|
102
|
+ this.page = page;
|
|
103
|
+ this.config = config.clone();
|
96
|
104
|
this.sample = sample;
|
97
|
105
|
this.parser = new ListableParser(sample.getClass());
|
98
|
106
|
|
|
@@ -101,22 +109,30 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
101
|
109
|
this.configPanel = new JPanel(new MigLayout("fill", "[fill]"));
|
102
|
110
|
this.previewPanel = new JPanel(new MigLayout("fill", "[fill]", "[fill]"));
|
103
|
111
|
|
104
|
|
- configPanel.setBorder(BorderFactory.createTitledBorder("Information"));
|
|
112
|
+ configPanel.setBorder(BorderFactory.createTitledBorder("Configuration"));
|
105
|
113
|
previewPanel.setBorder(BorderFactory.createTitledBorder("Preview"));
|
106
|
114
|
|
107
|
115
|
this.panel = new ListablePanel(sample, parser, config);
|
108
|
116
|
|
109
|
117
|
previewPanel.add(panel);
|
110
|
118
|
|
|
119
|
+ final JButton cancelButton = new JButton("Cancel");
|
|
120
|
+ final JButton okButton = new JButton("OK");
|
|
121
|
+
|
|
122
|
+ cancelButton.addActionListener(this);
|
|
123
|
+ okButton.addActionListener(this);
|
|
124
|
+
|
111
|
125
|
add(configPanel);
|
112
|
126
|
add(previewPanel);
|
|
127
|
+ add(cancelButton, "split");
|
|
128
|
+ add(okButton, "split");
|
113
|
129
|
|
114
|
130
|
initConfigPanel();
|
115
|
131
|
layoutConfigPanel();
|
116
|
132
|
|
117
|
133
|
pack();
|
118
|
134
|
|
119
|
|
- setLocationRelativeTo(owner);
|
|
135
|
+ setLocationRelativeTo(window);
|
120
|
136
|
setResizable(false);
|
121
|
137
|
}
|
122
|
138
|
|
|
@@ -130,6 +146,8 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
130
|
146
|
for (int i = 0; i < config.sortOrder.length; i++) {
|
131
|
147
|
components.put("+sort_" + i, getComponents(config.sortOrder[i]));
|
132
|
148
|
}
|
|
149
|
+
|
|
150
|
+ complete = true;
|
133
|
151
|
}
|
134
|
152
|
|
135
|
153
|
protected void layoutConfigPanel() {
|
|
@@ -208,13 +226,11 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
208
|
226
|
}
|
209
|
227
|
|
210
|
228
|
protected void rebuildConfig() {
|
211
|
|
- for (String loc : new String[]{"tl", "tr", "bl", "br"}) {
|
|
229
|
+ config.sortOrder = new ConfigElement[components.size() - 5];
|
|
230
|
+
|
|
231
|
+ for (String loc : components.keySet()) {
|
212
|
232
|
final List<ConfigElement> elements = new ArrayList<ConfigElement>();
|
213
|
233
|
|
214
|
|
- if (!components.containsKey(loc)) {
|
215
|
|
- continue;
|
216
|
|
- }
|
217
|
|
-
|
218
|
234
|
for (JComponent component : components.get(loc)) {
|
219
|
235
|
if (component instanceof JTextField) {
|
220
|
236
|
elements.add(new LiteralConfigElement(((JTextField) component).getText()));
|
|
@@ -235,6 +251,11 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
235
|
251
|
config.bottomRight = res;
|
236
|
252
|
} else if (loc.equals("bl")) {
|
237
|
253
|
config.bottomLeft = res;
|
|
254
|
+ } else if (loc.equals("+group")) {
|
|
255
|
+ config.group = res;
|
|
256
|
+ } else if (loc.startsWith("+sort_")) {
|
|
257
|
+ final int line = Integer.parseInt(loc.substring(6));
|
|
258
|
+ config.sortOrder[line] = res;
|
238
|
259
|
}
|
239
|
260
|
}
|
240
|
261
|
}
|
|
@@ -242,8 +263,10 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
242
|
263
|
/** {@inheritDoc} */
|
243
|
264
|
@Override
|
244
|
265
|
public void itemStateChanged(final ItemEvent e) {
|
245
|
|
- rebuildConfig();
|
246
|
|
- panel.listableUpdated(sample);
|
|
266
|
+ if (complete) {
|
|
267
|
+ rebuildConfig();
|
|
268
|
+ panel.listableUpdated(sample);
|
|
269
|
+ }
|
247
|
270
|
}
|
248
|
271
|
|
249
|
272
|
/** {@inheritDoc} */
|
|
@@ -265,6 +288,16 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
265
|
288
|
panel.listableUpdated(sample);
|
266
|
289
|
}
|
267
|
290
|
|
|
291
|
+ /** {@inheritDoc} */
|
|
292
|
+ @Override
|
|
293
|
+ public void actionPerformed(final ActionEvent e) {
|
|
294
|
+ if (((JButton) e.getSource()).getText().equals("OK")) {
|
|
295
|
+ page.setConfig(config);
|
|
296
|
+ }
|
|
297
|
+
|
|
298
|
+ dispose();
|
|
299
|
+ }
|
|
300
|
+
|
268
|
301
|
private class ButtonActionListener implements ActionListener {
|
269
|
302
|
|
270
|
303
|
private final String location;
|