|
@@ -26,8 +26,8 @@ import com.dmdirc.interfaces.config.ConfigProvider;
|
26
|
26
|
import com.dmdirc.plugins.PluginInfo;
|
27
|
27
|
import com.dmdirc.ui.themes.Theme;
|
28
|
28
|
import com.dmdirc.ui.themes.ThemeManager;
|
29
|
|
-import com.dmdirc.updater.UpdateChecker;
|
30
|
29
|
import com.dmdirc.updater.UpdateComponent;
|
|
30
|
+import com.dmdirc.updater.manager.CachingUpdateManager;
|
31
|
31
|
import com.dmdirc.updater.manager.UpdateStatus;
|
32
|
32
|
import com.dmdirc.util.collections.ListenerList;
|
33
|
33
|
|
|
@@ -56,44 +56,54 @@ public final class AddonToggle {
|
56
|
56
|
* Creates a new instance of AddonToggle to wrap the specified
|
57
|
57
|
* PluginInfo.
|
58
|
58
|
*
|
|
59
|
+ * @param updateManager The update manager to use to retrieve component info.
|
59
|
60
|
* @param identity Identity to change update settings in.
|
60
|
61
|
* @param pi The PluginInfo to be wrapped.
|
61
|
62
|
*/
|
62
|
|
- public AddonToggle(final ConfigProvider identity, final PluginInfo pi) {
|
|
63
|
+ public AddonToggle(
|
|
64
|
+ final CachingUpdateManager updateManager,
|
|
65
|
+ final ConfigProvider identity,
|
|
66
|
+ final PluginInfo pi) {
|
63
|
67
|
this.identity = identity;
|
64
|
68
|
this.pi = pi;
|
65
|
69
|
this.theme = null;
|
66
|
70
|
this.themeManager = null;
|
67
|
71
|
state = pi.isLoaded();
|
68
|
72
|
|
69
|
|
- for (UpdateComponent comp : UpdateChecker.getManager().getComponents()) {
|
70
|
|
- if (comp.getName().equals("addon-" + getID())) {
|
71
|
|
- updateState = UpdateChecker.getManager().getStatus(comp)
|
72
|
|
- != UpdateStatus.CHECKING_NOT_PERMITTED;
|
73
|
|
- break;
|
74
|
|
- }
|
75
|
|
- }
|
|
73
|
+ checkUpdateState(updateManager);
|
76
|
74
|
}
|
77
|
75
|
|
78
|
76
|
/**
|
79
|
|
- * Creates a new instance of AddonToggle to wrap the specified
|
80
|
|
- * Theme.
|
|
77
|
+ * Creates a new instance of AddonToggle to wrap the specified Theme.
|
81
|
78
|
*
|
|
79
|
+ * @param updateManager The update manager to use to retrieve component info.
|
82
|
80
|
* @param identity Identity to change update settings in.
|
83
|
81
|
* @param themeManager The manager to update when toggling a theme.
|
84
|
82
|
* @param theme The Theme to be wrapped
|
85
|
83
|
*/
|
86
|
|
- public AddonToggle(final ConfigProvider identity, final ThemeManager themeManager, final Theme theme) {
|
|
84
|
+ public AddonToggle(
|
|
85
|
+ final CachingUpdateManager updateManager,
|
|
86
|
+ final ConfigProvider identity,
|
|
87
|
+ final ThemeManager themeManager,
|
|
88
|
+ final Theme theme) {
|
87
|
89
|
this.identity = identity;
|
88
|
90
|
this.pi = null;
|
89
|
91
|
this.theme = theme;
|
90
|
92
|
this.themeManager = themeManager;
|
91
|
93
|
state = theme.isEnabled();
|
92
|
94
|
|
93
|
|
- for (UpdateComponent comp : UpdateChecker.getManager().getComponents()) {
|
|
95
|
+ checkUpdateState(updateManager);
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ /**
|
|
99
|
+ * Checks whether or not the component that is controlled by this toggle is enabled.
|
|
100
|
+ *
|
|
101
|
+ * @param updateManager The update manager to use to retrieve component info.
|
|
102
|
+ */
|
|
103
|
+ private void checkUpdateState(final CachingUpdateManager updateManager) {
|
|
104
|
+ for (UpdateComponent comp : updateManager.getComponents()) {
|
94
|
105
|
if (comp.getName().equals("addon-" + getID())) {
|
95
|
|
- updateState = UpdateChecker.getManager().getStatus(comp)
|
96
|
|
- != UpdateStatus.CHECKING_NOT_PERMITTED;
|
|
106
|
+ updateState = updateManager.getStatus(comp) != UpdateStatus.CHECKING_NOT_PERMITTED;
|
97
|
107
|
break;
|
98
|
108
|
}
|
99
|
109
|
}
|