|
@@ -28,13 +28,6 @@ import com.dmdirc.ClientModule.GlobalConfig;
|
28
|
28
|
import com.dmdirc.ClientModule.UserConfig;
|
29
|
29
|
import com.dmdirc.actions.ActionManager;
|
30
|
30
|
import com.dmdirc.actions.CoreActionType;
|
31
|
|
-import com.dmdirc.addons.ui_swing.MainFrame;
|
32
|
|
-import com.dmdirc.addons.ui_swing.UIUtilities;
|
33
|
|
-import com.dmdirc.config.prefs.PluginPreferencesCategory;
|
34
|
|
-import com.dmdirc.config.prefs.PreferencesCategory;
|
35
|
|
-import com.dmdirc.config.prefs.PreferencesDialogModel;
|
36
|
|
-import com.dmdirc.config.prefs.PreferencesSetting;
|
37
|
|
-import com.dmdirc.config.prefs.PreferencesType;
|
38
|
31
|
import com.dmdirc.interfaces.ActionListener;
|
39
|
32
|
import com.dmdirc.interfaces.actions.ActionType;
|
40
|
33
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
|
@@ -43,15 +36,12 @@ import com.dmdirc.interfaces.config.ConfigProvider;
|
43
|
36
|
import com.dmdirc.parser.interfaces.ChannelClientInfo;
|
44
|
37
|
import com.dmdirc.parser.interfaces.ChannelInfo;
|
45
|
38
|
import com.dmdirc.parser.interfaces.ClientInfo;
|
46
|
|
-import com.dmdirc.plugins.PluginInfo;
|
47
|
39
|
import com.dmdirc.ui.Colour;
|
48
|
|
-import com.dmdirc.ui.IconManager;
|
49
|
40
|
import com.dmdirc.ui.messages.ColourManager;
|
50
|
41
|
|
51
|
42
|
import java.util.ArrayList;
|
52
|
43
|
import java.util.List;
|
53
|
44
|
import java.util.Map;
|
54
|
|
-import java.util.concurrent.Callable;
|
55
|
45
|
|
56
|
46
|
import javax.inject.Inject;
|
57
|
47
|
import javax.inject.Singleton;
|
|
@@ -70,34 +60,20 @@ public class NickColourManager implements ActionListener, ConfigChangeListener {
|
70
|
60
|
private boolean userandomcolour;
|
71
|
61
|
private boolean settext;
|
72
|
62
|
private boolean setnicklist;
|
73
|
|
- /** This plugin's plugin info. */
|
74
|
|
- private final PluginInfo pluginInfo;
|
75
|
63
|
/** Manager to parse colours with. */
|
76
|
64
|
private final ColourManager colourManager;
|
77
|
|
- /** Main frame to parent dialogs on. */
|
78
|
|
- private final MainFrame mainFrame;
|
79
|
|
- /** Icon manager to retrieve icons from. */
|
80
|
|
- private final IconManager iconManager;
|
81
|
65
|
/** Config to read settings from. */
|
82
|
66
|
private final AggregateConfigProvider globalConfig;
|
83
|
|
- /** Config to write settings to. */
|
84
|
|
- private final ConfigProvider userConfig;
|
85
|
67
|
/** Plugin's setting domain. */
|
86
|
68
|
private final String domain;
|
87
|
69
|
|
88
|
70
|
@Inject
|
89
|
|
- public NickColourManager(final PluginInfo pluginInfo,
|
|
71
|
+ public NickColourManager(final ColourManager colourManager,
|
90
|
72
|
@NickColourModule.NickColourSettingsDomain final String domain,
|
91
|
|
- final ColourManager colourManager, final MainFrame mainFrame,
|
92
|
|
- @GlobalConfig final IconManager iconManager,
|
93
|
73
|
@GlobalConfig final AggregateConfigProvider globalConfig,
|
94
|
74
|
@UserConfig final ConfigProvider userConfig) {
|
95
|
|
- this.mainFrame = mainFrame;
|
96
|
75
|
this.domain = domain;
|
97
|
|
- this.iconManager = iconManager;
|
98
|
|
- this.pluginInfo = pluginInfo;
|
99
|
76
|
this.globalConfig = globalConfig;
|
100
|
|
- this.userConfig = userConfig;
|
101
|
77
|
this.colourManager = colourManager;
|
102
|
78
|
}
|
103
|
79
|
|
|
@@ -147,9 +123,9 @@ public class NickColourManager implements ActionListener, ConfigChangeListener {
|
147
|
123
|
String[] parts = null;
|
148
|
124
|
|
149
|
125
|
if (globalConfig.hasOptionString(domain, nickOption1)) {
|
150
|
|
- parts = getParts(nickOption1);
|
|
126
|
+ parts = getParts(globalConfig, domain, nickOption1);
|
151
|
127
|
} else if (globalConfig.hasOptionString(domain, nickOption2)) {
|
152
|
|
- parts = getParts(nickOption2);
|
|
128
|
+ parts = getParts(globalConfig, domain, nickOption2);
|
153
|
129
|
}
|
154
|
130
|
|
155
|
131
|
if (parts != null) {
|
|
@@ -207,16 +183,19 @@ public class NickColourManager implements ActionListener, ConfigChangeListener {
|
207
|
183
|
/**
|
208
|
184
|
* Reads the nick colour data from the config.
|
209
|
185
|
*
|
|
186
|
+ * @param config Config to read settings from
|
|
187
|
+ * @param domain Config domain
|
|
188
|
+ *
|
210
|
189
|
* @return A multi-dimensional array of nick colour info.
|
211
|
190
|
*/
|
212
|
|
- public Object[][] getData() {
|
|
191
|
+ public static Object[][] getData(final AggregateConfigProvider config, final String domain) {
|
213
|
192
|
final List<Object[]> data = new ArrayList<>();
|
214
|
193
|
|
215
|
|
- for (String key : globalConfig.getOptions(domain).keySet()) {
|
|
194
|
+ for (String key : config.getOptions(domain).keySet()) {
|
216
|
195
|
if (key.startsWith("color:")) {
|
217
|
196
|
final String network = key.substring(6, key.indexOf(':', 6));
|
218
|
197
|
final String user = key.substring(1 + key.indexOf(':', 6));
|
219
|
|
- final String[] parts = getParts(key);
|
|
198
|
+ final String[] parts = getParts(config, domain, key);
|
220
|
199
|
|
221
|
200
|
data.add(new Object[]{network, user, parts[0], parts[1]});
|
222
|
201
|
}
|
|
@@ -238,12 +217,15 @@ public class NickColourManager implements ActionListener, ConfigChangeListener {
|
238
|
217
|
* Retrieves the config option with the specified key, and returns an array of the colours that
|
239
|
218
|
* should be used for it.
|
240
|
219
|
*
|
241
|
|
- * @param key The config key to look up
|
|
220
|
+ * @param config Config to read settings from
|
|
221
|
+ * @param domain Config domain
|
|
222
|
+ * @param key The config key to look up
|
242
|
223
|
*
|
243
|
224
|
* @return The colours specified by the given key
|
244
|
225
|
*/
|
245
|
|
- private String[] getParts(final String key) {
|
246
|
|
- String[] parts = globalConfig.getOption(domain, key).split(":");
|
|
226
|
+ private static String[] getParts(final AggregateConfigProvider config, final String domain,
|
|
227
|
+ final String key) {
|
|
228
|
+ String[] parts = config.getOption(domain, key).split(":");
|
247
|
229
|
|
248
|
230
|
if (parts.length == 0) {
|
249
|
231
|
parts = new String[]{null, null};
|
|
@@ -270,60 +252,6 @@ public class NickColourManager implements ActionListener, ConfigChangeListener {
|
270
|
252
|
ActionManager.getActionManager().unregisterListener(this);
|
271
|
253
|
}
|
272
|
254
|
|
273
|
|
- /**
|
274
|
|
- * Shows the prefs configuration page for this plugin.
|
275
|
|
- *
|
276
|
|
- * @param manager Prefs manager to add settings to
|
277
|
|
- */
|
278
|
|
- public void showConfig(final PreferencesDialogModel manager) {
|
279
|
|
- final PreferencesCategory general = new PluginPreferencesCategory(
|
280
|
|
- pluginInfo, "Nick Colours",
|
281
|
|
- "General configuration for NickColour plugin.");
|
282
|
|
- final PreferencesCategory colours = new PluginPreferencesCategory(
|
283
|
|
- pluginInfo, "Colours",
|
284
|
|
- "Set colours for specific nicknames.", UIUtilities.invokeAndWait(
|
285
|
|
- new Callable<NickColourPanel>() {
|
286
|
|
- /** {@inheritDoc} */
|
287
|
|
- @Override
|
288
|
|
- public NickColourPanel call() {
|
289
|
|
- return new NickColourPanel(mainFrame, iconManager,
|
290
|
|
- NickColourManager.this, colourManager, userConfig);
|
291
|
|
- }
|
292
|
|
- }));
|
293
|
|
-
|
294
|
|
- general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
295
|
|
- "ui", "shownickcoloursintext", "Show colours in text area",
|
296
|
|
- "Colour nicknames in main text area?",
|
297
|
|
- manager.getConfigManager(), manager.getIdentity()));
|
298
|
|
- general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
299
|
|
- "ui", "shownickcoloursinnicklist", "Show colours in"
|
300
|
|
- + " nick list", "Colour nicknames in channel nick lists?",
|
301
|
|
- manager.getConfigManager(), manager.getIdentity()));
|
302
|
|
- general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
303
|
|
- domain, "settext", "Set colours in textarea",
|
304
|
|
- "Should the plugin set the textarea colour of nicks?",
|
305
|
|
- manager.getConfigManager(), manager.getIdentity()));
|
306
|
|
- general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
307
|
|
- domain, "setnicklist", "Set colours in nick list",
|
308
|
|
- "Should the plugin set the nick list colour of nicks?",
|
309
|
|
- manager.getConfigManager(), manager.getIdentity()));
|
310
|
|
- general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
311
|
|
- domain, "userandomcolour", "Use random colour",
|
312
|
|
- "Use a pseudo-random colour for each person?",
|
313
|
|
- manager.getConfigManager(), manager.getIdentity()));
|
314
|
|
- general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
315
|
|
- domain, "useowncolour", "Use colour for own nick",
|
316
|
|
- "Always use the same colour for our own nickname?",
|
317
|
|
- manager.getConfigManager(), manager.getIdentity()));
|
318
|
|
- general.addSetting(new PreferencesSetting(PreferencesType.COLOUR, domain,
|
319
|
|
- "owncolour", "Colour to use for own nick",
|
320
|
|
- "Colour used for our own nickname, if above setting is "
|
321
|
|
- + "enabled.", manager.getConfigManager(), manager.getIdentity()));
|
322
|
|
-
|
323
|
|
- general.addSubCategory(colours);
|
324
|
|
- manager.getCategory("Plugins").addSubCategory(general);
|
325
|
|
- }
|
326
|
|
-
|
327
|
255
|
/**
|
328
|
256
|
* Updates cached settings.
|
329
|
257
|
*/
|