|
@@ -23,7 +23,7 @@
|
23
|
23
|
package com.dmdirc.addons.ui_swing.components.frames;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.WritableFrameContainer;
|
26
|
|
-import com.dmdirc.addons.ui_swing.SwingController;
|
|
26
|
+import com.dmdirc.addons.ui_swing.MainFrame;
|
27
|
27
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
28
|
28
|
import com.dmdirc.addons.ui_swing.actions.CopyAction;
|
29
|
29
|
import com.dmdirc.addons.ui_swing.actions.CutAction;
|
|
@@ -33,11 +33,12 @@ import com.dmdirc.addons.ui_swing.components.AwayLabel;
|
33
|
33
|
import com.dmdirc.addons.ui_swing.components.TypingLabel;
|
34
|
34
|
import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
|
35
|
35
|
import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputHandler;
|
36
|
|
-import com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialog;
|
|
36
|
+import com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialogFactory;
|
37
|
37
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
38
|
38
|
import com.dmdirc.interfaces.ui.InputWindow;
|
39
|
39
|
import com.dmdirc.logger.ErrorLevel;
|
40
|
40
|
import com.dmdirc.logger.Logger;
|
|
41
|
+import com.dmdirc.plugins.PluginManager;
|
41
|
42
|
import com.dmdirc.ui.input.InputHandler;
|
42
|
43
|
import com.dmdirc.ui.messages.ColourManager;
|
43
|
44
|
|
|
@@ -51,6 +52,7 @@ import java.awt.event.MouseEvent;
|
51
|
52
|
import java.awt.event.MouseListener;
|
52
|
53
|
import java.io.IOException;
|
53
|
54
|
|
|
55
|
+import javax.inject.Provider;
|
54
|
56
|
import javax.swing.JPanel;
|
55
|
57
|
import javax.swing.JPopupMenu;
|
56
|
58
|
import javax.swing.KeyStroke;
|
|
@@ -65,8 +67,6 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
65
|
67
|
|
66
|
68
|
/** Serial version UID. */
|
67
|
69
|
private static final long serialVersionUID = 3;
|
68
|
|
- /** Swing controller. */
|
69
|
|
- private final SwingController controller;
|
70
|
70
|
/** Config provider for this frame. */
|
71
|
71
|
private final AggregateConfigProvider config;
|
72
|
72
|
/** Colour manager for this frame. */
|
|
@@ -85,6 +85,12 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
85
|
85
|
private AwayLabel awayLabel;
|
86
|
86
|
/** Typing indicator label. */
|
87
|
87
|
private TypingLabel typingLabel;
|
|
88
|
+ /** Main frame. */
|
|
89
|
+ private final Provider<MainFrame> mainFrame;
|
|
90
|
+ /** Plugin Manager. */
|
|
91
|
+ private final PluginManager pluginManager;
|
|
92
|
+ /** Paste dialog factory. */
|
|
93
|
+ private final PasteDialogFactory pasteDialogFactory;
|
88
|
94
|
|
89
|
95
|
/**
|
90
|
96
|
* Creates a new instance of InputFrame.
|
|
@@ -97,9 +103,11 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
97
|
103
|
final WritableFrameContainer owner) {
|
98
|
104
|
super(owner, deps);
|
99
|
105
|
|
100
|
|
- this.controller = getController();
|
101
|
106
|
this.config = owner.getConfigManager();
|
102
|
107
|
this.colourManager = new ColourManager(config);
|
|
108
|
+ this.mainFrame = deps.mainFrame;
|
|
109
|
+ this.pluginManager = deps.pluginManager;
|
|
110
|
+ this.pasteDialogFactory = deps.pasteDialog;
|
103
|
111
|
|
104
|
112
|
initComponents();
|
105
|
113
|
|
|
@@ -107,19 +115,19 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
107
|
115
|
//GTK users appear to dislike choice, ignore them if they want some.
|
108
|
116
|
getInputField().setBackground(UIUtilities.convertColour(
|
109
|
117
|
colourManager.getColourFromString(
|
110
|
|
- config.getOptionString(
|
111
|
|
- "ui", "inputbackgroundcolour",
|
112
|
|
- "ui", "backgroundcolour"), null)));
|
|
118
|
+ config.getOptionString(
|
|
119
|
+ "ui", "inputbackgroundcolour",
|
|
120
|
+ "ui", "backgroundcolour"), null)));
|
113
|
121
|
getInputField().setForeground(UIUtilities.convertColour(
|
114
|
122
|
colourManager.getColourFromString(
|
115
|
|
- config.getOptionString(
|
116
|
|
- "ui", "inputforegroundcolour",
|
117
|
|
- "ui", "foregroundcolour"), null)));
|
|
123
|
+ config.getOptionString(
|
|
124
|
+ "ui", "inputforegroundcolour",
|
|
125
|
+ "ui", "foregroundcolour"), null)));
|
118
|
126
|
getInputField().setCaretColor(UIUtilities.convertColour(
|
119
|
127
|
colourManager.getColourFromString(
|
120
|
|
- config.getOptionString(
|
121
|
|
- "ui", "inputforegroundcolour",
|
122
|
|
- "ui", "foregroundcolour"), null)));
|
|
128
|
+ config.getOptionString(
|
|
129
|
+ "ui", "inputforegroundcolour",
|
|
130
|
+ "ui", "foregroundcolour"), null)));
|
123
|
131
|
}
|
124
|
132
|
|
125
|
133
|
config.addChangeListener("ui", "inputforegroundcolour", this);
|
|
@@ -132,16 +140,16 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
132
|
140
|
| KeyEvent.SHIFT_DOWN_MASK), "textpaneCopy");
|
133
|
141
|
getInputField().getTextField().getActionMap().put("textpaneCopy",
|
134
|
142
|
new InputFieldCopyAction(getTextPane(),
|
135
|
|
- getInputField().getTextField()));
|
|
143
|
+ getInputField().getTextField()));
|
136
|
144
|
}
|
137
|
145
|
|
138
|
146
|
/**
|
139
|
147
|
* Initialises the components for this frame.
|
140
|
148
|
*/
|
141
|
149
|
private void initComponents() {
|
142
|
|
- inputField = new SwingInputField(this, getController().getMainFrame());
|
143
|
|
- inputHandler = new SwingInputHandler(controller.getPluginManager(),
|
144
|
|
- inputField, getContainer().getCommandParser(), getContainer());
|
|
150
|
+ inputField = new SwingInputField(this, mainFrame.get());
|
|
151
|
+ inputHandler = new SwingInputHandler(pluginManager, inputField,
|
|
152
|
+ getContainer().getCommandParser(), getContainer());
|
145
|
153
|
inputHandler.addValidationListener(inputField);
|
146
|
154
|
inputHandler.setTabCompleter(((WritableFrameContainer) frameParent).
|
147
|
155
|
getTabCompleter());
|
|
@@ -331,7 +339,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
331
|
339
|
//- selection + clipboard)
|
332
|
340
|
final String text = inputFieldText.substring(0, getInputField().
|
333
|
341
|
getSelectionStart()) + clipboard + inputFieldText.substring(
|
334
|
|
- getInputField().getSelectionEnd());
|
|
342
|
+ getInputField().getSelectionEnd());
|
335
|
343
|
final String[] clipboardLines = getSplitLine(text);
|
336
|
344
|
//check theres something to paste
|
337
|
345
|
if (clipboardLines.length > 1) {
|
|
@@ -343,8 +351,8 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
343
|
351
|
if (pasteTrigger != null && getContainer().getNumLines(text)
|
344
|
352
|
> pasteTrigger) {
|
345
|
353
|
//show the multi line paste dialog
|
346
|
|
- new PasteDialog(controller, this, text, getController()
|
347
|
|
- .getMainFrame()).display();
|
|
354
|
+ pasteDialogFactory.getPasteDialog(this, text, mainFrame.get()).
|
|
355
|
+ displayOrRequestFocus();
|
348
|
356
|
} else {
|
349
|
357
|
//send the lines
|
350
|
358
|
for (final String clipboardLine : clipboardLines) {
|
|
@@ -380,22 +388,22 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
380
|
388
|
case "backgroundcolour":
|
381
|
389
|
getInputField().setBackground(UIUtilities.convertColour(
|
382
|
390
|
colourManager.getColourFromString(
|
383
|
|
- config.getOptionString(
|
384
|
|
- "ui", "inputbackgroundcolour",
|
385
|
|
- "ui", "backgroundcolour"), null)));
|
|
391
|
+ config.getOptionString(
|
|
392
|
+ "ui", "inputbackgroundcolour",
|
|
393
|
+ "ui", "backgroundcolour"), null)));
|
386
|
394
|
break;
|
387
|
395
|
case "inputforegroundcolour":
|
388
|
396
|
case "foregroundcolour":
|
389
|
397
|
getInputField().setForeground(UIUtilities.convertColour(
|
390
|
398
|
colourManager.getColourFromString(
|
391
|
|
- config.getOptionString(
|
392
|
|
- "ui", "inputforegroundcolour",
|
393
|
|
- "ui", "foregroundcolour"), null)));
|
|
399
|
+ config.getOptionString(
|
|
400
|
+ "ui", "inputforegroundcolour",
|
|
401
|
+ "ui", "foregroundcolour"), null)));
|
394
|
402
|
getInputField().setCaretColor(UIUtilities.convertColour(
|
395
|
403
|
colourManager.getColourFromString(
|
396
|
|
- config.getOptionString(
|
397
|
|
- "ui", "inputforegroundcolour",
|
398
|
|
- "ui", "foregroundcolour"), null)));
|
|
404
|
+ config.getOptionString(
|
|
405
|
+ "ui", "inputforegroundcolour",
|
|
406
|
+ "ui", "foregroundcolour"), null)));
|
399
|
407
|
break;
|
400
|
408
|
}
|
401
|
409
|
}
|