Parcourir la source

More eventbus logging.

Change-Id: If9b36c1b183dd48a0bd48d4faa78942abb884535
Reviewed-on: http://gerrit.dmdirc.com/3716
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/16/3716/5
Greg Holmes il y a 9 ans
Parent
révision
e7b44d97e3

+ 10
- 3
src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorker.java Voir le fichier

@@ -28,9 +28,9 @@ import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28 28
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
29 29
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
30 30
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
31
+import com.dmdirc.events.UserErrorEvent;
31 32
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
32 33
 import com.dmdirc.logger.ErrorLevel;
33
-import com.dmdirc.logger.Logger;
34 34
 import com.dmdirc.updater.manager.UpdateManager;
35 35
 import com.dmdirc.util.URLBuilder;
36 36
 import com.dmdirc.util.annotations.factory.Unbound;
@@ -39,6 +39,8 @@ import com.dmdirc.util.io.DownloadListener;
39 39
 import com.dmdirc.util.io.Downloader;
40 40
 import com.dmdirc.util.io.InvalidConfigFileException;
41 41
 
42
+import com.google.common.eventbus.EventBus;
43
+
42 44
 import java.io.IOException;
43 45
 import java.util.ArrayList;
44 46
 import java.util.Collection;
@@ -84,6 +86,8 @@ public class DataLoaderWorker
84 86
     private final AggregateConfigProvider globalConfig;
85 87
     /** Downloader to download files. */
86 88
     private final Downloader downloader;
89
+    /** The event bus to post errors to. */
90
+    private final EventBus eventBus;
87 91
 
88 92
     /**
89 93
      * Creates a new data loader worker.
@@ -94,6 +98,7 @@ public class DataLoaderWorker
94 98
      * @param workerFactory Factory to use to produce install workers.
95 99
      * @param updateManager Manager to use to retrieve update information.
96 100
      * @param tempDirectory The directory to store temporary items in, such as the addons feed.
101
+     * @param eventBus      The event bus to post errors to
97 102
      * @param table         Table to load data into
98 103
      * @param download      Download new addons feed?
99 104
      * @param browserWindow Browser window to pass to table objects
@@ -106,6 +111,7 @@ public class DataLoaderWorker
106 111
             final InstallWorkerFactory workerFactory,
107 112
             final UpdateManager updateManager,
108 113
             @SuppressWarnings("qualifiers") @Directory(DirectoryType.TEMPORARY) final String tempDirectory,
114
+            final EventBus eventBus,
109 115
             @Unbound final AddonTable table,
110 116
             @Unbound final boolean download,
111 117
             @Unbound final BrowserWindow browserWindow,
@@ -120,6 +126,7 @@ public class DataLoaderWorker
120 126
         this.tempDirectory = tempDirectory;
121 127
         this.browserWindow = browserWindow;
122 128
         this.scrollPane = scrollPane;
129
+        this.eventBus = eventBus;
123 130
     }
124 131
 
125 132
     @Override
@@ -140,7 +147,7 @@ public class DataLoaderWorker
140 147
                         tempDirectory + "addons.feed", this);
141 148
             } catch (final IOException ex) {
142 149
                 loadingPanel.removeAll();
143
-                loadingPanel.add(new TextLabel("Unable to download feeds."));
150
+                loadingPanel.add(new TextLabel("Unable to download feeds: " + ex.getMessage()));
144 151
                 return Collections.<AddonInfo>emptyList();
145 152
             }
146 153
         }
@@ -173,7 +180,7 @@ public class DataLoaderWorker
173 180
         } catch (final InterruptedException ex) {
174 181
             data = Collections.<AddonInfo>emptyList();
175 182
         } catch (final ExecutionException ex) {
176
-            Logger.appError(ErrorLevel.MEDIUM, ex.getMessage(), ex);
183
+            eventBus.post(new UserErrorEvent(ErrorLevel.MEDIUM, ex, ex.getMessage(), ""));
177 184
             data = Collections.<AddonInfo>emptyList();
178 185
         }
179 186
         final int selectedRow;

+ 6
- 1
src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorkerFactory.java Voir le fichier

@@ -29,6 +29,8 @@ import com.dmdirc.updater.manager.UpdateManager;
29 29
 import com.dmdirc.util.URLBuilder;
30 30
 import com.dmdirc.util.io.Downloader;
31 31
 
32
+import com.google.common.eventbus.EventBus;
33
+
32 34
 import javax.inject.Inject;
33 35
 import javax.swing.JScrollPane;
34 36
 
@@ -43,6 +45,7 @@ public class DataLoaderWorkerFactory {
43 45
     private final InstallWorkerFactory workerFactory;
44 46
     private final UpdateManager updateManager;
45 47
     private final String tempDirectory;
48
+    private final EventBus eventBus;
46 49
 
47 50
     @Inject
48 51
     public DataLoaderWorkerFactory(final Downloader downloader,
@@ -50,6 +53,7 @@ public class DataLoaderWorkerFactory {
50 53
             final URLBuilder urlBuilder,
51 54
             final InstallWorkerFactory workerFactory,
52 55
             final UpdateManager updateManager,
56
+            final EventBus eventBus,
53 57
             @CommandLineOptionsModule.Directory(CommandLineOptionsModule.DirectoryType.TEMPORARY) final String tempDirectory) {
54 58
         this.downloader = downloader;
55 59
         this.globalConfig = globalConfig;
@@ -57,10 +61,11 @@ public class DataLoaderWorkerFactory {
57 61
         this.workerFactory = workerFactory;
58 62
         this.updateManager = updateManager;
59 63
         this.tempDirectory = tempDirectory;
64
+        this.eventBus = eventBus;
60 65
     }
61 66
     public DataLoaderWorker getDataLoaderWorker(final AddonTable list, final boolean download,
62 67
             final BrowserWindow browserWindow, final JScrollPane scrollPane) {
63 68
         return new DataLoaderWorker(downloader, globalConfig, urlBuilder, workerFactory,
64
-                updateManager, tempDirectory, list, download, browserWindow, scrollPane);
69
+                updateManager, tempDirectory, eventBus, list, download, browserWindow, scrollPane);
65 70
     }
66 71
 }

Chargement…
Annuler
Enregistrer