“link with editor” for FormEditor

2020-04-16 03:48发布

问题:

I am looking for a solution of "link with editor" but for FormEditor instead of ViewPart as described in http://murygin.wordpress.com/2012/06/13/link-eclipse-view-to-editor/

I try to do similar. But the "link with editor" does not fire any action.

Thanks for help!

回答1:

I found out that I could use "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 is my code in 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>

I implemented the class:

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

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


标签: eclipse-rcp