Search in sources :

Example 16 with ParseResult

use of org.eclipse.nebula.widgets.nattable.filterrow.ParseResult in project nebula.widgets.nattable by eclipse.

the class FilterRowUtils method parseExpression.

/**
 * Parses the text entered in the filter row. The text is parsed to figure
 * out the type of match operation (<, > etc.) and the value next to
 * it.
 *
 * @param string
 *            entered by the user in the filter row text box
 */
public static ParseResult parseExpression(String string) {
    Scanner scanner = new Scanner(string.trim());
    ParseResult parseResult = new ParseResult();
    // $NON-NLS-1$
    Pattern p = Pattern.compile("<>|([>|<]?=?)");
    String opToken = scanner.findWithinHorizon(p, 2);
    if (isNotEmpty(opToken)) {
        parseResult.setMatchType(MatchType.parse(opToken));
        while (scanner.hasNext()) {
            parseResult.setValueToMatch(scanner.next());
        }
    } else {
        parseResult.setValueToMatch(string);
    }
    scanner.close();
    return parseResult;
}
Also used : Scanner(java.util.Scanner) Pattern(java.util.regex.Pattern) ParseResult(org.eclipse.nebula.widgets.nattable.filterrow.ParseResult)

Example 17 with ParseResult

use of org.eclipse.nebula.widgets.nattable.filterrow.ParseResult in project nebula.widgets.nattable by eclipse.

the class FilterRowUtils method parseLiteral.

public static ParseResult parseLiteral(String string) {
    ParseResult parseResult = new ParseResult();
    parseResult.setMatchType(MatchType.NONE);
    parseResult.setValueToMatch(string);
    return parseResult;
}
Also used : ParseResult(org.eclipse.nebula.widgets.nattable.filterrow.ParseResult)

Aggregations

ParseResult (org.eclipse.nebula.widgets.nattable.filterrow.ParseResult)17 Test (org.junit.Test)14 BasicEventList (ca.odell.glazedlists.BasicEventList)1 CompositeMatcherEditor (ca.odell.glazedlists.matchers.CompositeMatcherEditor)1 MatcherEditor (ca.odell.glazedlists.matchers.MatcherEditor)1 TextMatcherEditor (ca.odell.glazedlists.matchers.TextMatcherEditor)1 ThresholdMatcherEditor (ca.odell.glazedlists.matchers.ThresholdMatcherEditor)1 Comparator (java.util.Comparator)1 Scanner (java.util.Scanner)1 Pattern (java.util.regex.Pattern)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 IDisplayConverter (org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter)1 MatchType (org.eclipse.nebula.widgets.nattable.filterrow.ParseResult.MatchType)1 TextMatchingMode (org.eclipse.nebula.widgets.nattable.filterrow.TextMatchingMode)1 Ignore (org.junit.Ignore)1