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.OperationInterface; |
8 | import de.uka.ipd.sdq.pcm.repository.OperationSignature; |
9 | |
10 | /** |
11 | * Filter to select only elements of types related to operation interfaces. |
12 | * In the past, this was about the meanwhile generic Interface model |
13 | * element but has become more specific to distinct between OperationInterfaces |
14 | * and EventGroups. |
15 | * |
16 | * This filter is used by the property tabs definition in the GMF editors. |
17 | * |
18 | * @author Benjamin Klatt |
19 | * |
20 | */ |
21 | public class OperationInterfaceFilter implements IFilter { |
22 | |
23 | /** |
24 | * Decide if an object is about operation interfaces. |
25 | * This could be an OperationInterface or an OperationSignature. |
26 | * @param toTest The element object to test. |
27 | * @return true/false if the object is of type OperationInterface or OperationSignature |
28 | */ |
29 | public boolean select(Object toTest) { |
30 | Object input = toTest; |
31 | if (input instanceof GraphicalEditPart) { |
32 | GraphicalEditPart ep = (GraphicalEditPart) input; |
33 | input = ep.getModel(); |
34 | } |
35 | if (input instanceof View) { |
36 | input = ((View) input).getElement(); |
37 | } |
38 | return input instanceof OperationInterface || input instanceof OperationSignature; |
39 | } |
40 | |
41 | } |