Parcourir la source

Move FrameManager to the SwingUI, use UI window listeners for frame containers

Make background opened windows respect maximised states

Fixes issue 4037

Change-Id: I2d5096ef116b5e5325eb050c51a17cab4e5b867d
Reviewed-on: http://gerrit.dmdirc.com/1154
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.4
Greboid il y a 14 ans
Parent
révision
15f5314833

+ 0
- 97
src/com/dmdirc/addons/ui_dummy/DummyFrameManager.java Voir le fichier

@@ -1,97 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2010 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.addons.ui_dummy;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Main;
27
-import com.dmdirc.ui.interfaces.FrameManager;
28
-import com.dmdirc.ui.interfaces.UIController;
29
-
30
-import java.awt.Color;
31
-
32
-import javax.swing.JComponent;
33
-
34
-/**
35
- * A dummy frame manager. Does nothing.
36
- * @author chris
37
- */
38
-public class DummyFrameManager implements FrameManager {
39
-    
40
-    /** Creates a new instance of DummyFrameManager. */
41
-    public DummyFrameManager() {
42
-        //Do nothing.
43
-    }
44
-    
45
-    /** {@inheritDoc} */
46
-    @Override
47
-    public void setParent(final JComponent parent) {
48
-        parent.setBackground(Color.RED);
49
-    }
50
-    
51
-    /** {@inheritDoc} */
52
-    @Override
53
-    public void addWindow(final FrameContainer<?> window, final boolean focus) {
54
-        Main.getUI().getStatusBar()
55
-                .setMessage("DummyFrameManager: addServer: " + window);
56
-    }
57
-    
58
-    /** {@inheritDoc} */
59
-    @Override
60
-    public void delWindow(final FrameContainer<?> window) {
61
-        Main.getUI().getStatusBar()
62
-                .setMessage("DummyFrameManager: delServer: " + window);
63
-    }
64
-    
65
-    /** {@inheritDoc} */
66
-    @Override
67
-    public void addWindow(final FrameContainer<?> parent,
68
-            final FrameContainer<?> window, final boolean focus) {
69
-        Main.getUI().getStatusBar()
70
-                .setMessage("DummyFrameManager: addCustom: " + window + "@" + parent);
71
-    }
72
-    
73
-    /** {@inheritDoc} */
74
-    @Override
75
-    public void delWindow(final FrameContainer<?> parent, final FrameContainer<?> window) {
76
-        Main.getUI().getStatusBar()
77
-                .setMessage("DummyFrameManager: delCustom: " + window + "@" + parent);
78
-    }
79
-    
80
-    /** {@inheritDoc} */
81
-    @Override
82
-    public boolean canPositionVertically() {
83
-        return true;
84
-    }
85
-    
86
-    /** {@inheritDoc} */
87
-    @Override
88
-    public boolean canPositionHorizontally() {
89
-        return true;
90
-    }
91
-
92
-    @Override
93
-    public void setController(UIController controller) {
94
-        throw new UnsupportedOperationException("Not supported yet.");
95
-    }
96
-
97
-}

+ 3
- 7
src/com/dmdirc/addons/ui_swing/MainFrame.java Voir le fichier

@@ -32,14 +32,12 @@ import com.dmdirc.Main;
32 32
 import com.dmdirc.ServerManager;
33 33
 import com.dmdirc.actions.ActionManager;
34 34
 import com.dmdirc.actions.CoreActionType;
35
-import com.dmdirc.addons.ui_swing.SwingWindowFactory.SwingWindowListener;
36 35
 import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
37 36
 import com.dmdirc.config.IdentityManager;
38 37
 import com.dmdirc.interfaces.ConfigChangeListener;
39 38
 import com.dmdirc.ui.IconManager;
40
-import com.dmdirc.ui.WindowManager;
41
-import com.dmdirc.ui.interfaces.FrameManager;
42
-import com.dmdirc.ui.interfaces.FramemanagerPosition;
39
+import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
40
+import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
43 41
 import com.dmdirc.ui.interfaces.MainWindow;
44 42
 import com.dmdirc.ui.interfaces.Window;
45 43
 import com.dmdirc.ui.CoreUIUtils;
@@ -365,10 +363,8 @@ public final class MainFrame extends JFrame implements WindowListener,
365 363
                     mainFrameManager = new TreeFrameManager();
366 364
                 }
367 365
                 mainFrameManager.setController(controller);
368
-
369
-                WindowManager.addFrameListener(mainFrameManager);
370 366
                 mainFrameManager.setParent(frameManagerPanel);
371
-
367
+                controller.getWindowFactory().addWindowListener(mainFrameManager);
372 368
                 controller.getWindowFactory().addWindowListener(MainFrame.this);
373 369
             }
374 370
         });

+ 0
- 24
src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java Voir le fichier

@@ -170,28 +170,4 @@ public class SwingWindowFactory implements FrameListener {
170 170
             }
171 171
         });
172 172
     }
173
-
174
-    /**
175
-     * An interface for objects interested in Swing UI window events.
176
-     */
177
-    public static interface SwingWindowListener {
178
-
179
-        /**
180
-         * Called when a new window is added.
181
-         *
182
-         * @param parent The parent of the added window (may be null)
183
-         * @param window The window that was added
184
-         */
185
-        void windowAdded(final Window parent, final Window window);
186
-
187
-        /**
188
-         * Called when a new window was deleted.
189
-         *
190
-         * @param parent The parent of the added window (may be null)
191
-         * @param window The window that was deleted
192
-         */
193
-        void windowDeleted(final Window parent, final Window window);
194
-        
195
-    }
196
-
197 173
 }

+ 47
- 0
src/com/dmdirc/addons/ui_swing/SwingWindowListener.java Voir le fichier

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.addons.ui_swing;
24
+
25
+import com.dmdirc.ui.interfaces.Window;
26
+
27
+/**
28
+ * An interface for objects interested in Swing UI window events.
29
+ */
30
+public interface SwingWindowListener {
31
+
32
+    /**
33
+     * Called when a new window is added.
34
+     *
35
+     * @param parent The parent of the added window (may be null)
36
+     * @param window The window that was added
37
+     */
38
+    void windowAdded(final Window parent, final Window window);
39
+
40
+    /**
41
+     * Called when a new window was deleted.
42
+     *
43
+     * @param parent The parent of the added window (may be null)
44
+     * @param window The window that was deleted
45
+     */
46
+    void windowDeleted(final Window parent, final Window window);
47
+}

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/MDIBar.java Voir le fichier

@@ -27,7 +27,7 @@ import com.dmdirc.addons.ui_swing.MainFrame;
27 27
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28 28
 import com.dmdirc.FrameContainer;
29 29
 import com.dmdirc.addons.ui_swing.SwingController;
30
-import com.dmdirc.addons.ui_swing.SwingWindowFactory.SwingWindowListener;
30
+import com.dmdirc.addons.ui_swing.SwingWindowListener;
31 31
 import com.dmdirc.config.ConfigManager;
32 32
 import com.dmdirc.config.IdentityManager;
33 33
 import com.dmdirc.interfaces.ConfigChangeListener;

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/desktopPane/DMDircDesktopPane.java Voir le fichier

@@ -26,7 +26,7 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.addons.ui_swing.BackgroundOption;
27 27
 import com.dmdirc.addons.ui_swing.MainFrame;
28 28
 import com.dmdirc.addons.ui_swing.SwingController;
29
-import com.dmdirc.addons.ui_swing.SwingWindowFactory.SwingWindowListener;
29
+import com.dmdirc.addons.ui_swing.SwingWindowListener;
30 30
 import com.dmdirc.addons.ui_swing.UIUtilities;
31 31
 import com.dmdirc.addons.ui_swing.components.TreeScroller;
32 32
 import com.dmdirc.addons.ui_swing.components.frames.InputTextFrame;

+ 1
- 0
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java Voir le fichier

@@ -275,6 +275,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
275 275
                     if (isIcon()) {
276 276
                         setIcon(false);
277 277
                     }
278
+                    setMaximum(controller.getMainFrame().getMaximised());
278 279
                     if (!isVisible()) {
279 280
                         TextFrame.super.setVisible(true);
280 281
                     }

+ 70
- 0
src/com/dmdirc/addons/ui_swing/framemanager/FrameManager.java Voir le fichier

@@ -0,0 +1,70 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.addons.ui_swing.framemanager;
24
+
25
+import com.dmdirc.addons.ui_swing.SwingWindowListener;
26
+import com.dmdirc.ui.interfaces.UIController;
27
+
28
+import javax.swing.JComponent;
29
+
30
+/**
31
+ * A frame manager is a widget that allows the user to navigate between the
32
+ * various frames that will be open at any one time.
33
+ * 
34
+ * @author chris
35
+ */
36
+public interface FrameManager extends SwingWindowListener {
37
+    
38
+    /**
39
+     * Sets the parent component of this frame manager. The frame manager
40
+     * should render itself within the parent.
41
+     * 
42
+     * @param parent The parent control
43
+     */
44
+    void setParent(JComponent parent);
45
+
46
+    /**
47
+     * Sets the UIController fot the frame manager.  This method will be called
48
+     * immediately after contruction of the frame manager.
49
+     *
50
+     * @param controller UIController
51
+     */
52
+    void setController(UIController controller);
53
+    
54
+    /**
55
+     * Indicates whether this frame manager can be positioned vertically
56
+     * (i.e., at the side of the screen).
57
+     * 
58
+     * @return True iff the frame manager can be positioned vertically
59
+     */
60
+    boolean canPositionVertically();
61
+    
62
+    /**
63
+     * Indicates whether this frame manager can be positioned horizontally
64
+     * (i.e., at the top or bottom of the screen).
65
+     * 
66
+     * @return True iff the frame manager can be positioned horizontally
67
+     */
68
+    boolean canPositionHorizontally();
69
+
70
+}

+ 68
- 0
src/com/dmdirc/addons/ui_swing/framemanager/FramemanagerPosition.java Voir le fichier

@@ -0,0 +1,68 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.addons.ui_swing.framemanager;
24
+
25
+import java.util.Locale;
26
+
27
+/**
28
+ * Frame manager position enum.
29
+ */
30
+public enum FramemanagerPosition {
31
+    /** Top of the window. */
32
+    TOP,
33
+    /** Left side of the window. */
34
+    LEFT,
35
+    /** Bottom of the window. */
36
+    BOTTOM,
37
+    /** Right side of the window. */
38
+    RIGHT,
39
+    /** Unknown position. */
40
+    UNKNOWN;
41
+    
42
+    /**
43
+     * Returns the frame position for s specified string.
44
+     *
45
+     * @param name Name of the string
46
+     *
47
+     * @return FramemanagerPosition for the string
48
+     */
49
+    public static FramemanagerPosition getPosition(final String name) {
50
+        if (name == null) {
51
+            return UNKNOWN;
52
+        }
53
+        try {
54
+            return valueOf(name.toUpperCase(Locale.getDefault()));
55
+        } catch (IllegalArgumentException ex) {
56
+            return valueOf("UNKNOWN");
57
+        }
58
+    }
59
+    
60
+    /**
61
+     * Determines if this position is one of the two horizontal positions.
62
+     * 
63
+     * @return True if this is a horizontal position, false otherwise
64
+     */
65
+    public boolean isHorizontal() {
66
+        return this == TOP || this == BOTTOM;
67
+    }
68
+}

+ 26
- 55
src/com/dmdirc/addons/ui_swing/framemanager/buttonbar/ButtonBar.java Voir le fichier

@@ -32,8 +32,8 @@ import com.dmdirc.interfaces.FrameInfoListener;
32 32
 import com.dmdirc.interfaces.NotificationListener;
33 33
 import com.dmdirc.interfaces.SelectionListener;
34 34
 import com.dmdirc.ui.IconManager;
35
-import com.dmdirc.ui.interfaces.FrameManager;
36
-import com.dmdirc.ui.interfaces.FramemanagerPosition;
35
+import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
36
+import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
37 37
 import com.dmdirc.ui.interfaces.UIController;
38 38
 import com.dmdirc.ui.interfaces.Window;
39 39
 import com.dmdirc.util.MapList;
@@ -210,80 +210,51 @@ public final class ButtonBar implements FrameManager, ActionListener,
210 210
 
211 211
     /** {@inheritDoc} */
212 212
     @Override
213
-    public void addWindow(final FrameContainer<?> window, final boolean focus) {
213
+    public void windowAdded(final Window parent, final Window window) {
214 214
         UIUtilities.invokeLater(new Runnable() {
215 215
 
216 216
             /** {inheritDoc} */
217 217
             @Override
218 218
             public void run() {
219
-                windows.add(window);
220
-                //This window is a root window
221
-                addButton(window);
222
-
223
-                relayout();
224
-                window.addNotificationListener(ButtonBar.this);
225
-                window.addSelectionListener(ButtonBar.this);
226
-                window.addFrameInfoListener(ButtonBar.this);
227
-            }
228
-
229
-        });
230
-    }
231
-
232
-    /** {@inheritDoc} */
233
-    @Override
234
-    public void delWindow(final FrameContainer<?> window) {
235
-        UIUtilities.invokeLater(new Runnable() {
236
-
237
-            /** {inheritDoc} */
238
-            @Override
239
-            public void run() {
240
-                windows.remove(window);
241
-                buttons.remove(window);
219
+                if (parent == null) {
220
+                    windows.add(window.getContainer());
221
+                    //This window is a root window
222
+                    addButton(window.getContainer());
223
+                } else {
224
+                    windows.add(parent.getContainer(), window.getContainer());
225
+                    //This window is a root window
226
+                    addButton(window.getContainer());
227
+                }
242 228
 
243 229
                 relayout();
244
-                window.removeNotificationListener(ButtonBar.this);
245
-                window.removeFrameInfoListener(ButtonBar.this);
246
-                window.removeSelectionListener(ButtonBar.this);
230
+                window.getContainer().addNotificationListener(ButtonBar.this);
231
+                window.getContainer().addSelectionListener(ButtonBar.this);
232
+                window.getContainer().addFrameInfoListener(ButtonBar.this);
247 233
             }
248
-        });
249
-    }
250
-
251
-    /** {@inheritDoc} */
252
-    @Override
253
-    public void addWindow(final FrameContainer<?> parent,
254
-            final FrameContainer<?> window, final boolean focus) {
255
-        UIUtilities.invokeLater(new Runnable() {
256 234
 
257
-            /** {inheritDoc} */
258
-            @Override
259
-            public void run() {
260
-                windows.add(parent, window);
261
-                //This window has a parent Window
262
-                addButton(window);
263
-
264
-                relayout();
265
-                window.addNotificationListener(ButtonBar.this);
266
-                window.addSelectionListener(ButtonBar.this);
267
-                window.addFrameInfoListener(ButtonBar.this);
268
-            }
269 235
         });
270 236
     }
271 237
 
272 238
     /** {@inheritDoc} */
273 239
     @Override
274
-    public void delWindow(final FrameContainer<?> parent, final FrameContainer<?> window) {
240
+    public void windowDeleted(final Window parent, final Window window) {
275 241
         UIUtilities.invokeLater(new Runnable() {
276 242
 
277 243
             /** {inheritDoc} */
278 244
             @Override
279 245
             public void run() {
280
-                windows.remove(parent, window);
281
-                buttons.remove(window);
246
+                if (parent == null) {
247
+                    windows.remove(window.getContainer());
248
+                    buttons.remove(window.getContainer());
249
+                } else {
250
+                    windows.remove(parent.getContainer(), window.getContainer());
251
+                    buttons.remove(parent.getContainer());
252
+                }
282 253
 
283 254
                 relayout();
284
-            window.removeNotificationListener(ButtonBar.this);
285
-            window.removeFrameInfoListener(ButtonBar.this);
286
-            window.removeSelectionListener(ButtonBar.this);
255
+                window.getContainer().removeNotificationListener(ButtonBar.this);
256
+                window.getContainer().removeFrameInfoListener(ButtonBar.this);
257
+                window.getContainer().removeSelectionListener(ButtonBar.this);
287 258
             }
288 259
         });
289 260
     }

+ 18
- 27
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java Voir le fichier

@@ -31,10 +31,11 @@ import com.dmdirc.interfaces.NotificationListener;
31 31
 import com.dmdirc.interfaces.SelectionListener;
32 32
 import com.dmdirc.logger.ErrorLevel;
33 33
 import com.dmdirc.logger.Logger;
34
-import com.dmdirc.ui.interfaces.FrameManager;
34
+import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
35 35
 import com.dmdirc.addons.ui_swing.UIUtilities;
36 36
 import com.dmdirc.ui.WindowManager;
37 37
 import com.dmdirc.ui.interfaces.UIController;
38
+import com.dmdirc.ui.interfaces.Window;
38 39
 
39 40
 import java.awt.Color;
40 41
 import java.awt.Rectangle;
@@ -150,51 +151,41 @@ public final class TreeFrameManager implements FrameManager,
150 151
 
151 152
     /** {@inheritDoc} */
152 153
     @Override
153
-    public void addWindow(final FrameContainer<?> window, final boolean focus) {
154
-        addWindow(model.getRootNode(), window);
155
-    }
156
-
157
-    /** {@inheritDoc} */
158
-    @Override
159
-    public void addWindow(final FrameContainer<?> parent,
160
-            final FrameContainer<?> window, final boolean focus) {
161
-        addWindow(nodes.get(parent), window);
162
-    }
163
-
164
-    /** {@inheritDoc} */
165
-    @Override
166
-    public void delWindow(final FrameContainer<?> parent,
167
-            final FrameContainer<?> window) {
168
-        delWindow(window);
154
+    public void windowAdded(final Window parent, final Window window) {
155
+        if (parent == null) {
156
+            addWindow(model.getRootNode(), window.getContainer());
157
+        } else {
158
+            addWindow(nodes.get(parent.getContainer()), window.getContainer());
159
+        }
169 160
     }
170 161
 
171 162
     /** {@inheritDoc} */
172 163
     @Override
173
-    public void delWindow(final FrameContainer<?> window) {
164
+    public void windowDeleted(final Window parent, final Window window) {
174 165
         UIUtilities.invokeAndWait(new Runnable() {
175 166
 
176 167
             /** {@inheritDoc} */
177 168
             @Override
178 169
             public void run() {
179
-                if (nodes == null || nodes.get(window) == null) {
170
+                if (nodes == null || nodes.get(window.getContainer()) == null) {
180 171
                     return;
181 172
                 }
182 173
                 final DefaultMutableTreeNode node =
183
-                        nodes.get(window);
174
+                        nodes.get(window.getContainer());
184 175
                 if (node.getLevel() == 0) {
185 176
                     Logger.appError(ErrorLevel.MEDIUM,
186 177
                             "delServer triggered for root node" +
187 178
                             node.toString(),
188 179
                             new IllegalArgumentException());
189 180
                 } else {
190
-                    model.removeNodeFromParent(nodes.get(window));
181
+                    model.removeNodeFromParent(nodes.get(window.getContainer()));
191 182
                 }
192 183
                 synchronized (nodes) {
193
-                    nodes.remove(window);
184
+                    nodes.remove(window.getContainer());
194 185
                 }
195
-                window.removeSelectionListener(TreeFrameManager.this);
196
-                window.removeFrameInfoListener(TreeFrameManager.this);
197
-                window.removeNotificationListener(TreeFrameManager.this);
186
+                window.getContainer().removeSelectionListener(TreeFrameManager.this);
187
+                window.getContainer().removeFrameInfoListener(TreeFrameManager.this);
188
+                window.getContainer().removeNotificationListener(TreeFrameManager.this);
198 189
             }
199 190
         });
200 191
     }
@@ -308,10 +299,10 @@ public final class TreeFrameManager implements FrameManager,
308 299
                         null, null));
309 300
 
310 301
                 for (FrameContainer<?> window : WindowManager.getRootWindows()) {
311
-                    addWindow(window, false);
302
+                    addWindow(null, window);
312 303
                     final Collection<FrameContainer<?>> childWindows = window.getChildren();
313 304
                     for (FrameContainer childWindow : childWindows) {
314
-                        addWindow(window, childWindow, false);
305
+                        addWindow(nodes.get(window), childWindow);
315 306
                     }
316 307
                 }
317 308
             }

+ 1
- 4
src/com/dmdirc/addons/ui_web/WebInterfaceUI.java Voir le fichier

@@ -42,7 +42,6 @@ import com.dmdirc.ui.WindowManager;
42 42
 import com.dmdirc.updater.Update;
43 43
 
44 44
 import com.dmdirc.addons.ui_web.uicomponents.WebChannelWindow;
45
-import com.dmdirc.addons.ui_web.uicomponents.WebFrameManager;
46 45
 import com.dmdirc.addons.ui_web.uicomponents.WebInputWindow;
47 46
 import com.dmdirc.addons.ui_web.uicomponents.WebMainWindow;
48 47
 import com.dmdirc.addons.ui_web.uicomponents.WebQueryWindow;
@@ -82,9 +81,7 @@ public class WebInterfaceUI implements UIController {
82 81
      * 
83 82
      * @param plugin The plugin which owns this Web UI
84 83
      */
85
-    public WebInterfaceUI(final WebInterfacePlugin plugin) {
86
-        WindowManager.addFrameListener(new WebFrameManager());
87
-        
84
+    public WebInterfaceUI(final WebInterfacePlugin plugin) {       
88 85
         final SecurityHandler sh = new SecurityHandler();
89 86
         final Constraint constraint = new Constraint();
90 87
         final ConstraintMapping cm = new ConstraintMapping();

+ 0
- 96
src/com/dmdirc/addons/ui_web/uicomponents/WebFrameManager.java Voir le fichier

@@ -1,96 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2010 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.addons.ui_web.uicomponents;
24
-
25
-import com.dmdirc.FrameContainer;
26
-import com.dmdirc.ui.interfaces.FrameManager;
27
-import com.dmdirc.addons.ui_web.DynamicRequestHandler;
28
-import com.dmdirc.addons.ui_web.Event;
29
-import com.dmdirc.addons.ui_web.WebInterfaceUI;
30
-import com.dmdirc.ui.interfaces.UIController;
31
-import javax.swing.JComponent;
32
-
33
-/**
34
- *
35
- * @author chris
36
- */
37
-public class WebFrameManager implements FrameManager {
38
-
39
-    /** {@inheritDoc} */
40
-    @Override
41
-    public void setParent(final JComponent parent) {
42
-        //TODO FIXME
43
-        throw new UnsupportedOperationException("Not supported yet.");
44
-    }
45
-
46
-    /** {@inheritDoc} */
47
-    @Override
48
-    public boolean canPositionVertically() {
49
-        //TODO FIXME
50
-        throw new UnsupportedOperationException("Not supported yet.");
51
-    }
52
-
53
-    /** {@inheritDoc} */
54
-    @Override
55
-    public boolean canPositionHorizontally() {
56
-        //TODO FIXME
57
-        throw new UnsupportedOperationException("Not supported yet.");
58
-    }
59
-
60
-    /** {@inheritDoc} */
61
-    @Override
62
-    public void addWindow(final FrameContainer<?> window, final boolean focus) {
63
-        DynamicRequestHandler.addEvent(new Event("newwindow", window.getFrame()));
64
-        WebInterfaceUI.active = (WebWindow) window.getFrame();
65
-    }
66
-
67
-    /** {@inheritDoc} */
68
-    @Override
69
-    public void delWindow(final FrameContainer<?> window) {
70
-        //TODO FIXME
71
-        throw new UnsupportedOperationException("Not supported yet.");
72
-    }
73
-
74
-    /** {@inheritDoc} */
75
-    @Override
76
-    public void addWindow(final FrameContainer<?> parent,
77
-            final FrameContainer<?> window, final boolean focus) {
78
-        DynamicRequestHandler.addEvent(new Event("newchildwindow", new Object[]{
79
-            parent.getFrame(), window.getFrame()
80
-        }));
81
-        WebInterfaceUI.active = (WebWindow) window.getFrame();
82
-    }
83
-
84
-    /** {@inheritDoc} */
85
-    @Override
86
-    public void delWindow(final FrameContainer<?> parent, final FrameContainer<?> window) {
87
-        //TODO FIXME
88
-        throw new UnsupportedOperationException("Not supported yet.");
89
-    }
90
-
91
-    @Override
92
-    public void setController(UIController controller) {
93
-        //Ignore
94
-    }
95
-
96
-}

Chargement…
Annuler
Enregistrer