在 rcp 中切换视角
Switch between perspectives in rcp
我有一个包含两个透视图的 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();
}
}
谢谢
我使用以下代码片段来切换视角:
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
workbenchWindow.getWorkbench().showPerspective("PERSPECTIVE_ID", workbenchWindow);
我有一个包含两个透视图的 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();
}
}
谢谢
我使用以下代码片段来切换视角:
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
workbenchWindow.getWorkbench().showPerspective("PERSPECTIVE_ID", workbenchWindow);