XViewer Depth First Search Filter and CustomizeManager [message #1071218] |
Fri, 19 July 2013 15:23 |
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:
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 |
ramukumar M Messages: 14 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
BR
Ramukumar M
[Updated on: Wed, 24 September 2014 10:38] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03086 seconds