在RCP应用程序中切换控制台的视图 [英] Toggle the view of the Console in a RCP application

查看:77
本文介绍了在RCP应用程序中切换控制台的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个显示控制台的RCPP应用程序。在关闭控制台的那一刻,除非重新启动应用程序,否则无法再次打开它。

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");
    }

来自ApplicationWorkbenchAdvisor。

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?

推荐答案

请参阅此先前的答案,这是一个示例如何显示视图。

See this previous answer which is an example of how to show a view.

在RCP应用程序中切换控制台视图

这篇关于在RCP应用程序中切换控制台的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆