/*
* (non-Javadoc) Method declared on ViewerFilter.
*/
public boolean select(Viewer viewer, Object parentElement,
Object element) {
StringMatcher matcher = getMatcher();
if (matcher == null || !(viewer instanceof TableViewer)) {
return true;
}
TableViewer tableViewer = (TableViewer) viewer;
String matchName = ((ILabelProvider) tableViewer.getLabelProvider())
.getText(element);
if(matchName == null) {
return false;
}
// A dirty editor's label will start with dirty prefix, this prefix
// should not be taken in consideration when matching with a pattern
String prefix = DefaultTabItem.DIRTY_PREFIX;
if (matchName.startsWith(prefix)) {
matchName = matchName.substring(prefix.length());
}
return matchName != null && matcher.match(matchName);
}