Eclipse plugin 我的eclipse插件控制台中的终止按钮
我已经在xtext中开发了一个eclipse插件,我需要在控制台中编写一些消息。 为此,我看到了这个网站,然后实现了以下代码:Eclipse plugin 我的eclipse插件控制台中的终止按钮,eclipse-plugin,Eclipse Plugin,我已经在xtext中开发了一个eclipse插件,我需要在控制台中编写一些消息。 为此,我看到了这个网站,然后实现了以下代码: private static MessageConsole findConsole(String name) { if (ConsolePlugin.getDefault() == null) return null; ConsolePlugin plugin = ConsolePlugin.getDefault(); ICon
private static MessageConsole findConsole(String name) {
if (ConsolePlugin.getDefault() == null)
return null;
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
for (int i = 0; i < existing.length; i++)
if (name.equals(existing[i].getName())) {
conMan.showConsoleView(existing[i]);
return (MessageConsole) existing[i];
}
// no console found, so create a new one
MessageConsole myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole[] { myConsole });
return myConsole;
}
public MessageConsoleStream getMessageStream() {
MessageConsole myConsole = findConsole("console");
if (myConsole != null) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
String id = IConsoleConstants.ID_CONSOLE_VIEW;
IConsoleView view;
try {
view = (IConsoleView) page.showView(id);
view.display(myConsole);
return myConsole.newMessageStream();
} catch (PartInitException e) {
e.printStackTrace();
}
}
return null;
}
private static MessageConsole findConsole(字符串名称){
if(ConsolePlugin.getDefault()==null)
返回null;
ConsolePlugin plugin=ConsolePlugin.getDefault();
IConsoleManager conMan=plugin.getConsoleManager();
IConsole[]existing=conMan.getConsoles();
for(int i=0;i
我已经将org.eclipse.ui.console添加到plugin.xml>dependencies>required plugins
当我想打印一些消息时:
MessageConsoleStream out=getMessageStream();
out.println(…)
它正在发挥作用。但我需要一个“终止按钮”在我的控制台,这似乎是不够的代码。
我该怎么做?
谢谢。这与控制台没有任何关系。您希望创建一个,它只需将一个按钮添加到现有视图的工具栏区域。还有一个问题。或者你可能想咨询一下医生