Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » XViewer Depth First Search Filter and CustomizeManager(Don't filter out parent element if children match)
XViewer Depth First Search Filter and CustomizeManager [message #1071218] Fri, 19 July 2013 15:23 Go to next message
Erik Englund is currently offline Erik EnglundFriend
Messages: 49
Registered: July 2009
Member
I would like XViewer to support a depth first search algorithm. In that if any of the children match it should also match the parent.

I accomplished this by overriding the getXViewerTextFilter method in my XViewer and returning an XViewer with following select method:

public boolean select(Viewer viewer, Object parentElement, Object element) {
		ITreeContentProvider cp = (ITreeContentProvider) this.xViewer.getContentProvider();
		boolean retVal = super.select(viewer, parentElement, element);
		if (retVal) {
			return true;
		}
		if (cp.hasChildren(element)) {
			for (Object child : cp.getChildren(element)) {
				retVal = select(viewer, element, child);
				if (retVal) {
					break;
				}
			}
		}
		return retVal;
	}


This seems to work. Is there a better method?

Also, I'd like it to automatically expand to show all matching children. Unfortunately, it looks like to do this I would need to change the behavior of the CustomizeManager in the setFilterText method to do:
xViewer.expandAll();


At the end of the method. However, there is no way to provide my own implementation of the CustomizeManager as it is a private field created in the constructor of the XViewer. Suggestions? It would be nice if the XViewerFactory provided a mechanism to provide my own CustomizeManager.

Thanks.
Re: XViewer Depth First Search Filter and CustomizeManager [message #1430391 is a reply to message #1071218] Wed, 24 September 2014 10:21 Go to previous message
ramukumar M is currently offline ramukumar MFriend
Messages: 7
Registered: June 2012
Junior Member
Hi
Thanks for the code. It help's me.

Do you find the solution to own implementation of the CustomizeManager?

I found a workaround I am not sure, it is the right way.
In the my XViewer, override the refresh method as follow

  @Override
  public void refresh() {
    super.refresh();
    if (getCustomizeMgr().getFilterText().isEmpty()) {
     // This is collapse entire tree when no filter is applied
      collapseAll();
    }
    else {
      expandAll();
    }
  }


Please let me know if this is right approach Smile


BR
Ramukumar M

[Updated on: Wed, 24 September 2014 10:38]

Report message to a moderator

Previous Topic:Grid with Row header problems viewing last column group
Next Topic:GanttChart Event Position after zoom
Goto Forum:
  


Current Time: Sat Dec 20 23:04:29 GMT 2014

Powered by FUDForum. Page generated in 0.01482 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software