在Eclipse RCP应用程序中快速视图

3
如何将快速查看添加到我的Eclipse RCP应用程序?
2个回答

2
您可以像这个主题中所述的那样添加正确的按钮:
通过将按钮添加到快速视图栏并在按钮事件中打开标准视图来完成。
Button button = new Button((Composite)((WorkbenchWindow) window).getFastViewBar().getControl(), SWT.PUSH);
为了避免在按钮事件中重叠,首先创建此视图的文件夹布局,并参考初始视图,然后调用操作以添加视图。
IFolderLayout ViewLayout1 = layout.createFolder ( "ViewLayout1",
                                                  IPageLayout.BOTTOM,
                                                  0.50f, initalView.ID);
OpenViewAction ov = new OpenViewAction (window, "label", secondview.ID);
ov.run ();

通过命令“org.eclipse.ui.views.showView”和参数“org.eclipse.ui.views.showView.makeFast”,可以以编程方式显示和最小化快速视图。

请参见Eclipse RCP:通过标准命令org.eclipse.ui.handlers.ShowViewHandler打开视图

Eclipse提供了标准命令org.eclipse.ui.views.showView,可打开任意视图。
默认处理程序是org.eclipse.ui.handlers.ShowViewHandler。该处理程序是如何添加带有参数的自定义命令的良好示例。它具有两个参数:

  • 第一个参数具有IDorg.eclipse.ui.views.showView.viewId,并标识应打开的视图ID,
  • 下一个参数具有ID org.eclipse.ui.views.showView.makeFast ,并确定是否将视图作为快速视图打开。

如果没有参数,该命令将允许用户选择要打开的视图。

请参见命令的参数以获取一些示例

让我们看看一个实际的示例:“Show View”命令。该命令是通用的,可以显示任何视图。将视图ID作为参数提供给命令:

<command
     name="%command.showView.name"
     description="%command.showView.description"
     categoryId="org.eclipse.ui.category.views"
     id="org.eclipse.ui.views.showView"
     defaultHandler="org.eclipse.ui.handlers.ShowViewHandler">
  <commandParameter
         id="org.eclipse.ui.views.showView.viewId"
         name="%command.showView.viewIdParameter"
         values="org.eclipse.ui.internal.registry.ViewParameterValues" />
  <commandParameter
     id="org.eclipse.ui.views.showView.makeFast"
     name="%command.showView.makeFastParameter"
     optional="true"/>
</command>

可能的参数值列表由类ViewParameterValues给出。该类将遍历视图注册表并返回结果。
注意:为了完整起见,在理论上(参见此线程),RCP应用程序可以通过从其WorkbenchAdvisorpreWindowOpen()方法调用WorkbenchWindowConfigurer.setShowFastViewBar(false)来禁用快速视图。这不仅会隐藏快速视图栏,还会隐藏视图上的“快速视图”菜单项。

2

在Eclipse RCP或RAP应用程序中添加快速视图的简单方法是先创建一个普通视图。在插件xml中,为该视图(我称其为fast.view)添加一个新的扩展,具有正确的属性。

<view
    closable="true"
    id="fast.view"
    minimized="true"
    ratio=".30f"
    relationship="fast" <--- This attribute tells the view to be a fast view.
    relative="other.view"
</view>

在添加此扩展后,我们还必须在工作区中显示快速查看栏。为此,请编辑ApplicationWorkbenchWindowAdvisor(或其他启动工作台窗口的顾问),并将以下行添加到preWindowOpen()方法中:
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setShowFastViewBars(true);

如果您已经有了IWorkbenchWindowsConfigurer,就不需要再创建一个新的。这个方法告诉工作台显示快速栏,在启动时您的新快速视图透视扩展应该会出现在那里。
我从Lars Vogel撰写的Eclipse Papercuts文章中获取了这些信息:http://www.vogella.de/blog/2009/09/15/fastview-eclipse-rcp/

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接