use of org.eclipse.tracecompass.tmf.core.filter.ITmfFilter in project tracecompass by tracecompass.
the class ColorSettingsManager method getColorSetting.
/**
* Gets the color settings that matches the filter for given event.
*
* @param event
* The event to check
*
* @return color settings defined for filter if found else default color
* settings
*/
public static ColorSetting getColorSetting(ITmfEvent event) {
for (int i = 0; i < fColorSettings.length; i++) {
ColorSetting colorSetting = fColorSettings[i];
ITmfFilter filter = colorSetting.getFilter();
if (filter != null && filter.matches(event)) {
return colorSetting;
}
}
return DEFAULT_COLOR_SETTING;
}
use of org.eclipse.tracecompass.tmf.core.filter.ITmfFilter in project tracecompass by tracecompass.
the class TmfFilterHelperTest method testInputRegexNot.
/**
* Test a negative regex on an && regex
*/
@Test
public void testInputRegexNot() {
String regex = "!(" + FIELD1_NAME + " matches .*afield.* && " + FIELD2_NAME + " present)";
ITmfFilter filter = getFilter(regex);
ITmfEventAspect<@NonNull Object> aspectF1 = TmfBaseAspects.getContentsAspect().forField(FIELD1_NAME);
ITmfEventAspect<@NonNull Object> aspectF2 = TmfBaseAspects.getContentsAspect().forField(FIELD2_NAME);
// verify the main root node
assertTrue(filter instanceof TmfFilterRootNode);
TmfFilterRootNode node = (TmfFilterRootNode) filter;
assertEquals(1, node.getChildrenCount());
ITmfFilterTreeNode child = node.getChild(0);
assertTrue(child instanceof TmfFilterAndNode);
TmfFilterAndNode andNode = (TmfFilterAndNode) child;
assertEquals(2, andNode.getChildrenCount());
// Verify first child, a matches node
child = andNode.getChild(0);
assertTrue(child instanceof TmfFilterMatchesNode);
TmfFilterMatchesNode equalsNode = (TmfFilterMatchesNode) child;
assertEquals(aspectF1, equalsNode.getEventAspect());
assertEquals(".*afield.*", equalsNode.getRegex());
// Verify second child the present node
child = andNode.getChild(1);
assertTrue(child instanceof TmfFilterMatchesNode);
equalsNode = (TmfFilterMatchesNode) child;
assertEquals(aspectF2, equalsNode.getEventAspect());
assertEquals(".*", equalsNode.getRegex());
// Test expected behavior on events
assertTrue(filter.matches(fEvent1));
assertTrue(filter.matches(fEvent2));
assertFalse(filter.matches(fEvent3));
}
use of org.eclipse.tracecompass.tmf.core.filter.ITmfFilter in project tracecompass by tracecompass.
the class TmfFilterHelperTest method getFilter.
private static ITmfFilter getFilter(String regex) {
ITmfTrace trace = STUB_TRACE;
assertNotNull(trace);
ITmfFilter filter = TmfFilterHelper.buildFilterFromRegex(Collections.singleton(regex), trace);
assertNotNull(filter);
return filter;
}
use of org.eclipse.tracecompass.tmf.core.filter.ITmfFilter in project tracecompass by tracecompass.
the class TmfFilterHelperTest method testInputRegexAspect.
/**
* Test a regex whose parameter corresponds to an aspect name
*/
@Test
public void testInputRegexAspect() {
ITmfEventAspect<@NonNull String> eventTypeAspect = TmfBaseAspects.getEventTypeAspect();
String regex = "\"" + eventTypeAspect.getName() + "\" == " + EVENT_NAME1;
ITmfFilter filter = getFilter(regex);
// verify the main root node
assertTrue(filter instanceof TmfFilterRootNode);
TmfFilterRootNode node = (TmfFilterRootNode) filter;
assertEquals(1, node.getChildrenCount());
ITmfFilterTreeNode child = node.getChild(0);
assertTrue(child instanceof TmfFilterEqualsNode);
// verify the equals node
TmfFilterEqualsNode equalsNode = (TmfFilterEqualsNode) child;
assertEquals(eventTypeAspect, equalsNode.getEventAspect());
assertEquals(EVENT_NAME1, equalsNode.getValue());
// Test expected behavior on events
assertTrue(filter.matches(fEvent1));
assertFalse(filter.matches(fEvent2));
assertFalse(filter.matches(fEvent3));
}
use of org.eclipse.tracecompass.tmf.core.filter.ITmfFilter in project tracecompass by tracecompass.
the class TmfFilterHelperTest method testInputRegexAnd.
/**
* Test a regex with &&
*/
@Test
public void testInputRegexAnd() {
String regex = FIELD1_NAME + " matches .*afield.* && " + FIELD2_NAME + " present";
ITmfFilter filter = getFilter(regex);
ITmfEventAspect<@NonNull Object> aspectF1 = TmfBaseAspects.getContentsAspect().forField(FIELD1_NAME);
ITmfEventAspect<@NonNull Object> aspectF2 = TmfBaseAspects.getContentsAspect().forField(FIELD2_NAME);
// verify the main root node
assertTrue(filter instanceof TmfFilterRootNode);
TmfFilterRootNode node = (TmfFilterRootNode) filter;
assertEquals(1, node.getChildrenCount());
ITmfFilterTreeNode child = node.getChild(0);
assertTrue(child instanceof TmfFilterAndNode);
TmfFilterAndNode andNode = (TmfFilterAndNode) child;
assertEquals(2, andNode.getChildrenCount());
// Verify first child, a matches node
child = andNode.getChild(0);
assertTrue(child instanceof TmfFilterMatchesNode);
TmfFilterMatchesNode equalsNode = (TmfFilterMatchesNode) child;
assertEquals(aspectF1, equalsNode.getEventAspect());
assertEquals(".*afield.*", equalsNode.getRegex());
// Verify second child the present node
child = andNode.getChild(1);
assertTrue(child instanceof TmfFilterMatchesNode);
equalsNode = (TmfFilterMatchesNode) child;
assertEquals(aspectF2, equalsNode.getEventAspect());
assertEquals(".*", equalsNode.getRegex());
// Test expected behavior on events
assertFalse(filter.matches(fEvent1));
assertFalse(filter.matches(fEvent2));
assertTrue(filter.matches(fEvent3));
}
Aggregations