Browse Source

EventBus logging for LoggingSwingWorker.

Change-Id: Ida9e3a33fe96b45b0bc35259ef8cbc4b36f7bf55
Reviewed-on: http://gerrit.dmdirc.com/3722
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/22/3722/2
Greg Holmes 9 years ago
parent
commit
3b29644b3a

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

@@ -56,7 +56,7 @@ public class FontPicker extends JComboBox<Object> {
56 56
         this.fontFamily = fontFamily;
57 57
 
58 58
         setRenderer(new FontListCellRenderer(getRenderer()));
59
-        new LoggingSwingWorker<String[], String[]>() {
59
+        new LoggingSwingWorker<String[], String[]>(eventBus) {
60 60
 
61 61
             @Override
62 62
             protected String[] doInBackground() {

+ 15
- 2
src/com/dmdirc/addons/ui_swing/components/LoggingSwingWorker.java View File

@@ -22,8 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components;
24 24
 
25
+import com.dmdirc.events.UserErrorEvent;
25 26
 import com.dmdirc.logger.ErrorLevel;
26
-import com.dmdirc.logger.Logger;
27
+
28
+import com.google.common.eventbus.EventBus;
27 29
 
28 30
 import java.util.concurrent.ExecutionException;
29 31
 
@@ -37,6 +39,17 @@ import javax.swing.SwingWorker;
37 39
  */
38 40
 public abstract class LoggingSwingWorker<T, V> extends SwingWorker<T, V> {
39 41
 
42
+    private final EventBus eventBus;
43
+
44
+    /**
45
+     * Creates a new logging swing worker.
46
+     *
47
+     * @param eventBus Event bus to post errors to.
48
+     */
49
+    public LoggingSwingWorker(final EventBus eventBus) {
50
+        this.eventBus = eventBus;
51
+    }
52
+
40 53
     @Override
41 54
     protected void done() {
42 55
         if (isCancelled()) {
@@ -47,7 +60,7 @@ public abstract class LoggingSwingWorker<T, V> extends SwingWorker<T, V> {
47 60
         } catch (InterruptedException ex) {
48 61
             //Ignore
49 62
         } catch (ExecutionException ex) {
50
-            Logger.appError(ErrorLevel.MEDIUM, ex.getMessage(), ex);
63
+            eventBus.post(new UserErrorEvent(ErrorLevel.MEDIUM, ex, ex.getMessage(), ""));
51 64
         }
52 65
     }
53 66
 

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

@@ -116,6 +116,7 @@ public class DataLoaderWorker
116 116
             @Unbound final boolean download,
117 117
             @Unbound final BrowserWindow browserWindow,
118 118
             @Unbound final JScrollPane scrollPane) {
119
+        super(eventBus);
119 120
         this.downloader = downloader;
120 121
         this.globalConfig = globalConfig;
121 122
         this.urlBuilder = urlBuilder;

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

@@ -30,6 +30,8 @@ import com.dmdirc.plugins.PluginManager;
30 30
 import com.dmdirc.util.annotations.factory.Unbound;
31 31
 import com.dmdirc.util.io.Downloader;
32 32
 
33
+import com.google.common.eventbus.EventBus;
34
+
33 35
 import java.io.File;
34 36
 import java.io.IOException;
35 37
 import java.util.concurrent.ExecutionException;
@@ -60,9 +62,10 @@ public class InstallWorker extends LoggingSwingWorker<String, Void> {
60 62
             @SuppressWarnings("qualifiers") @Directory(DirectoryType.PLUGINS) final String pluginDirectory,
61 63
             @SuppressWarnings("qualifiers") @Directory(DirectoryType.THEMES) final String themeDirectory,
62 64
             final PluginManager pluginManager,
65
+            final EventBus eventBus,
63 66
             @Unbound final AddonInfo info,
64 67
             @Unbound final InstallerWindow window) {
65
-
68
+        super(eventBus);
66 69
         this.downloader = downloader;
67 70
         this.info = info;
68 71
         this.installer = window;

+ 6
- 2
src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorkerFactory.java View File

@@ -26,6 +26,8 @@ import com.dmdirc.commandline.CommandLineOptionsModule;
26 26
 import com.dmdirc.plugins.PluginManager;
27 27
 import com.dmdirc.util.io.Downloader;
28 28
 
29
+import com.google.common.eventbus.EventBus;
30
+
29 31
 import javax.inject.Inject;
30 32
 
31 33
 /**
@@ -38,21 +40,23 @@ public class InstallWorkerFactory {
38 40
     private final String pluginDirectory;
39 41
     private final String themeDirectory;
40 42
     private final PluginManager pluginManager;
43
+    private final EventBus eventBus;
41 44
 
42 45
     @Inject
43 46
     public InstallWorkerFactory(final Downloader downloader,
44 47
             @CommandLineOptionsModule.Directory(CommandLineOptionsModule.DirectoryType.TEMPORARY) final String tempDirectory,
45 48
             @CommandLineOptionsModule.Directory(CommandLineOptionsModule.DirectoryType.PLUGINS) final String pluginDirectory,
46 49
             @CommandLineOptionsModule.Directory(CommandLineOptionsModule.DirectoryType.THEMES) final String themeDirectory,
47
-            final PluginManager pluginManager) {
50
+            final PluginManager pluginManager, final EventBus eventBus) {
48 51
         this.downloader = downloader;
49 52
         this.tempDirectory = tempDirectory;
50 53
         this.pluginDirectory = pluginDirectory;
51 54
         this.themeDirectory = themeDirectory;
52 55
         this.pluginManager = pluginManager;
56
+        this.eventBus = eventBus;
53 57
     }
54 58
     public InstallWorker getInstallWorker(final AddonInfo info, final InstallerWindow installer) {
55 59
         return new InstallWorker(downloader, tempDirectory, pluginDirectory, themeDirectory,
56
-                pluginManager, info, installer);
60
+                pluginManager, eventBus, info, installer);
57 61
     }
58 62
 }

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

@@ -30,6 +30,8 @@ import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
30 30
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31 31
 import com.dmdirc.config.prefs.PreferencesInterface;
32 32
 
33
+import com.google.common.eventbus.EventBus;
34
+
33 35
 import java.awt.Window;
34 36
 
35 37
 import javax.swing.JLabel;
@@ -60,6 +62,8 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
60 62
     private final Window parentWindow;
61 63
     /** The factory to use to produce data loader workers. */
62 64
     private final DataLoaderWorkerFactory workerFactory;
65
+    /** The event bus to post errors to. */
66
+    private final EventBus eventBus;
63 67
     /** Addon list scroll pane. */
64 68
     private JScrollPane scrollPane;
65 69
     /** Blurb label. */
@@ -77,11 +81,11 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
77 81
      * @param parentWindow  Parent window
78 82
      * @param workerFactory The factory to use to produce data loader workers.
79 83
      */
80
-    public AddonPanel(final Window parentWindow, final DataLoaderWorkerFactory workerFactory) {
81
-        super();
82
-
84
+    public AddonPanel(final Window parentWindow, final DataLoaderWorkerFactory workerFactory,
85
+            final EventBus eventBus) {
83 86
         this.parentWindow = parentWindow;
84 87
         this.workerFactory = workerFactory;
88
+        this.eventBus = eventBus;
85 89
 
86 90
         initComponents();
87 91
         layoutComponents();
@@ -127,21 +131,17 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
127 131
      * Populates the list in a background thread.
128 132
      */
129 133
     protected void load() {
130
-        /** {@inheritDoc}. */
131
-        new LoggingSwingWorker<Object, Object>() {
132
-            /** {@inheritDoc}. */
134
+        new LoggingSwingWorker<Object, Object>(eventBus) {
133 135
             @Override
134 136
             protected Object doInBackground() {
135 137
                 return populateList(addonList);
136 138
             }
137 139
 
138
-            /** {@inheritDoc}. */
139 140
             @Override
140 141
             protected void done() {
141 142
                 super.done();
142 143
                 scrollPane.setViewportView(addonList);
143 144
                 UIUtilities.invokeLater(new Runnable() {
144
-                    /** {@inheritDoc}. */
145 145
                     @Override
146 146
                     public void run() {
147 147
                         addonList.getSelectionModel()
@@ -179,7 +179,6 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
179 179
      */
180 180
     protected abstract String getTypeName();
181 181
 
182
-    /** {@inheritDoc}. */
183 182
     @Override
184 183
     public void valueChanged(final ListSelectionEvent e) {
185 184
         final int newSelection = addonList.getSelectedRow();
@@ -192,7 +191,6 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
192 191
         selectedAddon = addonList.getSelectedRow();
193 192
     }
194 193
 
195
-    /** {@inheritDoc}. */
196 194
     @Override
197 195
     public void hyperlinkUpdate(final HyperlinkEvent e) {
198 196
         if (e.getEventType() == EventType.ACTIVATED) {

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

@@ -82,7 +82,7 @@ public class PluginPanel extends AddonPanel {
82 82
             @GlobalConfig final IconManager iconManager,
83 83
             final CachingUpdateManager updateManager,
84 84
             @UserConfig final ConfigProvider userConfig) {
85
-        super(parentWindow, workerFactory);
85
+        super(parentWindow, workerFactory, eventBus);
86 86
         this.pluginManager = pluginManager;
87 87
         this.iconManager = iconManager;
88 88
         this.updateManager = updateManager;

+ 6
- 2
src/com/dmdirc/addons/ui_swing/components/addonpanel/ThemePanel.java View File

@@ -33,6 +33,8 @@ import com.dmdirc.ui.themes.Theme;
33 33
 import com.dmdirc.ui.themes.ThemeManager;
34 34
 import com.dmdirc.updater.manager.CachingUpdateManager;
35 35
 
36
+import com.google.common.eventbus.EventBus;
37
+
36 38
 import java.awt.Window;
37 39
 import java.util.ArrayList;
38 40
 import java.util.Collections;
@@ -67,6 +69,7 @@ public class ThemePanel extends AddonPanel {
67 69
      * @param iconManager   Manager to use to retrieve addon-related icons.
68 70
      * @param updateManager Manager to use to retrieve update information.
69 71
      * @param userConfig    Configuration to write update-related settings to.
72
+     * @param eventBus      The event bus to post errors to.
70 73
      */
71 74
     @Inject
72 75
     public ThemePanel(
@@ -75,8 +78,9 @@ public class ThemePanel extends AddonPanel {
75 78
             final DataLoaderWorkerFactory workerFactory,
76 79
             @GlobalConfig final IconManager iconManager,
77 80
             final CachingUpdateManager updateManager,
78
-            @UserConfig final ConfigProvider userConfig) {
79
-        super(parentWindow, workerFactory);
81
+            @UserConfig final ConfigProvider userConfig,
82
+            final EventBus eventBus) {
83
+        super(parentWindow, workerFactory, eventBus);
80 84
         this.themeManager = themeManager;
81 85
         this.iconManager = iconManager;
82 86
         this.updateManager = updateManager;

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

@@ -49,6 +49,8 @@ import javax.swing.text.JTextComponent;
49 49
  */
50 50
 public class SwingInputHandler extends InputHandler implements KeyListener {
51 51
 
52
+    private final EventBus eventBus;
53
+
52 54
     /**
53 55
      * Creates a new instance of InputHandler. Adds listeners to the target that we need to operate.
54 56
      *
@@ -67,6 +69,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
67 69
             final FrameContainer parentWindow,
68 70
             final EventBus eventBus) {
69 71
         super(serviceManager, target, commandController, commandParser, parentWindow, eventBus);
72
+        this.eventBus = eventBus;
70 73
     }
71 74
 
72 75
     @Override
@@ -148,7 +151,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
148 151
 
149 152
             @Override
150 153
             public void actionPerformed(final ActionEvent e) {
151
-                new LoggingSwingWorker<Object, Void>() {
154
+                new LoggingSwingWorker<Object, Void>(eventBus) {
152 155
 
153 156
                     @Override
154 157
                     protected Object doInBackground() {
@@ -172,7 +175,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
172 175
 
173 176
                     @Override
174 177
                     public void actionPerformed(final ActionEvent e) {
175
-                        new LoggingSwingWorker<Object, Void>() {
178
+                        new LoggingSwingWorker<Object, Void>(eventBus) {
176 179
 
177 180
                             @Override
178 181
                             protected Object doInBackground() {
@@ -230,7 +233,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
230 233
                                             "Event is not from known source.");
231 234
                         }
232 235
                         if (source.isEditable()) {
233
-                            new LoggingSwingWorker<Object, Void>() {
236
+                            new LoggingSwingWorker<Object, Void>(eventBus) {
234 237
 
235 238
                                 @Override
236 239
                                 protected Object doInBackground() {

+ 8
- 4
src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java View File

@@ -27,6 +27,8 @@ import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
27 27
 import com.dmdirc.plugins.PluginInfo;
28 28
 import com.dmdirc.util.resourcemanager.ResourceManager;
29 29
 
30
+import com.google.common.eventbus.EventBus;
31
+
30 32
 import java.io.BufferedReader;
31 33
 import java.io.IOException;
32 34
 import java.io.InputStream;
@@ -59,12 +61,14 @@ public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
59 61
     /**
60 62
      * Instantiates a new licence loader.
61 63
      *
62
-     * @param plugins List of plugins to get licenses from
63
-     * @param tree    Tree to add licenses to
64
-     * @param model   Model to load licences into
64
+     * @param plugins  List of plugins to get licenses from
65
+     * @param tree     Tree to add licenses to
66
+     * @param model    Model to load licences into
67
+     * @param eventBus The event bus to post errors to
65 68
      */
66 69
     public LicenceLoader(final Collection<PluginInfo> plugins, final JTree tree,
67
-            final DefaultTreeModel model) {
70
+            final DefaultTreeModel model, final EventBus eventBus) {
71
+        super(eventBus);
68 72
         this.plugins = plugins;
69 73
         this.tree = tree;
70 74
         this.model = model;

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

@@ -29,6 +29,8 @@ import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 29
 import com.dmdirc.plugins.PluginInfo;
30 30
 import com.dmdirc.plugins.PluginManager;
31 31
 
32
+import com.google.common.eventbus.EventBus;
33
+
32 34
 import java.awt.Font;
33 35
 import java.awt.Rectangle;
34 36
 
@@ -73,14 +75,15 @@ public class LicencesPanel extends JPanel implements TreeSelectionListener {
73 75
      *
74 76
      * @param globalConfig  The config to read settings from.
75 77
      * @param pluginManager The manager to use to find plugins (to display their licenses).
78
+     * @param eventBus      The event bus to post errors to.
76 79
      */
77 80
     @Inject
78 81
     public LicencesPanel(
79 82
             @GlobalConfig final AggregateConfigProvider globalConfig,
80
-            final PluginManager pluginManager) {
83
+            final PluginManager pluginManager, final EventBus eventBus) {
81 84
         config = globalConfig;
82 85
         initComponents();
83
-        new LicenceLoader(pluginManager.getPluginInfos(), list, listModel).execute();
86
+        new LicenceLoader(pluginManager.getPluginInfos(), list, listModel, eventBus).execute();
84 87
         addListeners();
85 88
         layoutComponents();
86 89
     }

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

@@ -58,6 +58,7 @@ public class IconLoader extends LoggingSwingWorker<Icon, Void> {
58 58
      */
59 59
     public IconLoader(final IconManager iconManager, final EventBus eventBus,
60 60
             final CategoryLabel label, final String icon) {
61
+        super(eventBus);
61 62
         this.iconManager = iconManager;
62 63
         this.eventBus = eventBus;
63 64
         this.label = label;

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

@@ -84,6 +84,7 @@ public class PrefsCategoryLoader extends LoggingSwingWorker<JPanel, Object> {
84 84
             final EventBus eventBus,
85 85
             final CategoryPanel categoryPanel,
86 86
             final PreferencesCategory category) {
87
+        super(eventBus);
87 88
         this.factory = factory;
88 89
         this.eventBus = eventBus;
89 90
         this.categoryPanel = categoryPanel;

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

@@ -114,7 +114,7 @@ public final class SwingPreferencesDialog extends StandardDialog implements
114 114
 
115 115
         initComponents();
116 116
 
117
-        worker = new LoggingSwingWorker<PreferencesDialogModel, Void>() {
117
+        worker = new LoggingSwingWorker<PreferencesDialogModel, Void>(eventBus) {
118 118
 
119 119
             @Override
120 120
             protected PreferencesDialogModel doInBackground() {
@@ -251,7 +251,7 @@ public final class SwingPreferencesDialog extends StandardDialog implements
251 251
             saveOptions();
252 252
         }
253 253
 
254
-        new LoggingSwingWorker<Void, Void>() {
254
+        new LoggingSwingWorker<Void, Void>(eventBus) {
255 255
             @Override
256 256
             protected Void doInBackground() {
257 257
                 if (manager != null) {

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

@@ -39,6 +39,8 @@ import com.dmdirc.updater.manager.UpdateManagerListener;
39 39
 import com.dmdirc.updater.manager.UpdateManagerStatus;
40 40
 import com.dmdirc.updater.manager.UpdateStatus;
41 41
 
42
+import com.google.common.eventbus.EventBus;
43
+
42 44
 import java.awt.Dimension;
43 45
 import java.awt.Window;
44 46
 import java.awt.event.ActionEvent;
@@ -79,6 +81,8 @@ public class SwingUpdaterDialog extends StandardDialog implements
79 81
     private UpdateStatusTableCellRenderer updateStatusRenderer;
80 82
     /** Provider of restart dialogs. */
81 83
     private final DialogProvider<SwingRestartDialog> restartDialogProvider;
84
+    /** The event bus to post errors to. */
85
+    private final EventBus eventBus;
82 86
 
83 87
     /**
84 88
      * Creates a new instance of the updater dialog.
@@ -86,16 +90,19 @@ public class SwingUpdaterDialog extends StandardDialog implements
86 90
      * @param updateManager         The update manager to use for information
87 91
      * @param parentWindow          Parent window
88 92
      * @param restartDialogProvider Provider of restart dialogs.
93
+     * @param eventBus              The event bus to post errors to
89 94
      */
90 95
     @Inject
91 96
     public SwingUpdaterDialog(
92 97
             final CachingUpdateManager updateManager,
93 98
             @MainWindow final Window parentWindow,
94
-            @ForUpdates final DialogProvider<SwingRestartDialog> restartDialogProvider) {
99
+            @ForUpdates final DialogProvider<SwingRestartDialog> restartDialogProvider,
100
+            final EventBus eventBus) {
95 101
         super(parentWindow, ModalityType.MODELESS);
96 102
 
97 103
         this.updateManager = updateManager;
98 104
         this.restartDialogProvider = restartDialogProvider;
105
+        this.eventBus = eventBus;
99 106
 
100 107
         initComponents();
101 108
         layoutComponents();
@@ -110,8 +117,6 @@ public class SwingUpdaterDialog extends StandardDialog implements
110 117
 
111 118
     /**
112 119
      * Initialises the components.
113
-     *
114
-     * @param updates The updates that are available
115 120
      */
116 121
     private void initComponents() {
117 122
         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
@@ -188,7 +193,7 @@ public class SwingUpdaterDialog extends StandardDialog implements
188 193
 
189 194
             header.setText("DMDirc is updating the following components:");
190 195
 
191
-            new LoggingSwingWorker<Void, Void>() {
196
+            new LoggingSwingWorker<Void, Void>(eventBus) {
192 197
 
193 198
                 @Override
194 199
                 protected Void doInBackground() {

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

@@ -28,6 +28,8 @@ import com.dmdirc.config.ConfigBinding;
28 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 29
 import com.dmdirc.util.URLBuilder;
30 30
 
31
+import com.google.common.eventbus.EventBus;
32
+
31 33
 import java.awt.Graphics;
32 34
 import java.awt.Graphics2D;
33 35
 import java.awt.Image;
@@ -67,6 +69,8 @@ public class BackgroundPainter extends LayerUI<JComponent> {
67 69
      * Config manager to bind to and retrieve settings from.
68 70
      */
69 71
     private final AggregateConfigProvider configManager;
72
+    /** The event bus to post errors to. */
73
+    private final EventBus eventBus;
70 74
     /**
71 75
      * Background image.
72 76
      */
@@ -81,6 +85,7 @@ public class BackgroundPainter extends LayerUI<JComponent> {
81 85
      *
82 86
      * @param configManager Config manager to retrieve settings from
83 87
      * @param urlBuilder    URL Builder
88
+     * @param eventBus      The event bus to post errors to
84 89
      * @param domain        Domain to retrieve settings from
85 90
      * @param imageKey      Key for background image
86 91
      * @param optionKey     Key for background type
@@ -88,6 +93,7 @@ public class BackgroundPainter extends LayerUI<JComponent> {
88 93
     public BackgroundPainter(
89 94
             final AggregateConfigProvider configManager,
90 95
             final URLBuilder urlBuilder,
96
+            final EventBus eventBus,
91 97
             final String domain, final String imageKey,
92 98
             final String optionKey) {
93 99
         this.configManager = configManager;
@@ -95,6 +101,7 @@ public class BackgroundPainter extends LayerUI<JComponent> {
95 101
         this.domain = domain;
96 102
         this.imageKey = imageKey;
97 103
         this.optionKey = optionKey;
104
+        this.eventBus = eventBus;
98 105
         configManager.getBinder().bind(this, BackgroundPainter.class);
99 106
     }
100 107
 
@@ -124,7 +131,7 @@ public class BackgroundPainter extends LayerUI<JComponent> {
124 131
         if (value == null || value.isEmpty()) {
125 132
             backgroundImage = null;
126 133
         } else {
127
-            new ImageLoader(urlBuilder.getUrl(value), this).execute();
134
+            new ImageLoader(urlBuilder.getUrl(value), this, eventBus).execute();
128 135
         }
129 136
     }
130 137
 

+ 5
- 7
src/com/dmdirc/addons/ui_swing/textpane/ImageLoader.java View File

@@ -24,6 +24,8 @@ package com.dmdirc.addons.ui_swing.textpane;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
26 26
 
27
+import com.google.common.eventbus.EventBus;
28
+
27 29
 import java.awt.Image;
28 30
 import java.io.IOException;
29 31
 import java.net.URL;
@@ -48,14 +50,13 @@ public class ImageLoader extends LoggingSwingWorker<Image, Void> {
48 50
      */
49 51
     private final BackgroundPainter painter;
50 52
 
51
-    public ImageLoader(final URL imageURL, final BackgroundPainter painter) {
53
+    public ImageLoader(final URL imageURL, final BackgroundPainter painter,
54
+            final EventBus eventBus) {
55
+        super(eventBus);
52 56
         this.imageURL = imageURL;
53 57
         this.painter = painter;
54 58
     }
55 59
 
56
-    /**
57
-     * {@inheritDoc}
58
-     */
59 60
     @Override
60 61
     protected Image doInBackground() {
61 62
         try {
@@ -70,9 +71,6 @@ public class ImageLoader extends LoggingSwingWorker<Image, Void> {
70 71
         }
71 72
     }
72 73
 
73
-    /**
74
-     * {@inheritDoc}
75
-     */
76 74
     @Override
77 75
     protected void done() {
78 76
         try {

+ 7
- 3
src/com/dmdirc/addons/ui_swing/textpane/TextPane.java View File

@@ -32,6 +32,8 @@ import com.dmdirc.ui.messages.LinePosition;
32 32
 import com.dmdirc.ui.messages.Styliser;
33 33
 import com.dmdirc.util.URLBuilder;
34 34
 
35
+import com.google.common.eventbus.EventBus;
36
+
35 37
 import java.awt.Color;
36 38
 import java.awt.Point;
37 39
 import java.awt.datatransfer.Clipboard;
@@ -86,16 +88,17 @@ public final class TextPane extends JComponent implements MouseWheelListener,
86 88
     /**
87 89
      * Creates a new instance of TextPane.
88 90
      *
91
+     * @param eventBus     The event bus to post errors to.
89 92
      * @param configDomain The domain to read configuration from.
90 93
      * @param urlBuilder   The builder to use to construct URLs for resources.
91
-     * @param clipboard     The clipboard to handle copy and paste actions
94
+     * @param clipboard    The clipboard to handle copy and paste actions
92 95
      * @param frame        Parent Frame
93 96
      */
94 97
     public TextPane(
98
+            final EventBus eventBus,
95 99
             final String configDomain,
96 100
             final URLBuilder urlBuilder, final Clipboard clipboard,
97 101
             final TextFrame frame) {
98
-        super();
99 102
         this.frame = frame;
100 103
         this.configDomain = configDomain;
101 104
         this.clipboard = clipboard;
@@ -110,7 +113,8 @@ public final class TextPane extends JComponent implements MouseWheelListener,
110 113
 
111 114
         setLayout(new MigLayout("fill, hidemode 3"));
112 115
         backgroundPainter = new BackgroundPainter(frame.getContainer().getConfigManager(),
113
-                urlBuilder, configDomain, "textpanebackground", "textpanebackgroundoption");
116
+                urlBuilder, eventBus, configDomain, "textpanebackground",
117
+                "textpanebackgroundoption");
114 118
         canvas = new TextPaneCanvas(this, document);
115 119
         final JXLayer<JComponent> layer = new JXLayer<JComponent>(canvas);
116 120
         layer.setUI(backgroundPainter);

+ 6
- 2
src/com/dmdirc/addons/ui_swing/textpane/TextPaneFactory.java View File

@@ -27,6 +27,8 @@ import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
27 27
 import com.dmdirc.plugins.PluginDomain;
28 28
 import com.dmdirc.util.URLBuilder;
29 29
 
30
+import com.google.common.eventbus.EventBus;
31
+
30 32
 import java.awt.datatransfer.Clipboard;
31 33
 
32 34
 import javax.inject.Inject;
@@ -41,17 +43,19 @@ public class TextPaneFactory {
41 43
     private final String configDomain;
42 44
     private final URLBuilder urlBuilder;
43 45
     private final Clipboard clipboard;
46
+    private final EventBus eventBus;
44 47
 
45 48
     @Inject
46 49
     public TextPaneFactory(@PluginDomain(SwingController.class) final String configDomain,
47
-            final URLBuilder urlBuilder, final Clipboard clipboard) {
50
+            final URLBuilder urlBuilder, final Clipboard clipboard, final EventBus eventBus) {
48 51
         this.configDomain = configDomain;
49 52
         this.urlBuilder = urlBuilder;
50 53
         this.clipboard = clipboard;
54
+        this.eventBus = eventBus;
51 55
     }
52 56
 
53 57
     public TextPane getTextPane(final TextFrame frame) {
54
-        return new TextPane(configDomain, urlBuilder, clipboard, frame);
58
+        return new TextPane(eventBus, configDomain, urlBuilder, clipboard, frame);
55 59
     }
56 60
 
57 61
 }

Loading…
Cancel
Save