請參閱<<實現RCP自身的控制台>>和<<RCP實現Eclipse Console相關推薦文章>>

用法整理如下

1.依組件來使用,所以不需要使用showConsole()

只需要建立單例的 MessageConsole

public class ConsoleFactory {
    public static MessageConsole console = new MessageConsole("Netunit Console", null);

   public static MessageConsole getConsole() {
        return console;
    }
}

在view當中利用

TextConsoleViewer tcv = new TextConsoleViewer(consoleComposite, ConsoleFactory.getConsole());

即可輸出文字至tcv 上

2.依照view來使用

可在Perspective定義實現的位置 而view ID為IConsoleConstants.ID_CONSOLE_VIEW

因此在consoleFactory會定義如下段程式碼描述

  showConsoleJPG

其中25-35行 就是把console放在ConsolePlugin.getDefault().getConsoleManager()內作統一管理

36行 cosole view

38-39是接管system.out寫入conolse當中

 

 


輸出方法

                MessageConsoleStream printer = ConsoleFactory.console.newMessageStream();
                ConsoleFactory.showConsole();
                printer.println("Submit");

或是有使用System.setOut也可直接用System.out.priintln("XXXXMESSAGE")輸出訊息

創作者介紹
創作者 無語 的頭像
JKKLin

無語

JKKLin 發表在 痞客邦 留言(0) 人氣( 137 )