|
@@ -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;
|