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

发布于 2025-01-04 04:42:35 字数 1975 浏览 1 评论 0原文

我正在开发一个显示控制台的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空袭的梦i 2025-01-11 04:42:35

请参阅之前的答案,这是如何显示视图的示例。

切换 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文