Sfoglia il codice sorgente

Switch more plugins to use events for showconfig.

pull/287/head
Greg Holmes 9 anni fa
parent
commit
39404c3806

+ 1
- 12
ui_swing/src/com/dmdirc/addons/ui_swing/SwingController.java Vedi File

@@ -29,7 +29,6 @@ import com.dmdirc.addons.ui_swing.commands.PopOutCommand;
29 29
 import com.dmdirc.addons.ui_swing.commands.ServerSettings;
30 30
 import com.dmdirc.addons.ui_swing.framemanager.FrameManagerProvider;
31 31
 import com.dmdirc.addons.ui_swing.injection.SwingModule;
32
-import com.dmdirc.config.prefs.PreferencesDialogModel;
33 32
 import com.dmdirc.interfaces.ui.UIController;
34 33
 import com.dmdirc.plugins.Exported;
35 34
 import com.dmdirc.plugins.PluginInfo;
@@ -51,8 +50,6 @@ public class SwingController extends BaseCommandPlugin implements UIController {
51 50
     private final PluginInfo pluginInfo;
52 51
     /** The manager we're using for dependencies. */
53 52
     private SwingManager swingManager;
54
-    /** This plugin's settings domain. */
55
-    private final String domain;
56 53
 
57 54
     /**
58 55
      * Instantiates a new SwingController.
@@ -61,14 +58,13 @@ public class SwingController extends BaseCommandPlugin implements UIController {
61 58
      */
62 59
     public SwingController(final PluginInfo pluginInfo) {
63 60
         this.pluginInfo = pluginInfo;
64
-        this.domain = pluginInfo.getDomain();
65 61
     }
66 62
 
67 63
     @Override
68 64
     public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
69 65
         super.load(pluginInfo, graph);
70 66
 
71
-        setObjectGraph(graph.plus(new SwingModule(this, pluginInfo.getDomain())));
67
+        setObjectGraph(graph.plus(new SwingModule(this, pluginInfo, pluginInfo.getDomain())));
72 68
         getObjectGraph().validate();
73 69
         swingManager = getObjectGraph().get(SwingManager.class);
74 70
 
@@ -102,13 +98,6 @@ public class SwingController extends BaseCommandPlugin implements UIController {
102 98
         super.onUnload();
103 99
     }
104 100
 
105
-    @Override
106
-    public void showConfig(final PreferencesDialogModel manager) {
107
-        manager.getCategory("GUI").addSubCategory(
108
-                new SwingPreferencesModel(pluginInfo, domain, manager.getConfigManager(),
109
-                        manager.getIdentity()).getSwingUICategory());
110
-    }
111
-
112 101
     /**
113 102
      * Returns the version of this swing UI.
114 103
      *

+ 17
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/SwingManager.java Vedi File

@@ -31,9 +31,12 @@ import com.dmdirc.addons.ui_swing.events.SwingEventBus;
31 31
 import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
32 32
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManagerProvider;
33 33
 import com.dmdirc.addons.ui_swing.wizard.firstrun.FirstRunWizardExecutor;
34
+import com.dmdirc.events.ClientPrefsOpenedEvent;
34 35
 import com.dmdirc.events.FeedbackNagEvent;
35 36
 import com.dmdirc.events.FirstRunEvent;
36 37
 import com.dmdirc.events.UnknownURLEvent;
38
+import com.dmdirc.plugins.PluginDomain;
39
+import com.dmdirc.plugins.PluginInfo;
37 40
 import com.dmdirc.ui.WindowManager;
38 41
 
39 42
 import java.awt.Window;
@@ -80,6 +83,8 @@ public class SwingManager {
80 83
     private MainFrame mainFrame;
81 84
     /** Swing UI initialiser. */
82 85
     private final SwingUIInitialiser uiInitialiser;
86
+    private final PluginInfo pluginInfo;
87
+    private final String domain;
83 88
 
84 89
     /**
85 90
      * Creates a new instance of {@link SwingManager}.
@@ -116,7 +121,9 @@ public class SwingManager {
116 121
             final SwingEventBus swingEventBus,
117 122
             final TreeFrameManagerProvider treeProvider,
118 123
             final Provider<SwingWindowManager> swingWindowManager,
119
-            final SwingUIInitialiser uiInitialiser) {
124
+            final SwingUIInitialiser uiInitialiser,
125
+            final PluginInfo pluginInfo,
126
+            @PluginDomain(SwingController.class)final String domain) {
120 127
         this.windowFactory = windowFactory;
121 128
         this.windowManager = windowManager;
122 129
         this.menuBar = menuBar;
@@ -132,6 +139,8 @@ public class SwingManager {
132 139
         this.treeProvider = treeProvider;
133 140
         this.swingWindowManager = swingWindowManager;
134 141
         this.uiInitialiser = uiInitialiser;
142
+        this.pluginInfo = pluginInfo;
143
+        this.domain = domain;
135 144
     }
136 145
 
137 146
     /**
@@ -208,4 +217,11 @@ public class SwingManager {
208 217
         UIUtilities.invokeLater(feedbackNagProvider::get);
209 218
     }
210 219
 
220
+    @Handler
221
+    public void showConfig(final ClientPrefsOpenedEvent event) {
222
+        event.getModel().getCategory("GUI").addSubCategory(
223
+                new SwingPreferencesModel(pluginInfo, domain, event.getModel().getConfigManager(),
224
+                        event.getModel().getIdentity()).getSwingUICategory());
225
+    }
226
+
211 227
 }

+ 11
- 3
ui_swing/src/com/dmdirc/addons/ui_swing/injection/SwingModule.java Vedi File

@@ -59,6 +59,7 @@ import com.dmdirc.interfaces.LifecycleController;
59 59
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
60 60
 import com.dmdirc.interfaces.config.ConfigProvider;
61 61
 import com.dmdirc.plugins.PluginDomain;
62
+import com.dmdirc.plugins.PluginInfo;
62 63
 import com.dmdirc.plugins.ServiceLocator;
63 64
 import com.dmdirc.plugins.ServiceManager;
64 65
 import com.dmdirc.addons.ui_swing.components.IconManager;
@@ -89,15 +90,17 @@ import dagger.Provides;
89 90
             ServerSettings.class,
90 91
             ChannelSettings.class
91 92
         })
93
+@SuppressWarnings("TypeMayBeWeakened")
92 94
 public class SwingModule {
93 95
 
94
-    /** The controller to return to clients. */
95 96
     private final SwingController controller;
96
-    /** The domain for plugin settings. */
97
+    private final PluginInfo pluginInfo;
97 98
     private final String domain;
98 99
 
99
-    public SwingModule(final SwingController controller, final String domain) {
100
+    public SwingModule(final SwingController controller, final PluginInfo pluginInfo,
101
+            final String domain) {
100 102
         this.controller = controller;
103
+        this.pluginInfo = pluginInfo;
101 104
         this.domain = domain;
102 105
     }
103 106
 
@@ -213,4 +216,9 @@ public class SwingModule {
213 216
         return provider.getFrameManager();
214 217
     }
215 218
 
219
+    @Provides
220
+    public PluginInfo getPluginInfo() {
221
+        return pluginInfo;
222
+    }
223
+
216 224
 }

+ 34
- 1
windowstatus/src/com/dmdirc/addons/windowstatus/WindowStatusManager.java Vedi File

@@ -33,6 +33,12 @@ import com.dmdirc.addons.ui_swing.events.SwingWindowSelectedEvent;
33 33
 import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
34 34
 import com.dmdirc.config.ConfigBinder;
35 35
 import com.dmdirc.config.ConfigBinding;
36
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
37
+import com.dmdirc.config.prefs.PreferencesCategory;
38
+import com.dmdirc.config.prefs.PreferencesDialogModel;
39
+import com.dmdirc.config.prefs.PreferencesSetting;
40
+import com.dmdirc.config.prefs.PreferencesType;
41
+import com.dmdirc.events.ClientPrefsOpenedEvent;
36 42
 import com.dmdirc.events.StatusBarComponentAddedEvent;
37 43
 import com.dmdirc.events.StatusBarComponentRemovedEvent;
38 44
 import com.dmdirc.interfaces.Connection;
@@ -41,6 +47,7 @@ import com.dmdirc.interfaces.PrivateChat;
41 47
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
42 48
 import com.dmdirc.interfaces.ui.Window;
43 49
 import com.dmdirc.plugins.PluginDomain;
50
+import com.dmdirc.plugins.PluginInfo;
44 51
 
45 52
 import javax.inject.Inject;
46 53
 
@@ -53,6 +60,7 @@ public class WindowStatusManager {
53 60
 
54 61
     /** Active frame manager. */
55 62
     private final ActiveFrameManager activeFrameManager;
63
+    private final PluginInfo pluginInfo;
56 64
     /** Config to read settings from. */
57 65
     private final ConfigBinder configBinder;
58 66
     /** The event bus to post events to. */
@@ -73,8 +81,10 @@ public class WindowStatusManager {
73 81
             @GlobalConfig final AggregateConfigProvider config,
74 82
             @PluginDomain(WindowStatusPlugin.class) final String domain,
75 83
             final DMDircMBassador eventBus,
76
-            final SwingEventBus swingEventBus) {
84
+            final SwingEventBus swingEventBus,
85
+            final PluginInfo pluginInfo) {
77 86
         this.activeFrameManager = activeFrameManager;
87
+        this.pluginInfo = pluginInfo;
78 88
         this.configBinder = config.getBinder().withDefaultDomain(domain);
79 89
         this.eventBus = eventBus;
80 90
         this.swingEventBus = swingEventBus;
@@ -204,4 +214,27 @@ public class WindowStatusManager {
204 214
         nonePrefix = value;
205 215
         updateStatus();
206 216
     }
217
+
218
+    @Handler
219
+    public void showConfig(final ClientPrefsOpenedEvent event) {
220
+        final PreferencesDialogModel manager = event.getModel();
221
+        final PreferencesCategory category = new PluginPreferencesCategory(
222
+                pluginInfo, "Window status", "");
223
+
224
+        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
225
+                pluginInfo.getDomain(), "channel.shownone", "Show 'none' count",
226
+                "Should the count for users with no state be shown?",
227
+                manager.getConfigManager(), manager.getIdentity()));
228
+        category.addSetting(new PreferencesSetting(PreferencesType.TEXT,
229
+                pluginInfo.getDomain(), "channel.noneprefix", "'None' count prefix",
230
+                "The Prefix to use when showing the 'none' count",
231
+                manager.getConfigManager(), manager.getIdentity()));
232
+        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
233
+                pluginInfo.getDomain(), "client.showname", "Show real name",
234
+                "Should the realname for clients be shown if known?",
235
+                manager.getConfigManager(), manager.getIdentity()));
236
+
237
+        manager.getCategory("Plugins").addSubCategory(category);
238
+    }
239
+
207 240
 }

+ 5
- 0
windowstatus/src/com/dmdirc/addons/windowstatus/WindowStatusModule.java Vedi File

@@ -53,4 +53,9 @@ public class WindowStatusModule {
53 53
         return pluginInfo.getDomain();
54 54
     }
55 55
 
56
+    @Provides
57
+    public PluginInfo getPluginInfo() {
58
+        return pluginInfo;
59
+    }
60
+
56 61
 }

+ 0
- 32
windowstatus/src/com/dmdirc/addons/windowstatus/WindowStatusPlugin.java Vedi File

@@ -22,11 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.windowstatus;
24 24
 
25
-import com.dmdirc.config.prefs.PluginPreferencesCategory;
26
-import com.dmdirc.config.prefs.PreferencesCategory;
27
-import com.dmdirc.config.prefs.PreferencesDialogModel;
28
-import com.dmdirc.config.prefs.PreferencesSetting;
29
-import com.dmdirc.config.prefs.PreferencesType;
30 25
 import com.dmdirc.plugins.PluginInfo;
31 26
 import com.dmdirc.plugins.implementations.BasePlugin;
32 27
 
@@ -37,15 +32,9 @@ import dagger.ObjectGraph;
37 32
  */
38 33
 public class WindowStatusPlugin extends BasePlugin {
39 34
 
40
-    /** Plugin info. */
41
-    private final PluginInfo pluginInfo;
42 35
     /** Nick colour manager. */
43 36
     private WindowStatusManager windowStatusManager;
44 37
 
45
-    public WindowStatusPlugin(final PluginInfo pluginInfo) {
46
-        this.pluginInfo = pluginInfo;
47
-    }
48
-
49 38
     @Override
50 39
     public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
51 40
         super.load(pluginInfo, graph);
@@ -65,25 +54,4 @@ public class WindowStatusPlugin extends BasePlugin {
65 54
         windowStatusManager.onUnload();
66 55
     }
67 56
 
68
-    @Override
69
-    public void showConfig(final PreferencesDialogModel manager) {
70
-        final PreferencesCategory category = new PluginPreferencesCategory(
71
-                pluginInfo, "Window status", "");
72
-
73
-        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
74
-                pluginInfo.getDomain(), "channel.shownone", "Show 'none' count",
75
-                "Should the count for users with no state be shown?",
76
-                manager.getConfigManager(), manager.getIdentity()));
77
-        category.addSetting(new PreferencesSetting(PreferencesType.TEXT,
78
-                pluginInfo.getDomain(), "channel.noneprefix", "'None' count prefix",
79
-                "The Prefix to use when showing the 'none' count",
80
-                manager.getConfigManager(), manager.getIdentity()));
81
-        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
82
-                pluginInfo.getDomain(), "client.showname", "Show real name",
83
-                "Should the realname for clients be shown if known?",
84
-                manager.getConfigManager(), manager.getIdentity()));
85
-
86
-        manager.getCategory("Plugins").addSubCategory(category);
87
-    }
88
-
89 57
 }

Loading…
Annulla
Salva