1 | package de.uka.ipd.sdq.pcm.dialogs.parameters; |
2 | |
3 | import org.eclipse.emf.common.notify.AdapterFactory; |
4 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
5 | import org.eclipse.emf.edit.provider.ITableItemLabelProvider; |
6 | import org.eclipse.emf.edit.provider.ItemProviderDecorator; |
7 | |
8 | import de.uka.ipd.sdq.pcm.dialogs.datatype.ParameterRepresentation; |
9 | import de.uka.ipd.sdq.pcm.repository.Parameter; |
10 | import de.uka.ipd.sdq.pcm.repository.Signature; |
11 | |
12 | /** |
13 | * This class is a decorator for the generated EMF.Edit item providers. It |
14 | * provides item providers which are used in the operations tab of the tabbed |
15 | * properties sheet when editing interfaces. It implements |
16 | * ITableItemLabelProvider to display the given EObject in a tabular form. |
17 | * Additionally it provided the labels by partcial delegation to the original |
18 | * IItemLabelProvider. |
19 | * |
20 | * @author Roman Andrej |
21 | */ |
22 | public class ParametersItemProvider extends ItemProviderDecorator implements |
23 | ITableItemLabelProvider, IItemLabelProvider { |
24 | |
25 | /** |
26 | * Inherited default constructor |
27 | * |
28 | * @param factory |
29 | * The factory which created this object |
30 | */ |
31 | public ParametersItemProvider(AdapterFactory adapterFactory){ |
32 | super(adapterFactory); |
33 | } |
34 | |
35 | /** |
36 | * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#getColumnImage(java.lang.Object, |
37 | * int) Get the icon by delegation if the first column is displayed |
38 | */ |
39 | @Override |
40 | public Object getColumnImage(Object object, int columnIndex) { |
41 | if (columnIndex == CreateEditorContents.ICON_COLUMN_INDEX) |
42 | return this.getImage(object); |
43 | return null; |
44 | } |
45 | |
46 | /** |
47 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, |
48 | * int) Format the columns with the given index constant as string text |
49 | * for displaying |
50 | */ |
51 | @Override |
52 | public String getColumnText(Object element, int columnIndex) { |
53 | String result = ""; |
54 | Parameter parameter = (Parameter) element; |
55 | |
56 | switch (columnIndex) { |
57 | case CreateEditorContents.ICON_COLUMN_INDEX: |
58 | break; |
59 | case CreateEditorContents.CONTEXT_COLUMN_INDEX: |
60 | result = ((Signature) parameter.eContainer()).getEntityName(); |
61 | break; |
62 | case CreateEditorContents.NAME_COLUMN_INDEX: |
63 | if (parameter.getParameterName() != null) |
64 | result = parameter.getParameterName(); |
65 | else |
66 | result = "null"; |
67 | break; |
68 | case CreateEditorContents.TYPE_COLUMN_INDEX: |
69 | result = ParameterRepresentation.dataTypeToString(parameter |
70 | .getDataType__Parameter()); |
71 | break; |
72 | default: |
73 | break; |
74 | } |
75 | return result; |
76 | } |
77 | } |