|
@@ -35,6 +35,7 @@ import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
|
35
|
35
|
import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
|
36
|
36
|
import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider;
|
37
|
37
|
import com.dmdirc.commandparser.PopupType;
|
|
38
|
+import com.dmdirc.config.ConfigBinding;
|
38
|
39
|
import com.dmdirc.events.ClientClosingEvent;
|
39
|
40
|
import com.dmdirc.events.FrameClosingEvent;
|
40
|
41
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
|
@@ -54,6 +55,8 @@ import net.miginfocom.swing.MigLayout;
|
54
|
55
|
|
55
|
56
|
import net.engio.mbassy.listener.Handler;
|
56
|
57
|
|
|
58
|
+import static com.dmdirc.addons.ui_swing.SwingPreconditions.checkOnEDT;
|
|
59
|
+
|
57
|
60
|
/**
|
58
|
61
|
* The channel frame is the GUI component that represents a channel to the user.
|
59
|
62
|
*/
|
|
@@ -112,8 +115,6 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
|
112
|
115
|
|
113
|
116
|
initComponents(topicBarFactory, deps.colourManagerFactory);
|
114
|
117
|
|
115
|
|
- globalConfig.addChangeListener("ui", "channelSplitPanePosition", this);
|
116
|
|
- globalConfig.addChangeListener(domain, "shownicklist", this);
|
117
|
118
|
eventBus.subscribe(this);
|
118
|
119
|
|
119
|
120
|
identity = identityFactory.createChannelConfig(owner.getConnection().getNetwork(),
|
|
@@ -144,21 +145,13 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
|
144
|
145
|
add(getSearchBar(), "growx");
|
145
|
146
|
add(inputPanel, "growx");
|
146
|
147
|
|
|
148
|
+ getContainer().getConfigManager()
|
|
149
|
+ .getBinder().withDefaultDomain(domain).bind(this, ChannelFrame.class);
|
147
|
150
|
splitPane.setLeftComponent(getTextPane());
|
148
|
|
- if (getContainer().getConfigManager().getOptionBool(domain, "shownicklist")) {
|
149
|
|
- splitPane.setRightComponent(nicklist);
|
150
|
|
- } else {
|
151
|
|
- splitPane.setRightComponent(null);
|
152
|
|
- }
|
153
|
151
|
splitPane.setResizeWeight(1);
|
154
|
152
|
splitPane.setDividerLocation(-1);
|
155
|
153
|
}
|
156
|
154
|
|
157
|
|
- /**
|
158
|
|
- * {@inheritDoc}.
|
159
|
|
- *
|
160
|
|
- * @param actionEvent Action event
|
161
|
|
- */
|
162
|
155
|
@Override
|
163
|
156
|
public void actionPerformed(final ActionEvent actionEvent) {
|
164
|
157
|
if (actionEvent.getSource() == settingsMI) {
|
|
@@ -166,41 +159,36 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
|
166
|
159
|
}
|
167
|
160
|
}
|
168
|
161
|
|
169
|
|
- @Override
|
170
|
|
- public void configChanged(final String domain, final String key) {
|
171
|
|
- super.configChanged(domain, key);
|
172
|
|
-
|
173
|
|
- if ("channelSplitPanePosition".equals(key)) {
|
174
|
|
- final int splitPanePosition = getContainer().getConfigManager()
|
175
|
|
- .getOptionInt("ui", "channelSplitPanePosition");
|
176
|
|
- UIUtilities.invokeLater(() -> {
|
177
|
|
- nicklist.setPreferredSize(
|
178
|
|
- new Dimension(splitPanePosition, 0));
|
179
|
|
- splitPane.setDividerLocation(splitPane.getWidth() - splitPane.
|
180
|
|
- getDividerSize() - splitPanePosition);
|
181
|
|
- });
|
182
|
|
- }
|
183
|
|
- if ("shownicklist".equals(key)) {
|
184
|
|
- if (getContainer().getConfigManager().getOptionBool(domain, "shownicklist")) {
|
|
162
|
+ @ConfigBinding(domain = "ui", key = "channelSplitPanePosition")
|
|
163
|
+ public void handleSplitPanePosition(final int value) {
|
|
164
|
+ UIUtilities.invokeLater(() -> {
|
|
165
|
+ nicklist.setPreferredSize(new Dimension(value, 0));
|
|
166
|
+ splitPane.setDividerLocation(splitPane.getWidth() - splitPane.getDividerSize() - value);
|
|
167
|
+ });
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ @ConfigBinding(key = "shownicklist")
|
|
171
|
+ public void handleShowNickList(final boolean value) {
|
|
172
|
+ UIUtilities.invokeLater(() -> {
|
|
173
|
+ if (value) {
|
185
|
174
|
splitPane.setRightComponent(nicklist);
|
186
|
175
|
} else {
|
187
|
176
|
splitPane.setRightComponent(null);
|
188
|
177
|
}
|
189
|
|
- }
|
|
178
|
+ });
|
190
|
179
|
}
|
191
|
180
|
|
192
|
|
- @Handler
|
|
181
|
+ @Handler(invocation = EdtHandlerInvocation.class)
|
193
|
182
|
public void handleClientClosing(final ClientClosingEvent event) {
|
194
|
183
|
saveSplitPanePosition();
|
195
|
184
|
}
|
196
|
185
|
|
197
|
186
|
private void saveSplitPanePosition() {
|
198
|
|
- UIUtilities.invokeAndWait(() -> {
|
199
|
|
- if (getContainer().getConfigManager().getOptionInt("ui",
|
200
|
|
- "channelSplitPanePosition") != nicklist.getWidth()) {
|
201
|
|
- identity.setOption("ui", "channelSplitPanePosition", nicklist.getWidth());
|
202
|
|
- }
|
203
|
|
- });
|
|
187
|
+ checkOnEDT();
|
|
188
|
+ if (getContainer().getConfigManager().getOptionInt("ui",
|
|
189
|
+ "channelSplitPanePosition") != nicklist.getWidth()) {
|
|
190
|
+ identity.setOption("ui", "channelSplitPanePosition", nicklist.getWidth());
|
|
191
|
+ }
|
204
|
192
|
}
|
205
|
193
|
|
206
|
194
|
@Override
|