1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfEventFieldAspect
;
19 * Base class for filter nodes which use event aspects
21 * @author Patrick Tasse
23 public abstract class TmfFilterAspectNode
extends TmfFilterTreeNode
{
25 /** event aspect attribute name */
26 public static final String EVENT_ASPECT_ATTR
= "eventaspect"; //$NON-NLS-1$
27 /** trace type id attribute name */
28 public static final String TRACE_TYPE_ID_ATTR
= "tracetypeid"; //$NON-NLS-1$
29 /** field attribute name */
30 public static final String FIELD_ATTR
= "field"; //$NON-NLS-1$
31 /** special case trace type id for base aspects */
32 public static final String BASE_ASPECT_ID
= "BASE.ASPECT.ID"; //$NON-NLS-1$
35 protected ITmfEventAspect fEventAspect
;
37 private String fTraceTypeId
;
40 * @param parent the parent node
42 public TmfFilterAspectNode(ITmfFilterTreeNode parent
) {
47 * @return The event aspect of this filter
49 public ITmfEventAspect
getEventAspect() {
55 * The event aspect to assign to this filter
57 public void setEventAspect(ITmfEventAspect aspect
) {
58 fEventAspect
= aspect
;
62 * @return The trace type id from which the event aspect belongs, or a
64 * @see #BASE_ASPECT_ID
66 public String
getTraceTypeId() {
72 * The trace type id from which the event aspect belongs, or a
74 * @see #BASE_ASPECT_ID
76 public void setTraceTypeId(String traceTypeId
) {
77 fTraceTypeId
= traceTypeId
;
82 * true if the string representation should explicitly include
83 * the trace type id that can differentiate it from other aspects
86 * @return The string representation of the event aspect
88 public String
getAspectLabel(boolean explicit
) {
89 if (fEventAspect
== null) {
90 return ""; //$NON-NLS-1$
92 StringBuilder sb
= new StringBuilder(fEventAspect
.getName());
95 sb
.append(fTraceTypeId
);
98 if (fEventAspect
instanceof TmfEventFieldAspect
) {
99 String field
= ((TmfEventFieldAspect
) fEventAspect
).getFieldPath();
100 if (field
!= null && !field
.isEmpty()) {
101 if (field
.charAt(0) != '/') {
107 return sb
.toString();
111 public ITmfFilterTreeNode
clone() {
112 TmfFilterAspectNode clone
= (TmfFilterAspectNode
) super.clone();
113 clone
.setEventAspect(fEventAspect
);
114 clone
.setTraceTypeId(fTraceTypeId
);