Commit 642bc968 authored by Florian's avatar Florian

added draft for threshold filter

parent d6a0cba8
package kieker.tools.eclipse.analysis.filter;
import java.util.regex.Pattern;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import kieker.tools.eclipse.analysis.Activator;
import kieker.tools.eclipse.analysis.model.Properties;
/**
* Filter for Minimum and Maximum
*
* @author Florian Echternkamp
*/
public class ThresholdFilter extends ViewerFilter {
public enum Limit {
UPPER, LOWER
};
private Limit limitType;
private int colIndex;
private String searchString;
public ThresholdFilter() {
this(Limit.UPPER, 0);
}
/**
* Constructor for a TreeFilter for the column defined by the parameter
*
* @param i
* column index
*/
public ThresholdFilter(Limit l, int colIndex) {
limitType = l;
this.colIndex = colIndex;
}
/**
* Sets the filter string
*
* @param s
* string to filter
*/
public void setSearchText(String s) {
// literalize string to disable regular expressions, inputs like "test("
// for a method filter would otherwise lead to exceptions
s = Pattern.quote(s);
// add wildcards at the start and the end to also filter for objects
// which contains the search string
this.searchString = ".*" + s + ".*";
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
// empty search, all objects are true
if (searchString == null || searchString.length() == 0) {
return true;
}
TreeViewer treeViewer = (TreeViewer) viewer;
// checks if the index is in bounds of the column count
if (0 <= colIndex && colIndex < treeViewer.getTree().getColumns().length) {
ColumnLabelProvider labelProvider = (ColumnLabelProvider) treeViewer.getLabelProvider(colIndex);
String labelText = labelProvider.getText(element);
return labelText.matches(searchString);
}
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment