1 /*******************************************************************************
2 * Copyright (c) 2014 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
.linuxtools
.internal
.tmf
.core
.filter
;
14 import java
.util
.List
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.event
.collapse
.ITmfCollapsibleEvent
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
21 * Stateful filter that compares consecutive events for collapsing feature.
23 * Usage of this class in conjunction with other {@link ITmfFilterTreeNode}
24 * filters is not supported. Will throw {@link UnsupportedOperationException}
27 * @author Bernd Hufmann
29 public class TmfCollapseFilter
implements ITmfFilterTreeNode
{
31 private static final String COLLAPSE_NODE_NAME
= "Collapse"; //$NON-NLS-1$
33 private ITmfCollapsibleEvent fPrevEvent
= null;
36 public boolean matches(ITmfEvent event
) {
38 if (fPrevEvent
!= null) {
39 if (event
instanceof ITmfCollapsibleEvent
) {
40 boolean isCollapsible
= fPrevEvent
.isCollapsibleWith(event
);
41 fPrevEvent
= (ITmfCollapsibleEvent
) event
;
49 if (event
instanceof ITmfCollapsibleEvent
) {
50 fPrevEvent
= (ITmfCollapsibleEvent
) event
;
57 public ITmfFilterTreeNode
getParent() {
62 public String
getNodeName() {
63 return COLLAPSE_NODE_NAME
;
67 public boolean hasChildren() {
72 public int getChildrenCount() {
77 public ITmfFilterTreeNode
[] getChildren() {
78 return new ITmfFilterTreeNode
[0];
82 public ITmfFilterTreeNode
getChild(int index
) {
83 throw new UnsupportedOperationException();
87 public ITmfFilterTreeNode
remove() {
88 throw new UnsupportedOperationException();
92 public ITmfFilterTreeNode
removeChild(ITmfFilterTreeNode node
) {
93 throw new UnsupportedOperationException();
97 public int addChild(ITmfFilterTreeNode node
) {
98 throw new UnsupportedOperationException();
102 public ITmfFilterTreeNode
replaceChild(int index
, ITmfFilterTreeNode node
) {
103 throw new UnsupportedOperationException();
107 public void setParent(ITmfFilterTreeNode parent
) {
111 public List
<String
> getValidChildren() {
112 throw new UnsupportedOperationException();
116 public ITmfFilterTreeNode
clone() {
117 return new TmfCollapseFilter();