首先在Perspective中加上
IFolderLayout folderLayout = layout.createFolder("folder", IPageLayout.BOTTOM,0.70f, editorArea);
folderLayout.addView(IConsoleConstants.ID_CONSOLE_VIEW);
就可以显示Console了,然后在创建它的控制者:
package com.netunit.workbench.sys;
import java.io.PrintStream;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
/**
* Console Factory
*
* @author 何明
*
*/
public class ConsoleFactory {
public static MessageConsole console = new MessageConsole("Netunit Console",
null);
public void openConsole() {
showConsole();
}
public static void showConsole() {
if (console != null) {
IConsoleManager manager = ConsolePlugin.getDefault()
.getConsoleManager();
IConsole[] existing = manager.getConsoles();
boolean exists = false;
for (int i = 0; i < existing.length; i++) {
if (console == existing[i])
exists = true;
}
if (!exists) {
manager.addConsoles(new IConsole[] { console });
}
manager.showConsoleView(console);
MessageConsoleStream stream = console.newMessageStream();
System.setOut(new PrintStream(stream));
}
}
public static void closeConsole() {
IConsoleManager manager = ConsolePlugin.getDefault()
.getConsoleManager();
if (console != null) {
manager.removeConsoles(new IConsole[] { console });
}
}
public static MessageConsole getConsole() {
return console;
}
}
然后在调用的地方加上一下代码即可
MessageConsoleStream printer =ConsoleFactory.console.newMessageStream();
ConsoleFactory.showConsole();
printer.print("aaaaaaaaaa\n");
不过这样就不符合规范了,最好的方法就是写个静态方法带String参数,传进去的参数就是你想要输出的东西,
不信就试一试,不过在写代码之前别忘了基本的,就是先得添加org.eclipse.ui.console扩展点,控制台就轻而易举的实现了,够简单吧
分享到:
相关推荐
Eclipse rcp 实现文本内容对比功能,可自己选取对比的文件进行比较
Eclipse RCP富客户端平台,基于Eclipse开发的。
Eclipse RCP 软件打包发布方法。之前花了5分下了一个教材,更不不好用。现在自己摸索写了一个,绝对赞~
EclipseRCP教程EclipseRCP教程EclipseRCP教程
Eclipse 4 RCP 测试项目 基于
eclipse使用内部浏览器加载echarts,过程中可能存在鼠标移动事件不响应,这个是eclipse浏览器中与echarts.js内兼容问题,该问题可通过修改echarts.js解决,如果找不到可以私信我
RCP for eclipse3.4 ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
TC13-Teamcenter开发模式之RCP_Eclipse 配置手册 TC13 Eclipse 配置手册 Teamcenter13,TC12开发,TC11开发 软件 Eclipse 配置手册 Teamcenter13,TC12开发,TC11开发 软件 Eclipse 配置方法
Eclipse富客户端平台RCP程序使用的中文语言包。用于开发Eclipse插件或RCP富客户端平台使用。
Eclipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作. ...
eclipse rcp应用系统开发方法与实战的代码文件
RCP经典,rcp eclipse
clipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作 ...
网络上能够找到的最详细的EclipseRcp教程
基于eclipse RCP实现的邮件管理客户端,是一个比较完整的eclipse RCP例子,国内少有的资源,比较适合想学习eclipse RCP技术,而又不知道从何下手的网友。
EclipseRcp 例子程序
eclipse rcp check table
rcp]-eclipse_rcp
Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT
教你如何学习eclipse rcp rcp技术是eclipse使用更灵活