|
@@ -24,15 +24,14 @@
|
24
|
24
|
package com.dmdirc.addons.ui_swing.components;
|
25
|
25
|
|
26
|
26
|
import com.dmdirc.Channel;
|
|
27
|
+import com.dmdirc.Topic;
|
27
|
28
|
import com.dmdirc.addons.ui_swing.SwingController;
|
28
|
29
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
29
|
30
|
import com.dmdirc.addons.ui_swing.actions.NoNewlinesPasteAction;
|
30
|
31
|
import com.dmdirc.addons.ui_swing.components.frames.ChannelFrame;
|
31
|
32
|
import com.dmdirc.config.IdentityManager;
|
32
|
33
|
import com.dmdirc.interfaces.ConfigChangeListener;
|
33
|
|
-import com.dmdirc.parser.interfaces.ChannelInfo;
|
34
|
|
-import com.dmdirc.parser.interfaces.Parser;
|
35
|
|
-import com.dmdirc.parser.interfaces.callbacks.ChannelTopicListener;
|
|
34
|
+import com.dmdirc.interfaces.TopicChangeListener;
|
36
|
35
|
import com.dmdirc.ui.IconManager;
|
37
|
36
|
import com.dmdirc.ui.messages.ColourManager;
|
38
|
37
|
import com.dmdirc.ui.messages.Styliser;
|
|
@@ -78,8 +77,8 @@ import net.miginfocom.swing.MigLayout;
|
78
|
77
|
* Component to show and edit topics for a channel.
|
79
|
78
|
*/
|
80
|
79
|
public class TopicBar extends JComponent implements ActionListener,
|
81
|
|
- ConfigChangeListener, ChannelTopicListener, HyperlinkListener,
|
82
|
|
- MouseListener, DocumentListener {
|
|
80
|
+ ConfigChangeListener, HyperlinkListener, MouseListener,
|
|
81
|
+ DocumentListener, TopicChangeListener {
|
83
|
82
|
|
84
|
83
|
/**
|
85
|
84
|
* A version number for this class. It should be changed whenever the class
|
|
@@ -117,7 +116,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
117
|
116
|
this.channel = channelFrame.getChannel();
|
118
|
117
|
controller = channelFrame.getController();
|
119
|
118
|
topicText = new TextPaneInputField();
|
120
|
|
- topicLengthMax = channel.getServer().getParser().getMaxTopicLength();
|
|
119
|
+ topicLengthMax = channel.getMaxTopicLength();
|
121
|
120
|
errorIcon =
|
122
|
121
|
new JLabel(IconManager.getIconManager().getIcon("input-error"));
|
123
|
122
|
//TODO issue 3251
|
|
@@ -154,9 +153,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
154
|
153
|
add(topicCancel, "");
|
155
|
154
|
add(topicEdit, "");
|
156
|
155
|
|
157
|
|
- channel.getChannelInfo().getParser().getCallbackManager().addCallback(
|
158
|
|
- ChannelTopicListener.class, this, channel.getChannelInfo().
|
159
|
|
- getName());
|
|
156
|
+ channel.addTopicChangeListener(this);
|
160
|
157
|
topicText.addActionListener(this);
|
161
|
158
|
topicEdit.addActionListener(this);
|
162
|
159
|
topicCancel.addActionListener(this);
|
|
@@ -211,15 +208,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
211
|
208
|
|
212
|
209
|
/** {@inheritDoc} */
|
213
|
210
|
@Override
|
214
|
|
- public void onChannelTopic(final Parser tParser, ChannelInfo cChannel,
|
215
|
|
- boolean bIsJoinTopic) {
|
216
|
|
- topicChanged();
|
217
|
|
- }
|
218
|
|
-
|
219
|
|
- /**
|
220
|
|
- * Topic has changed, update topic.
|
221
|
|
- */
|
222
|
|
- private void topicChanged() {
|
|
211
|
+ public void topicChanged(final Channel channel, final Topic topic) {
|
223
|
212
|
if (topicText.isEditable()) {
|
224
|
213
|
return;
|
225
|
214
|
}
|
|
@@ -254,7 +243,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
254
|
243
|
}
|
255
|
244
|
((ChannelFrame) channel.getFrame()).getInputField().
|
256
|
245
|
requestFocusInWindow();
|
257
|
|
- topicChanged();
|
|
246
|
+ topicChanged(channel, null);
|
258
|
247
|
topicText.setFocusable(false);
|
259
|
248
|
topicText.setEditable(false);
|
260
|
249
|
topicCancel.setVisible(false);
|
|
@@ -278,7 +267,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
278
|
267
|
topicCancel.setVisible(false);
|
279
|
268
|
((ChannelFrame) channel.getFrame()).getInputField().
|
280
|
269
|
requestFocusInWindow();
|
281
|
|
- topicChanged();
|
|
270
|
+ topicChanged(channel, null);
|
282
|
271
|
}
|
283
|
272
|
}
|
284
|
273
|
|
|
@@ -429,8 +418,7 @@ public class TopicBar extends JComponent implements ActionListener,
|
429
|
418
|
* Closes this topic bar.
|
430
|
419
|
*/
|
431
|
420
|
public void close() {
|
432
|
|
- channel.getChannelInfo().getParser().getCallbackManager().delCallback(
|
433
|
|
- ChannelTopicListener.class, this);
|
|
421
|
+ channel.removeTopicChangeListener(this);
|
434
|
422
|
}
|
435
|
423
|
|
436
|
424
|
/**
|