|
@@ -32,6 +32,7 @@ import java.awt.event.ItemListener;
|
32
|
32
|
import java.awt.event.KeyEvent;
|
33
|
33
|
import java.awt.event.KeyListener;
|
34
|
34
|
import java.util.ArrayList;
|
|
35
|
+import java.util.Collections;
|
35
|
36
|
import java.util.HashMap;
|
36
|
37
|
import java.util.List;
|
37
|
38
|
import java.util.Map;
|
|
@@ -124,57 +125,61 @@ public class ListableConfigDialog extends JDialog implements ItemListener, KeyLi
|
124
|
125
|
components.put("tr", getComponents(config.topRight));
|
125
|
126
|
components.put("bl", getComponents(config.bottomLeft));
|
126
|
127
|
components.put("br", getComponents(config.bottomRight));
|
127
|
|
- components.put("group", getComponents(config.group));
|
|
128
|
+ components.put("+group", getComponents(config.group));
|
128
|
129
|
|
129
|
130
|
for (int i = 0; i < config.sortOrder.length; i++) {
|
130
|
|
- components.put("sort_" + i, getComponents(config.sortOrder[i]));
|
|
131
|
+ components.put("+sort_" + i, getComponents(config.sortOrder[i]));
|
131
|
132
|
}
|
132
|
133
|
}
|
133
|
134
|
|
134
|
135
|
protected void layoutConfigPanel() {
|
135
|
136
|
configPanel.removeAll();
|
136
|
137
|
|
137
|
|
- JButton addButton = new JButton("+");
|
138
|
|
- addButton.addActionListener(new ButtonActionListener("tl"));
|
139
|
|
- addButton.setMaximumSize(new Dimension(35, 100));
|
140
|
|
- configPanel.add(new JLabel("Group by:", JLabel.RIGHT));
|
141
|
|
- addComponents("group");
|
142
|
|
- configPanel.add(addButton, "span, al right");
|
143
|
|
-
|
144
|
|
- configPanel.add(new JSeparator(), "gaptop 10, gapbottom 10, newline, span, growx");
|
145
|
|
-
|
146
|
|
- addButton = new JButton("+");
|
147
|
|
- addButton.addActionListener(new ButtonActionListener("tl"));
|
148
|
|
- addButton.setMaximumSize(new Dimension(35, 100));
|
149
|
|
- configPanel.add(new JLabel("Top left:", JLabel.RIGHT));
|
150
|
|
- addComponents("tl");
|
151
|
|
- configPanel.add(addButton, "span, al right");
|
152
|
|
-
|
153
|
|
- addButton = new JButton("+");
|
154
|
|
- addButton.addActionListener(new ButtonActionListener("bl"));
|
155
|
|
- addButton.setMaximumSize(new Dimension(35, 100));
|
156
|
|
- configPanel.add(new JLabel("Bottom left:", JLabel.RIGHT), "newline");
|
157
|
|
- addComponents("bl");
|
158
|
|
- configPanel.add(addButton, "span, al right");
|
159
|
|
-
|
160
|
|
- addButton = new JButton("+");
|
161
|
|
- addButton.addActionListener(new ButtonActionListener("tr"));
|
162
|
|
- addButton.setMaximumSize(new Dimension(35, 100));
|
163
|
|
- configPanel.add(new JLabel("Top right:", JLabel.RIGHT), "newline");
|
164
|
|
- addComponents("tr");
|
165
|
|
- configPanel.add(addButton, "span, al right");
|
166
|
|
-
|
167
|
|
- addButton = new JButton("+");
|
168
|
|
- addButton.addActionListener(new ButtonActionListener("br"));
|
169
|
|
- addButton.setMaximumSize(new Dimension(35, 100));
|
170
|
|
- configPanel.add(new JLabel("Bottom right:", JLabel.RIGHT), "newline");
|
171
|
|
- addComponents("br");
|
172
|
|
- configPanel.add(addButton, "span, al right");
|
|
138
|
+ JButton addButton;
|
|
139
|
+
|
|
140
|
+ final List<String> keyset = new ArrayList<String>(components.keySet());
|
|
141
|
+ Collections.sort(keyset);
|
|
142
|
+
|
|
143
|
+ for (int i = 0; i < keyset.size(); i++) {
|
|
144
|
+ final String key = keyset.get(i);
|
|
145
|
+
|
|
146
|
+ addButton = new JButton("+");
|
|
147
|
+ addButton.addActionListener(new ButtonActionListener(key));
|
|
148
|
+ addButton.setMaximumSize(new Dimension(35, 100));
|
|
149
|
+ configPanel.add(new JLabel(getText(key), JLabel.RIGHT));
|
|
150
|
+ addComponents(key);
|
|
151
|
+ configPanel.add(addButton, "span, al right");
|
|
152
|
+
|
|
153
|
+ if (key.length() > 2 && i < keyset.size() - 1
|
|
154
|
+ && !keyset.get(i + 1).startsWith(key.substring(0, 4))) {
|
|
155
|
+ configPanel.add(new JSeparator(),
|
|
156
|
+ "gaptop 10, gapbottom 10, newline, span, growx");
|
|
157
|
+ }
|
|
158
|
+ }
|
173
|
159
|
|
174
|
160
|
configPanel.revalidate();
|
175
|
161
|
pack();
|
176
|
162
|
}
|
177
|
163
|
|
|
164
|
+ protected String getText(final String key) {
|
|
165
|
+ if (key.equals("+group")) {
|
|
166
|
+ return "Group by:";
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ if (key.startsWith("+sort")) {
|
|
170
|
+ return key.equals("+sort_0") ? "Sort by:" : "... then:";
|
|
171
|
+ }
|
|
172
|
+
|
|
173
|
+ final StringBuilder builder = new StringBuilder();
|
|
174
|
+
|
|
175
|
+ builder.append(key.startsWith("t") ? "Top" : "Bottom");
|
|
176
|
+ builder.append(' ');
|
|
177
|
+ builder.append(key.endsWith("r") ? "right" : "left");
|
|
178
|
+ builder.append(':');
|
|
179
|
+
|
|
180
|
+ return builder.toString();
|
|
181
|
+ }
|
|
182
|
+
|
178
|
183
|
protected void addComponents(final String location) {
|
179
|
184
|
for (JComponent component : components.get(location)) {
|
180
|
185
|
configPanel.add(component, "growy, width 100!");
|