Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Calling viewer.update(element, ...) on a filtered object does not 'unfilter' it.
Calling viewer.update(element, ...) on a filtered object does not 'unfilter' it. [message #485678] Mon, 14 September 2009 12:57
Florian Hackenberger is currently offline Florian HackenbergerFriend
Messages: 123
Registered: July 2009
Senior Member

I'm on eclipse 3.4 and I'm using the jface TableViewer. The viewer has a
filter which filters objects if the property 'hidden' is true.
Say we have an element 'test1' which has the property hidden initially set
to true, so the viewer does not display it.
The property changes to false, and we want the viewer to reflect the change
(unhide the element).
According to the docs of StructuredViewer.update(Object, String[]):
* If the viewer has a filter which is affected by a change to one of the
* properties, the element may appear or disappear if the change affects
* whether or not the element is filtered out.
the element should be visible after calling viewer.update(element, new
String[] { "hidden" }), it is still hidden however. The test code is below.
BTW: The filter always returns true for isFilterProperty(...).

Can someone please tell me if I have overlooked something obvious, or point
me to a bug report, if that actually is a bug?


public class TableViewTest /* extends ViewPart */{
public static final String ID = "test.TableViewTest"; //$NON-NLS-1$

TableViewer viewer;

public class ViewerContent {
public ViewerContent(boolean hidden, String title) {
this.hidden = hidden;
this.title = title;
public boolean hidden = false;
public String title;

public ViewerContent[] content = new ViewerContent[] {
new ViewerContent(true, "test1"),
new ViewerContent(false, "test2")

public void createPartControl(Composite parent) {
Composite comp = new Composite(parent, parent.getStyle());

Button button = new Button(comp, SWT.TOGGLE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
button.setText("show element test1");
button.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
public void widgetSelected(SelectionEvent e) {
content[0].hidden = !content[0].hidden;
// Does not work (contrary to the docs)
viewer.update(content[0], new String[] { "hidden" });
// Does not work either
// Works

// Define the viewer
viewer = new TableViewer(comp);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true,

viewer.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {
public Object[] getElements(Object inputElement) {
return content;
viewer.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
return ((ViewerContent)element).title;
viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
public boolean isFilterProperty(Object element, String property) {
return true;
public boolean select(Viewer viewer, Object parentElement,
Object element) {
return !((ViewerContent)element).hidden;
viewer.setInput(new Object[] {});
public void setFocus() {

DI Florian Hackenberger
Previous Topic:Treeviewer losing expand/collapse boxes when jarred
Next Topic:How To Tie A Toolbar Button To A Specific Perspective?
Goto Forum:

Current Time: Thu May 24 21:37:27 GMT 2018

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

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

Back to the top