|
@@ -90,6 +90,12 @@ public class TopicBar extends JComponent implements ActionListener,
|
90
|
90
|
private Color backgroundColour;
|
91
|
91
|
/** Error icon. */
|
92
|
92
|
private final JLabel errorIcon;
|
|
93
|
+ /** Show the topic bar? */
|
|
94
|
+ private boolean showBar;
|
|
95
|
+ /** Show the full topic, or truncate? */
|
|
96
|
+ private boolean showFull;
|
|
97
|
+ /** Hide topic bar when topic is empty? */
|
|
98
|
+ private boolean hideEmpty;
|
93
|
99
|
|
94
|
100
|
/**
|
95
|
101
|
* Instantiates a new topic bar.
|
|
@@ -106,10 +112,10 @@ public class TopicBar extends JComponent implements ActionListener,
|
106
|
112
|
topicText = new TextPaneInputField(channelFrame.getController(),
|
107
|
113
|
parentWindow);
|
108
|
114
|
topicLengthMax = channel.getMaxTopicLength();
|
|
115
|
+ updateOptions();
|
109
|
116
|
errorIcon = new JLabel(channelFrame.getIconManager()
|
110
|
117
|
.getIcon("input-error"));
|
111
|
|
- topicText.setEditorKit(new WrapEditorKit(channel.getConfigManager()
|
112
|
|
- .getOptionBool(controller.getDomain(), "showfulltopic")));
|
|
118
|
+ topicText.setEditorKit(new WrapEditorKit(showFull));
|
113
|
119
|
((DefaultStyledDocument) topicText.getDocument()).setDocumentFilter(
|
114
|
120
|
new NewlinesDocumentFilter());
|
115
|
121
|
|
|
@@ -150,7 +156,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
150
|
156
|
"enterButton");
|
151
|
157
|
topicText.getActionMap().put("enterButton", new AbstractAction(
|
152
|
158
|
"enterButton") {
|
153
|
|
-
|
154
|
159
|
/**
|
155
|
160
|
* A version number for this class. It should be changed whenever the class
|
156
|
161
|
* structure is changed (or anything else that would prevent serialized
|
|
@@ -168,7 +173,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
168
|
173
|
"escapeButton");
|
169
|
174
|
topicText.getActionMap().put("escapeButton", new AbstractAction(
|
170
|
175
|
"escapeButton") {
|
171
|
|
-
|
172
|
176
|
private static final long serialVersionUID = 1;
|
173
|
177
|
|
174
|
178
|
/** {@inheritDoc} */
|
|
@@ -192,7 +196,10 @@ public class TopicBar extends JComponent implements ActionListener,
|
192
|
196
|
controller.getDomain(), "showfulltopic", this);
|
193
|
197
|
controller.getGlobalConfig().addChangeListener(
|
194
|
198
|
controller.getDomain(), "hideEmptyTopicBar", this);
|
|
199
|
+ controller.getGlobalConfig().addChangeListener(
|
|
200
|
+ controller.getDomain(), "showtopicbar", this);
|
195
|
201
|
|
|
202
|
+ setVisible(true);
|
196
|
203
|
topicText.setFocusable(false);
|
197
|
204
|
topicText.setEditable(false);
|
198
|
205
|
topicCancel.setVisible(false);
|
|
@@ -204,7 +211,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
204
|
211
|
@Override
|
205
|
212
|
public final void topicChanged(final Channel channel, final Topic topic) {
|
206
|
213
|
UIUtilities.invokeLater(new Runnable() {
|
207
|
|
-
|
208
|
214
|
/** {@inheritDoc} */
|
209
|
215
|
@Override
|
210
|
216
|
public void run() {
|
|
@@ -216,15 +222,10 @@ public class TopicBar extends JComponent implements ActionListener,
|
216
|
222
|
channel.getStyliser().addStyledString(
|
217
|
223
|
(StyledDocument) topicText.getDocument(),
|
218
|
224
|
new String[]{Styliser.CODE_HEXCOLOUR
|
219
|
|
- + UIUtilities.getHex(foregroundColour)
|
220
|
|
- + channel.getCurrentTopic().getTopic(), },
|
|
225
|
+ + UIUtilities.getHex(foregroundColour)
|
|
226
|
+ + channel.getCurrentTopic().getTopic(),},
|
221
|
227
|
as);
|
222
|
228
|
}
|
223
|
|
- if (channel.getConfigManager().getOptionBool(controller.
|
224
|
|
- getDomain(),
|
225
|
|
- "hideEmptyTopicBar")) {
|
226
|
|
- setVisible(topicText.getDocument().getLength() != 0);
|
227
|
|
- }
|
228
|
229
|
topicText.setCaretPosition(0);
|
229
|
230
|
validateTopic();
|
230
|
231
|
setVisible(false);
|
|
@@ -233,6 +234,20 @@ public class TopicBar extends JComponent implements ActionListener,
|
233
|
234
|
});
|
234
|
235
|
}
|
235
|
236
|
|
|
237
|
+ /** {@inheritDoc} */
|
|
238
|
+ @Override
|
|
239
|
+ public void setVisible(final boolean visibility) {
|
|
240
|
+ if (!showBar || !visibility) {
|
|
241
|
+ super.setVisible(false);
|
|
242
|
+ return;
|
|
243
|
+ }
|
|
244
|
+ if (hideEmpty) {
|
|
245
|
+ super.setVisible(topicText.getDocument().getLength() != 0);
|
|
246
|
+ return;
|
|
247
|
+ }
|
|
248
|
+ super.setVisible(true);
|
|
249
|
+ }
|
|
250
|
+
|
236
|
251
|
/**
|
237
|
252
|
* {@inheritDoc}
|
238
|
253
|
*
|
|
@@ -373,7 +388,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
373
|
388
|
*/
|
374
|
389
|
public void setCaretPosition(final int position) {
|
375
|
390
|
UIUtilities.invokeLater(new Runnable() {
|
376
|
|
-
|
377
|
391
|
/** {@inheritDoc} */
|
378
|
392
|
@Override
|
379
|
393
|
public void run() {
|
|
@@ -389,7 +403,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
389
|
403
|
*/
|
390
|
404
|
public void setCaretColor(final Color optionColour) {
|
391
|
405
|
UIUtilities.invokeLater(new Runnable() {
|
392
|
|
-
|
393
|
406
|
/** {@inheritDoc} */
|
394
|
407
|
@Override
|
395
|
408
|
public void run() {
|
|
@@ -406,7 +419,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
406
|
419
|
@Override
|
407
|
420
|
public void setForeground(final Color optionColour) {
|
408
|
421
|
UIUtilities.invokeLater(new Runnable() {
|
409
|
|
-
|
410
|
422
|
/** {@inheritDoc} */
|
411
|
423
|
@Override
|
412
|
424
|
public void run() {
|
|
@@ -422,7 +434,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
422
|
434
|
*/
|
423
|
435
|
public void setDisabledTextColour(final Color optionColour) {
|
424
|
436
|
UIUtilities.invokeLater(new Runnable() {
|
425
|
|
-
|
426
|
437
|
/** {@inheritDoc} */
|
427
|
438
|
@Override
|
428
|
439
|
public void run() {
|
|
@@ -439,7 +450,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
439
|
450
|
@Override
|
440
|
451
|
public void setBackground(final Color optionColour) {
|
441
|
452
|
UIUtilities.invokeLater(new Runnable() {
|
442
|
|
-
|
443
|
453
|
/** {@inheritDoc} */
|
444
|
454
|
@Override
|
445
|
455
|
public void run() {
|
|
@@ -451,21 +461,24 @@ public class TopicBar extends JComponent implements ActionListener,
|
451
|
461
|
/** {@inheritDoc} */
|
452
|
462
|
@Override
|
453
|
463
|
public void configChanged(final String domain, final String key) {
|
|
464
|
+ updateOptions();
|
|
465
|
+ setVisible(showBar);
|
454
|
466
|
if ("showfulltopic".equals(key)) {
|
455
|
|
- topicText.setEditorKit(new WrapEditorKit(channel.getConfigManager()
|
456
|
|
- .getOptionBool(controller.getDomain(), "showfulltopic")));
|
|
467
|
+ topicText.setEditorKit(new WrapEditorKit(showFull));
|
457
|
468
|
((DefaultStyledDocument) topicText.getDocument()).setDocumentFilter(
|
458
|
469
|
new NewlinesDocumentFilter());
|
459
|
470
|
topicChanged(channel, null);
|
460
|
471
|
}
|
461
|
472
|
setColours();
|
462
|
|
- if ("hideEmptyTopicBar".equals(key)) {
|
463
|
|
- setVisible(true);
|
464
|
|
- if (channel.getConfigManager().getOptionBool(controller.getDomain(),
|
465
|
|
- "hideEmptyTopicBar")) {
|
466
|
|
- setVisible(topicText.getDocument().getLength() != 0);
|
467
|
|
- }
|
468
|
|
- }
|
|
473
|
+ }
|
|
474
|
+
|
|
475
|
+ private void updateOptions() {
|
|
476
|
+ showFull = channel.getConfigManager()
|
|
477
|
+ .getOptionBool(controller.getDomain(), "showfulltopic");
|
|
478
|
+ hideEmpty = channel.getConfigManager()
|
|
479
|
+ .getOptionBool(controller.getDomain(), "hideEmptyTopicBar");
|
|
480
|
+ showBar = channel.getConfigManager()
|
|
481
|
+ .getOptionBool(controller.getDomain(), "showtopicbar");
|
469
|
482
|
}
|
470
|
483
|
|
471
|
484
|
/**
|
|
@@ -480,7 +493,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
480
|
493
|
*/
|
481
|
494
|
public void validateTopic() {
|
482
|
495
|
UIUtilities.invokeLater(new Runnable() {
|
483
|
|
-
|
484
|
496
|
/** {@inheritDoc} */
|
485
|
497
|
@Override
|
486
|
498
|
public void run() {
|
|
@@ -560,7 +572,6 @@ public class TopicBar extends JComponent implements ActionListener,
|
560
|
572
|
validateTopic();
|
561
|
573
|
if (topicText.isEditable()) {
|
562
|
574
|
SwingUtilities.invokeLater(new Runnable() {
|
563
|
|
-
|
564
|
575
|
@Override
|
565
|
576
|
public void run() {
|
566
|
577
|
applyAttributes();
|