如何将文件与 Eclipse 插件中的透视图关联起来

发布于 2024-10-09 22:52:28 字数 464 浏览 0 评论 0原文

我已经为 eclipse 创建了一个与文件扩展名 .eap 关联的编辑器插件,

我还创建了一个包含此数据视图的透视图。

我想添加以下行为:当我双击 .eap 文件时,我希望打开 EAP 透视图。

就像您第一次单击 Java 文件时所发生的情况一样。

任何帮助表示赞赏!

将要


    try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        workbench.showPerspective(EapPerspective.ID,
                workbench.getActiveWorkbenchWindow());
    } catch (WorkbenchException e) {
        e.printStackTrace();
    }

I have created an editor plug-in for eclipse that is associated with the file extension .eap

I have also created a perspective that contains views for this data.

I would like to add the following behaviour: When I double click on the .eap file I'd like the EAP Perspective to be opened.

Just like what happens when you click on a Java file for the first time.

Any help appreciated!

Will


    try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        workbench.showPerspective(EapPerspective.ID,
                workbench.getActiveWorkbenchWindow());
    } catch (WorkbenchException e) {
        e.printStackTrace();
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

逆流 2024-10-16 22:52:28

据我所知,第一次点击或打开Java文件并不会打开Java透视图。然而,也许您在想,使用“新建 Java 类向导”后,如何提示您更改为 Java 透视图。

无论如何,您可以执行以下操作:

  • 在 org.eclipse.ui.newWizards 扩展点中,指定 FinalPerspective 以及 PreferredPerspectives
  • 假设您已子类化 AbstractTextEditor,则重写 setFocus() 方法并添加一些逻辑以更改为适当的视角,如下所示(但要小心添加特定的 null 检查):

    getEditorSite().getWorkbenchWindow().getWorkbench().showPerspective(desc.getId(),
    getWindow(), pageInput);

推荐第一个解决方案,尽管它不会涵盖您要求的所有情况,而第二个解决方案有点顽皮,因为它违反了 Eclipse 约定。

As far as I know, clicking on or opening a Java file for the first time will not open the Java perspective. However, perhaps you are thinking about how after using the New Java Class Wizard, you are prompted to change to the Java perspective.

Regardless, there are several things that you can do:

  • In the org.eclipse.ui.newWizards extension point, specify the finalPerspective as well as preferredPerspectives
  • Assuming that you have sub-classed AbstractTextEditor, then override the setFocus() method and add some logic to change to the appropriate perspective, something like this (but be careful to add specific null checks):

    getEditorSite().getWorkbenchWindow().getWorkbench().showPerspective(desc.getId(),
    getWindow(), pageInput);

The first solution is recommended, although it will not cover all the cases that you are asking for, and the second is a bit naughty as it goes against Eclipse conventions.

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