【问题标题】:Fast views in eclipse rcp applicationeclipse rcp 应用程序中的快速视图
【发布时间】:2010-10-20 05:41:27
【问题描述】:

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

【问题讨论】:

    标签: eclipse eclipse-rcp


    【解决方案1】:

    可以添加右键,如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.makeFast”的命令“org.eclipse.ui.views.showView”以编程方式显示和最小化快速视图。

    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,
    • 下一个具有ID org.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 应用可以通过调用WorkbenchWindowConfigurer.setShowFastViewBar(false) 来禁用快速视图 WorkbenchAdvisorpreWindowOpen() 方法。
    这不仅隐藏了快速视图栏,还隐藏了视图上的快速视图菜单项。

    【讨论】:

      【解决方案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/

      【讨论】:

        猜你喜欢
        • 2011-11-24
        • 2023-03-24
        • 1970-01-01
        • 2013-11-12
        • 1970-01-01
        • 1970-01-01
        • 2012-07-06
        • 2023-04-07
        • 1970-01-01
        相关资源
        最近更新 更多