Browse Source

Merge pull request #452 from csmith/master

Migrate debug plugin to showOutput/showError.
pull/453/head
Greg Holmes 8 years ago
parent
commit
c48b23016f

+ 17
- 7
debug/src/com/dmdirc/addons/debug/Debug.java View File

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
      * @param target   The command window to send the line to
107
      * @param target   The command window to send the line to
108
      * @param isSilent Whether this command is being silenced or not
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 View File

86
             final CommandArguments args, final CommandContext context);
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
      * @param target   The command window to send the line to
91
      * @param target   The command window to send the line to
92
      * @param isSilent Whether this command is being silenced or not
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 View File

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

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/ConfigInfo.java View File

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

+ 2
- 2
debug/src/com/dmdirc/addons/debug/commands/ForceUpdate.java View File

93
         if (globalConfig.getOptionBool("updater", "enable")) {
93
         if (globalConfig.getOptionBool("updater", "enable")) {
94
             UpdateChecker.checkNow(updateManager, identityController, "Forced update checker");
94
             UpdateChecker.checkNow(updateManager, identityController, "Forced update checker");
95
         } else {
95
         } else {
96
-            sendLine(origin, args.isSilent(), FORMAT_ERROR, "Update checking is "
96
+            showError(origin, args.isSilent(), "Update checking is "
97
                     + "currently disabled.  You can enable it by typing:");
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
                     + "    /set updater enable true");
99
                     + "    /set updater enable true");
100
         }
100
         }
101
     }
101
     }

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/GlobalConfigInfo.java View File

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

+ 1
- 1
debug/src/com/dmdirc/addons/debug/commands/Identities.java View File

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

+ 3
- 3
debug/src/com/dmdirc/addons/debug/commands/MemInfo.java View File

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

+ 2
- 2
debug/src/com/dmdirc/addons/debug/commands/Notify.java View File

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

+ 1
- 2
debug/src/com/dmdirc/addons/debug/commands/RunGC.java View File

61
     public void execute(@Nonnull final WindowModel origin,
61
     public void execute(@Nonnull final WindowModel origin,
62
             final CommandArguments args, final CommandContext context) {
62
             final CommandArguments args, final CommandContext context) {
63
         System.gc();
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 View File

66
         final Optional<Connection> optionalConnection = origin.getConnection();
66
         final Optional<Connection> optionalConnection = origin.getConnection();
67
         if (optionalConnection.isPresent()) {
67
         if (optionalConnection.isPresent()) {
68
             final Connection connection = optionalConnection.get();
68
             final Connection connection = optionalConnection.get();
69
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Server name: "
69
+            showOutput(origin, args.isSilent(), "Server name: "
70
                     + connection.getAddress());
70
                     + connection.getAddress());
71
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Actual name: "
71
+            showOutput(origin, args.isSilent(), "Actual name: "
72
                     + connection.getParser().get().getServerName());
72
                     + connection.getParser().get().getServerName());
73
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Network: "
73
+            showOutput(origin, args.isSilent(), "Network: "
74
                     + connection.getNetwork());
74
                     + connection.getNetwork());
75
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "IRCd: "
75
+            showOutput(origin, args.isSilent(), "IRCd: "
76
                     + connection.getParser().get().getServerSoftware() + " - "
76
                     + connection.getParser().get().getServerSoftware() + " - "
77
                     + connection.getParser().get().getServerSoftwareType());
77
                     + connection.getParser().get().getServerSoftwareType());
78
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Modes: "
78
+            showOutput(origin, args.isSilent(), "Modes: "
79
                     + connection.getParser().get().getBooleanChannelModes() + ' '
79
                     + connection.getParser().get().getBooleanChannelModes() + ' '
80
                     + connection.getParser().get().getListChannelModes() + ' '
80
                     + connection.getParser().get().getListChannelModes() + ' '
81
                     + connection.getParser().get().getParameterChannelModes() + ' '
81
                     + connection.getParser().get().getParameterChannelModes() + ' '
82
                     + connection.getParser().get().getDoubleParameterChannelModes());
82
                     + connection.getParser().get().getDoubleParameterChannelModes());
83
         } else {
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 View File

65
             final CommandArguments args, final CommandContext context) {
65
             final CommandArguments args, final CommandContext context) {
66
         final Optional<Connection> optionalConnection = origin.getConnection();
66
         final Optional<Connection> optionalConnection = origin.getConnection();
67
         if (optionalConnection.isPresent()) {
67
         if (optionalConnection.isPresent()) {
68
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
68
+            showOutput(origin, args.isSilent(),
69
                     optionalConnection.get().getStatus().getTransitionHistory());
69
                     optionalConnection.get().getStatus().getTransitionHistory());
70
         } else {
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 View File

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

+ 1
- 2
debug/src/com/dmdirc/addons/debug/commands/ShowRaw.java View File

69
         if (connection.isPresent()) {
69
         if (connection.isPresent()) {
70
             windowFactory.getRawWindow(connection.get());
70
             windowFactory.getRawWindow(connection.get());
71
         } else {
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 View File

65
             final CommandArguments args, final CommandContext context) {
65
             final CommandArguments args, final CommandContext context) {
66
         for (Entry<Thread, StackTraceElement[]> thread
66
         for (Entry<Thread, StackTraceElement[]> thread
67
                 : Thread.getAllStackTraces().entrySet()) {
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
             for (StackTraceElement element : thread.getValue()) {
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 View File

83
             final long start = System.currentTimeMillis();
83
             final long start = System.currentTimeMillis();
84
             origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(0));
84
             origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(0));
85
             final long end = System.currentTimeMillis();
85
             final long end = System.currentTimeMillis();
86
-            sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
86
+            showOutput(origin, args.isSilent(),
87
                     "Command executed in " + (end - start) + " milliseconds.");
87
                     "Command executed in " + (end - start) + " milliseconds.");
88
         }
88
         }
89
     }
89
     }

Loading…
Cancel
Save