1 | package de.uka.ipd.sdq.pcmbench.tabs; |
2 | |
3 | import org.eclipse.gef.GraphicalEditPart; |
4 | import org.eclipse.gmf.runtime.notation.View; |
5 | import org.eclipse.jface.viewers.IFilter; |
6 | |
7 | import de.uka.ipd.sdq.pcm.repository.InfrastructureInterface; |
8 | import de.uka.ipd.sdq.pcm.repository.InfrastructureSignature; |
9 | |
10 | /** |
11 | * Filter to select only elements related to event groups and types. |
12 | * |
13 | * In the past, this was about the meanwhile generic Interface model |
14 | * element but has become more specific to distinct between OperationInterfaces |
15 | * and EventGroups. |
16 | * |
17 | * This filter is used by the property tabs definition in the GMF editors. |
18 | * |
19 | * @author Benjamin Klatt |
20 | * @author groenda |
21 | * |
22 | */ |
23 | public class InfrastructureInterfaceFilter implements IFilter { |
24 | |
25 | /** |
26 | * Decide if an object is about event groups and types. |
27 | * This could be an EventGroup or an EventType. |
28 | * @param toTest The element object to test. |
29 | * @return true/false if the object is of type EventGroup or EventType. |
30 | */ |
31 | public boolean select(Object toTest) { |
32 | Object input = toTest; |
33 | if (input instanceof GraphicalEditPart) { |
34 | GraphicalEditPart ep = (GraphicalEditPart) input; |
35 | input = ep.getModel(); |
36 | } |
37 | if (input instanceof View) { |
38 | input = ((View) input).getElement(); |
39 | } |
40 | return input instanceof InfrastructureInterface || input instanceof InfrastructureSignature; |
41 | } |
42 | |
43 | } |