2010-04-30 32 views

回答

2

您可以添加右键,在​​:

,可以通过添加一个按钮来快速视图栏和按钮事件

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: open a view via standard command org.eclipse.ui.handlers.ShowViewHandler参见:

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

  • 第一有IDorg.eclipse.ui.views.showView.viewId和识别哪个应当打开的视图ID,
  • 下一个具有IDorg.eclipse.ui.views.showView.makeFast,并且确定如果视图应该是作为快速视图中打开。

没有参数,该命令将让用户选择打开哪个视图。

的一些例子

让我们看到现实世界的例子见Parameter for commands: “显示视图” 命令。该命令是通用的,可以显示任何视图。视图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应用程序可以从他们 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> 

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

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

如果你已经有一个IWorkbenchWindowsConfigurer,你不需要做一个新的。此方法告诉工作台显示快速栏,并且您的新快速视图透视图扩展应该在启动时存在。

我从一篇由Lars Vogel编写的Eclipse Papercuts文章中得到这个信息:http://www.vogella.de/blog/2009/09/15/fastview-eclipse-rcp/

相关问题