瀏覽代碼

Fix some checkstyle errors

Change-Id: I67a3f25ee46e7ff8c924e9ac64cc05b0e11986ae
Reviewed-on: http://gerrit.dmdirc.com/1772
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.5
Greg Holmes 13 年之前
父節點
當前提交
c93ba0cc41

+ 58
- 0
src/com/dmdirc/addons/ui_swing/components/SearchValidator.java 查看文件

@@ -0,0 +1,58 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+package com.dmdirc.addons.ui_swing.components;
23
+
24
+import com.dmdirc.util.validators.ValidationResponse;
25
+import com.dmdirc.util.validators.Validator;
26
+
27
+/**
28
+ * Simple search validator.
29
+ */
30
+public class SearchValidator implements Validator<String> {
31
+
32
+    /**
33
+     * A version number for this class. It should be changed whenever the
34
+     * class structure is changed (or anything else that would prevent
35
+     * serialized objects being unserialized with the new class).
36
+     */
37
+    private static final long serialVersionUID = 1;
38
+    /** Validates. */
39
+    private boolean validates = true;
40
+
41
+    /** {@inheritDoc} */
42
+    @Override
43
+    public ValidationResponse validate(final String object) {
44
+        if (validates) {
45
+            return new ValidationResponse();
46
+        }
47
+        return new ValidationResponse("Not found.");
48
+    }
49
+
50
+    /**
51
+     * Sets whether this validator validates.
52
+     *
53
+     * @param validates Does this search bar validate?
54
+     */
55
+    public void setValidates(final boolean validates) {
56
+        this.validates = validates;
57
+    }
58
+}

+ 154
- 0
src/com/dmdirc/addons/ui_swing/components/SendWorker.java 查看文件

@@ -0,0 +1,154 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.components;
24
+
25
+import com.dmdirc.addons.ui_swing.dialogs.FeedbackDialog;
26
+import com.dmdirc.config.IdentityManager;
27
+import com.dmdirc.util.Downloader;
28
+
29
+import java.io.IOException;
30
+import java.net.MalformedURLException;
31
+import java.util.HashMap;
32
+import java.util.List;
33
+import java.util.Map;
34
+
35
+/**
36
+ * Sends feedback worker thread.
37
+ */
38
+public class SendWorker extends LoggingSwingWorker {
39
+
40
+    /** Parent feedback dialog. */
41
+    private FeedbackDialog dialog;
42
+    /** Name. */
43
+    private String name;
44
+    /** Email. */
45
+    private String email;
46
+    /** Feedback. */
47
+    private String feedback;
48
+    /** Server name. */
49
+    private String serverInfo;
50
+    /** DMDirc Info. */
51
+    private String dmdircInfo;
52
+    /** Error/Success message. */
53
+    private StringBuilder error;
54
+
55
+    /**
56
+     * Creates a new send worker to send feedback.
57
+     *
58
+     * @param dialog Parent feedback dialog
59
+     * @param name Name
60
+     * @param email Email
61
+     * @param feedback Feedback
62
+     */
63
+    public SendWorker(final FeedbackDialog dialog, final String name,
64
+            final String email, final String feedback) {
65
+        this(dialog, name, email, feedback, "", "");
66
+    }
67
+
68
+    /**
69
+     * Creates a new send worker to send feedback.
70
+     *
71
+     * @param dialog Parent feedback dialog
72
+     * @param name Name
73
+     * @param email Email
74
+     * @param feedback Feedback
75
+     * @param serverInfo serverInfo
76
+     * @param dmdircInfo DMDirc info
77
+     */
78
+    public SendWorker(final FeedbackDialog dialog, final String name,
79
+            final String email, final String feedback,
80
+            final String serverInfo, final String dmdircInfo) {
81
+        super();
82
+
83
+        this.dialog = dialog;
84
+        this.name = name;
85
+        this.email = email;
86
+        this.feedback = feedback;
87
+        this.serverInfo = serverInfo;
88
+        this.dmdircInfo = dmdircInfo;
89
+
90
+        error = new StringBuilder();
91
+    }
92
+
93
+    /** {@inheritDoc} */
94
+    @Override
95
+    protected Object doInBackground() {
96
+        final Map<String, String> postData =
97
+                new HashMap<String, String>();
98
+
99
+        if (!name.isEmpty()) {
100
+            postData.put("name", name);
101
+        }
102
+        if (!email.isEmpty()) {
103
+            postData.put("email", email);
104
+        }
105
+        if (!feedback.isEmpty()) {
106
+            postData.put("feedback", feedback);
107
+        }
108
+        postData.put("version", IdentityManager.getGlobalConfig().getOption(
109
+                "version", "version"));
110
+        if (!serverInfo.isEmpty()) {
111
+            postData.put("serverInfo", serverInfo);
112
+        }
113
+        if (!dmdircInfo.isEmpty()) {
114
+            postData.put("dmdircInfo", dmdircInfo);
115
+        }
116
+
117
+        sendData(postData);
118
+
119
+        return error;
120
+    }
121
+
122
+    /**
123
+     * Sends the error data to the server appending returned information to the
124
+     * global error variable.
125
+     *
126
+     * @param postData Feedback data to send
127
+     */
128
+    private void sendData(final Map<String, String> postData) {
129
+        try {
130
+            final List<String> response =
131
+                    Downloader.getPage("http://www.dmdirc.com/feedback.php",
132
+                    postData);
133
+            if (response.size() >= 1) {
134
+                for (String responseLine : response) {
135
+                    error.append(responseLine).append("\n");
136
+                }
137
+            } else {
138
+                error.append("Failure: Unknown response from the server.");
139
+            }
140
+        } catch (MalformedURLException ex) {
141
+            error.append("Malformed feedback URL.");
142
+        } catch (IOException ex) {
143
+            error.append("Failure: ").append(ex.getMessage());
144
+        }
145
+    }
146
+
147
+    /** {@inheritDoc} */
148
+    @Override
149
+    protected void done() {
150
+        super.done();
151
+        dialog.layoutComponents2(error);
152
+    }
153
+}
154
+

+ 0
- 35
src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java 查看文件

@@ -37,8 +37,6 @@ import com.dmdirc.ui.messages.IRCDocument;
37 37
 import com.dmdirc.ui.messages.IRCDocumentSearcher;
38 38
 import com.dmdirc.ui.messages.LinePosition;
39 39
 import com.dmdirc.util.ListenerList;
40
-import com.dmdirc.util.validators.ValidationResponse;
41
-import com.dmdirc.util.validators.Validator;
42 40
 
43 41
 import java.awt.event.ActionEvent;
44 42
 import java.awt.event.ActionListener;
@@ -419,36 +417,3 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
419 417
                 getOptionColour("ui", "foregroundcolour"));
420 418
     }
421 419
 }
422
-
423
-/**
424
- * Simple search validator.
425
- */
426
-class SearchValidator implements Validator<String> {
427
-
428
-    /**
429
-     * A version number for this class. It should be changed whenever the class
430
-     * structure is changed (or anything else that would prevent serialized
431
-     * objects being unserialized with the new class).
432
-     */
433
-    private static final long serialVersionUID = 1;
434
-    /** Validates. */
435
-    private boolean validates = true;
436
-
437
-    /** {@inheritDoc} */
438
-    @Override
439
-    public ValidationResponse validate(final String object) {
440
-        if (validates) {
441
-            return new ValidationResponse();
442
-        }
443
-        return new ValidationResponse("Not found.");
444
-    }
445
-
446
-    /**
447
-     * Sets whether this validator validates.
448
-     *
449
-     * @param validates Does this search bar validate?
450
-     */
451
-    public void setValidates(final boolean validates) {
452
-        this.validates = validates;
453
-    }
454
-}

+ 73
- 0
src/com/dmdirc/addons/ui_swing/components/statusbar/InviteAction.java 查看文件

@@ -0,0 +1,73 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.components.statusbar;
24
+
25
+import com.dmdirc.Invite;
26
+
27
+import java.awt.event.ActionEvent;
28
+import java.util.Arrays;
29
+
30
+import javax.swing.AbstractAction;
31
+
32
+/**
33
+ * Invite action.
34
+ */
35
+class InviteAction extends AbstractAction {
36
+
37
+    /**
38
+     * A version number for this class. It should be changed whenever the class
39
+     * structure is changed (or anything else that would prevent serialized
40
+     * objects being unserialized with the new class).
41
+     */
42
+    private static final long serialVersionUID = 1;
43
+    /** Invite. */
44
+    private final Invite invite;
45
+
46
+    /**
47
+     * Instantiates a new invite action.
48
+     *
49
+     * @param invite Invite for the action
50
+     */
51
+    public InviteAction(final Invite invite) {
52
+        super(invite.getChannel() + " (" + invite.getSource()[0] + ")");
53
+
54
+        this.invite = invite;
55
+    }
56
+
57
+    /**
58
+     * {@inheritDoc}
59
+     *
60
+     * @param e Action event
61
+     */
62
+    @Override
63
+    public void actionPerformed(final ActionEvent e) {
64
+        invite.accept();
65
+    }
66
+
67
+    /** {@inheritDoc} */
68
+    @Override
69
+    public String toString() {
70
+        return invite.getChannel() + "(" + Arrays.toString(invite.getSource())
71
+                + ")";
72
+    }
73
+}

+ 1
- 46
src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java 查看文件

@@ -38,10 +38,8 @@ import com.dmdirc.ui.interfaces.StatusBarComponent;
38 38
 
39 39
 import java.awt.event.ActionEvent;
40 40
 import java.awt.event.MouseEvent;
41
-import java.util.Arrays;
42 41
 import java.util.List;
43 42
 
44
-import javax.swing.AbstractAction;
45 43
 import javax.swing.BorderFactory;
46 44
 import javax.swing.JLabel;
47 45
 import javax.swing.JMenuItem;
@@ -70,7 +68,7 @@ public class InviteLabel extends StatusbarPopupPanel implements
70 68
     /** Accept invites menu item. */
71 69
     private final JMenuItem accept;
72 70
     /** Parent window. */
73
-    private MainFrame mainFrame;
71
+    private final MainFrame mainFrame;
74 72
     /** Active frame. */
75 73
     private FrameContainer activeFrame;
76 74
 
@@ -214,46 +212,3 @@ public class InviteLabel extends StatusbarPopupPanel implements
214 212
         }
215 213
     }
216 214
 }
217
-
218
-/**
219
- * Invite action.
220
- */
221
-class InviteAction extends AbstractAction {
222
-
223
-    /**
224
-     * A version number for this class. It should be changed whenever the class
225
-     * structure is changed (or anything else that would prevent serialized
226
-     * objects being unserialized with the new class).
227
-     */
228
-    private static final long serialVersionUID = 1;
229
-    /** Invite. */
230
-    private final Invite invite;
231
-
232
-    /**
233
-     * Instantiates a new invite action.
234
-     *
235
-     * @param invite Invite for the action
236
-     */
237
-    public InviteAction(final Invite invite) {
238
-        super(invite.getChannel() + " (" + invite.getSource()[0] + ")");
239
-
240
-        this.invite = invite;
241
-    }
242
-
243
-    /**
244
-     * {@inheritDoc}
245
-     *
246
-     * @param e Action event
247
-     */
248
-    @Override
249
-    public void actionPerformed(final ActionEvent e) {
250
-        invite.accept();
251
-    }
252
-
253
-    /** {@inheritDoc} */
254
-    @Override
255
-    public String toString() {
256
-        return invite.getChannel() + "(" + Arrays.toString(invite.getSource()) +
257
-                ")";
258
-    }
259
-}

+ 2
- 129
src/com/dmdirc/addons/ui_swing/dialogs/FeedbackDialog.java 查看文件

@@ -27,21 +27,14 @@ import com.dmdirc.Server;
27 27
 import com.dmdirc.ServerManager;
28 28
 import com.dmdirc.addons.ui_swing.SwingController;
29 29
 import com.dmdirc.addons.ui_swing.UIUtilities;
30
-import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
30
+import com.dmdirc.addons.ui_swing.components.SendWorker;
31 31
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
32
-import com.dmdirc.config.IdentityManager;
33 32
 import com.dmdirc.ui.core.util.Info;
34
-import com.dmdirc.util.Downloader;
35 33
 
36 34
 import java.awt.Insets;
37 35
 import java.awt.Window;
38 36
 import java.awt.event.ActionEvent;
39 37
 import java.awt.event.ActionListener;
40
-import java.io.IOException;
41
-import java.net.MalformedURLException;
42
-import java.util.HashMap;
43
-import java.util.List;
44
-import java.util.Map;
45 38
 
46 39
 import javax.swing.BorderFactory;
47 40
 import javax.swing.JButton;
@@ -195,7 +188,7 @@ public final class FeedbackDialog extends StandardDialog implements
195 188
      *
196 189
      * @param error Did the submission error?
197 190
      */
198
-    protected void layoutComponents2(final StringBuilder error) {
191
+    public void layoutComponents2(final StringBuilder error) {
199 192
         getContentPane().setVisible(false);
200 193
         getContentPane().removeAll();
201 194
         getOkButton().setEnabled(true);
@@ -325,123 +318,3 @@ public final class FeedbackDialog extends StandardDialog implements
325 318
         }
326 319
     }
327 320
 }
328
-
329
-/**
330
- * Sends feedback worker thread.
331
- */
332
-class SendWorker extends LoggingSwingWorker {
333
-
334
-    /** Parent feedback dialog. */
335
-    private FeedbackDialog dialog;
336
-    /** Name. */
337
-    private String name;
338
-    /** Email. */
339
-    private String email;
340
-    /** Feedback. */
341
-    private String feedback;
342
-    /** Server name. */
343
-    private String serverInfo;
344
-    /** DMDirc Info. */
345
-    private String dmdircInfo;
346
-    /** Error/Success message. */
347
-    private StringBuilder error;
348
-
349
-    /**
350
-     * Creates a new send worker to send feedback.
351
-     *
352
-     * @param dialog Parent feedback dialog
353
-     * @param name Name
354
-     * @param email Email
355
-     * @param feedback Feedback
356
-     */
357
-    public SendWorker(final FeedbackDialog dialog, final String name,
358
-            final String email, final String feedback) {
359
-        this(dialog, name, email, feedback, "", "");
360
-    }
361
-
362
-    /**
363
-     * Creates a new send worker to send feedback.
364
-     *
365
-     * @param dialog Parent feedback dialog
366
-     * @param name Name
367
-     * @param email Email
368
-     * @param feedback Feedback
369
-     * @param serverInfo serverInfo
370
-     * @param dmdircInfo DMDirc info
371
-     */
372
-    public SendWorker(final FeedbackDialog dialog, final String name,
373
-            final String email, final String feedback,
374
-            final String serverInfo, final String dmdircInfo) {
375
-        super();
376
-
377
-        this.dialog = dialog;
378
-        this.name = name;
379
-        this.email = email;
380
-        this.feedback = feedback;
381
-        this.serverInfo = serverInfo;
382
-        this.dmdircInfo = dmdircInfo;
383
-
384
-        error = new StringBuilder();
385
-    }
386
-
387
-    /** {@inheritDoc} */
388
-    @Override
389
-    protected Object doInBackground() {
390
-        final Map<String, String> postData =
391
-                new HashMap<String, String>();
392
-
393
-        if (!name.isEmpty()) {
394
-            postData.put("name", name);
395
-        }
396
-        if (!email.isEmpty()) {
397
-            postData.put("email", email);
398
-        }
399
-        if (!feedback.isEmpty()) {
400
-            postData.put("feedback", feedback);
401
-        }
402
-        postData.put("version", IdentityManager.getGlobalConfig().getOption(
403
-                "version", "version"));
404
-        if (!serverInfo.isEmpty()) {
405
-            postData.put("serverInfo", serverInfo);
406
-        }
407
-        if (!dmdircInfo.isEmpty()) {
408
-            postData.put("dmdircInfo", dmdircInfo);
409
-        }
410
-
411
-        sendData(postData);
412
-
413
-        return error;
414
-    }
415
-
416
-    /**
417
-     * Sends the error data to the server appending returned information to the
418
-     * global error variable.
419
-     *
420
-     * @param postData Feedback data to send
421
-     */
422
-    private void sendData(final Map<String, String> postData) {
423
-        try {
424
-            final List<String> response =
425
-                    Downloader.getPage("http://www.dmdirc.com/feedback.php",
426
-                    postData);
427
-            if (response.size() >= 1) {
428
-                for (String responseLine : response) {
429
-                    error.append(responseLine).append("\n");
430
-                }
431
-            } else {
432
-                error.append("Failure: Unknown response from the server.");
433
-            }
434
-        } catch (MalformedURLException ex) {
435
-            error.append("Malformed feedback URL.");
436
-        } catch (IOException ex) {
437
-            error.append("Failure: ").append(ex.getMessage());
438
-        }
439
-    }
440
-
441
-    /** {@inheritDoc} */
442
-    @Override
443
-    protected void done() {
444
-        super.done();
445
-        dialog.layoutComponents2(error);
446
-    }
447
-}

+ 79
- 0
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionGroupNoDuplicatesInListValidator.java 查看文件

@@ -0,0 +1,79 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.dialogs.actionsmanager;
24
+
25
+import com.dmdirc.actions.ActionGroup;
26
+import com.dmdirc.addons.ui_swing.components.validating.NoDuplicatesInListValidator;
27
+
28
+import javax.swing.DefaultListModel;
29
+import javax.swing.JList;
30
+
31
+/**
32
+ * No duplicates list validator, overriden to work with action groups.
33
+ */
34
+class ActionGroupNoDuplicatesInListValidator extends
35
+        NoDuplicatesInListValidator {
36
+
37
+    /**
38
+     * Creates a new validator.
39
+     *
40
+     * @param list List
41
+     * @param model Model to validate
42
+     */
43
+    public ActionGroupNoDuplicatesInListValidator(final JList list,
44
+            final DefaultListModel model) {
45
+        super(true, list, model);
46
+    }
47
+
48
+    /**
49
+     * Creates a new validator.
50
+     *
51
+     * @param list List
52
+     * @param caseSensitive Case sensitive check?
53
+     * @param model Model to validate
54
+     */
55
+    public ActionGroupNoDuplicatesInListValidator(final boolean caseSensitive,
56
+            final JList list, final DefaultListModel model) {
57
+        super(caseSensitive, list, model);
58
+    }
59
+
60
+    /** {@inheritDoc} */
61
+    @Override
62
+    public String listValueToString(final Object object) {
63
+        return ((ActionGroup) object).getName();
64
+    }
65
+
66
+    /** {@inheritDoc} */
67
+    @Override
68
+    public int indexOfString(final String string) {
69
+        final String value = caseSensitive ? string : string.toLowerCase();
70
+        int index = -1;
71
+        for (int i = 0; i < model.getSize(); i++) {
72
+            if (((ActionGroup) model.get(i)).getName().equals(value)) {
73
+                index = i;
74
+                break;
75
+            }
76
+        }
77
+        return index;
78
+    }
79
+}

+ 5
- 56
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialog.java 查看文件

@@ -35,7 +35,6 @@ import com.dmdirc.addons.ui_swing.components.SortedListModel;
35 35
 import com.dmdirc.addons.ui_swing.components.frames.AppleJFrame;
36 36
 import com.dmdirc.addons.ui_swing.components.renderers.ActionGroupListCellRenderer;
37 37
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
38
-import com.dmdirc.addons.ui_swing.components.validating.NoDuplicatesInListValidator;
39 38
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
40 39
 import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog;
41 40
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
@@ -101,7 +100,7 @@ public final class ActionsManagerDialog extends StandardDialog implements
101 100
     /** Are we saving? */
102 101
     private final AtomicBoolean saving = new AtomicBoolean(false);
103 102
     /** Duplicate action group validator. */
104
-    private ValidatorChain<String> validator;
103
+    private final ValidatorChain<String> validator;
105 104
 
106 105
     /** 
107 106
      * Creates a new instance of ActionsManagerDialog.
@@ -342,7 +341,7 @@ public final class ActionsManagerDialog extends StandardDialog implements
342 341
     private void addGroup() {
343 342
         final int index = groups.getSelectedIndex();
344 343
         groups.getSelectionModel().clearSelection();
345
-        final StandardInputDialog inputDialog = new StandardInputDialog(this,
344
+        new StandardInputDialog(this,
346 345
                 ModalityType.DOCUMENT_MODAL, "New action group",
347 346
                 "Please enter the name of the new action group", validator) {
348 347
 
@@ -377,8 +376,7 @@ public final class ActionsManagerDialog extends StandardDialog implements
377 376
             public void cancelled() {
378 377
                 groups.setSelectedIndex(index);
379 378
             }
380
-        };
381
-        inputDialog.display(this);
379
+        }.display(this);
382 380
     }
383 381
 
384 382
     /**
@@ -460,11 +458,11 @@ public final class ActionsManagerDialog extends StandardDialog implements
460 458
                 groups.setSelectedIndex(location);
461 459
                 return true;
462 460
             }
463
-
461
+            
464 462
             /** {@inheritDoc} */
465 463
             @Override
466 464
             public void cancelled() {
467
-                return;
465
+                //Ignore
468 466
             }
469 467
         }.display();
470 468
     }
@@ -521,52 +519,3 @@ public final class ActionsManagerDialog extends StandardDialog implements
521 519
         }
522 520
     }
523 521
 }
524
-
525
-/**
526
- * No duplicates list validator, overriden to work with action groups.
527
- */
528
-class ActionGroupNoDuplicatesInListValidator extends NoDuplicatesInListValidator {
529
-
530
-    /**
531
-     * Creates a new validator.
532
-     *
533
-     * @param list List
534
-     * @param model Model to validate
535
-     */
536
-    public ActionGroupNoDuplicatesInListValidator(final JList list,
537
-            final DefaultListModel model) {
538
-        super(true, list, model);
539
-    }
540
-
541
-    /**
542
-     * Creates a new validator.
543
-     *
544
-     * @param list List
545
-     * @param caseSensitive Case sensitive check?
546
-     * @param model Model to validate
547
-     */
548
-    public ActionGroupNoDuplicatesInListValidator(final boolean caseSensitive,
549
-            final JList list, final DefaultListModel model) {
550
-        super(caseSensitive, list, model);
551
-    }
552
-    
553
-    /** {@inheritDoc} */
554
-    @Override
555
-    public String listValueToString(final Object object) {
556
-        return ((ActionGroup) object).getName();
557
-    }
558
-
559
-    /** {@inheritDoc} */
560
-    @Override
561
-    public int indexOfString(final String string) {
562
-        final String value = caseSensitive ? string : string.toLowerCase();
563
-        int index = -1;
564
-        for (int i = 0; i < model.getSize(); i++) {
565
-            if (((ActionGroup) model.get(i)).getName().equals(value)) {
566
-                index = i;
567
-                break;
568
-            }
569
-        }
570
-        return index;
571
-    }
572
-}

Loading…
取消
儲存