tmf: Add collapsible event table header bar with applied filter labels
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / filter / model / TmfFilterObjectNode.java
1 /*******************************************************************************
2 * Copyright (c) 2016 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.core.filter.model;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
19 import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter;
20
21 /**
22 * Filter node that contains its own filter object
23 *
24 * @version 1.0
25 * @author Patrick Tasse
26 * @since 2.0
27 */
28 public class TmfFilterObjectNode extends TmfFilterTreeNode {
29
30 /** filter node name */
31 public static final String NODE_NAME = "FILTEROBJECT"; //$NON-NLS-1$
32 /** name attribute name */
33 public static final String NAME_ATTR = "name"; //$NON-NLS-1$
34
35 private final ITmfFilter fFilter;
36
37 /**
38 * @param filter the filter object
39 */
40 public TmfFilterObjectNode(ITmfFilter filter) {
41 super(null);
42 fFilter = filter;
43 }
44
45 /**
46 * @param parent the parent node
47 * @param filter the filter object
48 */
49 public TmfFilterObjectNode(ITmfFilterTreeNode parent, ITmfFilter filter) {
50 super(parent);
51 fFilter = filter;
52 }
53
54 /**
55 * @return the filter object
56 */
57 public ITmfFilter getFilter() {
58 return fFilter;
59 }
60
61 @Override
62 public String getNodeName() {
63 return NODE_NAME;
64 }
65
66 @Override
67 public boolean matches(ITmfEvent event) {
68 // There should be at most one child
69 for (ITmfFilterTreeNode node : getChildren()) {
70 if (node.matches(event)) {
71 return true;
72 }
73 }
74 return false;
75 }
76
77 @Override
78 public List<String> getValidChildren() {
79 return new ArrayList<>(0);
80 }
81
82 @Override
83 public String toString(boolean explicit) {
84 if (fFilter instanceof ITmfFilterTreeNode) {
85 return ((ITmfFilterTreeNode) fFilter).toString(explicit);
86 }
87 return fFilter.toString();
88 }
89 }
This page took 0.057263 seconds and 5 git commands to generate.