eclipse rcp应用程序中的快速视图

时间:2010-04-30 08:39:20

标签: eclipse eclipse-rcp

如何在我的eclipse rcp应用程序中添加快速视图?

2 个答案:

答案 0 :(得分:2)

您可以添加右键,如this thread

  

可以通过向快速查看栏添加按钮并在按钮事件中打开标准视图来完成

按钮按钮= new Button((Composite)((WorkbenchWindow)窗口).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: open a view via standard command org.eclipse.ui.handlers.ShowViewHandler

  

Eclipse提供标准命令org.eclipse.ui.views.showView来打开任意视图   默认处理程序为org.eclipse.ui.handlers.ShowViewHandler。这个处理程序是一个很好的例子,你可以用参数添加自己的命令。它需要两个参数:

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

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

有关示例

,请参阅 Parameter for commands
  

让我们看看现实世界的例子:“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给出。该类将遍历视图注册表并返回它。


注意:理论上(this thread

只是完整
  

RCP应用可以通过调用WorkbenchWindowConfigurer.setShowFastViewBar(false)来禁用快速视图   WorkbenchAdvisor的{​​{1}}方法   这不仅会隐藏快速视图栏,还会隐藏视图上的“快速查看”菜单项。

答案 1 :(得分: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>

添加此扩展程序后,我们还必须在工作区中显示快速视图栏。为此,请编辑ApplicationWorkbenhWindowAdvisor(或启动工作台窗口的其他顾问程序),并将以下行添加到preWindowOpen()方法中:

IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setShowFastViewBars(true);

如果您已经拥有IWorkbenchWindowsConfigurer,则无需重新创建。此方法告诉工作台显示快速栏,并且新的快速视图透视图扩展应该在启动时存在。

我从Lars Vogel撰写的Eclipse Papercuts文章中获得了这些信息:http://www.vogella.de/blog/2009/09/15/fastview-eclipse-rcp/