|
@@ -33,11 +33,11 @@ import com.dmdirc.addons.ui_swing.components.TypingLabel;
|
33
|
33
|
import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
|
34
|
34
|
import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputHandler;
|
35
|
35
|
import com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialogFactory;
|
|
36
|
+import com.dmdirc.events.UserErrorEvent;
|
36
|
37
|
import com.dmdirc.interfaces.CommandController;
|
37
|
38
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
38
|
39
|
import com.dmdirc.interfaces.ui.InputWindow;
|
39
|
40
|
import com.dmdirc.logger.ErrorLevel;
|
40
|
|
-import com.dmdirc.logger.Logger;
|
41
|
41
|
import com.dmdirc.plugins.PluginManager;
|
42
|
42
|
import com.dmdirc.ui.input.InputHandler;
|
43
|
43
|
import com.dmdirc.ui.messages.ColourManager;
|
|
@@ -109,20 +109,20 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
109
|
109
|
* @param inputFieldProvider The provider to use to create a new input field.
|
110
|
110
|
* @param owner WritableFrameContainer owning this frame.
|
111
|
111
|
*/
|
112
|
|
- public InputTextFrame(
|
|
112
|
+ protected InputTextFrame(
|
113
|
113
|
final TextFrameDependencies deps,
|
114
|
114
|
final Provider<SwingInputField> inputFieldProvider,
|
115
|
115
|
final FrameContainer owner) {
|
116
|
116
|
super(owner, owner.getCommandParser(), deps);
|
117
|
117
|
|
118
|
|
- this.config = owner.getConfigManager();
|
119
|
|
- this.colourManager = new ColourManager(config);
|
120
|
|
- this.parentWindow = deps.mainWindow;
|
121
|
|
- this.pluginManager = deps.pluginManager;
|
122
|
|
- this.pasteDialogFactory = deps.pasteDialog;
|
123
|
|
- this.clipboard = deps.clipboard;
|
124
|
|
- this.commandController = deps.commandController;
|
125
|
|
- this.eventBus = deps.eventBus;
|
|
118
|
+ config = owner.getConfigManager();
|
|
119
|
+ colourManager = new ColourManager(config);
|
|
120
|
+ parentWindow = deps.mainWindow;
|
|
121
|
+ pluginManager = deps.pluginManager;
|
|
122
|
+ pasteDialogFactory = deps.pasteDialog;
|
|
123
|
+ clipboard = deps.clipboard;
|
|
124
|
+ commandController = deps.commandController;
|
|
125
|
+ eventBus = deps.eventBus;
|
126
|
126
|
|
127
|
127
|
initComponents(inputFieldProvider);
|
128
|
128
|
|
|
@@ -233,11 +233,6 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
233
|
233
|
return inputField;
|
234
|
234
|
}
|
235
|
235
|
|
236
|
|
- /**
|
237
|
|
- * {@inheritDoc}
|
238
|
|
- *
|
239
|
|
- * @param mouseEvent Mouse event
|
240
|
|
- */
|
241
|
236
|
@Override
|
242
|
237
|
public void mouseClicked(final MouseEvent mouseEvent) {
|
243
|
238
|
if (mouseEvent.getSource() == getTextPane()) {
|
|
@@ -245,51 +240,26 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
245
|
240
|
}
|
246
|
241
|
}
|
247
|
242
|
|
248
|
|
- /**
|
249
|
|
- * {@inheritDoc}
|
250
|
|
- *
|
251
|
|
- * @param mouseEvent Mouse event
|
252
|
|
- */
|
253
|
243
|
@Override
|
254
|
244
|
public void mousePressed(final MouseEvent mouseEvent) {
|
255
|
245
|
processMouseEvent(mouseEvent);
|
256
|
246
|
}
|
257
|
247
|
|
258
|
|
- /**
|
259
|
|
- * {@inheritDoc}
|
260
|
|
- *
|
261
|
|
- * @param mouseEvent Mouse event
|
262
|
|
- */
|
263
|
248
|
@Override
|
264
|
249
|
public void mouseReleased(final MouseEvent mouseEvent) {
|
265
|
250
|
processMouseEvent(mouseEvent);
|
266
|
251
|
}
|
267
|
252
|
|
268
|
|
- /**
|
269
|
|
- * {@inheritDoc}
|
270
|
|
- *
|
271
|
|
- * @param mouseEvent Mouse event
|
272
|
|
- */
|
273
|
253
|
@Override
|
274
|
254
|
public void mouseExited(final MouseEvent mouseEvent) {
|
275
|
255
|
//Ignore
|
276
|
256
|
}
|
277
|
257
|
|
278
|
|
- /**
|
279
|
|
- * {@inheritDoc}
|
280
|
|
- *
|
281
|
|
- * @param mouseEvent Mouse event
|
282
|
|
- */
|
283
|
258
|
@Override
|
284
|
259
|
public void mouseEntered(final MouseEvent mouseEvent) {
|
285
|
260
|
//Ignore
|
286
|
261
|
}
|
287
|
262
|
|
288
|
|
- /**
|
289
|
|
- * Processes every mouse button event to check for a popup trigger.
|
290
|
|
- *
|
291
|
|
- * @param e mouse event
|
292
|
|
- */
|
293
|
263
|
@Override
|
294
|
264
|
public void processMouseEvent(final MouseEvent e) {
|
295
|
265
|
if (e.isPopupTrigger() && e.getSource() == getInputField()) {
|
|
@@ -312,7 +282,8 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
312
|
282
|
return;
|
313
|
283
|
}
|
314
|
284
|
} catch (final IllegalStateException ex) {
|
315
|
|
- Logger.userError(ErrorLevel.LOW, "Unable to paste from clipboard.");
|
|
285
|
+ eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex,
|
|
286
|
+ "Unable to past from clipboard.", ""));
|
316
|
287
|
return;
|
317
|
288
|
}
|
318
|
289
|
|
|
@@ -322,10 +293,11 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
322
|
293
|
doPaste((String) Toolkit.getDefaultToolkit()
|
323
|
294
|
.getSystemClipboard().getData(DataFlavor.stringFlavor));
|
324
|
295
|
} catch (final IOException ex) {
|
325
|
|
- Logger.userError(ErrorLevel.LOW,
|
326
|
|
- "Unable to get clipboard contents: " + ex.getMessage());
|
|
296
|
+ eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex,
|
|
297
|
+ "Unable to get clipboard contents: " + ex.getMessage(), ""));
|
327
|
298
|
} catch (final UnsupportedFlavorException ex) {
|
328
|
|
- Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
|
|
299
|
+ eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex,
|
|
300
|
+ "Unsupported clipboard type", ""));
|
329
|
301
|
}
|
330
|
302
|
}
|
331
|
303
|
|
|
@@ -407,6 +379,9 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
|
407
|
379
|
"ui", "inputforegroundcolour",
|
408
|
380
|
"ui", "foregroundcolour"), null)));
|
409
|
381
|
break;
|
|
382
|
+ default:
|
|
383
|
+ //Do nothing
|
|
384
|
+ break;
|
410
|
385
|
}
|
411
|
386
|
}
|
412
|
387
|
}
|