Преглед на файлове

Merge pull request #443 from csmith/core-updates

Plugin support for core changes.
pull/444/head
Greg Holmes преди 8 години
родител
ревизия
d6f0f4e0fc

+ 0
- 3
activewindow/build.gradle Целия файл

@@ -1,3 +0,0 @@
1
-dependencies {
2
-  compile plugin('ui_swing')
3
-}

+ 0
- 32
activewindow/plugin.config Целия файл

@@ -1,32 +0,0 @@
1
-# This is a DMDirc configuration file.
2
-
3
-# This section indicates which sections below take key/value
4
-# pairs, rather than a simple list. It should be placed above
5
-# any sections that take key/values.
6
-keysections:
7
-  metadata
8
-  updates
9
-  version
10
-  requires
11
-
12
-metadata:
13
-  author=Greboid <greg@dmdirc.com>
14
-  mainclass=com.dmdirc.addons.activewindow.ActiveWindowPlugin
15
-  description=Provides an active window command to the swing UI
16
-  name=activewindow
17
-  nicename=Active Window
18
-
19
-updates:
20
-  id=66
21
-
22
-requires:
23
-  parent=ui_swing
24
-
25
-version:
26
-  friendly=1.0
27
-
28
-provides:
29
-  active command
30
-
31
-required-services:
32
-  swing ui

+ 0
- 85
activewindow/src/com/dmdirc/addons/activewindow/ActiveCommand.java Целия файл

@@ -1,85 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
26
-import com.dmdirc.commandparser.BaseCommandInfo;
27
-import com.dmdirc.commandparser.CommandArguments;
28
-import com.dmdirc.commandparser.CommandInfo;
29
-import com.dmdirc.commandparser.CommandType;
30
-import com.dmdirc.commandparser.commands.Command;
31
-import com.dmdirc.commandparser.commands.IntelligentCommand;
32
-import com.dmdirc.commandparser.commands.context.CommandContext;
33
-import com.dmdirc.interfaces.CommandController;
34
-import com.dmdirc.interfaces.WindowModel;
35
-import com.dmdirc.ui.input.AdditionalTabTargets;
36
-import com.dmdirc.ui.input.TabCompleterUtils;
37
-
38
-import javax.annotation.Nonnull;
39
-import javax.inject.Inject;
40
-
41
-/**
42
- * Executes another command as if it were executed in the active window.
43
- */
44
-public class ActiveCommand extends Command implements IntelligentCommand {
45
-
46
-    /** A command info object for this command. */
47
-    public static final CommandInfo INFO = new BaseCommandInfo("active",
48
-            "active <command> - executes the command as though it had been "
49
-            + "executed in the active window", CommandType.TYPE_GLOBAL);
50
-    /** Active frame manager. */
51
-    private final ActiveFrameManager activeFrameManager;
52
-    /** Tab-completer utilities. */
53
-    private final TabCompleterUtils tabUtils;
54
-
55
-    /**
56
-     * Creates a new active command.
57
-     *
58
-     * @param controller          The controller to use for command information.
59
-     * @param activeFrameManager The active window manager
60
-     */
61
-    @Inject
62
-    public ActiveCommand(
63
-            final CommandController controller,
64
-            final ActiveFrameManager activeFrameManager,
65
-            final TabCompleterUtils tabUtils) {
66
-        super(controller);
67
-
68
-        this.activeFrameManager = activeFrameManager;
69
-        this.tabUtils = tabUtils;
70
-    }
71
-
72
-    @Override
73
-    public void execute(@Nonnull final WindowModel origin,
74
-            final CommandArguments args, final CommandContext context) {
75
-        activeFrameManager.getActiveFrame().ifPresent(f -> f.getContainer().getCommandParser()
76
-                .parseCommand(f.getContainer(), args.getArgumentsAsString()));
77
-    }
78
-
79
-    @Override
80
-    public AdditionalTabTargets getSuggestions(final int arg,
81
-            final IntelligentCommandContext context) {
82
-        return tabUtils.getIntelligentResults(arg, context, 0);
83
-    }
84
-
85
-}

+ 0
- 67
activewindow/src/com/dmdirc/addons/activewindow/ActiveWindowManager.java Целия файл

@@ -1,67 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
26
-
27
-import javax.inject.Inject;
28
-
29
-/**
30
- * Manages the active window sink.
31
- */
32
-public class ActiveWindowManager {
33
-
34
-    /** The message sink to register and unregister. */
35
-    private final ActiveWindowMessageSink sink;
36
-    /** The manager to add and remove the sink from. */
37
-    private final MessageSinkManager sinkManager;
38
-
39
-    /**
40
-     * Creates a new instance of {@link ActiveWindowManager}.
41
-     *
42
-     * @param sinkManager The manager to add and remove sinks from.
43
-     * @param sink        The sink to be added and removed.
44
-     */
45
-    @Inject
46
-    public ActiveWindowManager(
47
-            final MessageSinkManager sinkManager,
48
-            final ActiveWindowMessageSink sink) {
49
-        this.sink = sink;
50
-        this.sinkManager = sinkManager;
51
-    }
52
-
53
-    /**
54
-     * Registers the sink with the manager.
55
-     */
56
-    public void register() {
57
-        sinkManager.addSink(sink);
58
-    }
59
-
60
-    /**
61
-     * Unregisters the sink from the manager.
62
-     */
63
-    public void unregister() {
64
-        sinkManager.removeSink(sink);
65
-    }
66
-
67
-}

+ 0
- 68
activewindow/src/com/dmdirc/addons/activewindow/ActiveWindowMessageSink.java Целия файл

@@ -1,68 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
26
-import com.dmdirc.interfaces.WindowModel;
27
-import com.dmdirc.ui.messages.sink.MessageSink;
28
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
29
-
30
-import java.util.Date;
31
-import java.util.regex.Pattern;
32
-
33
-import javax.inject.Inject;
34
-
35
-/**
36
- * A message sink which passes messages onto the active swing window.
37
- */
38
-public class ActiveWindowMessageSink implements MessageSink {
39
-
40
-    /** The pattern to use to match this sink. */
41
-    private static final Pattern PATTERN = Pattern.compile("active");
42
-    /** Active frame manager. */
43
-    private final ActiveFrameManager activeFrameManager;
44
-
45
-    /**
46
-     * Creates a new ActiveWindowMessageSink for the specified mainframe.
47
-     *
48
-     * @param activeFrameManager Active frame manager.
49
-     */
50
-    @Inject
51
-    public ActiveWindowMessageSink(final ActiveFrameManager activeFrameManager) {
52
-        this.activeFrameManager = activeFrameManager;
53
-    }
54
-
55
-    @Override
56
-    public Pattern getPattern() {
57
-        return PATTERN;
58
-    }
59
-
60
-    @Override
61
-    public void handleMessage(final MessageSinkManager dispatcher,
62
-            final WindowModel source, final String[] patternMatches,
63
-            final Date date, final String messageType, final Object... args) {
64
-        activeFrameManager.getActiveFrame()
65
-                .ifPresent(f -> f.getContainer().addLine(messageType, date, args));
66
-    }
67
-
68
-}

+ 0
- 34
activewindow/src/com/dmdirc/addons/activewindow/ActiveWindowModule.java Целия файл

@@ -1,34 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.addons.ui_swing.injection.SwingModule;
26
-
27
-import dagger.Module;
28
-
29
-/**
30
- * DI module for the active window plugin.
31
- */
32
-@Module(injects = {ActiveWindowManager.class, ActiveCommand.class}, addsTo = SwingModule.class)
33
-public class ActiveWindowModule {
34
-}

+ 0
- 58
activewindow/src/com/dmdirc/addons/activewindow/ActiveWindowPlugin.java Целия файл

@@ -1,58 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.plugins.PluginInfo;
26
-import com.dmdirc.plugins.implementations.BaseCommandPlugin;
27
-
28
-import dagger.ObjectGraph;
29
-
30
-/** Plugin to provide an active window command to the Swing UI. */
31
-public class ActiveWindowPlugin extends BaseCommandPlugin {
32
-
33
-    /** Manager to use for the active window sink. */
34
-    private ActiveWindowManager activeWindowManager;
35
-
36
-    @Override
37
-    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
38
-        super.load(pluginInfo, graph);
39
-
40
-        setObjectGraph(graph.plus(new ActiveWindowModule()));
41
-        registerCommand(ActiveCommand.class, ActiveCommand.INFO);
42
-
43
-        activeWindowManager = getObjectGraph().get(ActiveWindowManager.class);
44
-    }
45
-
46
-    @Override
47
-    public void onLoad() {
48
-        super.onLoad();
49
-        activeWindowManager.register();
50
-    }
51
-
52
-    @Override
53
-    public void onUnload() {
54
-        super.onUnload();
55
-        activeWindowManager.unregister();
56
-    }
57
-
58
-}

+ 0
- 26
activewindow/src/com/dmdirc/addons/activewindow/package-info.java Целия файл

@@ -1,26 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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
-/**
24
- * Provides an active window command to the swing UI.
25
- */
26
-package com.dmdirc.addons.activewindow;

+ 0
- 89
activewindow/test/com/dmdirc/addons/activewindow/ActiveCommandTest.java Целия файл

@@ -1,89 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
26
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
27
-import com.dmdirc.commandparser.CommandArguments;
28
-import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
29
-import com.dmdirc.commandparser.commands.context.CommandContext;
30
-import com.dmdirc.commandparser.parsers.CommandParser;
31
-import com.dmdirc.interfaces.CommandController;
32
-import com.dmdirc.interfaces.WindowModel;
33
-import com.dmdirc.ui.input.TabCompleterUtils;
34
-
35
-import java.util.Optional;
36
-
37
-import org.junit.Before;
38
-import org.junit.Test;
39
-import org.junit.runner.RunWith;
40
-import org.mockito.Mock;
41
-import org.mockito.runners.MockitoJUnitRunner;
42
-
43
-import static org.mockito.Mockito.never;
44
-import static org.mockito.Mockito.verify;
45
-import static org.mockito.Mockito.when;
46
-
47
-@RunWith(MockitoJUnitRunner.class)
48
-public class ActiveCommandTest {
49
-
50
-    @Mock private IntelligentCommandContext intelligentCommandContext;
51
-    @Mock private CommandParser commandParser;
52
-    @Mock private CommandController commandController;
53
-    @Mock private ActiveFrameManager activeFrameManager;
54
-    @Mock private TabCompleterUtils tabCompleterUtils;
55
-    @Mock private WindowModel frameContainer;
56
-    @Mock private TextFrame textFrame;
57
-    @Mock private CommandArguments commandArguments;
58
-    @Mock private CommandContext commandContext;
59
-    private ActiveCommand activeCommand;
60
-
61
-    @Before
62
-    public void setUp() throws Exception {
63
-        when(textFrame.getContainer()).thenReturn(frameContainer);
64
-        when(frameContainer.getCommandParser()).thenReturn(commandParser);
65
-        when(commandArguments.getArgumentsAsString()).thenReturn("some arguments");
66
-        activeCommand = new ActiveCommand(commandController, activeFrameManager, tabCompleterUtils);
67
-    }
68
-
69
-    @Test
70
-    public void testExecute_NoActive() throws Exception {
71
-        when(activeFrameManager.getActiveFrame()).thenReturn(Optional.empty());
72
-        activeCommand.execute(frameContainer, commandArguments, commandContext);
73
-        verify(commandParser, never())
74
-                .parseCommand(frameContainer, commandArguments.getArgumentsAsString());
75
-    }
76
-
77
-    @Test
78
-    public void testExecute_Active() throws Exception {
79
-        when(activeFrameManager.getActiveFrame()).thenReturn(Optional.of(textFrame));
80
-        activeCommand.execute(frameContainer, commandArguments, commandContext);
81
-        verify(commandParser).parseCommand(frameContainer, commandArguments.getArgumentsAsString());
82
-    }
83
-
84
-    @Test
85
-    public void testGetSuggestions() throws Exception {
86
-        activeCommand.getSuggestions(1, intelligentCommandContext);
87
-        verify(tabCompleterUtils).getIntelligentResults(1, intelligentCommandContext, 0);
88
-    }
89
-}

+ 0
- 58
activewindow/test/com/dmdirc/addons/activewindow/ActiveWindowManagerTest.java Целия файл

@@ -1,58 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
26
-
27
-import org.junit.Before;
28
-import org.junit.Test;
29
-import org.junit.runner.RunWith;
30
-import org.mockito.Mock;
31
-import org.mockito.runners.MockitoJUnitRunner;
32
-
33
-import static org.mockito.Mockito.verify;
34
-
35
-@RunWith(MockitoJUnitRunner.class)
36
-public class ActiveWindowManagerTest {
37
-
38
-    @Mock private MessageSinkManager messageSinkManager;
39
-    @Mock private ActiveWindowMessageSink activeWindowMessageSink;
40
-    private ActiveWindowManager activeWindowManager;
41
-
42
-    @Before
43
-    public void setUp() throws Exception {
44
-        activeWindowManager = new ActiveWindowManager(messageSinkManager, activeWindowMessageSink);
45
-    }
46
-
47
-    @Test
48
-    public void testRegister() throws Exception {
49
-        activeWindowManager.register();
50
-        verify(messageSinkManager).addSink(activeWindowMessageSink);
51
-    }
52
-
53
-    @Test
54
-    public void testUnregister() throws Exception {
55
-        activeWindowManager.unregister();
56
-        verify(messageSinkManager).removeSink(activeWindowMessageSink);
57
-    }
58
-}

+ 0
- 80
activewindow/test/com/dmdirc/addons/activewindow/ActiveWindowMessageSinkTest.java Целия файл

@@ -1,80 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.activewindow;
24
-
25
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
26
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
27
-import com.dmdirc.interfaces.WindowModel;
28
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
29
-
30
-import java.util.Date;
31
-import java.util.Optional;
32
-import java.util.regex.Pattern;
33
-
34
-import org.junit.Before;
35
-import org.junit.Test;
36
-import org.junit.runner.RunWith;
37
-import org.mockito.Mock;
38
-import org.mockito.runners.MockitoJUnitRunner;
39
-
40
-import static junit.framework.TestCase.assertEquals;
41
-import static org.mockito.Mockito.never;
42
-import static org.mockito.Mockito.verify;
43
-import static org.mockito.Mockito.when;
44
-
45
-@RunWith(MockitoJUnitRunner.class)
46
-public class ActiveWindowMessageSinkTest {
47
-
48
-    private static final Pattern PATTERN = Pattern.compile("active");
49
-    @Mock private ActiveFrameManager activeFrameManager;
50
-    @Mock private MessageSinkManager messageSinkManager;
51
-    @Mock private WindowModel frameContainer;
52
-    @Mock private TextFrame textFrame;
53
-    @Mock private Date date;
54
-    private ActiveWindowMessageSink sink;
55
-
56
-    @Before
57
-    public void setUp() throws Exception {
58
-        sink = new ActiveWindowMessageSink(activeFrameManager);
59
-        when(textFrame.getContainer()).thenReturn(frameContainer);
60
-    }
61
-
62
-    @Test
63
-    public void testGetPattern() throws Exception {
64
-        assertEquals(PATTERN.toString(), sink.getPattern().toString());
65
-    }
66
-
67
-    @Test
68
-    public void testHandleMessage_NoActive() throws Exception {
69
-        when(activeFrameManager.getActiveFrame()).thenReturn(Optional.empty());
70
-        sink.handleMessage(messageSinkManager, frameContainer, null, date, "type", "message");
71
-        verify(frameContainer, never()).addLine("type", date, "message");
72
-    }
73
-
74
-    @Test
75
-    public void testHandleMessage_Active() throws Exception {
76
-        when(activeFrameManager.getActiveFrame()).thenReturn(Optional.of(textFrame));
77
-        sink.handleMessage(messageSinkManager, frameContainer, null, date, "type", "message");
78
-        verify(frameContainer).addLine("type", date, "message");
79
-    }
80
-}

+ 0
- 4
dcc/src/com/dmdirc/addons/dcc/ChatContainer.java Целия файл

@@ -34,7 +34,6 @@ import com.dmdirc.interfaces.config.AggregateConfigProvider;
34 34
 import com.dmdirc.ui.core.components.WindowComponent;
35 35
 import com.dmdirc.ui.input.TabCompleterFactory;
36 36
 import com.dmdirc.ui.messages.BackBufferFactory;
37
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
38 37
 import com.dmdirc.util.EventUtils;
39 38
 
40 39
 import java.util.Arrays;
@@ -66,7 +65,6 @@ public class ChatContainer extends DCCFrameContainer implements DCCChatHandler {
66 65
      * @param nick                My Current Nickname
67 66
      * @param targetNick          Nickname of target
68 67
      * @param tabCompleterFactory The factory to use to create tab completers.
69
-     * @param messageSinkManager  The sink manager to use to dispatch messages.
70 68
      * @param eventBus            The bus to dispatch events on.
71 69
      */
72 70
     public ChatContainer(
@@ -79,11 +77,9 @@ public class ChatContainer extends DCCFrameContainer implements DCCChatHandler {
79 77
             final String nick,
80 78
             final String targetNick,
81 79
             final TabCompleterFactory tabCompleterFactory,
82
-            final MessageSinkManager messageSinkManager,
83 80
             final DMDircMBassador eventBus) {
84 81
         super(parent, title, "dcc-chat-inactive", configManager, backBufferFactory,
85 82
                 new DCCCommandParser(configManager, commandController, eventBus),
86
-                messageSinkManager,
87 83
                 tabCompleterFactory,
88 84
                 eventBus,
89 85
                 Arrays.asList(

+ 1
- 7
dcc/src/com/dmdirc/addons/dcc/DCCCommand.java Целия файл

@@ -49,7 +49,6 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
49 49
 import com.dmdirc.ui.input.TabCompleterFactory;
50 50
 import com.dmdirc.ui.input.TabCompletionType;
51 51
 import com.dmdirc.ui.messages.BackBufferFactory;
52
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
53 52
 
54 53
 import java.awt.Window;
55 54
 import java.io.File;
@@ -74,8 +73,6 @@ public class DCCCommand extends Command implements IntelligentCommand {
74 73
     private final Window mainWindow;
75 74
     /** Window management. */
76 75
     private final WindowManager windowManager;
77
-    /** The sink manager to use to dispatch messages. */
78
-    private final MessageSinkManager messageSinkManager;
79 76
     /** The factory to use for tab completers. */
80 77
     private final TabCompleterFactory tabCompleterFactory;
81 78
     /** The bus to dispatch events on. */
@@ -90,7 +87,6 @@ public class DCCCommand extends Command implements IntelligentCommand {
90 87
             final CommandController controller,
91 88
             @MainWindow final Window mainWindow,
92 89
             final DCCManager plugin,
93
-            final MessageSinkManager messageSinkManager,
94 90
             final WindowManager windowManager,
95 91
             final TabCompleterFactory tabCompleterFactory,
96 92
             final DMDircMBassador eventBus,
@@ -98,7 +94,6 @@ public class DCCCommand extends Command implements IntelligentCommand {
98 94
         super(controller);
99 95
         this.mainWindow = mainWindow;
100 96
         myPlugin = plugin;
101
-        this.messageSinkManager = messageSinkManager;
102 97
         this.windowManager = windowManager;
103 98
         this.tabCompleterFactory = tabCompleterFactory;
104 99
         this.eventBus = eventBus;
@@ -170,11 +165,10 @@ public class DCCCommand extends Command implements IntelligentCommand {
170 165
                     myNickname,
171 166
                     target,
172 167
                     tabCompleterFactory,
173
-                    messageSinkManager,
174 168
                     eventBus);
175 169
             windowManager.addWindow(myPlugin.getContainer(), window);
176 170
             parser.sendCTCP(target, "DCC", "CHAT chat " + DCC.ipToLong(
177
-                    myPlugin.getListenIP(parser)) + " " + chat.getPort());
171
+                    myPlugin.getListenIP(parser)) + ' ' + chat.getPort());
178 172
             eventBus.publish(new DccChatRequestSentEvent(connection, target));
179 173
             sendLine(origin, isSilent, "DCCChatStarting", target, chat.getHost(), chat.getPort());
180 174
             window.addLine("DCCChatStarting", target, chat.getHost(), chat.getPort());

+ 0
- 4
dcc/src/com/dmdirc/addons/dcc/DCCFrameContainer.java Целия файл

@@ -30,7 +30,6 @@ import com.dmdirc.interfaces.WindowModel;
30 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31 31
 import com.dmdirc.ui.input.TabCompleterFactory;
32 32
 import com.dmdirc.ui.messages.BackBufferFactory;
33
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
34 33
 
35 34
 import java.util.Collection;
36 35
 import java.util.Optional;
@@ -53,7 +52,6 @@ public abstract class DCCFrameContainer extends FrameContainer {
53 52
      * @param icon                The icon to use
54 53
      * @param configManager       Config manager
55 54
      * @param parser              Command parser to use for this window
56
-     * @param messageSinkManager  The sink manager to use to dispatch messages.
57 55
      * @param tabCompleterFactory The factory to use to create tab completers.
58 56
      * @param eventBus            The bus to dispatch events on.
59 57
      * @param components          The UI components that this frame requires
@@ -65,13 +63,11 @@ public abstract class DCCFrameContainer extends FrameContainer {
65 63
             final AggregateConfigProvider configManager,
66 64
             final BackBufferFactory backBufferFactory,
67 65
             final CommandParser parser,
68
-            final MessageSinkManager messageSinkManager,
69 66
             final TabCompleterFactory tabCompleterFactory,
70 67
             final DMDircMBassador eventBus,
71 68
             final Collection<String> components) {
72 69
         super(parent, icon, title, title, configManager, backBufferFactory,
73 70
                 tabCompleterFactory.getTabCompleter(configManager),
74
-                messageSinkManager,
75 71
                 eventBus,
76 72
                 components);
77 73
         initBackBuffer();

+ 0
- 6
dcc/src/com/dmdirc/addons/dcc/DCCManager.java Целия файл

@@ -61,7 +61,6 @@ import com.dmdirc.plugins.PluginInfo;
61 61
 import com.dmdirc.ui.WindowManager;
62 62
 import com.dmdirc.ui.input.TabCompleterFactory;
63 63
 import com.dmdirc.ui.messages.BackBufferFactory;
64
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
65 64
 
66 65
 import com.google.common.collect.Sets;
67 66
 
@@ -100,8 +99,6 @@ public class DCCManager {
100 99
     private PlaceholderContainer container;
101 100
     /** Config manager to read settings from. */
102 101
     private final AggregateConfigProvider config;
103
-    /** The sink manager to use to dispatch messages. */
104
-    private final MessageSinkManager messageSinkManager;
105 102
     /** Window Management. */
106 103
     private final WindowManager windowManager;
107 104
     /** The command controller to use. */
@@ -127,7 +124,6 @@ public class DCCManager {
127 124
             final IdentityController identityController,
128 125
             @GlobalConfig final AggregateConfigProvider globalConfig,
129 126
             final CommandController commandController,
130
-            final MessageSinkManager messageSinkManager,
131 127
             final WindowManager windowManager,
132 128
             final TabCompleterFactory tabCompleterFactory,
133 129
             final SwingWindowFactory windowFactory,
@@ -137,7 +133,6 @@ public class DCCManager {
137 133
             @Directory(DirectoryType.BASE) final String baseDirectory,
138 134
             final BackBufferFactory backBufferFactory) {
139 135
         this.mainWindow = mainWindow;
140
-        this.messageSinkManager = messageSinkManager;
141 136
         this.windowManager = windowManager;
142 137
         this.commandController = commandController;
143 138
         this.tabCompleterFactory = tabCompleterFactory;
@@ -476,7 +471,6 @@ public class DCCManager {
476 471
                 myNickname,
477 472
                 nickname,
478 473
                 tabCompleterFactory,
479
-                messageSinkManager,
480 474
                 eventBus);
481 475
         windowManager.addWindow(getContainer(), f);
482 476
         f.addLine("DCCChatStarting", nickname, chat.getHost(), chat.getPort());

+ 0
- 3
debug/src/com/dmdirc/addons/debug/RawWindow.java Целия файл

@@ -32,7 +32,6 @@ import com.dmdirc.parser.interfaces.Parser;
32 32
 import com.dmdirc.ui.core.components.WindowComponent;
33 33
 import com.dmdirc.ui.input.TabCompleterFactory;
34 34
 import com.dmdirc.ui.messages.BackBufferFactory;
35
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
36 35
 
37 36
 import java.util.Arrays;
38 37
 import java.util.Optional;
@@ -48,7 +47,6 @@ public class RawWindow extends FrameContainer {
48 47
 
49 48
     public RawWindow(
50 49
             final Connection connection,
51
-            final MessageSinkManager messageSinkManager,
52 50
             final TabCompleterFactory tabCompleterFactory,
53 51
             final BackBufferFactory backBufferFactory) {
54 52
         super(connection.getWindowModel(), "raw", "Raw", "(Raw log)",
@@ -57,7 +55,6 @@ public class RawWindow extends FrameContainer {
57 55
                 tabCompleterFactory.getTabCompleter(connection.getWindowModel().getTabCompleter(),
58 56
                         connection.getWindowModel().getConfigManager(),
59 57
                         CommandType.TYPE_QUERY, CommandType.TYPE_CHAT),
60
-                messageSinkManager,
61 58
                 connection.getWindowModel().getEventBus(),
62 59
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
63 60
                         WindowComponent.INPUTFIELD.getIdentifier()));

+ 6
- 7
debug/src/com/dmdirc/addons/debug/RawWindowFactory.java Целия файл

@@ -28,7 +28,6 @@ import com.dmdirc.interfaces.Connection;
28 28
 import com.dmdirc.ui.WindowManager;
29 29
 import com.dmdirc.ui.input.TabCompleterFactory;
30 30
 import com.dmdirc.ui.messages.BackBufferFactory;
31
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
32 31
 
33 32
 import javax.inject.Inject;
34 33
 import javax.inject.Singleton;
@@ -41,24 +40,24 @@ public class RawWindowFactory {
41 40
 
42 41
     private final TabCompleterFactory tabCompleterFactory;
43 42
     private final CommandController commandController;
44
-    private final MessageSinkManager messageSinkManager;
45 43
     private final BackBufferFactory backBufferFactory;
46 44
     private final WindowManager windowManager;
47 45
 
48 46
     @Inject
49
-    public RawWindowFactory(final TabCompleterFactory tabCompleterFactory,
50
-            final CommandController commandController, final MessageSinkManager messageSinkManager,
51
-            final BackBufferFactory backBufferFactory, final WindowManager windowManager) {
47
+    public RawWindowFactory(
48
+            final TabCompleterFactory tabCompleterFactory,
49
+            final CommandController commandController,
50
+            final BackBufferFactory backBufferFactory,
51
+            final WindowManager windowManager) {
52 52
         this.tabCompleterFactory = tabCompleterFactory;
53 53
         this.commandController = commandController;
54
-        this.messageSinkManager = messageSinkManager;
55 54
         this.backBufferFactory = backBufferFactory;
56 55
         this.windowManager = windowManager;
57 56
     }
58 57
 
59 58
     public RawWindow getRawWindow(final Connection connection) {
60 59
         final RawWindow rawWindow = new RawWindow(connection,
61
-                messageSinkManager, tabCompleterFactory,  backBufferFactory);
60
+                tabCompleterFactory,  backBufferFactory);
62 61
         rawWindow.setCommandParser(new ServerCommandParser(
63 62
                 connection.getWindowModel().getConfigManager(),
64 63
                 commandController,

+ 1
- 4
redirect/src/com/dmdirc/addons/redirect/FakeWriteableFrameContainer.java Целия файл

@@ -28,7 +28,6 @@ import com.dmdirc.interfaces.Connection;
28 28
 import com.dmdirc.interfaces.WindowModel;
29 29
 import com.dmdirc.ui.messages.BackBufferFactory;
30 30
 import com.dmdirc.ui.messages.Formatter;
31
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
32 31
 
33 32
 import java.util.Collections;
34 33
 import java.util.Date;
@@ -47,13 +46,11 @@ public class FakeWriteableFrameContainer extends FrameContainer {
47 46
      */
48 47
     public FakeWriteableFrameContainer(
49 48
             final WindowModel target,
50
-            final MessageSinkManager messageSinkManager,
51 49
             final DMDircMBassador eventBus,
52 50
             final BackBufferFactory backBufferFactory) {
53 51
         super(target, target.getIcon(), target.getName(), target.getTitle(),
54 52
                 target.getConfigManager(), backBufferFactory,
55
-                target.getTabCompleter(), messageSinkManager, eventBus,
56
-                Collections.<String>emptyList());
53
+                target.getTabCompleter(), eventBus, Collections.<String>emptyList());
57 54
         this.target = target;
58 55
         initBackBuffer();
59 56
         setCommandParser(target.getCommandParser());

+ 1
- 6
redirect/src/com/dmdirc/addons/redirect/RedirectCommand.java Целия файл

@@ -36,7 +36,6 @@ import com.dmdirc.interfaces.WindowModel;
36 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 37
 import com.dmdirc.ui.input.TabCompleterUtils;
38 38
 import com.dmdirc.ui.messages.BackBufferFactory;
39
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
40 39
 
41 40
 import javax.annotation.Nonnull;
42 41
 import javax.inject.Inject;
@@ -52,8 +51,6 @@ public class RedirectCommand extends Command implements IntelligentCommand {
52 51
             "redirect <command> - sends the output of the command to a "
53 52
             + "channel or query window",
54 53
             CommandType.TYPE_CHAT);
55
-    /** The sink manager to use to dispatch messages. */
56
-    private final MessageSinkManager messageSinkManager;
57 54
     /** The bus to dispatch events on. */
58 55
     private final DMDircMBassador eventBus;
59 56
     private final BackBufferFactory backBufferFactory;
@@ -66,12 +63,10 @@ public class RedirectCommand extends Command implements IntelligentCommand {
66 63
     @Inject
67 64
     public RedirectCommand(
68 65
             final CommandController controller,
69
-            final MessageSinkManager messageSinkManager,
70 66
             final DMDircMBassador eventBus,
71 67
             final BackBufferFactory backBufferFactory,
72 68
             final TabCompleterUtils tabCompleterUtils) {
73 69
         super(controller);
74
-        this.messageSinkManager = messageSinkManager;
75 70
         this.eventBus = eventBus;
76 71
         this.backBufferFactory = backBufferFactory;
77 72
         this.tabCompleterUtils = tabCompleterUtils;
@@ -83,7 +78,7 @@ public class RedirectCommand extends Command implements IntelligentCommand {
83 78
         final Chat target = ((ChatCommandContext) context).getChat();
84 79
         target.getWindowModel().getCommandParser().parseCommand(
85 80
                 new FakeWriteableFrameContainer(target.getWindowModel(),
86
-                        messageSinkManager, eventBus, backBufferFactory),
81
+                        eventBus, backBufferFactory),
87 82
                 args.getArgumentsAsString());
88 83
     }
89 84
 

Loading…
Отказ
Запис