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 04:44 Go to next message
Zongyong Qin is currently offline Zongyong Qin
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 04:43 Go to previous message
Zongyong Qin is currently offline Zongyong Qin
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:trying to get white space/empty space within a jface listviewer
Next Topic:Action and updateTargets(): strange behaviour
Goto Forum:
  


Current Time: Sat Aug 30 16:27:03 EDT 2014

Powered by FUDForum. Page generated in 0.08563 seconds