1 | package de.uka.ipd.sdq.pcm.gmf.seff.helper; |
2 | |
3 | import java.util.ArrayList; |
4 | |
5 | import org.eclipse.emf.common.util.EList; |
6 | import org.eclipse.jface.viewers.ITreeContentProvider; |
7 | import org.eclipse.jface.viewers.Viewer; |
8 | |
9 | import de.uka.ipd.sdq.pcm.repository.CollectionDataType; |
10 | import de.uka.ipd.sdq.pcm.repository.DataType; |
11 | import de.uka.ipd.sdq.pcm.repository.Interface; |
12 | import de.uka.ipd.sdq.pcm.repository.OperationInterface; |
13 | import de.uka.ipd.sdq.pcm.repository.OperationSignature; |
14 | import de.uka.ipd.sdq.pcm.repository.Parameter; |
15 | import de.uka.ipd.sdq.pcm.repository.Signature; |
16 | |
17 | /** |
18 | * @author roman |
19 | * |
20 | * The ContentProvider for SelectObjectDialog. The Dialog will coll from |
21 | * ParameterCollectionIteratorActionEditHelperAdvice. Are only indicated |
22 | * parameter, which have an inside type CollectionDataType. |
23 | */ |
24 | public class CollectionIteratorContentProvider implements ITreeContentProvider { |
25 | |
26 | /* (non-Javadoc) |
27 | * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) |
28 | */ |
29 | public Object[] getChildren(Object parent) { |
30 | |
31 | if (parent instanceof OperationInterface) { |
32 | OperationInterface interf = (OperationInterface) parent; |
33 | return interf.getSignatures__OperationInterface().toArray(); |
34 | } |
35 | |
36 | if (parent instanceof OperationSignature) { |
37 | OperationSignature signature = (OperationSignature) parent; |
38 | ArrayList<Parameter> collParameters = new ArrayList<Parameter>(); |
39 | EList<Parameter> parameters = signature.getParameters__OperationSignature(); |
40 | for (Parameter p : parameters) { |
41 | DataType dataType = p.getDataType__Parameter(); |
42 | if (dataType instanceof CollectionDataType) |
43 | collParameters.add(p); |
44 | } |
45 | return collParameters.toArray(); |
46 | } |
47 | return new Object[0]; |
48 | } |
49 | |
50 | /* (non-Javadoc) |
51 | * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) |
52 | */ |
53 | public Object getParent(Object element) { |
54 | // TODO Auto-generated method stub |
55 | return null; |
56 | } |
57 | |
58 | /* (non-Javadoc) |
59 | * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) |
60 | */ |
61 | public boolean hasChildren(Object element) { |
62 | if (element instanceof Interface) |
63 | return true; |
64 | if (element instanceof Signature) |
65 | return true; |
66 | return false; |
67 | } |
68 | |
69 | /* (non-Javadoc) |
70 | * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) |
71 | */ |
72 | public Object[] getElements(Object inputElement) { |
73 | if (inputElement instanceof Interface) |
74 | return getChildren(inputElement); |
75 | return null; |
76 | } |
77 | |
78 | /* (non-Javadoc) |
79 | * @see org.eclipse.jface.viewers.IContentProvider#dispose() |
80 | */ |
81 | public void dispose() { |
82 | // TODO Auto-generated method stub |
83 | |
84 | } |
85 | |
86 | /* (non-Javadoc) |
87 | * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
88 | */ |
89 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
90 | // TODO Auto-generated method stub |
91 | |
92 | } |
93 | |
94 | } |