Help! an issue after removed the filter [message #642669] |
Thu, 02 December 2010 04:44  |
Eclipse User |
|
|
|
Hi,
I get a problem when use the filter to a CheckboxTreeViewer, could anyone help me?
I add a filter, which is just to return the checked elements, to a CheckboxTreeViewer, the filter is like:
class TreeFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
ItemRecord record = (ItemRecord) element;
return repositoryTree.getChecked(record);
}
}
it works to filter the tree, but after that ,I removed this filter, the problem is happened: the before checked item is unchecked automatically, if add this fiter agian, it can't work well any more.
I create a check box to add or remove the filter, the code is like:
showSelectBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showSelectBTN.getSelection()) {
repositoryTree.addFilter(treeFilter);
} else {
repositoryTree.removeFilter(treeFilter);
repositoryTree.expandAll();
}
}
});
any suggestion is appreciated!
Regards,
Zongyong
|
|
|
Re: Help! an issue after removed the filter [message #674523 is a reply to message #642669] |
Fri, 27 May 2011 04:43  |
Eclipse User |
|
|
|
Finally, I got a workround,I got the checked element before remove the filter, and set them checked after do that, am I on the right way to do that?
ItemRecord[] elements = getElements();
repositoryTree.removeFilter(treeFilter);
repositoryTree.expandAll();
repositoryTree.setCheckedElements(elements);
any suggestion is appreciated!
Regards,
Zongyong
|
|
|
Powered by
FUDForum. Page generated in 0.02899 seconds