|
@@ -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
|
}
|