|
@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_swing.components.frames;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.DMDircMBassador;
|
26
|
26
|
import com.dmdirc.FrameContainer;
|
|
27
|
+import com.dmdirc.addons.ui_swing.EDTInvocation;
|
27
|
28
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
28
|
29
|
import com.dmdirc.addons.ui_swing.actions.CopyAction;
|
29
|
30
|
import com.dmdirc.addons.ui_swing.actions.CutAction;
|
|
@@ -33,9 +34,9 @@ import com.dmdirc.addons.ui_swing.components.TypingLabel;
|
33
|
34
|
import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
|
34
|
35
|
import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputHandler;
|
35
|
36
|
import com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialogFactory;
|
|
37
|
+import com.dmdirc.config.ConfigBinding;
|
36
|
38
|
import com.dmdirc.events.UserErrorEvent;
|
37
|
39
|
import com.dmdirc.interfaces.CommandController;
|
38
|
|
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
39
|
40
|
import com.dmdirc.interfaces.ui.InputWindow;
|
40
|
41
|
import com.dmdirc.logger.ErrorLevel;
|
41
|
42
|
import com.dmdirc.plugins.PluginManager;
|
|
@@ -43,6 +44,7 @@ import com.dmdirc.ui.input.InputHandler;
|
43
|
44
|
import com.dmdirc.ui.input.TabCompleterUtils;
|
44
|
45
|
|
45
|
46
|
import java.awt.BorderLayout;
|
|
47
|
+import java.awt.Color;
|
46
|
48
|
import java.awt.Point;
|
47
|
49
|
import java.awt.Toolkit;
|
48
|
50
|
import java.awt.Window;
|
|
@@ -64,13 +66,10 @@ import net.miginfocom.layout.PlatformDefaults;
|
64
|
66
|
/**
|
65
|
67
|
* Frame with an input field.
|
66
|
68
|
*/
|
67
|
|
-public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
68
|
|
- MouseListener {
|
|
69
|
+public abstract class InputTextFrame extends TextFrame implements InputWindow, MouseListener {
|
69
|
70
|
|
70
|
71
|
/** Serial version UID. */
|
71
|
72
|
private static final long serialVersionUID = 3;
|
72
|
|
- /** Config provider for this frame. */
|
73
|
|
- private final AggregateConfigProvider config;
|
74
|
73
|
/** Input field panel. */
|
75
|
74
|
protected JPanel inputPanel;
|
76
|
75
|
/** The InputHandler for our input field. */
|
|
@@ -111,7 +110,6 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
111
|
110
|
final FrameContainer owner) {
|
112
|
111
|
super(owner, owner.getCommandParser(), deps);
|
113
|
112
|
|
114
|
|
- config = owner.getConfigManager();
|
115
|
113
|
parentWindow = deps.mainWindow;
|
116
|
114
|
pluginManager = deps.pluginManager;
|
117
|
115
|
pasteDialogFactory = deps.pasteDialog;
|
|
@@ -121,36 +119,15 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
121
|
119
|
|
122
|
120
|
initComponents(inputFieldProvider, deps.tabCompleterUtils);
|
123
|
121
|
|
124
|
|
- if (!UIUtilities.isGTKUI()) {
|
125
|
|
- //GTK users appear to dislike choice, ignore them if they want some.
|
126
|
|
- getInputField().setBackground(UIUtilities.convertColour(
|
127
|
|
- colourManager.getColourFromString(
|
128
|
|
- config.getOptionString(
|
129
|
|
- "ui", "inputbackgroundcolour",
|
130
|
|
- "ui", "backgroundcolour"), null)));
|
131
|
|
- getInputField().setForeground(UIUtilities.convertColour(
|
132
|
|
- colourManager.getColourFromString(
|
133
|
|
- config.getOptionString(
|
134
|
|
- "ui", "inputforegroundcolour",
|
135
|
|
- "ui", "foregroundcolour"), null)));
|
136
|
|
- getInputField().setCaretColor(UIUtilities.convertColour(
|
137
|
|
- colourManager.getColourFromString(
|
138
|
|
- config.getOptionString(
|
139
|
|
- "ui", "inputforegroundcolour",
|
140
|
|
- "ui", "foregroundcolour"), null)));
|
141
|
|
- }
|
142
|
|
-
|
143
|
|
- config.addChangeListener("ui", "inputforegroundcolour", this);
|
144
|
|
- config.addChangeListener("ui", "inputbackgroundcolour", this);
|
|
122
|
+ getContainer().getConfigManager().getBinder().bind(this, InputTextFrame.class);
|
145
|
123
|
|
146
|
|
- getInputField().getTextField().getInputMap().put(KeyStroke.getKeyStroke(
|
147
|
|
- KeyEvent.VK_C, UIUtilities.getCtrlMask()), "textpaneCopy");
|
|
124
|
+ getInputField().getTextField().getInputMap().put(
|
|
125
|
+ KeyStroke.getKeyStroke(KeyEvent.VK_C, UIUtilities.getCtrlMask()), "textpaneCopy");
|
148
|
126
|
getInputField().getTextField().getInputMap().put(KeyStroke.getKeyStroke(
|
149
|
127
|
KeyEvent.VK_C, UIUtilities.getCtrlMask()
|
150
|
128
|
| KeyEvent.SHIFT_DOWN_MASK), "textpaneCopy");
|
151
|
129
|
getInputField().getTextField().getActionMap().put("textpaneCopy",
|
152
|
|
- new InputFieldCopyAction(getTextPane(),
|
153
|
|
- getInputField().getTextField()));
|
|
130
|
+ new InputFieldCopyAction(getTextPane(), getInputField().getTextField()));
|
154
|
131
|
}
|
155
|
132
|
|
156
|
133
|
/**
|
|
@@ -349,46 +326,25 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
349
|
326
|
return line.replace("\r\n", "\n").replace('\r', '\n').split("\n");
|
350
|
327
|
}
|
351
|
328
|
|
352
|
|
- @Override
|
353
|
|
- public void configChanged(final String domain, final String key) {
|
354
|
|
- super.configChanged(domain, key);
|
355
|
|
-
|
356
|
|
- if ("ui".equals(domain) && getContainer().getConfigManager() != null
|
357
|
|
- && getInputField() != null && !UIUtilities.isGTKUI()) {
|
358
|
|
- switch (key) {
|
359
|
|
- case "inputbackgroundcolour":
|
360
|
|
- case "backgroundcolour":
|
361
|
|
- getInputField().setBackground(UIUtilities.convertColour(
|
362
|
|
- colourManager.getColourFromString(
|
363
|
|
- config.getOptionString(
|
364
|
|
- "ui", "inputbackgroundcolour",
|
365
|
|
- "ui", "backgroundcolour"), null)));
|
366
|
|
- break;
|
367
|
|
- case "inputforegroundcolour":
|
368
|
|
- case "foregroundcolour":
|
369
|
|
- getInputField().setForeground(UIUtilities.convertColour(
|
370
|
|
- colourManager.getColourFromString(
|
371
|
|
- config.getOptionString(
|
372
|
|
- "ui", "inputforegroundcolour",
|
373
|
|
- "ui", "foregroundcolour"), null)));
|
374
|
|
- getInputField().setCaretColor(UIUtilities.convertColour(
|
375
|
|
- colourManager.getColourFromString(
|
376
|
|
- config.getOptionString(
|
377
|
|
- "ui", "inputforegroundcolour",
|
378
|
|
- "ui", "foregroundcolour"), null)));
|
379
|
|
- break;
|
380
|
|
- default:
|
381
|
|
- //Do nothing
|
382
|
|
- break;
|
383
|
|
- }
|
|
329
|
+ @ConfigBinding(domain="ui", key="inputbackgroundcolour",
|
|
330
|
+ fallbacks = {"ui", "backgroundcolour"}, invocation = EDTInvocation.class)
|
|
331
|
+ public void handleInputBackgroundColour(final String value) {
|
|
332
|
+ if (getInputField() == null || UIUtilities.isGTKUI()) {
|
|
333
|
+ return;
|
384
|
334
|
}
|
|
335
|
+ getInputField().setBackground(UIUtilities.convertColour(
|
|
336
|
+ colourManager.getColourFromString(value, null)));
|
385
|
337
|
}
|
386
|
338
|
|
387
|
|
- /** Request input field focus. */
|
388
|
|
- public void requestInputFieldFocus() {
|
389
|
|
- if (inputField != null) {
|
390
|
|
- inputField.requestFocusInWindow();
|
|
339
|
+ @ConfigBinding(domain = "ui", key="inputforegroundcolour", fallbacks = {"ui",
|
|
340
|
+ "foregroundcolour"}, invocation = EDTInvocation.class)
|
|
341
|
+ public void handleInputForegroundColour(final String value) {
|
|
342
|
+ if (getInputField() == null || UIUtilities.isGTKUI()) {
|
|
343
|
+ return;
|
391
|
344
|
}
|
|
345
|
+ final Color colour = UIUtilities.convertColour(colourManager.getColourFromString(value, null));
|
|
346
|
+ getInputField().setForeground(colour);
|
|
347
|
+ getInputField().setCaretColor(colour);
|
392
|
348
|
}
|
393
|
349
|
|
394
|
350
|
@Override
|
|
@@ -399,7 +355,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
399
|
355
|
|
400
|
356
|
@Override
|
401
|
357
|
public void dispose() {
|
402
|
|
- frameParent.getConfigManager().removeListener(this);
|
|
358
|
+ getContainer().getConfigManager().getBinder().unbind(this);
|
403
|
359
|
super.dispose();
|
404
|
360
|
}
|
405
|
361
|
|