ソースを参照

Adds an active window command back to the client, swing ui only.

Change-Id: I3355f8b04449162413a6888e03e5d5d269193b0a
Reviewed-on: http://gerrit.dmdirc.com/1952
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 13年前
コミット
e0220cf274

+ 100
- 0
src/com/dmdirc/addons/activewindow/ActiveCommand.java ファイルの表示

@@ -0,0 +1,100 @@
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
+package com.dmdirc.addons.activewindow;
23
+
24
+import com.dmdirc.FrameContainer;
25
+import com.dmdirc.WritableFrameContainer;
26
+import com.dmdirc.addons.ui_swing.MainFrame;
27
+import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
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.IntelligentCommand;
33
+import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
34
+import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.ui.input.AdditionalTabTargets;
36
+import com.dmdirc.ui.input.TabCompleter;
37
+
38
+/**
39
+ * Executes another command as if it were executed in the active window.
40
+ */
41
+public final class ActiveCommand extends Command implements CommandInfo,
42
+        IntelligentCommand {
43
+
44
+    /** Parent MainFrame. */
45
+    private final MainFrame mainFrame;
46
+
47
+    /**
48
+     * Creates a new active command.
49
+     *
50
+     * @param mainFrame Parent MainFrame
51
+     */
52
+    public ActiveCommand(final MainFrame mainFrame) {
53
+        super();
54
+        this.mainFrame = mainFrame;
55
+    }
56
+
57
+    /** {@inheritDoc} */
58
+    @Override
59
+    public void execute(final FrameContainer origin,
60
+            final CommandArguments args, final CommandContext context) {
61
+        final TextFrame frame = mainFrame.getActiveFrame();
62
+        if (frame.getContainer() instanceof WritableFrameContainer) {
63
+            ((WritableFrameContainer) frame.getContainer()).getCommandParser()
64
+                    .parseCommand(frame.getContainer(), context.getSource(),
65
+                    args.getArgumentsAsString());
66
+        }
67
+    }
68
+
69
+    /** {@inheritDoc} */
70
+    @Override
71
+    public String getName() {
72
+        return "active";
73
+    }
74
+
75
+    /** {@inheritDoc} */
76
+    @Override
77
+    public boolean showInHelp() {
78
+        return true;
79
+    }
80
+
81
+    /** {@inheritDoc} */
82
+    @Override
83
+    public CommandType getType() {
84
+        return CommandType.TYPE_GLOBAL;
85
+    }
86
+
87
+    /** {@inheritDoc} */
88
+    @Override
89
+    public String getHelp() {
90
+        return "active <command> - Executes the command as though it had been "
91
+                + "executed in the active window";
92
+    }
93
+
94
+    /** {@inheritDoc} */
95
+    @Override
96
+    public AdditionalTabTargets getSuggestions(final int arg,
97
+            final IntelligentCommandContext context) {
98
+        return TabCompleter.getIntelligentResults(arg, context, 0);
99
+    }
100
+}

+ 52
- 0
src/com/dmdirc/addons/activewindow/ActiveWindowPlugin.java ファイルの表示

@@ -0,0 +1,52 @@
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.activewindow;
24
+
25
+import com.dmdirc.addons.ui_swing.SwingController;
26
+import com.dmdirc.commandparser.CommandManager;
27
+import com.dmdirc.plugins.BasePlugin;
28
+import com.dmdirc.plugins.PluginManager;
29
+
30
+/**
31
+ * Plugin to provide an active window command to the Swing UI.
32
+ */
33
+public final class ActiveWindowPlugin extends BasePlugin {
34
+
35
+    /** The command we've registered. */
36
+    private ActiveCommand command;
37
+
38
+    /** {@inheritDoc} */
39
+    @Override
40
+    public void onLoad() {
41
+        command = new ActiveCommand(((SwingController) PluginManager
42
+                .getPluginManager().getPluginInfoByName("ui_swing")
43
+                .getPlugin()).getMainFrame());
44
+        CommandManager.registerCommand(command);
45
+    }
46
+
47
+    /** {@inheritDoc} */
48
+    @Override
49
+    public void onUnload() {
50
+        CommandManager.unregisterCommand(command);
51
+    }
52
+}

+ 26
- 0
src/com/dmdirc/addons/activewindow/package-info.java ファイルの表示

@@ -0,0 +1,26 @@
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
+/**
24
+ * Provides an active window command to the swing UI.
25
+ */
26
+package com.dmdirc.addons.activewindow;

+ 32
- 0
src/com/dmdirc/addons/activewindow/plugin.config ファイルの表示

@@ -0,0 +1,32 @@
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=0.1
27
+
28
+provides:
29
+  active command
30
+
31
+required-services:
32
+  swing ui

読み込み中…
キャンセル
保存