Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Help! an issue after removed the filter(an issue after removed the filter in CheckboxTreeViewer)
icon5.gif  Help! an issue after removed the filter [message #642669] Thu, 02 December 2010 09:44 Go to next message
Zongyong Qin is currently offline Zongyong QinFriend
Messages: 4
Registered: December 2010
Junior Member
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 08:43 Go to previous message
Zongyong Qin is currently offline Zongyong QinFriend
Messages: 4
Registered: December 2010
Junior Member
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
Previous Topic:Why the label provider isn't triggered as soon as the refresh method is called?
Next Topic:StructuredViewer useHashlookup
Goto Forum:
  


Current Time: Thu Apr 25 08:02:18 GMT 2024

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

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

Back to the top