瀏覽代碼

Remove windows from commands

Change-Id: I895be099fa526e4e4b566e7178120b5d1ad0912c
Depends-On: I5b6e7e2ca81d114028fef6cac0d88498def62ea0
Reviewed-on: http://gerrit.dmdirc.com/2012
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 13 年之前
父節點
當前提交
5f76f5b75c
共有 30 個檔案被更改,包括 223 行新增62 行删除
  1. 1
    1
      src/com/dmdirc/addons/activewindow/ActiveCommand.java
  2. 5
    1
      src/com/dmdirc/addons/debug/commands/FirstRun.java
  3. 3
    4
      src/com/dmdirc/addons/debug/commands/Time.java
  4. 2
    2
      src/com/dmdirc/addons/nowplaying/NowPlayingCommand.java
  5. 1
    1
      src/com/dmdirc/addons/redirect/RedirectCommand.java
  6. 4
    4
      src/com/dmdirc/addons/tabcompletion_bash/BashStyle.java
  7. 2
    2
      src/com/dmdirc/addons/tabcompletion_bash/BashStylePlugin.java
  8. 6
    6
      src/com/dmdirc/addons/tabcompletion_mirc/MircStyle.java
  9. 2
    2
      src/com/dmdirc/addons/tabcompletion_mirc/MircStylePlugin.java
  10. 2
    7
      src/com/dmdirc/addons/time/TimedCommand.java
  11. 1
    1
      src/com/dmdirc/addons/time/TimerCommand.java
  12. 2
    5
      src/com/dmdirc/addons/time/TimerManager.java
  13. 4
    2
      src/com/dmdirc/addons/ui_dummy/DummyInputHandler.java
  14. 2
    1
      src/com/dmdirc/addons/ui_dummy/DummyInputWindow.java
  15. 25
    0
      src/com/dmdirc/addons/ui_swing/SwingController.java
  16. 1
    1
      src/com/dmdirc/addons/ui_swing/actions/CommandAction.java
  17. 67
    0
      src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java
  18. 67
    0
      src/com/dmdirc/addons/ui_swing/commands/ServerSettings.java
  19. 3
    2
      src/com/dmdirc/addons/ui_swing/components/TopicBar.java
  20. 1
    1
      src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java
  21. 1
    1
      src/com/dmdirc/addons/ui_swing/components/frames/CustomInputFrame.java
  22. 1
    1
      src/com/dmdirc/addons/ui_swing/components/frames/ServerFrame.java
  23. 4
    4
      src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java
  24. 3
    2
      src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java
  25. 1
    1
      src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java
  26. 1
    1
      src/com/dmdirc/addons/ui_swing/dialogs/paste/PasteDialog.java
  27. 5
    4
      src/com/dmdirc/addons/ui_swing/textpane/TextPane.java
  28. 2
    1
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java
  29. 2
    2
      src/com/dmdirc/addons/ui_web/uicomponents/WebInputWindow.java
  30. 2
    2
      test/com/dmdirc/addons/redirect/RedirectCommandTest.java

+ 1
- 1
src/com/dmdirc/addons/activewindow/ActiveCommand.java 查看文件

@@ -66,7 +66,7 @@ public class ActiveCommand extends Command implements IntelligentCommand {
66 66
         final TextFrame frame = mainFrame.getActiveFrame();
67 67
         if (frame.getContainer() instanceof WritableFrameContainer) {
68 68
             ((WritableFrameContainer) frame.getContainer()).getCommandParser()
69
-                    .parseCommand(frame.getContainer(), context.getSource(),
69
+                    .parseCommand(frame.getContainer(),
70 70
                     args.getArgumentsAsString());
71 71
         }
72 72
     }

+ 5
- 1
src/com/dmdirc/addons/debug/commands/FirstRun.java 查看文件

@@ -25,8 +25,10 @@ package com.dmdirc.addons.debug.commands;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.addons.debug.Debug;
27 27
 import com.dmdirc.addons.debug.DebugCommand;
28
+import com.dmdirc.addons.ui_swing.SwingController;
28 29
 import com.dmdirc.commandparser.CommandArguments;
29 30
 import com.dmdirc.commandparser.commands.context.CommandContext;
31
+import com.dmdirc.plugins.PluginManager;
30 32
 
31 33
 /**
32 34
  * Opens the DMDirc first run wizard.
@@ -58,7 +60,9 @@ public class FirstRun extends DebugCommand {
58 60
     @Override
59 61
     public void execute(final FrameContainer origin,
60 62
             final CommandArguments args, final CommandContext context) {
61
-        context.getSource().getController().showFirstRunWizard();
63
+        ((SwingController) PluginManager.getPluginManager()
64
+                .getPluginInfoByName("ui_swing").getPlugin())
65
+                .showFirstRunWizard();
62 66
     }
63 67
 
64 68
 }

+ 3
- 4
src/com/dmdirc/addons/debug/commands/Time.java 查看文件

@@ -31,7 +31,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
31 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
32 32
 import com.dmdirc.ui.input.AdditionalTabTargets;
33 33
 import com.dmdirc.ui.input.TabCompletionType;
34
-import com.dmdirc.ui.interfaces.Window;
35 34
 
36 35
 /**
37 36
  * Times how long it takes to execute commands.
@@ -63,7 +62,7 @@ public class Time extends DebugCommand implements IntelligentCommand {
63 62
     @Override
64 63
     public void execute(final FrameContainer origin,
65 64
             final CommandArguments args, final CommandContext context) {
66
-        doTime(origin, context.getSource(), args);
65
+        doTime(origin, args);
67 66
     }
68 67
 
69 68
     /**
@@ -73,7 +72,7 @@ public class Time extends DebugCommand implements IntelligentCommand {
73 72
      * @param window The window to be passed on to the timed command, if any
74 73
      * @param args The arguments that were passed to the command
75 74
      */
76
-    private void doTime(final FrameContainer origin, final Window window,
75
+    private void doTime(final FrameContainer origin,
77 76
             final CommandArguments args) {
78 77
         if (args.getArguments().length == 0) {
79 78
             showUsage(origin, args.isSilent(), getName(), getUsage());
@@ -84,7 +83,7 @@ public class Time extends DebugCommand implements IntelligentCommand {
84 83
             final WritableFrameContainer container
85 84
                     = (WritableFrameContainer) origin;
86 85
             final long start = System.currentTimeMillis();
87
-            container.getCommandParser().parseCommand(origin, window,
86
+            container.getCommandParser().parseCommand(origin,
88 87
                     args.getArgumentsAsString(0));
89 88
             final long end = System.currentTimeMillis();
90 89
             sendLine(origin, args.isSilent(), FORMAT_OUTPUT,

+ 2
- 2
src/com/dmdirc/addons/nowplaying/NowPlayingCommand.java 查看文件

@@ -80,7 +80,7 @@ public final class NowPlayingCommand extends Command implements
80 80
                     if (source.getState() == MediaSourceState.CLOSED) {
81 81
                         sendLine(origin, args.isSilent(), FORMAT_ERROR, "Source is not running.");
82 82
                     } else {
83
-                        target.getCommandParser().parseCommand(origin, context.getSource(),
83
+                        target.getCommandParser().parseCommand(origin,
84 84
                                 getInformation(source, args.getArgumentsAsString(2)));
85 85
                     }
86 86
                 }
@@ -90,7 +90,7 @@ public final class NowPlayingCommand extends Command implements
90 90
             }
91 91
         } else {
92 92
             if (parent.hasRunningSource()) {
93
-                target.getCommandParser().parseCommand(origin, context.getSource(),
93
+                target.getCommandParser().parseCommand(origin,
94 94
                         getInformation(parent.getBestSource(), args.
95 95
                         getArgumentsAsString(0)));
96 96
             } else {

+ 1
- 1
src/com/dmdirc/addons/redirect/RedirectCommand.java 查看文件

@@ -49,7 +49,7 @@ public class RedirectCommand extends Command implements IntelligentCommand,
49 49
         final MessageTarget target = ((ChatCommandContext) context)
50 50
                 .getChat();
51 51
         target.getCommandParser().parseCommand(new FakeWriteableFrameContainer(
52
-                target), context.getSource(), args.getArgumentsAsString());
52
+                target), args.getArgumentsAsString());
53 53
     }
54 54
 
55 55
     /** {@inheritDoc} */

+ 4
- 4
src/com/dmdirc/addons/tabcompletion_bash/BashStyle.java 查看文件

@@ -22,12 +22,12 @@
22 22
 
23 23
 package com.dmdirc.addons.tabcompletion_bash;
24 24
 
25
+import com.dmdirc.WritableFrameContainer;
25 26
 import com.dmdirc.ui.input.AdditionalTabTargets;
26 27
 import com.dmdirc.ui.input.TabCompleter;
27 28
 import com.dmdirc.ui.input.TabCompleterResult;
28 29
 import com.dmdirc.ui.input.tabstyles.TabCompletionResult;
29 30
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
30
-import com.dmdirc.ui.interfaces.InputWindow;
31 31
 
32 32
 import java.awt.Toolkit;
33 33
 
@@ -46,7 +46,7 @@ public class BashStyle implements TabCompletionStyle {
46 46
     protected final TabCompleter tabCompleter;
47 47
 
48 48
     /** The input window that we use. */
49
-    protected final InputWindow window;
49
+    protected final WritableFrameContainer window;
50 50
 
51 51
     /**
52 52
      * Creates a new Bash-style tab completer.
@@ -54,7 +54,7 @@ public class BashStyle implements TabCompletionStyle {
54 54
      * @param completer The tab completer this style is for
55 55
      * @param window The window this tab style is for
56 56
      */
57
-    public BashStyle(final TabCompleter completer, final InputWindow window) {
57
+    public BashStyle(final TabCompleter completer, final WritableFrameContainer window) {
58 58
         this.tabCompleter = completer;
59 59
         this.window = window;
60 60
     }
@@ -92,7 +92,7 @@ public class BashStyle implements TabCompletionStyle {
92 92
 
93 93
             final String sub = res.getBestSubstring();
94 94
             if (sub.equalsIgnoreCase(word) && tabCount >= 2) {
95
-                window.getContainer().addLine("tabCompletion", res.toString());
95
+                window.addLine("tabCompletion", res.toString());
96 96
 
97 97
                 return null;
98 98
             } else {

+ 2
- 2
src/com/dmdirc/addons/tabcompletion_bash/BashStylePlugin.java 查看文件

@@ -22,10 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.tabcompletion_bash;
24 24
 
25
+import com.dmdirc.WritableFrameContainer;
25 26
 import com.dmdirc.plugins.BasePlugin;
26 27
 import com.dmdirc.ui.input.TabCompleter;
27 28
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
28
-import com.dmdirc.ui.interfaces.InputWindow;
29 29
 
30 30
 public class BashStylePlugin extends BasePlugin {
31 31
 
@@ -49,7 +49,7 @@ public class BashStylePlugin extends BasePlugin {
49 49
      * @return A relevant TabCompletionStyle
50 50
      */
51 51
     public TabCompletionStyle getCompletionStyle(final TabCompleter completer,
52
-            final InputWindow window) {
52
+            final WritableFrameContainer window) {
53 53
         return new BashStyle(completer, window);
54 54
     }
55 55
 

+ 6
- 6
src/com/dmdirc/addons/tabcompletion_mirc/MircStyle.java 查看文件

@@ -23,12 +23,12 @@
23 23
 package com.dmdirc.addons.tabcompletion_mirc;
24 24
 
25 25
 import com.dmdirc.Channel;
26
+import com.dmdirc.WritableFrameContainer;
26 27
 import com.dmdirc.ui.input.AdditionalTabTargets;
27 28
 import com.dmdirc.ui.input.TabCompleter;
28 29
 import com.dmdirc.ui.input.TabCompleterResult;
29 30
 import com.dmdirc.ui.input.tabstyles.TabCompletionResult;
30 31
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
31
-import com.dmdirc.ui.interfaces.InputWindow;
32 32
 
33 33
 import java.awt.Toolkit;
34 34
 import java.util.Collections;
@@ -45,7 +45,7 @@ public class MircStyle implements TabCompletionStyle {
45 45
     protected final TabCompleter tabCompleter;
46 46
 
47 47
     /** The input window that we use. */
48
-    protected final InputWindow window;
48
+    protected final WritableFrameContainer window;
49 49
 
50 50
     /**
51 51
      * Creates a new mIRC-style tab completer.
@@ -53,7 +53,7 @@ public class MircStyle implements TabCompletionStyle {
53 53
      * @param completer The tab completer this style is for
54 54
      * @param window The window this tab style is for
55 55
      */
56
-    public MircStyle(final TabCompleter completer, final InputWindow window) {
56
+    public MircStyle(final TabCompleter completer, final WritableFrameContainer window) {
57 57
         this.tabCompleter = completer;
58 58
         this.window = window;
59 59
     }
@@ -83,10 +83,10 @@ public class MircStyle implements TabCompletionStyle {
83 83
             } else {
84 84
                 Collections.sort(res.getResults(), String.CASE_INSENSITIVE_ORDER);
85 85
 
86
-                if (word.length() > 0 && window.getContainer() instanceof Channel
87
-                        && ((Channel) window.getContainer())
86
+                if (word.length() > 0 && window instanceof Channel
87
+                        && ((Channel) window)
88 88
                         .getChannelInfo().getName().startsWith(word)) {
89
-                    target = ((Channel) window.getContainer()).getChannelInfo().getName();
89
+                    target = ((Channel) window).getChannelInfo().getName();
90 90
                 } else {
91 91
                     target = res.getResults().get(0);
92 92
                 }

+ 2
- 2
src/com/dmdirc/addons/tabcompletion_mirc/MircStylePlugin.java 查看文件

@@ -22,10 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.tabcompletion_mirc;
24 24
 
25
+import com.dmdirc.WritableFrameContainer;
25 26
 import com.dmdirc.plugins.BasePlugin;
26 27
 import com.dmdirc.ui.input.TabCompleter;
27 28
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
28
-import com.dmdirc.ui.interfaces.InputWindow;
29 29
 
30 30
 public class MircStylePlugin extends BasePlugin {
31 31
 
@@ -49,7 +49,7 @@ public class MircStylePlugin extends BasePlugin {
49 49
      * @return A relevant TabCompletionStyle
50 50
      */
51 51
     public TabCompletionStyle getCompletionStyle(final TabCompleter completer,
52
-            final InputWindow window) {
52
+            final WritableFrameContainer window) {
53 53
         return new MircStyle(completer, window);
54 54
     }
55 55
 

+ 2
- 7
src/com/dmdirc/addons/time/TimedCommand.java 查看文件

@@ -27,7 +27,6 @@ import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.WritableFrameContainer;
28 28
 import com.dmdirc.commandparser.parsers.CommandParser;
29 29
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
30
-import com.dmdirc.ui.interfaces.Window;
31 30
 
32 31
 import java.util.Timer;
33 32
 import java.util.TimerTask;
@@ -46,9 +45,6 @@ public final class TimedCommand extends TimerTask {
46 45
     /** The container to use for executing commands. */
47 46
     private final FrameContainer origin;
48 47
 
49
-    /** The window the command came from. */
50
-    private final Window window;
51
-
52 48
     /** The timer we're using for scheduling this command. */
53 49
     private final Timer timer;
54 50
 
@@ -69,14 +65,13 @@ public final class TimedCommand extends TimerTask {
69 65
      */
70 66
     public TimedCommand(final TimerManager manager, final int timerKey,
71 67
             final int repetitions, final int delay, final String command,
72
-            final FrameContainer origin, final Window window) {
68
+            final FrameContainer origin) {
73 69
         super();
74 70
 
75 71
         this.timerKey = timerKey;
76 72
         this.repetitions = repetitions;
77 73
         this.command = command;
78 74
         this.origin = origin;
79
-        this.window = window;
80 75
         this.manager = manager;
81 76
 
82 77
         timer = new Timer("Timed Command Timer");
@@ -113,7 +108,7 @@ public final class TimedCommand extends TimerTask {
113 108
             parser = ((WritableFrameContainer) origin).getCommandParser();
114 109
         }
115 110
 
116
-        parser.parseCommand(origin, window, command);
111
+        parser.parseCommand(origin, command);
117 112
 
118 113
         if (--repetitions <= 0) {
119 114
             manager.removeTimer(timerKey);

+ 1
- 1
src/com/dmdirc/addons/time/TimerCommand.java 查看文件

@@ -119,7 +119,7 @@ public final class TimerCommand extends Command implements IntelligentCommand,
119 119
                     }
120 120
 
121 121
                     manager.addTimer(repetitions, interval, command,
122
-                            origin, context.getSource());
122
+                            origin);
123 123
 
124 124
                     sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Command scheduled.");
125 125
                 }

+ 2
- 5
src/com/dmdirc/addons/time/TimerManager.java 查看文件

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.time;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.ui.interfaces.Window;
27 26
 
28 27
 import java.util.HashMap;
29 28
 import java.util.Map;
@@ -52,16 +51,14 @@ public class TimerManager {
52 51
      * @param interval Interval between repetitions
53 52
      * @param command Command to be run when the timer fires
54 53
      * @param origin The frame container to use for the execution
55
-     * @param commandContext The window the command came from
56 54
      */
57 55
     public void addTimer(final int repetitions, final int interval,
58
-            final String command, final FrameContainer origin,
59
-            final Window commandContext) {
56
+            final String command, final FrameContainer origin) {
60 57
 
61 58
         synchronized (this) {
62 59
             final int timerKey = findFreeKey();
63 60
             timerList.put(timerKey, new TimedCommand(this, timerKey,
64
-                    repetitions, interval, command, origin, commandContext));
61
+                    repetitions, interval, command, origin));
65 62
         }
66 63
     }
67 64
 

+ 4
- 2
src/com/dmdirc/addons/ui_dummy/DummyInputHandler.java 查看文件

@@ -22,10 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_dummy;
24 24
 
25
+import com.dmdirc.WritableFrameContainer;
25 26
 import com.dmdirc.commandparser.parsers.CommandParser;
26 27
 import com.dmdirc.ui.input.InputHandler;
27 28
 import com.dmdirc.ui.interfaces.InputField;
28
-import com.dmdirc.ui.interfaces.InputWindow;
29 29
 
30 30
 /**
31 31
  * Dummy input handler.
@@ -40,7 +40,9 @@ public class DummyInputHandler extends InputHandler {
40 40
      * @param commandParser The command parser to use for this text field.
41 41
      * @param parentWindow The window that owns this input handler
42 42
      */
43
-    public DummyInputHandler(final InputField target, final CommandParser commandParser, final InputWindow parentWindow) {
43
+    public DummyInputHandler(final InputField target,
44
+            final CommandParser commandParser,
45
+            final WritableFrameContainer parentWindow) {
44 46
         super(target, commandParser, parentWindow);
45 47
     }
46 48
 

+ 2
- 1
src/com/dmdirc/addons/ui_dummy/DummyInputWindow.java 查看文件

@@ -50,7 +50,8 @@ public class DummyInputWindow implements InputWindow {
50 50
     /** {@inheritDoc} */
51 51
     @Override
52 52
     public InputHandler getInputHandler() {
53
-        return new DummyInputHandler(new DummyInputField(), null, this);
53
+        return new DummyInputHandler(new DummyInputField(), null,
54
+                getContainer());
54 55
     }
55 56
 
56 57
     /** {@inheritDoc} */

+ 25
- 0
src/com/dmdirc/addons/ui_swing/SwingController.java 查看文件

@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_swing;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28
+import com.dmdirc.addons.ui_swing.commands.*; //NOPMD
28 29
 import com.dmdirc.addons.ui_swing.components.addonpanel.AddonPanel;
29 30
 import com.dmdirc.addons.ui_swing.components.addonpanel.PluginPanel;
30 31
 import com.dmdirc.addons.ui_swing.components.addonpanel.ThemePanel;
@@ -42,6 +43,8 @@ import com.dmdirc.addons.ui_swing.dialogs.serversetting.ServerSettingsDialog;
42 43
 import com.dmdirc.addons.ui_swing.dialogs.url.URLDialog;
43 44
 import com.dmdirc.addons.ui_swing.wizard.WizardListener;
44 45
 import com.dmdirc.addons.ui_swing.wizard.firstrun.SwingFirstRunWizard;
46
+import com.dmdirc.commandparser.CommandInfo;
47
+import com.dmdirc.commandparser.CommandManager;
45 48
 import com.dmdirc.config.Identity;
46 49
 import com.dmdirc.config.IdentityManager;
47 50
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
@@ -114,6 +117,8 @@ public class SwingController extends BasePlugin implements UIController {
114 117
     private DMDircEventQueue eventQueue;
115 118
     /** Key listener to handle dialog key events. */
116 119
     private DialogKeyListener keyListener;
120
+    /** List of commands to load and unload. */
121
+    private final List<CommandInfo> commands = new ArrayList<CommandInfo>();
117 122
 
118 123
     /** Instantiates a new SwingController. */
119 124
     public SwingController() {
@@ -491,9 +496,21 @@ public class SwingController extends BasePlugin implements UIController {
491 496
                     "Main frame not created. Unable to continue.");
492 497
         }
493 498
 
499
+        loadCommands();
500
+
494 501
         WindowManager.getWindowManager().addListenerAndSync(windowFactory);
495 502
     }
496 503
 
504
+    /** Loads the commands provided by this plugin. */
505
+    private void loadCommands() {
506
+        commands.add(ServerSettings.INFO);
507
+        commands.add(ChannelSettings.INFO);
508
+        CommandManager.getCommandManager().registerCommand(
509
+                new ServerSettings(), ServerSettings.INFO);
510
+        CommandManager.getCommandManager().registerCommand(
511
+                new ChannelSettings(), ChannelSettings.INFO);
512
+    }
513
+
497 514
     /** {@inheritDoc} */
498 515
     @Override
499 516
     public void onUnload() {
@@ -509,6 +526,14 @@ public class SwingController extends BasePlugin implements UIController {
509 526
         for (java.awt.Window window : getTopLevelWindows()) {
510 527
             window.dispose();
511 528
         }
529
+        unloadCommands();
530
+    }
531
+
532
+    /** Unloads the commands loaded by this plugin. */
533
+    private void unloadCommands() {
534
+        for (CommandInfo command : commands) {
535
+            CommandManager.getCommandManager().unregisterCommand(command);
536
+        }
512 537
     }
513 538
 
514 539
     /** {@inheritDoc} */

+ 1
- 1
src/com/dmdirc/addons/ui_swing/actions/CommandAction.java 查看文件

@@ -75,7 +75,7 @@ public class CommandAction extends AbstractAction {
75 75
     @Override
76 76
     public void actionPerformed(final ActionEvent e) {
77 77
         for (String line : command.split("\n")) {
78
-            parser.parseCommand(window.getContainer(), window, line);
78
+            parser.parseCommand(window.getContainer(), line);
79 79
         }
80 80
     }
81 81
 

+ 67
- 0
src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java 查看文件

@@ -0,0 +1,67 @@
1
+/*
2
+ * Copyright (c) 2006-2011 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.commands;
24
+
25
+import com.dmdirc.FrameContainer;
26
+import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.commandparser.BaseCommandInfo;
28
+import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
30
+import com.dmdirc.commandparser.CommandType;
31
+import com.dmdirc.commandparser.commands.Command;
32
+import com.dmdirc.commandparser.commands.CommandOptions;
33
+import com.dmdirc.commandparser.commands.IntelligentCommand;
34
+import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
35
+import com.dmdirc.commandparser.commands.context.CommandContext;
36
+import com.dmdirc.plugins.PluginManager;
37
+import com.dmdirc.ui.input.AdditionalTabTargets;
38
+
39
+/**
40
+ * Opens the channel settings window for the channel.
41
+ */
42
+@CommandOptions(allowOffline = false)
43
+public class ChannelSettings extends Command implements
44
+        IntelligentCommand {
45
+
46
+    /** A command info object for this command. */
47
+    public static final CommandInfo INFO = new BaseCommandInfo("channelsettings",
48
+            "channelsettings - opens the channel settings window",
49
+            CommandType.TYPE_CHANNEL);
50
+
51
+    /** {@inheritDoc} */
52
+    @Override
53
+    public void execute(final FrameContainer origin,
54
+            final CommandArguments args, final CommandContext context) {
55
+        ((SwingController) PluginManager.getPluginManager()
56
+                .getPluginInfoByName("ui_swing").getPlugin())
57
+                .showChannelSettingsDialog(((ChannelCommandContext) context)
58
+                .getChannel());
59
+    }
60
+
61
+    /** {@inheritDoc} */
62
+    @Override
63
+    public AdditionalTabTargets getSuggestions(final int arg,
64
+            final IntelligentCommandContext context) {
65
+        return new AdditionalTabTargets().excludeAll();
66
+    }
67
+}

+ 67
- 0
src/com/dmdirc/addons/ui_swing/commands/ServerSettings.java 查看文件

@@ -0,0 +1,67 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes,
3
+ * Simon Mott
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+
24
+package com.dmdirc.addons.ui_swing.commands;
25
+
26
+import com.dmdirc.FrameContainer;
27
+import com.dmdirc.addons.ui_swing.SwingController;
28
+import com.dmdirc.commandparser.BaseCommandInfo;
29
+import com.dmdirc.commandparser.CommandArguments;
30
+import com.dmdirc.commandparser.CommandInfo;
31
+import com.dmdirc.commandparser.CommandType;
32
+import com.dmdirc.commandparser.commands.Command;
33
+import com.dmdirc.commandparser.commands.CommandOptions;
34
+import com.dmdirc.commandparser.commands.IntelligentCommand;
35
+import com.dmdirc.commandparser.commands.context.CommandContext;
36
+import com.dmdirc.plugins.PluginManager;
37
+import com.dmdirc.ui.input.AdditionalTabTargets;
38
+
39
+/**
40
+ * Opens the server settings window for the server.
41
+ *
42
+ * @since 0.6.4
43
+ */
44
+@CommandOptions(allowOffline=false)
45
+public class ServerSettings extends Command implements IntelligentCommand {
46
+
47
+    /** A command info object for this command. */
48
+    public static final CommandInfo INFO = new BaseCommandInfo("serversettings",
49
+            "serversettings - opens the server settings window",
50
+            CommandType.TYPE_SERVER);
51
+
52
+    /** {@inheritDoc} */
53
+    @Override
54
+    public void execute(final FrameContainer origin,
55
+            final CommandArguments args, final CommandContext context) {
56
+        ((SwingController) PluginManager.getPluginManager()
57
+                .getPluginInfoByName("ui_swing").getPlugin())
58
+                .showServerSettingsDialog(context.getSource().getServer());
59
+    }
60
+
61
+    /** {@inheritDoc} */
62
+    @Override
63
+    public AdditionalTabTargets getSuggestions(final int arg,
64
+            final IntelligentCommandContext context) {
65
+        return new AdditionalTabTargets().excludeAll();
66
+    }
67
+}

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/TopicBar.java 查看文件

@@ -101,7 +101,7 @@ public class TopicBar extends JComponent implements ActionListener,
101 101
     /**
102 102
      * Instantiates a new topic bar.
103 103
      *
104
-     * @param window Parent window
104
+     * @param parentWindow Parent window
105 105
      * @param channelFrame Parent channel frame
106 106
      */
107 107
     public TopicBar(final Window parentWindow,
@@ -129,7 +129,8 @@ public class TopicBar extends JComponent implements ActionListener,
129 129
                 getIcon("close-active"));
130 130
 
131 131
         final SwingInputHandler handler = new SwingInputHandler(topicText,
132
-                channelFrame.getContainer().getCommandParser(), channelFrame);
132
+                channelFrame.getContainer().getCommandParser(),
133
+                channelFrame.getContainer());
133 134
         handler.setTypes(true, false, true, false);
134 135
         handler.setTabCompleter(channel.getTabCompleter());
135 136
 

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java 查看文件

@@ -98,7 +98,7 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
98 98
                 CoreActionType.CLIENT_CLOSING);
99 99
 
100 100
         setInputHandler(new SwingInputHandler(getInputField(),
101
-                owner.getCommandParser(), this));
101
+                owner.getCommandParser(), getContainer()));
102 102
 
103 103
         identity = IdentityManager.getChannelConfig(owner.getServer().
104 104
                 getNetwork(), owner.getChannelInfo().getName());

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/frames/CustomInputFrame.java 查看文件

@@ -55,7 +55,7 @@ public class CustomInputFrame extends InputTextFrame {
55 55
         super(controller, owner);
56 56
 
57 57
         setInputHandler(new SwingInputHandler(getInputField(),
58
-                owner.getCommandParser(), this));
58
+                owner.getCommandParser(), getContainer()));
59 59
 
60 60
         initComponents();
61 61
     }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/frames/ServerFrame.java 查看文件

@@ -74,7 +74,7 @@ public final class ServerFrame extends InputTextFrame implements
74 74
         initComponents();
75 75
 
76 76
         setInputHandler(new SwingInputHandler(getInputField(),
77
-                owner.getCommandParser(), this));
77
+                owner.getCommandParser(), getContainer()));
78 78
 
79 79
         owner.addCertificateProblemListener(this);
80 80
     }

+ 4
- 4
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java 查看文件

@@ -169,7 +169,7 @@ public abstract class TextFrame extends JPanel implements Window,
169 169
      * Initialises the components for this frame.
170 170
      */
171 171
     private void initComponents() {
172
-        setTextPane(new TextPane(this));
172
+        setTextPane(new TextPane(getController(), this));
173 173
 
174 174
         searchBar = new SwingSearchBar(this);
175 175
         searchBar.setVisible(false);
@@ -251,14 +251,14 @@ public abstract class TextFrame extends JPanel implements Window,
251 251
 
252 252
     /** {@inheritDoc} */
253 253
     @Override
254
-    public void mouseClicked(final ClickTypeValue clickType,
254
+    public void mouseClicked(final ClickTypeValue clicktype,
255 255
             final MouseEventType eventType, final MouseEvent event) {
256 256
         if (event.isPopupTrigger()) {
257
-            showPopupMenuInternal(clickType, event.getPoint());
257
+            showPopupMenuInternal(clicktype, event.getPoint());
258 258
         }
259 259
         if (eventType == MouseEventType.CLICK
260 260
                 && event.getButton() == MouseEvent.BUTTON1) {
261
-            handleLinkClick(clickType);
261
+            handleLinkClick(clicktype);
262 262
         }
263 263
     }
264 264
 

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java 查看文件

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.inputfields;
24 24
 
25
+import com.dmdirc.WritableFrameContainer;
25 26
 import com.dmdirc.addons.ui_swing.Apple;
26 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
27 28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
@@ -30,7 +31,6 @@ import com.dmdirc.logger.ErrorLevel;
30 31
 import com.dmdirc.logger.Logger;
31 32
 import com.dmdirc.ui.input.InputHandler;
32 33
 import com.dmdirc.ui.interfaces.InputField;
33
-import com.dmdirc.ui.interfaces.InputWindow;
34 34
 
35 35
 import java.awt.event.ActionEvent;
36 36
 import java.awt.event.KeyEvent;
@@ -57,7 +57,8 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
57 57
      * @param parentWindow The window that owns this input handler
58 58
      */
59 59
     public SwingInputHandler(final InputField target,
60
-            final CommandParser commandParser, final InputWindow parentWindow) {
60
+            final CommandParser commandParser,
61
+            final WritableFrameContainer parentWindow) {
61 62
         super(target, commandParser, parentWindow);
62 63
     }
63 64
 

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java 查看文件

@@ -110,7 +110,7 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
110 110
         topicText.setRows(5);
111 111
         topicText.setColumns(30);
112 112
         final SwingInputHandler handler = new SwingInputHandler(topicText,
113
-                channel.getCommandParser(), channelWindow);
113
+                channel.getCommandParser(), channelWindow.getContainer());
114 114
         handler.setTypes(true, false, true, false);
115 115
         handler.setTabCompleter(channel.getTabCompleter());
116 116
 

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/paste/PasteDialog.java 查看文件

@@ -125,7 +125,7 @@ public final class PasteDialog extends StandardDialog implements ActionListener,
125 125
         textField.setRows(10);
126 126
 
127 127
         new SwingInputHandler(textField, parent.getContainer()
128
-                .getCommandParser(), parent)
128
+                .getCommandParser(), parent.getContainer())
129 129
                 .setTypes(false, false, true,false);
130 130
 
131 131
         scrollPane.setViewportView(textField);

+ 5
- 4
src/com/dmdirc/addons/ui_swing/textpane/TextPane.java 查看文件

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_swing.textpane;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.SwingController;
26 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
27
+import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
27 28
 import com.dmdirc.interfaces.ConfigChangeListener;
28 29
 import com.dmdirc.ui.interfaces.Window;
29 30
 import com.dmdirc.ui.messages.IRCDocument;
@@ -81,9 +82,10 @@ public final class TextPane extends JComponent implements MouseWheelListener,
81 82
     /**
82 83
      * Creates a new instance of TextPane.
83 84
      *
85
+     * @param controller Parent swing controller
84 86
      * @param frame Parent Frame
85 87
      */
86
-    public TextPane(final Window frame) {
88
+    public TextPane(final SwingController controller, final TextFrame frame) {
87 89
         super();
88 90
         this.frame = frame;
89 91
 
@@ -106,9 +108,8 @@ public final class TextPane extends JComponent implements MouseWheelListener,
106 108
         add(scrollBar, "dock east");
107 109
         scrollBar.addAdjustmentListener(this);
108 110
         scrollBar.addAdjustmentListener(canvas);
109
-        frame.getContainer().getConfigManager().addChangeListener(
110
-                ((SwingController) frame.getController()).getDomain(),
111
-                "textpanelinenotification", this);
111
+        frame.getContainer().getConfigManager().addChangeListener(controller
112
+                .getDomain(), "textpanelinenotification", this);
112 113
         configChanged("", "textpanelinenotification");
113 114
 
114 115
         addMouseWheelListener(this);

+ 2
- 1
src/com/dmdirc/addons/ui_web/uicomponents/WebInputHandler.java 查看文件

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_web.uicomponents;
24 24
 
25
+import com.dmdirc.WritableFrameContainer;
25 26
 import com.dmdirc.commandparser.parsers.CommandParser;
26 27
 import com.dmdirc.ui.input.InputHandler;
27 28
 import com.dmdirc.ui.input.TabCompleter;
@@ -35,7 +36,7 @@ public class WebInputHandler extends InputHandler {
35 36
 
36 37
     public WebInputHandler(final InputField thisTarget,
37 38
                            final CommandParser thisCommandParser,
38
-                           final WebInputWindow thisParentWindow) {
39
+                           final WritableFrameContainer thisParentWindow) {
39 40
         super(thisTarget, thisCommandParser, thisParentWindow);
40 41
     }
41 42
 

+ 2
- 2
src/com/dmdirc/addons/ui_web/uicomponents/WebInputWindow.java 查看文件

@@ -52,7 +52,7 @@ public class WebInputWindow extends WebWindow implements InputWindow {
52 52
         this.parent = parent;
53 53
         this.commandparser = parent.getCommandParser();
54 54
         this.inputhandler = new WebInputHandler(new WebInputField(),
55
-                commandparser, this);
55
+                commandparser, getContainer());
56 56
     }
57 57
 
58 58
     /** {@inheritDoc} */
@@ -64,7 +64,7 @@ public class WebInputWindow extends WebWindow implements InputWindow {
64 64
     public InputHandler getInputHandler(final String clientID) {
65 65
         if (!inputHandlers.containsKey(clientID)) {
66 66
             final WebInputHandler ih = new WebInputHandler(
67
-                    new WebInputField(clientID), commandparser, this);
67
+                    new WebInputField(clientID), commandparser, getContainer());
68 68
             ih.setTabCompleter(inputhandler.getTabCompleter());
69 69
             inputHandlers.put(clientID, ih);
70 70
         }

+ 2
- 2
test/com/dmdirc/addons/redirect/RedirectCommandTest.java 查看文件

@@ -52,8 +52,8 @@ public class RedirectCommandTest {
52 52
         when(window.getContainer().getConfigManager()).thenReturn(IdentityManager.getGlobalConfig());
53 53
 
54 54
         command.execute(target, new CommandArguments("/redirect /echo test"),
55
-                new ChatCommandContext(window, command, target));
56
-        
55
+                new ChatCommandContext(window.getContainer(), command, target));
56
+
57 57
         verify(target).sendLine("test");
58 58
     }
59 59
 

Loading…
取消
儲存