1 /*******************************************************************************
2 * Copyright (c) 2014, 2016 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 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.internal
.tmf
.core
.filter
;
14 import java
.util
.List
;
16 import org
.eclipse
.jdt
.annotation
.NonNull
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.collapse
.ITmfCollapsibleEvent
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
22 * Stateful filter that compares consecutive events for collapsing feature.
24 * Usage of this class in conjunction with other {@link ITmfFilterTreeNode}
25 * filters is not supported. Will throw {@link UnsupportedOperationException}
28 * @author Bernd Hufmann
30 public class TmfCollapseFilter
implements ITmfFilterTreeNode
{
32 private static final String COLLAPSE_NODE_NAME
= "Collapse"; //$NON-NLS-1$
34 private ITmfCollapsibleEvent fPrevEvent
= null;
37 public boolean matches(ITmfEvent event
) {
39 if (fPrevEvent
!= null) {
40 if (event
instanceof ITmfCollapsibleEvent
) {
41 boolean isCollapsible
= fPrevEvent
.isCollapsibleWith(event
);
42 fPrevEvent
= (ITmfCollapsibleEvent
) event
;
50 if (event
instanceof ITmfCollapsibleEvent
) {
51 fPrevEvent
= (ITmfCollapsibleEvent
) event
;
58 public ITmfFilterTreeNode
getParent() {
63 public String
getNodeName() {
64 return COLLAPSE_NODE_NAME
;
68 public boolean hasChildren() {
73 public int getChildrenCount() {
78 public @NonNull ITmfFilterTreeNode
[] getChildren() {
79 return new @NonNull ITmfFilterTreeNode
[0];
83 public ITmfFilterTreeNode
getChild(int index
) {
84 throw new UnsupportedOperationException();
88 public ITmfFilterTreeNode
remove() {
89 throw new UnsupportedOperationException();
93 public ITmfFilterTreeNode
removeChild(ITmfFilterTreeNode node
) {
94 throw new UnsupportedOperationException();
98 public int addChild(ITmfFilterTreeNode node
) {
99 throw new UnsupportedOperationException();
103 public ITmfFilterTreeNode
replaceChild(int index
, ITmfFilterTreeNode node
) {
104 throw new UnsupportedOperationException();
108 public void setParent(ITmfFilterTreeNode parent
) {
112 public List
<String
> getValidChildren() {
113 throw new UnsupportedOperationException();
117 public String
toString() {
118 return COLLAPSE_NODE_NAME
;
122 public String
toString(boolean explicit
) {
123 return COLLAPSE_NODE_NAME
+ " [" + fPrevEvent
+ ']'; //$NON-NLS-1$
127 public ITmfFilterTreeNode
clone() {
128 return new TmfCollapseFilter();