Browse Source

Merge pull request #645 from csmith/master

Remove usages of FrameContainer window methods.
pull/646/head
Greg Holmes 8 years ago
parent
commit
c40549b94b

+ 5
- 1
src/com/dmdirc/CustomWindow.java View File

@@ -36,6 +36,8 @@ import java.util.Optional;
36 36
  */
37 37
 public class CustomWindow extends FrameContainer {
38 38
 
39
+    private final Optional<Connection> connection;
40
+
39 41
     /**
40 42
      * Creates a new custom window as a child of the specified window.
41 43
      */
@@ -47,6 +49,7 @@ public class CustomWindow extends FrameContainer {
47 49
         super(parent, "custom", name, title, parent.getConfigManager(), backBufferFactory,
48 50
                 parent.getEventBus(),
49 51
                 Collections.singletonList(WindowComponent.TEXTAREA.getIdentifier()));
52
+        connection = parent.getConnection();
50 53
         initBackBuffer();
51 54
     }
52 55
 
@@ -61,12 +64,13 @@ public class CustomWindow extends FrameContainer {
61 64
             final BackBufferFactory backBufferFactory) {
62 65
         super(null, "custom", name, title, configProvider, backBufferFactory,
63 66
                 eventBus, Collections.singletonList(WindowComponent.TEXTAREA.getIdentifier()));
67
+        connection = Optional.empty();
64 68
         initBackBuffer();
65 69
     }
66 70
 
67 71
     @Override
68 72
     public Optional<Connection> getConnection() {
69
-        return getParent().flatMap(WindowModel::getConnection);
73
+        return connection;
70 74
     }
71 75
 
72 76
 }

+ 3
- 3
src/com/dmdirc/commandparser/commands/global/Echo.java View File

@@ -109,7 +109,7 @@ public class Echo extends Command implements IntelligentCommand {
109 109
             while (frame == null && target.isPresent()) {
110 110
                 frame = windowManager.findCustomWindow(target.get(),
111 111
                         results.getArgumentsAsString(targetFlag));
112
-                target = target.flatMap(WindowModel::getParent);
112
+                target = target.flatMap(windowManager::getParent);
113 113
             }
114 114
 
115 115
             if (frame == null) {
@@ -144,12 +144,12 @@ public class Echo extends Command implements IntelligentCommand {
144 144
             final Optional<Connection> connection = context.getWindow().getConnection();
145 145
 
146 146
             //Active window's Children
147
-            windowList.addAll(context.getWindow().getChildren());
147
+            windowList.addAll(windowManager.getChildren(context.getWindow()));
148 148
 
149 149
             //Children of Current Window's server
150 150
             connection
151 151
                     .map(Connection::getWindowModel)
152
-                    .map(WindowModel::getChildren)
152
+                    .map(windowManager::getChildren)
153 153
                     .ifPresent(windowList::addAll);
154 154
 
155 155
             //Global Windows

+ 6
- 2
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java View File

@@ -36,6 +36,7 @@ import com.dmdirc.interfaces.CommandController;
36 36
 import com.dmdirc.interfaces.Connection;
37 37
 import com.dmdirc.interfaces.WindowModel;
38 38
 import com.dmdirc.parser.common.ChannelJoinRequest;
39
+import com.dmdirc.ui.WindowManager;
39 40
 import com.dmdirc.ui.input.AdditionalTabTargets;
40 41
 import com.dmdirc.ui.messages.Styliser;
41 42
 
@@ -69,6 +70,7 @@ public class JoinChannelCommand extends Command implements IntelligentCommand {
69 70
     private final Multimap<WindowModel, String> mentions = ArrayListMultimap.create();
70 71
     /** Lock to synchronise on when accessing mentions. */
71 72
     private final Object mentionsLock = new Object();
73
+    private final WindowManager windowManager;
72 74
 
73 75
     /**
74 76
      * Creates a new instance of the join channel command.
@@ -79,8 +81,10 @@ public class JoinChannelCommand extends Command implements IntelligentCommand {
79 81
     @Inject
80 82
     public JoinChannelCommand(
81 83
             final CommandController controller,
84
+            final WindowManager windowManager,
82 85
             final DMDircMBassador eventBus) {
83 86
         super(controller);
87
+        this.windowManager = windowManager;
84 88
         eventBus.subscribe(this);
85 89
     }
86 90
 
@@ -185,14 +189,14 @@ public class JoinChannelCommand extends Command implements IntelligentCommand {
185 189
         }
186 190
 
187 191
         // Check the parent window
188
-        final Optional<WindowModel> parent = source.getParent();
192
+        final Optional<WindowModel> parent = windowManager.getParent(source);
189 193
         if (checkParents && parent.isPresent()) {
190 194
             results.addAll(checkSource(parent.get(), true, false));
191 195
         }
192 196
 
193 197
         // Check the children window
194 198
         if (checkChildren) {
195
-            for (WindowModel child : source.getChildren()) {
199
+            for (WindowModel child : windowManager.getChildren(source)) {
196 200
                 results.addAll(checkSource(child, false, true));
197 201
             }
198 202
         }

Loading…
Cancel
Save