添加keyevent以在IPageLayout下切换ViewPart

时间:2011-08-15 06:10:59

标签: java user-interface swt eclipse-rcp

如何为不同的viewpart分配切换焦点的键??

示例:(按“SWT.F7”关注viewpartA,“SWT.F8”关注viewpartB)

public class UserPerspective implements IPerspectiveFactory{
    ......
    ......
    public void createInitialLayout(IPageLayout layout){
        final IFolderLayout leftPanel = layout.createFolder(......);
        leftPanel.addView(viewpartA.ID);

        final IFolderLayout rightPanel = layout.createFolder(......);
        rightPanel.addView(viewpartB.ID);
    }
}

1 个答案:

答案 0 :(得分:2)

您可以使用以下键绑定。仔细阅读序列的文档 - 这有点棘手: - )

下面的value属性是目标视图的ID。

<extension
      point="org.eclipse.ui.bindings">
   <key
         commandId="org.eclipse.ui.views.showView"
         schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
         sequence="F6">
      <parameter
            id="org.eclipse.ui.views.showView.viewId"
            value="com.rcpcompany.so.ed.view">
      </parameter>
   </key>
   <key
         commandId="org.eclipse.ui.views.showView"
         schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
         sequence="SHIFT+F6">
      <parameter
            id="org.eclipse.ui.views.showView.viewId"
            value="com.rcpcompany.so.ed.view1">
      </parameter>
   </key>
</extension>