【问题标题】:Switch between perspectives in rcp在 rcp 中切换透视图
【发布时间】:2015-03-25 21:26:13
【问题描述】:

我有一个包含两个视角的 rcp 应用程序。从一个角度来看,我有一棵树。在双击树的任何项目时,它会打开所选树项目的详细信息,但在相同的透视图中。我想在双击时切换视角,而不是在同一视角中打开所选项目的详细信息。我该怎么做?

我的双击监听器是

 // Add double click listener to open an element editor on double click action:
    getViewer().addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (currentTreeSelection instanceof StoreableElement) {
                openElementContentEditor((StoreableElement)currentTreeSelection);
            }

        }
    }); 

内容编辑器是显示所选树项详细信息的部分。

 public void openElementContentEditor(StoreableElement element) {

    ElementDescriptor ed = DataStoreManagement.getInstance().getElementDescriptorById(element.getDescriptor());
    String editorID = ed.getEditor();
    IDataStoreEditorInput editorInput = DataStoreManagement.getInstance().createEditorInput(element);

    try {
        PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow()
                .getActivePage()
                .openEditor(editorInput, editorID, true,
                        IWorkbenchPage.MATCH_INPUT);

    } catch (PartInitException e) {
        e.printStackTrace();
    }
}

谢谢

【问题讨论】:

    标签: java eclipse-plugin eclipse-rcp perspective


    【解决方案1】:

    我使用如下sn-p切换视角:

    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    workbenchWindow.getWorkbench().showPerspective("PERSPECTIVE_ID", workbenchWindow);
    

    【讨论】:

      猜你喜欢
      • 2012-07-16
      • 1970-01-01
      • 1970-01-01
      • 2012-04-28
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多