Browse Source

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 17 years ago
parent
commit
aed4d6b3cb

+ 62
- 1
src/com/dmdirc/FrameContainer.java View File

23
 package com.dmdirc;
23
 package com.dmdirc;
24
 
24
 
25
 import com.dmdirc.config.ConfigManager;
25
 import com.dmdirc.config.ConfigManager;
26
+import com.dmdirc.interfaces.IconChangeListener;
26
 import com.dmdirc.interfaces.NotificationListener;
27
 import com.dmdirc.interfaces.NotificationListener;
28
+import com.dmdirc.interfaces.SelectionListener;
27
 import com.dmdirc.logger.ErrorLevel;
29
 import com.dmdirc.logger.ErrorLevel;
28
 import com.dmdirc.logger.Logger;
30
 import com.dmdirc.logger.Logger;
29
 import com.dmdirc.ui.interfaces.Window;
31
 import com.dmdirc.ui.interfaces.Window;
214
                 Logger.userError(ErrorLevel.LOW, "Unable to maximise window");
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
         clearNotification();
228
         clearNotification();
219
 
229
 
220
         if (getServer() != null) {
230
         if (getServer() != null) {
254
             getFrame().addLine(type, args);
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
      * Adds a notification listener for this frame container.
284
      * Adds a notification listener for this frame container.
272
     public void removeNotificationListener(final NotificationListener listener) {
297
     public void removeNotificationListener(final NotificationListener listener) {
273
         listeners.remove(NotificationListener.class, listener);
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 View File

270
                 serverInfo.getSSL() ? "secure-server" : "server");
270
                 serverInfo.getSSL() ? "secure-server" : "server");
271
         if (window != null) {
271
         if (window != null) {
272
             window.setFrameIcon(icon);
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 View File

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 View File

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 View File

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

+ 0
- 8
src/com/dmdirc/ui/dummy/DummyMainWindow.java View File

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

+ 1
- 10
src/com/dmdirc/ui/interfaces/MainWindow.java View File

50
      * @param frame The frame to be activated
50
      * @param frame The frame to be activated
51
      */
51
      */
52
     void setActiveFrame(final Window frame);
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
      * Retrieves the application icon.
55
      * Retrieves the application icon.
65
      *
56
      *

+ 0
- 8
src/com/dmdirc/ui/interfaces/UIController.java View File

54
      */
54
      */
55
     StatusBar getStatusBar();
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
      * Creates a channel window for the specified channel.
58
      * Creates a channel window for the specified channel.
67
      *
59
      *

+ 0
- 7
src/com/dmdirc/ui/swing/MainFrame.java View File

284
         }
284
         }
285
     }
285
     }
286
 
286
 
287
-    /** {@inheritDoc}. */
288
-    @Override
289
-    @Deprecated
290
-    public FrameManager getFrameManager() {
291
-        return mainFrameManager;
292
-    }
293
-
294
     /**
287
     /**
295
      * Returns the size of the frame manager.
288
      * Returns the size of the frame manager.
296
      *
289
      *

+ 0
- 6
src/com/dmdirc/ui/swing/SwingController.java View File

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

Loading…
Cancel
Save