Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
1244feae5d

+ 2
- 0
src/com/dmdirc/addons/ui_swing/components/JIconTextField.java Näytä tiedosto

@@ -36,6 +36,8 @@ import javax.swing.UIManager;
36 36
  */
37 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 41
     /** Insets used by a normal text field. */
40 42
     private final Insets dummyInsets;
41 43
     /** Icon to show, or null. */

+ 15
- 9
src/com/dmdirc/addons/ui_swing/components/validating/ValidatingJTextField.java Näytä tiedosto

@@ -105,21 +105,27 @@ public class ValidatingJTextField extends JIconTextField implements DocumentList
105 105
      */
106 106
     public void checkError() {
107 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 123
         } else {
119 124
             setIcon(null);
120 125
             setMessage(null);
121 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 Näytä tiedosto

@@ -49,12 +49,10 @@ import net.miginfocom.swing.MigLayout;
49 49
 public class ActionConditionsTreePanel extends JPanel implements ActionListener,
50 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 53
     private static final long serialVersionUID = 1;
54
+    /** Icon manager. */
55
+    private final IconManager iconManager;
58 56
     /** Button group. */
59 57
     private ButtonGroup group;
60 58
     /** All triggers button. */
@@ -73,8 +71,6 @@ public class ActionConditionsTreePanel extends JPanel implements ActionListener,
73 71
     private ConditionRuleValidator treeValidator;
74 72
     /** validates. */
75 73
     private boolean validates = true;
76
-    /** Icon manager. */
77
-    private IconManager iconManager;
78 74
 
79 75
     /**
80 76
      * Instantiates the panel.
@@ -139,6 +135,11 @@ public class ActionConditionsTreePanel extends JPanel implements ActionListener,
139 135
         }
140 136
 
141 137
         switch (type) {
138
+            case CONJUNCTION:
139
+                allButton.setSelected(true);
140
+                rule.setText("");
141
+                rule.setEnabled(false);
142
+                break;
142 143
             case DISJUNCTION:
143 144
                 oneButton.setSelected(true);
144 145
                 rule.setText("");

Loading…
Peruuta
Tallenna