Переглянути джерело

Merge pull request #289 from greboid/ned

Use events for showing config in some more plugins.
pull/293/head
Chris Smith 9 роки тому
джерело
коміт
a555bbde77
21 змінених файлів з 601 додано та 512 видалено
  1. 42
    1
      freedesktop_notifications/src/com/dmdirc/addons/freedesktop_notifications/FDManager.java
  2. 6
    0
      freedesktop_notifications/src/com/dmdirc/addons/freedesktop_notifications/FDModule.java
  3. 1
    38
      freedesktop_notifications/src/com/dmdirc/addons/freedesktop_notifications/FreeDesktopNotificationsPlugin.java
  4. 6
    0
      identd/src/com/dmdirc/addons/identd/IdentModule.java
  5. 85
    0
      identd/src/com/dmdirc/addons/identd/IdentdManager.java
  6. 0
    71
      identd/src/com/dmdirc/addons/identd/IdentdPlugin.java
  7. 37
    0
      lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayManager.java
  8. 11
    5
      lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayModule.java
  9. 1
    42
      lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayPlugin.java
  10. 87
    0
      logging/src/com/dmdirc/addons/logging/LoggingManager.java
  11. 11
    4
      logging/src/com/dmdirc/addons/logging/LoggingModule.java
  12. 1
    94
      logging/src/com/dmdirc/addons/logging/LoggingPlugin.java
  13. 164
    10
      osd/src/com/dmdirc/addons/osd/OsdManager.java
  14. 49
    0
      osd/src/com/dmdirc/addons/osd/OsdModule.java
  15. 9
    173
      osd/src/com/dmdirc/addons/osd/OsdPlugin.java
  16. 26
    0
      systray/src/com/dmdirc/addons/systray/SystrayManager.java
  17. 6
    0
      systray/src/com/dmdirc/addons/systray/SystrayModule.java
  18. 0
    32
      systray/src/com/dmdirc/addons/systray/SystrayPlugin.java
  19. 1
    42
      windowflashing/src/com/dmdirc/addons/windowflashing/WindowFlashing.java
  20. 43
    0
      windowflashing/src/com/dmdirc/addons/windowflashing/WindowFlashingManager.java
  21. 15
    0
      windowflashing/src/com/dmdirc/addons/windowflashing/WindowFlashingModule.java

+ 42
- 1
freedesktop_notifications/src/com/dmdirc/addons/freedesktop_notifications/FDManager.java Переглянути файл

@@ -25,12 +25,19 @@ package com.dmdirc.addons.freedesktop_notifications;
25 25
 import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.ClientModule.UserConfig;
27 27
 import com.dmdirc.DMDircMBassador;
28
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
29
+import com.dmdirc.config.prefs.PreferencesCategory;
30
+import com.dmdirc.config.prefs.PreferencesDialogModel;
31
+import com.dmdirc.config.prefs.PreferencesSetting;
32
+import com.dmdirc.config.prefs.PreferencesType;
33
+import com.dmdirc.events.ClientPrefsOpenedEvent;
28 34
 import com.dmdirc.events.UserErrorEvent;
29 35
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30 36
 import com.dmdirc.interfaces.config.ConfigChangeListener;
31 37
 import com.dmdirc.interfaces.config.ConfigProvider;
32 38
 import com.dmdirc.logger.ErrorLevel;
33 39
 import com.dmdirc.plugins.PluginDomain;
40
+import com.dmdirc.plugins.PluginInfo;
34 41
 import com.dmdirc.plugins.implementations.PluginFilesHelper;
35 42
 import com.dmdirc.ui.messages.Styliser;
36 43
 import com.dmdirc.util.io.StreamUtils;
@@ -43,6 +50,8 @@ import java.io.IOException;
43 50
 import javax.inject.Inject;
44 51
 import javax.inject.Singleton;
45 52
 
53
+import net.engio.mbassy.listener.Handler;
54
+
46 55
 @Singleton
47 56
 public class FDManager implements ConfigChangeListener {
48 57
 
@@ -56,6 +65,7 @@ public class FDManager implements ConfigChangeListener {
56 65
     private final PluginFilesHelper filesHelper;
57 66
     /** The event bus to post errors to. */
58 67
     private final DMDircMBassador eventBus;
68
+    private final PluginInfo pluginInfo;
59 69
     /** notification timeout. */
60 70
     private int timeout;
61 71
     /** notification icon. */
@@ -71,12 +81,14 @@ public class FDManager implements ConfigChangeListener {
71 81
             @UserConfig final ConfigProvider userConfig,
72 82
             @PluginDomain(FreeDesktopNotificationsPlugin.class) final String domain,
73 83
             final PluginFilesHelper filesHelper,
74
-            final DMDircMBassador eventBus) {
84
+            final DMDircMBassador eventBus,
85
+            @PluginDomain(FreeDesktopNotificationsPlugin.class) final PluginInfo pluginInfo) {
75 86
         this.domain = domain;
76 87
         this.config = config;
77 88
         this.userConfig = userConfig;
78 89
         this.filesHelper = filesHelper;
79 90
         this.eventBus = eventBus;
91
+        this.pluginInfo = pluginInfo;
80 92
     }
81 93
 
82 94
     /**
@@ -171,4 +183,33 @@ public class FDManager implements ConfigChangeListener {
171 183
         config.removeListener(this);
172 184
     }
173 185
 
186
+
187
+
188
+    @Handler
189
+    public void showConfig(final ClientPrefsOpenedEvent event) {
190
+        final PreferencesDialogModel manager = event.getModel();
191
+        final PreferencesCategory general = new PluginPreferencesCategory(
192
+                pluginInfo, "FreeDesktop Notifications",
193
+                "General configuration for FreeDesktop Notifications plugin.");
194
+
195
+        general.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
196
+                pluginInfo.getDomain(), "general.timeout", "Timeout",
197
+                "Length of time in seconds before the notification popup closes.",
198
+                manager.getConfigManager(), manager.getIdentity()));
199
+        general.addSetting(new PreferencesSetting(PreferencesType.FILE,
200
+                pluginInfo.getDomain(), "general.icon", "icon",
201
+                "Path to icon to use on the notification.",
202
+                manager.getConfigManager(), manager.getIdentity()));
203
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
204
+                pluginInfo.getDomain(), "advanced.escapehtml", "Escape HTML",
205
+                "Some Implementations randomly parse HTML, escape it before showing?",
206
+                manager.getConfigManager(), manager.getIdentity()));
207
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
208
+                pluginInfo.getDomain(), "advanced.stripcodes", "Strip Control Codes",
209
+                "Strip IRC Control codes from messages?",
210
+                manager.getConfigManager(), manager.getIdentity()));
211
+
212
+        manager.getCategory("Plugins").addSubCategory(general);
213
+    }
214
+
174 215
 }

+ 6
- 0
freedesktop_notifications/src/com/dmdirc/addons/freedesktop_notifications/FDModule.java Переглянути файл

@@ -54,4 +54,10 @@ public class FDModule {
54 54
         return new PluginFilesHelper(manager, pluginInfo);
55 55
     }
56 56
 
57
+    @Provides
58
+    @PluginDomain(FreeDesktopNotificationsPlugin.class)
59
+    public PluginInfo getPluginInfo() {
60
+        return pluginInfo;
61
+    }
62
+
57 63
 }

+ 1
- 38
freedesktop_notifications/src/com/dmdirc/addons/freedesktop_notifications/FreeDesktopNotificationsPlugin.java Переглянути файл

@@ -22,11 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.freedesktop_notifications;
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.Exported;
31 26
 import com.dmdirc.plugins.PluginInfo;
32 27
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
@@ -38,15 +33,9 @@ import dagger.ObjectGraph;
38 33
  */
39 34
 public class FreeDesktopNotificationsPlugin extends BaseCommandPlugin {
40 35
 
41
-    /** This plugin's plugin info. */
42
-    private final PluginInfo pluginInfo;
43 36
     /** Manager to show notifications. */
44 37
     private FDManager manager;
45 38
 
46
-    public FreeDesktopNotificationsPlugin(final PluginInfo pluginInfo) {
47
-        this.pluginInfo = pluginInfo;
48
-    }
49
-
50 39
     @Override
51 40
     public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
52 41
         super.load(pluginInfo, graph);
@@ -81,35 +70,9 @@ public class FreeDesktopNotificationsPlugin extends BaseCommandPlugin {
81 70
      * Called when this plugin is Unloaded.
82 71
      */
83 72
     @Override
84
-    public synchronized void onUnload() {
73
+    public void onUnload() {
85 74
         manager.onUnLoad();
86 75
         super.onUnload();
87 76
     }
88 77
 
89
-    @Override
90
-    public void showConfig(final PreferencesDialogModel manager) {
91
-        final PreferencesCategory general = new PluginPreferencesCategory(
92
-                pluginInfo, "FreeDesktop Notifications",
93
-                "General configuration for FreeDesktop Notifications plugin.");
94
-
95
-        general.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
96
-                pluginInfo.getDomain(), "general.timeout", "Timeout",
97
-                "Length of time in seconds before the notification popup closes.",
98
-                manager.getConfigManager(), manager.getIdentity()));
99
-        general.addSetting(new PreferencesSetting(PreferencesType.FILE,
100
-                pluginInfo.getDomain(), "general.icon", "icon",
101
-                "Path to icon to use on the notification.",
102
-                manager.getConfigManager(), manager.getIdentity()));
103
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
104
-                pluginInfo.getDomain(), "advanced.escapehtml", "Escape HTML",
105
-                "Some Implementations randomly parse HTML, escape it before showing?",
106
-                manager.getConfigManager(), manager.getIdentity()));
107
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
108
-                pluginInfo.getDomain(), "advanced.stripcodes", "Strip Control Codes",
109
-                "Strip IRC Control codes from messages?",
110
-                manager.getConfigManager(), manager.getIdentity()));
111
-
112
-        manager.getCategory("Plugins").addSubCategory(general);
113
-    }
114
-
115 78
 }

+ 6
- 0
identd/src/com/dmdirc/addons/identd/IdentModule.java Переглянути файл

@@ -44,4 +44,10 @@ public class IdentModule {
44 44
         return pluginInfo.getDomain();
45 45
     }
46 46
 
47
+    @Provides
48
+    @PluginDomain(IdentdPlugin.class)
49
+    public PluginInfo getPluginInfo() {
50
+        return pluginInfo;
51
+    }
52
+
47 53
 }

+ 85
- 0
identd/src/com/dmdirc/addons/identd/IdentdManager.java Переглянути файл

@@ -24,12 +24,20 @@ package com.dmdirc.addons.identd;
24 24
 
25 25
 import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.DMDircMBassador;
27
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
28
+import com.dmdirc.config.prefs.PreferencesCategory;
29
+import com.dmdirc.config.prefs.PreferencesDialogModel;
30
+import com.dmdirc.config.prefs.PreferencesSetting;
31
+import com.dmdirc.config.prefs.PreferencesType;
32
+import com.dmdirc.events.ClientPrefsOpenedEvent;
27 33
 import com.dmdirc.events.ServerConnectErrorEvent;
28 34
 import com.dmdirc.events.ServerConnectedEvent;
29 35
 import com.dmdirc.events.ServerConnectingEvent;
30 36
 import com.dmdirc.interfaces.Connection;
31 37
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
32 38
 import com.dmdirc.plugins.PluginDomain;
39
+import com.dmdirc.plugins.PluginInfo;
40
+import com.dmdirc.util.validators.PortValidator;
33 41
 
34 42
 import java.util.ArrayList;
35 43
 import java.util.List;
@@ -50,11 +58,14 @@ public class IdentdManager {
50 58
     private final IdentdServer server;
51 59
     /** Event bus to subscribe to events on. */
52 60
     private final DMDircMBassador eventBus;
61
+    private final PluginInfo pluginInfo;
53 62
 
54 63
     @Inject
55 64
     public IdentdManager(@GlobalConfig final AggregateConfigProvider config,
56 65
             @PluginDomain(IdentdPlugin.class) final String domain,
66
+            @PluginDomain(IdentdPlugin.class) final PluginInfo pluginInfo,
57 67
             final IdentdServer server, final DMDircMBassador eventBus) {
68
+        this.pluginInfo = pluginInfo;
58 69
         connections = new ArrayList<>();
59 70
         this.config = config;
60 71
         this.domain = domain;
@@ -113,4 +124,78 @@ public class IdentdManager {
113 124
             }
114 125
     }
115 126
 
127
+
128
+
129
+    @Handler
130
+    public void showConfig(final ClientPrefsOpenedEvent event) {
131
+        final PreferencesDialogModel manager = event.getModel();
132
+        final PreferencesCategory general = new PluginPreferencesCategory(
133
+                pluginInfo, "Identd",
134
+                "General Identd Plugin config ('Lower' options take priority "
135
+                        + "over those above them)");
136
+        final PreferencesCategory advanced = new PluginPreferencesCategory(
137
+                pluginInfo, "Advanced",
138
+                "Advanced Identd Plugin config - Only edit these if you need "
139
+                        + "to/know what you are doing. Editing these could prevent "
140
+                        + "access to some servers. ('Lower' options take priority over "
141
+                        + "those above them)");
142
+
143
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
144
+                domain, "general.useUsername", "Use connection "
145
+                + "username rather than system username", "If this is enabled,"
146
+                + " the username for the connection will be used rather than '"
147
+                + System.getProperty("user.name") + '\'',
148
+                manager.getConfigManager(), manager.getIdentity()));
149
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
150
+                domain, "general.useNickname", "Use connection "
151
+                + "nickname rather than system username", "If this is enabled, "
152
+                + "the nickname for the connection will be used rather than '"
153
+                + System.getProperty("user.name") + '\'',
154
+                manager.getConfigManager(), manager.getIdentity()));
155
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
156
+                domain, "general.useCustomName", "Use custom name" + " all the time",
157
+                "If this is enabled, the name specified below" + " will be used all the time",
158
+                manager.getConfigManager(),
159
+                manager.getIdentity()));
160
+        general.addSetting(new PreferencesSetting(PreferencesType.TEXT,
161
+                domain, "general.customName", "Custom Name to use",
162
+                "The custom name to use when 'Use Custom Name' is enabled",
163
+                manager.getConfigManager(), manager.getIdentity()));
164
+        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
165
+                domain, "advanced.alwaysOn", "Always have ident " + "port open",
166
+                "By default the identd only runs when there are "
167
+                        + "active connection attempts. This overrides that.",
168
+                manager.getConfigManager(), manager.getIdentity()));
169
+        advanced.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
170
+                new PortValidator(), domain, "advanced.port",
171
+                "What port should the identd listen on", "Default port is 113,"
172
+                + " this is probably useless if changed unless you port forward"
173
+                + " ident to a different port", manager.getConfigManager(),
174
+                manager.getIdentity()));
175
+        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
176
+                domain, "advanced.useCustomSystem", "Use custom OS",
177
+                "By default the plugin uses 'UNIX' or 'WIN32' as the system "
178
+                        + "type, this can be overridden by enabling this.",
179
+                manager.getConfigManager(), manager.getIdentity()));
180
+        advanced.addSetting(new PreferencesSetting(PreferencesType.TEXT,
181
+                domain, "advanced.customSystem", "Custom OS to use",
182
+                "The custom system to use when 'Use Custom System' is enabled",
183
+                manager.getConfigManager(), manager.getIdentity()));
184
+        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
185
+                domain, "advanced.isHiddenUser", "Respond to ident"
186
+                + " requests with HIDDEN-USER error", "By default the plugin will"
187
+                + " give a USERID response, this can force an 'ERROR :"
188
+                + " HIDDEN-USER' response instead.", manager.getConfigManager(),
189
+                manager.getIdentity()));
190
+        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
191
+                domain, "advanced.isNoUser", "Respond to ident"
192
+                + " requests with NO-USER error", "By default the plugin will"
193
+                + " give a USERID response, this can force an 'ERROR : NO-USER'"
194
+                + " response instead. (Overrides HIDDEN-USER)",
195
+                manager.getConfigManager(), manager.getIdentity()));
196
+
197
+        manager.getCategory("Plugins").addSubCategory(general);
198
+        general.addSubCategory(advanced);
199
+    }
200
+
116 201
 }

+ 0
- 71
identd/src/com/dmdirc/addons/identd/IdentdPlugin.java Переглянути файл

@@ -74,75 +74,4 @@ public class IdentdPlugin extends BasePlugin {
74 74
         identdManager.onLoad();
75 75
     }
76 76
 
77
-    @Override
78
-    public void showConfig(final PreferencesDialogModel manager) {
79
-        final PreferencesCategory general = new PluginPreferencesCategory(
80
-                pluginInfo, "Identd",
81
-                "General Identd Plugin config ('Lower' options take priority "
82
-                + "over those above them)");
83
-        final PreferencesCategory advanced = new PluginPreferencesCategory(
84
-                pluginInfo, "Advanced",
85
-                "Advanced Identd Plugin config - Only edit these if you need "
86
-                + "to/know what you are doing. Editing these could prevent "
87
-                + "access to some servers. ('Lower' options take priority over "
88
-                + "those above them)");
89
-
90
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
91
-                domain, "general.useUsername", "Use connection "
92
-                + "username rather than system username", "If this is enabled,"
93
-                + " the username for the connection will be used rather than '"
94
-                + System.getProperty("user.name") + '\'',
95
-                manager.getConfigManager(), manager.getIdentity()));
96
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
97
-                domain, "general.useNickname", "Use connection "
98
-                + "nickname rather than system username", "If this is enabled, "
99
-                + "the nickname for the connection will be used rather than '"
100
-                + System.getProperty("user.name") + '\'',
101
-                manager.getConfigManager(), manager.getIdentity()));
102
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
103
-                domain, "general.useCustomName", "Use custom name" + " all the time",
104
-                "If this is enabled, the name specified below" + " will be used all the time",
105
-                manager.getConfigManager(),
106
-                manager.getIdentity()));
107
-        general.addSetting(new PreferencesSetting(PreferencesType.TEXT,
108
-                domain, "general.customName", "Custom Name to use",
109
-                "The custom name to use when 'Use Custom Name' is enabled",
110
-                manager.getConfigManager(), manager.getIdentity()));
111
-        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
112
-                domain, "advanced.alwaysOn", "Always have ident " + "port open",
113
-                "By default the identd only runs when there are "
114
-                + "active connection attempts. This overrides that.",
115
-                manager.getConfigManager(), manager.getIdentity()));
116
-        advanced.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
117
-                new PortValidator(), domain, "advanced.port",
118
-                "What port should the identd listen on", "Default port is 113,"
119
-                + " this is probably useless if changed unless you port forward"
120
-                + " ident to a different port", manager.getConfigManager(),
121
-                manager.getIdentity()));
122
-        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
123
-                domain, "advanced.useCustomSystem", "Use custom OS",
124
-                "By default the plugin uses 'UNIX' or 'WIN32' as the system "
125
-                + "type, this can be overridden by enabling this.",
126
-                manager.getConfigManager(), manager.getIdentity()));
127
-        advanced.addSetting(new PreferencesSetting(PreferencesType.TEXT,
128
-                domain, "advanced.customSystem", "Custom OS to use",
129
-                "The custom system to use when 'Use Custom System' is enabled",
130
-                manager.getConfigManager(), manager.getIdentity()));
131
-        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
132
-                domain, "advanced.isHiddenUser", "Respond to ident"
133
-                + " requests with HIDDEN-USER error", "By default the plugin will"
134
-                + " give a USERID response, this can force an 'ERROR :"
135
-                + " HIDDEN-USER' response instead.", manager.getConfigManager(),
136
-                manager.getIdentity()));
137
-        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
138
-                domain, "advanced.isNoUser", "Respond to ident"
139
-                + " requests with NO-USER error", "By default the plugin will"
140
-                + " give a USERID response, this can force an 'ERROR : NO-USER'"
141
-                + " response instead. (Overrides HIDDEN-USER)",
142
-                manager.getConfigManager(), manager.getIdentity()));
143
-
144
-        manager.getCategory("Plugins").addSubCategory(general);
145
-        general.addSubCategory(advanced);
146
-    }
147
-
148 77
 }

+ 37
- 0
lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayManager.java Переглянути файл

@@ -31,6 +31,12 @@ import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
31 31
 import com.dmdirc.addons.ui_swing.events.SwingEventBus;
32 32
 import com.dmdirc.addons.ui_swing.events.SwingWindowSelectedEvent;
33 33
 import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
34
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
35
+import com.dmdirc.config.prefs.PreferencesCategory;
36
+import com.dmdirc.config.prefs.PreferencesDialogModel;
37
+import com.dmdirc.config.prefs.PreferencesSetting;
38
+import com.dmdirc.config.prefs.PreferencesType;
39
+import com.dmdirc.events.ClientPrefsOpenedEvent;
34 40
 import com.dmdirc.events.ServerDisconnectedEvent;
35 41
 import com.dmdirc.events.ServerGotPingEvent;
36 42
 import com.dmdirc.events.ServerNoPingEvent;
@@ -42,6 +48,7 @@ import com.dmdirc.interfaces.Connection;
42 48
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
43 49
 import com.dmdirc.interfaces.config.ConfigChangeListener;
44 50
 import com.dmdirc.plugins.PluginDomain;
51
+import com.dmdirc.plugins.PluginInfo;
45 52
 import com.dmdirc.util.collections.RollingList;
46 53
 
47 54
 import java.util.Date;
@@ -71,6 +78,7 @@ public class LagDisplayManager implements ConfigChangeListener {
71 78
     private final Provider<LagDisplayPanel> panelProvider;
72 79
     /** The settings domain to use. */
73 80
     private final String domain;
81
+    private final PluginInfo pluginInfo;
74 82
     /** Config to read global settings from. */
75 83
     private final AggregateConfigProvider globalConfig;
76 84
     /** A cache of ping times. */
@@ -92,12 +100,14 @@ public class LagDisplayManager implements ConfigChangeListener {
92 100
             final ActiveFrameManager activeFrameManager,
93 101
             final Provider<LagDisplayPanel> panelProvider,
94 102
             @PluginDomain(LagDisplayPlugin.class) final String domain,
103
+            @PluginDomain(LagDisplayPlugin.class) final PluginInfo pluginInfo,
95 104
             @GlobalConfig final AggregateConfigProvider globalConfig) {
96 105
         this.eventBus = eventBus;
97 106
         this.swingEventBus = swingEventBus;
98 107
         this.activeFrameManager = activeFrameManager;
99 108
         this.panelProvider = panelProvider;
100 109
         this.domain = domain;
110
+        this.pluginInfo = pluginInfo;
101 111
         this.globalConfig = globalConfig;
102 112
     }
103 113
 
@@ -299,4 +309,31 @@ public class LagDisplayManager implements ConfigChangeListener {
299 309
                 .filter(connection::equals).isPresent();
300 310
     }
301 311
 
312
+
313
+
314
+    @Handler
315
+    public void showConfig(final ClientPrefsOpenedEvent event) {
316
+        final PreferencesDialogModel manager = event.getModel();
317
+        final PreferencesCategory cat = new PluginPreferencesCategory(
318
+                pluginInfo, "Lag display plugin", "");
319
+        cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
320
+                pluginInfo.getDomain(), "usealternate",
321
+                "Alternate method", "Use an alternate method of determining "
322
+                + "lag which bypasses bouncers or proxies that may reply?",
323
+                manager.getConfigManager(), manager.getIdentity()));
324
+        cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
325
+                pluginInfo.getDomain(), "graph", "Show graph", "Show a graph of ping times "
326
+                + "for the current server in the information popup?",
327
+                manager.getConfigManager(), manager.getIdentity()));
328
+        cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
329
+                pluginInfo.getDomain(), "labels", "Show labels", "Show labels on selected "
330
+                + "points on the ping graph?",
331
+                manager.getConfigManager(), manager.getIdentity()));
332
+        cat.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
333
+                pluginInfo.getDomain(), "history", "Graph points", "Number of data points "
334
+                + "to plot on the graph, if enabled.",
335
+                manager.getConfigManager(), manager.getIdentity()));
336
+        manager.getCategory("Plugins").addSubCategory(cat);
337
+    }
338
+
302 339
 }

+ 11
- 5
lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayModule.java Переглянути файл

@@ -24,6 +24,7 @@ package com.dmdirc.addons.lagdisplay;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.injection.SwingModule;
26 26
 import com.dmdirc.plugins.PluginDomain;
27
+import com.dmdirc.plugins.PluginInfo;
27 28
 
28 29
 import dagger.Module;
29 30
 import dagger.Provides;
@@ -34,17 +35,22 @@ import dagger.Provides;
34 35
 @Module(injects = LagDisplayManager.class, addsTo = SwingModule.class)
35 36
 public class LagDisplayModule {
36 37
 
37
-    /** The domain for plugin settings. */
38
-    private final String domain;
38
+    private final PluginInfo pluginInfo;
39 39
 
40
-    public LagDisplayModule(final String domain) {
41
-        this.domain = domain;
40
+    public LagDisplayModule(final PluginInfo pluginInfo) {
41
+        this.pluginInfo = pluginInfo;
42 42
     }
43 43
 
44 44
     @Provides
45 45
     @PluginDomain(LagDisplayPlugin.class)
46 46
     public String getDomain() {
47
-        return domain;
47
+        return pluginInfo.getDomain();
48
+    }
49
+
50
+    @Provides
51
+    @PluginDomain(LagDisplayPlugin.class)
52
+    public PluginInfo getPluginInfo() {
53
+        return pluginInfo;
48 54
     }
49 55
 
50 56
 }

+ 1
- 42
lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayPlugin.java Переглянути файл

@@ -22,11 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.lagdisplay;
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,25 +32,14 @@ import dagger.ObjectGraph;
37 32
  */
38 33
 public final class LagDisplayPlugin extends BasePlugin {
39 34
 
40
-    /** This plugin's plugin info. */
41
-    private final PluginInfo pluginInfo;
42 35
     /** The manager currently in use. */
43 36
     private LagDisplayManager manager;
44 37
 
45
-    /**
46
-     * Creates a new LagDisplayPlugin.
47
-     *
48
-     * @param pluginInfo This plugin's plugin info
49
-     */
50
-    public LagDisplayPlugin(final PluginInfo pluginInfo) {
51
-        this.pluginInfo = pluginInfo;
52
-    }
53
-
54 38
     @Override
55 39
     public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
56 40
         super.load(pluginInfo, graph);
57 41
 
58
-        setObjectGraph(graph.plus(new LagDisplayModule(pluginInfo.getDomain())));
42
+        setObjectGraph(graph.plus(new LagDisplayModule(pluginInfo)));
59 43
         manager = getObjectGraph().get(LagDisplayManager.class);
60 44
     }
61 45
 
@@ -68,29 +52,4 @@ public final class LagDisplayPlugin extends BasePlugin {
68 52
     public void onUnload() {
69 53
         manager.unload();
70 54
     }
71
-
72
-    @Override
73
-    public void showConfig(final PreferencesDialogModel manager) {
74
-        final PreferencesCategory cat = new PluginPreferencesCategory(
75
-                pluginInfo, "Lag display plugin", "");
76
-        cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
77
-                pluginInfo.getDomain(), "usealternate",
78
-                "Alternate method", "Use an alternate method of determining "
79
-                + "lag which bypasses bouncers or proxies that may reply?",
80
-                manager.getConfigManager(), manager.getIdentity()));
81
-        cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
82
-                pluginInfo.getDomain(), "graph", "Show graph", "Show a graph of ping times "
83
-                + "for the current server in the information popup?",
84
-                manager.getConfigManager(), manager.getIdentity()));
85
-        cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
86
-                pluginInfo.getDomain(), "labels", "Show labels", "Show labels on selected "
87
-                + "points on the ping graph?",
88
-                manager.getConfigManager(), manager.getIdentity()));
89
-        cat.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
90
-                pluginInfo.getDomain(), "history", "Graph points", "Number of data points "
91
-                + "to plot on the graph, if enabled.",
92
-                manager.getConfigManager(), manager.getIdentity()));
93
-        manager.getCategory("Plugins").addSubCategory(cat);
94
-    }
95
-
96 55
 }

+ 87
- 0
logging/src/com/dmdirc/addons/logging/LoggingManager.java Переглянути файл

@@ -27,6 +27,11 @@ import com.dmdirc.DMDircMBassador;
27 27
 import com.dmdirc.FrameContainer;
28 28
 import com.dmdirc.Query;
29 29
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
30
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
31
+import com.dmdirc.config.prefs.PreferencesCategory;
32
+import com.dmdirc.config.prefs.PreferencesDialogModel;
33
+import com.dmdirc.config.prefs.PreferencesSetting;
34
+import com.dmdirc.config.prefs.PreferencesType;
30 35
 import com.dmdirc.events.BaseChannelActionEvent;
31 36
 import com.dmdirc.events.BaseChannelMessageEvent;
32 37
 import com.dmdirc.events.BaseQueryActionEvent;
@@ -41,6 +46,7 @@ import com.dmdirc.events.ChannelOpenedEvent;
41 46
 import com.dmdirc.events.ChannelPartEvent;
42 47
 import com.dmdirc.events.ChannelQuitEvent;
43 48
 import com.dmdirc.events.ChannelTopicChangeEvent;
49
+import com.dmdirc.events.ClientPrefsOpenedEvent;
44 50
 import com.dmdirc.events.QueryClosedEvent;
45 51
 import com.dmdirc.events.QueryOpenedEvent;
46 52
 import com.dmdirc.events.UserErrorEvent;
@@ -52,6 +58,7 @@ import com.dmdirc.interfaces.config.AggregateConfigProvider;
52 58
 import com.dmdirc.interfaces.config.ConfigChangeListener;
53 59
 import com.dmdirc.logger.ErrorLevel;
54 60
 import com.dmdirc.plugins.PluginDomain;
61
+import com.dmdirc.plugins.PluginInfo;
55 62
 import com.dmdirc.ui.WindowManager;
56 63
 import com.dmdirc.ui.messages.BackBufferFactory;
57 64
 import com.dmdirc.ui.messages.Styliser;
@@ -97,6 +104,7 @@ public class LoggingManager implements ConfigChangeListener {
97 104
     private static final Object FORMAT_LOCK = new Object();
98 105
     /** This plugin's plugin info. */
99 106
     private final String domain;
107
+    private final PluginInfo pluginInfo;
100 108
     /** Global config. */
101 109
     private final AggregateConfigProvider config;
102 110
     /** The manager to add history windows to. */
@@ -125,12 +133,14 @@ public class LoggingManager implements ConfigChangeListener {
125 133
 
126 134
     @Inject
127 135
     public LoggingManager(@PluginDomain(LoggingPlugin.class) final String domain,
136
+            @PluginDomain(LoggingPlugin.class) final PluginInfo pluginInfo,
128 137
             @GlobalConfig final AggregateConfigProvider globalConfig,
129 138
             final WindowManager windowManager, final DMDircMBassador eventBus,
130 139
             @Directory(LoggingModule.LOGS_DIRECTORY) final Provider<String> directoryProvider,
131 140
             final BackBufferFactory backBufferFactory,
132 141
             final LogFileLocator locator) {
133 142
         this.domain = domain;
143
+        this.pluginInfo = pluginInfo;
134 144
         this.config = globalConfig;
135 145
         this.windowManager = windowManager;
136 146
         this.eventBus = eventBus;
@@ -603,6 +613,83 @@ public class LoggingManager implements ConfigChangeListener {
603 613
         backbufferLines = config.getOptionInt(domain, "backbuffer.lines");
604 614
     }
605 615
 
616
+    @Handler
617
+    public void showConfig(final ClientPrefsOpenedEvent event) {
618
+        final PreferencesDialogModel manager = event.getModel();
619
+        final PreferencesCategory general = new PluginPreferencesCategory(
620
+                pluginInfo, "Logging", "General configuration for Logging plugin.");
621
+        final PreferencesCategory backbuffer = new PluginPreferencesCategory(
622
+                pluginInfo, "Back Buffer", "Options related to the automatic backbuffer");
623
+        final PreferencesCategory advanced = new PluginPreferencesCategory(
624
+                pluginInfo, "Advanced",
625
+                "Advanced configuration for Logging plugin. You shouldn't need to edit this unless you know what you are doing.");
626
+
627
+        general.addSetting(new PreferencesSetting(PreferencesType.DIRECTORY,
628
+                pluginInfo.getDomain(), "general.directory", "Directory",
629
+                "Directory for log files", manager.getConfigManager(),
630
+                manager.getIdentity()));
631
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
632
+                pluginInfo.getDomain(), "general.networkfolders",
633
+                "Separate logs by network",
634
+                "Should the files be stored in a sub-dir with the networks name?",
635
+                manager.getConfigManager(), manager.getIdentity()));
636
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
637
+                pluginInfo.getDomain(), "general.addtime", "Timestamp logs",
638
+                "Should a timestamp be added to the log files?",
639
+                manager.getConfigManager(), manager.getIdentity()));
640
+        general.addSetting(new PreferencesSetting(PreferencesType.TEXT,
641
+                pluginInfo.getDomain(), "general.timestamp", "Timestamp format",
642
+                "The String to pass to 'SimpleDateFormat' to format the timestamp",
643
+                manager.getConfigManager(), manager.getIdentity()));
644
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
645
+                pluginInfo.getDomain(), "general.stripcodes", "Strip Control Codes",
646
+                "Remove known irc control codes from lines before saving?",
647
+                manager.getConfigManager(), manager.getIdentity()));
648
+        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
649
+                pluginInfo.getDomain(), "general.channelmodeprefix",
650
+                "Show channel mode prefix", "Show the @,+ etc next to nicknames",
651
+                manager.getConfigManager(), manager.getIdentity()));
652
+
653
+        backbuffer.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
654
+                pluginInfo.getDomain(), "backbuffer.autobackbuffer", "Automatically display",
655
+                "Automatically display the backbuffer when a channel is joined",
656
+                manager.getConfigManager(), manager.getIdentity()));
657
+        backbuffer.addSetting(new PreferencesSetting(PreferencesType.COLOUR,
658
+                pluginInfo.getDomain(), "backbuffer.colour", "Colour to use for display",
659
+                "Colour used when displaying the backbuffer",
660
+                manager.getConfigManager(), manager.getIdentity()));
661
+        backbuffer.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
662
+                pluginInfo.getDomain(), "backbuffer.lines", "Number of lines to show",
663
+                "Number of lines used when displaying backbuffer",
664
+                manager.getConfigManager(), manager.getIdentity()));
665
+        backbuffer.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
666
+                pluginInfo.getDomain(), "backbuffer.timestamp", "Show Formatter-Timestamp",
667
+                "Should the line be added to the frame with the timestamp from "
668
+                        + "the formatter aswell as the file contents",
669
+                manager.getConfigManager(), manager.getIdentity()));
670
+
671
+        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
672
+                pluginInfo.getDomain(), "advanced.filenamehash", "Add Filename hash",
673
+                "Add the MD5 hash of the channel/client name to the filename. "
674
+                        + "(This is used to allow channels with similar names "
675
+                        + "(ie a _ not a  -) to be logged separately)",
676
+                manager.getConfigManager(), manager.getIdentity()));
677
+
678
+        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
679
+                pluginInfo.getDomain(), "advanced.usedate", "Use Date directories",
680
+                "Should the log files be in separate directories based on the date?",
681
+                manager.getConfigManager(), manager.getIdentity()));
682
+        advanced.addSetting(new PreferencesSetting(PreferencesType.TEXT,
683
+                pluginInfo.getDomain(), "advanced.usedateformat", "Archive format",
684
+                "The String to pass to 'SimpleDateFormat' to format the "
685
+                        + "directory name(s) for archiving",
686
+                manager.getConfigManager(), manager.getIdentity()));
687
+
688
+        general.addSubCategory(backbuffer.setInline());
689
+        general.addSubCategory(advanced.setInline());
690
+        manager.getCategory("Plugins").addSubCategory(general.setInlineAfter());
691
+    }
692
+
606 693
     /** Open File. */
607 694
     private static class OpenFile {
608 695
 

+ 11
- 4
logging/src/com/dmdirc/addons/logging/LoggingModule.java Переглянути файл

@@ -30,6 +30,7 @@ import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
30 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31 31
 import com.dmdirc.interfaces.config.ConfigProvider;
32 32
 import com.dmdirc.plugins.PluginDomain;
33
+import com.dmdirc.plugins.PluginInfo;
33 34
 
34 35
 import java.io.File;
35 36
 
@@ -44,16 +45,16 @@ public class LoggingModule {
44 45
 
45 46
     public static final String LOGS_DIRECTORY = "logs";
46 47
 
47
-    private final String domain;
48
+    private final PluginInfo pluginInfo;
48 49
 
49
-    public LoggingModule(final String domain) {
50
-        this.domain = domain;
50
+    public LoggingModule(final PluginInfo pluginInfo) {
51
+        this.pluginInfo = pluginInfo;
51 52
     }
52 53
 
53 54
     @Provides
54 55
     @PluginDomain(LoggingPlugin.class)
55 56
     public String getDomain() {
56
-        return domain;
57
+        return pluginInfo.getDomain();
57 58
     }
58 59
 
59 60
     @Provides
@@ -72,4 +73,10 @@ public class LoggingModule {
72 73
         return globalConfig.getOptionString(domain, "general.directory");
73 74
     }
74 75
 
76
+    @Provides
77
+    @PluginDomain(LoggingPlugin.class)
78
+    public PluginInfo getPluginInfo() {
79
+        return pluginInfo;
80
+    }
81
+
75 82
 }

+ 1
- 94
logging/src/com/dmdirc/addons/logging/LoggingPlugin.java Переглянути файл

@@ -22,11 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.logging;
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.BaseCommandPlugin;
32 27
 
@@ -37,26 +32,14 @@ import dagger.ObjectGraph;
37 32
  */
38 33
 public class LoggingPlugin extends BaseCommandPlugin {
39 34
 
40
-    /** This plugin's plugin info. */
41
-    private final PluginInfo pluginInfo;
42
-
43 35
     /** The manager in use. */
44 36
     private LoggingManager manager;
45 37
 
46
-    /**
47
-     * Creates a new instance of this plugin.
48
-     *
49
-     * @param pluginInfo This plugin's plugin info
50
-     */
51
-    public LoggingPlugin(final PluginInfo pluginInfo) {
52
-        this.pluginInfo = pluginInfo;
53
-    }
54
-
55 38
     @Override
56 39
     public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
57 40
         super.load(pluginInfo, graph);
58 41
 
59
-        setObjectGraph(graph.plus(new LoggingModule(pluginInfo.getDomain())));
42
+        setObjectGraph(graph.plus(new LoggingModule(pluginInfo)));
60 43
         manager = getObjectGraph().get(LoggingManager.class);
61 44
 
62 45
         registerCommand(LoggingCommand.class, LoggingCommand.INFO);
@@ -74,80 +57,4 @@ public class LoggingPlugin extends BaseCommandPlugin {
74 57
         manager.unload();
75 58
     }
76 59
 
77
-    @Override
78
-    public void showConfig(final PreferencesDialogModel manager) {
79
-        final PreferencesCategory general = new PluginPreferencesCategory(
80
-                pluginInfo, "Logging", "General configuration for Logging plugin.");
81
-        final PreferencesCategory backbuffer = new PluginPreferencesCategory(
82
-                pluginInfo, "Back Buffer", "Options related to the automatic backbuffer");
83
-        final PreferencesCategory advanced = new PluginPreferencesCategory(
84
-                pluginInfo, "Advanced",
85
-                "Advanced configuration for Logging plugin. You shouldn't need to edit this unless you know what you are doing.");
86
-
87
-        general.addSetting(new PreferencesSetting(PreferencesType.DIRECTORY,
88
-                pluginInfo.getDomain(), "general.directory", "Directory",
89
-                "Directory for log files", manager.getConfigManager(),
90
-                manager.getIdentity()));
91
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
92
-                pluginInfo.getDomain(), "general.networkfolders",
93
-                "Separate logs by network",
94
-                "Should the files be stored in a sub-dir with the networks name?",
95
-                manager.getConfigManager(), manager.getIdentity()));
96
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
97
-                pluginInfo.getDomain(), "general.addtime", "Timestamp logs",
98
-                "Should a timestamp be added to the log files?",
99
-                manager.getConfigManager(), manager.getIdentity()));
100
-        general.addSetting(new PreferencesSetting(PreferencesType.TEXT,
101
-                pluginInfo.getDomain(), "general.timestamp", "Timestamp format",
102
-                "The String to pass to 'SimpleDateFormat' to format the timestamp",
103
-                manager.getConfigManager(), manager.getIdentity()));
104
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
105
-                pluginInfo.getDomain(), "general.stripcodes", "Strip Control Codes",
106
-                "Remove known irc control codes from lines before saving?",
107
-                manager.getConfigManager(), manager.getIdentity()));
108
-        general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
109
-                pluginInfo.getDomain(), "general.channelmodeprefix",
110
-                "Show channel mode prefix", "Show the @,+ etc next to nicknames",
111
-                manager.getConfigManager(), manager.getIdentity()));
112
-
113
-        backbuffer.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
114
-                pluginInfo.getDomain(), "backbuffer.autobackbuffer", "Automatically display",
115
-                "Automatically display the backbuffer when a channel is joined",
116
-                manager.getConfigManager(), manager.getIdentity()));
117
-        backbuffer.addSetting(new PreferencesSetting(PreferencesType.COLOUR,
118
-                pluginInfo.getDomain(), "backbuffer.colour", "Colour to use for display",
119
-                "Colour used when displaying the backbuffer",
120
-                manager.getConfigManager(), manager.getIdentity()));
121
-        backbuffer.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
122
-                pluginInfo.getDomain(), "backbuffer.lines", "Number of lines to show",
123
-                "Number of lines used when displaying backbuffer",
124
-                manager.getConfigManager(), manager.getIdentity()));
125
-        backbuffer.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
126
-                pluginInfo.getDomain(), "backbuffer.timestamp", "Show Formatter-Timestamp",
127
-                "Should the line be added to the frame with the timestamp from "
128
-                + "the formatter aswell as the file contents",
129
-                manager.getConfigManager(), manager.getIdentity()));
130
-
131
-        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
132
-                pluginInfo.getDomain(), "advanced.filenamehash", "Add Filename hash",
133
-                "Add the MD5 hash of the channel/client name to the filename. "
134
-                + "(This is used to allow channels with similar names "
135
-                + "(ie a _ not a  -) to be logged separately)",
136
-                manager.getConfigManager(), manager.getIdentity()));
137
-
138
-        advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
139
-                pluginInfo.getDomain(), "advanced.usedate", "Use Date directories",
140
-                "Should the log files be in separate directories based on the date?",
141
-                manager.getConfigManager(), manager.getIdentity()));
142
-        advanced.addSetting(new PreferencesSetting(PreferencesType.TEXT,
143
-                pluginInfo.getDomain(), "advanced.usedateformat", "Archive format",
144
-                "The String to pass to 'SimpleDateFormat' to format the "
145
-                + "directory name(s) for archiving",
146
-                manager.getConfigManager(), manager.getIdentity()));
147
-
148
-        general.addSubCategory(backbuffer.setInline());
149
-        general.addSubCategory(advanced.setInline());
150
-        manager.getCategory("Plugins").addSubCategory(general.setInlineAfter());
151
-    }
152
-
153 60
 }

+ 164
- 10
osd/src/com/dmdirc/addons/osd/OsdManager.java Переглянути файл

@@ -23,39 +23,80 @@
23 23
 package com.dmdirc.addons.osd;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
+import com.dmdirc.addons.ui_swing.injection.MainWindow;
27
+import com.dmdirc.config.prefs.CategoryChangeListener;
28
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
29
+import com.dmdirc.config.prefs.PreferencesCategory;
30
+import com.dmdirc.config.prefs.PreferencesDialogModel;
31
+import com.dmdirc.config.prefs.PreferencesInterface;
32
+import com.dmdirc.config.prefs.PreferencesSetting;
33
+import com.dmdirc.config.prefs.PreferencesType;
34
+import com.dmdirc.config.prefs.SettingChangeListener;
35
+import com.dmdirc.events.ClientPrefsOpenedEvent;
26 36
 import com.dmdirc.interfaces.config.IdentityController;
37
+import com.dmdirc.plugins.PluginDomain;
27 38
 import com.dmdirc.plugins.PluginInfo;
28 39
 import com.dmdirc.ui.messages.ColourManager;
40
+import com.dmdirc.ui.messages.ColourManagerFactory;
41
+import com.dmdirc.util.validators.NumericalValidator;
42
+import com.dmdirc.util.validators.OptionalValidator;
29 43
 
30 44
 import java.awt.Window;
31 45
 import java.util.ArrayList;
46
+import java.util.HashMap;
32 47
 import java.util.LinkedList;
33 48
 import java.util.List;
49
+import java.util.Map;
34 50
 import java.util.Queue;
35 51
 
52
+import javax.inject.Inject;
53
+
54
+import net.engio.mbassy.listener.Handler;
55
+
36 56
 /**
37 57
  * Class to manage OSD Windows.
38 58
  */
39
-public class OsdManager {
59
+public class OsdManager implements CategoryChangeListener, PreferencesInterface,
60
+        SettingChangeListener {
40 61
 
41 62
     /** The frame the OSD will be associated with. */
42 63
     private final Window mainFrame;
43
-    /** The controller to read/write settings with. */
44
-    private final IdentityController identityController;
45
-    /** The colour manager to use to parse colours. */
46
-    private final ColourManager colourManager;
47 64
     /** List of OSD Windows. */
48 65
     private final List<OsdWindow> windowList = new ArrayList<>();
49 66
     /** List of messages to be queued. */
50 67
     private final Queue<QueuedMessage> windowQueue = new LinkedList<>();
51 68
     /** This plugin's settings domain. */
52 69
     private final String domain;
70
+    /** Config OSD Window. */
71
+    private OsdWindow osdWindow;
72
+    /** X-axis position of OSD. */
73
+    private int x;
74
+    /** Y-axis potion of OSD. */
75
+    private int y;
76
+    /** Setting objects with registered change listeners. */
77
+    private PreferencesSetting fontSizeSetting;
78
+    private PreferencesSetting backgroundSetting;
79
+    private PreferencesSetting foregroundSetting;
80
+    private PreferencesSetting widthSetting;
81
+    private PreferencesSetting timeoutSetting;
82
+    private PreferencesSetting maxWindowsSetting;
83
+    /** This plugin's plugin info. */
84
+    private final PluginInfo pluginInfo;
85
+    /** The controller to read/write settings with. */
86
+    private final IdentityController identityController;
87
+    /** The manager to use to parse colours. */
88
+    private final ColourManager colourManager;
53 89
 
54
-    public OsdManager(final Window mainFrame, final IdentityController identityController,
55
-            final ColourManager colourManager, final PluginInfo pluginInfo) {
90
+    @Inject
91
+    public OsdManager(
92
+            @MainWindow final Window mainFrame,
93
+            final IdentityController identityController,
94
+            final ColourManagerFactory colourManagerFactory,
95
+            @PluginDomain(OsdPlugin.class) final PluginInfo pluginInfo) {
56 96
         this.mainFrame = mainFrame;
57 97
         this.identityController = identityController;
58
-        this.colourManager = colourManager;
98
+        this.colourManager = colourManagerFactory.getColourManager(identityController.getGlobalConfiguration());
99
+        this.pluginInfo = pluginInfo;
59 100
         this.domain = pluginInfo.getDomain();
60 101
     }
61 102
 
@@ -97,8 +138,9 @@ public class OsdManager {
97 138
      * @param message Text to display in the OSD window.
98 139
      */
99 140
     private synchronized void displayWindow(final int timeout, final String message) {
100
-        final OsdPolicy policy = OsdPolicy.valueOf(identityController.getGlobalConfiguration()
101
-                .getOption(domain, "newbehaviour").toUpperCase());
141
+        final OsdPolicy policy = OsdPolicy.valueOf(
142
+                identityController.getGlobalConfiguration().getOption(domain, "newbehaviour")
143
+                        .toUpperCase());
102 144
         final int startY = identityController.getGlobalConfiguration()
103 145
                 .getOptionInt(domain, "locationY");
104 146
 
@@ -167,4 +209,116 @@ public class OsdManager {
167 209
         return windowList.size();
168 210
     }
169 211
 
212
+    @Handler
213
+    public void showConfig(final ClientPrefsOpenedEvent event) {
214
+        final PreferencesDialogModel manager = event.getModel();
215
+        x = identityController.getGlobalConfiguration()
216
+                .getOptionInt(domain, "locationX");
217
+        y = identityController.getGlobalConfiguration()
218
+                .getOptionInt(domain, "locationY");
219
+
220
+        final PreferencesCategory category = new PluginPreferencesCategory(
221
+                pluginInfo, "OSD",
222
+                "General configuration for OSD plugin.", "category-osd");
223
+
224
+        fontSizeSetting = new PreferencesSetting(PreferencesType.INTEGER,
225
+                domain, "fontSize", "Font size", "Changes the font " + "size of the OSD",
226
+                manager.getConfigManager(),
227
+                manager.getIdentity()).registerChangeListener(this);
228
+        backgroundSetting = new PreferencesSetting(PreferencesType.COLOUR,
229
+                domain, "bgcolour", "Background colour",
230
+                "Background colour for the OSD", manager.getConfigManager(),
231
+                manager.getIdentity()).registerChangeListener(this);
232
+        foregroundSetting = new PreferencesSetting(PreferencesType.COLOUR,
233
+                domain, "fgcolour", "Foreground colour",
234
+                "Foreground colour for the OSD", manager.getConfigManager(),
235
+                manager.getIdentity()).registerChangeListener(this);
236
+        widthSetting = new PreferencesSetting(PreferencesType.INTEGER,
237
+                domain, "width", "OSD Width", "Width of the OSD Window",
238
+                manager.getConfigManager(), manager.getIdentity())
239
+                .registerChangeListener(this);
240
+        timeoutSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
241
+                new OptionalValidator(new NumericalValidator(1, Integer.MAX_VALUE)),
242
+                domain, "timeout", "Timeout", "Length of time in "
243
+                + "seconds before the OSD window closes", manager.getConfigManager(),
244
+                manager.getIdentity());
245
+        maxWindowsSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
246
+                new OptionalValidator(new NumericalValidator(1, Integer.MAX_VALUE)),
247
+                domain, "maxWindows", "Maximum open windows",
248
+                "Maximum number of OSD windows that will be displayed at any given time",
249
+                manager.getConfigManager(), manager.getIdentity());
250
+
251
+        category.addSetting(fontSizeSetting);
252
+        category.addSetting(backgroundSetting);
253
+        category.addSetting(foregroundSetting);
254
+        category.addSetting(widthSetting);
255
+        category.addSetting(timeoutSetting);
256
+        category.addSetting(maxWindowsSetting);
257
+
258
+        final Map<String, String> posOptions = new HashMap<>();
259
+
260
+        //Populate policy MULTICHOICE
261
+        for (OsdPolicy policy : OsdPolicy.values()) {
262
+            posOptions.put(policy.name(), policy.getDescription());
263
+        }
264
+
265
+        category.addSetting(new PreferencesSetting(domain, "newbehaviour",
266
+                "New window policy", "What to do when an OSD Window "
267
+                + "is opened when there are other, existing windows open",
268
+                posOptions, manager.getConfigManager(), manager.getIdentity()));
269
+
270
+        category.addChangeListener(this);
271
+        manager.getCategory("Plugins").addSubCategory(category);
272
+        manager.registerSaveListener(this);
273
+    }
274
+
275
+    @Override
276
+    public void categorySelected(final PreferencesCategory category) {
277
+        osdWindow = new OsdWindow(mainFrame, identityController, this, colourManager,
278
+                -1, "Please drag this OSD to position", true, x, y, domain);
279
+        osdWindow.setBackgroundColour(backgroundSetting.getValue());
280
+        osdWindow.setForegroundColour(foregroundSetting.getValue());
281
+        osdWindow.setFontSize(Integer.parseInt(fontSizeSetting.getValue()));
282
+    }
283
+
284
+    @Override
285
+    public void categoryDeselected(final PreferencesCategory category) {
286
+        x = osdWindow.getLocationOnScreen().x;
287
+        y = osdWindow.getLocationOnScreen().y;
288
+
289
+        osdWindow.dispose();
290
+        osdWindow = null;
291
+    }
292
+
293
+    @Override
294
+    public void save() {
295
+        identityController.getUserSettings().setOption(domain, "locationX", x);
296
+        identityController.getUserSettings().setOption(domain, "locationY", y);
297
+    }
298
+
299
+    @Override
300
+    public void settingChanged(final PreferencesSetting setting) {
301
+        if (osdWindow == null) {
302
+            // They've changed categories but are somehow poking settings.
303
+            // Ignore the request.
304
+            return;
305
+        }
306
+
307
+        if (setting.equals(fontSizeSetting)) {
308
+            osdWindow.setFontSize(Integer.parseInt(setting.getValue()));
309
+        } else if (setting.equals(backgroundSetting)) {
310
+            osdWindow.setBackgroundColour(setting.getValue());
311
+        } else if (setting.equals(foregroundSetting)) {
312
+            osdWindow.setForegroundColour(setting.getValue());
313
+        } else if (setting.equals(widthSetting)) {
314
+            int width = 500;
315
+            try {
316
+                width = Integer.parseInt(setting.getValue());
317
+            } catch (NumberFormatException e) {
318
+                //Ignore
319
+            }
320
+            osdWindow.setSize(width, osdWindow.getHeight());
321
+        }
322
+    }
323
+
170 324
 }

+ 49
- 0
osd/src/com/dmdirc/addons/osd/OsdModule.java Переглянути файл

@@ -0,0 +1,49 @@
1
+/*
2
+ * Copyright (c) 2006-2015 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.osd;
24
+
25
+import com.dmdirc.addons.ui_swing.injection.SwingModule;
26
+import com.dmdirc.plugins.PluginDomain;
27
+import com.dmdirc.plugins.PluginInfo;
28
+
29
+import dagger.Module;
30
+import dagger.Provides;
31
+
32
+/**
33
+ * Dependency injection module for the OSD plugin.
34
+ */
35
+@Module(injects = {OsdManager.class, OsdCommand.class}, addsTo = SwingModule.class)
36
+public class OsdModule {
37
+
38
+    private final PluginInfo pluginInfo;
39
+
40
+    public OsdModule(final PluginInfo pluginInfo) {
41
+        this.pluginInfo = pluginInfo;
42
+    }
43
+
44
+    @Provides
45
+    @PluginDomain(OsdPlugin.class)
46
+    public PluginInfo getPluginInfo() {
47
+        return pluginInfo;
48
+    }
49
+}

+ 9
- 173
osd/src/com/dmdirc/addons/osd/OsdPlugin.java Переглянути файл

@@ -22,193 +22,29 @@
22 22
 
23 23
 package com.dmdirc.addons.osd;
24 24
 
25
-import com.dmdirc.addons.ui_swing.SwingController;
26
-import com.dmdirc.config.prefs.CategoryChangeListener;
27
-import com.dmdirc.config.prefs.PluginPreferencesCategory;
28
-import com.dmdirc.config.prefs.PreferencesCategory;
29
-import com.dmdirc.config.prefs.PreferencesDialogModel;
30
-import com.dmdirc.config.prefs.PreferencesInterface;
31
-import com.dmdirc.config.prefs.PreferencesSetting;
32
-import com.dmdirc.config.prefs.PreferencesType;
33
-import com.dmdirc.config.prefs.SettingChangeListener;
34
-import com.dmdirc.interfaces.CommandController;
35
-import com.dmdirc.interfaces.config.IdentityController;
36 25
 import com.dmdirc.plugins.Exported;
37 26
 import com.dmdirc.plugins.PluginInfo;
38 27
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
39
-import com.dmdirc.ui.messages.ColourManager;
40
-import com.dmdirc.util.validators.NumericalValidator;
41
-import com.dmdirc.util.validators.OptionalValidator;
42 28
 
43
-import java.awt.Frame;
44
-import java.util.HashMap;
45
-import java.util.Map;
29
+import dagger.ObjectGraph;
46 30
 
47 31
 /**
48 32
  * Allows the user to display on-screen-display messages.
49 33
  */
50
-public class OsdPlugin extends BaseCommandPlugin implements
51
-        CategoryChangeListener, PreferencesInterface, SettingChangeListener {
34
+public class OsdPlugin extends BaseCommandPlugin {
52 35
 
53
-    /** Config OSD Window. */
54
-    private OsdWindow osdWindow;
55
-    /** The OSD Manager that this plugin is using. */
56
-    private final OsdManager osdManager;
57
-    /** X-axis position of OSD. */
58
-    private int x;
59
-    /** Y-axis potion of OSD. */
60
-    private int y;
61
-    /** Setting objects with registered change listeners. */
62
-    private PreferencesSetting fontSizeSetting;
63
-    private PreferencesSetting backgroundSetting;
64
-    private PreferencesSetting foregroundSetting;
65
-    private PreferencesSetting widthSetting;
66
-    private PreferencesSetting timeoutSetting;
67
-    private PreferencesSetting maxWindowsSetting;
68
-    /** This plugin's plugin info. */
69
-    private final PluginInfo pluginInfo;
70
-    /** The controller to read/write settings with. */
71
-    private final IdentityController identityController;
72
-    /** The manager to use to parse colours. */
73
-    private final ColourManager colourManager;
74
-    /** The frame that the OSDs will be associated with. */
75
-    private final Frame mainFrame;
76
-    /** This plugin's settings domain. */
77
-    private final String domain;
78
-
79
-    /**
80
-     * Creates a new instance of this plugin.
81
-     *
82
-     * @param swingController    The controller that owns this plugin.
83
-     * @param pluginInfo         This plugin's plugin info
84
-     * @param identityController The controller to use to read and write settings.
85
-     * @param commandController  Command controller to register commands
86
-     * @param colourManager      The manager to use to parse colours.
87
-     */
88
-    public OsdPlugin(
89
-            final SwingController swingController,
90
-            final PluginInfo pluginInfo,
91
-            final IdentityController identityController,
92
-            final CommandController commandController,
93
-            final ColourManager colourManager) {
94
-        this.pluginInfo = pluginInfo;
95
-        this.identityController = identityController;
96
-        this.colourManager = colourManager;
97
-        this.mainFrame = swingController.getMainFrame();
98
-        this.domain = pluginInfo.getDomain();
99
-        osdManager = new OsdManager(mainFrame, identityController, colourManager, pluginInfo);
100
-        registerCommand(new OsdCommand(commandController, osdManager), OsdCommand.INFO);
101
-    }
102
-
103
-    @Override
104
-    public void showConfig(final PreferencesDialogModel manager) {
105
-        x = identityController.getGlobalConfiguration()
106
-                .getOptionInt(domain, "locationX");
107
-        y = identityController.getGlobalConfiguration()
108
-                .getOptionInt(domain, "locationY");
109
-
110
-        final PreferencesCategory category = new PluginPreferencesCategory(
111
-                pluginInfo, "OSD",
112
-                "General configuration for OSD plugin.", "category-osd");
113
-
114
-        fontSizeSetting = new PreferencesSetting(PreferencesType.INTEGER,
115
-                domain, "fontSize", "Font size", "Changes the font " + "size of the OSD",
116
-                manager.getConfigManager(),
117
-                manager.getIdentity()).registerChangeListener(this);
118
-        backgroundSetting = new PreferencesSetting(PreferencesType.COLOUR,
119
-                domain, "bgcolour", "Background colour",
120
-                "Background colour for the OSD", manager.getConfigManager(),
121
-                manager.getIdentity()).registerChangeListener(this);
122
-        foregroundSetting = new PreferencesSetting(PreferencesType.COLOUR,
123
-                domain, "fgcolour", "Foreground colour",
124
-                "Foreground colour for the OSD", manager.getConfigManager(),
125
-                manager.getIdentity()).registerChangeListener(this);
126
-        widthSetting = new PreferencesSetting(PreferencesType.INTEGER,
127
-                domain, "width", "OSD Width", "Width of the OSD Window",
128
-                manager.getConfigManager(), manager.getIdentity())
129
-                .registerChangeListener(this);
130
-        timeoutSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
131
-                new OptionalValidator(new NumericalValidator(1, Integer.MAX_VALUE)),
132
-                domain, "timeout", "Timeout", "Length of time in "
133
-                + "seconds before the OSD window closes", manager.getConfigManager(),
134
-                manager.getIdentity());
135
-        maxWindowsSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
136
-                new OptionalValidator(new NumericalValidator(1, Integer.MAX_VALUE)),
137
-                domain, "maxWindows", "Maximum open windows",
138
-                "Maximum number of OSD windows that will be displayed at any given time",
139
-                manager.getConfigManager(), manager.getIdentity());
140
-
141
-        category.addSetting(fontSizeSetting);
142
-        category.addSetting(backgroundSetting);
143
-        category.addSetting(foregroundSetting);
144
-        category.addSetting(widthSetting);
145
-        category.addSetting(timeoutSetting);
146
-        category.addSetting(maxWindowsSetting);
147
-
148
-        final Map<String, String> posOptions = new HashMap<>();
149
-
150
-        //Populate policy MULTICHOICE
151
-        for (OsdPolicy policy : OsdPolicy.values()) {
152
-            posOptions.put(policy.name(), policy.getDescription());
153
-        }
154 36
 
155
-        category.addSetting(new PreferencesSetting(domain, "newbehaviour",
156
-                "New window policy", "What to do when an OSD Window "
157
-                + "is opened when there are other, existing windows open",
158
-                posOptions, manager.getConfigManager(), manager.getIdentity()));
159
-
160
-        category.addChangeListener(this);
161
-        manager.getCategory("Plugins").addSubCategory(category);
162
-        manager.registerSaveListener(this);
163
-    }
164
-
165
-    @Override
166
-    public void categorySelected(final PreferencesCategory category) {
167
-        osdWindow = new OsdWindow(mainFrame, identityController, osdManager, colourManager,
168
-                -1, "Please drag this OSD to position", true, x, y, domain);
169
-        osdWindow.setBackgroundColour(backgroundSetting.getValue());
170
-        osdWindow.setForegroundColour(foregroundSetting.getValue());
171
-        osdWindow.setFontSize(Integer.parseInt(fontSizeSetting.getValue()));
172
-    }
173
-
174
-    @Override
175
-    public void categoryDeselected(final PreferencesCategory category) {
176
-        x = osdWindow.getLocationOnScreen().x;
177
-        y = osdWindow.getLocationOnScreen().y;
178
-
179
-        osdWindow.dispose();
180
-        osdWindow = null;
181
-    }
37
+    /** The OSD Manager that this plugin is using. */
38
+    private OsdManager osdManager;
182 39
 
183 40
     @Override
184
-    public void save() {
185
-        identityController.getUserSettings().setOption(domain, "locationX", x);
186
-        identityController.getUserSettings().setOption(domain, "locationY", y);
187
-    }
41
+    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
42
+        super.load(pluginInfo, graph);
188 43
 
189
-    @Override
190
-    public void settingChanged(final PreferencesSetting setting) {
191
-        if (osdWindow == null) {
192
-            // They've changed categories but are somehow poking settings.
193
-            // Ignore the request.
194
-            return;
195
-        }
44
+        setObjectGraph(graph.plus(new OsdModule(pluginInfo)));
45
+        osdManager = getObjectGraph().get(OsdManager.class);
196 46
 
197
-        if (setting.equals(fontSizeSetting)) {
198
-            osdWindow.setFontSize(Integer.parseInt(setting.getValue()));
199
-        } else if (setting.equals(backgroundSetting)) {
200
-            osdWindow.setBackgroundColour(setting.getValue());
201
-        } else if (setting.equals(foregroundSetting)) {
202
-            osdWindow.setForegroundColour(setting.getValue());
203
-        } else if (setting.equals(widthSetting)) {
204
-            int width = 500;
205
-            try {
206
-                width = Integer.parseInt(setting.getValue());
207
-            } catch (NumberFormatException e) {
208
-                //Ignore
209
-            }
210
-            osdWindow.setSize(width, osdWindow.getHeight());
211
-        }
47
+        registerCommand(OsdCommand.class, OsdCommand.INFO);
212 48
     }
213 49
 
214 50
     /**

+ 26
- 0
systray/src/com/dmdirc/addons/systray/SystrayManager.java Переглянути файл

@@ -25,10 +25,17 @@ package com.dmdirc.addons.systray;
25 25
 import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.DMDircMBassador;
27 27
 import com.dmdirc.addons.ui_swing.MainFrame;
28
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
29
+import com.dmdirc.config.prefs.PreferencesCategory;
30
+import com.dmdirc.config.prefs.PreferencesDialogModel;
31
+import com.dmdirc.config.prefs.PreferencesSetting;
32
+import com.dmdirc.config.prefs.PreferencesType;
28 33
 import com.dmdirc.events.ClientMinimisedEvent;
34
+import com.dmdirc.events.ClientPrefsOpenedEvent;
29 35
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30 36
 import com.dmdirc.plugins.PluginDomain;
31 37
 import com.dmdirc.addons.ui_swing.components.IconManager;
38
+import com.dmdirc.plugins.PluginInfo;
32 39
 import com.dmdirc.ui.messages.Styliser;
33 40
 
34 41
 import java.awt.AWTException;
@@ -48,6 +55,7 @@ import net.engio.mbassy.listener.Handler;
48 55
 
49 56
 public class SystrayManager implements ActionListener, MouseListener {
50 57
 
58
+    private final PluginInfo pluginInfo;
51 59
     /** Main frame instance. */
52 60
     private final MainFrame mainFrame;
53 61
     /** This plugin's settings domain. */
@@ -65,11 +73,13 @@ public class SystrayManager implements ActionListener, MouseListener {
65 73
     public SystrayManager(
66 74
             @GlobalConfig final AggregateConfigProvider globalConfig,
67 75
             @PluginDomain(SystrayPlugin.class) final String domain,
76
+            @PluginDomain(SystrayPlugin.class) final PluginInfo pluginInfo,
68 77
             final MainFrame mainFrame,
69 78
             final IconManager iconManager,
70 79
             final DMDircMBassador eventBus) {
71 80
         this.globalConfig = globalConfig;
72 81
         this.domain = domain;
82
+        this.pluginInfo = pluginInfo;
73 83
         this.mainFrame = mainFrame;
74 84
         this.iconManager = iconManager;
75 85
         this.eventBus = eventBus;
@@ -158,6 +168,22 @@ public class SystrayManager implements ActionListener, MouseListener {
158 168
         }
159 169
     }
160 170
 
171
+    @Handler
172
+    public void showConfig(final ClientPrefsOpenedEvent event) {
173
+        final PreferencesDialogModel manager = event.getModel();
174
+        final PreferencesCategory category = new PluginPreferencesCategory(
175
+                pluginInfo, "System Tray",
176
+                "General configuration settings");
177
+
178
+        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
179
+                pluginInfo.getDomain(), "autominimise", "Auto-hide DMDirc when minimised",
180
+                "If this option is enabled, the systray plugin will hide DMDirc"
181
+                        + " to the system tray whenever DMDirc is minimised",
182
+                manager.getConfigManager(), manager.getIdentity()));
183
+
184
+        manager.getCategory("Plugins").addSubCategory(category);
185
+    }
186
+
161 187
     @Override
162 188
     public void mousePressed(final MouseEvent e) {
163 189
         //Ignore

+ 6
- 0
systray/src/com/dmdirc/addons/systray/SystrayModule.java Переглянути файл

@@ -44,4 +44,10 @@ public class SystrayModule {
44 44
         return pluginInfo.getDomain();
45 45
     }
46 46
 
47
+    @Provides
48
+    @PluginDomain(SystrayPlugin.class)
49
+    public PluginInfo getPluginInfo() {
50
+        return pluginInfo;
51
+    }
52
+
47 53
 }

+ 0
- 32
systray/src/com/dmdirc/addons/systray/SystrayPlugin.java Переглянути файл

@@ -22,11 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.systray;
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.Exported;
31 26
 import com.dmdirc.plugins.PluginInfo;
32 27
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
@@ -42,20 +37,9 @@ import dagger.ObjectGraph;
42 37
  */
43 38
 public class SystrayPlugin extends BaseCommandPlugin {
44 39
 
45
-    /** This plugin's plugin info. */
46
-    private final PluginInfo pluginInfo;
47 40
     /** Systray manager. */
48 41
     private SystrayManager manager;
49 42
 
50
-    /**
51
-     * Creates a new system tray plugin.
52
-     *
53
-     * @param pluginInfo This plugin's plugin info.
54
-     */
55
-    public SystrayPlugin(final PluginInfo pluginInfo) {
56
-        this.pluginInfo = pluginInfo;
57
-    }
58
-
59 43
     @Override
60 44
     public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
61 45
         super.load(pluginInfo, graph);
@@ -97,20 +81,4 @@ public class SystrayPlugin extends BaseCommandPlugin {
97 81
         manager.unload();
98 82
         super.onUnload();
99 83
     }
100
-
101
-    @Override
102
-    public void showConfig(final PreferencesDialogModel manager) {
103
-        final PreferencesCategory category = new PluginPreferencesCategory(
104
-                pluginInfo, "System Tray",
105
-                "General configuration settings");
106
-
107
-        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
108
-                pluginInfo.getDomain(), "autominimise", "Auto-hide DMDirc when minimised",
109
-                "If this option is enabled, the systray plugin will hide DMDirc"
110
-                + " to the system tray whenever DMDirc is minimised",
111
-                manager.getConfigManager(), manager.getIdentity()));
112
-
113
-        manager.getCategory("Plugins").addSubCategory(category);
114
-    }
115
-
116 84
 }

+ 1
- 42
windowflashing/src/com/dmdirc/addons/windowflashing/WindowFlashing.java Переглянути файл

@@ -22,11 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.windowflashing;
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.Exported;
31 26
 import com.dmdirc.plugins.PluginInfo;
32 27
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
@@ -40,19 +35,12 @@ public class WindowFlashing extends BaseCommandPlugin {
40 35
 
41 36
     /** Window flashing manager. */
42 37
     private WindowFlashingManager manager;
43
-    /** This plugin's plugin info. */
44
-    private PluginInfo pluginInfo;
45
-
46
-    public WindowFlashing(final PluginInfo pluginInfo) {
47
-        this.pluginInfo = pluginInfo;
48
-    }
49 38
 
50 39
     @Override
51 40
     public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
52 41
         super.load(pluginInfo, graph);
53
-        this.pluginInfo = pluginInfo;
54 42
 
55
-        setObjectGraph(graph.plus(new WindowFlashingModule()));
43
+        setObjectGraph(graph.plus(new WindowFlashingModule(pluginInfo)));
56 44
         registerCommand(FlashWindow.class, FlashWindow.INFO);
57 45
         manager = getObjectGraph().get(WindowFlashingManager.class);
58 46
     }
@@ -80,33 +68,4 @@ public class WindowFlashing extends BaseCommandPlugin {
80 68
         manager.onUnload();
81 69
     }
82 70
 
83
-    @Override
84
-    public void showConfig(final PreferencesDialogModel manager) {
85
-        final PreferencesCategory category = new PluginPreferencesCategory(
86
-                pluginInfo, "Window Flashing",
87
-                "General configuration for window flashing plugin.");
88
-
89
-        category.addSetting(new PreferencesSetting(
90
-                PreferencesType.OPTIONALINTEGER, pluginInfo.getDomain(), "blinkrate",
91
-                "Blink rate", "Specifies the rate at which the taskbar and or "
92
-                + "caption will blink, if unspecified this will be your cursor "
93
-                + "blink rate.",
94
-                manager.getConfigManager(), manager.getIdentity()));
95
-        category.addSetting(new PreferencesSetting(
96
-                PreferencesType.OPTIONALINTEGER, pluginInfo.getDomain(), "flashcount",
97
-                "Flash count", "Specifies the number of times to blink, if "
98
-                + "unspecified this will blink indefinitely",
99
-                manager.getConfigManager(), manager.getIdentity()));
100
-        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
101
-                pluginInfo.getDomain(), "flashtaskbar", "Flash taskbar",
102
-                "Should the taskbar entry flash?",
103
-                manager.getConfigManager(), manager.getIdentity()));
104
-        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
105
-                pluginInfo.getDomain(), "flashcaption", "Flash caption",
106
-                "Should the window caption flash?",
107
-                manager.getConfigManager(), manager.getIdentity()));
108
-
109
-        manager.getCategory("Plugins").addSubCategory(category);
110
-    }
111
-
112 71
 }

+ 43
- 0
windowflashing/src/com/dmdirc/addons/windowflashing/WindowFlashingManager.java Переглянути файл

@@ -27,8 +27,16 @@ import com.dmdirc.DMDircMBassador;
27 27
 import com.dmdirc.addons.ui_swing.MainFrame;
28 28
 import com.dmdirc.config.ConfigBinder;
29 29
 import com.dmdirc.config.ConfigBinding;
30
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
31
+import com.dmdirc.config.prefs.PreferencesCategory;
32
+import com.dmdirc.config.prefs.PreferencesDialogModel;
33
+import com.dmdirc.config.prefs.PreferencesSetting;
34
+import com.dmdirc.config.prefs.PreferencesType;
30 35
 import com.dmdirc.events.ClientFocusGainedEvent;
36
+import com.dmdirc.events.ClientPrefsOpenedEvent;
31 37
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
38
+import com.dmdirc.plugins.PluginDomain;
39
+import com.dmdirc.plugins.PluginInfo;
32 40
 
33 41
 import javax.inject.Inject;
34 42
 import javax.inject.Singleton;
@@ -44,6 +52,7 @@ import net.engio.mbassy.listener.Handler;
44 52
 @Singleton
45 53
 public class WindowFlashingManager {
46 54
 
55
+    private final PluginInfo pluginInfo;
47 56
     /** Swing main frame. */
48 57
     private final MainFrame mainFrame;
49 58
     /** Event bus. */
@@ -70,8 +79,10 @@ public class WindowFlashingManager {
70 79
     @Inject
71 80
     public WindowFlashingManager(
72 81
             @GlobalConfig final AggregateConfigProvider config,
82
+            @PluginDomain(WindowFlashing.class) final PluginInfo pluginInfo,
73 83
             final MainFrame mainFrame,
74 84
             final DMDircMBassador eventBus) {
85
+        this.pluginInfo = pluginInfo;
75 86
         this.mainFrame = mainFrame;
76 87
         this.eventBus = eventBus;
77 88
         binder = config.getBinder();
@@ -165,4 +176,36 @@ public class WindowFlashingManager {
165 176
         }
166 177
     }
167 178
 
179
+
180
+
181
+    @Handler
182
+    public void showConfig(final ClientPrefsOpenedEvent event) {
183
+        final PreferencesDialogModel manager = event.getModel();
184
+        final PreferencesCategory category = new PluginPreferencesCategory(
185
+                pluginInfo, "Window Flashing",
186
+                "General configuration for window flashing plugin.");
187
+
188
+        category.addSetting(new PreferencesSetting(
189
+                PreferencesType.OPTIONALINTEGER, pluginInfo.getDomain(), "blinkrate",
190
+                "Blink rate", "Specifies the rate at which the taskbar and or "
191
+                + "caption will blink, if unspecified this will be your cursor "
192
+                + "blink rate.",
193
+                manager.getConfigManager(), manager.getIdentity()));
194
+        category.addSetting(new PreferencesSetting(
195
+                PreferencesType.OPTIONALINTEGER, pluginInfo.getDomain(), "flashcount",
196
+                "Flash count", "Specifies the number of times to blink, if "
197
+                + "unspecified this will blink indefinitely",
198
+                manager.getConfigManager(), manager.getIdentity()));
199
+        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
200
+                pluginInfo.getDomain(), "flashtaskbar", "Flash taskbar",
201
+                "Should the taskbar entry flash?",
202
+                manager.getConfigManager(), manager.getIdentity()));
203
+        category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
204
+                pluginInfo.getDomain(), "flashcaption", "Flash caption",
205
+                "Should the window caption flash?",
206
+                manager.getConfigManager(), manager.getIdentity()));
207
+
208
+        manager.getCategory("Plugins").addSubCategory(category);
209
+    }
210
+
168 211
 }

+ 15
- 0
windowflashing/src/com/dmdirc/addons/windowflashing/WindowFlashingModule.java Переглянути файл

@@ -23,12 +23,27 @@
23 23
 package com.dmdirc.addons.windowflashing;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.injection.SwingModule;
26
+import com.dmdirc.plugins.PluginDomain;
27
+import com.dmdirc.plugins.PluginInfo;
26 28
 
27 29
 import dagger.Module;
30
+import dagger.Provides;
28 31
 
29 32
 /**
30 33
  * DI Module for the window flashing module.
31 34
  */
32 35
 @Module(injects = {WindowFlashingManager.class, FlashWindow.class}, addsTo = SwingModule.class)
33 36
 public class WindowFlashingModule {
37
+
38
+    private final PluginInfo pluginInfo;
39
+
40
+    public WindowFlashingModule(final PluginInfo pluginInfo) {
41
+        this.pluginInfo = pluginInfo;
42
+    }
43
+
44
+    @Provides
45
+    @PluginDomain(WindowFlashing.class)
46
+    public PluginInfo getPluginInfo() {
47
+        return pluginInfo;
48
+    }
34 49
 }

Завантаження…
Відмінити
Зберегти