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.EventType; |
9 | |
10 | /** |
11 | * This class is a decorator for the generated EMF.Edit item providers. It |
12 | * provides item providers which are used in the event types tab of the tabbed |
13 | * properties sheet when editing event groups. It implements |
14 | * ITableItemLabelProvider to display the given EObject in a tabular form. |
15 | * Additionally it provided the labels by practical delegation to the original |
16 | * IItemLabelProvider. |
17 | * |
18 | * The OperationsTabItemProvider was used as template for this class. |
19 | * |
20 | * @author Benjamin Klatt |
21 | */ |
22 | public class EventTypesTabItemProvider 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 EventTypesTabItemProvider(AdapterFactory factory) { |
32 | super(factory); |
33 | } |
34 | |
35 | /* (non-Javadoc) |
36 | * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#getColumnImage(java.lang.Object, |
37 | * int) |
38 | */ |
39 | @Override |
40 | public Object getColumnImage(Object object, int columnIndex) { |
41 | if (columnIndex == EventTypesEditorSection.ICON_COLUMN_INDEX) |
42 | return this.getImage(object); |
43 | return null; |
44 | } |
45 | |
46 | /** |
47 | * Format the columns with the given index constant as string text for displaying. |
48 | * |
49 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, |
50 | * int) |
51 | */ |
52 | @Override |
53 | public String getColumnText(Object element, int columnIndex) { |
54 | String result = ""; |
55 | EventType eventType = (EventType) element; |
56 | ParameterRepresentation parser = new ParameterRepresentation(); |
57 | |
58 | switch (columnIndex) { |
59 | case EventTypesEditorSection.ICON_COLUMN_INDEX: |
60 | break; |
61 | case EventTypesEditorSection.EVENTTYPENAME_COLUMN_INDEX: |
62 | result = eventType.getEntityName(); |
63 | break; |
64 | case EventTypesEditorSection.PARAMETER_NAME_COLUMN_INDEX: |
65 | if(eventType != null && |
66 | eventType.getParameter__EventType() != null && |
67 | eventType.getParameter__EventType().getParameterName() != null){ |
68 | result = eventType.getParameter__EventType().getParameterName(); |
69 | } else { |
70 | result = ""; |
71 | } |
72 | break; |
73 | case EventTypesEditorSection.PARAMETER_TYPE_COLUMN_INDEX: |
74 | if(eventType != null && |
75 | eventType.getParameter__EventType() != null && |
76 | eventType.getParameter__EventType().getDataType__Parameter() != null){ |
77 | result = parser.setDataTypeToString(eventType |
78 | .getParameter__EventType() |
79 | .getDataType__Parameter()); |
80 | } else { |
81 | result = ""; |
82 | } |
83 | break; |
84 | default: |
85 | break; |
86 | } |
87 | return parser.isNotNull(result); |
88 | } |
89 | } |