|
@@ -22,19 +22,23 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.serverlistdialog;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.ClientModule.GlobalConfig;
|
25
|
26
|
import com.dmdirc.addons.serverlists.ServerGroup;
|
26
|
27
|
import com.dmdirc.addons.serverlists.ServerGroupItem;
|
27
|
|
-import com.dmdirc.addons.ui_swing.SwingController;
|
|
28
|
+import com.dmdirc.addons.ui_swing.PrefsComponentFactory;
|
28
|
29
|
import com.dmdirc.addons.ui_swing.components.expandingsettings.SettingsPanel;
|
29
|
30
|
import com.dmdirc.config.ConfigManager;
|
30
|
31
|
import com.dmdirc.config.prefs.PreferencesManager;
|
31
|
32
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
32
|
33
|
import com.dmdirc.interfaces.config.ConfigProvider;
|
|
34
|
+import com.dmdirc.interfaces.config.IdentityFactory;
|
|
35
|
+import com.dmdirc.ui.IconManager;
|
33
|
36
|
|
34
|
37
|
import java.util.HashMap;
|
35
|
38
|
import java.util.Map;
|
36
|
39
|
import java.util.Map.Entry;
|
37
|
40
|
|
|
41
|
+import javax.inject.Inject;
|
38
|
42
|
import javax.swing.BorderFactory;
|
39
|
43
|
import javax.swing.JPanel;
|
40
|
44
|
import javax.swing.UIManager;
|
|
@@ -55,19 +59,32 @@ public class Settings extends JPanel implements ServerListListener {
|
55
|
59
|
private final Map<ServerGroupItem, SettingsPanel> panels = new HashMap<>();
|
56
|
60
|
/** Platform border. */
|
57
|
61
|
private final Border border;
|
58
|
|
- /** Swing controller. */
|
59
|
|
- private final SwingController controller;
|
|
62
|
+ /** Manager to use to retrieve icons. */
|
|
63
|
+ private final IconManager iconManager;
|
|
64
|
+ /** Factory to use to produce preference components. */
|
|
65
|
+ private final PrefsComponentFactory componentFactory;
|
|
66
|
+ /** Factory to use to produce identities. */
|
|
67
|
+ private final IdentityFactory identityFactory;
|
60
|
68
|
|
61
|
69
|
/**
|
62
|
70
|
* Instantiates a new settings panel.
|
63
|
71
|
*
|
64
|
|
- * @param controller Swing controller
|
65
|
72
|
* @param model Backing model
|
|
73
|
+ * @param iconManager Manager to use to retrieve icons.
|
|
74
|
+ * @param componentFactory Factory to use to produce preference components.
|
|
75
|
+ * @param identityFactory Factory to use to produce identities.
|
66
|
76
|
*/
|
67
|
|
- public Settings(final SwingController controller, final ServerListModel model) {
|
|
77
|
+ @Inject
|
|
78
|
+ public Settings(
|
|
79
|
+ final ServerListModel model,
|
|
80
|
+ @GlobalConfig final IconManager iconManager,
|
|
81
|
+ final PrefsComponentFactory componentFactory,
|
|
82
|
+ final IdentityFactory identityFactory) {
|
68
|
83
|
super();
|
69
|
|
- this.controller = controller;
|
70
|
84
|
this.model = model;
|
|
85
|
+ this.iconManager = iconManager;
|
|
86
|
+ this.componentFactory = componentFactory;
|
|
87
|
+ this.identityFactory = identityFactory;
|
71
|
88
|
addListeners();
|
72
|
89
|
border = UIManager.getBorder("TitledBorder.border");
|
73
|
90
|
setBorder(BorderFactory.createTitledBorder(border, "Network Settings"));
|
|
@@ -111,14 +128,12 @@ public class Settings extends JPanel implements ServerListListener {
|
111
|
128
|
private SettingsPanel getSettingsPanel(final ServerGroupItem item) {
|
112
|
129
|
if (!panels.containsKey(item)) {
|
113
|
130
|
if (item instanceof ServerGroup) {
|
114
|
|
- panels.put(item, new SettingsPanel(controller.getIconManager(), controller.getPrefsComponentFactory(), "", false));
|
|
131
|
+ panels.put(item, new SettingsPanel(iconManager, componentFactory, "", false));
|
115
|
132
|
addSettings(panels.get(item), new ConfigManager("irc", "",
|
116
|
133
|
item.getGroup().getNetwork(), item.getName()),
|
117
|
|
- controller.getIdentityFactory().createServerConfig(item.getName()));
|
118
|
|
- } else if (item == null) {
|
119
|
|
- panels.put(null, new SettingsPanel(controller.getIconManager(), controller.getPrefsComponentFactory(), "", false));
|
|
134
|
+ identityFactory.createServerConfig(item.getName()));
|
120
|
135
|
} else {
|
121
|
|
- panels.put(item, new SettingsPanel(controller.getIconManager(), controller.getPrefsComponentFactory(), "", false));
|
|
136
|
+ panels.put(item, new SettingsPanel(iconManager, componentFactory, "", false));
|
122
|
137
|
}
|
123
|
138
|
}
|
124
|
139
|
return panels.get(item);
|