Przeglądaj źródła

Added Selection and IconChange listeners

Removed deprecated frame manager methods

git-svn-id: http://svn.dmdirc.com/trunk@2476 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Chris Smith 16 lat temu
rodzic
commit
aed4d6b3cb

+ 62
- 1
src/com/dmdirc/FrameContainer.java Wyświetl plik

@@ -23,7 +23,9 @@
23 23
 package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.config.ConfigManager;
26
+import com.dmdirc.interfaces.IconChangeListener;
26 27
 import com.dmdirc.interfaces.NotificationListener;
28
+import com.dmdirc.interfaces.SelectionListener;
27 29
 import com.dmdirc.logger.ErrorLevel;
28 30
 import com.dmdirc.logger.Logger;
29 31
 import com.dmdirc.ui.interfaces.Window;
@@ -214,7 +216,15 @@ public abstract class FrameContainer {
214 216
                 Logger.userError(ErrorLevel.LOW, "Unable to maximise window");
215 217
             }
216 218
         }
217
-        Main.getUI().getMainWindow().getFrameManager().setSelected(this);
219
+        
220
+        final Object[] listenerList = listeners.getListenerList();
221
+        for (int i = 0; i < listenerList.length; i += 2) {
222
+            if (listenerList[i] == SelectionListener.class) {
223
+                ((SelectionListener) listenerList[i + 1])
224
+                            .selectionChanged(getFrame());
225
+            }
226
+        }        
227
+        
218 228
         clearNotification();
219 229
 
220 230
         if (getServer() != null) {
@@ -254,6 +264,21 @@ public abstract class FrameContainer {
254 264
             getFrame().addLine(type, args);
255 265
         }
256 266
     }
267
+    
268
+    /**
269
+     * Informs icon change listeners that this container's icon has changed.
270
+     * 
271
+     * @param newIcon This container's new icon
272
+     */
273
+    protected void iconUpdated(final Icon newIcon) {
274
+        final Object[] listenerList = listeners.getListenerList();
275
+        for (int i = 0; i < listenerList.length; i += 2) {
276
+            if (listenerList[i] == IconChangeListener.class) {
277
+                ((IconChangeListener) listenerList[i + 1])
278
+                            .iconChanged(getFrame(), newIcon);
279
+            }
280
+        }        
281
+    }
257 282
 
258 283
     /**
259 284
      * Adds a notification listener for this frame container.
@@ -272,4 +297,40 @@ public abstract class FrameContainer {
272 297
     public void removeNotificationListener(final NotificationListener listener) {
273 298
         listeners.remove(NotificationListener.class, listener);
274 299
     }
300
+    
301
+    /**
302
+     * Adds a selection listener for this frame container.
303
+     *
304
+     * @param listener The listener to be added
305
+     */
306
+    public void addSelectionListener(final SelectionListener listener) {
307
+        listeners.add(SelectionListener.class, listener);
308
+    }
309
+
310
+    /**
311
+     * Removes a selection listener from this frame container.
312
+     *
313
+     * @param listener The listener to be removed
314
+     */
315
+    public void removeSelectionListener(final SelectionListener listener) {
316
+        listeners.remove(SelectionListener.class, listener);
317
+    }    
318
+    
319
+    /**
320
+     * Adds an icon change listener for this frame container.
321
+     *
322
+     * @param listener The listener to be added
323
+     */
324
+    public void addIconChangeListener(final IconChangeListener listener) {
325
+        listeners.add(IconChangeListener.class, listener);
326
+    }
327
+
328
+    /**
329
+     * Removes an icon change listener from this frame container.
330
+     *
331
+     * @param listener The listener to be removed
332
+     */
333
+    public void removeIconChangeListener(final IconChangeListener listener) {
334
+        listeners.remove(IconChangeListener.class, listener);
335
+    }       
275 336
 }

+ 2
- 1
src/com/dmdirc/Server.java Wyświetl plik

@@ -270,7 +270,8 @@ public final class Server extends WritableFrameContainer implements Serializable
270 270
                 serverInfo.getSSL() ? "secure-server" : "server");
271 271
         if (window != null) {
272 272
             window.setFrameIcon(icon);
273
-            Main.getUI().getMainWindow().getFrameManager().iconUpdated(this);
273
+            
274
+            iconUpdated(icon);
274 275
         }
275 276
     }
276 277
     

+ 47
- 0
src/com/dmdirc/interfaces/IconChangeListener.java Wyświetl plik

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.interfaces;
24
+
25
+import com.dmdirc.ui.interfaces.Window;
26
+
27
+import java.util.EventListener;
28
+
29
+import javax.swing.Icon;
30
+
31
+/**
32
+ * Defines the methods that should be implemented by classes which wish to
33
+ * receive information about frame icon changes.
34
+ *
35
+ * @author Chris
36
+ */
37
+public interface IconChangeListener extends EventListener {
38
+
39
+    /**
40
+     * Called when a window's icon is changed.
41
+     *
42
+     * @param window The window whose icon changed
43
+     * @param icon The new icon for the window
44
+     */
45
+    void iconChanged(final Window window, final Icon icon);
46
+
47
+}

+ 44
- 0
src/com/dmdirc/interfaces/SelectionListener.java Wyświetl plik

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.interfaces;
24
+
25
+import com.dmdirc.ui.interfaces.Window;
26
+
27
+import java.util.EventListener;
28
+
29
+/**
30
+ * Defines the methods that should be implemented by classes which wish to
31
+ * receive information about frame selection changes.
32
+ *
33
+ * @author Chris
34
+ */
35
+public interface SelectionListener extends EventListener {
36
+
37
+    /**
38
+     * Called when a new window is selected.
39
+     *
40
+     * @param window The window that's now selected
41
+     */
42
+    void selectionChanged(final Window window);
43
+
44
+}

+ 1
- 8
src/com/dmdirc/ui/dummy/DummyController.java Wyświetl plik

@@ -29,7 +29,6 @@ import com.dmdirc.Server;
29 29
 import com.dmdirc.WritableFrameContainer;
30 30
 import com.dmdirc.commandparser.parsers.CommandParser;
31 31
 import com.dmdirc.ui.interfaces.ChannelWindow;
32
-import com.dmdirc.ui.interfaces.FrameManager;
33 32
 import com.dmdirc.ui.interfaces.InputWindow;
34 33
 import com.dmdirc.ui.interfaces.MainWindow;
35 34
 import com.dmdirc.ui.interfaces.PreferencesInterface;
@@ -40,7 +39,6 @@ import com.dmdirc.ui.interfaces.StatusBar;
40 39
 import com.dmdirc.ui.interfaces.UIController;
41 40
 import com.dmdirc.ui.interfaces.UpdaterDialog;
42 41
 import com.dmdirc.ui.interfaces.Window;
43
-import com.dmdirc.ui.dummy.DummyFrameManager;
44 42
 import com.dmdirc.updater.Update;
45 43
 
46 44
 import java.util.List;
@@ -69,12 +67,7 @@ public final class DummyController implements UIController {
69 67
     public StatusBar getStatusBar() {
70 68
         return new DummyStatusBar();
71 69
     }
72
-    
73
-    /** {@inheritDoc} */
74
-    public FrameManager getFrameManager() {
75
-        return new DummyFrameManager();
76
-    }
77
-    
70
+       
78 71
     /** {@inheritDoc} */
79 72
     public ChannelWindow getChannel(final Channel channel) {
80 73
         return new DummyChannelWindow(channel);

+ 0
- 8
src/com/dmdirc/ui/dummy/DummyMainWindow.java Wyświetl plik

@@ -22,10 +22,8 @@
22 22
 
23 23
 package com.dmdirc.ui.dummy;
24 24
 
25
-import com.dmdirc.ui.interfaces.FrameManager;
26 25
 import com.dmdirc.ui.interfaces.MainWindow;
27 26
 import com.dmdirc.ui.interfaces.Window;
28
-import com.dmdirc.ui.dummy.DummyFrameManager;
29 27
 
30 28
 import java.util.ArrayList;
31 29
 import java.util.List;
@@ -71,12 +69,6 @@ public final class DummyMainWindow implements MainWindow {
71 69
         active = frame;
72 70
     }
73 71
     
74
-    /** {@inheritDoc} */
75
-    @Deprecated
76
-    public FrameManager getFrameManager() {
77
-        return new DummyFrameManager();
78
-    }
79
-    
80 72
     /** {@inheritDoc} */
81 73
     public ImageIcon getIcon() {
82 74
         return null;

+ 1
- 10
src/com/dmdirc/ui/interfaces/MainWindow.java Wyświetl plik

@@ -50,16 +50,7 @@ public interface MainWindow {
50 50
      * @param frame The frame to be activated
51 51
      */
52 52
     void setActiveFrame(final Window frame);
53
-    
54
-    /**
55
-     * Retrieves the frame manager that's currently in use.
56
-     *
57
-     * @return The current frame manager
58
-     * @deprecated Frame Managers should interface via WindowManager.
59
-     */
60
-    @Deprecated
61
-    FrameManager getFrameManager();
62
-    
53
+        
63 54
     /**
64 55
      * Retrieves the application icon.
65 56
      *

+ 0
- 8
src/com/dmdirc/ui/interfaces/UIController.java Wyświetl plik

@@ -54,14 +54,6 @@ public interface UIController {
54 54
      */
55 55
     StatusBar getStatusBar();
56 56
     
57
-    /**
58
-     * Retrieves the frame manager used by this UI.
59
-     *
60
-     * @return This UI's frame manager
61
-     */
62
-    @Deprecated
63
-    FrameManager getFrameManager();
64
-    
65 57
     /**
66 58
      * Creates a channel window for the specified channel.
67 59
      *

+ 0
- 7
src/com/dmdirc/ui/swing/MainFrame.java Wyświetl plik

@@ -284,13 +284,6 @@ public final class MainFrame extends JFrame implements WindowListener,
284 284
         }
285 285
     }
286 286
 
287
-    /** {@inheritDoc}. */
288
-    @Override
289
-    @Deprecated
290
-    public FrameManager getFrameManager() {
291
-        return mainFrameManager;
292
-    }
293
-
294 287
     /**
295 288
      * Returns the size of the frame manager.
296 289
      *

+ 0
- 6
src/com/dmdirc/ui/swing/SwingController.java Wyświetl plik

@@ -34,7 +34,6 @@ import com.dmdirc.config.IdentityManager;
34 34
 import com.dmdirc.logger.ErrorLevel;
35 35
 import com.dmdirc.logger.Logger;
36 36
 import com.dmdirc.ui.interfaces.ChannelWindow;
37
-import com.dmdirc.ui.interfaces.FrameManager;
38 37
 import com.dmdirc.ui.interfaces.InputWindow;
39 38
 import com.dmdirc.ui.interfaces.PreferencesInterface;
40 39
 import com.dmdirc.ui.interfaces.PreferencesPanel;
@@ -95,11 +94,6 @@ public final class SwingController implements UIController {
95 94
         return statusBar;
96 95
     }
97 96
     
98
-    /** {@inheritDoc} */
99
-    public FrameManager getFrameManager() {
100
-        return getMainWindow().getFrameManager();
101
-    }
102
-    
103 97
     /** {@inheritDoc} */
104 98
     public ChannelWindow getChannel(final Channel channel) {
105 99
         return new ChannelFrame(channel);

Ładowanie…
Anuluj
Zapisz