FormEditor的“与编辑器链接”

时间:2013-11-15 13:43:44

标签: eclipse-rcp

我正在寻找“与编辑器链接”的解决方案,但是对于FormEditor而不是http://murygin.wordpress.com/2012/06/13/link-eclipse-view-to-editor/

中描述的ViewPart

我尝试做类似的事情。但是“与编辑的联系”并没有触发任何行动。

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

我发现我可以使用“Navigator Link Helper”:

http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_navigator_linkHelper.html

Hier是我在plugin.xml中的代码:

<extension point="org.eclipse.ui.navigator.viewer">
   ...
   <viewerContentBinding ...>
      <includes>
         <contentExtension pattern="my.ui.navigator.linkHelper.myExplorer"/>
      </includes>
   </viewerContentBinding>
   ...
</extension>
<extension point="org.eclipse.ui.navigator.linkHelper">
   <linkHelper
             class="my.ui.navigator.MyExplorerLinkHelper"
             id="my.ui.navigator.linkHelper.myExplorer">
      <selectionEnablement>
     <or>
        <adapt type="org.eclipse.core.resources.IProject"/>
        <instanceof value="org.eclipse.core.resources.IProject"/>
         </or>
      </selectionEnablement>
      <editorInputEnablement>
     <or>
        <adapt type="org.eclipse.core.resources.IProject"/>
        <instanceof value="org.eclipse.core.resources.IProject"/>
         </or>
      </editorInputEnablement>
   </linkHelper>
</extension>

我实现了这个类:

public class MyExplorerLinkHelper implements ILinkHelper {
    @Override
    public IStructuredSelection findSelection(IEditorInput anInput) {
        ...
    }

    @Override
    public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) {
        ...
    }
}