Browse Source

Merge pull request #98 from greboid/standarddialogs

Use lambdas in StandardQuestionDialog.
pull/101/head
Chris Smith 9 years ago
parent
commit
b8229ebe13

+ 0
- 65
dcc/src/com/dmdirc/addons/dcc/ChatRequestDialog.java View File

1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
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.dcc;
24
-
25
-import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
26
-import com.dmdirc.interfaces.Connection;
27
-import com.dmdirc.parser.interfaces.Parser;
28
-
29
-import java.awt.Window;
30
-
31
-/**
32
- * Confirm DCC Chat dialog.
33
- */
34
-public class ChatRequestDialog extends StandardQuestionDialog {
35
-
36
-    private static final long serialVersionUID = 1L;
37
-    private final DCCManager manager;
38
-    private final Parser parser;
39
-    private final String nickname;
40
-    private final String[] ctcpData;
41
-
42
-    public ChatRequestDialog(final Window owner, final DCCManager manager,
43
-            final Connection connection, final String nickname, final String[] ctcpData) {
44
-        super(owner, ModalityType.APPLICATION_MODAL,
45
-                "DCC Chat Request", "User " + nickname + " on "
46
-                + connection.getAddress()
47
-                + " would like to start a DCC Chat with you.\n\n"
48
-                + "Do you want to continue?");
49
-        this.manager = manager;
50
-        this.parser = connection.getParser();
51
-        this.nickname = nickname;
52
-        this.ctcpData = ctcpData;
53
-    }
54
-
55
-    @Override
56
-    public boolean save() {
57
-        manager.handleDCCChat(parser, nickname, ctcpData);
58
-        return true;
59
-    }
60
-
61
-    @Override
62
-    public void cancelled() {
63
-    }
64
-
65
-}

+ 13
- 3
dcc/src/com/dmdirc/addons/dcc/DCCManager.java View File

34
 import com.dmdirc.addons.ui_swing.SwingWindowFactory;
34
 import com.dmdirc.addons.ui_swing.SwingWindowFactory;
35
 import com.dmdirc.addons.ui_swing.components.frames.ComponentFrameFactory;
35
 import com.dmdirc.addons.ui_swing.components.frames.ComponentFrameFactory;
36
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
36
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
37
+import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
37
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
38
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
38
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
39
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
39
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
40
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
55
 import com.dmdirc.ui.messages.ColourManagerFactory;
56
 import com.dmdirc.ui.messages.ColourManagerFactory;
56
 import com.dmdirc.util.URLBuilder;
57
 import com.dmdirc.util.URLBuilder;
57
 
58
 
59
+import java.awt.Dialog;
58
 import java.awt.Window;
60
 import java.awt.Window;
59
 import java.io.File;
61
 import java.io.File;
60
 import java.io.IOException;
62
 import java.io.IOException;
406
             handleDCCChat(connection.getParser(), nickname, ctcpData);
408
             handleDCCChat(connection.getParser(), nickname, ctcpData);
407
         } else {
409
         } else {
408
             eventBus.publish(new DccChatRequestEvent(connection, nickname));
410
             eventBus.publish(new DccChatRequestEvent(connection, nickname));
409
-            new ChatRequestDialog(mainWindow, this, connection, nickname, ctcpData).display();
411
+            new StandardQuestionDialog(mainWindow, Dialog.ModalityType.APPLICATION_MODAL,
412
+                    "DCC Chat Request", "User " + nickname + " on " + connection.getAddress()
413
+                    + " would like to start a DCC Chat with you.\n\nDo you want to continue?",
414
+                    () -> handleDCCChat(connection.getParser(), nickname, ctcpData)).display();
410
         }
415
         }
411
     }
416
     }
412
 
417
 
518
                 (token.isEmpty() || port.equals("0"))) {
523
                 (token.isEmpty() || port.equals("0"))) {
519
             // Make sure this is not a reverse DCC Send that we no longer care about.
524
             // Make sure this is not a reverse DCC Send that we no longer care about.
520
             eventBus.publish(new DccSendRequestEvent(connection, nickname, filename));
525
             eventBus.publish(new DccSendRequestEvent(connection, nickname, filename));
521
-            new SendRequestDialog(mainWindow, this, token, ipLong, portInt, filename, size,
522
-                    nickname, connection).display();
526
+            final long passedSize = size;
527
+            new StandardQuestionDialog(mainWindow, Dialog.ModalityType.APPLICATION_MODAL,
528
+                    "DCC Send Request", "User " + nickname + " on " + connection.getAddress()
529
+                            + " would like to send you a file over DCC.\n\nFile: "
530
+                            + filename + "\n\nDo you want to continue?",
531
+                    () -> handleDCCSend(token, ipLong, portInt, filename, passedSize, nickname,
532
+                            connection.getParser())).display();
523
         }
533
         }
524
     }
534
     }
525
 
535
 

+ 8
- 26
dcc/src/com/dmdirc/addons/dcc/PlaceholderContainer.java View File

32
 
32
 
33
 import java.awt.Dialog.ModalityType;
33
 import java.awt.Dialog.ModalityType;
34
 import java.awt.Window;
34
 import java.awt.Window;
35
-import java.util.Arrays;
35
+import java.util.Collections;
36
 
36
 
37
 /**
37
 /**
38
  * Creates a placeholder DCC Frame.
38
  * Creates a placeholder DCC Frame.
61
             final URLBuilder urlBuilder,
61
             final URLBuilder urlBuilder,
62
             final DMDircMBassador eventBus) {
62
             final DMDircMBassador eventBus) {
63
         super(null, "dcc", "DCCs", "DCCs", config, colourManagerFactory, urlBuilder, eventBus,
63
         super(null, "dcc", "DCCs", "DCCs", config, colourManagerFactory, urlBuilder, eventBus,
64
-                Arrays.asList("com.dmdirc.addons.dcc.ui.PlaceholderPanel"));
64
+                Collections.singletonList("com.dmdirc.addons.dcc.ui.PlaceholderPanel"));
65
         this.plugin = plugin;
65
         this.plugin = plugin;
66
         this.parentWindow = parentWindow;
66
         this.parentWindow = parentWindow;
67
     }
67
     }
70
     public void close() {
70
     public void close() {
71
         int dccs = 0;
71
         int dccs = 0;
72
         for (FrameContainer window : getChildren()) {
72
         for (FrameContainer window : getChildren()) {
73
-            if ((window instanceof TransferContainer
74
-                    && ((TransferContainer) window).getDCC().isActive())
75
-                    || (window instanceof ChatContainer
76
-                    && ((ChatContainer) window).getDCC().isActive())) {
73
+            if (window instanceof TransferContainer
74
+                    && ((TransferContainer) window).getDCC().isActive()
75
+                    || window instanceof ChatContainer
76
+                    && ((ChatContainer) window).getDCC().isActive()) {
77
                 dccs++;
77
                 dccs++;
78
             }
78
             }
79
         }
79
         }
82
             new StandardQuestionDialog(parentWindow, ModalityType.MODELESS,
82
             new StandardQuestionDialog(parentWindow, ModalityType.MODELESS,
83
                     "Close confirmation",
83
                     "Close confirmation",
84
                     "Closing this window will cause all existing DCCs "
84
                     "Closing this window will cause all existing DCCs "
85
-                    + "to terminate, are you sure you want to do this?") {
86
-                        /**
87
-                         * A version number for this class. It should be changed whenever the class
88
-                         * structure is changed (or anything else that would prevent serialized
89
-                         * objects being unserialized with the new class).
90
-                         */
91
-                        private static final long serialVersionUID = 1;
92
-
93
-                        @Override
94
-                        public boolean save() {
95
-                            PlaceholderContainer.super.close();
96
-                            plugin.removeContainer();
97
-                            return true;
98
-                        }
99
-
100
-                        @Override
101
-                        public void cancelled() {
102
-                            // Don't close!
103
-                        }
104
-                    }.display();
85
+                    + "to terminate, are you sure you want to do this?",
86
+                    () -> { close(); plugin.removeContainer();}).display();
105
         } else {
87
         } else {
106
             super.close();
88
             super.close();
107
             plugin.removeContainer();
89
             plugin.removeContainer();

+ 0
- 74
dcc/src/com/dmdirc/addons/dcc/SendRequestDialog.java View File

1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
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.dcc;
24
-
25
-import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
26
-import com.dmdirc.interfaces.Connection;
27
-import com.dmdirc.parser.interfaces.Parser;
28
-
29
-import java.awt.Window;
30
-
31
-/**
32
- * Confirm DCC Send dialog.
33
- */
34
-public class SendRequestDialog extends StandardQuestionDialog {
35
-
36
-    private static final long serialVersionUID = 1L;
37
-    private final DCCManager manager;
38
-    private final String token;
39
-    private final long ip;
40
-    private final int port;
41
-    private final String filename;
42
-    private final long size;
43
-    private final String nickname;
44
-    private final Parser parser;
45
-
46
-    public SendRequestDialog(final Window owner, final DCCManager manager, final String token,
47
-            final long ip, final int port, final String filename, final long size,
48
-            final String nickname, final Connection connection) {
49
-        super(owner, ModalityType.APPLICATION_MODAL, "DCC Send Request",
50
-                "User " + nickname + " on "
51
-                + connection.getAddress()
52
-                + " would like to send you a file over DCC.\n\nFile: "
53
-                + filename + "\n\nDo you want to continue?");
54
-        this.manager = manager;
55
-        this.token = token;
56
-        this.ip = ip;
57
-        this.port = port;
58
-        this.filename = filename;
59
-        this.size = size;
60
-        this.nickname = nickname;
61
-        this.parser = connection.getParser();
62
-    }
63
-
64
-    @Override
65
-    public boolean save() {
66
-        manager.handleDCCSend(token, ip, port, filename, size, nickname, parser);
67
-        return true;
68
-    }
69
-
70
-    @Override
71
-    public void cancelled() {
72
-    }
73
-
74
-}

+ 1
- 1
nickcolours/src/com/dmdirc/addons/nickcolours/NickColourInputDialog.java View File

81
             final NickColourPanel panel, final int row,
81
             final NickColourPanel panel, final int row,
82
             final String nickname, final String network,
82
             final String nickname, final String network,
83
             final String textcolour, final String nickcolour) {
83
             final String textcolour, final String nickcolour) {
84
-        super(parentWindow, false);
84
+        super(parentWindow, ModalityType.MODELESS);
85
 
85
 
86
         this.panel = panel;
86
         this.panel = panel;
87
         this.row = row;
87
         this.row = row;

+ 5
- 12
ui_swing/src/com/dmdirc/addons/ui_swing/MainFrame.java View File

27
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
27
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
28
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
29
 import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
29
 import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
30
-import com.dmdirc.addons.ui_swing.dialogs.ConfirmQuitDialog;
31
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
30
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
32
 import com.dmdirc.addons.ui_swing.events.SwingActiveWindowChangeRequestEvent;
31
 import com.dmdirc.addons.ui_swing.events.SwingActiveWindowChangeRequestEvent;
33
 import com.dmdirc.addons.ui_swing.events.SwingEventBus;
32
 import com.dmdirc.addons.ui_swing.events.SwingEventBus;
51
 import com.dmdirc.ui.IconManager;
50
 import com.dmdirc.ui.IconManager;
52
 import com.dmdirc.util.collections.QueuedLinkedHashSet;
51
 import com.dmdirc.util.collections.QueuedLinkedHashSet;
53
 
52
 
53
+import java.awt.Dialog;
54
 import java.awt.Dimension;
54
 import java.awt.Dimension;
55
 import java.awt.event.WindowEvent;
55
 import java.awt.event.WindowEvent;
56
 import java.awt.event.WindowFocusListener;
56
 import java.awt.event.WindowFocusListener;
432
      */
432
      */
433
     public void quit(final int exitCode) {
433
     public void quit(final int exitCode) {
434
         if (exitCode == 0 && globalConfig.getOptionBool("ui", "confirmQuit")) {
434
         if (exitCode == 0 && globalConfig.getOptionBool("ui", "confirmQuit")) {
435
-            final StandardQuestionDialog dialog = new ConfirmQuitDialog(this) {
436
-                /** Serial version UID. */
437
-                private static final long serialVersionUID = 9;
438
-
439
-                @Override
440
-                protected void handleQuit() {
441
-                    doQuit(exitCode);
442
-                }
443
-            };
444
-            dialog.display();
435
+            new StandardQuestionDialog(this, Dialog.ModalityType.APPLICATION_MODAL,
436
+                    "Quit confirm", "You are about to quit DMDirc, are you sure?",
437
+                    () -> { doQuit(0); return true;}).display();
445
             return;
438
             return;
446
         }
439
         }
447
         doQuit(exitCode);
440
         doQuit(exitCode);
493
         activeFrame = event.getWindow();
486
         activeFrame = event.getWindow();
494
 
487
 
495
         if (activeFrame.isPresent()) {
488
         if (activeFrame.isPresent()) {
496
-            framePanel.add((activeFrame.get()).getDisplayFrame(), "grow");
489
+            framePanel.add(activeFrame.get().getDisplayFrame(), "grow");
497
             setTitle(activeFrame.get().getContainer().getTitle());
490
             setTitle(activeFrame.get().getContainer().getTitle());
498
         } else {
491
         } else {
499
             framePanel.add(new JPanel(), "grow");
492
             framePanel.add(new JPanel(), "grow");

+ 0
- 61
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/ConfirmQuitDialog.java View File

1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
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;
24
-
25
-import java.awt.Window;
26
-
27
-/**
28
- * A simple dialog to confirm and handle the quitting of the client.
29
- */
30
-public abstract class ConfirmQuitDialog extends StandardQuestionDialog {
31
-
32
-    /** A version number for this class. */
33
-    private static final long serialVersionUID = 1;
34
-
35
-    /**
36
-     * Creates a new client quit confirmation dialog.
37
-     *
38
-     * @param parentWindow Parent window
39
-     */
40
-    public ConfirmQuitDialog(final Window parentWindow) {
41
-        super(parentWindow, ModalityType.APPLICATION_MODAL, "Quit confirm",
42
-                "You are about to quit DMDirc, are you sure?");
43
-    }
44
-
45
-    @Override
46
-    public boolean save() {
47
-        handleQuit();
48
-        return true;
49
-    }
50
-
51
-    @Override
52
-    public void cancelled() {
53
-        // Do nothing
54
-    }
55
-
56
-    /**
57
-     * Called when the user confirms they wish to quit the client.
58
-     */
59
-    protected abstract void handleQuit();
60
-
61
-}

+ 0
- 81
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/DMDircJOptionPane.java View File

1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
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;
24
-
25
-import javax.swing.JDialog;
26
-import javax.swing.JOptionPane;
27
-
28
-/**
29
- * Extension of JOptionPane to allow Word Wrapping.
30
- */
31
-public class DMDircJOptionPane extends JOptionPane {
32
-
33
-    /** A version number for this class. */
34
-    private static final long serialVersionUID = 1;
35
-    /** Maximum characters per line. */
36
-    private int maxCharactersPerLineCount = Integer.MAX_VALUE;
37
-    /** Title of Dialog. */
38
-    private String title = "";
39
-
40
-    /**
41
-     * Create a DMDircJOptionPane.
42
-     *
43
-     * @param title       Title to use
44
-     * @param message     Message to show
45
-     * @param messageType Message Type.
46
-     * @param optionType  Options.
47
-     */
48
-    public DMDircJOptionPane(final String title, final String message,
49
-            final int messageType, final int optionType) {
50
-        super(message, messageType, optionType);
51
-        this.title = title;
52
-    }
53
-
54
-    /**
55
-     * Set the maximum number of characters per line.
56
-     *
57
-     * @param maxCharactersPerLineCount Maximum characters per line
58
-     */
59
-    public void setMaxCharactersPerLineCount(final int maxCharactersPerLineCount) {
60
-        this.maxCharactersPerLineCount = maxCharactersPerLineCount;
61
-    }
62
-
63
-    @Override
64
-    public int getMaxCharactersPerLineCount() {
65
-        return this.maxCharactersPerLineCount;
66
-    }
67
-
68
-    /** Show this dialog. */
69
-    public void showDialog() {
70
-        // Recalculate width, because JOptionPane calculates it before the
71
-        // constructor gets a chance to finish, and so gets a max chars of 0.
72
-        final Object oldMessage = this.getMessage();
73
-        this.setMessage("");
74
-        this.setMessage(oldMessage);
75
-
76
-        final JDialog dialog = createDialog(title);
77
-        dialog.setVisible(true);
78
-        dialog.dispose();
79
-    }
80
-
81
-}

+ 3
- 49
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/StandardDialog.java View File

29
 import java.awt.Window;
29
 import java.awt.Window;
30
 import java.awt.event.WindowAdapter;
30
 import java.awt.event.WindowAdapter;
31
 import java.awt.event.WindowEvent;
31
 import java.awt.event.WindowEvent;
32
-import java.util.concurrent.Semaphore;
33
 
32
 
34
 import javax.swing.JButton;
33
 import javax.swing.JButton;
35
 import javax.swing.JDialog;
34
 import javax.swing.JDialog;
36
-import javax.swing.SwingUtilities;
37
 
35
 
38
 /**
36
 /**
39
  * Provides common methods for dialogs.
37
  * Provides common methods for dialogs.
43
     /** Serial version UID. */
41
     /** Serial version UID. */
44
     private static final long serialVersionUID = 1;
42
     private static final long serialVersionUID = 1;
45
     /** Parent window. */
43
     /** Parent window. */
46
-    private Window owner;
44
+    private Component owner;
47
     /** The OK button for this frame. */
45
     /** The OK button for this frame. */
48
     private JButton okButton;
46
     private JButton okButton;
49
     /** The cancel button for this frame. */
47
     /** The cancel button for this frame. */
50
     private JButton cancelButton;
48
     private JButton cancelButton;
51
 
49
 
52
-    /**
53
-     * Creates a new instance of StandardDialog.
54
-     *
55
-     * @param owner The window that owns this dialog
56
-     * @param modal Whether to display modally or not
57
-     */
58
-    public StandardDialog(final Window owner, final boolean modal) {
59
-        this(owner, modal ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
60
-    }
61
-
62
     /**
50
     /**
63
      * Creates a new instance of StandardDialog.
51
      * Creates a new instance of StandardDialog.
64
      *
52
      *
94
      *
82
      *
95
      * @param parent Parent window
83
      * @param parent Parent window
96
      */
84
      */
97
-    public void displayOrRequestFocus(final Window parent) {
85
+    public void displayOrRequestFocus(final Component parent) {
98
         if (isVisible()) {
86
         if (isVisible()) {
99
             requestFocus();
87
             requestFocus();
100
         } else {
88
         } else {
107
      *
95
      *
108
      * @param owner Window to center on
96
      * @param owner Window to center on
109
      */
97
      */
110
-    public void display(final Window owner) {
98
+    public void display(final Component owner) {
111
         this.owner = owner;
99
         this.owner = owner;
112
         display();
100
         display();
113
     }
101
     }
133
         setVisible(true);
121
         setVisible(true);
134
     }
122
     }
135
 
123
 
136
-    /**
137
-     * Displays the dialog centering on the parent window, blocking until complete.
138
-     */
139
-    public void displayBlocking() {
140
-        displayBlocking(owner);
141
-    }
142
-
143
-    /**
144
-     * Displays the dialog centering on the specified window, blocking until complete.
145
-     *
146
-     * @param owner Window to center on
147
-     */
148
-    public void displayBlocking(final Component owner) {
149
-        if (SwingUtilities.isEventDispatchThread()) {
150
-            throw new IllegalStateException("Unable to display blocking dialog"
151
-                    + " in the EDT.");
152
-        }
153
-        final Semaphore semaphore = new Semaphore(0);
154
-        SwingUtilities.invokeLater(new Runnable() {
155
-
156
-            @Override
157
-            public void run() {
158
-                display();
159
-                addWindowListener(new WindowAdapter() {
160
-                    @Override
161
-                    public void windowClosed(final WindowEvent e) {
162
-                        semaphore.release();
163
-                    }
164
-                });
165
-            }
166
-        });
167
-        semaphore.acquireUninterruptibly();
168
-    }
169
-
170
     /**
124
     /**
171
      * Centres this dialog on its owner, or the screen if no owner is present.
125
      * Centres this dialog on its owner, or the screen if no owner is present.
172
      */
126
      */

+ 9
- 24
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/StandardInputDialog.java View File

29
 import com.dmdirc.util.validators.Validator;
29
 import com.dmdirc.util.validators.Validator;
30
 
30
 
31
 import java.awt.Window;
31
 import java.awt.Window;
32
-import java.awt.event.ActionEvent;
33
-import java.awt.event.ActionListener;
34
 import java.awt.event.WindowAdapter;
32
 import java.awt.event.WindowAdapter;
35
 import java.awt.event.WindowEvent;
33
 import java.awt.event.WindowEvent;
36
 import java.util.concurrent.atomic.AtomicBoolean;
34
 import java.util.concurrent.atomic.AtomicBoolean;
37
 
35
 
38
 import javax.swing.JButton;
36
 import javax.swing.JButton;
37
+import javax.swing.WindowConstants;
39
 import javax.swing.event.DocumentEvent;
38
 import javax.swing.event.DocumentEvent;
40
 import javax.swing.event.DocumentListener;
39
 import javax.swing.event.DocumentListener;
41
 import javax.swing.text.AbstractDocument;
40
 import javax.swing.text.AbstractDocument;
75
     public StandardInputDialog(
74
     public StandardInputDialog(
76
             final Window owner, final ModalityType modal, final IconManager iconManager,
75
             final Window owner, final ModalityType modal, final IconManager iconManager,
77
             final String title, final String message) {
76
             final String title, final String message) {
78
-        this(owner, modal, iconManager, title, message, new Validator<String>() {
79
-
80
-            @Override
81
-            public ValidationResponse validate(final String object) {
82
-                return new ValidationResponse();
83
-            }
84
-        });
77
+        this(owner, modal, iconManager, title, message, o -> new ValidationResponse());
85
     }
78
     }
86
 
79
 
87
     /**
80
     /**
105
         this.iconManager = iconManager;
98
         this.iconManager = iconManager;
106
 
99
 
107
         setTitle(title);
100
         setTitle(title);
108
-        setDefaultCloseOperation(StandardInputDialog.DISPOSE_ON_CLOSE);
101
+        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
109
 
102
 
110
         initComponents();
103
         initComponents();
111
         addListeners();
104
         addListeners();
138
      * Adds the listeners.
131
      * Adds the listeners.
139
      */
132
      */
140
     private void addListeners() {
133
     private void addListeners() {
141
-        getOkButton().addActionListener(new ActionListener() {
142
-
143
-            @Override
144
-            public void actionPerformed(final ActionEvent e) {
145
-                if (save()) {
146
-                    dispose();
147
-                }
148
-            }
149
-        });
150
-        getCancelButton().addActionListener(new ActionListener() {
151
-
152
-            @Override
153
-            public void actionPerformed(final ActionEvent e) {
154
-                cancelled();
134
+        getOkButton().addActionListener(e -> {
135
+            if (save()) {
155
                 dispose();
136
                 dispose();
156
             }
137
             }
157
         });
138
         });
139
+        getCancelButton().addActionListener(e -> {
140
+            cancelled();
141
+            dispose();
142
+        });
158
         addWindowListener(new WindowAdapter() {
143
         addWindowListener(new WindowAdapter() {
159
 
144
 
160
             @Override
145
             @Override

+ 0
- 137
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/StandardMessageDialog.java View File

1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
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;
24
-
25
-import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26
-
27
-import java.awt.Window;
28
-import java.awt.event.ActionEvent;
29
-import java.awt.event.ActionListener;
30
-import java.awt.event.WindowAdapter;
31
-import java.awt.event.WindowEvent;
32
-
33
-import javax.swing.JButton;
34
-
35
-import net.miginfocom.swing.MigLayout;
36
-
37
-/**
38
- * Abstract standard dialog for showing messages.
39
- */
40
-public class StandardMessageDialog extends StandardDialog {
41
-
42
-    /** Serial version UID. */
43
-    private static final long serialVersionUID = 1;
44
-    /** Message. */
45
-    private final String message;
46
-    /** Blurb label. */
47
-    private TextLabel blurb;
48
-
49
-    /**
50
-     * Instantiates a new standard input dialog.
51
-     *
52
-     * @param owner   Dialog owner
53
-     * @param modal   modality type
54
-     * @param title   Dialog title
55
-     * @param message Dialog message
56
-     */
57
-    public StandardMessageDialog(
58
-            final Window owner, final ModalityType modal, final String title,
59
-            final String message) {
60
-        super(owner, modal);
61
-
62
-        this.message = message;
63
-
64
-        setTitle(title);
65
-        setDefaultCloseOperation(StandardInputDialog.DISPOSE_ON_CLOSE);
66
-
67
-        initComponents();
68
-        addListeners();
69
-        layoutComponents();
70
-    }
71
-
72
-    /**
73
-     * Called when the dialog's OK button is clicked.
74
-     *
75
-     * @return whether the dialog can close
76
-     */
77
-    public boolean save() {
78
-        return true;
79
-    }
80
-
81
-    /**
82
-     * Called when the dialog's cancel button is clicked, or otherwise closed.
83
-     */
84
-    public void cancelled() {
85
-        //Do nothing
86
-    }
87
-
88
-    /**
89
-     * Initialises the components.
90
-     */
91
-    private void initComponents() {
92
-        orderButtons(new JButton(), new JButton());
93
-        getOkButton().setText("OK");
94
-        blurb = new TextLabel(message);
95
-    }
96
-
97
-    /**
98
-     * Adds the listeners.
99
-     */
100
-    private void addListeners() {
101
-        final ActionListener listener = new ActionListener() {
102
-
103
-            @Override
104
-            public void actionPerformed(final ActionEvent e) {
105
-                if (save()) {
106
-                    dispose();
107
-                }
108
-            }
109
-        };
110
-        getCancelButton().addActionListener(listener);
111
-        getOkButton().addActionListener(listener);
112
-        addWindowListener(new WindowAdapter() {
113
-
114
-            @Override
115
-            public void windowOpened(final WindowEvent e) {
116
-                //Ignore
117
-            }
118
-
119
-            @Override
120
-            public void windowClosed(final WindowEvent e) {
121
-                cancelled();
122
-            }
123
-        });
124
-    }
125
-
126
-    /**
127
-     * Lays out the components.
128
-     */
129
-    private void layoutComponents() {
130
-        setLayout(new MigLayout("fill, wrap 1, hidemode 3, wmax min(80sp, 500),"
131
-                + " wmin min(80sp, 500), pack"));
132
-
133
-        add(blurb, "growx");
134
-        add(getOkButton(), "right");
135
-    }
136
-
137
-}

+ 52
- 34
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/StandardQuestionDialog.java View File

25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26
 
26
 
27
 import java.awt.Window;
27
 import java.awt.Window;
28
-import java.awt.event.ActionEvent;
29
-import java.awt.event.ActionListener;
30
 import java.awt.event.WindowAdapter;
28
 import java.awt.event.WindowAdapter;
31
 import java.awt.event.WindowEvent;
29
 import java.awt.event.WindowEvent;
30
+import java.util.function.BooleanSupplier;
32
 
31
 
33
 import javax.swing.JButton;
32
 import javax.swing.JButton;
33
+import javax.swing.WindowConstants;
34
 
34
 
35
 import net.miginfocom.swing.MigLayout;
35
 import net.miginfocom.swing.MigLayout;
36
 
36
 
37
 /**
37
 /**
38
  * Standard input dialog.
38
  * Standard input dialog.
39
  */
39
  */
40
-public abstract class StandardQuestionDialog extends StandardDialog {
40
+public class StandardQuestionDialog extends StandardDialog {
41
 
41
 
42
     /** Serial version UID. */
42
     /** Serial version UID. */
43
     private static final long serialVersionUID = 1;
43
     private static final long serialVersionUID = 1;
46
     /** Blurb label. */
46
     /** Blurb label. */
47
     private TextLabel blurb;
47
     private TextLabel blurb;
48
     /** Question result. */
48
     /** Question result. */
49
-    private boolean result = false;
49
+    private boolean result;
50
+    /** Function to call when the dialog is saved. */
51
+    private final BooleanSupplier save;
52
+    /** Function to call when the dialog is cancelled. */
53
+    private final Runnable cancel;
50
 
54
 
51
     /**
55
     /**
52
      * Instantiates a new standard input dialog.
56
      * Instantiates a new standard input dialog.
58
      */
62
      */
59
     public StandardQuestionDialog(
63
     public StandardQuestionDialog(
60
             final Window owner, final ModalityType modal, final String title,
64
             final Window owner, final ModalityType modal, final String title,
61
-            final String message) {
65
+            final String message,
66
+            final BooleanSupplier save) {
67
+        this(owner, modal, title, message, save, () -> {});
68
+    }
69
+
70
+    /**
71
+     * Instantiates a new standard input dialog.
72
+     *
73
+     * @param owner   Dialog owner
74
+     * @param modal   modality type
75
+     * @param title   Dialog title
76
+     * @param message Dialog message
77
+     */
78
+    public StandardQuestionDialog(
79
+            final Window owner, final ModalityType modal, final String title,
80
+            final String message,
81
+            final Runnable save) {
82
+        this(owner, modal, title, message, () -> {save.run(); return true; }, () -> {});
83
+    }
84
+
85
+    /**
86
+     * Instantiates a new standard input dialog.
87
+     *
88
+     * @param owner   Dialog owner
89
+     * @param modal   modality type
90
+     * @param title   Dialog title
91
+     * @param message Dialog message
92
+     */
93
+    public StandardQuestionDialog(
94
+            final Window owner, final ModalityType modal, final String title,
95
+            final String message,
96
+            final BooleanSupplier save,
97
+            final Runnable cancel) {
62
         super(owner, modal);
98
         super(owner, modal);
63
 
99
 
64
         this.message = message;
100
         this.message = message;
101
+        this.save = save;
102
+        this.cancel = cancel;
65
 
103
 
66
         setTitle(title);
104
         setTitle(title);
67
-        setDefaultCloseOperation(StandardInputDialog.DISPOSE_ON_CLOSE);
105
+        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
68
 
106
 
69
         initComponents();
107
         initComponents();
70
         addListeners();
108
         addListeners();
71
         layoutComponents();
109
         layoutComponents();
72
     }
110
     }
73
 
111
 
74
-    /**
75
-     * Called when the dialog's OK button is clicked.
76
-     *
77
-     * @return whether the dialog can close
78
-     */
79
-    public abstract boolean save();
80
-
81
-    /**
82
-     * Called when the dialog's cancel button is clicked, or otherwise closed.
83
-     */
84
-    public abstract void cancelled();
85
-
86
     /**
112
     /**
87
      * Initialises the components.
113
      * Initialises the components.
88
      */
114
      */
97
      * Adds the listeners.
123
      * Adds the listeners.
98
      */
124
      */
99
     private void addListeners() {
125
     private void addListeners() {
100
-        getOkButton().addActionListener(new ActionListener() {
101
-
102
-            @Override
103
-            public void actionPerformed(final ActionEvent e) {
104
-                if (save()) {
105
-                    result = true;
106
-                    dispose();
107
-                }
108
-            }
109
-        });
110
-        getCancelButton().addActionListener(new ActionListener() {
111
-
112
-            @Override
113
-            public void actionPerformed(final ActionEvent e) {
114
-                cancelled();
126
+        getOkButton().addActionListener(e -> {
127
+            if (save.getAsBoolean()) {
128
+                result = true;
115
                 dispose();
129
                 dispose();
116
             }
130
             }
117
         });
131
         });
132
+        getCancelButton().addActionListener(e -> {
133
+            cancel.run();
134
+            dispose();
135
+        });
118
         addWindowListener(new WindowAdapter() {
136
         addWindowListener(new WindowAdapter() {
119
 
137
 
120
             @Override
138
             @Override
125
             @Override
143
             @Override
126
             public void windowClosed(final WindowEvent e) {
144
             public void windowClosed(final WindowEvent e) {
127
                 if (!result) {
145
                 if (!result) {
128
-                    cancelled();
146
+                    cancel.run();
129
                 }
147
                 }
130
             }
148
             }
131
         });
149
         });

+ 4
- 23
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsGroupPanel.java View File

130
      */
130
      */
131
     private void initComponents() {
131
     private void initComponents() {
132
         scrollPane = new JScrollPane();
132
         scrollPane = new JScrollPane();
133
-        model = new ActionTableModel(group == null ? new ArrayList<Action>() : group.getActions());
133
+        model = new ActionTableModel(group == null ? new ArrayList<>() : group.getActions());
134
         table = new PackingTable(model, scrollPane, false) {
134
         table = new PackingTable(model, scrollPane, false) {
135
             /** A version number for this class. */
135
             /** A version number for this class. */
136
             private static final long serialVersionUID = 1;
136
             private static final long serialVersionUID = 1;
137
             /** Action type renderer. */
137
             /** Action type renderer. */
138
-            private final ActionTypeTableCellRenderer typeRenderer
139
-                    = new ActionTypeTableCellRenderer();
138
+            private final TableCellRenderer typeRenderer = new ActionTypeTableCellRenderer();
140
             /** Action response renderer. */
139
             /** Action response renderer. */
141
-            private final ArrayCellRenderer arrayRenderer = new ArrayCellRenderer();
140
+            private final TableCellRenderer arrayRenderer = new ArrayCellRenderer();
142
 
141
 
143
             @Override
142
             @Override
144
             public TableCellRenderer getCellRenderer(final int row, final int column) {
143
             public TableCellRenderer getCellRenderer(final int row, final int column) {
235
             new StandardQuestionDialog(parent,
234
             new StandardQuestionDialog(parent,
236
                     ModalityType.APPLICATION_MODAL, "Confirm deletion",
235
                     ModalityType.APPLICATION_MODAL, "Confirm deletion",
237
                     "Are you sure you wish to delete the action '" + action.
236
                     "Are you sure you wish to delete the action '" + action.
238
-                    getName() + "'?") {
239
-                        /**
240
-                         * A version number for this class. It should be changed whenever the class
241
-                         * structure is changed (or anything else that would prevent serialized
242
-                         * objects being unserialized with the new class).
243
-                         */
244
-                        private static final long serialVersionUID = 1;
245
-
246
-                        @Override
247
-                        public boolean save() {
248
-                            group.deleteAction(action);
249
-                            return true;
250
-                        }
251
-
252
-                        @Override
253
-                        public void cancelled() {
254
-                            //Ignore
255
-                        }
256
-                    }.display();
237
+                    getName() + "'?", () -> group.deleteAction(action)).display();
257
         }
238
         }
258
     }
239
     }
259
 
240
 

+ 16
- 30
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialog.java View File

385
      */
385
      */
386
     private void delGroup() {
386
     private void delGroup() {
387
         final String group = groups.getSelectedValue().getName();
387
         final String group = groups.getSelectedValue().getName();
388
-        new StandardQuestionDialog(this,
389
-                ModalityType.APPLICATION_MODAL,
390
-                "Confirm deletion",
391
-                "Are you sure you wish to delete the '" + group
392
-                + "' group and all actions within it?") {
393
-                    /** Java Serialisation version ID. */
394
-                    private static final long serialVersionUID = 1;
395
-
396
-                    @Override
397
-                    public boolean save() {
398
-                        int location = ((DefaultListModel) groups.getModel()).indexOf(
399
-                                ActionManager.getActionManager().getOrCreateGroup(group));
400
-                        ActionManager.getActionManager().deleteGroup(group);
401
-                        reloadGroups();
402
-                        if (groups.getModel().getSize() == 0) {
403
-                            location = -1;
404
-                        } else if (location >= groups.getModel().getSize()) {
405
-                            location = groups.getModel().getSize();
406
-                        } else if (location <= 0) {
407
-                            location = 0;
408
-                        }
409
-                        groups.setSelectedIndex(location);
410
-                        return true;
411
-                    }
412
-
413
-                    @Override
414
-                    public void cancelled() {
415
-                        //Ignore
416
-                    }
417
-                }.display();
388
+        new StandardQuestionDialog(this, ModalityType.APPLICATION_MODAL, "Confirm deletion",
389
+                "Are you sure you wish to delete the '" + group +
390
+                        "' group and all actions within it?", () -> {
391
+            int location = ((DefaultListModel) groups.getModel())
392
+                    .indexOf(ActionManager.getActionManager().getOrCreateGroup(group));
393
+            ActionManager.getActionManager().deleteGroup(group);
394
+            reloadGroups();
395
+            if (groups.getModel().getSize() == 0) {
396
+                location = -1;
397
+            } else if (location >= groups.getModel().getSize()) {
398
+                location = groups.getModel().getSize();
399
+            } else if (location <= 0) {
400
+                location = 0;
401
+            }
402
+            groups.setSelectedIndex(location);
403
+        }).display();
418
     }
404
     }
419
 
405
 
420
     @Override
406
     @Override

+ 120
- 261
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerDialogLinker.java View File

30
 import com.dmdirc.ui.IconManager;
30
 import com.dmdirc.ui.IconManager;
31
 
31
 
32
 import java.awt.Dialog.ModalityType;
32
 import java.awt.Dialog.ModalityType;
33
-import java.awt.event.ActionEvent;
34
-import java.awt.event.ActionListener;
35
-import java.beans.PropertyChangeEvent;
36
-import java.beans.PropertyChangeListener;
37
 import java.beans.PropertyVetoException;
33
 import java.beans.PropertyVetoException;
38
-import java.beans.VetoableChangeListener;
39
 
34
 
40
 import javax.swing.DefaultListModel;
35
 import javax.swing.DefaultListModel;
41
 import javax.swing.JButton;
36
 import javax.swing.JButton;
44
 import javax.swing.ListSelectionModel;
39
 import javax.swing.ListSelectionModel;
45
 import javax.swing.event.DocumentEvent;
40
 import javax.swing.event.DocumentEvent;
46
 import javax.swing.event.DocumentListener;
41
 import javax.swing.event.DocumentListener;
47
-import javax.swing.event.ListSelectionEvent;
48
-import javax.swing.event.ListSelectionListener;
49
 
42
 
50
 /**
43
 /**
51
  * Links the UI code with the model and controller.
44
  * Links the UI code with the model and controller.
78
      * @param list List to bind
71
      * @param list List to bind
79
      */
72
      */
80
     public void bindProfileList(final JList<Profile> list) {
73
     public void bindProfileList(final JList<Profile> list) {
81
-        list.setModel(new DefaultListModel<Profile>());
74
+        list.setModel(new DefaultListModel<>());
82
         final VetoableListSelectionModel listModel = new VetoableListSelectionModel();
75
         final VetoableListSelectionModel listModel = new VetoableListSelectionModel();
83
         list.setSelectionModel(listModel);
76
         list.setSelectionModel(listModel);
84
-        listModel.addVetoableSelectionListener(new VetoableChangeListener() {
85
-
86
-            @Override
87
-            public void vetoableChange(final PropertyChangeEvent evt) throws PropertyVetoException {
88
-                if (!model.isChangeProfileAllowed()) {
89
-                    throw new PropertyVetoException("", evt);
90
-                }
77
+        listModel.addVetoableSelectionListener(evt -> {
78
+            if (!model.isChangeProfileAllowed()) {
79
+                throw new PropertyVetoException("", evt);
91
             }
80
             }
92
         });
81
         });
93
-        listModel.addListSelectionListener(new ListSelectionListener() {
94
-            @Override
95
-            public void valueChanged(final ListSelectionEvent e) {
96
-                model.setSelectedProfile(list.getSelectedValue());
82
+        listModel.addListSelectionListener(e -> model.setSelectedProfile(list.getSelectedValue()));
83
+        model.addPropertyChangeListener("profiles", evt -> {
84
+            ((DefaultListModel) list.getModel()).clear();
85
+            for (Profile profile : model.getProfiles()) {
86
+                ((DefaultListModel<Profile>) list.getModel()).addElement(profile);
97
             }
87
             }
98
-        });
99
-        model.addPropertyChangeListener("profiles", new PropertyChangeListener() {
100
-            @Override
101
-            public void propertyChange(final PropertyChangeEvent evt) {
102
-                ((DefaultListModel) list.getModel()).clear();
103
-                for (Profile profile : model.getProfiles()) {
104
-                    ((DefaultListModel<Profile>) list.getModel()).addElement(profile);
105
-                }
106
-                if (list.getSelectedValue() != model.getSelectedProfile()) {
107
-                    list.setSelectedValue(model.getSelectedProfile(), true);
108
-                }
109
-            }
110
-        });
111
-        model.addPropertyChangeListener("name", new PropertyChangeListener() {
112
-            @Override
113
-            public void propertyChange(final PropertyChangeEvent evt) {
114
-                list.repaint();
88
+            if (list.getSelectedValue() != model.getSelectedProfile()) {
89
+                list.setSelectedValue(model.getSelectedProfile(), true);
115
             }
90
             }
116
         });
91
         });
92
+        model.addPropertyChangeListener("name", evt -> list.repaint());
117
         for (Profile profile : model.getProfiles()) {
93
         for (Profile profile : model.getProfiles()) {
118
             ((DefaultListModel<Profile>) list.getModel()).addElement(profile);
94
             ((DefaultListModel<Profile>) list.getModel()).addElement(profile);
119
         }
95
         }
125
      * @param nicknames list to bind
101
      * @param nicknames list to bind
126
      */
102
      */
127
     public void bindProfileNicknames(final ReorderableJList<String> nicknames) {
103
     public void bindProfileNicknames(final ReorderableJList<String> nicknames) {
128
-        nicknames.setModel(new DefaultListModel<String>());
104
+        nicknames.setModel(new DefaultListModel<>());
129
         nicknames.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
105
         nicknames.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
130
-        nicknames.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
131
-            @Override
132
-            public void valueChanged(final ListSelectionEvent e) {
133
-                model.setSelectedNickname(nicknames.getSelectedValue());
134
-            }
135
-        });
136
-        model.addPropertyChangeListener("selectedprofile", new PropertyChangeListener() {
137
-            @Override
138
-            public void propertyChange(final PropertyChangeEvent evt) {
139
-                nicknames.getModel().clear();
140
-                for (String nickname : model.getNicknames()) {
141
-                    nicknames.getModel().addElement(nickname);
142
-                }
143
-                nicknames.setSelectedValue(model.getSelectedNickname(), true);
144
-                nicknames.setEnabled(model.isManipulateProfileAllowed());
145
-            }
106
+        nicknames.getSelectionModel().addListSelectionListener(
107
+                e -> model.setSelectedNickname(nicknames.getSelectedValue()));
108
+        model.addPropertyChangeListener("selectedprofile", evt -> {
109
+            nicknames.getModel().clear();
110
+            for (String nickname : model.getNicknames()) {
111
+                nicknames.getModel().addElement(nickname);
112
+            }
113
+            nicknames.setSelectedValue(model.getSelectedNickname(), true);
114
+            nicknames.setEnabled(model.isManipulateProfileAllowed());
146
         });
115
         });
147
-        model.addPropertyChangeListener("profiles", new PropertyChangeListener() {
148
-            @Override
149
-            public void propertyChange(final PropertyChangeEvent evt) {
150
-                nicknames.setEnabled(model.isManipulateProfileAllowed());
151
-            }
152
-        });
153
-        model.addPropertyChangeListener("nicknames", new PropertyChangeListener() {
154
-            @Override
155
-            public void propertyChange(final PropertyChangeEvent evt) {
156
-                nicknames.getModel().clear();
157
-                for (String nickname : model.getNicknames()) {
158
-                    nicknames.getModel().addElement(nickname);
159
-                }
160
-                nicknames.setSelectedValue(model.getSelectedNickname(), true);
161
-                nicknames.setEnabled(model.isManipulateProfileAllowed());
162
-            }
116
+        model.addPropertyChangeListener("profiles",
117
+                evt -> nicknames.setEnabled(model.isManipulateProfileAllowed()));
118
+        model.addPropertyChangeListener("nicknames", evt -> {
119
+            nicknames.getModel().clear();
120
+            for (String nickname : model.getNicknames()) {
121
+                nicknames.getModel().addElement(nickname);
122
+            }
123
+            nicknames.setSelectedValue(model.getSelectedNickname(), true);
124
+            nicknames.setEnabled(model.isManipulateProfileAllowed());
163
         });
125
         });
164
         nicknames.setEnabled(model.isManipulateProfileAllowed());
126
         nicknames.setEnabled(model.isManipulateProfileAllowed());
165
     }
127
     }
170
      * @param addNickname Button to bind
132
      * @param addNickname Button to bind
171
      */
133
      */
172
     public void bindAddNickname(final JButton addNickname) {
134
     public void bindAddNickname(final JButton addNickname) {
173
-        addNickname.addActionListener(new ActionListener() {
174
-            @Override
175
-            public void actionPerformed(final ActionEvent e) {
176
-                new StandardInputDialog(dialog, ModalityType.DOCUMENT_MODAL, iconManager,
177
-                        "Add nickname", "Enter nickname to add:", new AddNicknameValidator(model)) {
178
-                            private static final long serialVersionUID = 1L;
179
-
180
-                            @Override
181
-                            public boolean save() {
182
-                                controller.addNickname(getText());
183
-                                return true;
184
-                            }
185
-
186
-                            @Override
187
-                            public void cancelled() {
188
-                            }
189
-                        }.display();
190
-            }
191
-        });
192
-        model.addPropertyChangeListener("selectedprofile", new PropertyChangeListener() {
193
-            @Override
194
-            public void propertyChange(final PropertyChangeEvent evt) {
195
-                addNickname.setEnabled(model.isManipulateProfileAllowed());
196
-            }
197
-        });
198
-        model.addPropertyChangeListener("profiles", new PropertyChangeListener() {
199
-            @Override
200
-            public void propertyChange(final PropertyChangeEvent evt) {
201
-                addNickname.setEnabled(model.isManipulateProfileAllowed());
202
-            }
203
-        });
135
+        addNickname.addActionListener(e -> new StandardInputDialog(dialog, ModalityType.DOCUMENT_MODAL, iconManager,
136
+                "Add nickname", "Enter nickname to add:", new AddNicknameValidator(model)) {
137
+                    private static final long serialVersionUID = 1L;
138
+
139
+                    @Override
140
+                    public boolean save() {
141
+                        controller.addNickname(getText());
142
+                        return true;
143
+                    }
144
+
145
+                    @Override
146
+                    public void cancelled() {
147
+                    }
148
+                }.display());
149
+        model.addPropertyChangeListener("selectedprofile",
150
+                evt -> addNickname.setEnabled(model.isManipulateProfileAllowed()));
151
+        model.addPropertyChangeListener("profiles",
152
+                evt -> addNickname.setEnabled(model.isManipulateProfileAllowed()));
204
         addNickname.setEnabled(model.isManipulateProfileAllowed());
153
         addNickname.setEnabled(model.isManipulateProfileAllowed());
205
     }
154
     }
206
 
155
 
210
      * @param editNickname Button to bind
159
      * @param editNickname Button to bind
211
      */
160
      */
212
     public void bindEditNickname(final JButton editNickname) {
161
     public void bindEditNickname(final JButton editNickname) {
213
-        editNickname.addActionListener(new ActionListener() {
214
-            @Override
215
-            public void actionPerformed(final ActionEvent e) {
216
-                final StandardInputDialog inputDialog = new StandardInputDialog(dialog,
217
-                        ModalityType.DOCUMENT_MODAL, iconManager,
218
-                        "Add nickname", "Enter edited nickname:",
219
-                        new EditNicknameValidator(model)) {
220
-                            private static final long serialVersionUID = 1L;
221
-
222
-                            @Override
223
-                            public boolean save() {
224
-                                controller.editNickname(getText());
225
-                                return true;
226
-                            }
227
-
228
-                            @Override
229
-                            public void cancelled() {
230
-                            }
231
-                        };
232
-                inputDialog.setText((String) model.getSelectedNickname());
233
-                inputDialog.display();
234
-            }
235
-        });
236
-        model.addPropertyChangeListener("selectednickname", new PropertyChangeListener() {
237
-            @Override
238
-            public void propertyChange(final PropertyChangeEvent evt) {
239
-                editNickname.setEnabled(model.isManipulateNicknameAllowed());
240
-            }
241
-        });
242
-        model.addPropertyChangeListener("nicknames", new PropertyChangeListener() {
243
-            @Override
244
-            public void propertyChange(final PropertyChangeEvent evt) {
245
-                editNickname.setEnabled(model.isManipulateNicknameAllowed());
246
-            }
162
+        editNickname.addActionListener(e -> {
163
+            final StandardInputDialog inputDialog = new StandardInputDialog(dialog,
164
+                    ModalityType.DOCUMENT_MODAL, iconManager,
165
+                    "Add nickname", "Enter edited nickname:",
166
+                    new EditNicknameValidator(model)) {
167
+                        private static final long serialVersionUID = 1L;
168
+
169
+                        @Override
170
+                        public boolean save() {
171
+                            controller.editNickname(getText());
172
+                            return true;
173
+                        }
174
+
175
+                        @Override
176
+                        public void cancelled() {
177
+                        }
178
+                    };
179
+            inputDialog.setText((String) model.getSelectedNickname());
180
+            inputDialog.display();
247
         });
181
         });
182
+        model.addPropertyChangeListener("selectednickname",
183
+                evt -> editNickname.setEnabled(model.isManipulateNicknameAllowed()));
184
+        model.addPropertyChangeListener("nicknames",
185
+                evt -> editNickname.setEnabled(model.isManipulateNicknameAllowed()));
248
         editNickname.setEnabled(model.isManipulateNicknameAllowed());
186
         editNickname.setEnabled(model.isManipulateNicknameAllowed());
249
     }
187
     }
250
 
188
 
254
      * @param deleteNickname Button to bind
192
      * @param deleteNickname Button to bind
255
      */
193
      */
256
     public void bindDeleteNickname(final JButton deleteNickname) {
194
     public void bindDeleteNickname(final JButton deleteNickname) {
257
-        deleteNickname.addActionListener(new ActionListener() {
258
-            @Override
259
-            public void actionPerformed(final ActionEvent e) {
260
-                new StandardQuestionDialog(dialog, ModalityType.DOCUMENT_MODAL,
261
-                        "Delete nickname?", "Are you sure you want to delete this nickname?") {
262
-                            private static final long serialVersionUID = 1L;
263
-
264
-                            @Override
265
-                            public boolean save() {
266
-                                controller.deleteNickname();
267
-                                return true;
268
-                            }
269
-
270
-                            @Override
271
-                            public void cancelled() {
272
-                            }
273
-                        }.display();
274
-            }
275
-        });
276
-        model.addPropertyChangeListener("selectednickname", new PropertyChangeListener() {
277
-            @Override
278
-            public void propertyChange(final PropertyChangeEvent evt) {
279
-                deleteNickname.setEnabled(model.isManipulateNicknameAllowed());
280
-            }
281
-        });
282
-        model.addPropertyChangeListener("nicknames", new PropertyChangeListener() {
283
-            @Override
284
-            public void propertyChange(final PropertyChangeEvent evt) {
285
-                deleteNickname.setEnabled(model.isManipulateNicknameAllowed());
286
-            }
287
-        });
195
+        deleteNickname.addActionListener(e -> new StandardQuestionDialog(dialog, ModalityType.DOCUMENT_MODAL,
196
+                "Delete nickname?", "Are you sure you want to delete this nickname?",
197
+                controller::deleteNickname).display());
198
+        model.addPropertyChangeListener("selectednickname",
199
+                evt -> deleteNickname.setEnabled(model.isManipulateNicknameAllowed()));
200
+        model.addPropertyChangeListener("nicknames",
201
+                evt -> deleteNickname.setEnabled(model.isManipulateNicknameAllowed()));
288
         deleteNickname.setEnabled(model.isManipulateNicknameAllowed());
202
         deleteNickname.setEnabled(model.isManipulateNicknameAllowed());
289
     }
203
     }
290
 
204
 
315
                 profileName.setEnabled(model.isManipulateProfileAllowed());
229
                 profileName.setEnabled(model.isManipulateProfileAllowed());
316
             }
230
             }
317
         });
231
         });
318
-        model.addPropertyChangeListener("selectedprofile", new PropertyChangeListener() {
319
-            @Override
320
-            public void propertyChange(final PropertyChangeEvent evt) {
321
-                profileName.setText(model.getName());
322
-                profileName.setEnabled(model.isManipulateProfileAllowed());
323
-            }
232
+        model.addPropertyChangeListener("selectedprofile", evt -> {
233
+            profileName.setText(model.getName());
234
+            profileName.setEnabled(model.isManipulateProfileAllowed());
324
         });
235
         });
325
-        model.addPropertyChangeListener("profiles", new PropertyChangeListener() {
326
-            @Override
327
-            public void propertyChange(final PropertyChangeEvent evt) {
328
-                profileName.setText(model.getName());
329
-                profileName.setEnabled(model.isManipulateProfileAllowed());
330
-            }
236
+        model.addPropertyChangeListener("profiles", evt -> {
237
+            profileName.setText(model.getName());
238
+            profileName.setEnabled(model.isManipulateProfileAllowed());
331
         });
239
         });
332
         profileName.setEnabled(model.isManipulateProfileAllowed());
240
         profileName.setEnabled(model.isManipulateProfileAllowed());
333
     }
241
     }
357
                 profileRealname.setEnabled(model.isManipulateProfileAllowed());
265
                 profileRealname.setEnabled(model.isManipulateProfileAllowed());
358
             }
266
             }
359
         });
267
         });
360
-        model.addPropertyChangeListener("selectedprofile", new PropertyChangeListener() {
361
-            @Override
362
-            public void propertyChange(final PropertyChangeEvent evt) {
363
-                profileRealname.setText(model.getRealname());
364
-                profileRealname.setEnabled(model.isManipulateProfileAllowed());
365
-            }
268
+        model.addPropertyChangeListener("selectedprofile", evt -> {
269
+            profileRealname.setText(model.getRealname());
270
+            profileRealname.setEnabled(model.isManipulateProfileAllowed());
366
         });
271
         });
367
         profileRealname.setEnabled(model.isManipulateProfileAllowed());
272
         profileRealname.setEnabled(model.isManipulateProfileAllowed());
368
     }
273
     }
392
                 profileIdent.setEnabled(model.isManipulateProfileAllowed());
297
                 profileIdent.setEnabled(model.isManipulateProfileAllowed());
393
             }
298
             }
394
         });
299
         });
395
-        model.addPropertyChangeListener("selectedprofile", new PropertyChangeListener() {
396
-            @Override
397
-            public void propertyChange(final PropertyChangeEvent evt) {
398
-                profileIdent.setEnabled(model.isManipulateProfileAllowed());
399
-            }
400
-        });
401
-        model.addPropertyChangeListener("profiles", new PropertyChangeListener() {
402
-            @Override
403
-            public void propertyChange(final PropertyChangeEvent evt) {
404
-                profileIdent.setEnabled(model.isManipulateProfileAllowed());
405
-            }
406
-        });
300
+        model.addPropertyChangeListener("selectedprofile",
301
+                evt -> profileIdent.setEnabled(model.isManipulateProfileAllowed()));
302
+        model.addPropertyChangeListener("profiles",
303
+                evt -> profileIdent.setEnabled(model.isManipulateProfileAllowed()));
407
         profileIdent.setEnabled(model.isManipulateProfileAllowed());
304
         profileIdent.setEnabled(model.isManipulateProfileAllowed());
408
     }
305
     }
409
 
306
 
413
      * @param addProfile Button to bind
310
      * @param addProfile Button to bind
414
      */
311
      */
415
     public void bindAddProfile(final JButton addProfile) {
312
     public void bindAddProfile(final JButton addProfile) {
416
-        addProfile.addActionListener(new ActionListener() {
417
-            @Override
418
-            public void actionPerformed(final ActionEvent e) {
419
-                final StandardInputDialog inputDialog = new StandardInputDialog(dialog,
420
-                        ModalityType.DOCUMENT_MODAL, iconManager,
421
-                        "Add profile", "New profile name:",
422
-                        new ProfileNameValidator(model.getProfiles())) {
423
-                            private static final long serialVersionUID = 1L;
424
-
425
-                            @Override
426
-                            public boolean save() {
427
-                                controller.addProfile(getText());
428
-                                return true;
429
-                            }
430
-
431
-                            @Override
432
-                            public void cancelled() {
433
-                            }
434
-                        };
435
-                inputDialog.setDocumentFilter(new ProfileNameDocumentFilter());
436
-                inputDialog.setText((String) model.getSelectedNickname());
437
-                inputDialog.display();
438
-            }
313
+        addProfile.addActionListener(e -> {
314
+            final StandardInputDialog inputDialog = new StandardInputDialog(dialog,
315
+                    ModalityType.DOCUMENT_MODAL, iconManager,
316
+                    "Add profile", "New profile name:",
317
+                    new ProfileNameValidator(model.getProfiles())) {
318
+                        private static final long serialVersionUID = 1L;
319
+
320
+                        @Override
321
+                        public boolean save() {
322
+                            controller.addProfile(getText());
323
+                            return true;
324
+                        }
325
+
326
+                        @Override
327
+                        public void cancelled() {
328
+                        }
329
+                    };
330
+            inputDialog.setDocumentFilter(new ProfileNameDocumentFilter());
331
+            inputDialog.setText((String) model.getSelectedNickname());
332
+            inputDialog.display();
439
         });
333
         });
440
     }
334
     }
441
 
335
 
445
      * @param deleteProfile Button to bind
339
      * @param deleteProfile Button to bind
446
      */
340
      */
447
     public void bindDeleteProfile(final JButton deleteProfile) {
341
     public void bindDeleteProfile(final JButton deleteProfile) {
448
-        deleteProfile.addActionListener(new ActionListener() {
449
-            @Override
450
-            public void actionPerformed(final ActionEvent e) {
451
-                new StandardQuestionDialog(dialog, ModalityType.DOCUMENT_MODAL,
452
-                        "Delete profile?", "Are you sure you want to delete this profile?") {
453
-                            private static final long serialVersionUID = 1L;
454
-
455
-                            @Override
456
-                            public boolean save() {
457
-                                controller.deleteProfile();
458
-                                return true;
459
-                            }
460
-
461
-                            @Override
462
-                            public void cancelled() {
463
-                            }
464
-                        }.display();
465
-            }
466
-        });
467
-        model.addPropertyChangeListener("profiles", new PropertyChangeListener() {
468
-            @Override
469
-            public void propertyChange(final PropertyChangeEvent evt) {
470
-                deleteProfile.setEnabled(model.isManipulateProfileAllowed());
471
-            }
472
-        });
342
+        deleteProfile.addActionListener(e -> new StandardQuestionDialog(dialog, ModalityType.DOCUMENT_MODAL,
343
+                "Delete profile?", "Are you sure you want to delete this profile?",
344
+                controller::deleteProfile).display());
345
+        model.addPropertyChangeListener("profiles",
346
+                evt -> deleteProfile.setEnabled(model.isManipulateProfileAllowed()));
473
         deleteProfile.setEnabled(model.isManipulateProfileAllowed());
347
         deleteProfile.setEnabled(model.isManipulateProfileAllowed());
474
     }
348
     }
475
 
349
 
479
      * @param okButton Button to bind
353
      * @param okButton Button to bind
480
      */
354
      */
481
     public void bindOKButton(final JButton okButton) {
355
     public void bindOKButton(final JButton okButton) {
482
-        okButton.addActionListener(new ActionListener() {
483
-            @Override
484
-            public void actionPerformed(final ActionEvent e) {
485
-                controller.saveAndCloseDialog();
486
-            }
487
-        });
488
-        model.addPropertyChangeListener(new PropertyChangeListener() {
489
-            @Override
490
-            public void propertyChange(final PropertyChangeEvent evt) {
491
-                okButton.setEnabled(model.isOKAllowed());
492
-            }
493
-        });
356
+        okButton.addActionListener(e -> controller.saveAndCloseDialog());
357
+        model.addPropertyChangeListener(evt -> okButton.setEnabled(model.isOKAllowed()));
494
         okButton.setEnabled(model.isOKAllowed());
358
         okButton.setEnabled(model.isOKAllowed());
495
     }
359
     }
496
 
360
 
500
      * @param cancelButton Button to bind
364
      * @param cancelButton Button to bind
501
      */
365
      */
502
     public void bindCancelButton(final JButton cancelButton) {
366
     public void bindCancelButton(final JButton cancelButton) {
503
-        cancelButton.addActionListener(new ActionListener() {
504
-            @Override
505
-            public void actionPerformed(final ActionEvent e) {
506
-                controller.closeDialog();
507
-            }
508
-        });
367
+        cancelButton.addActionListener(e -> controller.closeDialog());
509
     }
368
     }
510
 
369
 
511
 }
370
 }

+ 6
- 18
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/serversetting/IgnoreListPanel.java View File

92
         this.connection = connection;
92
         this.connection = connection;
93
         this.parentWindow = parentWindow;
93
         this.parentWindow = parentWindow;
94
 
94
 
95
-        this.setOpaque(UIUtilities.getTabbedPaneOpaque());
95
+        setOpaque(UIUtilities.getTabbedPaneOpaque());
96
         initComponents();
96
         initComponents();
97
         addListeners();
97
         addListeners();
98
         populateList();
98
         populateList();
204
             new StandardQuestionDialog(parentWindow,
204
             new StandardQuestionDialog(parentWindow,
205
                     ModalityType.APPLICATION_MODAL,
205
                     ModalityType.APPLICATION_MODAL,
206
                     "Confirm deletion",
206
                     "Confirm deletion",
207
-                    "Are you sure you want to delete this item?") {
208
-                        /** A version number for this class. */
209
-                        private static final long serialVersionUID = 1;
210
-
211
-                        @Override
212
-                        public boolean save() {
213
-                            cachedIgnoreList.remove(list.getSelectedIndex());
214
-
215
-                            updateList();
216
-                            return true;
217
-                        }
218
-
219
-                        @Override
220
-                        public void cancelled() {
221
-                            //Ignore
222
-                        }
223
-                    }.display();
207
+                    "Are you sure you want to delete this item?",
208
+                    () -> {
209
+                        cachedIgnoreList.remove(list.getSelectedIndex());
210
+                        updateList();
211
+                    }).display();
224
         } else if (e.getSource() == viewToggle) {
212
         } else if (e.getSource() == viewToggle) {
225
             listModel.setIsSimple(!viewToggle.isSelected());
213
             listModel.setIsSimple(!viewToggle.isSelected());
226
         }
214
         }

+ 5
- 18
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/serversetting/ServerSettingsDialog.java View File

43
 import javax.swing.JButton;
43
 import javax.swing.JButton;
44
 import javax.swing.JScrollPane;
44
 import javax.swing.JScrollPane;
45
 import javax.swing.JTabbedPane;
45
 import javax.swing.JTabbedPane;
46
+import javax.swing.ScrollPaneConstants;
46
 
47
 
47
 import net.miginfocom.swing.MigLayout;
48
 import net.miginfocom.swing.MigLayout;
48
 
49
 
127
                 "These settings are specific to this network, any settings specified here will "
128
                 "These settings are specific to this network, any settings specified here will "
128
                 + "overwrite global settings");
129
                 + "overwrite global settings");
129
 
130
 
130
-        if (settingsPanel != null) {
131
-            addSettings();
132
-        }
131
+        addSettings();
133
 
132
 
134
         final JScrollPane userModesSP = new JScrollPane(modesPanel);
133
         final JScrollPane userModesSP = new JScrollPane(modesPanel);
135
-        userModesSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
134
+        userModesSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
136
         userModesSP.setOpaque(UIUtilities.getTabbedPaneOpaque());
135
         userModesSP.setOpaque(UIUtilities.getTabbedPaneOpaque());
137
         userModesSP.getViewport().setOpaque(UIUtilities.getTabbedPaneOpaque());
136
         userModesSP.getViewport().setOpaque(UIUtilities.getTabbedPaneOpaque());
138
         userModesSP.setBorder(null);
137
         userModesSP.setBorder(null);
174
         } else {
173
         } else {
175
             new StandardQuestionDialog(getOwner(), ModalityType.MODELESS,
174
             new StandardQuestionDialog(getOwner(), ModalityType.MODELESS,
176
                     "Server has been disconnected.", "Any changes you have " +
175
                     "Server has been disconnected.", "Any changes you have " +
177
-                    "made will be lost, are you sure you want to close this " + "dialog?") {
178
-                private static final long serialVersionUID = 1;
179
-
180
-                @Override
181
-                public boolean save() {
182
-                    ServerSettingsDialog.this.dispose();
183
-                    return true;
184
-                }
185
-
186
-                @Override
187
-                public void cancelled() {
188
-                    //Ignore
189
-                }
190
-            }.display();
176
+                    "made will be lost, are you sure you want to close this " + "dialog?",
177
+                    () -> { dispose(); }).display();
191
         }
178
         }
192
     }
179
     }
193
 
180
 

Loading…
Cancel
Save