1 | package de.uka.ipd.sdq.pcm.dialogs.exception; |
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.ExceptionType; |
9 | import de.uka.ipd.sdq.pcm.repository.Signature; |
10 | |
11 | /** @author roman */ |
12 | public class ExceptionsItemProvider extends ItemProviderDecorator implements |
13 | ITableItemLabelProvider, IItemLabelProvider { |
14 | |
15 | /** |
16 | * Inherited default constructor |
17 | * |
18 | * @param factory |
19 | * The factory which created this object |
20 | */ |
21 | public ExceptionsItemProvider(AdapterFactory adapterFactory){ |
22 | super(adapterFactory); |
23 | } |
24 | |
25 | /** |
26 | * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#getColumnImage(java.lang.Object, |
27 | * int) Get the icon by delegation if the first column is displayed |
28 | */ |
29 | @Override |
30 | public Object getColumnImage(Object object, int columnIndex) { |
31 | if (columnIndex == ExceptionsDialog.ICON_COLUMN_INDEX) |
32 | return this.getImage(object); |
33 | return null; |
34 | } |
35 | |
36 | /** |
37 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, |
38 | * int) Format the columns with the given index constant as string text |
39 | * for displaying |
40 | */ |
41 | @Override |
42 | public String getColumnText(Object element, int columnIndex) { |
43 | String result = ""; |
44 | ExceptionType exceptionType = (ExceptionType) element; |
45 | |
46 | switch (columnIndex) { |
47 | case ExceptionsDialog.ICON_COLUMN_INDEX: |
48 | break; |
49 | case ExceptionsDialog.CONTEXT_COLUMN_INDEX: |
50 | result = ((Signature) exceptionType.eContainer()).getEntityName(); |
51 | break; |
52 | case ExceptionsDialog.NAME_COLUMN_INDEX: |
53 | result = getExceptionName(exceptionType); |
54 | break; |
55 | default: |
56 | break; |
57 | } |
58 | return result == null ? "" : result; |
59 | } |
60 | |
61 | private String getExceptionName(ExceptionType type){ |
62 | String exceptionName = type.getExceptionName(); |
63 | if (exceptionName != null) |
64 | return exceptionName; |
65 | return "null"; |
66 | } |
67 | } |