Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » On changing the ViewerFilter on my TableViewer doesn't impose a refiltering
On changing the ViewerFilter on my TableViewer doesn't impose a refiltering [message #290593] Fri, 26 August 2005 15:12
Eclipse UserFriend
Originally posted by: Shelley.Cristol.rmb.co.za

I have an SWT.Table with a TableViewer and a ViewerFilter for displaying
messages in the table. There are 4 types of messages and the filtering of
these messages is controlled by the user. Each time the user changes the
filtering, I remove the old filter and add another filter. My problem is
that the select method in the filter is only accessed the very first time
when data is loaded into the table and not when the user changes the
filter making the filter null and void.

I've googled for the phrases TableViewer and ViewerFilter but have not
found anything that was useful for my purposes. I've also checked FAQ's on
this site and others to no avail.

Here is the code that calls my filter and the actual filter class, if
anyone has any pointers for me, it would be greatly appreciated. The
constant resetFilters and refresh of the tableViewer may seem like
overkill, but I was just trying various options. I also tried adding extra
elements into the table to force a refiltering...


// The initial adding of the filter, after adding the data the
// select method of the ErrorViewerFilter is accessed but not again
filter = new ErrorViewerFilter(new ErrorLevelList());
tv.addFilter(filter);

// The method I call on prompting by the user to change the filter
protected void setViewerFilter(ErrorLevelList list) {
tv.removeFilter(filter);
tv.resetFilters();
filter = new ErrorViewerFilter(list);

tv.addFilter(filter);
tv.resetFilters();
tv.refresh();
}


protected class ErrorViewerFilter extends ViewerFilter {

protected Pattern error = null;
protected Pattern warning = null;
protected Pattern info = null;
protected Pattern critical = null;

public ErrorViewerFilter(ErrorLevelList list) {
if(list == null)
return;
for(int i = 0; i < list.getErrorLevels().size(); i++) {
if ((list.getErrorLevel(i)).equals("ERROR"))
error = Pattern.compile(list.getErrorLevel(i));
if ((list.getErrorLevel(i)).equals("WARNING"))
warning = Pattern.compile(list.getErrorLevel(i));
if ((list.getErrorLevel(i)).equals("INFORMATION"))
info = Pattern.compile(list.getErrorLevel(i));
if ((list.getErrorLevel(i)).equals("CRITICAL"))
critical = Pattern.compile(list.getErrorLevel(i));
}
}

public boolean select(Viewer viewer, Object parentElement, Object
element)
{
boolean result = false;

if (error != null)
result =
error.matcher(((ExceptionVO)element).getERROR_LEVEL().trim() ).matches();
if (warning != null)
result =
warning.matcher(((ExceptionVO)element).getERROR_LEVEL().trim ()).matches();
if (info != null)
result =
info.matcher(((ExceptionVO)element).getERROR_LEVEL().trim()) .matches();
if (critical != null)
result =
critical.matcher(((ExceptionVO)element).getERROR_LEVEL().tri m()).matches();

return result;
}
}
}
Previous Topic:"symbol gdk_font_equal: referenced symbol not found" when trying to run Eclipse 3.1 on Sol
Next Topic:Eclipse internal design (component diagrams or similar needed)
Goto Forum:
  


Current Time: Tue Apr 23 15:42:22 GMT 2024

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

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

Back to the top