Explorar el Código

Remove FrameContainer parent/child fields.

pull/646/head
Chris Smith hace 8 años
padre
commit
874b2afd2d

+ 1
- 1
src/com/dmdirc/Channel.java Ver fichero

@@ -108,7 +108,7 @@ public class Channel extends FrameContainer implements GroupChat {
108 108
             final TabCompleterFactory tabCompleterFactory,
109 109
             final BackBufferFactory backBufferFactory,
110 110
             final GroupChatUserManager groupChatUserManager) {
111
-        super(connection.getWindowModel(), "channel-inactive",
111
+        super("channel-inactive",
112 112
                 newChannelInfo.getName(),
113 113
                 Styliser.stipControlCodes(newChannelInfo.getName()),
114 114
                 configMigrator.getConfigProvider(),

+ 2
- 2
src/com/dmdirc/CustomWindow.java Ver fichero

@@ -46,7 +46,7 @@ public class CustomWindow extends FrameContainer {
46 46
             final String title,
47 47
             final WindowModel parent,
48 48
             final BackBufferFactory backBufferFactory) {
49
-        super(parent, "custom", name, title, parent.getConfigManager(), backBufferFactory,
49
+        super("custom", name, title, parent.getConfigManager(), backBufferFactory,
50 50
                 parent.getEventBus(),
51 51
                 Collections.singletonList(WindowComponent.TEXTAREA.getIdentifier()));
52 52
         connection = parent.getConnection();
@@ -62,7 +62,7 @@ public class CustomWindow extends FrameContainer {
62 62
             final AggregateConfigProvider configProvider,
63 63
             final DMDircMBassador eventBus,
64 64
             final BackBufferFactory backBufferFactory) {
65
-        super(null, "custom", name, title, configProvider, backBufferFactory,
65
+        super("custom", name, title, configProvider, backBufferFactory,
66 66
                 eventBus, Collections.singletonList(WindowComponent.TEXTAREA.getIdentifier()));
67 67
         connection = Optional.empty();
68 68
         initBackBuffer();

+ 0
- 31
src/com/dmdirc/FrameContainer.java Ver fichero

@@ -47,9 +47,6 @@ import java.util.HashSet;
47 47
 import java.util.List;
48 48
 import java.util.Optional;
49 49
 import java.util.Set;
50
-import java.util.concurrent.CopyOnWriteArrayList;
51
-
52
-import javax.annotation.Nullable;
53 50
 
54 51
 import static com.google.common.base.Preconditions.checkState;
55 52
 
@@ -61,10 +58,6 @@ public abstract class FrameContainer implements WindowModel {
61 58
 
62 59
     /** Listeners not yet using ListenerSupport. */
63 60
     protected final ListenerList listeners = new ListenerList();
64
-    /** The children of this frame. */
65
-    private final Collection<WindowModel> children = new CopyOnWriteArrayList<>();
66
-    /** The parent of this frame. */
67
-    private final Optional<WindowModel> parent;
68 61
     /** The name of the icon being used for this container's frame. */
69 62
     private String icon;
70 63
     /** The name of this container. */
@@ -108,7 +101,6 @@ public abstract class FrameContainer implements WindowModel {
108 101
      * Instantiate new frame container.
109 102
      */
110 103
     protected FrameContainer(
111
-            @Nullable final WindowModel parent,
112 104
             final String icon,
113 105
             final String name,
114 106
             final String title,
@@ -116,7 +108,6 @@ public abstract class FrameContainer implements WindowModel {
116 108
             final BackBufferFactory backBufferFactory,
117 109
             final DMDircMBassador eventBus,
118 110
             final Collection<String> components) {
119
-        this.parent = Optional.ofNullable(parent);
120 111
         this.configManager = config;
121 112
         this.name = name;
122 113
         this.title = title;
@@ -139,7 +130,6 @@ public abstract class FrameContainer implements WindowModel {
139 130
      * Instantiate new frame container that accepts user input.
140 131
      */
141 132
     protected FrameContainer(
142
-            @Nullable final WindowModel parent,
143 133
             final String icon,
144 134
             final String name,
145 135
             final String title,
@@ -148,7 +138,6 @@ public abstract class FrameContainer implements WindowModel {
148 138
             final TabCompleter tabCompleter,
149 139
             final DMDircMBassador eventBus,
150 140
             final Collection<String> components) {
151
-        this.parent = Optional.ofNullable(parent);
152 141
         this.configManager = config;
153 142
         this.name = name;
154 143
         this.title = title;
@@ -176,11 +165,6 @@ public abstract class FrameContainer implements WindowModel {
176 165
         this.commandParser = Optional.ofNullable(commandParser);
177 166
     }
178 167
 
179
-    @Override
180
-    public Optional<WindowModel> getParent() {
181
-        return parent;
182
-    }
183
-
184 168
     @Override
185 169
     public String getIcon() {
186 170
         return icon;
@@ -211,21 +195,6 @@ public abstract class FrameContainer implements WindowModel {
211 195
         return writable;
212 196
     }
213 197
 
214
-    @Override
215
-    public Collection<WindowModel> getChildren() {
216
-        return Collections.unmodifiableCollection(children);
217
-    }
218
-
219
-    @Override
220
-    public void addChild(final WindowModel child) {
221
-        children.add(child);
222
-    }
223
-
224
-    @Override
225
-    public void removeChild(final WindowModel child) {
226
-        children.remove(child);
227
-    }
228
-
229 198
     /**
230 199
      * Changes the name of this container, and fires a {@link FrameNameChangedEvent}.
231 200
      *

+ 1
- 1
src/com/dmdirc/GlobalWindow.java Ver fichero

@@ -54,7 +54,7 @@ public class GlobalWindow extends FrameContainer {
54 54
     public GlobalWindow(@GlobalConfig final AggregateConfigProvider config,
55 55
             final GlobalCommandParser parser, final TabCompleterFactory tabCompleterFactory,
56 56
             final DMDircMBassador eventBus, final BackBufferFactory backBufferFactory) {
57
-        super(null, "icon", "Global", "(Global)", config, backBufferFactory,
57
+        super("icon", "Global", "(Global)", config, backBufferFactory,
58 58
                 tabCompleterFactory.getTabCompleter(config, CommandType.TYPE_GLOBAL), eventBus,
59 59
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
60 60
                         WindowComponent.INPUTFIELD.getIdentifier()));

+ 1
- 1
src/com/dmdirc/Query.java Ver fichero

@@ -71,7 +71,7 @@ public class Query extends FrameContainer implements PrivateChat {
71 71
             final User user,
72 72
             final TabCompleterFactory tabCompleterFactory,
73 73
             final BackBufferFactory backBufferFactory) {
74
-        super(connection.getWindowModel(), "query",
74
+        super("query",
75 75
                 user.getNickname(),
76 76
                 user.getNickname(),
77 77
                 connection.getWindowModel().getConfigManager(),

+ 1
- 1
src/com/dmdirc/Server.java Ver fichero

@@ -186,7 +186,7 @@ public class Server extends FrameContainer implements Connection {
186 186
             @Nonnull final Profile profile,
187 187
             final BackBufferFactory backBufferFactory,
188 188
             final UserManager userManager) {
189
-        super(null, "server-disconnected",
189
+        super("server-disconnected",
190 190
                 getHost(uri),
191 191
                 getHost(uri),
192 192
                 configMigrator.getConfigProvider(),

+ 0
- 29
src/com/dmdirc/interfaces/WindowModel.java Ver fichero

@@ -41,8 +41,6 @@ import java.util.Set;
41 41
  */
42 42
 public interface WindowModel {
43 43
 
44
-    Optional<WindowModel> getParent();
45
-
46 44
     String getIcon();
47 45
 
48 46
     String getName();
@@ -55,33 +53,6 @@ public interface WindowModel {
55 53
 
56 54
     boolean isWritable();
57 55
 
58
-    /**
59
-     * Returns a collection of direct children of this frame.
60
-     *
61
-     * @return This frame's children
62
-     *
63
-     * @since 0.6.4
64
-     */
65
-    Collection<WindowModel> getChildren();
66
-
67
-    /**
68
-     * Adds a new child window to this frame.
69
-     *
70
-     * @param child The window to be added
71
-     *
72
-     * @since 0.6.4
73
-     */
74
-    void addChild(WindowModel child);
75
-
76
-    /**
77
-     * Removes a child window from this frame.
78
-     *
79
-     * @param child The window to be removed
80
-     *
81
-     * @since 0.6.4
82
-     */
83
-    void removeChild(WindowModel child);
84
-
85 56
     /**
86 57
      * Changes the title of this container, and fires a {@link FrameTitleChangedEvent}.
87 58
      *

+ 0
- 2
src/com/dmdirc/ui/WindowManager.java Ver fichero

@@ -218,7 +218,6 @@ public class WindowManager {
218 218
         checkArgument(isInHierarchy(parent));
219 219
         checkNotNull(child);
220 220
 
221
-        parent.addChild(child);
222 221
         parents.put(child, parent);
223 222
         children.put(parent, child);
224 223
 
@@ -264,7 +263,6 @@ public class WindowManager {
264 263
         } else {
265 264
             final WindowModel parent = parents.get(window);
266 265
             fireDeleteWindow(parent, window);
267
-            parent.removeChild(window);
268 266
             parents.remove(parent);
269 267
         }
270 268
     }

+ 1
- 1
test/com/dmdirc/harness/TestWritableFrameContainer.java Ver fichero

@@ -42,7 +42,7 @@ public class TestWritableFrameContainer extends FrameContainer {
42 42
             final AggregateConfigProvider cm, final CommandManager commandManager,
43 43
             final DMDircMBassador eventBus,
44 44
             final BackBufferFactory backBufferFactory) {
45
-        super(null, "raw", "Raw", "(Raw)", cm, backBufferFactory,
45
+        super("raw", "Raw", "(Raw)", cm, backBufferFactory,
46 46
                 new TabCompleter(cm),
47 47
                 eventBus,
48 48
                 Collections.<String>emptySet());

+ 0
- 2
test/com/dmdirc/ui/WindowManagerTest.java Ver fichero

@@ -194,7 +194,6 @@ public class WindowManagerTest {
194 194
         manager.removeWindow(child);
195 195
 
196 196
         verify(frameListener).delWindow(container, child);
197
-        verify(container).removeChild(child);
198 197
     }
199 198
 
200 199
     @Test
@@ -207,7 +206,6 @@ public class WindowManagerTest {
207 206
 
208 207
         verify(frameListener).delWindow(container, child);
209 208
         verify(grandchild).close();
210
-        verify(container).removeChild(child);
211 209
     }
212 210
 
213 211
     @Test

Loading…
Cancelar
Guardar