本文介绍了如何用不同的输入文本打开多个consoleview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Eclipse rcp应用程序
中单击一个swt按钮打开带有不同输入文本的多个控制台视图,有人可以告诉我吗?
谢谢。
i want to open multiple console view with different input text on single swt button click in eclipse rcp applicationCan anybody tell me about this ?Thank you.
推荐答案
添加org.eclipse.ui.console作为依赖项,之后您可以创建其他扩展名。
有关此实现的更多详细信息,您可以在此页面上找到。
Add org.eclipse.ui.console as dependency and after that you can create different extensions.
Some more details about the implementation you can find on this page http://www.eclipsezone.com/eclipse/forums/t66777.html.
此处是一个简单的实现():
Here a simple implementation (source):
plugin.xml
<plugin>
<extension point="org.eclipse.ui.console.consoleFactories">
<consoleFactory label="ConsoleX" class="console.Factory">
</consoleFactory>
</extension>
</plugin>
一流的工厂
package 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 Factory implements IConsoleFactory {
private static MessageConsole _console;
public void openConsole() {
MessageConsole console = getConsole();
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);
}
}
public static MessageConsole getConsole() {
if (_console == null) {
_console = new MessageConsole("ConsoleX",null);
}
return _console;
}
}
用法
Factory.getConsole().activate();
Factory.getConsole().newOutputStream().write("Hello world.".getBytes());
这篇关于如何用不同的输入文本打开多个consoleview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!