ソースを参照

Use events in Awaylabel.

Change-Id: I405473927f71fe17f6668b028b3a1247f06f4054
Reviewed-on: http://gerrit.dmdirc.com/3788
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/88/3788/4
Greg Holmes 9年前
コミット
7ffc51227e

+ 7
- 7
src/com/dmdirc/addons/ui_swing/components/AwayLabel.java ファイルの表示

@@ -24,19 +24,21 @@ package com.dmdirc.addons.ui_swing.components;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
+import com.dmdirc.events.FrameClosingEvent;
27 28
 import com.dmdirc.interfaces.AwayStateListener;
28
-import com.dmdirc.interfaces.FrameCloseListener;
29 29
 import com.dmdirc.interfaces.config.ConfigChangeListener;
30 30
 
31 31
 import javax.swing.JLabel;
32 32
 
33
+import net.engio.mbassy.listener.Handler;
34
+
33 35
 import static com.google.common.base.Preconditions.checkNotNull;
34 36
 
35 37
 /**
36 38
  * Simple panel to show when a user is away or not.
37 39
  */
38 40
 public class AwayLabel extends JLabel implements ConfigChangeListener,
39
-        AwayStateListener, FrameCloseListener {
41
+        AwayStateListener {
40 42
 
41 43
     /** A version number for this class. */
42 44
     private static final long serialVersionUID = 2;
@@ -65,8 +67,6 @@ public class AwayLabel extends JLabel implements ConfigChangeListener,
65 67
             setVisible(container.getConnection().isAway());
66 68
             container.getConnection().addAwayStateListener(this);
67 69
         }
68
-
69
-        container.addCloseListener(this);
70 70
     }
71 71
 
72 72
     @Override
@@ -110,9 +110,9 @@ public class AwayLabel extends JLabel implements ConfigChangeListener,
110 110
         });
111 111
     }
112 112
 
113
-    @Override
114
-    public void windowClosing(final FrameContainer window) {
115
-        if (container.getConnection() != null) {
113
+    @Handler
114
+    public void windowClosing(final FrameClosingEvent event) {
115
+        if (event.getContainer().equals(container) && container.getConnection() != null) {
116 116
             container.getConnection().removeAwayStateListener(this);
117 117
         }
118 118
     }

+ 1
- 0
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java ファイルの表示

@@ -196,6 +196,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
196 196
         inputFieldPopup.setLightWeightPopupEnabled(true);
197 197
 
198 198
         awayLabel = new AwayLabel(getContainer());
199
+        eventBus.subscribe(awayLabel);
199 200
         typingLabel = new TypingLabel(getContainer());
200 201
     }
201 202
 

読み込み中…
キャンセル
保存