Skip to main content
summaryrefslogtreecommitdiffstats
blob: 16661d1707f8241a80a6687c23f88abf089a4f7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*******************************************************************************
 * Copyright (c) 2006, 2015 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.help.internal.dynamic;

import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.help.UAContentFilter;
import org.eclipse.help.internal.UAElement;

/*
 * The handler responsible for filtering elements. Filters can either be
 * an attribute of the element to filter, or any number of child filter
 * elements.
 */
public class FilterHandler extends ProcessorHandler {

	private IEvaluationContext context;

	public FilterHandler(IEvaluationContext context) {
		this.context = context;
	}

	@Override
	public short handle(UAElement element, String id) {
		if (UAContentFilter.isFiltered(element, context)) {
			UAElement parent = element.getParentElement();
			if (parent != null) {
				parent.removeChild(element);
			}
			return HANDLED_SKIP;
		}
		return UNHANDLED;
	}
}

Back to the top