|
@@ -35,7 +35,7 @@ import com.dmdirc.addons.ui_swing.SwingController;
|
35
|
35
|
import com.dmdirc.addons.ui_swing.components.ListScroller;
|
36
|
36
|
import com.dmdirc.addons.ui_swing.components.SortedListModel;
|
37
|
37
|
import com.dmdirc.addons.ui_swing.components.frames.AppleJFrame;
|
38
|
|
-import com.dmdirc.addons.ui_swing.components.renderers.ActionGroupListCellRenderer;
|
|
38
|
+import com.dmdirc.addons.ui_swing.components.renderers.PropertyListCellRenderer;
|
39
|
39
|
import com.dmdirc.addons.ui_swing.components.text.TextLabel;
|
40
|
40
|
import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
|
41
|
41
|
import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog;
|
|
@@ -73,11 +73,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
73
|
73
|
ActionListener, com.dmdirc.interfaces.ActionListener,
|
74
|
74
|
ListSelectionListener {
|
75
|
75
|
|
76
|
|
- /**
|
77
|
|
- * A version number for this class. It should be changed whenever the class structure is changed
|
78
|
|
- * (or anything else that would prevent serialized objects being unserialized with the new
|
79
|
|
- * class).
|
80
|
|
- */
|
|
76
|
+ /** A version number for this class. */
|
81
|
77
|
private static final long serialVersionUID = 1;
|
82
|
78
|
/** Config instance. */
|
83
|
79
|
private final ConfigProvider config;
|
|
@@ -90,7 +86,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
90
|
86
|
/** Info label. */
|
91
|
87
|
private TextLabel infoLabel;
|
92
|
88
|
/** Group list. */
|
93
|
|
- private JList groups;
|
|
89
|
+ private JList<ActionGroup> groups;
|
94
|
90
|
/** Add button. */
|
95
|
91
|
private JButton add;
|
96
|
92
|
/** Edit button. */
|
|
@@ -123,6 +119,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
123
|
119
|
* @param groupPanelFactory Factory to use to create group panels.
|
124
|
120
|
*/
|
125
|
121
|
@Inject
|
|
122
|
+ @SuppressWarnings("unchecked")
|
126
|
123
|
public ActionsManagerDialog(
|
127
|
124
|
final MainFrame parentWindow,
|
128
|
125
|
final SwingController controller,
|
|
@@ -160,7 +157,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
160
|
157
|
+ " intelligently respond to various events. Action groups are"
|
161
|
158
|
+ " there for you to organise groups, add or remove them"
|
162
|
159
|
+ " to suit your needs.");
|
163
|
|
- groups = new JList(new SortedListModel<>(new ActionGroupNameComparator()));
|
|
160
|
+ groups = new JList<>(new SortedListModel<>(new ActionGroupNameComparator()));
|
164
|
161
|
actions = groupPanelFactory.getActionsGroupPanel(this, null);
|
165
|
162
|
info = new ActionGroupInformationPanel(null);
|
166
|
163
|
settings = new HashMap<>();
|
|
@@ -179,7 +176,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
179
|
176
|
actions.setBorder(BorderFactory.createTitledBorder(UIManager.getBorder(
|
180
|
177
|
"TitledBorder.border"), "Actions"));
|
181
|
178
|
|
182
|
|
- groups.setCellRenderer(new ActionGroupListCellRenderer(groups.getCellRenderer()));
|
|
179
|
+ groups.setCellRenderer(new PropertyListCellRenderer<>(groups.getCellRenderer(), ActionGroup.class, "name"));
|
183
|
180
|
groups.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
184
|
181
|
edit.setEnabled(false);
|
185
|
182
|
delete.setEnabled(false);
|
|
@@ -256,7 +253,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
256
|
253
|
private void reloadGroups(final ActionGroup selectedGroup) {
|
257
|
254
|
((DefaultListModel) groups.getModel()).clear();
|
258
|
255
|
for (ActionGroup group : ActionManager.getActionManager().getGroupsMap().values()) {
|
259
|
|
- ((DefaultListModel) groups.getModel()).addElement(group);
|
|
256
|
+ ((DefaultListModel<ActionGroup>) groups.getModel()).addElement(group);
|
260
|
257
|
}
|
261
|
258
|
groups.setSelectedValue(selectedGroup, true);
|
262
|
259
|
}
|
|
@@ -354,8 +351,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
354
|
351
|
* Prompts then edits an action group.
|
355
|
352
|
*/
|
356
|
353
|
private void editGroup() {
|
357
|
|
- final String oldName =
|
358
|
|
- ((ActionGroup) groups.getSelectedValue()).getName();
|
|
354
|
+ final String oldName = groups.getSelectedValue().getName();
|
359
|
355
|
final StandardInputDialog inputDialog = new StandardInputDialog(
|
360
|
356
|
this, ModalityType.DOCUMENT_MODAL, iconManager, "Edit action group",
|
361
|
357
|
"Please enter the new name of the action group", validator) {
|
|
@@ -392,8 +388,7 @@ public class ActionsManagerDialog extends StandardDialog implements
|
392
|
388
|
* Prompts then deletes an action group.
|
393
|
389
|
*/
|
394
|
390
|
private void delGroup() {
|
395
|
|
- final String group =
|
396
|
|
- ((ActionGroup) groups.getSelectedValue()).getName();
|
|
391
|
+ final String group = groups.getSelectedValue().getName();
|
397
|
392
|
new StandardQuestionDialog(this,
|
398
|
393
|
ModalityType.APPLICATION_MODAL,
|
399
|
394
|
"Confirm deletion",
|
|
@@ -436,9 +431,8 @@ public class ActionsManagerDialog extends StandardDialog implements
|
436
|
431
|
return;
|
437
|
432
|
}
|
438
|
433
|
|
439
|
|
- changeActiveGroup((ActionGroup) groups.getSelectedValue());
|
440
|
|
- if (groups.getSelectedIndex() == -1 || !((ActionGroup) groups.
|
441
|
|
- getSelectedValue()).isDelible()) {
|
|
434
|
+ changeActiveGroup(groups.getSelectedValue());
|
|
435
|
+ if (groups.getSelectedIndex() == -1 || !groups.getSelectedValue().isDelible()) {
|
442
|
436
|
edit.setEnabled(false);
|
443
|
437
|
delete.setEnabled(false);
|
444
|
438
|
} else {
|
|
@@ -457,13 +451,11 @@ public class ActionsManagerDialog extends StandardDialog implements
|
457
|
451
|
if (type.equals(CoreActionType.ACTION_CREATED) || type.equals(
|
458
|
452
|
CoreActionType.ACTION_UPDATED)) {
|
459
|
453
|
final Action action = (Action) arguments[0];
|
460
|
|
- if (action.getGroup().equals(((ActionGroup) groups.getSelectedValue()).
|
461
|
|
- getName())) {
|
|
454
|
+ if (action.getGroup().equals(groups.getSelectedValue().getName())) {
|
462
|
455
|
actions.actionChanged(action);
|
463
|
456
|
}
|
464
|
457
|
} else {
|
465
|
|
- if (arguments[0].equals(((ActionGroup) groups.getSelectedValue()).
|
466
|
|
- getName())) {
|
|
458
|
+ if (arguments[0].equals(groups.getSelectedValue().getName())) {
|
467
|
459
|
actions.actionDeleted((String) arguments[1]);
|
468
|
460
|
}
|
469
|
461
|
}
|