1 | package de.uka.ipd.sdq.pcm.dialogs.datatype; |
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.parameters.CreateEditorContents; |
9 | import de.uka.ipd.sdq.pcm.repository.InnerDeclaration; |
10 | |
11 | /** |
12 | * This class is a decorator for the generated EMF.Edit item providers. It |
13 | * provides item providers which are used in the operations tab of the tabbed |
14 | * properties sheet when editing interfaces. It implements |
15 | * ITableItemLabelProvider to display the given EObject in a tabular form. |
16 | * Additionally it provided the labels by partcial delegation to the original |
17 | * IItemLabelProvider. |
18 | * |
19 | * @author Roman Andrej |
20 | */ |
21 | public class InnerDeclarationItemProvider extends ItemProviderDecorator implements |
22 | ITableItemLabelProvider, IItemLabelProvider { |
23 | |
24 | /** |
25 | * @param adapterFactory |
26 | */ |
27 | public InnerDeclarationItemProvider(AdapterFactory adapterFactory){ |
28 | super(adapterFactory); |
29 | } |
30 | |
31 | /* |
32 | * (non-Javadoc) |
33 | * |
34 | * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#getColumnImage(java.lang.Object, |
35 | * int) |
36 | */ |
37 | @Override |
38 | public Object getColumnImage(Object object, int columnIndex) { |
39 | if (columnIndex == CreateEditorContents.ICON_COLUMN_INDEX) |
40 | return this.getImage(object); |
41 | return null; |
42 | } |
43 | |
44 | /* |
45 | * (non-Javadoc) |
46 | * |
47 | * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#getColumnText(java.lang.Object, |
48 | * int) |
49 | */ |
50 | @Override |
51 | public String getColumnText(Object element, int columnIndex) { |
52 | String result = ""; |
53 | |
54 | InnerDeclaration declaration = (InnerDeclaration) element; |
55 | |
56 | switch (columnIndex) { |
57 | case CreateEditorContents.ICON_COLUMN_INDEX: |
58 | break; |
59 | case CreateEditorContents.CONTEXT_COLUMN_INDEX: |
60 | result = declaration.getClass().getSimpleName(); |
61 | break; |
62 | case CreateEditorContents.NAME_COLUMN_INDEX: |
63 | if (declaration != null) |
64 | result = declaration.getEntityName(); |
65 | break; |
66 | case CreateEditorContents.TYPE_COLUMN_INDEX: |
67 | result = ParameterRepresentation.dataTypeToString(declaration |
68 | .getDatatype_InnerDeclaration()); |
69 | break; |
70 | default: |
71 | break; |
72 | } |
73 | return result; |
74 | } |
75 | } |