1 | package de.uka.ipd.sdq.pcmbench.tabs.operations; |
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.repository.OperationSignature; |
9 | |
10 | /** |
11 | * @author Snowball |
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 | public class OperationsTabItemProvider extends ItemProviderDecorator implements |
21 | ITableItemLabelProvider, IItemLabelProvider { |
22 | |
23 | /** |
24 | * Inherited default constructor |
25 | * |
26 | * @param factory |
27 | * The factory which created this object |
28 | */ |
29 | public OperationsTabItemProvider(AdapterFactory factory) { |
30 | super(factory); |
31 | } |
32 | |
33 | /* (non-Javadoc) |
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 == OperationsEditorSection.ICON_COLUMN_INDEX) |
40 | return this.getImage(object); |
41 | return null; |
42 | } |
43 | |
44 | /** |
45 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, |
46 | * int) Format the columns with the given index constant as string text |
47 | * for displaying |
48 | */ |
49 | @Override |
50 | public String getColumnText(Object element, int columnIndex) { |
51 | String result = ""; |
52 | OperationSignature signature = (OperationSignature) element; |
53 | ParameterRepresentation parser = new ParameterRepresentation(); |
54 | |
55 | switch (columnIndex) { |
56 | case OperationsEditorSection.ICON_COLUMN_INDEX: |
57 | break; |
58 | case OperationsEditorSection.RETURNTYPE_COLUMN_INDEX: |
59 | result = parser.setDataTypeToString(signature |
60 | .getReturnType__OperationSignature()); |
61 | break; |
62 | case OperationsEditorSection.SIGNATURENAME_COLUMN_INDEX: |
63 | result = signature.getEntityName(); |
64 | break; |
65 | case OperationsEditorSection.PARAMETER_COLUMN_INDEX: |
66 | result = parser.setParametersToString(signature |
67 | .getParameters__OperationSignature()); |
68 | break; |
69 | case OperationsEditorSection.EXCEPTIONS_COLUMN_INDEX: |
70 | result = parser.setExceptionsToString(signature |
71 | .getExceptions__Signature()); |
72 | break; |
73 | default: |
74 | break; |
75 | } |
76 | return parser.isNotNull(result); |
77 | } |
78 | } |