簡體   English   中英

eclipse rcp應用程序中的快速視圖

[英]Fast views in eclipse rcp application

如何在我的eclipse rcp應用程序中添加快速視圖?

您可以添加正確的按鈕,如在此主題中

這可以通過向快速查看欄添加按鈕並在按鈕事件中打開標准視圖來完成

按鈕按鈕=新按鈕((復合)((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:通過標准命令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並確定視圖是否應作為快速視圖打開。

如果沒有參數,該命令將允許用戶選擇要打開的視圖。

有關示例,請參閱命令的參數

讓我們看看現實世界的例子:“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>

參數的所有可能值的列表由ViewParameterValuesViewParameterValues 該類將遍歷視圖注冊表並返回它。


注意:理論上只是為了完整( 這個主題

RCP應用程序可以通過從WorkbenchAdvisorpreWindowOpen()方法調用WorkbenchWindowConfigurer.setShowFastViewBar(false)來禁用快速視圖。
這不僅會隱藏快速視圖欄,還會隱藏視圖上的“快速查看”菜單項。

向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,則無需創建新的IWorkbenchWindowsConfigurer。 此方法告訴工作台顯示快速欄,並且新的快速視圖透視圖擴展應該在啟動時存在。

我從Lars Vogel撰寫的Eclipse Papercuts文章中獲得了這些信息: http ://www.vogella.de/blog/2009/09/15/fastview-eclipse-rcp/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM