Quellcode durchsuchen

Merge pull request #379 from greboid/dev4

Quit the client off the EDT.
pull/380/head
Chris Smith vor 9 Jahren
Ursprung
Commit
464302021e

+ 1
- 0
channelwho/src/com/dmdirc/addons/channelwho/ChannelWhoManager.java Datei anzeigen

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

+ 6
- 4
channelwho/src/com/dmdirc/addons/channelwho/ConnectionHandler.java Datei anzeigen

@@ -87,11 +87,13 @@ public class ConnectionHandler {
87 87
 
88 88
     @VisibleForTesting
89 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 94
                         channel.requestUsersInfo();
94
-                    }}));
95
+                    }
96
+                }));
95 97
     }
96 98
 
97 99
     @VisibleForTesting

+ 5
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/UIUtilities.java Datei anzeigen

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_swing;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.addons.ui_swing.components.DMDircUndoableEditListener;
27
+import com.dmdirc.addons.ui_swing.components.RunnableSwingWorker;
27 28
 import com.dmdirc.util.colours.Colour;
28 29
 
29 30
 import java.awt.Color;
@@ -245,6 +246,10 @@ public final class UIUtilities {
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 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 Datei anzeigen

@@ -0,0 +1,49 @@
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 Datei anzeigen

@@ -0,0 +1,43 @@
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 Datei anzeigen

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

Laden…
Abbrechen
Speichern