|
@@ -109,8 +109,8 @@ public class TopicBar extends JComponent implements ActionListener,
|
109
|
109
|
topicLengthMax = channel.getMaxTopicLength();
|
110
|
110
|
errorIcon =
|
111
|
111
|
new JLabel(IconManager.getIconManager().getIcon("input-error"));
|
112
|
|
- if (channelFrame.getConfigManager().getOptionBool(controller.
|
113
|
|
- getDomain(), "showfulltopic")) {
|
|
112
|
+ if (channelFrame.getConfigManager().getOptionBool(controller.getDomain(),
|
|
113
|
+ "showfulltopic")) {
|
114
|
114
|
topicText.setEditorKit(new StyledEditorKit());
|
115
|
115
|
} else {
|
116
|
116
|
topicText.setEditorKit(new WrapEditorKit());
|
|
@@ -156,7 +156,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
156
|
156
|
/** {@inheritDoc} */
|
157
|
157
|
@Override
|
158
|
158
|
public void actionPerformed(ActionEvent e) {
|
159
|
|
- TopicBar.this.actionPerformed(e);
|
|
159
|
+ commitTopicEdit();
|
160
|
160
|
}
|
161
|
161
|
});
|
162
|
162
|
topicText.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"),
|
|
@@ -169,8 +169,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
169
|
169
|
/** {@inheritDoc} */
|
170
|
170
|
@Override
|
171
|
171
|
public void actionPerformed(ActionEvent e) {
|
172
|
|
- e.setSource(topicCancel);
|
173
|
|
- TopicBar.this.actionPerformed(e);
|
|
172
|
+ cancelTopicEdit();
|
174
|
173
|
}
|
175
|
174
|
});
|
176
|
175
|
topicText.addHyperlinkListener(this);
|
|
@@ -204,7 +203,8 @@ public class TopicBar extends JComponent implements ActionListener,
|
204
|
203
|
}
|
205
|
204
|
topicText.setText("");
|
206
|
205
|
if (channel.getCurrentTopic() != null) {
|
207
|
|
- channel.getStyliser().addStyledString((StyledDocument) topicText.getDocument(),
|
|
206
|
+ channel.getStyliser().addStyledString((StyledDocument) topicText.
|
|
207
|
+ getDocument(),
|
208
|
208
|
new String[]{Styliser.CODE_HEXCOLOUR + ColourManager.getHex(
|
209
|
209
|
foregroundColour) + channel.getCurrentTopic().getTopic(),},
|
210
|
210
|
as);
|
|
@@ -229,43 +229,53 @@ public class TopicBar extends JComponent implements ActionListener,
|
229
|
229
|
if (!channel.isOnChannel()) {
|
230
|
230
|
return;
|
231
|
231
|
}
|
232
|
|
- if (e.getSource() == topicEdit || e.getSource() == topicText) {
|
|
232
|
+ if (e.getSource() == topicEdit) {
|
233
|
233
|
if (topicText.isEditable()) {
|
234
|
|
- if ((channel.getCurrentTopic() == null && !topicText.getText().isEmpty())
|
235
|
|
- || (channel.getCurrentTopic() != null &&
|
236
|
|
- !channel.getCurrentTopic().getTopic().equals(topicText.getText()))) {
|
237
|
|
- channel.setTopic(topicText.getText());
|
238
|
|
- }
|
239
|
|
- ((ChannelFrame) channel.getFrame()).getInputField().
|
240
|
|
- requestFocusInWindow();
|
241
|
|
- topicChanged(channel, null);
|
242
|
|
- topicText.setFocusable(false);
|
243
|
|
- topicText.setEditable(false);
|
244
|
|
- topicCancel.setVisible(false);
|
|
234
|
+ commitTopicEdit();
|
245
|
235
|
} else {
|
246
|
|
- topicText.setVisible(false);
|
247
|
|
- topicText.setText("");
|
248
|
|
- if (channel.getCurrentTopic() != null) {
|
249
|
|
- topicText.setText(channel.getCurrentTopic().getTopic());
|
250
|
|
- }
|
251
|
|
- applyAttributes();
|
252
|
|
- topicText.setCaretPosition(0);
|
253
|
|
- topicText.setFocusable(true);
|
254
|
|
- topicText.setEditable(true);
|
255
|
|
- topicText.setVisible(true);
|
256
|
|
- topicText.requestFocusInWindow();
|
257
|
|
- topicCancel.setVisible(true);
|
|
236
|
+ setupTopicEdit();
|
258
|
237
|
}
|
259
|
238
|
} else if (e.getSource() == topicCancel) {
|
260
|
|
- topicText.setFocusable(false);
|
261
|
|
- topicText.setEditable(false);
|
262
|
|
- topicCancel.setVisible(false);
|
263
|
|
- ((ChannelFrame) channel.getFrame()).getInputField().
|
264
|
|
- requestFocusInWindow();
|
265
|
|
- topicChanged(channel, null);
|
|
239
|
+ cancelTopicEdit();
|
266
|
240
|
}
|
267
|
241
|
}
|
268
|
242
|
|
|
243
|
+ private void commitTopicEdit() {
|
|
244
|
+ if ((channel.getCurrentTopic() == null && !topicText.getText().isEmpty())
|
|
245
|
+ || (channel.getCurrentTopic() != null
|
|
246
|
+ && !channel.getCurrentTopic().getTopic().equals(topicText.getText()))) {
|
|
247
|
+ channel.setTopic(topicText.getText());
|
|
248
|
+ }
|
|
249
|
+ ((ChannelFrame) channel.getFrame()).getInputField().requestFocusInWindow();
|
|
250
|
+ topicChanged(channel, null);
|
|
251
|
+ topicText.setFocusable(false);
|
|
252
|
+ topicText.setEditable(false);
|
|
253
|
+ topicCancel.setVisible(false);
|
|
254
|
+ }
|
|
255
|
+
|
|
256
|
+ private void setupTopicEdit() {
|
|
257
|
+ topicText.setVisible(false);
|
|
258
|
+ topicText.setText("");
|
|
259
|
+ if (channel.getCurrentTopic() != null) {
|
|
260
|
+ topicText.setText(channel.getCurrentTopic().getTopic());
|
|
261
|
+ }
|
|
262
|
+ applyAttributes();
|
|
263
|
+ topicText.setCaretPosition(0);
|
|
264
|
+ topicText.setFocusable(true);
|
|
265
|
+ topicText.setEditable(true);
|
|
266
|
+ topicText.setVisible(true);
|
|
267
|
+ topicText.requestFocusInWindow();
|
|
268
|
+ topicCancel.setVisible(true);
|
|
269
|
+ }
|
|
270
|
+
|
|
271
|
+ private void cancelTopicEdit() {
|
|
272
|
+ topicText.setFocusable(false);
|
|
273
|
+ topicText.setEditable(false);
|
|
274
|
+ topicCancel.setVisible(false);
|
|
275
|
+ ((ChannelFrame) channel.getFrame()).getInputField().requestFocusInWindow();
|
|
276
|
+ topicChanged(channel, null);
|
|
277
|
+ }
|
|
278
|
+
|
269
|
279
|
/** {@inheritDoc} */
|
270
|
280
|
@Override
|
271
|
281
|
public void hyperlinkUpdate(final HyperlinkEvent e) {
|
|
@@ -451,7 +461,9 @@ public class TopicBar extends JComponent implements ActionListener,
|
451
|
461
|
@Override
|
452
|
462
|
public void mouseClicked(MouseEvent e) {
|
453
|
463
|
if (e.getClickCount() == 2) {
|
454
|
|
- topicEdit.doClick();
|
|
464
|
+ if (!topicText.isEditable()) {
|
|
465
|
+ topicEdit.doClick();
|
|
466
|
+ }
|
455
|
467
|
}
|
456
|
468
|
}
|
457
|
469
|
|