1 /*******************************************************************************
2 * Copyright (c) 2014 Inria
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 * Generoso Pagano, Inria - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.dialogs
;
15 import org
.eclipse
.jface
.viewers
.AbstractTreeViewer
;
16 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
17 import org
.eclipse
.jface
.viewers
.Viewer
;
18 import org
.eclipse
.ui
.dialogs
.PatternFilter
;
21 * A filter extending the <code>org.eclipse.ui.dialogs.PatternFilter<code>.
23 * It redefines the {@link #isElementVisible(Viewer, Object)}} method in order
24 * to have a match on a node if: the node matches or one of the children matches
25 * or one of the parents matches.
27 * @author "Generoso Pagano <generoso.pagano@inria.fr>"
30 public class TreePatternFilter
extends PatternFilter
{
33 public boolean isElementVisible(Viewer viewer
, Object element
) {
34 return super.isElementVisible(viewer
, element
) || isChildMatch(viewer
, element
);
38 * Check if at least one of the parents of this element is a match with the
42 * the viewer that contains the element
44 * the tree element to check
45 * @return true if the given element has a parent that matches the filter
48 private boolean isChildMatch(Viewer viewer
, Object element
) {
49 Object parent
= ((ITreeContentProvider
) ((AbstractTreeViewer
) viewer
).getContentProvider())
51 while (parent
!= null) {
52 if (isLeafMatch(viewer
, parent
)) {
55 parent
= ((ITreeContentProvider
) ((AbstractTreeViewer
) viewer
).getContentProvider())
This page took 0.031813 seconds and 5 git commands to generate.