Browse Source

Merge pull request #379 from greboid/dev4

Quit the client off the EDT.
pull/380/head
Chris Smith 9 years ago
parent
commit
464302021e

+ 1
- 0
channelwho/src/com/dmdirc/addons/channelwho/ChannelWhoManager.java View File

106
                 new NumericalValidator(0, Integer.MAX_VALUE), domain, "whointerval",
106
                 new NumericalValidator(0, Integer.MAX_VALUE), domain, "whointerval",
107
                 "Who Interval", "The interval WHO requests will be sent to channels",
107
                 "Who Interval", "The interval WHO requests will be sent to channels",
108
                 event.getModel().getConfigManager(), event.getModel().getIdentity()));
108
                 event.getModel().getConfigManager(), event.getModel().getIdentity()));
109
+        event.getModel().getCategory("Plugins").addSubCategory(category);
109
     }
110
     }
110
 
111
 
111
     @VisibleForTesting
112
     @VisibleForTesting

+ 6
- 4
channelwho/src/com/dmdirc/addons/channelwho/ConnectionHandler.java View File

87
 
87
 
88
     @VisibleForTesting
88
     @VisibleForTesting
89
     void checkWho() {
89
     void checkWho() {
90
-        connectionManager.getConnections().forEach(connection ->
91
-                connection.getGroupChatManager().getChannels().forEach(channel -> {
92
-                    if (channel.getWindowModel().getConfigManager().getOptionBool(domain, "sendwho")) {
90
+        connectionManager.getConnections().forEach(
91
+                connection -> connection.getGroupChatManager().getChannels().forEach(channel -> {
92
+                    if (channel.getWindowModel().getConfigManager()
93
+                            .getOptionBool(domain, "sendwho")) {
93
                         channel.requestUsersInfo();
94
                         channel.requestUsersInfo();
94
-                    }}));
95
+                    }
96
+                }));
95
     }
97
     }
96
 
98
 
97
     @VisibleForTesting
99
     @VisibleForTesting

+ 5
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/UIUtilities.java View File

24
 
24
 
25
 import com.dmdirc.DMDircMBassador;
25
 import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.components.DMDircUndoableEditListener;
26
 import com.dmdirc.addons.ui_swing.components.DMDircUndoableEditListener;
27
+import com.dmdirc.addons.ui_swing.components.RunnableSwingWorker;
27
 import com.dmdirc.util.colours.Colour;
28
 import com.dmdirc.util.colours.Colour;
28
 
29
 
29
 import java.awt.Color;
30
 import java.awt.Color;
245
         }
246
         }
246
     }
247
     }
247
 
248
 
249
+    public static void invokeOffEDT(final Runnable runnable) {
250
+        new RunnableSwingWorker<Void,Void>(runnable).execute();
251
+    }
252
+
248
     /**
253
     /**
249
      * Check if we are using the GTK look and feel.
254
      * Check if we are using the GTK look and feel.
250
      *
255
      *

+ 49
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/components/RunnableLoggingSwingWorker.java View File

1
+/*
2
+ * Copyright (c) 2006-2015 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.components;
24
+
25
+import com.dmdirc.DMDircMBassador;
26
+
27
+/**
28
+ * {@link LoggingSwingWorker} that runs a {@link Runnable}.
29
+ */
30
+public class RunnableLoggingSwingWorker<T, V> extends LoggingSwingWorker<T, V> {
31
+
32
+    private final Runnable runnable;
33
+
34
+    /**
35
+     * Creates a new logging swing worker.
36
+     *
37
+     * @param eventBus Event bus to post errors to.
38
+     */
39
+    public RunnableLoggingSwingWorker(final DMDircMBassador eventBus, final Runnable runnable) {
40
+        super(eventBus);
41
+        this.runnable = runnable;
42
+    }
43
+
44
+    @Override
45
+    protected T doInBackground() throws Exception {
46
+        runnable.run();
47
+        return null;
48
+    }
49
+}

+ 43
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/components/RunnableSwingWorker.java View File

1
+/*
2
+ * Copyright (c) 2006-2015 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.components;
24
+
25
+import javax.swing.SwingWorker;
26
+
27
+/**
28
+ * {@link SwingWorker} that takes a {@link Runnable}.
29
+ */
30
+public class RunnableSwingWorker<T, V> extends SwingWorker<T, V> {
31
+
32
+    private final Runnable runnable;
33
+
34
+    public RunnableSwingWorker(final Runnable runnable) {
35
+        this.runnable = runnable;
36
+    }
37
+
38
+    @Override
39
+    protected T doInBackground() throws Exception {
40
+        runnable.run();
41
+        return null;
42
+    }
43
+}

+ 2
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/ServerMenu.java View File

24
 
24
 
25
 import com.dmdirc.ServerState;
25
 import com.dmdirc.ServerState;
26
 import com.dmdirc.addons.ui_swing.Apple;
26
 import com.dmdirc.addons.ui_swing.Apple;
27
+import com.dmdirc.addons.ui_swing.UIUtilities;
27
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28
 import com.dmdirc.addons.ui_swing.dialogs.newserver.NewServerDialog;
29
 import com.dmdirc.addons.ui_swing.dialogs.newserver.NewServerDialog;
29
 import com.dmdirc.addons.ui_swing.dialogs.serversetting.ServerSettingsDialog;
30
 import com.dmdirc.addons.ui_swing.dialogs.serversetting.ServerSettingsDialog;
120
             final JMenuItem exit = new JMenuItem();
121
             final JMenuItem exit = new JMenuItem();
121
             exit.setText("Exit");
122
             exit.setText("Exit");
122
             exit.setMnemonic('x');
123
             exit.setMnemonic('x');
123
-            exit.addActionListener(e -> lifecycleController.quit());
124
+            exit.addActionListener(e -> UIUtilities.invokeOffEDT(lifecycleController::quit));
124
             add(exit);
125
             add(exit);
125
         }
126
         }
126
     }
127
     }

Loading…
Cancel
Save