Explorar el Código

Remove input methods from WindowModel.

Migrate all users to using the InputModel.
pull/648/head
Chris Smith hace 8 años
padre
commit
217b5b1a22

+ 14
- 8
src/com/dmdirc/Channel.java Ver fichero

@@ -113,7 +113,8 @@ public class Channel extends FrameContainer implements GroupChat {
113 113
                 Styliser.stipControlCodes(newChannelInfo.getName()),
114 114
                 configMigrator.getConfigProvider(),
115 115
                 backBufferFactory,
116
-                tabCompleterFactory.getTabCompleter(connection.getWindowModel().getTabCompleter(),
116
+                tabCompleterFactory.getTabCompleter(
117
+                        connection.getWindowModel().getInputModel().get().getTabCompleter(),
117 118
                         configMigrator.getConfigProvider(), CommandType.TYPE_CHANNEL,
118 119
                         CommandType.TYPE_CHAT),
119 120
                 connection.getWindowModel().getEventBus(),
@@ -297,7 +298,8 @@ public class Channel extends FrameContainer implements GroupChat {
297 298
     public void addClient(final GroupChatUser client) {
298 299
         getEventBus().publishAsync(new NickListClientAddedEvent(this, client));
299 300
 
300
-        getTabCompleter().addEntry(TabCompletionType.CHANNEL_NICK, client.getNickname());
301
+        getInputModel().get().getTabCompleter().addEntry(
302
+                TabCompletionType.CHANNEL_NICK, client.getNickname());
301 303
     }
302 304
 
303 305
     /**
@@ -308,7 +310,8 @@ public class Channel extends FrameContainer implements GroupChat {
308 310
     public void removeClient(final GroupChatUser client) {
309 311
         getEventBus().publishAsync(new NickListClientRemovedEvent(this, client));
310 312
 
311
-        getTabCompleter().removeEntry(TabCompletionType.CHANNEL_NICK, client.getNickname());
313
+        getInputModel().get().getTabCompleter().removeEntry(
314
+                TabCompletionType.CHANNEL_NICK, client.getNickname());
312 315
 
313 316
         if (client.getUser().equals(connection.getLocalUser().orElse(null))) {
314 317
             resetWindow();
@@ -323,10 +326,11 @@ public class Channel extends FrameContainer implements GroupChat {
323 326
     public void setClients(final Collection<GroupChatUser> clients) {
324 327
         getEventBus().publishAsync(new NickListClientsChangedEvent(this, clients));
325 328
 
326
-        getTabCompleter().clear(TabCompletionType.CHANNEL_NICK);
329
+        getInputModel().get().getTabCompleter().clear(TabCompletionType.CHANNEL_NICK);
327 330
 
328
-        getTabCompleter().addEntries(TabCompletionType.CHANNEL_NICK,
329
-            clients.stream().map(GroupChatUser::getNickname).collect(Collectors.toList()));
331
+        getInputModel().get().getTabCompleter().addEntries(
332
+                TabCompletionType.CHANNEL_NICK,
333
+                clients.stream().map(GroupChatUser::getNickname).collect(Collectors.toList()));
330 334
     }
331 335
 
332 336
     /**
@@ -336,8 +340,10 @@ public class Channel extends FrameContainer implements GroupChat {
336 340
      * @param newName The new nickname of the client
337 341
      */
338 342
     public void renameClient(final String oldName, final String newName) {
339
-        getTabCompleter().removeEntry(TabCompletionType.CHANNEL_NICK, oldName);
340
-        getTabCompleter().addEntry(TabCompletionType.CHANNEL_NICK, newName);
343
+        getInputModel().get().getTabCompleter().removeEntry(
344
+                TabCompletionType.CHANNEL_NICK, oldName);
345
+        getInputModel().get().getTabCompleter().addEntry(
346
+                TabCompletionType.CHANNEL_NICK, newName);
341 347
         refreshClients();
342 348
     }
343 349
 

+ 1
- 6
src/com/dmdirc/FrameContainer.java Ver fichero

@@ -191,11 +191,6 @@ public abstract class FrameContainer implements WindowModel, InputModel {
191 191
         return eventBus;
192 192
     }
193 193
 
194
-    @Override
195
-    public boolean isWritable() {
196
-        return writable;
197
-    }
198
-
199 194
     /**
200 195
      * Changes the name of this container, and fires a {@link FrameNameChangedEvent}.
201 196
      *
@@ -350,7 +345,7 @@ public abstract class FrameContainer implements WindowModel, InputModel {
350 345
 
351 346
     @Override
352 347
     public Optional<InputModel> getInputModel() {
353
-        if (isWritable()) {
348
+        if (writable) {
354 349
             return Optional.of(this);
355 350
         } else {
356 351
             return Optional.empty();

+ 3
- 3
src/com/dmdirc/GroupChatManagerImpl.java Ver fichero

@@ -151,8 +151,8 @@ public class GroupChatManagerImpl implements GroupChatManager {
151 151
                     connection.getAddress(), chan.getName());
152 152
             final Channel newChan = channelFactory.getChannel(
153 153
                     connection, chan, channelConfig);
154
-            connection.getWindowModel().getTabCompleter().addEntry(TabCompletionType.CHANNEL,
155
-                    chan.getName());
154
+            connection.getWindowModel().getInputModel().get().getTabCompleter()
155
+                    .addEntry(TabCompletionType.CHANNEL, chan.getName());
156 156
             newChan.getWindowModel().getEventBus().subscribe(this);
157 157
             channels.add(newChan);
158 158
         }
@@ -195,7 +195,7 @@ public class GroupChatManagerImpl implements GroupChatManager {
195 195
     @Handler
196 196
     void handleChannelClosing(final ChannelClosedEvent event) {
197 197
         final GroupChat channel = event.getChannel();
198
-        connection.getWindowModel().getTabCompleter()
198
+        connection.getWindowModel().getInputModel().get().getTabCompleter()
199 199
                 .removeEntry(TabCompletionType.CHANNEL, channel.getName());
200 200
         channels.remove(channel.getName());
201 201
         channel.getEventBus().unsubscribe(this);

+ 3
- 2
src/com/dmdirc/Query.java Ver fichero

@@ -76,7 +76,8 @@ public class Query extends FrameContainer implements PrivateChat {
76 76
                 user.getNickname(),
77 77
                 connection.getWindowModel().getConfigManager(),
78 78
                 backBufferFactory,
79
-                tabCompleterFactory.getTabCompleter(connection.getWindowModel().getTabCompleter(),
79
+                tabCompleterFactory.getTabCompleter(
80
+                        connection.getWindowModel().getInputModel().get().getTabCompleter(),
80 81
                         connection.getWindowModel().getConfigManager(),
81 82
                         CommandType.TYPE_QUERY, CommandType.TYPE_CHAT),
82 83
                 connection.getWindowModel().getEventBus(),
@@ -125,7 +126,7 @@ public class Query extends FrameContainer implements PrivateChat {
125 126
             return;
126 127
         }
127 128
 
128
-        final int maxLineLength = getMaxLineLength();
129
+        final int maxLineLength = getInputModel().get().getMaxLineLength();
129 130
 
130 131
         if (maxLineLength >= action.length() + 2) {
131 132
             connection.getParser().get().sendAction(getNickname(), action);

+ 5
- 4
src/com/dmdirc/Server.java Ver fichero

@@ -488,7 +488,7 @@ public class Server extends FrameContainer implements Connection {
488 488
             if (!getState().isDisconnected()) {
489 489
                 newQuery.reregister();
490 490
             }
491
-            getTabCompleter().addEntry(TabCompletionType.QUERY_NICK, nick);
491
+            getInputModel().get().getTabCompleter().addEntry(TabCompletionType.QUERY_NICK, nick);
492 492
             queries.put(lnick, newQuery);
493 493
         }
494 494
 
@@ -497,8 +497,8 @@ public class Server extends FrameContainer implements Connection {
497 497
 
498 498
     @Override
499 499
     public void updateQuery(final Query query, final String oldNick, final String newNick) {
500
-        getTabCompleter().removeEntry(TabCompletionType.QUERY_NICK, oldNick);
501
-        getTabCompleter().addEntry(TabCompletionType.QUERY_NICK, newNick);
500
+        getInputModel().get().getTabCompleter().removeEntry(TabCompletionType.QUERY_NICK, oldNick);
501
+        getInputModel().get().getTabCompleter().addEntry(TabCompletionType.QUERY_NICK, newNick);
502 502
 
503 503
         queries.put(converter.toLowerCase(newNick), query);
504 504
         queries.remove(converter.toLowerCase(oldNick));
@@ -511,7 +511,8 @@ public class Server extends FrameContainer implements Connection {
511 511
 
512 512
     @Override
513 513
     public void delQuery(final Query query) {
514
-        getTabCompleter().removeEntry(TabCompletionType.QUERY_NICK, query.getNickname());
514
+        getInputModel().get().getTabCompleter().removeEntry(
515
+                TabCompletionType.QUERY_NICK, query.getNickname());
515 516
         queries.remove(converter.toLowerCase(query.getNickname()));
516 517
     }
517 518
 

+ 10
- 8
src/com/dmdirc/commandparser/CommandManager.java Ver fichero

@@ -167,9 +167,9 @@ public class CommandManager implements CommandController {
167 167
         final String silencedCommandName = getCommandChar() + getSilenceChar() + command.getName();
168 168
 
169 169
         if (command.getType() == CommandType.TYPE_GLOBAL) {
170
-            registerCommandName(globalWindowProvider.get().getTabCompleter(),
170
+            registerCommandName(globalWindowProvider.get().getInputModel().get().getTabCompleter(),
171 171
                     plainCommandName, register);
172
-            registerCommandName(globalWindowProvider.get().getTabCompleter(),
172
+            registerCommandName(globalWindowProvider.get().getInputModel().get().getTabCompleter(),
173 173
                     silencedCommandName, register);
174 174
         }
175 175
 
@@ -177,18 +177,20 @@ public class CommandManager implements CommandController {
177 177
         for (Connection server : connectionManager.getConnections()) {
178 178
             if (command.getType() == CommandType.TYPE_SERVER
179 179
                     || command.getType() == CommandType.TYPE_GLOBAL) {
180
-                registerCommandName(server.getWindowModel().getTabCompleter(),
180
+                registerCommandName(server.getWindowModel().getInputModel().get().getTabCompleter(),
181 181
                         plainCommandName, register);
182
-                registerCommandName(server.getWindowModel().getTabCompleter(),
182
+                registerCommandName(server.getWindowModel().getInputModel().get().getTabCompleter(),
183 183
                         silencedCommandName, register);
184 184
             }
185 185
 
186 186
             if (command.getType() == CommandType.TYPE_CHANNEL
187 187
                     || command.getType() == CommandType.TYPE_CHAT) {
188 188
                 for (GroupChat channel : server.getGroupChatManager().getChannels()) {
189
-                    registerCommandName(channel.getWindowModel().getTabCompleter(),
189
+                    registerCommandName(
190
+                            channel.getWindowModel().getInputModel().get().getTabCompleter(),
190 191
                             plainCommandName, register);
191
-                    registerCommandName(channel.getWindowModel().getTabCompleter(),
192
+                    registerCommandName(
193
+                            channel.getWindowModel().getInputModel().get().getTabCompleter(),
192 194
                             silencedCommandName, register);
193 195
                 }
194 196
             }
@@ -196,9 +198,9 @@ public class CommandManager implements CommandController {
196 198
             if (command.getType() == CommandType.TYPE_QUERY
197 199
                     || command.getType() == CommandType.TYPE_CHAT) {
198 200
                 for (Query query : server.getQueries()) {
199
-                    registerCommandName(query.getTabCompleter(),
201
+                    registerCommandName(query.getInputModel().get().getTabCompleter(),
200 202
                             plainCommandName, register);
201
-                    registerCommandName(query.getTabCompleter(),
203
+                    registerCommandName(query.getInputModel().get().getTabCompleter(),
202 204
                             silencedCommandName, register);
203 205
                 }
204 206
             }

+ 4
- 1
src/com/dmdirc/commandparser/aliases/AliasCommandHandler.java Ver fichero

@@ -26,6 +26,7 @@ import com.dmdirc.commandparser.CommandArguments;
26 26
 import com.dmdirc.commandparser.commands.Command;
27 27
 import com.dmdirc.commandparser.commands.context.CommandContext;
28 28
 import com.dmdirc.interfaces.CommandController;
29
+import com.dmdirc.interfaces.InputModel;
29 30
 import com.dmdirc.interfaces.WindowModel;
30 31
 
31 32
 import javax.annotation.Nonnull;
@@ -47,7 +48,9 @@ public class AliasCommandHandler extends Command {
47 48
             final CommandContext context) {
48 49
         if (args.getArguments().length >= alias.getMinArguments()) {
49 50
             for (String line : alias.getSubstitution().split("\n")) {
50
-                origin.getCommandParser().parseCommand(origin, getSubstituteCommand(line, args));
51
+                origin.getInputModel().map(InputModel::getCommandParser)
52
+                        .ifPresent(cp -> cp.parseCommand(origin,
53
+                                getSubstituteCommand(line, args)));
51 54
             }
52 55
         } else {
53 56
             showError(origin, args.isSilent(), alias.getName() + " requires at least "

+ 3
- 1
src/com/dmdirc/commandparser/auto/AutoCommandHandler.java Ver fichero

@@ -28,6 +28,7 @@ import com.dmdirc.commandparser.parsers.GlobalCommandParser;
28 28
 import com.dmdirc.events.ClientOpenedEvent;
29 29
 import com.dmdirc.events.ServerConnectedEvent;
30 30
 import com.dmdirc.interfaces.CommandController;
31
+import com.dmdirc.interfaces.InputModel;
31 32
 import com.dmdirc.interfaces.WindowModel;
32 33
 
33 34
 import java.util.Optional;
@@ -77,7 +78,8 @@ public class AutoCommandHandler {
77 78
         if (appliesToServer(event.getConnection().getNetwork(),
78 79
                 event.getConnection().getAddress(), event.getConnection().getProfile().getName())) {
79 80
             final WindowModel container = event.getConnection().getWindowModel();
80
-            final CommandParser parser = container.getCommandParser();
81
+            final CommandParser parser = container.getInputModel()
82
+                    .map(InputModel::getCommandParser).get();
81 83
             execute(container, parser);
82 84
         }
83 85
     }

+ 3
- 2
src/com/dmdirc/commandparser/commands/global/AllServers.java Ver fichero

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
32 32
 import com.dmdirc.interfaces.CommandController;
33 33
 import com.dmdirc.interfaces.Connection;
34 34
 import com.dmdirc.interfaces.ConnectionManager;
35
+import com.dmdirc.interfaces.InputModel;
35 36
 import com.dmdirc.interfaces.WindowModel;
36 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 38
 import com.dmdirc.ui.input.TabCompleterUtils;
@@ -74,8 +75,8 @@ public class AllServers extends Command implements IntelligentCommand {
74 75
         final String command = args.getArgumentsAsString();
75 76
 
76 77
         for (Connection target : connectionManager.getConnections()) {
77
-            target.getWindowModel().getCommandParser()
78
-                    .parseCommand(target.getWindowModel(), command);
78
+            target.getWindowModel().getInputModel().map(InputModel::getCommandParser)
79
+                    .ifPresent(cp -> cp.parseCommand(target.getWindowModel(), command));
79 80
         }
80 81
     }
81 82
 

+ 2
- 2
src/com/dmdirc/commandparser/commands/global/Help.java Ver fichero

@@ -82,8 +82,8 @@ public class Help extends Command implements IntelligentCommand {
82 82
      * @param isSilent Whether this command has been silenced or not
83 83
      */
84 84
     private void showAllCommands(final WindowModel origin, final boolean isSilent) {
85
-        final List<String> commands = new ArrayList<>(origin.getCommandParser()
86
-                .getCommands().keySet());
85
+        final List<String> commands = new ArrayList<>(origin.getInputModel().get()
86
+                .getCommandParser().getCommands().keySet());
87 87
 
88 88
         Collections.sort(commands);
89 89
 

+ 8
- 2
src/com/dmdirc/commandparser/commands/global/Ifplugin.java Ver fichero

@@ -30,14 +30,18 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33
+import com.dmdirc.commandparser.parsers.CommandParser;
33 34
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
34 35
 import com.dmdirc.interfaces.CommandController;
36
+import com.dmdirc.interfaces.InputModel;
35 37
 import com.dmdirc.interfaces.WindowModel;
36 38
 import com.dmdirc.plugins.PluginInfo;
37 39
 import com.dmdirc.plugins.PluginManager;
38 40
 import com.dmdirc.ui.input.AdditionalTabTargets;
39 41
 import com.dmdirc.ui.input.TabCompleterUtils;
40 42
 
43
+import java.util.Optional;
44
+
41 45
 import javax.annotation.Nonnull;
42 46
 import javax.inject.Inject;
43 47
 import javax.inject.Provider;
@@ -105,8 +109,10 @@ public class Ifplugin extends Command implements IntelligentCommand {
105 109
         }
106 110
 
107 111
         if (result != negative) {
108
-            if (origin.isWritable()) {
109
-                origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(1));
112
+            final Optional<CommandParser> parser = origin.getInputModel()
113
+                    .map(InputModel::getCommandParser);
114
+            if (parser.isPresent()) {
115
+                parser.get().parseCommand(origin, args.getArgumentsAsString(1));
110 116
             } else {
111 117
                 globalCommandParserProvider.get()
112 118
                         .parseCommand(globalWindowProvider.get(), args.getArgumentsAsString(1));

+ 3
- 2
src/com/dmdirc/commandparser/commands/server/AllChannels.java Ver fichero

@@ -33,6 +33,7 @@ import com.dmdirc.commandparser.commands.context.ServerCommandContext;
33 33
 import com.dmdirc.interfaces.CommandController;
34 34
 import com.dmdirc.interfaces.Connection;
35 35
 import com.dmdirc.interfaces.GroupChat;
36
+import com.dmdirc.interfaces.InputModel;
36 37
 import com.dmdirc.interfaces.WindowModel;
37 38
 import com.dmdirc.ui.input.AdditionalTabTargets;
38 39
 import com.dmdirc.ui.input.TabCompleterUtils;
@@ -71,8 +72,8 @@ public class AllChannels extends Command implements IntelligentCommand {
71 72
         final String command = args.getArgumentsAsString();
72 73
 
73 74
         for (GroupChat channel : server.getGroupChatManager().getChannels()) {
74
-            channel.getWindowModel().getCommandParser().parseCommand(channel.getWindowModel(),
75
-                    command);
75
+            channel.getWindowModel().getInputModel().map(InputModel::getCommandParser)
76
+                    .ifPresent(cp -> cp.parseCommand(channel.getWindowModel(), command));
76 77
         }
77 78
     }
78 79
 

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/Message.java Ver fichero

@@ -123,7 +123,7 @@ public class Message extends Command implements IntelligentCommand,
123 123
     public int getLineCount(final WindowModel origin, final CommandArguments arguments) {
124 124
         if (arguments.getArguments().length >= 2) {
125 125
             final String target = arguments.getArguments()[0];
126
-            return origin.getConnection().get().getWindowModel().getNumLines(
126
+            return origin.getConnection().get().getWindowModel().getInputModel().get().getNumLines(
127 127
                     "PRIVMSG " + target + " :" + arguments.getArgumentsAsString(1));
128 128
         } else {
129 129
             return 1;

+ 2
- 2
src/com/dmdirc/commandparser/commands/server/OpenQuery.java Ver fichero

@@ -111,8 +111,8 @@ public class OpenQuery extends Command implements IntelligentCommand,
111 111
     public int getLineCount(final WindowModel origin, final CommandArguments arguments) {
112 112
         if (arguments.getArguments().length >= 2) {
113 113
             final String target = arguments.getArguments()[0];
114
-            return origin.getConnection().get().getWindowModel().getNumLines("PRIVMSG "
115
-                    + target + " :" + arguments.getArgumentsAsString(1));
114
+            return origin.getConnection().get().getWindowModel().getInputModel().get()
115
+                    .getNumLines("PRIVMSG " + target + " :" + arguments.getArgumentsAsString(1));
116 116
         } else {
117 117
             return 1;
118 118
         }

+ 3
- 2
src/com/dmdirc/commandparser/parsers/CommandParser.java Ver fichero

@@ -37,6 +37,7 @@ import com.dmdirc.events.UnknownCommandEvent;
37 37
 import com.dmdirc.interfaces.CommandController;
38 38
 import com.dmdirc.interfaces.Connection;
39 39
 import com.dmdirc.interfaces.GroupChat;
40
+import com.dmdirc.interfaces.InputModel;
40 41
 import com.dmdirc.interfaces.WindowModel;
41 42
 import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
42 43
 import com.dmdirc.util.collections.RollingList;
@@ -204,8 +205,8 @@ public abstract class CommandParser implements Serializable {
204 205
                 final Optional<GroupChat> channel = server.getGroupChatManager()
205 206
                         .getChannel(channelName);
206 207
                 if (channel.isPresent()) {
207
-                    channel.get().getWindowModel().getCommandParser()
208
-                            .parseCommand(origin, newCommandString, false);
208
+                    channel.get().getWindowModel().getInputModel().map(InputModel::getCommandParser)
209
+                            .ifPresent(cp -> cp.parseCommand(origin, newCommandString, false));
209 210
                 } else {
210 211
                     final Map.Entry<CommandInfo, Command> actCommand = commandManager.getCommand(
211 212
                             CommandType.TYPE_CHANNEL, command);

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

@@ -23,11 +23,9 @@
23 23
 package com.dmdirc.interfaces;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.commandparser.parsers.CommandParser;
27 26
 import com.dmdirc.events.FrameIconChangedEvent;
28 27
 import com.dmdirc.events.FrameTitleChangedEvent;
29 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
-import com.dmdirc.ui.input.TabCompleter;
31 29
 import com.dmdirc.ui.messages.BackBuffer;
32 30
 import com.dmdirc.ui.messages.UnreadStatusManager;
33 31
 
@@ -49,8 +47,6 @@ public interface WindowModel {
49 47
 
50 48
     DMDircMBassador getEventBus();
51 49
 
52
-    boolean isWritable();
53
-
54 50
     /**
55 51
      * Changes the title of this container, and fires a {@link FrameTitleChangedEvent}.
56 52
      *
@@ -109,44 +105,6 @@ public interface WindowModel {
109 105
      */
110 106
     BackBuffer getBackBuffer();
111 107
 
112
-    /**
113
-     * Sends a line of text to this container's source.
114
-     *
115
-     * @param line The line to be sent
116
-     */
117
-    void sendLine(String line);
118
-
119
-    /**
120
-     * Retrieves the command parser to be used for this container.
121
-     *
122
-     * @return This container's command parser
123
-     */
124
-    CommandParser getCommandParser();
125
-
126
-    /**
127
-     * Retrieves the tab completer which should be used for this container.
128
-     *
129
-     * @return This container's tab completer
130
-     */
131
-    TabCompleter getTabCompleter();
132
-
133
-    /**
134
-     * Returns the maximum length that a line passed to sendLine() should be, in order to prevent it
135
-     * being truncated or causing protocol violations.
136
-     *
137
-     * @return The maximum line length for this container
138
-     */
139
-    int getMaxLineLength();
140
-
141
-    /**
142
-     * Returns the number of lines that the specified string would be sent as.
143
-     *
144
-     * @param line The string to be split and sent
145
-     *
146
-     * @return The number of lines required to send the specified string
147
-     */
148
-    int getNumLines(String line);
149
-
150 108
     /**
151 109
      * Returns the model used to define input parameters for this window.
152 110
      *

+ 1
- 1
src/com/dmdirc/ui/input/InputHandler.java Ver fichero

@@ -298,7 +298,7 @@ public abstract class InputHandler implements ConfigChangeListener {
298 298
                 fireLineWrap(count);
299 299
             }
300 300
         } else {
301
-            final int lines = parentWindow.getNumLines(text);
301
+            final int lines = parentWindow.getInputModel().get().getNumLines(text);
302 302
             fireLineWrap(lines);
303 303
         }
304 304
     }

+ 6
- 1
test/com/dmdirc/commandparser/aliases/AliasCommandHandlerTest.java Ver fichero

@@ -30,8 +30,11 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
30 30
 import com.dmdirc.commandparser.parsers.CommandParser;
31 31
 import com.dmdirc.events.CommandErrorEvent;
32 32
 import com.dmdirc.interfaces.CommandController;
33
+import com.dmdirc.interfaces.InputModel;
33 34
 import com.dmdirc.interfaces.WindowModel;
34 35
 
36
+import java.util.Optional;
37
+
35 38
 import org.junit.Before;
36 39
 import org.junit.Test;
37 40
 import org.junit.runner.RunWith;
@@ -48,6 +51,7 @@ import static org.mockito.Mockito.when;
48 51
 public class AliasCommandHandlerTest {
49 52
 
50 53
     @Mock private WindowModel container;
54
+    @Mock private InputModel inputModel;
51 55
     @Mock private CommandController commandController;
52 56
     @Mock private CommandParser commandParser;
53 57
     @Mock private CommandContext context;
@@ -57,7 +61,8 @@ public class AliasCommandHandlerTest {
57 61
 
58 62
     @Before
59 63
     public void setup() {
60
-        when(container.getCommandParser()).thenReturn(commandParser);
64
+        when(container.getInputModel()).thenReturn(Optional.of(inputModel));
65
+        when(inputModel.getCommandParser()).thenReturn(commandParser);
61 66
         when(commandController.getCommandChar()).thenReturn('#');
62 67
         when(commandController.getSilenceChar()).thenReturn('/');
63 68
         when(context.getSource()).thenReturn(container);

+ 12
- 9
test/com/dmdirc/commandparser/auto/AutoCommandHandlerTest.java Ver fichero

@@ -30,6 +30,7 @@ import com.dmdirc.events.ClientOpenedEvent;
30 30
 import com.dmdirc.events.ServerConnectedEvent;
31 31
 import com.dmdirc.interfaces.CommandController;
32 32
 import com.dmdirc.interfaces.Connection;
33
+import com.dmdirc.interfaces.InputModel;
33 34
 import com.dmdirc.interfaces.WindowModel;
34 35
 
35 36
 import java.util.Optional;
@@ -57,12 +58,13 @@ public class AutoCommandHandlerTest {
57 58
     @Mock private Connection connection;
58 59
     @Mock private Profile profile;
59 60
     @Mock private WindowModel container;
61
+    @Mock private InputModel inputModel;
60 62
     @Mock private CommandParser commandParser;
61 63
     private AutoCommandHandler autoCommandHandler;
62 64
 
63 65
     @Before
64 66
     public void setup() {
65
-        when(autoCommand.getProfile()).thenReturn(Optional.ofNullable("profile"));
67
+        when(autoCommand.getProfile()).thenReturn(Optional.of("profile"));
66 68
         when(autoCommand.getResponse()).thenReturn("Testing123");
67 69
         when(autoCommand.getServer()).thenReturn(Optional.<String>empty());
68 70
         when(autoCommand.getNetwork()).thenReturn(Optional.<String>empty());
@@ -72,7 +74,8 @@ public class AutoCommandHandlerTest {
72 74
         when(connection.getAddress()).thenReturn("irc.quakenet.org");
73 75
         when(connection.getNetwork()).thenReturn("Quakenet");
74 76
         when(profile.getName()).thenReturn("profile");
75
-        when(container.getCommandParser()).thenReturn(commandParser);
77
+        when(container.getInputModel()).thenReturn(Optional.of(inputModel));
78
+        when(inputModel.getCommandParser()).thenReturn(commandParser);
76 79
         autoCommandHandler = new AutoCommandHandler(commandController, globalCommandParser,
77 80
                 globalWindow, autoCommand);
78 81
     }
@@ -86,7 +89,7 @@ public class AutoCommandHandlerTest {
86 89
 
87 90
     @Test
88 91
     public void testCheckAutoCommandWithoutGlobal() {
89
-        when(autoCommand.getNetwork()).thenReturn(Optional.ofNullable("Quakenet"));
92
+        when(autoCommand.getNetwork()).thenReturn(Optional.of("Quakenet"));
90 93
         autoCommandHandler.checkAutoCommand(clientOpenedEvent);
91 94
         verify(globalCommandParser, never()).parseCommand(globalWindow,
92 95
                 commandController.getCommandChar() + autoCommand.getResponse());
@@ -103,8 +106,8 @@ public class AutoCommandHandlerTest {
103 106
 
104 107
     @Test
105 108
     public void testCheckAutoCommandNoProfile() {
106
-        when(autoCommand.getNetwork()).thenReturn(Optional.ofNullable("Quakenet"));
107
-        when(autoCommand.getProfile()).thenReturn(Optional.ofNullable("profile1"));
109
+        when(autoCommand.getNetwork()).thenReturn(Optional.of("Quakenet"));
110
+        when(autoCommand.getProfile()).thenReturn(Optional.of("profile1"));
108 111
         autoCommandHandler.checkAutoCommand(serverConnectedEvent);
109 112
         verify(globalCommandParser, never()).parseCommand(globalWindow,
110 113
                 commandController.getCommandChar() + autoCommand.getResponse());
@@ -114,7 +117,7 @@ public class AutoCommandHandlerTest {
114 117
 
115 118
     @Test
116 119
     public void testCheckAutoCommandWithProfile() {
117
-        when(autoCommand.getNetwork()).thenReturn(Optional.ofNullable("Quakenet"));
120
+        when(autoCommand.getNetwork()).thenReturn(Optional.of("Quakenet"));
118 121
         autoCommandHandler.checkAutoCommand(serverConnectedEvent);
119 122
         verify(globalCommandParser, never()).parseCommand(globalWindow,
120 123
                 commandController.getCommandChar() + autoCommand.getResponse());
@@ -124,7 +127,7 @@ public class AutoCommandHandlerTest {
124 127
 
125 128
     @Test
126 129
     public void testCheckAutoCommandWithProfileNoServer() {
127
-        when(autoCommand.getServer()).thenReturn(Optional.ofNullable("server"));
130
+        when(autoCommand.getServer()).thenReturn(Optional.of("server"));
128 131
         autoCommandHandler.checkAutoCommand(serverConnectedEvent);
129 132
         verify(globalCommandParser, never()).parseCommand(globalWindow,
130 133
                 commandController.getCommandChar() + autoCommand.getResponse());
@@ -134,7 +137,7 @@ public class AutoCommandHandlerTest {
134 137
 
135 138
     @Test
136 139
     public void testCheckAutoCommandWithProfileNoServerOrNetwork() {
137
-        when(autoCommand.getNetwork()).thenReturn(Optional.ofNullable("network"));
140
+        when(autoCommand.getNetwork()).thenReturn(Optional.of("network"));
138 141
         autoCommandHandler.checkAutoCommand(serverConnectedEvent);
139 142
         verify(globalCommandParser, never()).parseCommand(globalWindow,
140 143
                 commandController.getCommandChar() + autoCommand.getResponse());
@@ -144,7 +147,7 @@ public class AutoCommandHandlerTest {
144 147
 
145 148
     @Test
146 149
     public void testCheckAutoCommandWithProfileWithServer() {
147
-        when(autoCommand.getNetwork()).thenReturn(Optional.ofNullable("Quakenet"));
150
+        when(autoCommand.getNetwork()).thenReturn(Optional.of("Quakenet"));
148 151
         autoCommandHandler.checkAutoCommand(serverConnectedEvent);
149 152
         verify(globalCommandParser, never()).parseCommand(globalWindow,
150 153
                 commandController.getCommandChar() + autoCommand.getResponse());

+ 4
- 1
test/com/dmdirc/commandparser/parsers/CommandParserTest.java Ver fichero

@@ -30,6 +30,7 @@ import com.dmdirc.harness.TestCommandParser;
30 30
 import com.dmdirc.interfaces.CommandController;
31 31
 import com.dmdirc.interfaces.Connection;
32 32
 import com.dmdirc.interfaces.GroupChatManager;
33
+import com.dmdirc.interfaces.InputModel;
33 34
 import com.dmdirc.interfaces.WindowModel;
34 35
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
35 36
 
@@ -58,6 +59,7 @@ public class CommandParserTest {
58 59
     @Mock private Command command;
59 60
     @Mock private Command channelCommand;
60 61
     @Mock private WindowModel container;
62
+    @Mock private InputModel inputModel;
61 63
     @Mock private Channel channel;
62 64
     @Mock private Connection connection;
63 65
     @Mock private GroupChatManager groupChatManager;
@@ -90,7 +92,8 @@ public class CommandParserTest {
90 92
         channelCommandParser.registerCommand(channelCommand, channelCommandInfo);
91 93
 
92 94
         when(channel.getWindowModel()).thenReturn(channel);
93
-        when(channel.getCommandParser()).thenReturn(channelCommandParser);
95
+        when(channel.getInputModel()).thenReturn(Optional.of(inputModel));
96
+        when(inputModel.getCommandParser()).thenReturn(channelCommandParser);
94 97
     }
95 98
 
96 99
     @Test

Loading…
Cancelar
Guardar