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.EventGroup; |
8 | import de.uka.ipd.sdq.pcm.repository.EventType; |
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 | * |
21 | */ |
22 | public class EventGroupFilter implements IFilter { |
23 | |
24 | /** |
25 | * Decide if an object is about event groups and types. |
26 | * This could be an EventGroup or an EventType. |
27 | * @param toTest The element object to test. |
28 | * @return true/false if the object is of type EventGroup or EventType. |
29 | */ |
30 | public boolean select(Object toTest) { |
31 | Object input = toTest; |
32 | if (input instanceof GraphicalEditPart) { |
33 | GraphicalEditPart ep = (GraphicalEditPart) input; |
34 | input = ep.getModel(); |
35 | } |
36 | if (input instanceof View) { |
37 | input = ((View) input).getElement(); |
38 | } |
39 | return input instanceof EventGroup || input instanceof EventType; |
40 | } |
41 | |
42 | } |