Bläddra i källkod

SLF4J Logging in the Swing UI.

pull/419/head
Greg Holmes 9 år sedan
förälder
incheckning
3c789532e7
21 ändrade filer med 84 tillägg och 169 borttagningar
  1. 6
    11
      ui_swing/src/com/dmdirc/addons/ui_swing/UIUtilities.java
  2. 1
    1
      ui_swing/src/com/dmdirc/addons/ui_swing/components/FontPicker.java
  3. 5
    15
      ui_swing/src/com/dmdirc/addons/ui_swing/components/LoggingSwingWorker.java
  4. 7
    16
      ui_swing/src/com/dmdirc/addons/ui_swing/components/RunnableLoggingSwingWorker.java
  5. 10
    16
      ui_swing/src/com/dmdirc/addons/ui_swing/components/SupplierLoggingSwingWorker.java
  6. 7
    10
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorker.java
  7. 1
    5
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorkerFactory.java
  8. 0
    1
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorker.java
  9. 1
    2
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java
  10. 3
    7
      ui_swing/src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java
  11. 2
    5
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryLabel.java
  12. 4
    11
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java
  13. 9
    12
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/IconLoader.java
  14. 3
    10
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/PreferencesListCellRenderer.java
  15. 6
    11
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/PrefsCategoryLoader.java
  16. 11
    14
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.java
  17. 1
    1
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/updater/SwingUpdaterDialog.java
  18. 1
    7
      ui_swing/src/com/dmdirc/addons/ui_swing/textpane/BackgroundPainter.java
  19. 3
    5
      ui_swing/src/com/dmdirc/addons/ui_swing/textpane/ImageLoader.java
  20. 1
    4
      ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPane.java
  21. 2
    5
      ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPaneFactory.java

+ 6
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/UIUtilities.java Visa fil

262
     /**
262
     /**
263
      * Invokes something off the EDT, logging any exceptions that occur.
263
      * Invokes something off the EDT, logging any exceptions that occur.
264
      *
264
      *
265
-     * @param eventBus Eventbus to post errors to
266
      * @param runnable Runnable to execute off the EDT
265
      * @param runnable Runnable to execute off the EDT
267
      */
266
      */
268
-    public static void invokeOffEDT(final DMDircMBassador eventBus, final Runnable runnable) {
269
-        new RunnableLoggingSwingWorker<Void, Void>(eventBus, runnable).execute();
267
+    public static void invokeOffEDT(final Runnable runnable) {
268
+        new RunnableLoggingSwingWorker<Void, Void>(runnable).execute();
270
     }
269
     }
271
 
270
 
272
     /**
271
     /**
273
      * Invokes something off the EDT, handling the result when its finished on the EDT, logging
272
      * Invokes something off the EDT, handling the result when its finished on the EDT, logging
274
      * any exceptions that occur.
273
      * any exceptions that occur.
275
      *
274
      *
276
-     * @param eventBus Eventbus to post errors to
277
      * @param runnable Runnable to execute off the EDT
275
      * @param runnable Runnable to execute off the EDT
278
      * @param consumer Consumer to finalise the runnable on the EDT
276
      * @param consumer Consumer to finalise the runnable on the EDT
279
      *
277
      *
280
      * @param <T>      Type the consumer takes
278
      * @param <T>      Type the consumer takes
281
      */
279
      */
282
-    public static <T> void invokeOffEDT(final DMDircMBassador eventBus, final Runnable runnable,
283
-            final Consumer<T> consumer) {
284
-        new RunnableLoggingSwingWorker<>(eventBus, runnable, consumer).execute();
280
+    public static <T> void invokeOffEDT(final Runnable runnable, final Consumer<T> consumer) {
281
+        new RunnableLoggingSwingWorker<>(runnable, consumer).execute();
285
     }
282
     }
286
 
283
 
287
     /**
284
     /**
288
      * Invokes something off the EDT, handling the result when its finished on the EDT, logging
285
      * Invokes something off the EDT, handling the result when its finished on the EDT, logging
289
      * any exceptions that occur.
286
      * any exceptions that occur.
290
      *
287
      *
291
-     * @param eventBus Eventbus to post errors to
292
      * @param runnable Runnable to execute off the EDT
288
      * @param runnable Runnable to execute off the EDT
293
      * @param consumer Consumer to finalise the runnable on the EDT
289
      * @param consumer Consumer to finalise the runnable on the EDT
294
      *
290
      *
295
      * @param <T>      Type the consumer takes
291
      * @param <T>      Type the consumer takes
296
      */
292
      */
297
-    public static <T> void invokeOffEDT(final DMDircMBassador eventBus, final Supplier<T> runnable,
298
-            final Consumer<T> consumer) {
299
-        new SupplierLoggingSwingWorker<>(eventBus, runnable, consumer).execute();
293
+    public static <T> void invokeOffEDT(final Supplier<T> runnable, final Consumer<T> consumer) {
294
+        new SupplierLoggingSwingWorker<>(runnable, consumer).execute();
300
     }
295
     }
301
 
296
 
302
     /**
297
     /**

+ 1
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/components/FontPicker.java Visa fil

60
         this.fontFamily = fontFamily;
60
         this.fontFamily = fontFamily;
61
 
61
 
62
         setRenderer(new FontListCellRenderer(getRenderer()));
62
         setRenderer(new FontListCellRenderer(getRenderer()));
63
-        UIUtilities.invokeOffEDT(eventBus, this::getFonts, this::loadFonts);
63
+        UIUtilities.invokeOffEDT(this::getFonts, this::loadFonts);
64
     }
64
     }
65
 
65
 
66
     /**
66
     /**

+ 5
- 15
ui_swing/src/com/dmdirc/addons/ui_swing/components/LoggingSwingWorker.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.components;
23
 package com.dmdirc.addons.ui_swing.components;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.events.AppErrorEvent;
27
-import com.dmdirc.logger.ErrorLevel;
28
-
29
 import java.util.concurrent.ExecutionException;
25
 import java.util.concurrent.ExecutionException;
30
 
26
 
31
 import javax.swing.SwingWorker;
27
 import javax.swing.SwingWorker;
32
 
28
 
29
+import org.slf4j.Logger;
30
+import org.slf4j.LoggerFactory;
31
+
33
 /**
32
 /**
34
  * Logging swing worker.
33
  * Logging swing worker.
35
  *
34
  *
38
  */
37
  */
39
 public abstract class LoggingSwingWorker<T, V> extends SwingWorker<T, V> {
38
 public abstract class LoggingSwingWorker<T, V> extends SwingWorker<T, V> {
40
 
39
 
41
-    private final DMDircMBassador eventBus;
42
-
43
-    /**
44
-     * Creates a new logging swing worker.
45
-     *
46
-     * @param eventBus Event bus to post errors to.
47
-     */
48
-    public LoggingSwingWorker(final DMDircMBassador eventBus) {
49
-        this.eventBus = eventBus;
50
-    }
40
+    private static final Logger LOG = LoggerFactory.getLogger(LoggingSwingWorker.class);
51
 
41
 
52
     @Override
42
     @Override
53
     protected void done() {
43
     protected void done() {
59
         } catch (InterruptedException ex) {
49
         } catch (InterruptedException ex) {
60
             //Ignore
50
             //Ignore
61
         } catch (ExecutionException ex) {
51
         } catch (ExecutionException ex) {
62
-            eventBus.publishAsync(new AppErrorEvent(ErrorLevel.MEDIUM, ex, ex.getMessage(), ""));
52
+            LOG.warn(ex.getMessage(), ex);
63
         }
53
         }
64
     }
54
     }
65
 
55
 

+ 7
- 16
ui_swing/src/com/dmdirc/addons/ui_swing/components/RunnableLoggingSwingWorker.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.components;
23
 package com.dmdirc.addons.ui_swing.components;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-
27
 import java.util.List;
25
 import java.util.List;
28
 import java.util.function.Consumer;
26
 import java.util.function.Consumer;
29
 
27
 
35
     /**
33
     /**
36
      * Creates a new logging swing worker.
34
      * Creates a new logging swing worker.
37
      *
35
      *
38
-     * @param eventBus           Event bus to post errors to.
39
      * @param backgroundRunnable The runnable to call as the background task, off the EDT.
36
      * @param backgroundRunnable The runnable to call as the background task, off the EDT.
40
      */
37
      */
41
-    public RunnableLoggingSwingWorker(final DMDircMBassador eventBus,
42
-            final Runnable backgroundRunnable) {
43
-        this(eventBus, backgroundRunnable, result -> {});
38
+    public RunnableLoggingSwingWorker(final Runnable backgroundRunnable) {
39
+        this(backgroundRunnable, result -> {});
44
     }
40
     }
45
 
41
 
46
     /**
42
     /**
47
      * Creates a new logging swing worker.
43
      * Creates a new logging swing worker.
48
      *
44
      *
49
-     * @param eventBus           Event bus to post errors to.
50
      * @param backgroundRunnable The runnable to call as the background task, off the EDT.
45
      * @param backgroundRunnable The runnable to call as the background task, off the EDT.
51
      * @param doneConsumer       The consumer called when the background task is complete
46
      * @param doneConsumer       The consumer called when the background task is complete
52
      */
47
      */
53
-    public RunnableLoggingSwingWorker(final DMDircMBassador eventBus,
54
-            final Runnable backgroundRunnable,
48
+    public RunnableLoggingSwingWorker(final Runnable backgroundRunnable,
55
             final Consumer<T> doneConsumer) {
49
             final Consumer<T> doneConsumer) {
56
-        this(eventBus, backgroundRunnable, doneConsumer, chunks -> {});
50
+        this(backgroundRunnable, doneConsumer, chunks -> {});
57
     }
51
     }
58
 
52
 
59
     /**
53
     /**
60
      * Creates a new logging swing worker.
54
      * Creates a new logging swing worker.
61
      *
55
      *
62
-     * @param eventBus           Event bus to post errors to.
63
      * @param backgroundRunnable The runnable to call as the background task, off the EDT.
56
      * @param backgroundRunnable The runnable to call as the background task, off the EDT.
64
      * @param doneConsumer       The consumer called when the background task is complete
57
      * @param doneConsumer       The consumer called when the background task is complete
65
      * @param processConsumer    The consumer called to process results of the background task
58
      * @param processConsumer    The consumer called to process results of the background task
66
      *                           as it progresses
59
      *                           as it progresses
67
      */
60
      */
68
-    public RunnableLoggingSwingWorker(final DMDircMBassador eventBus,
69
-            final Runnable backgroundRunnable,
70
-            final Consumer<T> doneConsumer,
71
-            final Consumer<List<V>> processConsumer) {
72
-        super(eventBus, () -> { backgroundRunnable.run(); return null; } , doneConsumer, processConsumer);
61
+    public RunnableLoggingSwingWorker(final Runnable backgroundRunnable,
62
+            final Consumer<T> doneConsumer, final Consumer<List<V>> processConsumer) {
63
+        super(() -> { backgroundRunnable.run(); return null; } , doneConsumer, processConsumer);
73
     }
64
     }
74
 }
65
 }

+ 10
- 16
ui_swing/src/com/dmdirc/addons/ui_swing/components/SupplierLoggingSwingWorker.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.components;
23
 package com.dmdirc.addons.ui_swing.components;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.events.UserErrorEvent;
27
-import com.dmdirc.logger.ErrorLevel;
28
-
29
 import java.util.List;
25
 import java.util.List;
30
 import java.util.concurrent.ExecutionException;
26
 import java.util.concurrent.ExecutionException;
31
 import java.util.function.Consumer;
27
 import java.util.function.Consumer;
32
 import java.util.function.Supplier;
28
 import java.util.function.Supplier;
33
 
29
 
30
+import org.slf4j.Logger;
31
+import org.slf4j.LoggerFactory;
32
+
34
 /**
33
 /**
35
  * {@link LoggingSwingWorker} that runs a {@link Supplier}.
34
  * {@link LoggingSwingWorker} that runs a {@link Supplier}.
36
  */
35
  */
37
 public class SupplierLoggingSwingWorker<T, V> extends LoggingSwingWorker<T, V> {
36
 public class SupplierLoggingSwingWorker<T, V> extends LoggingSwingWorker<T, V> {
38
 
37
 
39
-    private final DMDircMBassador eventBus;
38
+    private static final Logger LOG = LoggerFactory.getLogger(SupplierLoggingSwingWorker.class);
40
     private final Consumer<T> doneConsumer;
39
     private final Consumer<T> doneConsumer;
41
     private final Consumer<List<V>> processConsumer;
40
     private final Consumer<List<V>> processConsumer;
42
     private final Supplier<T> backgroundSupplier;
41
     private final Supplier<T> backgroundSupplier;
44
     /**
43
     /**
45
      * Creates a new logging swing worker.
44
      * Creates a new logging swing worker.
46
      *
45
      *
47
-     * @param eventBus           Event bus to post errors to.
48
      * @param backgroundSupplier The supplier to call as the background task, off the EDT.
46
      * @param backgroundSupplier The supplier to call as the background task, off the EDT.
49
      */
47
      */
50
-    public SupplierLoggingSwingWorker(final DMDircMBassador eventBus,
48
+    public SupplierLoggingSwingWorker(
51
             final Supplier<T> backgroundSupplier) {
49
             final Supplier<T> backgroundSupplier) {
52
-        this(eventBus, backgroundSupplier, result -> {});
50
+        this(backgroundSupplier, result -> {});
53
     }
51
     }
54
 
52
 
55
     /**
53
     /**
56
      * Creates a new logging swing worker.
54
      * Creates a new logging swing worker.
57
      *
55
      *
58
-     * @param eventBus           Event bus to post errors to.
59
      * @param backgroundSupplier The supplier to call as the background task, off the EDT.
56
      * @param backgroundSupplier The supplier to call as the background task, off the EDT.
60
      * @param doneConsumer       The consumer called when the background task is complete
57
      * @param doneConsumer       The consumer called when the background task is complete
61
      */
58
      */
62
-    public SupplierLoggingSwingWorker(final DMDircMBassador eventBus,
59
+    public SupplierLoggingSwingWorker(
63
             final Supplier<T> backgroundSupplier,
60
             final Supplier<T> backgroundSupplier,
64
             final Consumer<T> doneConsumer) {
61
             final Consumer<T> doneConsumer) {
65
-        this(eventBus, backgroundSupplier, doneConsumer, chunks -> {});
62
+        this(backgroundSupplier, doneConsumer, chunks -> {});
66
     }
63
     }
67
 
64
 
68
     /**
65
     /**
69
      * Creates a new logging swing worker.
66
      * Creates a new logging swing worker.
70
      *
67
      *
71
-     * @param eventBus           Event bus to post errors to.
72
      * @param backgroundSupplier The supplier to call as the background task, off the EDT.
68
      * @param backgroundSupplier The supplier to call as the background task, off the EDT.
73
      * @param doneConsumer       The consumer called when the background task is complete
69
      * @param doneConsumer       The consumer called when the background task is complete
74
      * @param processConsumer    The consumer called to process results of the background task
70
      * @param processConsumer    The consumer called to process results of the background task
75
      *                           as it progresses
71
      *                           as it progresses
76
      */
72
      */
77
-    public SupplierLoggingSwingWorker(final DMDircMBassador eventBus,
73
+    public SupplierLoggingSwingWorker(
78
             final Supplier<T> backgroundSupplier,
74
             final Supplier<T> backgroundSupplier,
79
             final Consumer<T> doneConsumer,
75
             final Consumer<T> doneConsumer,
80
             final Consumer<List<V>> processConsumer) {
76
             final Consumer<List<V>> processConsumer) {
81
-        super(eventBus);
82
-        this.eventBus = eventBus;
83
         this.backgroundSupplier = backgroundSupplier;
77
         this.backgroundSupplier = backgroundSupplier;
84
         this.doneConsumer = doneConsumer;
78
         this.doneConsumer = doneConsumer;
85
         this.processConsumer = processConsumer;
79
         this.processConsumer = processConsumer;
102
         } catch (InterruptedException ex) {
96
         } catch (InterruptedException ex) {
103
             //Ignore
97
             //Ignore
104
         } catch (ExecutionException ex) {
98
         } catch (ExecutionException ex) {
105
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, ex, ex.getMessage(), ""));
99
+            LOG.warn(ex.getMessage(), ex);
106
         }
100
         }
107
     }
101
     }
108
 
102
 

+ 7
- 10
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorker.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
26
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
29
-import com.dmdirc.events.UserErrorEvent;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31
-import com.dmdirc.logger.ErrorLevel;
32
 import com.dmdirc.updater.manager.UpdateManager;
29
 import com.dmdirc.updater.manager.UpdateManager;
33
 import com.dmdirc.util.URLBuilder;
30
 import com.dmdirc.util.URLBuilder;
34
 import com.dmdirc.util.io.ConfigFile;
31
 import com.dmdirc.util.io.ConfigFile;
51
 
48
 
52
 import net.miginfocom.swing.MigLayout;
49
 import net.miginfocom.swing.MigLayout;
53
 
50
 
51
+import org.slf4j.Logger;
52
+import org.slf4j.LoggerFactory;
53
+
54
+import static com.dmdirc.util.LogUtils.USER_ERROR;
55
+
54
 /**
56
 /**
55
  * Loads the addon data feed into the addon browser.
57
  * Loads the addon data feed into the addon browser.
56
  */
58
  */
58
         extends LoggingSwingWorker<Collection<AddonInfo>, Object>
60
         extends LoggingSwingWorker<Collection<AddonInfo>, Object>
59
         implements DownloadListener {
61
         implements DownloadListener {
60
 
62
 
63
+    private static final Logger LOG = LoggerFactory.getLogger(DataLoaderWorker.class);
61
     /** List to load data into. */
64
     /** List to load data into. */
62
     private final AddonTable table;
65
     private final AddonTable table;
63
     /** Browser window to pass to addon info objects. */
66
     /** Browser window to pass to addon info objects. */
80
     private final AggregateConfigProvider globalConfig;
83
     private final AggregateConfigProvider globalConfig;
81
     /** Downloader to download files. */
84
     /** Downloader to download files. */
82
     private final Downloader downloader;
85
     private final Downloader downloader;
83
-    /** The event bus to post errors to. */
84
-    private final DMDircMBassador eventBus;
85
 
86
 
86
     /**
87
     /**
87
      * Creates a new data loader worker.
88
      * Creates a new data loader worker.
92
      * @param workerFactory Factory to use to produce install workers.
93
      * @param workerFactory Factory to use to produce install workers.
93
      * @param updateManager Manager to use to retrieve update information.
94
      * @param updateManager Manager to use to retrieve update information.
94
      * @param tempDirectory The directory to store temporary items in, such as the addons feed.
95
      * @param tempDirectory The directory to store temporary items in, such as the addons feed.
95
-     * @param eventBus      The event bus to post errors to
96
      * @param table         Table to load data into
96
      * @param table         Table to load data into
97
      * @param download      Download new addons feed?
97
      * @param download      Download new addons feed?
98
      * @param browserWindow Browser window to pass to table objects
98
      * @param browserWindow Browser window to pass to table objects
105
             final InstallWorkerFactory workerFactory,
105
             final InstallWorkerFactory workerFactory,
106
             final UpdateManager updateManager,
106
             final UpdateManager updateManager,
107
             final Path tempDirectory,
107
             final Path tempDirectory,
108
-            final DMDircMBassador eventBus,
109
             final AddonTable table,
108
             final AddonTable table,
110
             final boolean download,
109
             final boolean download,
111
             final BrowserWindow browserWindow,
110
             final BrowserWindow browserWindow,
112
             final JScrollPane scrollPane) {
111
             final JScrollPane scrollPane) {
113
-        super(eventBus);
114
         this.downloader = downloader;
112
         this.downloader = downloader;
115
         this.globalConfig = globalConfig;
113
         this.globalConfig = globalConfig;
116
         this.urlBuilder = urlBuilder;
114
         this.urlBuilder = urlBuilder;
121
         this.tempDirectory = tempDirectory;
119
         this.tempDirectory = tempDirectory;
122
         this.browserWindow = browserWindow;
120
         this.browserWindow = browserWindow;
123
         this.scrollPane = scrollPane;
121
         this.scrollPane = scrollPane;
124
-        this.eventBus = eventBus;
125
     }
122
     }
126
 
123
 
127
     @Override
124
     @Override
173
         } catch (final InterruptedException ex) {
170
         } catch (final InterruptedException ex) {
174
             data = Collections.emptyList();
171
             data = Collections.emptyList();
175
         } catch (final ExecutionException ex) {
172
         } catch (final ExecutionException ex) {
176
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, ex, ex.getMessage(), ""));
173
+            LOG.warn(USER_ERROR, ex.getMessage(), ex);
177
             data = Collections.emptyList();
174
             data = Collections.emptyList();
178
         }
175
         }
179
         final int selectedRow;
176
         final int selectedRow;

+ 1
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorkerFactory.java Visa fil

23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24
 
24
 
25
 import com.dmdirc.ClientModule.GlobalConfig;
25
 import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.DMDircMBassador;
27
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
26
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
28
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
27
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
29
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
47
     private final InstallWorkerFactory workerFactory;
46
     private final InstallWorkerFactory workerFactory;
48
     private final UpdateManager updateManager;
47
     private final UpdateManager updateManager;
49
     private final Path tempDirectory;
48
     private final Path tempDirectory;
50
-    private final DMDircMBassador eventBus;
51
 
49
 
52
     @Inject
50
     @Inject
53
     public DataLoaderWorkerFactory(final Downloader downloader,
51
     public DataLoaderWorkerFactory(final Downloader downloader,
55
             final URLBuilder urlBuilder,
53
             final URLBuilder urlBuilder,
56
             final InstallWorkerFactory workerFactory,
54
             final InstallWorkerFactory workerFactory,
57
             final UpdateManager updateManager,
55
             final UpdateManager updateManager,
58
-            final DMDircMBassador eventBus,
59
             @Directory(DirectoryType.TEMPORARY)
56
             @Directory(DirectoryType.TEMPORARY)
60
             final Path tempDirectory) {
57
             final Path tempDirectory) {
61
         this.downloader = downloader;
58
         this.downloader = downloader;
64
         this.workerFactory = workerFactory;
61
         this.workerFactory = workerFactory;
65
         this.updateManager = updateManager;
62
         this.updateManager = updateManager;
66
         this.tempDirectory = tempDirectory;
63
         this.tempDirectory = tempDirectory;
67
-        this.eventBus = eventBus;
68
     }
64
     }
69
     public DataLoaderWorker getDataLoaderWorker(final AddonTable list, final boolean download,
65
     public DataLoaderWorker getDataLoaderWorker(final AddonTable list, final boolean download,
70
             final BrowserWindow browserWindow, final JScrollPane scrollPane) {
66
             final BrowserWindow browserWindow, final JScrollPane scrollPane) {
71
         return new DataLoaderWorker(downloader, globalConfig, urlBuilder, workerFactory,
67
         return new DataLoaderWorker(downloader, globalConfig, urlBuilder, workerFactory,
72
-                updateManager, tempDirectory, eventBus, list, download, browserWindow, scrollPane);
68
+                updateManager, tempDirectory, list, download, browserWindow, scrollPane);
73
     }
69
     }
74
 }
70
 }

+ 0
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorker.java Visa fil

62
             final DMDircMBassador eventBus,
62
             final DMDircMBassador eventBus,
63
             final AddonInfo info,
63
             final AddonInfo info,
64
             final InstallerWindow window) {
64
             final InstallerWindow window) {
65
-        super(eventBus);
66
         this.downloader = downloader;
65
         this.downloader = downloader;
67
         this.info = info;
66
         this.info = info;
68
         this.installer = window;
67
         this.installer = window;

+ 1
- 2
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java Visa fil

128
      * Populates the list in a background thread.
128
      * Populates the list in a background thread.
129
      */
129
      */
130
     protected void load() {
130
     protected void load() {
131
-        UIUtilities.invokeOffEDT(eventBus,
132
-                () -> populateList(addonList),
131
+        UIUtilities.invokeOffEDT(() -> populateList(addonList),
133
                 value -> {
132
                 value -> {
134
                     scrollPane.setViewportView(addonList);
133
                     scrollPane.setViewportView(addonList);
135
                     addonList.getSelectionModel().addListSelectionListener(this);
134
                     addonList.getSelectionModel().addListSelectionListener(this);

+ 3
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java Visa fil

49
  */
49
  */
50
 public class SwingInputHandler extends InputHandler implements KeyListener {
50
 public class SwingInputHandler extends InputHandler implements KeyListener {
51
 
51
 
52
-    private final DMDircMBassador eventBus;
53
-
54
     /**
52
     /**
55
      * Creates a new instance of InputHandler. Adds listeners to the target that we need to operate.
53
      * Creates a new instance of InputHandler. Adds listeners to the target that we need to operate.
56
      *
54
      *
71
             final DMDircMBassador eventBus) {
69
             final DMDircMBassador eventBus) {
72
         super(serviceManager, target, commandController, commandParser, parentWindow,
70
         super(serviceManager, target, commandController, commandParser, parentWindow,
73
                 tabCompleterUtils, eventBus);
71
                 tabCompleterUtils, eventBus);
74
-        this.eventBus = eventBus;
75
     }
72
     }
76
 
73
 
77
     @Override
74
     @Override
154
             @Override
151
             @Override
155
             public void actionPerformed(final ActionEvent e) {
152
             public void actionPerformed(final ActionEvent e) {
156
                 localTarget.setEditable(false);
153
                 localTarget.setEditable(false);
157
-                UIUtilities.invokeOffEDT(eventBus, () -> doTabCompletion(false),
154
+                UIUtilities.invokeOffEDT(() -> doTabCompletion(false),
158
                         value -> localTarget.setEditable(true));
155
                         value -> localTarget.setEditable(true));
159
             }
156
             }
160
         });
157
         });
166
                     @Override
163
                     @Override
167
                     public void actionPerformed(final ActionEvent e) {
164
                     public void actionPerformed(final ActionEvent e) {
168
                         localTarget.setEditable(false);
165
                         localTarget.setEditable(false);
169
-                        UIUtilities.invokeOffEDT(eventBus,
170
-                                () -> doTabCompletion(true),
166
+                        UIUtilities.invokeOffEDT(() -> doTabCompletion(true),
171
                                 value -> localTarget.setEditable(true));
167
                                 value -> localTarget.setEditable(true));
172
                     }
168
                     }
173
                 });
169
                 });
209
                                         "Event is not from known source.");
205
                                         "Event is not from known source.");
210
                     }
206
                     }
211
                     if (source.isEditable()) {
207
                     if (source.isEditable()) {
212
-                        UIUtilities.invokeOffEDT(eventBus, () -> enterPressed(line));
208
+                        UIUtilities.invokeOffEDT(() -> enterPressed(line));
213
                     }
209
                     }
214
                 });
210
                 });
215
             }
211
             }

+ 2
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryLabel.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.config.prefs.PreferencesCategory;
27
 import com.dmdirc.addons.ui_swing.components.IconManager;
25
 import com.dmdirc.addons.ui_swing.components.IconManager;
26
+import com.dmdirc.config.prefs.PreferencesCategory;
28
 
27
 
29
 import java.awt.Dimension;
28
 import java.awt.Dimension;
30
 
29
 
52
      * Creates a new category label.
51
      * Creates a new category label.
53
      *
52
      *
54
      * @param iconManager Icon manager
53
      * @param iconManager Icon manager
55
-     * @param eventBus    The event bus to post errors to
56
      * @param parentList  Parent list
54
      * @param parentList  Parent list
57
      * @param category    Parent category
55
      * @param category    Parent category
58
      * @param numCats     Number of categories shown
56
      * @param numCats     Number of categories shown
59
      * @param index       Index of this label
57
      * @param index       Index of this label
60
      */
58
      */
61
     public CategoryLabel(final IconManager iconManager,
59
     public CategoryLabel(final IconManager iconManager,
62
-            final DMDircMBassador eventBus,
63
             @Nullable final JList<? extends PreferencesCategory> parentList,
60
             @Nullable final JList<? extends PreferencesCategory> parentList,
64
             final PreferencesCategory category, final int numCats,
61
             final PreferencesCategory category, final int numCats,
65
             final int index) {
62
             final int index) {
67
         final int padding = (int) (1.5 * PlatformDefaults.getUnitValueX("related").getValue());
64
         final int padding = (int) (1.5 * PlatformDefaults.getUnitValueX("related").getValue());
68
 
65
 
69
         setText(category.getTitle());
66
         setText(category.getTitle());
70
-        new IconLoader(iconManager, eventBus, this, category.getIcon()).execute();
67
+        new IconLoader(iconManager, this, category.getIcon()).execute();
71
 
68
 
72
         int level = 0;
69
         int level = 0;
73
         PreferencesCategory temp = category;
70
         PreferencesCategory temp = category;

+ 4
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.PrefsComponentFactory;
25
 import com.dmdirc.addons.ui_swing.PrefsComponentFactory;
27
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
+import com.dmdirc.addons.ui_swing.components.IconManager;
28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
29
 import com.dmdirc.addons.ui_swing.components.TitlePanel;
29
 import com.dmdirc.addons.ui_swing.components.TitlePanel;
30
 import com.dmdirc.addons.ui_swing.components.ToolTipPanel;
30
 import com.dmdirc.addons.ui_swing.components.ToolTipPanel;
31
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
32
 import com.dmdirc.config.prefs.PreferencesCategory;
32
 import com.dmdirc.config.prefs.PreferencesCategory;
33
-import com.dmdirc.addons.ui_swing.components.IconManager;
34
 
33
 
35
 import java.util.Arrays;
34
 import java.util.Arrays;
36
 import java.util.Collections;
35
 import java.util.Collections;
73
     private LoggingSwingWorker<JPanel, Object> worker;
72
     private LoggingSwingWorker<JPanel, Object> worker;
74
     /** Prefs component factory. */
73
     /** Prefs component factory. */
75
     private final PrefsComponentFactory factory;
74
     private final PrefsComponentFactory factory;
76
-    /** The event bus to post errors to. */
77
-    private final DMDircMBassador eventBus;
78
 
75
 
79
     /**
76
     /**
80
      * Instantiates a new category panel.
77
      * Instantiates a new category panel.
81
      *
78
      *
82
-     * @param eventBus    The event bus to post errors to
83
      * @param factory     Prefs component factory instance
79
      * @param factory     Prefs component factory instance
84
      * @param iconManager Icon manager
80
      * @param iconManager Icon manager
85
      */
81
      */
86
     @Inject
82
     @Inject
87
     public CategoryPanel(
83
     public CategoryPanel(
88
-            final DMDircMBassador eventBus,
89
             final PrefsComponentFactory factory,
84
             final PrefsComponentFactory factory,
90
             final IconManager iconManager) {
85
             final IconManager iconManager) {
91
-        this(eventBus, factory, iconManager, null);
86
+        this(factory, iconManager, null);
92
     }
87
     }
93
 
88
 
94
     /**
89
     /**
95
      * Instantiates a new category panel.
90
      * Instantiates a new category panel.
96
      *
91
      *
97
-     * @param eventBus    The event bus to post errors to
98
      * @param factory     Prefs component factory instance
92
      * @param factory     Prefs component factory instance
99
      * @param iconManager Icon manager
93
      * @param iconManager Icon manager
100
      * @param category    Initial category
94
      * @param category    Initial category
101
      */
95
      */
102
     public CategoryPanel(
96
     public CategoryPanel(
103
-            final DMDircMBassador eventBus, final PrefsComponentFactory factory,
97
+            final PrefsComponentFactory factory,
104
             final IconManager iconManager,
98
             final IconManager iconManager,
105
             final PreferencesCategory category) {
99
             final PreferencesCategory category) {
106
         super(new MigLayout("fillx, wrap, ins 0"));
100
         super(new MigLayout("fillx, wrap, ins 0"));
107
         this.factory = factory;
101
         this.factory = factory;
108
-        this.eventBus = eventBus;
109
 
102
 
110
         panels = Collections.synchronizedMap(new HashMap<>());
103
         panels = Collections.synchronizedMap(new HashMap<>());
111
 
104
 
208
         } else {
201
         } else {
209
             UIUtilities.invokeAndWait(() -> scrollPane.setViewportView(loading));
202
             UIUtilities.invokeAndWait(() -> scrollPane.setViewportView(loading));
210
 
203
 
211
-            worker = new PrefsCategoryLoader(factory, eventBus, this, category);
204
+            worker = new PrefsCategoryLoader(factory, this, category);
212
             worker.execute();
205
             worker.execute();
213
         }
206
         }
214
     }
207
     }

+ 9
- 12
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/IconLoader.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
27
-import com.dmdirc.events.UserErrorEvent;
28
-import com.dmdirc.logger.ErrorLevel;
29
 import com.dmdirc.addons.ui_swing.components.IconManager;
25
 import com.dmdirc.addons.ui_swing.components.IconManager;
26
+import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
30
 
27
 
31
 import java.util.concurrent.ExecutionException;
28
 import java.util.concurrent.ExecutionException;
32
 
29
 
33
 import javax.swing.Icon;
30
 import javax.swing.Icon;
34
 
31
 
32
+import org.slf4j.Logger;
33
+import org.slf4j.LoggerFactory;
34
+
35
+import static com.dmdirc.util.LogUtils.USER_ERROR;
36
+
35
 /**
37
 /**
36
  * Loads an icon in the background and uses it for a category label once it has been loaded.
38
  * Loads an icon in the background and uses it for a category label once it has been loaded.
37
  */
39
  */
38
 public class IconLoader extends LoggingSwingWorker<Icon, Void> {
40
 public class IconLoader extends LoggingSwingWorker<Icon, Void> {
39
 
41
 
42
+    private static final Logger LOG = LoggerFactory.getLogger(IconLoader.class);
40
     /** Category this icon will be used for. */
43
     /** Category this icon will be used for. */
41
     private final CategoryLabel label;
44
     private final CategoryLabel label;
42
-    /** The event bus to post errors to. */
43
-    private final DMDircMBassador eventBus;
44
     /** Icon to load. */
45
     /** Icon to load. */
45
     private final String icon;
46
     private final String icon;
46
     /** Icon manager. */
47
     /** Icon manager. */
51
      * loaded in the background.
52
      * loaded in the background.
52
      *
53
      *
53
      * @param iconManager Icon manager
54
      * @param iconManager Icon manager
54
-     * @param eventBus    The event bus to post errors to
55
      * @param label       Label to load category for
55
      * @param label       Label to load category for
56
      * @param icon        Icon to load
56
      * @param icon        Icon to load
57
      */
57
      */
58
-    public IconLoader(final IconManager iconManager, final DMDircMBassador eventBus,
59
-            final CategoryLabel label, final String icon) {
60
-        super(eventBus);
58
+    public IconLoader(final IconManager iconManager, final CategoryLabel label, final String icon) {
61
         this.iconManager = iconManager;
59
         this.iconManager = iconManager;
62
-        this.eventBus = eventBus;
63
         this.label = label;
60
         this.label = label;
64
         this.icon = icon;
61
         this.icon = icon;
65
     }
62
     }
76
         } catch (InterruptedException ex) {
73
         } catch (InterruptedException ex) {
77
             //Ignore
74
             //Ignore
78
         } catch (ExecutionException ex) {
75
         } catch (ExecutionException ex) {
79
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex, ex.getMessage(), ""));
76
+            LOG.info(USER_ERROR, ex.getMessage(), ex);
80
         }
77
         }
81
 
78
 
82
     }
79
     }

+ 3
- 10
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/PreferencesListCellRenderer.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.config.prefs.PreferencesCategory;
27
 import com.dmdirc.addons.ui_swing.components.IconManager;
25
 import com.dmdirc.addons.ui_swing.components.IconManager;
26
+import com.dmdirc.config.prefs.PreferencesCategory;
28
 
27
 
29
 import java.awt.Component;
28
 import java.awt.Component;
30
 import java.awt.Font;
29
 import java.awt.Font;
49
     private final IconManager iconManager;
48
     private final IconManager iconManager;
50
     /** Label map. */
49
     /** Label map. */
51
     private final Map<PreferencesCategory, JLabel> labelMap;
50
     private final Map<PreferencesCategory, JLabel> labelMap;
52
-    /** The event bus to post errors to. */
53
-    private final DMDircMBassador eventBus;
54
 
51
 
55
     /**
52
     /**
56
      * Instantiates a new prefs list cell renderer.
53
      * Instantiates a new prefs list cell renderer.
57
      *
54
      *
58
      * @param iconManager Icon manager to load icons
55
      * @param iconManager Icon manager to load icons
59
-     * @param eventBus    The event bus to post errors to
60
      * @param numCats     Number of categories in the list
56
      * @param numCats     Number of categories in the list
61
      */
57
      */
62
-    public PreferencesListCellRenderer(final IconManager iconManager, final DMDircMBassador eventBus,
63
-            final int numCats) {
58
+    public PreferencesListCellRenderer(final IconManager iconManager, final int numCats) {
64
         labelMap = new HashMap<>();
59
         labelMap = new HashMap<>();
65
         this.numCats = numCats;
60
         this.numCats = numCats;
66
         this.iconManager = iconManager;
61
         this.iconManager = iconManager;
67
-        this.eventBus = eventBus;
68
     }
62
     }
69
 
63
 
70
     @Override
64
     @Override
72
             final PreferencesCategory value, final int index, final boolean isSelected,
66
             final PreferencesCategory value, final int index, final boolean isSelected,
73
             final boolean cellHasFocus) {
67
             final boolean cellHasFocus) {
74
         if (!labelMap.containsKey(value)) {
68
         if (!labelMap.containsKey(value)) {
75
-            labelMap.put(value, new CategoryLabel(iconManager, eventBus,
76
-                    list, value, numCats, index));
69
+            labelMap.put(value, new CategoryLabel(iconManager, list, value, numCats, index));
77
         }
70
         }
78
         final JLabel label = labelMap.get(value);
71
         final JLabel label = labelMap.get(value);
79
 
72
 

+ 6
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/PrefsCategoryLoader.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.Apple;
25
 import com.dmdirc.addons.ui_swing.Apple;
27
 import com.dmdirc.addons.ui_swing.PrefsComponentFactory;
26
 import com.dmdirc.addons.ui_swing.PrefsComponentFactory;
28
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
 import com.dmdirc.addons.ui_swing.UIUtilities;
31
 import com.dmdirc.config.prefs.PreferencesCategory;
30
 import com.dmdirc.config.prefs.PreferencesCategory;
32
 import com.dmdirc.config.prefs.PreferencesSetting;
31
 import com.dmdirc.config.prefs.PreferencesSetting;
33
 import com.dmdirc.config.prefs.PreferencesType;
32
 import com.dmdirc.config.prefs.PreferencesType;
34
-import com.dmdirc.events.UserErrorEvent;
35
-import com.dmdirc.logger.ErrorLevel;
33
+import com.dmdirc.util.LogUtils;
36
 
34
 
37
 import java.awt.Component;
35
 import java.awt.Component;
38
 import java.awt.MenuContainer;
36
 import java.awt.MenuContainer;
47
 import net.miginfocom.layout.PlatformDefaults;
45
 import net.miginfocom.layout.PlatformDefaults;
48
 import net.miginfocom.swing.MigLayout;
46
 import net.miginfocom.swing.MigLayout;
49
 
47
 
48
+import org.slf4j.Logger;
49
+import org.slf4j.LoggerFactory;
50
+
50
 /**
51
 /**
51
  * Loads a preferences panel for a specified preferences category in the background.
52
  * Loads a preferences panel for a specified preferences category in the background.
52
  */
53
  */
53
 public class PrefsCategoryLoader extends LoggingSwingWorker<JPanel, Object> {
54
 public class PrefsCategoryLoader extends LoggingSwingWorker<JPanel, Object> {
54
 
55
 
56
+    private static final Logger LOG = LoggerFactory.getLogger(PrefsCategoryLoader.class);
55
     /** Panel gap. */
57
     /** Panel gap. */
56
     private final int padding = (int) PlatformDefaults.getUnitValueX("related").getValue();
58
     private final int padding = (int) PlatformDefaults.getUnitValueX("related").getValue();
57
     /** Panel left padding. */
59
     /** Panel left padding. */
66
     private final PreferencesCategory category;
68
     private final PreferencesCategory category;
67
     /** Prefs component factory instance. */
69
     /** Prefs component factory instance. */
68
     private final PrefsComponentFactory factory;
70
     private final PrefsComponentFactory factory;
69
-    /** The event bus to post the errors to. */
70
-    private final DMDircMBassador eventBus;
71
 
71
 
72
     /**
72
     /**
73
      * Instantiates a new preferences category loader.
73
      * Instantiates a new preferences category loader.
74
      *
74
      *
75
      * @param factory       Prefs component factory instance
75
      * @param factory       Prefs component factory instance
76
-     * @param eventBus      The event bus to post errors ro
77
      * @param categoryPanel Parent Category panel
76
      * @param categoryPanel Parent Category panel
78
      * @param category      Preferences Category to load
77
      * @param category      Preferences Category to load
79
      */
78
      */
80
     public PrefsCategoryLoader(final PrefsComponentFactory factory,
79
     public PrefsCategoryLoader(final PrefsComponentFactory factory,
81
-            final DMDircMBassador eventBus,
82
             final CategoryPanel categoryPanel,
80
             final CategoryPanel categoryPanel,
83
             final PreferencesCategory category) {
81
             final PreferencesCategory category) {
84
-        super(eventBus);
85
         this.factory = factory;
82
         this.factory = factory;
86
-        this.eventBus = eventBus;
87
         this.categoryPanel = categoryPanel;
83
         this.categoryPanel = categoryPanel;
88
         this.category = category;
84
         this.category = category;
89
 
85
 
116
         } catch (InterruptedException ex) {
112
         } catch (InterruptedException ex) {
117
             panel = errorCategory;
113
             panel = errorCategory;
118
         } catch (ExecutionException ex) {
114
         } catch (ExecutionException ex) {
119
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM, ex,
120
-                    "Error loading prefs panel", ""));
115
+            LOG.warn(LogUtils.USER_ERROR, "Error loading prefs panel", ex);
121
             panel = errorCategory;
116
             panel = errorCategory;
122
         }
117
         }
123
         return panel;
118
         return panel;

+ 11
- 14
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
 import com.dmdirc.addons.ui_swing.components.IconManager;
26
 import com.dmdirc.addons.ui_swing.components.IconManager;
28
 import com.dmdirc.addons.ui_swing.components.ListScroller;
27
 import com.dmdirc.addons.ui_swing.components.ListScroller;
34
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
33
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
35
 import com.dmdirc.config.prefs.PreferencesCategory;
34
 import com.dmdirc.config.prefs.PreferencesCategory;
36
 import com.dmdirc.config.prefs.PreferencesDialogModel;
35
 import com.dmdirc.config.prefs.PreferencesDialogModel;
37
-import com.dmdirc.events.UserErrorEvent;
38
-import com.dmdirc.logger.ErrorLevel;
39
 
36
 
40
 import java.awt.Window;
37
 import java.awt.Window;
41
 import java.awt.event.ActionEvent;
38
 import java.awt.event.ActionEvent;
57
 
54
 
58
 import net.miginfocom.swing.MigLayout;
55
 import net.miginfocom.swing.MigLayout;
59
 
56
 
57
+import org.slf4j.Logger;
58
+import org.slf4j.LoggerFactory;
59
+
60
+import static com.dmdirc.util.LogUtils.USER_ERROR;
61
+
60
 /**
62
 /**
61
  * Allows the user to modify global client preferences.
63
  * Allows the user to modify global client preferences.
62
  */
64
  */
63
 public final class SwingPreferencesDialog extends StandardDialog implements
65
 public final class SwingPreferencesDialog extends StandardDialog implements
64
         ActionListener, ListSelectionListener {
66
         ActionListener, ListSelectionListener {
65
 
67
 
68
+    private static final Logger LOG = LoggerFactory.getLogger(SwingPreferencesDialog.class);
66
     /** Serial version UID. */
69
     /** Serial version UID. */
67
     private static final long serialVersionUID = 9;
70
     private static final long serialVersionUID = 9;
68
     /** Preferences tab list, used to switch option types. */
71
     /** Preferences tab list, used to switch option types. */
81
     private final Provider<CategoryPanel> categoryPanelProvider;
84
     private final Provider<CategoryPanel> categoryPanelProvider;
82
     /** Icon manager to retrieve icons from. */
85
     /** Icon manager to retrieve icons from. */
83
     private final IconManager iconManager;
86
     private final IconManager iconManager;
84
-    /** The event bus to post errors to. */
85
-    private final DMDircMBassador eventBus;
86
 
87
 
87
     /**
88
     /**
88
      * Creates a new instance of SwingPreferencesDialog.
89
      * Creates a new instance of SwingPreferencesDialog.
92
      * @param restartDialogProvider The provider to use for restart dialogs.
93
      * @param restartDialogProvider The provider to use for restart dialogs.
93
      * @param dialogModelProvider   The provider to use to get a dialog model.
94
      * @param dialogModelProvider   The provider to use to get a dialog model.
94
      * @param categoryPanelProvider The provider to use to produce a category panel.
95
      * @param categoryPanelProvider The provider to use to produce a category panel.
95
-     * @param eventBus              The event bus to post errors to.
96
      */
96
      */
97
     @Inject
97
     @Inject
98
     public SwingPreferencesDialog(
98
     public SwingPreferencesDialog(
100
             final IconManager iconManager,
100
             final IconManager iconManager,
101
             @ForSettings final DialogProvider<SwingRestartDialog> restartDialogProvider,
101
             @ForSettings final DialogProvider<SwingRestartDialog> restartDialogProvider,
102
             final Provider<PreferencesDialogModel> dialogModelProvider,
102
             final Provider<PreferencesDialogModel> dialogModelProvider,
103
-            final Provider<CategoryPanel> categoryPanelProvider,
104
-            final DMDircMBassador eventBus) {
103
+            final Provider<CategoryPanel> categoryPanelProvider) {
105
         super(parentWindow, ModalityType.MODELESS);
104
         super(parentWindow, ModalityType.MODELESS);
106
 
105
 
107
         this.iconManager = iconManager;
106
         this.iconManager = iconManager;
108
         this.restartDialogProvider = restartDialogProvider;
107
         this.restartDialogProvider = restartDialogProvider;
109
         this.categoryPanelProvider = categoryPanelProvider;
108
         this.categoryPanelProvider = categoryPanelProvider;
110
-        this.eventBus = eventBus;
111
 
109
 
112
         initComponents();
110
         initComponents();
113
 
111
 
114
-        worker = new SupplierLoggingSwingWorker<>(eventBus,
112
+        worker = new SupplierLoggingSwingWorker<>(
115
                 () -> getPrefsModel(dialogModelProvider),
113
                 () -> getPrefsModel(dialogModelProvider),
116
                 value -> {
114
                 value -> {
117
                     if (value != null) {
115
                     if (value != null) {
129
             prefsManager = dialogModelProvider.get();
127
             prefsManager = dialogModelProvider.get();
130
         } catch (IllegalArgumentException ex) {
128
         } catch (IllegalArgumentException ex) {
131
             mainPanel.setError(ex.getMessage());
129
             mainPanel.setError(ex.getMessage());
132
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.HIGH, ex,
133
-                    "Unable to load the preferences dialog", ""));
130
+            LOG.error(USER_ERROR, "Unable to load the preferences dialog", ex);
134
         }
131
         }
135
         return prefsManager;
132
         return prefsManager;
136
     }
133
     }
142
         mainPanel.setCategory(null);
139
         mainPanel.setCategory(null);
143
 
140
 
144
         final int count = countCategories(manager.getCategories());
141
         final int count = countCategories(manager.getCategories());
145
-        tabList.setCellRenderer(new PreferencesListCellRenderer(iconManager, eventBus, count));
142
+        tabList.setCellRenderer(new PreferencesListCellRenderer(iconManager, count));
146
 
143
 
147
         addCategories(manager.getCategories());
144
         addCategories(manager.getCategories());
148
     }
145
     }
231
             saveOptions();
228
             saveOptions();
232
         }
229
         }
233
 
230
 
234
-        UIUtilities.invokeOffEDT(eventBus, () -> {
231
+        UIUtilities.invokeOffEDT(() -> {
235
             if (manager != null) {
232
             if (manager != null) {
236
                 manager.dismiss();
233
                 manager.dismiss();
237
             }
234
             }

+ 1
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/updater/SwingUpdaterDialog.java Visa fil

181
 
181
 
182
             header.setText("DMDirc is updating the following components:");
182
             header.setText("DMDirc is updating the following components:");
183
 
183
 
184
-            UIUtilities.invokeOffEDT(eventBus,
184
+            UIUtilities.invokeOffEDT(
185
                     () -> ((UpdateTableModel) table.getModel()).getUpdates().stream()
185
                     () -> ((UpdateTableModel) table.getModel()).getUpdates().stream()
186
                     .filter(((UpdateTableModel) table.getModel())::isEnabled)
186
                     .filter(((UpdateTableModel) table.getModel())::isEnabled)
187
                     .forEach(updateManager::install));
187
                     .forEach(updateManager::install));

+ 1
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/textpane/BackgroundPainter.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.textpane;
23
 package com.dmdirc.addons.ui_swing.textpane;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.BackgroundOption;
25
 import com.dmdirc.addons.ui_swing.BackgroundOption;
27
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
 import com.dmdirc.addons.ui_swing.UIUtilities;
28
 import com.dmdirc.config.ConfigBinding;
27
 import com.dmdirc.config.ConfigBinding;
67
      * Config manager to bind to and retrieve settings from.
66
      * Config manager to bind to and retrieve settings from.
68
      */
67
      */
69
     private final AggregateConfigProvider configManager;
68
     private final AggregateConfigProvider configManager;
70
-    /** The event bus to post errors to. */
71
-    private final DMDircMBassador eventBus;
72
     /**
69
     /**
73
      * Background image.
70
      * Background image.
74
      */
71
      */
83
      *
80
      *
84
      * @param configManager Config manager to retrieve settings from
81
      * @param configManager Config manager to retrieve settings from
85
      * @param urlBuilder    URL Builder
82
      * @param urlBuilder    URL Builder
86
-     * @param eventBus      The event bus to post errors to
87
      * @param domain        Domain to retrieve settings from
83
      * @param domain        Domain to retrieve settings from
88
      * @param imageKey      Key for background image
84
      * @param imageKey      Key for background image
89
      * @param optionKey     Key for background type
85
      * @param optionKey     Key for background type
91
     public BackgroundPainter(
87
     public BackgroundPainter(
92
             final AggregateConfigProvider configManager,
88
             final AggregateConfigProvider configManager,
93
             final URLBuilder urlBuilder,
89
             final URLBuilder urlBuilder,
94
-            final DMDircMBassador eventBus,
95
             @Nonnull final String domain, @Nonnull final String imageKey,
90
             @Nonnull final String domain, @Nonnull final String imageKey,
96
             @Nonnull final String optionKey) {
91
             @Nonnull final String optionKey) {
97
         this.configManager = configManager;
92
         this.configManager = configManager;
99
         this.domain = domain;
94
         this.domain = domain;
100
         this.imageKey = imageKey;
95
         this.imageKey = imageKey;
101
         this.optionKey = optionKey;
96
         this.optionKey = optionKey;
102
-        this.eventBus = eventBus;
103
         configManager.getBinder().bind(this, BackgroundPainter.class);
97
         configManager.getBinder().bind(this, BackgroundPainter.class);
104
     }
98
     }
105
 
99
 
132
         if (value == null || value.isEmpty()) {
126
         if (value == null || value.isEmpty()) {
133
             backgroundImage = null;
127
             backgroundImage = null;
134
         } else {
128
         } else {
135
-            new ImageLoader(urlBuilder.getUrl(value), this, eventBus).execute();
129
+            new ImageLoader(urlBuilder.getUrl(value), this).execute();
136
         }
130
         }
137
     }
131
     }
138
 
132
 

+ 3
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/textpane/ImageLoader.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.textpane;
23
 package com.dmdirc.addons.ui_swing.textpane;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
25
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
27
 
26
 
28
 import java.awt.Image;
27
 import java.awt.Image;
32
 
31
 
33
 import javax.imageio.ImageIO;
32
 import javax.imageio.ImageIO;
34
 
33
 
34
+import org.slf4j.Logger;
35
 import org.slf4j.LoggerFactory;
35
 import org.slf4j.LoggerFactory;
36
 
36
 
37
 /**
37
 /**
39
  */
39
  */
40
 public class ImageLoader extends LoggingSwingWorker<Image, Void> {
40
 public class ImageLoader extends LoggingSwingWorker<Image, Void> {
41
 
41
 
42
-    private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ImageLoader.class);
42
+    private static final Logger LOG = LoggerFactory.getLogger(ImageLoader.class);
43
     /**
43
     /**
44
      * URL of image file to load.
44
      * URL of image file to load.
45
      */
45
      */
49
      */
49
      */
50
     private final BackgroundPainter painter;
50
     private final BackgroundPainter painter;
51
 
51
 
52
-    public ImageLoader(final URL imageURL, final BackgroundPainter painter,
53
-            final DMDircMBassador eventBus) {
54
-        super(eventBus);
52
+    public ImageLoader(final URL imageURL, final BackgroundPainter painter) {
55
         this.imageURL = imageURL;
53
         this.imageURL = imageURL;
56
         this.painter = painter;
54
         this.painter = painter;
57
     }
55
     }

+ 1
- 4
ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPane.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.textpane;
23
 package com.dmdirc.addons.ui_swing.textpane;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
 import com.dmdirc.interfaces.config.ConfigChangeListener;
26
 import com.dmdirc.interfaces.config.ConfigChangeListener;
28
 import com.dmdirc.interfaces.ui.Window;
27
 import com.dmdirc.interfaces.ui.Window;
92
     /**
91
     /**
93
      * Creates a new instance of TextPane.
92
      * Creates a new instance of TextPane.
94
      *
93
      *
95
-     * @param eventBus     The event bus to post errors to.
96
      * @param configDomain The domain to read configuration from.
94
      * @param configDomain The domain to read configuration from.
97
      * @param urlBuilder   The builder to use to construct URLs for resources.
95
      * @param urlBuilder   The builder to use to construct URLs for resources.
98
      * @param clipboard    The clipboard to handle copy and paste actions
96
      * @param clipboard    The clipboard to handle copy and paste actions
99
      * @param frame        Parent Frame
97
      * @param frame        Parent Frame
100
      */
98
      */
101
     public TextPane(
99
     public TextPane(
102
-            final DMDircMBassador eventBus,
103
             final String configDomain,
100
             final String configDomain,
104
             final URLBuilder urlBuilder, final Clipboard clipboard,
101
             final URLBuilder urlBuilder, final Clipboard clipboard,
105
             final Window frame) {
102
             final Window frame) {
117
 
114
 
118
         setLayout(new MigLayout("fill, hidemode 3"));
115
         setLayout(new MigLayout("fill, hidemode 3"));
119
         backgroundPainter = new BackgroundPainter(frame.getContainer().getConfigManager(),
116
         backgroundPainter = new BackgroundPainter(frame.getContainer().getConfigManager(),
120
-                urlBuilder, eventBus, configDomain, "textpanebackground",
117
+                urlBuilder, configDomain, "textpanebackground",
121
                 "textpanebackgroundoption");
118
                 "textpanebackgroundoption");
122
         canvas = new TextPaneCanvas(this,
119
         canvas = new TextPaneCanvas(this,
123
                 new CachingDocument<>(document, new AttributedStringMessageMaker()));
120
                 new CachingDocument<>(document, new AttributedStringMessageMaker()));

+ 2
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPaneFactory.java Visa fil

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.textpane;
23
 package com.dmdirc.addons.ui_swing.textpane;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.SwingController;
25
 import com.dmdirc.addons.ui_swing.SwingController;
27
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
26
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28
 import com.dmdirc.plugins.PluginDomain;
27
 import com.dmdirc.plugins.PluginDomain;
42
     private final String configDomain;
41
     private final String configDomain;
43
     private final URLBuilder urlBuilder;
42
     private final URLBuilder urlBuilder;
44
     private final Clipboard clipboard;
43
     private final Clipboard clipboard;
45
-    private final DMDircMBassador eventBus;
46
 
44
 
47
     @Inject
45
     @Inject
48
     public TextPaneFactory(@PluginDomain(SwingController.class) final String configDomain,
46
     public TextPaneFactory(@PluginDomain(SwingController.class) final String configDomain,
49
-            final URLBuilder urlBuilder, final Clipboard clipboard, final DMDircMBassador eventBus) {
47
+            final URLBuilder urlBuilder, final Clipboard clipboard) {
50
         this.configDomain = configDomain;
48
         this.configDomain = configDomain;
51
         this.urlBuilder = urlBuilder;
49
         this.urlBuilder = urlBuilder;
52
         this.clipboard = clipboard;
50
         this.clipboard = clipboard;
53
-        this.eventBus = eventBus;
54
     }
51
     }
55
 
52
 
56
     public TextPane getTextPane(final TextFrame frame) {
53
     public TextPane getTextPane(final TextFrame frame) {
57
-        return new TextPane(eventBus, configDomain, urlBuilder, clipboard, frame);
54
+        return new TextPane(configDomain, urlBuilder, clipboard, frame);
58
     }
55
     }
59
 
56
 
60
 }
57
 }

Laddar…
Avbryt
Spara