|
@@ -23,13 +23,15 @@
|
23
|
23
|
package com.dmdirc.addons.ui_swing.dialogs.channelsetting;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.Channel;
|
26
|
|
-import com.dmdirc.addons.ui_swing.SwingController;
|
27
|
26
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
28
|
27
|
import com.dmdirc.addons.ui_swing.components.renderers.ExtendedListModeCellRenderer;
|
29
|
28
|
import com.dmdirc.addons.ui_swing.components.renderers.ListModeCellRenderer;
|
30
|
29
|
import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog;
|
|
30
|
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
31
|
31
|
import com.dmdirc.interfaces.config.ConfigChangeListener;
|
|
32
|
+import com.dmdirc.interfaces.config.ConfigProvider;
|
32
|
33
|
import com.dmdirc.parser.common.ChannelListModeItem;
|
|
34
|
+import com.dmdirc.ui.IconManager;
|
33
|
35
|
import com.dmdirc.util.collections.MapList;
|
34
|
36
|
import com.dmdirc.util.validators.NotEmptyValidator;
|
35
|
37
|
|
|
@@ -92,27 +94,39 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
|
92
|
94
|
private final JCheckBox toggle;
|
93
|
95
|
/** Parent window. */
|
94
|
96
|
private final Window parentWindow;
|
95
|
|
- /** Swing controller. */
|
96
|
|
- private final SwingController controller;
|
97
|
97
|
/** Native cell renderer. */
|
98
|
98
|
private final ListCellRenderer nativeRenderer;
|
99
|
99
|
/** Cell renderer. */
|
100
|
100
|
private ListCellRenderer renderer;
|
101
|
101
|
/** Mode list. */
|
102
|
102
|
private JList list;
|
|
103
|
+ /** The config to read settings from. */
|
|
104
|
+ private final AggregateConfigProvider globalConfig;
|
|
105
|
+ /** The config to write settings to. */
|
|
106
|
+ private final ConfigProvider userConfig;
|
|
107
|
+ /** The manager to use to retrieve icons for dialogs and validation. */
|
|
108
|
+ private final IconManager iconManager;
|
103
|
109
|
|
104
|
110
|
/**
|
105
|
111
|
* Creates a new instance of ChannelListModePane.
|
106
|
112
|
*
|
107
|
|
- * @param controller Swing controller
|
|
113
|
+ * @param globalConfig The config to read settings from.
|
|
114
|
+ * @param userConfig The config to write settings to.
|
|
115
|
+ * @param iconManager The manager to use to retrieve icons for dialogs and validation.
|
108
|
116
|
* @param channel Parent channel
|
109
|
117
|
* @param parentWindow Parent window
|
110
|
118
|
*/
|
111
|
|
- public ChannelListModesPane(final SwingController controller,
|
112
|
|
- final Channel channel, final Window parentWindow) {
|
|
119
|
+ public ChannelListModesPane(
|
|
120
|
+ final AggregateConfigProvider globalConfig,
|
|
121
|
+ final ConfigProvider userConfig,
|
|
122
|
+ final IconManager iconManager,
|
|
123
|
+ final Channel channel,
|
|
124
|
+ final Window parentWindow) {
|
113
|
125
|
super();
|
114
|
126
|
|
115
|
|
- this.controller = controller;
|
|
127
|
+ this.globalConfig = globalConfig;
|
|
128
|
+ this.userConfig = userConfig;
|
|
129
|
+ this.iconManager = iconManager;
|
116
|
130
|
this.setOpaque(UIUtilities.getTabbedPaneOpaque());
|
117
|
131
|
this.channel = channel;
|
118
|
132
|
this.parentWindow = parentWindow;
|
|
@@ -134,8 +148,8 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
|
134
|
148
|
removeListModeButton = new JButton("Remove");
|
135
|
149
|
removeListModeButton.setEnabled(false);
|
136
|
150
|
modeCount = new JLabel();
|
137
|
|
- toggle = new JCheckBox("Show extended information", channel.getConfigManager()
|
138
|
|
- .getOptionBool("general", "extendedListModes"));
|
|
151
|
+ toggle = new JCheckBox("Show extended information",
|
|
152
|
+ channel.getConfigManager().getOptionBool("general", "extendedListModes"));
|
139
|
153
|
toggle.setOpaque(UIUtilities.getTabbedPaneOpaque());
|
140
|
154
|
|
141
|
155
|
initListModesPanel();
|
|
@@ -264,9 +278,7 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
|
264
|
278
|
}
|
265
|
279
|
|
266
|
280
|
channel.getChannelInfo().flushModes();
|
267
|
|
-
|
268
|
|
- controller.getGlobalIdentity().
|
269
|
|
- setOption("general", "extendedListModes", toggle.isSelected());
|
|
281
|
+ userConfig.setOption("general", "extendedListModes", toggle.isSelected());
|
270
|
282
|
}
|
271
|
283
|
|
272
|
284
|
/** Adds a list mode. */
|
|
@@ -279,7 +291,7 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
|
279
|
291
|
getOption("server", "mode" + listModesArray[selectedIndex]);
|
280
|
292
|
}
|
281
|
293
|
new StandardInputDialog(parentWindow, ModalityType.DOCUMENT_MODAL,
|
282
|
|
- controller.getIconManager(), "Add new " + modeText,
|
|
294
|
+ iconManager, "Add new " + modeText,
|
283
|
295
|
"Please enter the hostmask for the new " + modeText,
|
284
|
296
|
new NotEmptyValidator()) {
|
285
|
297
|
/**
|
|
@@ -390,8 +402,7 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
|
390
|
402
|
/** {@inheritDoc} */
|
391
|
403
|
@Override
|
392
|
404
|
public void configChanged(final String domain, final String key) {
|
393
|
|
- if (controller.getGlobalConfig().getOptionBool("general",
|
394
|
|
- "extendedListModes")) {
|
|
405
|
+ if (globalConfig.getOptionBool("general", "extendedListModes")) {
|
395
|
406
|
renderer = new ListModeCellRenderer(nativeRenderer);
|
396
|
407
|
} else {
|
397
|
408
|
renderer = new ExtendedListModeCellRenderer();
|