Browse Source

Remove lovely parser callbacks, use sane core callbacks

Fixes issue 3637: Topic bar doesn't update correctly when someone else changes the topic

Change-Id: I54f99aa6d06c0a6565d3218dc48da16ad890a389
Reviewed-on: http://gerrit.dmdirc.com/657
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
tags/0.6.3
Gregory Holmes 14 years ago
parent
commit
e59c431e39
1 changed files with 10 additions and 22 deletions
  1. 10
    22
      src/com/dmdirc/addons/ui_swing/components/TopicBar.java

+ 10
- 22
src/com/dmdirc/addons/ui_swing/components/TopicBar.java View File

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

Loading…
Cancel
Save