|
@@ -22,8 +22,12 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.actions.ActionGroup;
|
|
26
|
+import com.dmdirc.actions.ActionManager;
|
25
|
27
|
import com.dmdirc.config.prefs.validator.FileNameValidator;
|
26
|
28
|
import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
|
|
29
|
+import com.dmdirc.config.prefs.validator.ActionNameValidator;
|
|
30
|
+import com.dmdirc.config.prefs.validator.ValidatorChain;
|
27
|
31
|
|
28
|
32
|
import java.beans.PropertyChangeEvent;
|
29
|
33
|
import java.beans.PropertyChangeListener;
|
|
@@ -32,8 +36,8 @@ import javax.swing.BorderFactory;
|
32
|
36
|
import javax.swing.JLabel;
|
33
|
37
|
import javax.swing.JPanel;
|
34
|
38
|
import javax.swing.JTextField;
|
35
|
|
-
|
36
|
39
|
import javax.swing.UIManager;
|
|
40
|
+
|
37
|
41
|
import net.miginfocom.swing.MigLayout;
|
38
|
42
|
|
39
|
43
|
/**
|
|
@@ -51,18 +55,25 @@ public class ActionNamePanel extends JPanel implements PropertyChangeListener {
|
51
|
55
|
private final String originalName;
|
52
|
56
|
/** Action name field. */
|
53
|
57
|
private ValidatingJTextField name;
|
|
58
|
+ /** Action group. */
|
|
59
|
+ private ActionGroup group;
|
54
|
60
|
|
55
|
|
- /** Instantiates the panel. */
|
56
|
|
- public ActionNamePanel() {
|
57
|
|
- this("");
|
|
61
|
+ /**
|
|
62
|
+ * Instantiates the panel.
|
|
63
|
+ *
|
|
64
|
+ * @param group Associated group for this action
|
|
65
|
+ */
|
|
66
|
+ public ActionNamePanel(final String group) {
|
|
67
|
+ this("", group);
|
58
|
68
|
}
|
59
|
69
|
|
60
|
70
|
/**
|
61
|
71
|
* Instantiates the panel.
|
62
|
72
|
*
|
63
|
73
|
* @param name Initial name of the action
|
|
74
|
+ * @param group Associated group for this action
|
64
|
75
|
*/
|
65
|
|
- public ActionNamePanel(final String name) {
|
|
76
|
+ public ActionNamePanel(final String name, final String group) {
|
66
|
77
|
super();
|
67
|
78
|
|
68
|
79
|
if (name == null) {
|
|
@@ -70,6 +81,7 @@ public class ActionNamePanel extends JPanel implements PropertyChangeListener {
|
70
|
81
|
} else {
|
71
|
82
|
this.originalName = name;
|
72
|
83
|
}
|
|
84
|
+ this.group = ActionManager.getGroup(group);
|
73
|
85
|
|
74
|
86
|
initComponents();
|
75
|
87
|
addListeners();
|
|
@@ -92,9 +104,11 @@ public class ActionNamePanel extends JPanel implements PropertyChangeListener {
|
92
|
104
|
}
|
93
|
105
|
|
94
|
106
|
/** Initialises the components. */
|
|
107
|
+ @SuppressWarnings("unchecked")
|
95
|
108
|
private void initComponents() {
|
96
|
|
- name = new ValidatingJTextField(new JTextField(originalName),
|
97
|
|
- new FileNameValidator());
|
|
109
|
+ name = new ValidatingJTextField(new JTextField(originalName),
|
|
110
|
+ new ValidatorChain<String>(new FileNameValidator(),
|
|
111
|
+ new ActionNameValidator(group)));
|
98
|
112
|
}
|
99
|
113
|
|
100
|
114
|
/** Adds the listeners. */
|