|
@@ -31,18 +31,18 @@ import com.dmdirc.ServerManager;
|
31
|
31
|
import com.dmdirc.actions.ActionManager;
|
32
|
32
|
import com.dmdirc.actions.interfaces.ActionType;
|
33
|
33
|
import com.dmdirc.actions.CoreActionType;
|
|
34
|
+import com.dmdirc.addons.ui_swing.MainFrame;
|
34
|
35
|
import com.dmdirc.interfaces.ActionListener;
|
35
|
36
|
import com.dmdirc.interfaces.InviteListener;
|
36
|
37
|
import com.dmdirc.ui.interfaces.StatusBarComponent;
|
37
|
38
|
import com.dmdirc.util.MapList;
|
38
|
39
|
|
39
|
|
-import java.awt.Window;
|
40
|
40
|
import java.awt.event.ActionEvent;
|
41
|
41
|
import java.awt.event.MouseEvent;
|
42
|
|
-
|
43
|
42
|
import java.util.ArrayList;
|
44
|
43
|
import java.util.Arrays;
|
45
|
44
|
import java.util.List;
|
|
45
|
+
|
46
|
46
|
import javax.swing.AbstractAction;
|
47
|
47
|
import javax.swing.BorderFactory;
|
48
|
48
|
import javax.swing.JLabel;
|
|
@@ -74,17 +74,19 @@ public class InviteLabel extends StatusbarPopupPanel implements StatusBarCompone
|
74
|
74
|
/** Accept invites menu item. */
|
75
|
75
|
private final JMenuItem accept;
|
76
|
76
|
/** Parent window. */
|
77
|
|
- private Window parentWindow;
|
|
77
|
+ private MainFrame mainFrame;
|
|
78
|
+ /** Active frame. */
|
|
79
|
+ private FrameContainer activeFrame;
|
78
|
80
|
|
79
|
81
|
/**
|
80
|
82
|
* Instantiates a new invite label.
|
81
|
83
|
*
|
82
|
|
- * @param parentWindow Parent window
|
|
84
|
+ * @param mainFrame Parent window
|
83
|
85
|
*/
|
84
|
|
- public InviteLabel(final Window parentWindow) {
|
|
86
|
+ public InviteLabel(final MainFrame mainFrame) {
|
85
|
87
|
super(new JLabel());
|
86
|
88
|
|
87
|
|
- this.parentWindow = parentWindow;
|
|
89
|
+ this.mainFrame = mainFrame;
|
88
|
90
|
|
89
|
91
|
setBorder(BorderFactory.createEtchedBorder());
|
90
|
92
|
label.setIcon(IconManager.getIconManager().getIcon("invite"));
|
|
@@ -134,7 +136,7 @@ public class InviteLabel extends StatusbarPopupPanel implements StatusBarCompone
|
134
|
136
|
/** {@inheritDoc} */
|
135
|
137
|
@Override
|
136
|
138
|
protected StatusbarPopupWindow getWindow() {
|
137
|
|
- return new InvitePopup(this, activeServer, parentWindow);
|
|
139
|
+ return new InvitePopup(this, activeServer, mainFrame);
|
138
|
140
|
}
|
139
|
141
|
|
140
|
142
|
/**
|
|
@@ -156,19 +158,14 @@ public class InviteLabel extends StatusbarPopupPanel implements StatusBarCompone
|
156
|
158
|
* Updates the invite label for the currently active server.
|
157
|
159
|
*/
|
158
|
160
|
private void update() {
|
159
|
|
- update(Main.getUI().getActiveServer());
|
160
|
|
- }
|
161
|
|
-
|
162
|
|
- /**
|
163
|
|
- * Updates the invite label for the server.
|
164
|
|
- *
|
165
|
|
- * @param server Server to update
|
166
|
|
- */
|
167
|
|
- private void update(final Server server) {
|
168
|
|
- activeServer = server;
|
169
|
|
- if (server != null && !inviteList.containsKey(server)) {
|
170
|
|
- inviteList.add(server, server.getInvites());
|
171
|
|
- server.addInviteListener(this);
|
|
161
|
+ if (activeFrame == null) {
|
|
162
|
+ activeServer = null;
|
|
163
|
+ } else {
|
|
164
|
+ activeServer = activeFrame.getServer();
|
|
165
|
+ }
|
|
166
|
+ if (activeServer != null && !inviteList.containsKey(activeServer)) {
|
|
167
|
+ inviteList.add(activeServer, activeServer.getInvites());
|
|
168
|
+ activeServer.addInviteListener(this);
|
172
|
169
|
}
|
173
|
170
|
|
174
|
171
|
if (activeServer == null || inviteList.get(activeServer).isEmpty()) {
|
|
@@ -206,11 +203,7 @@ public class InviteLabel extends StatusbarPopupPanel implements StatusBarCompone
|
206
|
203
|
@Override
|
207
|
204
|
public void processEvent(final ActionType type, final StringBuffer format,
|
208
|
205
|
final Object... arguments) {
|
209
|
|
- if (arguments[0] == null) {
|
210
|
|
- update((Server) null);
|
211
|
|
- } else {
|
212
|
|
- update(((FrameContainer) arguments[0]).getServer());
|
213
|
|
- }
|
|
206
|
+ update();
|
214
|
207
|
}
|
215
|
208
|
|
216
|
209
|
/**
|