Eclipse 向现有Gui添加新的透视图
因此,我一直在开发一个具有不同视图的单一透视图的GUI。但现在我们需要另一种不同观点的新视角。我一直在网上寻找添加透视图的示例和教程,但没有找到我想要的 附加的图像显示了我的GUI。在“示例菜单”中,我希望有一个菜单项可以打开我的新透视图 我试图解决这个问题,是想在原有的基础上添加另一个视角,但什么也没发生。 我的下一个想法是将第二个透视图的打开添加为第一个透视图菜单中的一个动作。但我不知道该怎么做,也不知道这是否是正确的方法。插件的一个片段如下所示Eclipse 向现有Gui添加新的透视图,eclipse,user-interface,plugins,view,perspective,Eclipse,User Interface,Plugins,View,Perspective,因此,我一直在开发一个具有不同视图的单一透视图的GUI。但现在我们需要另一种不同观点的新视角。我一直在网上寻找添加透视图的示例和教程,但没有找到我想要的 附加的图像显示了我的GUI。在“示例菜单”中,我希望有一个菜单项可以打开我的新透视图 我试图解决这个问题,是想在原有的基础上添加另一个视角,但什么也没发生。 我的下一个想法是将第二个透视图的打开添加为第一个透视图菜单中的一个动作。但我不知道该怎么做,也不知道这是否是正确的方法。插件的一个片段如下所示 您确实需要添加一个菜单项来打开
您确实需要添加一个菜单项来打开新的透视图。此操作的代码类似于Eclipse
ShowPerspectiveHandler
:
IWorkbench workbench=PlatformUI.getWorkbench();
IWorkbenchWindow activeWorkbenchWindow=workbench.getActiveWorkbenchWindow();
IWorkbenchPage activePage=activeWorkbenchWindow.getActivePage();
IPerspectiveDescriptor desc=workbench.getPerspectiveRegistry().findPerspectiveWithId(perspectiveId);
setPerspective(desc);
(为了清晰起见,省略了大量错误检查)
<perspective
name="RCP Perspective"
class="chipcoach.Perspective"
id="ChipCoach.perspective">
</perspective>
<perspective
class="chipcoach.Perspective2"
id="ChipCoach.perspective2"
name="PopupPerspective">
</perspective>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="ChipCoach.perspective">
</perspectiveExtension>
<perspectiveExtension
targetID="ChipCoach.perspective2">
</perspectiveExtension>
</extension>
<extension
point="org.eclipse.ui.actionSets">
<actionSet
id="ChipCoach.actionSet"
label="Sample Action Set"
visible="true">
<menu
id="sampleMenu"
label="Sample &Menu">
<separator
name="sampleGroup">
</separator>
</menu>
<action
class="chipcoach.actions.SampleAction"
icon="icons/sample.gif"
id="chipcoach.actions.SampleAction"
label="&Sample Action"
menubarPath="sampleMenu/sampleGroup"
toolbarPath="sampleGroup"
tooltip="Hello, Eclipse world">
</action>
<action
class="chipcoach.actions.OpenPerspective1"
icon="icons/sample.gif"
id="chipcoach.actions.openPerspective1"
label="&Open Perspective"
menubarPath="sampleMenu/sampleGroup"
style="push"
toolbarPath="sampleGroup">
</action>
</actionSet>