eclipse rcp控制台

时间:2014-05-13 01:39:20   收藏:0   阅读:340

ConsoleViewPart.java

package com.wbq.console;


import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleFactory;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;


public class ConsoleViewPart implements IConsoleFactory {

private static MessageConsole console = new MessageConsole("报文监控窗口", null);


public void openConsole() {
showConsole();
}


public static void showConsole() {
// try {
if (console != null) {
//得到默认控制台管理器
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
//得到所有的控制台实例
IConsole[] existing = manager.getConsoles();
boolean exists = false;
//新创建的MessageConsole实例不存在就加入到控制台管理器,并显示出来
for (int i = 0; i < existing.length; i++) {
if (console == existing[i])
exists = true;
}
if(!exists){
manager.addConsoles(new IConsole[] { console });
}
manager.showConsoleView(console);


// System.setOut(new PrintStream(stream));


}
// } catch (IOException e) {
// e.printStackTrace();
// }
}

public static void closeConsole() {
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
if (console != null) {
manager.removeConsoles(new IConsole[] { console });
}
}

public static MessageConsole getConsole(){
return console;
}

}


eclipse rcp控制台,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!