Filtering contents in Eclipse Common Navigator Framework view

ぃ、小莉子 提交于 2019-12-11 15:07:14

问题


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:

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

What is the accurate way to do it?


回答1:


  • 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, 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!



来源:https://stackoverflow.com/questions/47507660/filtering-contents-in-eclipse-common-navigator-framework-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!