我可能是我的回答晚了,但這裏是我能夠做到的(和它的工作對我來說):
我創造了我的控制檯基於此教程http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F,並修改了findConsole方法看起來像這樣的:
private MessageConsole findConsole(String name) {
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
//if console exists, clear it
for (int i = 0; i < existing.length; i++)
if (name.equals(existing[i].getName())){
((MessageConsole) existing[i]).clearConsole(); //this is the important part
return myConsole;
}
myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole[]{myConsole});
return myConsole;
}
因此,在其他一些按鈕/控制/監聽器什麼的,我有:
myConsole = findConsole(ASIO_RECORD_OUTPUT);
myConsoleOut = myConsole.newMessageStream();
,每當這段代碼被執行,我的控制檯被清除。希望能幫助到你。
編輯:忘了提,我在創建RCP應用程序時做了這個!
https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429 –
對不起,但clear()方法沒有爲java.io.Console定義http://docs.oracle.com/javase /7/docs/api/java/io/Console.html – lfergon