Browse Source

Fix validation of actions (and the validating text field itself).

Change-Id: I5a3bc9f0a7e3840f02e24cc9e2a919314b3df424
Fixes-Issue: CLIENT-438
Fixes-Issue: CLIENT-437
Reviewed-on: http://gerrit.dmdirc.com/3159
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Greg Holmes 10 years ago
parent
commit
1244feae5d

+ 2
- 0
src/com/dmdirc/addons/ui_swing/components/JIconTextField.java View File

36
  */
36
  */
37
 public class JIconTextField extends JTextField {
37
 public class JIconTextField extends JTextField {
38
 
38
 
39
+    /** A version number for this class, used in serialisation. */
40
+    private static final long serialVersionUID = 1L;
39
     /** Insets used by a normal text field. */
41
     /** Insets used by a normal text field. */
40
     private final Insets dummyInsets;
42
     private final Insets dummyInsets;
41
     /** Icon to show, or null. */
43
     /** Icon to show, or null. */

+ 15
- 9
src/com/dmdirc/addons/ui_swing/components/validating/ValidatingJTextField.java View File

105
      */
105
      */
106
     public void checkError() {
106
     public void checkError() {
107
         final boolean previousStatus = getMessage() == null || getMessage().isEmpty();
107
         final boolean previousStatus = getMessage() == null || getMessage().isEmpty();
108
+        final ValidationResponse vr = validator.validate(getText());
109
+        setMessage(vr.getFailureReason());
110
+        firePropertyChange("validationResult", previousStatus, !vr.isFailure());
111
+        if (vr.isFailure()) {
112
+            setIcon(errorIcon);
113
+        } else {
114
+            setIcon(null);
115
+        }
116
+    }
108
 
117
 
109
-        if (isEnabled()) {
110
-            final ValidationResponse vr = validator.validate(getText());
111
-            setMessage(vr.getFailureReason());
112
-            firePropertyChange("validationResult", previousStatus, !vr.isFailure());
113
-            if (vr.isFailure()) {
114
-                setIcon(errorIcon);
115
-            } else {
116
-                setIcon(null);
117
-            }
118
+    @Override
119
+    public void setEnabled(final boolean enabled) {
120
+        final boolean previousStatus = getMessage() == null || getMessage().isEmpty();
121
+        if (enabled) {
122
+            checkError();
118
         } else {
123
         } else {
119
             setIcon(null);
124
             setIcon(null);
120
             setMessage(null);
125
             setMessage(null);
121
             firePropertyChange("validationResult", previousStatus, true);
126
             firePropertyChange("validationResult", previousStatus, true);
122
         }
127
         }
128
+        super.setEnabled(enabled);
123
     }
129
     }
124
 
130
 
125
     /**
131
     /**

+ 8
- 7
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsTreePanel.java View File

49
 public class ActionConditionsTreePanel extends JPanel implements ActionListener,
49
 public class ActionConditionsTreePanel extends JPanel implements ActionListener,
50
         PropertyChangeListener, DocumentListener {
50
         PropertyChangeListener, DocumentListener {
51
 
51
 
52
-    /**
53
-     * A version number for this class. It should be changed whenever the class structure is changed
54
-     * (or anything else that would prevent serialized objects being unserialized with the new
55
-     * class).
56
-     */
52
+    /** A version number for this class. */
57
     private static final long serialVersionUID = 1;
53
     private static final long serialVersionUID = 1;
54
+    /** Icon manager. */
55
+    private final IconManager iconManager;
58
     /** Button group. */
56
     /** Button group. */
59
     private ButtonGroup group;
57
     private ButtonGroup group;
60
     /** All triggers button. */
58
     /** All triggers button. */
73
     private ConditionRuleValidator treeValidator;
71
     private ConditionRuleValidator treeValidator;
74
     /** validates. */
72
     /** validates. */
75
     private boolean validates = true;
73
     private boolean validates = true;
76
-    /** Icon manager. */
77
-    private IconManager iconManager;
78
 
74
 
79
     /**
75
     /**
80
      * Instantiates the panel.
76
      * Instantiates the panel.
139
         }
135
         }
140
 
136
 
141
         switch (type) {
137
         switch (type) {
138
+            case CONJUNCTION:
139
+                allButton.setSelected(true);
140
+                rule.setText("");
141
+                rule.setEnabled(false);
142
+                break;
142
             case DISJUNCTION:
143
             case DISJUNCTION:
143
                 oneButton.setSelected(true);
144
                 oneButton.setSelected(true);
144
                 rule.setText("");
145
                 rule.setText("");

Loading…
Cancel
Save