|
@@ -79,7 +79,18 @@ import java.nio.charset.IllegalCharsetNameException;
|
79
|
79
|
import java.nio.charset.UnsupportedCharsetException;
|
80
|
80
|
import java.util.concurrent.atomic.AtomicBoolean;
|
81
|
81
|
|
82
|
|
-import javax.swing.*;
|
|
82
|
+import javax.swing.BorderFactory;
|
|
83
|
+import javax.swing.JComponent;
|
|
84
|
+import javax.swing.JInternalFrame;
|
|
85
|
+import javax.swing.JMenu;
|
|
86
|
+import javax.swing.JMenuItem;
|
|
87
|
+import javax.swing.JPanel;
|
|
88
|
+import javax.swing.JPopupMenu;
|
|
89
|
+import javax.swing.JSeparator;
|
|
90
|
+import javax.swing.KeyStroke;
|
|
91
|
+import javax.swing.SwingUtilities;
|
|
92
|
+import javax.swing.UIManager;
|
|
93
|
+import javax.swing.WindowConstants;
|
83
|
94
|
import javax.swing.event.InternalFrameEvent;
|
84
|
95
|
import javax.swing.event.InternalFrameListener;
|
85
|
96
|
import javax.swing.plaf.basic.BasicInternalFrameUI;
|
|
@@ -115,9 +126,9 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
115
|
126
|
/** Are we closing? */
|
116
|
127
|
private boolean closing = false;
|
117
|
128
|
/** Command parser for popup commands. */
|
118
|
|
- private CommandParser commandParser;
|
|
129
|
+ private final CommandParser commandParser;
|
119
|
130
|
/** Swing controller. */
|
120
|
|
- private SwingController controller;
|
|
131
|
+ private final SwingController controller;
|
121
|
132
|
/** Are we maximising/restoring? */
|
122
|
133
|
private AtomicBoolean maximiseRestoreInProgress = new AtomicBoolean(false);
|
123
|
134
|
/** Content pane. */
|
|
@@ -161,8 +172,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
161
|
172
|
setResizable(true);
|
162
|
173
|
setIconifiable(true);
|
163
|
174
|
setFocusable(true);
|
164
|
|
- setPreferredSize(new Dimension(controller.getMainFrame().getWidth() / 2, controller.
|
165
|
|
- getMainFrame().getHeight() / 3));
|
|
175
|
+ setPreferredSize(new Dimension(controller.getMainFrame().getWidth() / 2,
|
|
176
|
+ controller.getMainFrame().getHeight() / 3));
|
166
|
177
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
167
|
178
|
|
168
|
179
|
addPropertyChangeListener("UI", this);
|
|
@@ -186,7 +197,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
186
|
197
|
|
187
|
198
|
/**
|
188
|
199
|
* Locate the appropriate command parser in the window heirarchy.
|
189
|
|
- *
|
|
200
|
+ *
|
190
|
201
|
* @return Closest command parser in the tree
|
191
|
202
|
*/
|
192
|
203
|
private CommandParser findCommandParser() {
|
|
@@ -198,7 +209,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
198
|
209
|
inputWindow.getContainer().getParent());
|
199
|
210
|
}
|
200
|
211
|
if (inputWindow instanceof InputWindow) {
|
201
|
|
- localParser = ((InputWindow) inputWindow).getCommandParser();
|
|
212
|
+ localParser = ((InputWindow) inputWindow).getContainer()
|
|
213
|
+ .getCommandParser();
|
202
|
214
|
}
|
203
|
215
|
|
204
|
216
|
if (localParser == null) {
|
|
@@ -216,7 +228,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
216
|
228
|
|
217
|
229
|
/**
|
218
|
230
|
* {@inheritDoc}
|
219
|
|
- *
|
|
231
|
+ *
|
220
|
232
|
* @deprecated Should use {@link FrameContainer#setTitle(java.lang.String)}
|
221
|
233
|
*/
|
222
|
234
|
@Override
|
|
@@ -234,7 +246,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
234
|
246
|
|
235
|
247
|
/**
|
236
|
248
|
* {@inheritDoc}
|
237
|
|
- *
|
|
249
|
+ *
|
238
|
250
|
* @deprecated Use {@link FrameContainer#getTitle()} instead
|
239
|
251
|
*/
|
240
|
252
|
@Override
|
|
@@ -353,7 +365,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
353
|
365
|
setIcon(true);
|
354
|
366
|
}
|
355
|
367
|
} catch (PropertyVetoException ex) {
|
356
|
|
- Logger.userError(ErrorLevel.LOW, "Unable to minimise frame");
|
|
368
|
+ Logger.userError(ErrorLevel.LOW,
|
|
369
|
+ "Unable to minimise frame");
|
357
|
370
|
}
|
358
|
371
|
}
|
359
|
372
|
});
|
|
@@ -385,7 +398,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
385
|
398
|
setMaximum(true);
|
386
|
399
|
LOGGER.finest("maximise(): Done?");
|
387
|
400
|
} catch (PropertyVetoException ex) {
|
388
|
|
- Logger.userError(ErrorLevel.LOW, "Unable to minimise frame");
|
|
401
|
+ Logger.userError(ErrorLevel.LOW,
|
|
402
|
+ "Unable to minimise frame");
|
389
|
403
|
}
|
390
|
404
|
maximiseRestoreInProgress.set(false);
|
391
|
405
|
|
|
@@ -414,7 +428,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
414
|
428
|
}
|
415
|
429
|
setMaximum(false);
|
416
|
430
|
} catch (PropertyVetoException ex) {
|
417
|
|
- Logger.userError(ErrorLevel.LOW, "Unable to minimise frame");
|
|
431
|
+ Logger.userError(ErrorLevel.LOW,
|
|
432
|
+ "Unable to minimise frame");
|
418
|
433
|
}
|
419
|
434
|
maximiseRestoreInProgress.set(false);
|
420
|
435
|
}
|
|
@@ -440,7 +455,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
440
|
455
|
|
441
|
456
|
/**
|
442
|
457
|
* {@inheritDoc}
|
443
|
|
- *
|
|
458
|
+ *
|
444
|
459
|
* @deprecated Use corresponding methods in {@link FrameContainer} instead
|
445
|
460
|
*/
|
446
|
461
|
@Override
|
|
@@ -451,7 +466,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
451
|
466
|
|
452
|
467
|
/**
|
453
|
468
|
* {@inheritDoc}
|
454
|
|
- *
|
|
469
|
+ *
|
455
|
470
|
* @deprecated Use corresponding methods in {@link FrameContainer} instead
|
456
|
471
|
*/
|
457
|
472
|
@Override
|
|
@@ -462,19 +477,21 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
462
|
477
|
|
463
|
478
|
/**
|
464
|
479
|
* {@inheritDoc}
|
465
|
|
- *
|
|
480
|
+ *
|
466
|
481
|
* @deprecated Use corresponding methods in {@link FrameContainer} instead
|
467
|
482
|
*/
|
468
|
483
|
@Override
|
469
|
484
|
@Deprecated
|
470
|
|
- public final void addLine(final StringBuffer messageType, final Object... args) {
|
|
485
|
+ public final void addLine(final StringBuffer messageType,
|
|
486
|
+ final Object... args) {
|
471
|
487
|
frameParent.addLine(messageType, args);
|
472
|
488
|
}
|
473
|
489
|
|
474
|
490
|
/**
|
475
|
491
|
* {@inheritDoc}
|
476
|
|
- *
|
477
|
|
- * @deprecated Call {@link IRCDocument#clear()} via {@link FrameContainer#getDocument()}
|
|
492
|
+ *
|
|
493
|
+ * @deprecated Call {@link IRCDocument#clear()} via
|
|
494
|
+ * {@link FrameContainer#getDocument()}
|
478
|
495
|
*/
|
479
|
496
|
@Override
|
480
|
497
|
@Deprecated
|
|
@@ -542,13 +559,14 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
542
|
559
|
/**
|
543
|
560
|
* Removes and reinserts the border of an internal frame on maximising.
|
544
|
561
|
* {@inheritDoc}
|
545
|
|
- *
|
|
562
|
+ *
|
546
|
563
|
* @param event Property change event
|
547
|
564
|
*/
|
548
|
565
|
@Override
|
549
|
566
|
public final void propertyChange(final PropertyChangeEvent event) {
|
550
|
567
|
LOGGER.finer("Property change: name: " + event.getPropertyName()
|
551
|
|
- + " value: " + event.getOldValue() + "->" + event.getNewValue());
|
|
568
|
+ + " value: " + event.getOldValue() + "->"
|
|
569
|
+ + event.getNewValue());
|
552
|
570
|
if ("UI".equals(event.getPropertyName())) {
|
553
|
571
|
if (isMaximum()) {
|
554
|
572
|
hideTitlebar();
|
|
@@ -591,7 +609,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
591
|
609
|
final String componentUI = (String) UIManager.get(
|
592
|
610
|
"InternalFrameUI");
|
593
|
611
|
|
594
|
|
- if ("javax.swing.plaf.synth.SynthLookAndFeel".equals(componentUI)) {
|
|
612
|
+ if ("javax.swing.plaf.synth.SynthLookAndFeel"
|
|
613
|
+ .equals(componentUI)) {
|
595
|
614
|
temp = SynthLookAndFeel.createUI(TextFrame.this);
|
596
|
615
|
} else {
|
597
|
616
|
try {
|
|
@@ -642,7 +661,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
642
|
661
|
|
643
|
662
|
/**
|
644
|
663
|
* Not needed for this class. {@inheritDoc}
|
645
|
|
- *
|
|
664
|
+ *
|
646
|
665
|
* @param event Internal frame event
|
647
|
666
|
*/
|
648
|
667
|
@Override
|
|
@@ -652,7 +671,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
652
|
671
|
|
653
|
672
|
/**
|
654
|
673
|
* Not needed for this class. {@inheritDoc}
|
655
|
|
- *
|
|
674
|
+ *
|
656
|
675
|
* @param event Internal frame event
|
657
|
676
|
*/
|
658
|
677
|
@Override
|
|
@@ -670,7 +689,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
670
|
689
|
|
671
|
690
|
/**
|
672
|
691
|
* Not needed for this class. {@inheritDoc}
|
673
|
|
- *
|
|
692
|
+ *
|
674
|
693
|
* @param event Internal frame event
|
675
|
694
|
*/
|
676
|
695
|
@Override
|
|
@@ -680,7 +699,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
680
|
699
|
|
681
|
700
|
/**
|
682
|
701
|
* Makes the internal frame invisible. {@inheritDoc}
|
683
|
|
- *
|
|
702
|
+ *
|
684
|
703
|
* @param event Internal frame event
|
685
|
704
|
*/
|
686
|
705
|
@Override
|
|
@@ -696,7 +715,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
696
|
715
|
|
697
|
716
|
/**
|
698
|
717
|
* Not needed for this class. {@inheritDoc}
|
699
|
|
- *
|
|
718
|
+ *
|
700
|
719
|
* @param event Internal frame event
|
701
|
720
|
*/
|
702
|
721
|
@Override
|
|
@@ -706,7 +725,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
706
|
725
|
|
707
|
726
|
/**
|
708
|
727
|
* Activates the input field on frame focus. {@inheritDoc}
|
709
|
|
- *
|
|
728
|
+ *
|
710
|
729
|
* @param event Internal frame event
|
711
|
730
|
*/
|
712
|
731
|
@Override
|
|
@@ -731,7 +750,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
731
|
750
|
|
732
|
751
|
/**
|
733
|
752
|
* Not needed for this class. {@inheritDoc}
|
734
|
|
- *
|
|
753
|
+ *
|
735
|
754
|
* @param event Internal frame event
|
736
|
755
|
*/
|
737
|
756
|
@Override
|
|
@@ -749,7 +768,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
749
|
768
|
|
750
|
769
|
/**
|
751
|
770
|
* {@inheritDoc}
|
752
|
|
- *
|
|
771
|
+ *
|
753
|
772
|
* @deprecated Use {@link FrameContainer#getConfigManager()}
|
754
|
773
|
*/
|
755
|
774
|
@Deprecated
|
|
@@ -768,7 +787,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
768
|
787
|
}
|
769
|
788
|
|
770
|
789
|
/**
|
771
|
|
- * {@inheritDoc}
|
|
790
|
+ * {@inheritDoc}
|
772
|
791
|
*
|
773
|
792
|
* @deprecated Use {@link FrameContainer#getTranscoder()} instead
|
774
|
793
|
*/
|
|
@@ -819,7 +838,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
819
|
838
|
if (ActionManager.processEvent(
|
820
|
839
|
CoreActionType.LINK_URL_CLICKED, null, this,
|
821
|
840
|
clicktype.getValue())) {
|
822
|
|
- URLHandler.getURLHander().launchApp(clicktype.getValue());
|
|
841
|
+ URLHandler.getURLHander().launchApp(
|
|
842
|
+ clicktype.getValue());
|
823
|
843
|
}
|
824
|
844
|
break;
|
825
|
845
|
case NICKNAME:
|
|
@@ -839,42 +859,42 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
839
|
859
|
|
840
|
860
|
/**
|
841
|
861
|
* What popup type should be used for popup menus for nicknames
|
842
|
|
- *
|
|
862
|
+ *
|
843
|
863
|
* @return Appropriate popuptype for this frame
|
844
|
864
|
*/
|
845
|
865
|
public abstract PopupType getNicknamePopupType();
|
846
|
866
|
|
847
|
867
|
/**
|
848
|
868
|
* What popup type should be used for popup menus for channels
|
849
|
|
- *
|
|
869
|
+ *
|
850
|
870
|
* @return Appropriate popuptype for this frame
|
851
|
871
|
*/
|
852
|
872
|
public abstract PopupType getChannelPopupType();
|
853
|
873
|
|
854
|
874
|
/**
|
855
|
875
|
* What popup type should be used for popup menus for hyperlinks
|
856
|
|
- *
|
|
876
|
+ *
|
857
|
877
|
* @return Appropriate popuptype for this frame
|
858
|
878
|
*/
|
859
|
879
|
public abstract PopupType getHyperlinkPopupType();
|
860
|
880
|
|
861
|
881
|
/**
|
862
|
882
|
* What popup type should be used for popup menus for normal clicks
|
863
|
|
- *
|
|
883
|
+ *
|
864
|
884
|
* @return Appropriate popuptype for this frame
|
865
|
885
|
*/
|
866
|
886
|
public abstract PopupType getNormalPopupType();
|
867
|
887
|
|
868
|
888
|
/**
|
869
|
889
|
* A method called to add custom popup items.
|
870
|
|
- *
|
|
890
|
+ *
|
871
|
891
|
* @param popupMenu Popup menu to add popup items to
|
872
|
892
|
*/
|
873
|
893
|
public abstract void addCustomPopupItems(final JPopupMenu popupMenu);
|
874
|
894
|
|
875
|
895
|
/**
|
876
|
|
- * Shows a popup menu at the specified point for the specified click type
|
877
|
|
- *
|
|
896
|
+ * Shows a popup menu at the specified point for the specified click type.
|
|
897
|
+ *
|
878
|
898
|
* @param type ClickType Click type
|
879
|
899
|
* @param point Point Point of the click
|
880
|
900
|
* @param argument Word under the click
|
|
@@ -885,7 +905,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
885
|
905
|
|
886
|
906
|
switch (type.getType()) {
|
887
|
907
|
case CHANNEL:
|
888
|
|
- popupMenu = getPopupMenu(getChannelPopupType(), type.getValue());
|
|
908
|
+ popupMenu = getPopupMenu(getChannelPopupType(),
|
|
909
|
+ type.getValue());
|
889
|
910
|
popupMenu.add(new ChannelCopyAction(type.getValue()));
|
890
|
911
|
if (popupMenu.getComponentCount() > 1) {
|
891
|
912
|
popupMenu.addSeparator();
|
|
@@ -893,7 +914,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
893
|
914
|
|
894
|
915
|
break;
|
895
|
916
|
case HYPERLINK:
|
896
|
|
- popupMenu = getPopupMenu(getHyperlinkPopupType(), type.getValue());
|
|
917
|
+ popupMenu = getPopupMenu(getHyperlinkPopupType(),
|
|
918
|
+ type.getValue());
|
897
|
919
|
popupMenu.add(new HyperlinkCopyAction(type.getValue()));
|
898
|
920
|
if (popupMenu.getComponentCount() > 1) {
|
899
|
921
|
popupMenu.addSeparator();
|
|
@@ -901,7 +923,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
901
|
923
|
|
902
|
924
|
break;
|
903
|
925
|
case NICKNAME:
|
904
|
|
- popupMenu = getPopupMenu(getNicknamePopupType(), type.getValue());
|
|
926
|
+ popupMenu = getPopupMenu(getNicknamePopupType(),
|
|
927
|
+ type.getValue());
|
905
|
928
|
if (popupMenu.getComponentCount() > 0) {
|
906
|
929
|
popupMenu.addSeparator();
|
907
|
930
|
}
|
|
@@ -935,10 +958,10 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
935
|
958
|
|
936
|
959
|
/**
|
937
|
960
|
* Builds a popup menu of a specified type
|
938
|
|
- *
|
|
961
|
+ *
|
939
|
962
|
* @param type type of menu to build
|
940
|
963
|
* @param arguments Arguments for the command
|
941
|
|
- *
|
|
964
|
+ *
|
942
|
965
|
* @return PopupMenu
|
943
|
966
|
*/
|
944
|
967
|
public JPopupMenu getPopupMenu(
|
|
@@ -956,12 +979,12 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
956
|
979
|
}
|
957
|
980
|
|
958
|
981
|
/**
|
959
|
|
- * Populates the specified popupmenu
|
960
|
|
- *
|
|
982
|
+ * Populates the specified popupmenu.
|
|
983
|
+ *
|
961
|
984
|
* @param menu Menu component
|
962
|
985
|
* @param popup Popup to get info from
|
963
|
986
|
* @param arguments Arguments for the command
|
964
|
|
- *
|
|
987
|
+ *
|
965
|
988
|
* @return Populated popup
|
966
|
989
|
*/
|
967
|
990
|
private JComponent populatePopupMenu(final JComponent menu,
|
|
@@ -1026,13 +1049,15 @@ public abstract class TextFrame extends JInternalFrame implements Window,
|
1026
|
1049
|
|
1027
|
1050
|
/** {@inheritDoc} */
|
1028
|
1051
|
@Override
|
1029
|
|
- public void nameChanged(final FrameContainer<?> window, final String name) {
|
|
1052
|
+ public void nameChanged(final FrameContainer<?> window,
|
|
1053
|
+ final String name) {
|
1030
|
1054
|
//Ignore
|
1031
|
1055
|
}
|
1032
|
1056
|
|
1033
|
1057
|
/** {@inheritDoc} */
|
1034
|
1058
|
@Override
|
1035
|
|
- public void titleChanged(final FrameContainer<?> window, final String title) {
|
|
1059
|
+ public void titleChanged(final FrameContainer<?> window,
|
|
1060
|
+ final String title) {
|
1036
|
1061
|
UIUtilities.invokeLater(new Runnable() {
|
1037
|
1062
|
|
1038
|
1063
|
/** {@inheritDoc} */
|