浏览代码

Refresh plugins when downloading a new one.

Don't try to add it based on path, just get the PluginManager
to refresh everything.
pull/425/head
Chris Smith 9 年前
父节点
当前提交
93ba059cef

+ 3
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorker.java 查看文件

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25
-import com.dmdirc.DMDircMBassador;
26 25
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
27 26
 import com.dmdirc.plugins.PluginManager;
28 27
 import com.dmdirc.util.io.Downloader;
@@ -59,7 +58,6 @@ public class InstallWorker extends LoggingSwingWorker<String, Void> {
59 58
             final String pluginDirectory,
60 59
             final String themeDirectory,
61 60
             final PluginManager pluginManager,
62
-            final DMDircMBassador eventBus,
63 61
             final AddonInfo info,
64 62
             final InstallerWindow window) {
65 63
         this.downloader = downloader;
@@ -82,10 +80,10 @@ public class InstallWorker extends LoggingSwingWorker<String, Void> {
82 80
                     final Path newFile = Paths.get(pluginDirectory, info.getTitle() + ".jar");
83 81
                     try {
84 82
                         Files.move(file, newFile);
85
-                        pluginManager.addPlugin(newFile.getFileName().toString());
83
+                        pluginManager.refreshPlugins();
86 84
                     } catch (IOException ex) {
87 85
                         return "Unable to install addon, failed to move file: "
88
-                                + file.toAbsolutePath().toString();
86
+                                + file.toAbsolutePath();
89 87
                     }
90 88
                     break;
91 89
                 case TYPE_THEME:
@@ -93,7 +91,7 @@ public class InstallWorker extends LoggingSwingWorker<String, Void> {
93 91
                         Files.move(file, Paths.get(themeDirectory, info.getTitle() + ".zip"));
94 92
                     } catch (IOException ex) {
95 93
                         return "Unable to install addon, failed to move file: "
96
-                                + file.toAbsolutePath().toString();
94
+                                + file.toAbsolutePath();
97 95
                     }
98 96
                     break;
99 97
                 default:

+ 4
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallWorkerFactory.java 查看文件

@@ -22,17 +22,18 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25
-import com.dmdirc.DMDircMBassador;
26 25
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
27 26
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
28 27
 import com.dmdirc.plugins.PluginManager;
29 28
 import com.dmdirc.util.io.Downloader;
30 29
 
31 30
 import javax.inject.Inject;
31
+import javax.inject.Singleton;
32 32
 
33 33
 /**
34 34
  * Factory for {@link InstallWorker}s.
35 35
  */
36
+@Singleton
36 37
 public class InstallWorkerFactory {
37 38
 
38 39
     private final Downloader downloader;
@@ -40,23 +41,21 @@ public class InstallWorkerFactory {
40 41
     private final String pluginDirectory;
41 42
     private final String themeDirectory;
42 43
     private final PluginManager pluginManager;
43
-    private final DMDircMBassador eventBus;
44 44
 
45 45
     @Inject
46 46
     public InstallWorkerFactory(final Downloader downloader,
47 47
             @Directory(DirectoryType.TEMPORARY) final String tempDirectory,
48 48
             @Directory(DirectoryType.PLUGINS) final String pluginDirectory,
49 49
             @Directory(DirectoryType.THEMES) final String themeDirectory,
50
-            final PluginManager pluginManager, final DMDircMBassador eventBus) {
50
+            final PluginManager pluginManager) {
51 51
         this.downloader = downloader;
52 52
         this.tempDirectory = tempDirectory;
53 53
         this.pluginDirectory = pluginDirectory;
54 54
         this.themeDirectory = themeDirectory;
55 55
         this.pluginManager = pluginManager;
56
-        this.eventBus = eventBus;
57 56
     }
58 57
     public InstallWorker getInstallWorker(final AddonInfo info, final InstallerWindow installer) {
59 58
         return new InstallWorker(downloader, tempDirectory, pluginDirectory,
60
-                themeDirectory, pluginManager, eventBus, info, installer);
59
+                themeDirectory, pluginManager, info, installer);
61 60
     }
62 61
 }

正在加载...
取消
保存