切换 RCP 应用程序中控制台的视图
我正在开发一个显示控制台的 RCPP 应用程序。目前,当我关闭控制台时,除非重新启动应用程序,否则无法再次打开它。
因此,我添加了一个新的菜单项来显示和隐藏控制台作为扩展点,并为其创建了一个处理程序。我可以检查控制台是否存在,但问题是当它关闭时它实际上是隐藏的并且没有被处理。
<pre>
private Console() {
super("", null);
setWaterMarks(-1, -1);
infoStream = newOutputStream();
errorStream = newOutputStream();
warnStream = newOutputStream();
infoColor = new Color(DioAction.getDisplay(), new RGB(0, 0, 0));
infoStream.setColor(infoColor);
warnColor = new Color(DioAction.getDisplay(), new RGB(255, 128, 0));
warnStream.setColor(warnColor);
errorColor = new Color(DioAction.getDisplay(), new RGB(255, 0, 0));
errorStream.setColor(errorColor);
}
public static Console getDefault() {
if (instance == null) {
instance = new Console();
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
IConsole[] existing = manager.getConsoles();
boolean exists = false;
for (int i = 0; i < existing.length; i++) {
if (instance == existing[i])
exists = true;
}
if (!exists)
manager.addConsoles(new IConsole[] { instance });
manager.showConsoleView(instance);
}
return instance;
}
public void info(String message) {
try {
infoStream.write(message);
infoStream.write("\n");
} catch (IOException e) {
e.printStackTrace();
}
}
</pre>
当我调用此方法时添加控制台:
@Override public void postStartup() { super.postStartup(); Console.getDefault().info("Hello"); }
从 ApplicationWorkbenchAdvisor。
我的问题是我应该如何检测控制台是否已关闭/隐藏并在选择菜单项时显示它?
I am developing a RCPP application which displays a Console. For the moment when I close the Console I cannot open it again unless I restart the application.
So I added a new menu item to show and hide the console as an extension point and created a handler for it. I can check whether the console exists but the problem is that when it closes it is actually hidden and not disposed of.
<pre>
private Console() {
super("", null);
setWaterMarks(-1, -1);
infoStream = newOutputStream();
errorStream = newOutputStream();
warnStream = newOutputStream();
infoColor = new Color(DioAction.getDisplay(), new RGB(0, 0, 0));
infoStream.setColor(infoColor);
warnColor = new Color(DioAction.getDisplay(), new RGB(255, 128, 0));
warnStream.setColor(warnColor);
errorColor = new Color(DioAction.getDisplay(), new RGB(255, 0, 0));
errorStream.setColor(errorColor);
}
public static Console getDefault() {
if (instance == null) {
instance = new Console();
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
IConsole[] existing = manager.getConsoles();
boolean exists = false;
for (int i = 0; i < existing.length; i++) {
if (instance == existing[i])
exists = true;
}
if (!exists)
manager.addConsoles(new IConsole[] { instance });
manager.showConsoleView(instance);
}
return instance;
}
public void info(String message) {
try {
infoStream.write(message);
infoStream.write("\n");
} catch (IOException e) {
e.printStackTrace();
}
}
</pre>
The console is added when I call this method:
@Override public void postStartup() { super.postStartup(); Console.getDefault().info("Hello"); }
from the ApplicationWorkbenchAdvisor.
My question is how should I detect whether the console has been closed/hidden and show it when I select the menu item?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅之前的答案,这是如何显示视图的示例。
切换 RCP 应用程序中控制台的视图
See this previous answer which is an example of how to show a view.
Toggle the view of the Console in a RCP application