01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.tests.views.properties.tabbed.dynamic.filters;
11:
12: import org.eclipse.core.runtime.Assert;
13: import org.eclipse.jface.viewers.IFilter;
14: import org.eclipse.ui.tests.views.properties.tabbed.dynamic.model.DynamicTestsColor;
15: import org.eclipse.ui.tests.views.properties.tabbed.dynamic.model.DynamicTestsElement;
16: import org.eclipse.ui.tests.views.properties.tabbed.dynamic.model.DynamicTestsShape;
17: import org.eclipse.ui.tests.views.properties.tabbed.dynamic.views.DynamicTestsTreeNode;
18:
19: /**
20: * A section filter for the dynamic tests view.
21: *
22: * @author Anthony Hunter
23: */
24: public class DynamicTestsElementSectionFilter implements IFilter {
25:
26: /**
27: * Determine if the filter applies to the provided color.
28: *
29: * @param element
30: * the element.
31: * @return true if the filter applies to the provided color.
32: */
33: protected boolean appliesToColor(DynamicTestsColor color) {
34: Assert.isNotNull(color);
35: return true;
36: }
37:
38: /**
39: * Determine if the filter applies to the provided shape.
40: *
41: * @param element
42: * the element.
43: * @return true if the filter applies to the provided shape.
44: */
45: protected boolean appliesToShape(DynamicTestsShape shape) {
46: Assert.isNotNull(shape);
47: return true;
48: }
49:
50: public boolean select(Object object) {
51: if (object instanceof DynamicTestsTreeNode) {
52: DynamicTestsElement element = ((DynamicTestsTreeNode) object)
53: .getDynamicTestsElement();
54: DynamicTestsColor color = (DynamicTestsColor) element
55: .getPropertyValue(DynamicTestsElement.ID_COLOR);
56: DynamicTestsShape shape = (DynamicTestsShape) element
57: .getPropertyValue(DynamicTestsElement.ID_SHAPE);
58: return (appliesToColor(color) && appliesToShape(shape));
59: }
60: return false;
61: }
62: }
|