Project

General

Profile

Download (1.69 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11

    
12
package org.eclipse.ui.internal.navigator.filters;
13

    
14
import org.eclipse.core.expressions.EvaluationResult;
15
import org.eclipse.core.expressions.Expression;
16
import org.eclipse.core.expressions.IEvaluationContext;
17
import org.eclipse.jface.viewers.Viewer;
18
import org.eclipse.jface.viewers.ViewerFilter;
19
import org.eclipse.ui.internal.navigator.NavigatorPlugin;
20

    
21
/**
22
 * @since 3.2
23
 * 
24
 */
25
public class CoreExpressionFilter extends ViewerFilter {
26

    
27
	private Expression filterExpression;
28

    
29
	/**
30
	 * Creates a filter which hides all elements that match the given
31
	 * expression.
32
	 * 
33
	 * @param aFilterExpression
34
	 *            An expression to hide elements in the viewer.
35
	 */
36
	public CoreExpressionFilter(Expression aFilterExpression) {
37
		filterExpression = aFilterExpression;
38
	}
39

    
40
	/*
41
	 * (non-Javadoc)
42
	 * 
43
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
44
	 *      java.lang.Object, java.lang.Object)
45
	 */
46
	public boolean select(Viewer viewer, Object parentElement, Object element) {
47

    
48
		IEvaluationContext context = NavigatorPlugin.getEvalContext(element);
49
		return NavigatorPlugin.safeEvaluate(filterExpression, context) != EvaluationResult.TRUE;
50
	}
51

    
52
}
(9-9/17)