Pārlūkot izejas kodu

Merge pull request #452 from csmith/master

Migrate debug plugin to showOutput/showError.
pull/453/head
Greg Holmes 8 gadus atpakaļ
vecāks
revīzija
c48b23016f

+ 17
- 7
debug/src/com/dmdirc/addons/debug/Debug.java Parādīt failu

@@ -102,17 +102,27 @@ public class Debug extends Command implements IntelligentCommand {
102 102
     }
103 103
 
104 104
     /**
105
-     * Sends a line, if appropriate, to the specified target.
105
+     * Shows output, if appropriate, in the specified target.
106 106
      *
107 107
      * @param target   The command window to send the line to
108 108
      * @param isSilent Whether this command is being silenced or not
109
-     * @param type     The type of message to send
110
-     * @param args     The arguments of the message
109
+     * @param message  The message to be sent
111 110
      */
112
-    @Deprecated
113
-    public void proxySendLine(final WindowModel target,
114
-            final boolean isSilent, final String type, final Object... args) {
115
-        sendLine(target, isSilent, type, args);
111
+    public void proxyShowOutput(final WindowModel target,
112
+            final boolean isSilent, final String message) {
113
+        showOutput(target, isSilent, message);
114
+    }
115
+
116
+    /**
117
+     * Shows an error, if appropriate, in the specified target.
118
+     *
119
+     * @param target   The command window to send the line to
120
+     * @param isSilent Whether this command is being silenced or not
121
+     * @param message  The message to be sent
122
+     */
123
+    public void proxyShowError(final WindowModel target,
124
+            final boolean isSilent, final String message) {
125
+        showError(target, isSilent, message);
116 126
     }
117 127
 
118 128
     /**

+ 15
- 6
debug/src/com/dmdirc/addons/debug/DebugCommand.java Parādīt failu

@@ -86,16 +86,25 @@ public abstract class DebugCommand {
86 86
             final CommandArguments args, final CommandContext context);
87 87
 
88 88
     /**
89
-     * Sends a line, if appropriate, to the specified target.
89
+     * Shows output, if appropriate, in the specified target.
90 90
      *
91 91
      * @param target   The command window to send the line to
92 92
      * @param isSilent Whether this command is being silenced or not
93
-     * @param type     The type of message to send
94
-     * @param args     The arguments of the message
93
+     * @param message  The message to be sent
95 94
      */
96
-    public void sendLine(final WindowModel target,
97
-            final boolean isSilent, final String type, final Object... args) {
98
-        commandProvider.get().proxySendLine(target, isSilent, type, args);
95
+    public void showOutput(final WindowModel target, final boolean isSilent, final String message) {
96
+        commandProvider.get().proxyShowOutput(target, isSilent, message);
97
+    }
98
+
99
+    /**
100
+     * Shows an error, if appropriate, in the specified target.
101
+     *
102
+     * @param target   The command window to send the line to
103
+     * @param isSilent Whether this command is being silenced or not
104
+     * @param message  The message to be sent
105
+     */
106
+    public void showError(final WindowModel target, final boolean isSilent, final String message) {
107
+        commandProvider.get().proxyShowError(target, isSilent, message);
99 108
     }
100 109
 
101 110
     /**

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/ColourSpam.java Parādīt failu

@@ -61,7 +61,7 @@ public class ColourSpam extends DebugCommand {
61 61
     public void execute(@Nonnull final WindowModel origin,
62 62
             final CommandArguments args, final CommandContext context) {
63 63
         for (int i = 0; i < 100; i++) {
64
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
64
+            showOutput(origin, args.isSilent(),
65 65
                     ((char) 3) + "5Colour! "
66 66
                     + ((char) 3) + "6Colour! " + ((char) 3) + "7Colour! "
67 67
                     + ((char) 3) + "6Colour! " + ((char) 3) + "7Colour! "

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/ConfigInfo.java Parādīt failu

@@ -62,7 +62,7 @@ public class ConfigInfo extends DebugCommand {
62 62
     public void execute(@Nonnull final WindowModel origin,
63 63
             final CommandArguments args, final CommandContext context) {
64 64
         for (ConfigProvider source : origin.getConfigManager().getSources()) {
65
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, source.getTarget()
65
+            showOutput(origin, args.isSilent(), source.getTarget()
66 66
                     + " - " + source + "(" + source.getTarget().getOrder()
67 67
                     + ")");
68 68
         }

+ 2
- 2
debug/src/com/dmdirc/addons/debug/commands/ForceUpdate.java Parādīt failu

@@ -93,9 +93,9 @@ public class ForceUpdate extends DebugCommand {
93 93
         if (globalConfig.getOptionBool("updater", "enable")) {
94 94
             UpdateChecker.checkNow(updateManager, identityController, "Forced update checker");
95 95
         } else {
96
-            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Update checking is "
96
+            showError(origin, args.isSilent(), "Update checking is "
97 97
                     + "currently disabled.  You can enable it by typing:");
98
-            sendLine(origin, args.isSilent(), FORMAT_ERROR, Styliser.CODE_FIXED
98
+            showError(origin, args.isSilent(), Styliser.CODE_FIXED
99 99
                     + "    /set updater enable true");
100 100
         }
101 101
     }

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/GlobalConfigInfo.java Parādīt failu

@@ -72,7 +72,7 @@ public class GlobalConfigInfo extends DebugCommand {
72 72
     public void execute(@Nonnull final WindowModel origin,
73 73
             final CommandArguments args, final CommandContext context) {
74 74
         for (ConfigProvider source : globalConfig.getSources()) {
75
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, source.getTarget()
75
+            showOutput(origin, args.isSilent(), source.getTarget()
76 76
                     + " - " + source + "(" + source.getTarget().getOrder()
77 77
                     + ")");
78 78
         }

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/Identities.java Parādīt failu

@@ -88,7 +88,7 @@ public class Identities extends DebugCommand {
88 88
                 String.valueOf(source.getTarget().getOrder())};
89 89
         }
90 90
 
91
-        sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
91
+        showOutput(origin, args.isSilent(),
92 92
                 doTable(new String[]{"Name", "Target", "Data", "Priority"}, data));
93 93
     }
94 94
 

+ 3
- 3
debug/src/com/dmdirc/addons/debug/commands/MemInfo.java Parādīt failu

@@ -60,11 +60,11 @@ public class MemInfo extends DebugCommand {
60 60
     @Override
61 61
     public void execute(@Nonnull final WindowModel origin,
62 62
             final CommandArguments args, final CommandContext context) {
63
-        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Total Memory: "
63
+        showOutput(origin, args.isSilent(), "Total Memory: "
64 64
                 + Runtime.getRuntime().totalMemory());
65
-        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Free Memory: "
65
+        showOutput(origin, args.isSilent(), "Free Memory: "
66 66
                 + Runtime.getRuntime().freeMemory());
67
-        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Used Memory: "
67
+        showOutput(origin, args.isSilent(), "Used Memory: "
68 68
                 + (Runtime.getRuntime().totalMemory()
69 69
                 - Runtime.getRuntime().freeMemory()));
70 70
     }

+ 2
- 2
debug/src/com/dmdirc/addons/debug/commands/Notify.java Parādīt failu

@@ -65,10 +65,10 @@ public class Notify extends DebugCommand {
65 65
             final CommandArguments args, final CommandContext context) {
66 66
         final Optional<Colour> colour = origin.getUnreadStatusManager().getNotificationColour();
67 67
         if (colour.isPresent()) {
68
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
68
+            showOutput(origin, args.isSilent(),
69 69
                     "Current notification colour is: " + colour.get());
70 70
         } else {
71
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
71
+            showOutput(origin, args.isSilent(),
72 72
                     "No current notification colour");
73 73
         }
74 74
     }

+ 1
- 2
debug/src/com/dmdirc/addons/debug/commands/RunGC.java Parādīt failu

@@ -61,8 +61,7 @@ public class RunGC extends DebugCommand {
61 61
     public void execute(@Nonnull final WindowModel origin,
62 62
             final CommandArguments args, final CommandContext context) {
63 63
         System.gc();
64
-        sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
65
-                "Invoked garbage collector.");
64
+        showOutput(origin, args.isSilent(), "Invoked garbage collector.");
66 65
     }
67 66
 
68 67
 }

+ 6
- 7
debug/src/com/dmdirc/addons/debug/commands/ServerInfo.java Parādīt failu

@@ -66,23 +66,22 @@ public class ServerInfo extends DebugCommand {
66 66
         final Optional<Connection> optionalConnection = origin.getConnection();
67 67
         if (optionalConnection.isPresent()) {
68 68
             final Connection connection = optionalConnection.get();
69
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Server name: "
69
+            showOutput(origin, args.isSilent(), "Server name: "
70 70
                     + connection.getAddress());
71
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Actual name: "
71
+            showOutput(origin, args.isSilent(), "Actual name: "
72 72
                     + connection.getParser().get().getServerName());
73
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Network: "
73
+            showOutput(origin, args.isSilent(), "Network: "
74 74
                     + connection.getNetwork());
75
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "IRCd: "
75
+            showOutput(origin, args.isSilent(), "IRCd: "
76 76
                     + connection.getParser().get().getServerSoftware() + " - "
77 77
                     + connection.getParser().get().getServerSoftwareType());
78
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Modes: "
78
+            showOutput(origin, args.isSilent(), "Modes: "
79 79
                     + connection.getParser().get().getBooleanChannelModes() + ' '
80 80
                     + connection.getParser().get().getListChannelModes() + ' '
81 81
                     + connection.getParser().get().getParameterChannelModes() + ' '
82 82
                     + connection.getParser().get().getDoubleParameterChannelModes());
83 83
         } else {
84
-            sendLine(origin, args.isSilent(), FORMAT_ERROR,
85
-                    "This window isn't connected to a server");
84
+            showError(origin, args.isSilent(), "This window isn't connected to a server");
86 85
         }
87 86
     }
88 87
 

+ 2
- 3
debug/src/com/dmdirc/addons/debug/commands/ServerState.java Parādīt failu

@@ -65,11 +65,10 @@ public class ServerState extends DebugCommand {
65 65
             final CommandArguments args, final CommandContext context) {
66 66
         final Optional<Connection> optionalConnection = origin.getConnection();
67 67
         if (optionalConnection.isPresent()) {
68
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
68
+            showOutput(origin, args.isSilent(),
69 69
                     optionalConnection.get().getStatus().getTransitionHistory());
70 70
         } else {
71
-            sendLine(origin, args.isSilent(), FORMAT_ERROR,
72
-                    "This window isn't connected to a server");
71
+            showError(origin, args.isSilent(), "This window isn't connected to a server");
73 72
         }
74 73
     }
75 74
 

+ 4
- 5
debug/src/com/dmdirc/addons/debug/commands/Services.java Parādīt failu

@@ -72,14 +72,13 @@ public class Services extends DebugCommand implements IntelligentCommand {
72 72
     @Override
73 73
     public void execute(@Nonnull final WindowModel origin,
74 74
             final CommandArguments args, final CommandContext context) {
75
-        sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Available Services:");
75
+        showOutput(origin, args.isSilent(), "Available Services:");
76 76
         for (Service service : serviceManager.getAllServices()) {
77
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "    "
78
-                    + service.toString());
77
+            showOutput(origin, args.isSilent(), "    " + service);
79 78
             if (args.getArguments().length > 0
80
-                    && args.getArguments()[0].equals("full")) {
79
+                    && "full".equals(args.getArguments()[0])) {
81 80
                 for (ServiceProvider provider : service.getProviders()) {
82
-                    sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
81
+                    showOutput(origin, args.isSilent(),
83 82
                             "            " + provider.getProviderName()
84 83
                             + " [Active: " + provider.isActive() + "]");
85 84
                 }

+ 1
- 2
debug/src/com/dmdirc/addons/debug/commands/ShowRaw.java Parādīt failu

@@ -69,8 +69,7 @@ public class ShowRaw extends DebugCommand {
69 69
         if (connection.isPresent()) {
70 70
             windowFactory.getRawWindow(connection.get());
71 71
         } else {
72
-            sendLine(origin, args.isSilent(), FORMAT_ERROR,
73
-                    "Cannot show raw window here.");
72
+            showError(origin, args.isSilent(), "Cannot show raw window here.");
74 73
         }
75 74
     }
76 75
 

+ 2
- 4
debug/src/com/dmdirc/addons/debug/commands/Threads.java Parādīt failu

@@ -65,12 +65,10 @@ public class Threads extends DebugCommand {
65 65
             final CommandArguments args, final CommandContext context) {
66 66
         for (Entry<Thread, StackTraceElement[]> thread
67 67
                 : Thread.getAllStackTraces().entrySet()) {
68
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, Styliser.CODE_BOLD
69
-                    + thread.getKey().getName());
68
+            showOutput(origin, args.isSilent(), Styliser.CODE_BOLD + thread.getKey().getName());
70 69
 
71 70
             for (StackTraceElement element : thread.getValue()) {
72
-                sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
73
-                        Styliser.CODE_FIXED + "    " + element.toString());
71
+                showOutput(origin, args.isSilent(), Styliser.CODE_FIXED + "    " + element);
74 72
             }
75 73
         }
76 74
     }

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/Time.java Parādīt failu

@@ -83,7 +83,7 @@ public class Time extends DebugCommand implements IntelligentCommand {
83 83
             final long start = System.currentTimeMillis();
84 84
             origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(0));
85 85
             final long end = System.currentTimeMillis();
86
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
86
+            showOutput(origin, args.isSilent(),
87 87
                     "Command executed in " + (end - start) + " milliseconds.");
88 88
         }
89 89
     }

Notiek ielāde…
Atcelt
Saglabāt