【发布时间】:2017-02-01 12:26:55
【问题描述】:
为了在我正在开发的插件的控制台中编写,我使用了我之前找到的这种方法。 我的工作
private static MessageConsole findConsole(String name) {
if (ConsolePlugin.getDefault() == null)
return null;
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
for (int i = 0; i < existing.length; i++)
if (name.equals(existing[i].getName())) {
conMan.showConsoleView(existing[i]);
return (MessageConsole) existing[i];
}
// no console found, so create a new one
MessageConsole myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole[] { myConsole });
return myConsole;
}
public static MessageConsoleStream getMessageStream() {
MessageConsole myConsole = findConsole("console");
if (myConsole != null) {
IWorkbench wb = PlatformUI.getWorkbench();
String id = IConsoleConstants.ID_CONSOLE_VIEW;
return myConsole.newMessageStream();
}
return null;
}
我是这样使用的:
MessageConsoleStream out = Application.getMessageStream();
out.print("AB");
现在我想从控制台读取。 我该怎么办?
【问题讨论】:
标签: java plugins eclipse-plugin