【问题标题】:How to contribute a new view in eclipse 4.2?如何在 Eclipse 4.2 中贡献一个新视图?
【发布时间】:2012-07-03 04:55:12
【问题描述】:

我正在尝试使用 Eclipse 4 API。我尝试使用插件贡献一个新视图。到目前为止我所拥有的是:

org.eclipse.e4.workbench.model 的扩展

<plugin>
   <extension id="id1" point="org.eclipse.e4.workbench.model">
      <fragment uri="fragment.e4xmi"></fragment>
   </extension>
</plugin>

fragment.e4xmi

<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmi:id="_r_EgIEXDEeGuDquXwerIpw">
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_rC_ngEXFEeGuDquXwerIpw">
    <elements xsi:type="basic:Part" xmi:id="_sQq7kEXFEeGuDquXwerIpw" elementId="test.TestView2" contributionURI="platform:/plugin/test/test.TestView2" label="TestView2" tooltip="Test Test Test" closeable="true"/>
  </fragments>
</fragment:ModelFragments>

我的视图实现:

package test;

import javax.inject.Inject;
import org.eclipse.e4.ui.di.Focus;

public class TestView2 {
    @Inject
    public TestView2() {
    }

    @Focus
    public void onFocus() {
    }
}

由于某种原因,该视图似乎没有被贡献。我错过了什么吗?我需要其他东西来完成这个谜题吗?如何调试问题?

编辑:

我想问题是,我的 String Model Fragment 没有 Element Id 也没有 Featurename。我想我必须插入 PartStackchildren 的 ID 作为 Featurename。问题:编辑器没有在向导中显示任何元素来选择Element Id ...

【问题讨论】:

    标签: java eclipse eclipse-plugin


    【解决方案1】:

    Eclipse 4.2 IDE 可能无法做到这一点。

    如您所述,必须设置元素 ID 和功能。通过使用模型编辑器 (Alt+Shift+F9) 可以看到 IDE 使用的应用程序 ID 为 org.eclipse.e4.legacy.ide.application,因此原则上您可以按照 Lars Vogel tutorial例如,向 IDE 提供命令、处理程序和菜单项,然后该命令可以打开您的视图。

    虽然如果您为自己的 E4 应用程序做出贡献,这可以正常工作,但当您尝试为 Eclipse 4.2 IDE 做出贡献时,它会失败,因为Bug 376486 - “Eclipse 4 IDE 无法通过片段或处理器扩展”。

    据我了解,问题在于 Eclipse 3 兼容层创建 E4 模型的方式是您无法向其中添加自己的 E4 片段。

    【讨论】:

    • 但实际上这意味着没有兼容层的eclipse 4 ide是不可扩展的!?您不能使用新 API 贡献视图???
    • 您仍然可以通过 Eclipse 3 机制对其进行扩展:在 plugin.xml 中定义视图或编辑器。但是您不能将 Eclipse 4 模型片段添加到 4.2 IDE,因为它使用的是兼容层。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-26
    • 1970-01-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 2011-06-12
    • 2011-12-08
    相关资源
    最近更新 更多