Procházet zdrojové kódy

Remove ValidatorChain varargs usages.

Change-Id: I6018652a059789b36c1119118c85ee0af2c87dd8
Reviewed-on: http://gerrit.dmdirc.com/3170
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Chris Smith před 10 roky
rodič
revize
0c7a17b84b

+ 9
- 13
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionNamePanel.java Zobrazit soubor

@@ -45,11 +45,7 @@ import net.miginfocom.swing.MigLayout;
45 45
  */
46 46
 public class ActionNamePanel extends JPanel implements PropertyChangeListener {
47 47
 
48
-    /**
49
-     * A version number for this class. It should be changed whenever the class structure is changed
50
-     * (or anything else that would prevent serialized objects being unserialized with the new
51
-     * class).
52
-     */
48
+    /** A version number for this class. */
53 49
     private static final long serialVersionUID = 1;
54 50
     /** Original name. */
55 51
     private String existingName;
@@ -100,15 +96,16 @@ public class ActionNamePanel extends JPanel implements PropertyChangeListener {
100 96
      *
101 97
      * @param newName new name
102 98
      */
103
-    @SuppressWarnings("unchecked")
104 99
     void setActionName(final String newName) {
105 100
         if (newName == null) {
106 101
             this.existingName = "";
107 102
         } else {
108 103
             this.existingName = newName;
109 104
         }
110
-        name.setValidator(new ValidatorChain<>(new FileNameValidator(),
111
-                new ActionNameValidator(group, existingName)));
105
+        name.setValidator(ValidatorChain.<String>builder()
106
+                .addValidator(new FileNameValidator())
107
+                .addValidator(new ActionNameValidator(group, existingName))
108
+                .build());
112 109
         this.name.setText(newName);
113 110
     }
114 111
 
@@ -118,12 +115,13 @@ public class ActionNamePanel extends JPanel implements PropertyChangeListener {
118 115
     }
119 116
 
120 117
     /** Initialises the components. */
121
-    @SuppressWarnings("unchecked")
122 118
     private void initComponents() {
123 119
         name = new ValidatingJTextField(iconManager,
124 120
                 existingName,
125
-                new ValidatorChain<>(new FileNameValidator(),
126
-                new ActionNameValidator(group, existingName)));
121
+                ValidatorChain.<String>builder()
122
+                .addValidator(new FileNameValidator())
123
+                .addValidator(new ActionNameValidator(group, existingName))
124
+                .build());
127 125
     }
128 126
 
129 127
     /** Adds the listeners. */
@@ -161,13 +159,11 @@ public class ActionNamePanel extends JPanel implements PropertyChangeListener {
161 159
         return name.getText();
162 160
     }
163 161
 
164
-    /** {@inheritDoc} */
165 162
     @Override
166 163
     public void setEnabled(final boolean enabled) {
167 164
         name.setEnabled(enabled);
168 165
     }
169 166
 
170
-    /** {@inheritDoc} */
171 167
     @Override
172 168
     public void propertyChange(final PropertyChangeEvent evt) {
173 169
         firePropertyChange("validationResult", evt.getOldValue(), evt.

+ 6
- 12
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialog.java Zobrazit soubor

@@ -119,7 +119,6 @@ public class ActionsManagerDialog extends StandardDialog implements
119 119
      * @param groupPanelFactory Factory to use to create group panels.
120 120
      */
121 121
     @Inject
122
-    @SuppressWarnings("unchecked")
123 122
     public ActionsManagerDialog(
124 123
             final MainFrame parentWindow,
125 124
             final SwingController controller,
@@ -136,9 +135,10 @@ public class ActionsManagerDialog extends StandardDialog implements
136 135
         this.groupPanelFactory = groupPanelFactory;
137 136
 
138 137
         initComponents();
139
-        validator = new ValidatorChain<>(
140
-                new ActionGroupNoDuplicatesInListValidator(groups,
141
-                (DefaultListModel) groups.getModel()), new FileNameValidator());
138
+        validator = ValidatorChain.<String>builder().addValidator(
139
+                new ActionGroupNoDuplicatesInListValidator(
140
+                groups, (DefaultListModel<ActionGroup>) groups.getModel()))
141
+                .addValidator(new FileNameValidator()).build();
142 142
         addListeners();
143 143
         layoutGroupPanel();
144 144
         layoutComponents();
@@ -176,7 +176,8 @@ public class ActionsManagerDialog extends StandardDialog implements
176 176
         actions.setBorder(BorderFactory.createTitledBorder(UIManager.getBorder(
177 177
                 "TitledBorder.border"), "Actions"));
178 178
 
179
-        groups.setCellRenderer(new PropertyListCellRenderer<>(groups.getCellRenderer(), ActionGroup.class, "name"));
179
+        groups.setCellRenderer(new PropertyListCellRenderer<>(groups.getCellRenderer(),
180
+                ActionGroup.class, "name"));
180 181
         groups.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
181 182
         edit.setEnabled(false);
182 183
         delete.setEnabled(false);
@@ -286,11 +287,6 @@ public class ActionsManagerDialog extends StandardDialog implements
286 287
         getContentPane().setVisible(true);
287 288
     }
288 289
 
289
-    /**
290
-     * {@inheritDoc}
291
-     *
292
-     * @param e Action event
293
-     */
294 290
     @Override
295 291
     public void actionPerformed(final ActionEvent e) {
296 292
         if (e.getSource() == add) {
@@ -424,7 +420,6 @@ public class ActionsManagerDialog extends StandardDialog implements
424 420
         }.display();
425 421
     }
426 422
 
427
-    /** {@inheritDoc} */
428 423
     @Override
429 424
     public void valueChanged(final ListSelectionEvent e) {
430 425
         if (e.getValueIsAdjusting()) {
@@ -441,7 +436,6 @@ public class ActionsManagerDialog extends StandardDialog implements
441 436
         }
442 437
     }
443 438
 
444
-    /** {@inheritDoc} */
445 439
     @Override
446 440
     public void processEvent(final ActionType type, final StringBuffer format,
447 441
             final Object... arguments) {

+ 4
- 4
src/com/dmdirc/addons/ui_swing/dialogs/aliases/AliasPanel.java Zobrazit soubor

@@ -95,10 +95,10 @@ public class AliasPanel extends JPanel implements ActionListener {
95 95
 
96 96
         this.actionFactory = actionFactory;
97 97
 
98
-        @SuppressWarnings("unchecked")
99
-        final ValidatorChain<String> chain = new ValidatorChain<>(
100
-                new CommandNameValidator(commandController.getCommandChar()),
101
-                new FileNameValidator());
98
+        final ValidatorChain<String> chain = ValidatorChain.<String>builder()
99
+                .addValidator(new CommandNameValidator(commandController.getCommandChar()))
100
+                .addValidator(new FileNameValidator())
101
+                .build();
102 102
         command = new ValidatingTextFieldInputField(iconManager, colourManager, globalConfig, chain);
103 103
         command.setEnabled(false);
104 104
 

+ 10
- 14
src/com/dmdirc/addons/ui_swing/dialogs/serversetting/IgnoreListPanel.java Zobrazit soubor

@@ -31,6 +31,7 @@ import com.dmdirc.ui.IconManager;
31 31
 import com.dmdirc.util.validators.NotEmptyValidator;
32 32
 import com.dmdirc.util.validators.RegexValidator;
33 33
 import com.dmdirc.util.validators.ValidatorChain;
34
+import com.dmdirc.util.validators.ValidatorChainBuilder;
34 35
 
35 36
 import java.awt.Dialog.ModalityType;
36 37
 import java.awt.Window;
@@ -80,7 +81,7 @@ public final class IgnoreListPanel extends JPanel implements ActionListener, Lis
80 81
     /**
81 82
      * Creates a new instance of IgnoreList.
82 83
      *
83
-     * @param iconManager   Icon manager
84
+     * @param iconManager  Icon manager
84 85
      * @param connection   The connection whose ignore list should be displayed.
85 86
      * @param parentWindow Parent window
86 87
      */
@@ -168,21 +169,18 @@ public final class IgnoreListPanel extends JPanel implements ActionListener, Lis
168 169
         connection.saveIgnoreList();
169 170
     }
170 171
 
171
-    /**
172
-     * {@inheritDoc}
173
-     *
174
-     * @param e Action event
175
-     */
176
-    @SuppressWarnings("unchecked")
177 172
     @Override
178 173
     public void actionPerformed(final ActionEvent e) {
179 174
         if (e.getSource() == addButton) {
175
+            final ValidatorChainBuilder<String> validatorBuilder = ValidatorChain.builder();
176
+            validatorBuilder.addValidator(new NotEmptyValidator());
177
+            if (viewToggle.isSelected()) {
178
+                validatorBuilder.addValidator(new RegexValidator());
179
+            }
180
+
180 181
             new StandardInputDialog(parentWindow,
181 182
                     ModalityType.MODELESS, iconManager, "New ignore list entry",
182
-                    "Please enter the new ignore list entry",
183
-                    viewToggle.isSelected() ? new ValidatorChain<>(
184
-                    new NotEmptyValidator(), new RegexValidator())
185
-                    : new NotEmptyValidator()) {
183
+                    "Please enter the new ignore list entry", validatorBuilder.build()) {
186 184
                 /** A version number for this class. */
187 185
                 private static final long serialVersionUID = 2;
188 186
 
@@ -205,8 +203,7 @@ public final class IgnoreListPanel extends JPanel implements ActionListener, Lis
205 203
                     //Ignore
206 204
                 }
207 205
             }.display();
208
-        } else if (e.getSource() == delButton && list.getSelectedIndex()
209
-                != -1) {
206
+        } else if (e.getSource() == delButton && list.getSelectedIndex() != -1) {
210 207
             new StandardQuestionDialog(parentWindow,
211 208
                     ModalityType.APPLICATION_MODAL,
212 209
                     "Confirm deletion",
@@ -234,7 +231,6 @@ public final class IgnoreListPanel extends JPanel implements ActionListener, Lis
234 231
         }
235 232
     }
236 233
 
237
-    /** {@inheritDoc} */
238 234
     @Override
239 235
     public void valueChanged(final ListSelectionEvent e) {
240 236
         if (list.getSelectedIndex() == -1) {

Načítá se…
Zrušit
Uložit