Browse Source

Remove another singleton.

Change-Id: I83d319c563b2862caf7278a1d60669cfff5242ce
Reviewed-on: http://gerrit.dmdirc.com/3501
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/01/3501/3
Greg Holmes 10 years ago
parent
commit
14fe3cb594

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

@@ -519,7 +519,7 @@ public class MainFrame extends JFrame implements WindowListener,
519 519
         this.exitCode = exitCode;
520 520
         quitting = true;
521 521
 
522
-        quitWorker.get().executeInExecutor();
522
+        quitWorker.get().execute();
523 523
     }
524 524
 
525 525
     @Override

+ 0
- 8
src/com/dmdirc/addons/ui_swing/QuitWorker.java View File

@@ -84,12 +84,4 @@ public class QuitWorker extends SwingWorker<Void, Void> {
84 84
         super.done();
85 85
         mainFrame.dispose();
86 86
     }
87
-
88
-    /**
89
-     * Execute this swing worker in the swing worker executor.
90
-     */
91
-    public void executeInExecutor() {
92
-        SwingWorkerExecutor.queue(this);
93
-    }
94
-
95 87
 }

+ 0
- 69
src/com/dmdirc/addons/ui_swing/SwingWorkerExecutor.java View File

@@ -1,69 +0,0 @@
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;
24
-
25
-import java.util.concurrent.Executors;
26
-import java.util.concurrent.LinkedBlockingQueue;
27
-import java.util.concurrent.ThreadFactory;
28
-import java.util.concurrent.ThreadPoolExecutor;
29
-import java.util.concurrent.TimeUnit;
30
-
31
-/**
32
- * Executor for creating swing worker daemon threads. Workaround for bug
33
- * http://bugs.sun.com/view_bug.do?bug_id=6880336
34
- */
35
-public final class SwingWorkerExecutor extends ThreadPoolExecutor implements
36
-        ThreadFactory {
37
-
38
-    /** Max number of swing worker threads. */
39
-    private static final int MAX_WORKERS = 20;
40
-    /** Static instance. */
41
-    public static final SwingWorkerExecutor EXECUTOR = new SwingWorkerExecutor();
42
-
43
-    /**
44
-     * Creates a new swing worker executor.
45
-     */
46
-    private SwingWorkerExecutor() {
47
-        super(1, MAX_WORKERS, 2L, TimeUnit.MINUTES,
48
-                new LinkedBlockingQueue<Runnable>());
49
-        setThreadFactory(this);
50
-    }
51
-
52
-    @Override
53
-    public Thread newThread(final Runnable r) {
54
-        final Thread thread = Executors.defaultThreadFactory().newThread(r);
55
-        thread.setName("SwingWorker-" + thread.getName());
56
-        thread.setDaemon(true);
57
-        return thread;
58
-    }
59
-
60
-    /**
61
-     * Queues the specified runnable on this executor.
62
-     *
63
-     * @param runnable Runnable to execute
64
-     */
65
-    public static void queue(final Runnable runnable) {
66
-        EXECUTOR.execute(runnable);
67
-    }
68
-
69
-}

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/FontPicker.java View File

@@ -72,7 +72,7 @@ public class FontPicker extends JComboBox<Object> {
72 72
                     Logger.appError(ErrorLevel.MEDIUM, ex.getMessage(), ex);
73 73
                 }
74 74
             }
75
-        }.executeInExecutor();
75
+        }.execute();
76 76
     }
77 77
 
78 78
     /**

+ 0
- 8
src/com/dmdirc/addons/ui_swing/components/LoggingSwingWorker.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components;
24 24
 
25
-import com.dmdirc.addons.ui_swing.SwingWorkerExecutor;
26 25
 import com.dmdirc.logger.ErrorLevel;
27 26
 import com.dmdirc.logger.Logger;
28 27
 
@@ -52,11 +51,4 @@ public abstract class LoggingSwingWorker<T, V> extends SwingWorker<T, V> {
52 51
         }
53 52
     }
54 53
 
55
-    /**
56
-     * Execute this swing worker in the swing worker executor.
57
-     */
58
-    public void executeInExecutor() {
59
-        SwingWorkerExecutor.queue(this);
60
-    }
61
-
62 54
 }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/addonbrowser/BrowserWindow.java View File

@@ -190,7 +190,7 @@ public class BrowserWindow extends JDialog implements ActionListener {
190 190
      * @param download Download new addon feed?
191 191
      */
192 192
     public final void loadData(final boolean download) {
193
-        loaderFactory.getDataLoaderWorker(list, download, this, scrollPane).executeInExecutor();
193
+        loaderFactory.getDataLoaderWorker(list, download, this, scrollPane).execute();
194 194
     }
195 195
 
196 196
     /**

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallListener.java View File

@@ -62,7 +62,7 @@ public class InstallListener implements ActionListener {
62 62
     public void actionPerformed(final ActionEvent e) {
63 63
         final InstallerWindow installer = new InstallerWindow(parentWindow, info);
64 64
         installer.display(parentWindow);
65
-        workerFactory.getInstallWorker(info, installer).executeInExecutor();
65
+        workerFactory.getInstallWorker(info, installer).execute();
66 66
     }
67 67
 
68 68
 }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java View File

@@ -146,7 +146,7 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
146 146
                     }
147 147
                 });
148 148
             }
149
-        }.executeInExecutor();
149
+        }.execute();
150 150
     }
151 151
 
152 152
     /** Lays out the dialog. */

+ 3
- 3
src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java View File

@@ -163,7 +163,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
163 163
                     protected void done() {
164 164
                         localTarget.setEditable(true);
165 165
                     }
166
-                }.executeInExecutor();
166
+                }.execute();
167 167
             }
168 168
         });
169 169
         localTarget.getActionMap().put("insert-shift-tab",
@@ -186,7 +186,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
186 186
                             protected void done() {
187 187
                                 localTarget.setEditable(true);
188 188
                             }
189
-                        }.executeInExecutor();
189
+                        }.execute();
190 190
                     }
191 191
                 });
192 192
         localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
@@ -239,7 +239,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
239 239
                                     enterPressed(line);
240 240
                                     return null;
241 241
                                 }
242
-                            }.executeInExecutor();
242
+                            }.execute();
243 243
                         }
244 244
                     }
245 245
                 });

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/FeedbackDialog.java View File

@@ -235,7 +235,7 @@ public class FeedbackDialog extends StandardDialog implements ActionListener, Do
235 235
         }
236 236
         new SendWorker(this, config, name.getText().trim(), email.getText().trim(),
237 237
                 feedback.getText().trim(), serverInfo.toString().trim(),
238
-                dmdircInfo.toString().trim()).executeInExecutor();
238
+                dmdircInfo.toString().trim()).execute();
239 239
     }
240 240
 
241 241
     /** Validates the input. */

+ 2
- 2
src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java View File

@@ -287,7 +287,7 @@ public class NewServerDialog extends StandardDialog implements
287 287
                         serverManager.connectToAddress(address, profile);
288 288
                         return null;
289 289
                     }
290
-                }.executeInExecutor();
290
+                }.execute();
291 291
             } else {
292 292
                 final Connection connection = activeFrameManager.getActiveFrame().getContainer().
293 293
                         getConnection();
@@ -303,7 +303,7 @@ public class NewServerDialog extends StandardDialog implements
303 303
                         }
304 304
                         return null;
305 305
                     }
306
-                }.executeInExecutor();
306
+                }.execute();
307 307
             }
308 308
         } catch (URISyntaxException ex) {
309 309
             Logger.userError(ErrorLevel.MEDIUM, "Unable to create URI", ex);

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java View File

@@ -82,7 +82,7 @@ public class LicencesPanel extends JPanel implements TreeSelectionListener {
82 82
 
83 83
         this.config = globalConfig;
84 84
         initComponents();
85
-        new LicenceLoader(pluginManager, list, listModel).executeInExecutor();
85
+        new LicenceLoader(pluginManager, list, listModel).execute();
86 86
         addListeners();
87 87
         layoutComponents();
88 88
     }

+ 1
- 2
src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryLabel.java View File

@@ -65,8 +65,7 @@ public class CategoryLabel extends JLabel {
65 65
         this.parentList = parentList;
66 66
 
67 67
         setText(category.getTitle());
68
-        new IconLoader(iconManager, this, category.getIcon())
69
-                .executeInExecutor();
68
+        new IconLoader(iconManager, this, category.getIcon()).execute();
70 69
 
71 70
         int level = 0;
72 71
         PreferencesCategory temp = category;

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java View File

@@ -215,7 +215,7 @@ public class CategoryPanel extends JPanel {
215 215
             });
216 216
 
217 217
             worker = new PrefsCategoryLoader(factory, this, category);
218
-            worker.executeInExecutor();
218
+            worker.execute();
219 219
         } else {
220 220
             categoryLoaded(category);
221 221
         }

+ 2
- 2
src/com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.java View File

@@ -141,7 +141,7 @@ public final class SwingPreferencesDialog extends StandardDialog implements
141 141
                 }
142 142
             }
143 143
         };
144
-        worker.executeInExecutor();
144
+        worker.execute();
145 145
     }
146 146
 
147 147
     private void setPrefsManager(final PreferencesDialogModel manager) {
@@ -254,7 +254,7 @@ public final class SwingPreferencesDialog extends StandardDialog implements
254 254
                 }
255 255
                 return null;
256 256
             }
257
-        }.executeInExecutor();
257
+        }.execute();
258 258
         dispose();
259 259
     }
260 260
 

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/updater/SwingUpdaterDialog.java View File

@@ -199,7 +199,7 @@ public class SwingUpdaterDialog extends StandardDialog implements
199 199
                     }
200 200
                     return null;
201 201
                 }
202
-            }.executeInExecutor();
202
+            }.execute();
203 203
 
204 204
             if (updateManager.getManagerStatus() == UpdateManagerStatus.IDLE_RESTART_NEEDED) {
205 205
                 restartDialogProvider.displayOrRequestFocus();

+ 1
- 1
src/com/dmdirc/addons/ui_swing/textpane/BackgroundPainter.java View File

@@ -124,7 +124,7 @@ public class BackgroundPainter extends LayerUI<JComponent> {
124 124
         if (value == null || value.isEmpty()) {
125 125
             backgroundImage = null;
126 126
         } else {
127
-            new ImageLoader(urlBuilder.getUrl(value), this).executeInExecutor();
127
+            new ImageLoader(urlBuilder.getUrl(value), this).execute();
128 128
         }
129 129
     }
130 130
 

Loading…
Cancel
Save