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
Erik Englund is currently offline Erik Englund
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.
Previous Topic:Efficiently Filling a grid
Next Topic:Copy and Paste in Nebula Grid
Goto Forum:
  


Current Time: Thu Sep 18 01:44:36 GMT 2014

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

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