Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to get filtered elements in a viewer ?
How to get filtered elements in a viewer ? [message #519971] Wed, 10 March 2010 16:46
Olivier Thierry is currently offline Olivier ThierryFriend
Messages: 11
Registered: January 2010
Location: Nantes, France
Junior Member
Hi,

I added filters (i.e. a class that extends ViewerFilter) to both a TableViewer and a CheckboxTreeViewer and it works OK. Now I need to get the elements that are displayed after the filter was applied. But I was surprised I couldn't find any method for this in viewer (while you have methods to get selected elements or checked elements).

Finally I could do it by calling
viewer.getTable().getItems()
or
viewer.getTree().getItems()
and then calling getData method for each item.

Something like this for example with a TableViewer :

List<Rejet> rejets = new ArrayList<Rejet>();
for (TableItem item : viewer().getTable().getItems()) {
	rejets.add((Rejet) item.getData());
}


It works but I don't find this very pretty ... And it can turn complex when you need to iterate on a tree for example to get all elements ! Is it the only way to do this ? Or did I miss something ?

Regards,

Olivier

[Updated on: Wed, 10 March 2010 16:47]

Report message to a moderator

Previous Topic:Jface unit tests
Next Topic:Lazy Loading in JFace
Goto Forum:
  


Current Time: Tue Nov 25 22:24:59 GMT 2014

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

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