Procházet zdrojové kódy

fixes issue 2284: add StatusBarLabel interface to remove Component import from core

tags/0.6.3m1rc1
Gregory Holmes před 15 roky
rodič
revize
2474adb707

+ 14
- 153
src/com/dmdirc/addons/lagdisplay/LagDisplayPlugin.java Zobrazit soubor

@@ -36,51 +36,26 @@ import com.dmdirc.config.prefs.PreferencesType;
36 36
 import com.dmdirc.interfaces.ActionListener;
37 37
 import com.dmdirc.plugins.Plugin;
38 38
 import com.dmdirc.ui.interfaces.Window;
39
-import com.dmdirc.addons.ui_swing.UIUtilities;
40 39
 
41
-import java.awt.Color;
42
-import java.awt.Component;
43
-import java.awt.Graphics;
44
-import java.awt.event.MouseEvent;
45
-import java.awt.event.MouseListener;
46 40
 import java.util.Date;
47 41
 import java.util.Map;
48 42
 import java.util.WeakHashMap;
49 43
 
50
-import javax.swing.BorderFactory;
51
-import javax.swing.JLabel;
52
-import javax.swing.JPanel;
53
-import javax.swing.UIManager;
54
-import javax.swing.border.EtchedBorder;
55
-
56
-import net.miginfocom.swing.MigLayout;
57
-
58 44
 /**
59 45
  * Displays the current server's lag in the status bar.
60 46
  * @author chris
61 47
  */
62
-public final class LagDisplayPlugin extends Plugin implements ActionListener,
63
-        MouseListener {
48
+public final class LagDisplayPlugin extends Plugin implements ActionListener {
64 49
     
65 50
     /** The panel we use in the status bar. */
66
-    private final JPanel panel = new JPanel();
51
+    private final LagDisplayPanel panel = new LagDisplayPanel(this);
67 52
     
68 53
     /** A cache of ping times. */
69 54
     private final Map<Server, String> pings = new WeakHashMap<Server, String>();
70 55
     
71
-    /** The label we use to show lag. */
72
-    private final JLabel label = new JLabel("Unknown");
73
-
74
-    /** The dialog we're using to show extra info. */
75
-    private ServerInfoDialog dialog;
76
-    
77 56
     /** Creates a new instance of LagDisplayPlugin. */
78 57
     public LagDisplayPlugin() {
79 58
         super();
80
-        
81
-        panel.setBorder(BorderFactory.createEtchedBorder());
82
-        panel.setLayout(new MigLayout("ins 0 rel 0 rel, aligny center"));
83
-        panel.add(label);
84 59
     }
85 60
     
86 61
     /** {@inheritDoc} */
@@ -92,8 +67,6 @@ public final class LagDisplayPlugin extends Plugin implements ActionListener,
92 67
                 CoreActionType.SERVER_NOPING, CoreActionType.CLIENT_FRAME_CHANGED,
93 68
                 CoreActionType.SERVER_DISCONNECTED, CoreActionType.SERVER_PINGSENT,
94 69
                 CoreActionType.SERVER_NUMERIC);
95
-
96
-        panel.addMouseListener(this);
97 70
     }
98 71
     
99 72
     /** {@inheritDoc} */
@@ -125,10 +98,10 @@ public final class LagDisplayPlugin extends Plugin implements ActionListener,
125 98
             pings.put(((Server) arguments[0]), value);
126 99
             
127 100
             if (((Server) arguments[0]).ownsFrame(active)) {
128
-                label.setText(value);
101
+                panel.setText(value);
129 102
             }
130 103
 
131
-            refreshDialog();
104
+            panel.refreshDialog();
132 105
         } else if (!useAlternate && type.equals(CoreActionType.SERVER_NOPING)) {
133 106
             final Window active = Main.getUI().getActiveWindow();
134 107
             final String value = formatTime(arguments[1]) + "+";
@@ -136,30 +109,30 @@ public final class LagDisplayPlugin extends Plugin implements ActionListener,
136 109
             pings.put(((Server) arguments[0]), value);
137 110
             
138 111
             if (((Server) arguments[0]).ownsFrame(active)) {
139
-                label.setText(value);
112
+                panel.setText(value);
140 113
             }
141 114
 
142
-            refreshDialog();
115
+            panel.refreshDialog();
143 116
         } else if (type.equals(CoreActionType.SERVER_DISCONNECTED)) {
144 117
             final Window active = Main.getUI().getActiveWindow();
145 118
             
146 119
             if (((Server) arguments[0]).ownsFrame(active)) {
147
-                label.setText("Not connected");
120
+                panel.setText("Not connected");
148 121
                 pings.remove(arguments[0]);
149 122
             }
150 123
 
151
-            refreshDialog();
124
+            panel.refreshDialog();
152 125
         } else if (type.equals(CoreActionType.CLIENT_FRAME_CHANGED)) {
153 126
             final FrameContainer source = (FrameContainer) arguments[0];
154 127
             if (source.getServer() == null) {
155
-                label.setText("Unknown");
128
+                panel.setText("Unknown");
156 129
             } else if (source.getServer().getState() != ServerState.CONNECTED) {
157
-                label.setText("Not connected");
130
+                panel.setText("Not connected");
158 131
             } else {
159
-                label.setText(getTime(source.getServer()));
132
+                panel.setText(getTime(source.getServer()));
160 133
             }
161 134
 
162
-            refreshDialog();
135
+            panel.refreshDialog();
163 136
         } else if (useAlternate && type.equals(CoreActionType.SERVER_PINGSENT)) {
164 137
             ((Server) arguments[0]).getParser().sendLine("LAGCHECK_" + new Date().getTime());
165 138
         } else if (useAlternate && type.equals(CoreActionType.SERVER_NUMERIC)
@@ -174,7 +147,7 @@ public final class LagDisplayPlugin extends Plugin implements ActionListener,
174 147
                 pings.put((Server) arguments[0], value);
175 148
                 
176 149
                 if (((Server) arguments[0]).ownsFrame(active)) {
177
-                    label.setText(value);
150
+                    panel.setText(value);
178 151
                 }                
179 152
             } catch (NumberFormatException ex) {
180 153
                 pings.remove((Server) arguments[0]);
@@ -184,7 +157,7 @@ public final class LagDisplayPlugin extends Plugin implements ActionListener,
184 157
                 format.delete(0, format.length());
185 158
             }
186 159
 
187
-            refreshDialog();
160
+            panel.refreshDialog();
188 161
         }
189 162
     }
190 163
 
@@ -213,44 +186,6 @@ public final class LagDisplayPlugin extends Plugin implements ActionListener,
213 186
         }
214 187
     }
215 188
 
216
-    /** {@inheritDoc} */
217
-    @Override
218
-    public void mouseClicked(final MouseEvent e) {
219
-        // Don't care
220
-    }
221
-
222
-    /** {@inheritDoc} */
223
-    @Override
224
-    public void mousePressed(final MouseEvent e) {
225
-        // Don't care
226
-    }
227
-
228
-    /** {@inheritDoc} */
229
-    @Override
230
-    public void mouseReleased(final MouseEvent e) {
231
-        // Don't care
232
-    }
233
-
234
-    /** {@inheritDoc} */
235
-    @Override
236
-    public void mouseEntered(final MouseEvent e) {
237
-        panel.setBackground(UIManager.getColor("ToolTip.background"));
238
-        panel.setForeground(UIManager.getColor("ToolTip.foreground"));
239
-        panel.setBorder(new ToplessEtchedBorder());
240
-
241
-        openDialog();
242
-    }
243
-
244
-    /** {@inheritDoc} */
245
-    @Override
246
-    public void mouseExited(final MouseEvent e) {
247
-        panel.setBackground(null);
248
-        panel.setForeground(null);
249
-        panel.setBorder(new EtchedBorder());
250
-
251
-        closeDialog();
252
-    }
253
-
254 189
     /** {@inheritDoc} */
255 190
     @Override
256 191
     public void showConfig(final PreferencesManager manager) {
@@ -262,78 +197,4 @@ public final class LagDisplayPlugin extends Plugin implements ActionListener,
262 197
                 + "lag which bypasses bouncers or proxies that may reply."));
263 198
         manager.getCategory("Plugins").addSubCategory(cat);
264 199
     }
265
-
266
-    /**
267
-     * Closes and reopens the dialog to update information and border positions.
268
-     */
269
-    protected void refreshDialog() {
270
-        UIUtilities.invokeLater(new Runnable() {
271
-            @Override
272
-            public void run() {
273
-                synchronized (ServerInfoDialog.class) {
274
-                    if (dialog != null) {
275
-                        closeDialog();
276
-                        openDialog();
277
-                    }
278
-                }
279
-            }
280
-        });
281
-    }
282
-
283
-    /**
284
-     * Opens the information dialog.
285
-     */
286
-    protected void openDialog() {
287
-        synchronized (ServerInfoDialog.class) {
288
-            dialog = new ServerInfoDialog(this, panel);
289
-            dialog.setVisible(true);
290
-        }
291
-    }
292
-
293
-    /**
294
-     * Closes the information dialog.
295
-     */
296
-    protected void closeDialog() {
297
-        synchronized (ServerInfoDialog.class) {
298
-            if (dialog != null) {
299
-                dialog.setVisible(false);
300
-                dialog.dispose();
301
-                dialog = null;
302
-            }
303
-        }
304
-    }
305
-
306
-    /**
307
-     * An {@link EtchedBorder} with no top.
308
-     */
309
-    private static class ToplessEtchedBorder extends EtchedBorder {
310
-
311
-        /**
312
-         * A version number for this class. It should be changed whenever the class
313
-         * structure is changed (or anything else that would prevent serialized
314
-         * objects being unserialized with the new class).
315
-         */
316
-        private static final long serialVersionUID = 1;
317
-
318
-        @Override
319
-        public void paintBorder(Component c, Graphics g, int x, int y, int width,
320
-                                int height) {
321
-            int w = width;
322
-            int h = height;
323
-
324
-            g.translate(x, y);
325
-
326
-            g.setColor(etchType == LOWERED? getShadowColor(c) : getHighlightColor(c));
327
-            g.drawLine(0, h-2, w, h-2);
328
-            g.drawLine(0, 0, 0, h-1);
329
-            g.drawLine(w-2, 0, w-2, h-1);
330
-
331
-            g.setColor(Color.WHITE);
332
-            g.drawLine(0, h-1, w, h-1);
333
-            g.drawLine(w-1, 0, w-1, h-1);
334
-
335
-            g.translate(-x, -y);
336
-        }
337
-
338
-    }
339 200
 }

+ 6
- 8
src/com/dmdirc/addons/ui_dummy/DummyStatusBar.java Zobrazit soubor

@@ -23,11 +23,9 @@
23 23
 package com.dmdirc.addons.ui_dummy;
24 24
 
25 25
 import com.dmdirc.ui.interfaces.StatusBar;
26
+import com.dmdirc.ui.interfaces.StatusBarComponent;
26 27
 import com.dmdirc.ui.interfaces.StatusMessageNotifier;
27 28
 
28
-import java.awt.Component;
29
-import javax.swing.Icon;
30
-
31 29
 /**
32 30
  * Dummy status bar, used for testing.
33 31
  */
@@ -59,18 +57,18 @@ public final class DummyStatusBar implements StatusBar {
59 57
     }
60 58
     
61 59
     @Override
62
-    public void setMessage(Icon icon, String newMessage) {
60
+    public void setMessage(String iconType, String newMessage) {
63 61
         System.out.println("DummyStatusBar: " + newMessage);
64 62
     }
65 63
 
66 64
     @Override
67
-    public void setMessage(Icon icon, String newMessage,
65
+    public void setMessage(String iconType, String newMessage,
68 66
             StatusMessageNotifier newNotifier) {
69 67
         System.out.println("DummyStatusBar: " + newMessage);
70 68
     }
71 69
 
72 70
     @Override
73
-    public void setMessage(Icon icon, String newMessage,
71
+    public void setMessage(String iconType, String newMessage,
74 72
             StatusMessageNotifier newNotifier, int timeout) {
75 73
         System.out.println("DummyStatusBar: " + newMessage);
76 74
     }
@@ -83,13 +81,13 @@ public final class DummyStatusBar implements StatusBar {
83 81
 
84 82
     /** {@inheritDoc} */
85 83
     @Override
86
-    public void addComponent(final Component component) {
84
+    public void addComponent(final StatusBarComponent component) {
87 85
         // Do nothing
88 86
     }
89 87
 
90 88
     /** {@inheritDoc} */
91 89
     @Override
92
-    public void removeComponent(final Component component) {
90
+    public void removeComponent(final StatusBarComponent component) {
93 91
         // Do nothing
94 92
     }
95 93
 

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/FeedbackNag.java Zobrazit soubor

@@ -26,6 +26,7 @@ import com.dmdirc.ui.IconManager;
26 26
 import com.dmdirc.Main;
27 27
 import com.dmdirc.addons.ui_swing.SwingController;
28 28
 import com.dmdirc.addons.ui_swing.dialogs.FeedbackDialog;
29
+import com.dmdirc.ui.interfaces.StatusBarComponent;
29 30
 
30 31
 import java.awt.event.ActionEvent;
31 32
 import java.awt.event.ActionListener;
@@ -41,8 +42,8 @@ import javax.swing.JPopupMenu;
41 42
 /**
42 43
  * Feedback nag icon.
43 44
  */
44
-public class FeedbackNag extends JLabel implements MouseListener,
45
-        ActionListener {
45
+public class FeedbackNag extends JLabel implements StatusBarComponent, 
46
+        MouseListener, ActionListener {
46 47
 
47 48
     /**
48 49
      * A version number for this class. It should be changed whenever the class

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/statusbar/ErrorLabel.java Zobrazit soubor

@@ -28,6 +28,7 @@ import com.dmdirc.logger.ErrorListener;
28 28
 import com.dmdirc.logger.ErrorManager;
29 29
 import com.dmdirc.logger.ProgramError;
30 30
 import com.dmdirc.ui.IconManager;
31
+import com.dmdirc.ui.interfaces.StatusBarComponent;
31 32
 
32 33
 import java.awt.event.ActionEvent;
33 34
 import java.awt.event.ActionListener;
@@ -46,8 +47,8 @@ import javax.swing.SwingUtilities;
46 47
 /**
47 48
  * Error label, responsible for showing errors in the status bar.
48 49
  */
49
-public class ErrorLabel extends JLabel implements MouseListener, ErrorListener,
50
-        ActionListener {
50
+public class ErrorLabel extends JLabel implements StatusBarComponent, 
51
+        MouseListener, ErrorListener, ActionListener {
51 52
 
52 53
     /**
53 54
      * A version number for this class. It should be changed whenever the class

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/statusbar/FeedbackNag.java Zobrazit soubor

@@ -26,6 +26,7 @@ import com.dmdirc.Main;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27 27
 import com.dmdirc.addons.ui_swing.dialogs.FeedbackDialog;
28 28
 import com.dmdirc.ui.IconManager;
29
+import com.dmdirc.ui.interfaces.StatusBarComponent;
29 30
 
30 31
 import java.awt.event.ActionEvent;
31 32
 import java.awt.event.ActionListener;
@@ -41,8 +42,8 @@ import javax.swing.JPopupMenu;
41 42
 /**
42 43
  * Feedback nag icon.
43 44
  */
44
-public class FeedbackNag extends JLabel implements MouseListener,
45
-        ActionListener {
45
+public class FeedbackNag extends JLabel implements StatusBarComponent, 
46
+        MouseListener, ActionListener {
46 47
 
47 48
     /**
48 49
      * A version number for this class. It should be changed whenever the class

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java Zobrazit soubor

@@ -33,6 +33,7 @@ import com.dmdirc.actions.interfaces.ActionType;
33 33
 import com.dmdirc.actions.CoreActionType;
34 34
 import com.dmdirc.interfaces.ActionListener;
35 35
 import com.dmdirc.interfaces.InviteListener;
36
+import com.dmdirc.ui.interfaces.StatusBarComponent;
36 37
 import com.dmdirc.util.MapList;
37 38
 
38 39
 import java.awt.event.ActionEvent;
@@ -52,8 +53,8 @@ import javax.swing.JSeparator;
52 53
 /**
53 54
  * Invite label.
54 55
  */
55
-public class InviteLabel extends JLabel implements InviteListener,
56
-        ActionListener, MouseListener {
56
+public class InviteLabel extends JLabel implements StatusBarComponent, 
57
+        InviteListener, ActionListener, MouseListener {
57 58
 
58 59
     /**
59 60
      * A version number for this class. It should be changed whenever the class

+ 11
- 7
src/com/dmdirc/addons/ui_swing/components/statusbar/MessageLabel.java Zobrazit soubor

@@ -23,6 +23,8 @@
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25 25
 import com.dmdirc.config.IdentityManager;
26
+import com.dmdirc.ui.IconManager;
27
+import com.dmdirc.ui.interfaces.StatusBarComponent;
26 28
 import com.dmdirc.ui.interfaces.StatusMessageNotifier;
27 29
 
28 30
 import java.awt.event.MouseEvent;
@@ -39,7 +41,8 @@ import javax.swing.SwingUtilities;
39 41
 /**
40 42
  * Message label handles showing messages in the status bar.
41 43
  */
42
-public class MessageLabel extends JLabel implements MouseListener {
44
+public class MessageLabel extends JLabel implements StatusBarComponent, 
45
+        MouseListener {
43 46
 
44 47
     /**
45 48
      * A version number for this class. It should be changed whenever the class
@@ -65,7 +68,7 @@ public class MessageLabel extends JLabel implements MouseListener {
65 68
     }
66 69
 
67 70
     public void setMessage(final String newMessage) {
68
-        setMessage(newMessage, null);
71
+        setMessage(newMessage, (StatusMessageNotifier) null);
69 72
     }
70 73
 
71 74
     public void setMessage(final String newMessage,
@@ -73,16 +76,16 @@ public class MessageLabel extends JLabel implements MouseListener {
73 76
         setMessage(null, newMessage, newNotifier);
74 77
     }
75 78
 
76
-    public void setMessage(final Icon icon, final String newMessage) {
77
-        setMessage(icon, newMessage, null);
79
+    public void setMessage(final String iconType, final String newMessage) {
80
+        setMessage(iconType, newMessage, null);
78 81
     }
79 82
 
80
-    public void setMessage(final Icon icon, final String newMessage,
83
+    public void setMessage(final String iconType, final String newMessage,
81 84
             final StatusMessageNotifier newNotifier) {
82 85
         final int timeout =
83 86
                 IdentityManager.getGlobalConfig().
84 87
                 getOptionInt("statusBar", "messageDisplayLength");
85
-        setMessage(icon, newMessage, newNotifier, timeout);
88
+        setMessage(iconType, newMessage, newNotifier, timeout);
86 89
     }
87 90
 
88 91
     public void setMessage(final String newMessage,
@@ -90,8 +93,9 @@ public class MessageLabel extends JLabel implements MouseListener {
90 93
         setMessage(null, newMessage, newNotifier, timeout);
91 94
     }
92 95
 
93
-    public synchronized void setMessage(final Icon icon, final String newMessage,
96
+    public synchronized void setMessage(final String iconType, final String newMessage,
94 97
             final StatusMessageNotifier newNotifier, final int timeout) {
98
+        final Icon icon = IconManager.getIconManager().getIcon(iconType);
95 99
         SwingUtilities.invokeLater(new Runnable() {
96 100
 
97 101
             /** {@inheritDoc} */

+ 25
- 11
src/com/dmdirc/addons/ui_swing/components/statusbar/SwingStatusBar.java Zobrazit soubor

@@ -22,13 +22,15 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
+import com.dmdirc.logger.ErrorLevel;
26
+import com.dmdirc.logger.Logger;
25 27
 import com.dmdirc.ui.interfaces.StatusBar;
28
+import com.dmdirc.ui.interfaces.StatusBarComponent;
26 29
 import com.dmdirc.ui.interfaces.StatusMessageNotifier;
27 30
 
28 31
 import java.awt.Component;
29 32
 import java.util.Arrays;
30 33
 
31
-import javax.swing.Icon;
32 34
 import javax.swing.JPanel;
33 35
 import javax.swing.SwingUtilities;
34 36
 
@@ -86,15 +88,15 @@ public final class SwingStatusBar extends JPanel implements StatusBar {
86 88
 
87 89
     /** {@inheritDoc} */
88 90
     @Override
89
-    public void setMessage(final Icon icon, final String newMessage) {
90
-        messageLabel.setMessage(icon, newMessage);
91
+    public void setMessage(final String iconType, final String newMessage) {
92
+        messageLabel.setMessage(iconType, newMessage);
91 93
     }
92 94
 
93 95
     /** {@inheritDoc} */
94 96
     @Override
95
-    public void setMessage(final Icon icon, final String newMessage,
97
+    public void setMessage(final String iconType, final String newMessage,
96 98
             final StatusMessageNotifier newNotifier) {
97
-        messageLabel.setMessage(icon, newMessage, newNotifier);
99
+        messageLabel.setMessage(iconType, newMessage, newNotifier);
98 100
     }
99 101
 
100 102
     /** {@inheritDoc} */
@@ -106,10 +108,10 @@ public final class SwingStatusBar extends JPanel implements StatusBar {
106 108
 
107 109
     /** {@inheritDoc} */
108 110
     @Override
109
-    public synchronized void setMessage(final Icon icon,
111
+    public synchronized void setMessage(final String iconType, 
110 112
             final String newMessage,
111 113
             final StatusMessageNotifier newNotifier, final int timeout) {
112
-        messageLabel.setMessage(icon, newMessage, newNotifier, timeout);
114
+        messageLabel.setMessage(iconType, newMessage, newNotifier, timeout);
113 115
     }
114 116
 
115 117
     /** {@inheritDoc} */
@@ -120,7 +122,13 @@ public final class SwingStatusBar extends JPanel implements StatusBar {
120 122
 
121 123
     /** {@inheritDoc} */
122 124
     @Override
123
-    public void addComponent(final Component component) {
125
+    public void addComponent(final StatusBarComponent component) {
126
+        if (!(component instanceof Component)) {
127
+            Logger.appError(ErrorLevel.HIGH, "Error adding status bar component", 
128
+                    new IllegalArgumentException("Component must be an " +
129
+                    "instance of java.awt.component"));
130
+            return;
131
+        }
124 132
         if (!Arrays.asList(getComponents()).contains(component)) {
125 133
             SwingUtilities.invokeLater(new Runnable() {
126 134
 
@@ -130,7 +138,7 @@ public final class SwingStatusBar extends JPanel implements StatusBar {
130 138
                     remove(updateLabel);
131 139
                     remove(errorLabel);
132 140
                     remove(inviteLabel);
133
-                    add(component,
141
+                    add((Component) component,
134 142
                             "sgy components, hmax 20, hmin 20, wmin 20, shrink 0");
135 143
                     add(updateLabel,
136 144
                             "sgy components, hmax 20, hmin 20, wmin 20, shrink 0");
@@ -146,13 +154,19 @@ public final class SwingStatusBar extends JPanel implements StatusBar {
146 154
 
147 155
     /** {@inheritDoc} */
148 156
     @Override
149
-    public void removeComponent(final Component component) {
157
+    public void removeComponent(final StatusBarComponent component) {
158
+        if (!(component instanceof Component)) {
159
+            Logger.appError(ErrorLevel.HIGH, "Error adding status bar component", 
160
+                    new IllegalArgumentException("Component must be an " +
161
+                    "instance of java.awt.component"));
162
+            return;
163
+        }
150 164
         SwingUtilities.invokeLater(new Runnable() {
151 165
 
152 166
             /** {@inheritDoc} */
153 167
             @Override
154 168
             public void run() {
155
-                remove(component);
169
+                remove((Component) component);
156 170
                 validate();
157 171
             }
158 172
             });

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/statusbar/UpdaterLabel.java Zobrazit soubor

@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_swing.components.statusbar;
25 25
 import com.dmdirc.addons.ui_swing.dialogs.updater.SwingUpdaterDialog;
26 26
 import com.dmdirc.interfaces.UpdateCheckerListener;
27 27
 import com.dmdirc.ui.IconManager;
28
+import com.dmdirc.ui.interfaces.StatusBarComponent;
28 29
 import com.dmdirc.updater.UpdateChecker;
29 30
 import com.dmdirc.updater.UpdateChecker.STATE;
30 31
 
@@ -38,8 +39,8 @@ import javax.swing.JLabel;
38 39
  * Updater label is responsible for handling the display of updates in the
39 40
  * status bar.
40 41
  */
41
-public class UpdaterLabel extends JLabel implements MouseListener,
42
-        UpdateCheckerListener {
42
+public class UpdaterLabel extends JLabel implements StatusBarComponent, 
43
+        MouseListener, UpdateCheckerListener {
43 44
 
44 45
     /**
45 46
      * A version number for this class. It should be changed whenever the class

+ 2
- 14
src/com/dmdirc/addons/windowstatus/WindowStatusPlugin.java Zobrazit soubor

@@ -48,12 +48,6 @@ import java.util.Hashtable;
48 48
 import java.util.Map;
49 49
 import java.util.Map.Entry;
50 50
 
51
-import javax.swing.BorderFactory;
52
-import javax.swing.JLabel;
53
-import javax.swing.JPanel;
54
-
55
-import net.miginfocom.swing.MigLayout;
56
-
57 51
 /**
58 52
  * Displays information related to the current window in the status bar.
59 53
  *
@@ -65,17 +59,11 @@ public final class WindowStatusPlugin extends Plugin implements ActionListener {
65 59
 	private static final String MY_DOMAIN = "plugin-Logging";
66 60
 
67 61
 	/** The panel we use in the status bar. */
68
-	private final JPanel panel = new JPanel();
69
-
70
-	/** The label we use to show window status. */
71
-	private final JLabel label = new JLabel("???");
62
+	private final WindowStatusPanel panel = new WindowStatusPanel();
72 63
 
73 64
 	/** Creates a new instance of WindowStatusPlugin. */
74 65
 	public WindowStatusPlugin() {
75 66
 		super();
76
-		panel.setBorder(BorderFactory.createEtchedBorder());
77
-		panel.setLayout(new MigLayout("ins 0 rel 0 rel, aligny center"));
78
-		panel.add(label);
79 67
 	}
80 68
 
81 69
 	/**
@@ -207,7 +195,7 @@ public final class WindowStatusPlugin extends Plugin implements ActionListener {
207 195
 		} else {
208 196
 			textString.append("???");
209 197
 		}
210
-		label.setText(textString.toString());
198
+		panel.setText(textString.toString());
211 199
 	}
212 200
 
213 201
 	/** {@inheritDoc} */

+ 8
- 12
src/com/dmdirc/ui/interfaces/StatusBar.java Zobrazit soubor

@@ -22,10 +22,6 @@
22 22
 
23 23
 package com.dmdirc.ui.interfaces;
24 24
 
25
-import java.awt.Component;
26
-
27
-import javax.swing.Icon;
28
-
29 25
 /**
30 26
  * Status bar interface.
31 27
  */
@@ -41,12 +37,12 @@ public interface StatusBar {
41 37
     /**
42 38
      * sets the message in the status bar.
43 39
      *
44
-     * @param icon Message icon
40
+     * @param iconType Message icon
45 41
      * @param newMessage Message to display
46 42
      * 
47 43
      * @since 0.6
48 44
      */
49
-    void setMessage(final Icon icon, final String newMessage);
45
+    void setMessage(final String iconType, final String newMessage);
50 46
     
51 47
     /**
52 48
      * Sets the message in the status bar with a specified callback event
@@ -65,14 +61,14 @@ public interface StatusBar {
65 61
      * Sets the message in the status bar with a specified callback event
66 62
      * using the default timeout.
67 63
      *
68
-     * @param icon Message icon
64
+     * @param iconType Message icon
69 65
      * @param newMessage Message to display
70 66
      * @param newNotifier status message notifier to be notified for events on
71 67
      * this message
72 68
      * 
73 69
      * @since 0.6
74 70
      */
75
-    void setMessage(final Icon icon, final String newMessage, 
71
+    void setMessage(final String iconType, final String newMessage, 
76 72
             final StatusMessageNotifier newNotifier);
77 73
     
78 74
     /**
@@ -91,7 +87,7 @@ public interface StatusBar {
91 87
      * Sets the message in the status bar with a specified callback event for
92 88
      * a specified time.
93 89
      *
94
-     * @param icon Message icon
90
+     * @param iconType Message icon
95 91
      * @param newMessage Message to display
96 92
      * @param newNotifier status message notifier to be notified for events on
97 93
      * this message
@@ -99,7 +95,7 @@ public interface StatusBar {
99 95
      * 
100 96
      * @since 0.6
101 97
      */
102
-    void setMessage(final Icon icon, final String newMessage,
98
+    void setMessage(final String iconType, final String newMessage,
103 99
             final StatusMessageNotifier newNotifier, final int timeout);
104 100
     
105 101
     /**
@@ -112,14 +108,14 @@ public interface StatusBar {
112 108
      *
113 109
      * @param component component to add
114 110
      */
115
-    void addComponent(final Component component);
111
+    void addComponent(final StatusBarComponent component);
116 112
     
117 113
     /**
118 114
      * Removes a component to the status bar.
119 115
      *
120 116
      * @param component component to add
121 117
      */
122
-    void removeComponent(final Component component);
118
+    void removeComponent(final StatusBarComponent component);
123 119
     
124 120
     /**
125 121
      * Returns true if the status bar is visible.

+ 0
- 2
src/com/dmdirc/ui/interfaces/Window.java Zobrazit soubor

@@ -28,8 +28,6 @@ import com.dmdirc.config.ConfigManager;
28 28
 
29 29
 import java.beans.PropertyVetoException;
30 30
 
31
-import javax.swing.Icon;
32
-
33 31
 /**
34 32
  * The Window interface specifies common methods that should be implemented
35 33
  * by all windows. It is assumed that all windows have a main text area.

Načítá se…
Zrušit
Uložit