2010-04-30 30 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/

相關問題