package de.tudresden.slr.model.bibtex.ui.presentation;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.dialogs.PatternFilter;

import de.tudresden.slr.model.bibtex.Document;

public class BibtexFilter extends PatternFilter {
	/**
	 * Check if the current (leaf) element is a match with the filter text. The
	 * default behavior checks that the label of the element is a match.
	 * 
	 * Subclasses should override this method.
	 * 
	 * @param viewer
	 *            the viewer that contains the element
	 * @param element
	 *            the tree element to check
	 * @return true if the given element's label matches the filter text
	 */
	@Override
	protected boolean isLeafMatch(Viewer viewer, Object element) {
		if (!(element instanceof Document)) {
			return false;
		}
		String labelText = ((ILabelProvider) ((StructuredViewer) viewer)
				.getLabelProvider()).getText(element);

		if (labelText == null) {
			return false;
		}
		return wordMatches(labelText) || contentMatches((Document) element);
	}

	/**
	 * Return whether or not if any property of the document matches the
	 * criteria.
	 * 
	 * @param element
	 * @return
	 */
	private boolean contentMatches(Document element) {
		for (String s : element.getAuthors()) {
			if (wordMatches(s)) {
				return true;
			}
		}
		return wordMatches(element.getAbstract());
	}
}

@@ -47,24 +47,56 @@
 ntation;%0D%0A%0D%0A
+import java.util.LinkedList;%0D%0A%0D%0A
 import org.e
@@ -322,16 +322,62 @@
 cument;%0D
+%0Aimport de.tudresden.slr.model.taxonomy.Term;%0D
 %0A%0D%0Apubli
@@ -1513,24 +1513,427 @@
 %0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A
+%09%09LinkedList%3CTerm%3E terms = new LinkedList%3CTerm%3E();%0D%0A%09%09if (element.getTaxonomy() != null && element.getTaxonomy().getDimensions() != null)%7B%0D%0A%09%09%09terms.addAll(element.getTaxonomy().getDimensions());%0D%0A%09%09%7D%0D%0A%09%09while(!terms.isEmpty())%7B%0D%0A%09%09%09Term t = terms.remove();%0D%0A%09%09%09if (wordMatches(t.getName()))%7B%0D%0A%09%09%09%09return true;%0D%0A%09%09%09%7D%0D%0A%09%09%09if (t.getSubclasses() != null)%7B%0D%0A%09%09%09%09terms.addAll(t.getSubclasses());%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A
 %09%09return wor

check taxonomy while filtering