|
@@ -22,16 +22,17 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.config.prefs;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.Main;
|
26
|
25
|
import com.dmdirc.actions.ActionManager;
|
27
|
26
|
import com.dmdirc.actions.CoreActionType;
|
28
|
27
|
import com.dmdirc.util.validators.NumericalValidator;
|
29
|
28
|
import com.dmdirc.util.validators.OptionalValidator;
|
30
|
29
|
import com.dmdirc.plugins.PluginManager;
|
31
|
30
|
import com.dmdirc.plugins.Service;
|
|
31
|
+import com.dmdirc.ui.interfaces.UIController;
|
32
|
32
|
import com.dmdirc.util.ListenerList;
|
33
|
33
|
|
34
|
34
|
import java.util.ArrayList;
|
|
35
|
+import java.util.Collections;
|
35
|
36
|
import java.util.HashMap;
|
36
|
37
|
import java.util.List;
|
37
|
38
|
import java.util.Map;
|
|
@@ -43,6 +44,9 @@ import java.util.Map;
|
43
|
44
|
*/
|
44
|
45
|
public class PreferencesManager {
|
45
|
46
|
|
|
47
|
+ /** The UI controller to use for custom categories. */
|
|
48
|
+ private final UIController controller;
|
|
49
|
+
|
46
|
50
|
/** A list of categories. */
|
47
|
51
|
private final List<PreferencesCategory> categories
|
48
|
52
|
= new ArrayList<PreferencesCategory>();
|
|
@@ -52,8 +56,13 @@ public class PreferencesManager {
|
52
|
56
|
|
53
|
57
|
/**
|
54
|
58
|
* Creates a new instance of PreferencesManager.
|
|
59
|
+ *
|
|
60
|
+ * @param controller The UI controller to use to retrieve custom UIs for
|
|
61
|
+ * preferences panels.
|
55
|
62
|
*/
|
56
|
|
- public PreferencesManager() {
|
|
63
|
+ public PreferencesManager(final UIController controller) {
|
|
64
|
+ this.controller = controller;
|
|
65
|
+
|
57
|
66
|
addDefaultCategories();
|
58
|
67
|
|
59
|
68
|
ActionManager.processEvent(CoreActionType.CLIENT_PREFS_OPENED, null, this);
|
|
@@ -74,7 +83,7 @@ public class PreferencesManager {
|
74
|
83
|
* @return An ordered list of categories
|
75
|
84
|
*/
|
76
|
85
|
public List<PreferencesCategory> getCategories() {
|
77
|
|
- return categories;
|
|
86
|
+ return Collections.unmodifiableList(categories);
|
78
|
87
|
}
|
79
|
88
|
|
80
|
89
|
/**
|
|
@@ -104,7 +113,7 @@ public class PreferencesManager {
|
104
|
113
|
boolean restart = false;
|
105
|
114
|
for (PreferencesCategory category : categories) {
|
106
|
115
|
if (category.save()) {
|
107
|
|
- restart = true;
|
|
116
|
+ restart |= true;
|
108
|
117
|
}
|
109
|
118
|
}
|
110
|
119
|
|
|
@@ -174,9 +183,11 @@ public class PreferencesManager {
|
174
|
183
|
|
175
|
184
|
/**
|
176
|
185
|
* Creates and adds the "Tab Completion" category.
|
|
186
|
+ *
|
|
187
|
+ * @param parent Parent category to add this category to
|
177
|
188
|
* @since 0.6.4
|
178
|
189
|
*/
|
179
|
|
- private void addTabCompletionCategory(PreferencesCategory parent) {
|
|
190
|
+ private void addTabCompletionCategory(final PreferencesCategory parent) {
|
180
|
191
|
final PreferencesCategory category = new PreferencesCategory("Tab Completion", "");
|
181
|
192
|
final Map<String, String> taboptions = new HashMap<String, String>();
|
182
|
193
|
|
|
@@ -251,6 +262,8 @@ public class PreferencesManager {
|
251
|
262
|
|
252
|
263
|
/**
|
253
|
264
|
* Creates and adds the "SSL" category.
|
|
265
|
+ *
|
|
266
|
+ * @param parent Parent category to add this category to
|
254
|
267
|
*/
|
255
|
268
|
private void addSSLCategory(final PreferencesCategory parent) {
|
256
|
269
|
final PreferencesCategory category = new PreferencesCategory("SSL",
|
|
@@ -454,9 +467,11 @@ public class PreferencesManager {
|
454
|
467
|
|
455
|
468
|
/**
|
456
|
469
|
* Creates the Style subcategory in "GUI".
|
|
470
|
+ *
|
457
|
471
|
* @since 0.6.4
|
|
472
|
+ * @param parent Parent category to add this category to
|
458
|
473
|
*/
|
459
|
|
- private void addStyleSubCategory(PreferencesCategory parent) {
|
|
474
|
+ private void addStyleSubCategory(final PreferencesCategory parent) {
|
460
|
475
|
final PreferencesCategory category = new PreferencesCategory("Link styles"
|
461
|
476
|
+ " and colours", "");
|
462
|
477
|
category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
@@ -481,7 +496,7 @@ public class PreferencesManager {
|
481
|
496
|
*/
|
482
|
497
|
private void addThemesCategory(final PreferencesCategory parent) {
|
483
|
498
|
parent.addSubCategory(new PreferencesCategory("Themes", "",
|
484
|
|
- "category-addons", Main.getUI().getThemesPrefsPanel()));
|
|
499
|
+ "category-addons", controller.getThemesPrefsPanel()));
|
485
|
500
|
}
|
486
|
501
|
|
487
|
502
|
/**
|
|
@@ -489,7 +504,7 @@ public class PreferencesManager {
|
489
|
504
|
*/
|
490
|
505
|
private void addPluginsCategory() {
|
491
|
506
|
addCategory(new PreferencesCategory("Plugins", "", "category-addons",
|
492
|
|
- Main.getUI().getPluginPrefsPanel()));
|
|
507
|
+ controller.getPluginPrefsPanel()));
|
493
|
508
|
}
|
494
|
509
|
|
495
|
510
|
/**
|
|
@@ -497,7 +512,7 @@ public class PreferencesManager {
|
497
|
512
|
*/
|
498
|
513
|
private void addUpdatesCategory() {
|
499
|
514
|
addCategory(new PreferencesCategory("Updates", "", "category-updates",
|
500
|
|
- Main.getUI().getUpdatesPrefsPanel()));
|
|
515
|
+ controller.getUpdatesPrefsPanel()));
|
501
|
516
|
}
|
502
|
517
|
|
503
|
518
|
/**
|
|
@@ -506,7 +521,7 @@ public class PreferencesManager {
|
506
|
521
|
private void addUrlHandlerCategory() {
|
507
|
522
|
addCategory(new PreferencesCategory("URL Handlers",
|
508
|
523
|
"Configure how DMDirc handles different types of URLs",
|
509
|
|
- "category-urlhandlers", Main.getUI().getUrlHandlersPrefsPanel()));
|
|
524
|
+ "category-urlhandlers", controller.getUrlHandlersPrefsPanel()));
|
510
|
525
|
}
|
511
|
526
|
|
512
|
527
|
/**
|