在Eclipse Common Navigator Framework视图中过滤内容 [英] Filtering contents in Eclipse Common Navigator Framework view

查看:107
本文介绍了在Eclipse Common Navigator Framework视图中过滤内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于3.x的Eclipse RCP应用程序。在应用程序部分,我将实现Eclipse本身的Common-navigator插件,以便在工作区中显示资源。我已经创建了如下所示的导航器视图:

I am developing a 3.x based Eclipse RCP application. In the part of application, I am implementing Common-navigator plugin of Eclipse itself, in order to display resources in the workspace. I'have created the navigator view shown below:

但是我只想显示一个树子元素。更具体地说,我只希望显示 clause 文件夹及其元素。

But I would like display only one tree child element. More specifically, I only want clause folder and its elements to be shown.

准确的方法是

推荐答案


  • 添加 org.eclipse.ui.navigator的依赖项(如果在plugin.xml中不存在。)

  • 添加扩展点 org.eclipse.ui.navigator.navigatorContent 在扩展选项卡中。

  • 在其下创建 CommonFilter 并将您的值提供给右侧的属性。

  • 创建一个扩展'org.eclipse.jface.viewers.ViewerFilter'的类,并在覆盖的公共布尔选择(查看器查看器,Object parentElement,Object元素)中实现逻辑$ c>(注意:返回true会在Navigator中保留资源,否则它将被隐藏)。

  • 在CommonFilter中的class属性的扩展名中配置此扩展类。

  • 然后您就可以进行测试了。

    • Add dependecy of org.eclipse.ui.navigator if not exists in plugin.xml.
    • Add extension point org.eclipse.ui.navigator.navigatorContent in extension tab.
    • Create CommonFilter under that and provide your values to the properties on the right.
    • Create a class which extends 'org.eclipse.jface.viewers.ViewerFilter' and implement you logic in overridden public boolean select(Viewer viewer, Object parentElement, Object element) (Note : return true would retain the resource in Navigator otherwise it will be hidden).
    • Configure this extended class in extension for class property in CommonFilter.
    • And you are good to go for testing.
    • BTW,这个方法是在所有导航器中添加通用过滤器。如果需要为特定的导航器进行配置,则需要获取其视图,然后使查看器脱离该视图,并将过滤器附加到查看器。为此,您可能需要一个触发点,例如菜单/按钮/启动扩展!

      BTW, this way is adding common filter to across all the Navigator. If you need to configure for particular navigator then you need to get its view and then get viewer out of it and attach your filter to viewer. To achieve this you may need a trigger point e.g., a menu/button/startup extension!

      这篇关于在Eclipse Common Navigator Framework视图中过滤内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆