|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.s60tools.appdep.ui.wizards; |
|
20 |
|
21 import org.eclipse.jface.viewers.ITableLabelProvider; |
|
22 import org.eclipse.jface.viewers.LabelProvider; |
|
23 import org.eclipse.swt.graphics.Image; |
|
24 |
|
25 import com.nokia.s60tools.appdep.resources.ImageKeys; |
|
26 import com.nokia.s60tools.appdep.resources.ImageResourceManager; |
|
27 import com.nokia.s60tools.appdep.resources.Messages; |
|
28 import com.nokia.s60tools.appdep.ui.wizards.BuildTargetEntry.BuildTargetStatusEnum; |
|
29 import com.nokia.s60tools.appdep.util.AppDepConsole; |
|
30 |
|
31 /** |
|
32 * Select Build Target wizard page label provider. |
|
33 */ |
|
34 class SelectBuildTargetWizardPageLabelProvider extends LabelProvider |
|
35 implements ITableLabelProvider { |
|
36 |
|
37 /* (non-Javadoc) |
|
38 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
|
39 */ |
|
40 public Image getColumnImage(Object element, int columnIndex) { |
|
41 |
|
42 // By default no images are used |
|
43 Image img = null; |
|
44 BuildTargetEntry entryData = (BuildTargetEntry) element; |
|
45 |
|
46 switch (columnIndex) { |
|
47 |
|
48 case BuildTargetEntry.TARGET_TYPE_COLUMN_INDEX: |
|
49 case BuildTargetEntry.COMPONENT_COUNT_COLUMN_INDEX: |
|
50 // fall-through, no image used for these in the moment |
|
51 break; |
|
52 |
|
53 case BuildTargetEntry.STATUS_COLUMN_INDEX: |
|
54 img = getStatusColumneImage(entryData); |
|
55 break; |
|
56 |
|
57 default: |
|
58 AppDepConsole.getInstance().println(Messages.getString("GeneralMessages.Unexpected_Column_Index_ErrMsg") + ": " +columnIndex, AppDepConsole.MSG_ERROR); //$NON-NLS-1$ //$NON-NLS-2$ |
|
59 break; |
|
60 } |
|
61 |
|
62 return img; |
|
63 } |
|
64 |
|
65 /** |
|
66 * Gets status column image for an entry data object. |
|
67 * @param entryData entry data. |
|
68 * @return status column image for an entry data object. |
|
69 */ |
|
70 private Image getStatusColumneImage(BuildTargetEntry entryData) { |
|
71 |
|
72 BuildTargetStatusEnum status = entryData.getStatus(); |
|
73 String imageKey = ImageKeys.TRAFFIC_LIGHT_RED_OBJ; |
|
74 |
|
75 switch (status) { |
|
76 |
|
77 case ECacheReady: |
|
78 imageKey = ImageKeys.TRAFFIC_LIGHT_GREEN_OBJ; |
|
79 break; |
|
80 |
|
81 case ECacheNeedsUpdate: |
|
82 case ENoCache: |
|
83 // fall-through |
|
84 imageKey = ImageKeys.TRAFFIC_LIGHT_YELLOW_OBJ; |
|
85 break; |
|
86 |
|
87 case EEmptyTarget: |
|
88 case ENotSupported: |
|
89 case ECachesIsBeingIndexed: |
|
90 case ECacheIsBeingGenerated: |
|
91 // fall-through |
|
92 imageKey = ImageKeys.TRAFFIC_LIGHT_RED_OBJ; |
|
93 break; |
|
94 |
|
95 default: |
|
96 break; |
|
97 } |
|
98 |
|
99 return ImageResourceManager.getImage(imageKey); |
|
100 } |
|
101 |
|
102 /* (non-Javadoc) |
|
103 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) |
|
104 */ |
|
105 public String getColumnText(Object element, int columnIndex) { |
|
106 |
|
107 String label = element.toString(); |
|
108 |
|
109 BuildTargetEntry entryData = (BuildTargetEntry) element; |
|
110 |
|
111 switch (columnIndex) { |
|
112 |
|
113 case BuildTargetEntry.TARGET_TYPE_COLUMN_INDEX: |
|
114 label = entryData.getTargetDescription(); |
|
115 break; |
|
116 |
|
117 case BuildTargetEntry.COMPONENT_COUNT_COLUMN_INDEX: |
|
118 label = entryData.getComponentCount(); |
|
119 break; |
|
120 |
|
121 case BuildTargetEntry.STATUS_COLUMN_INDEX: |
|
122 label = entryData.getStatusAsString(); |
|
123 break; |
|
124 |
|
125 default: |
|
126 AppDepConsole.getInstance().println(Messages.getString("GeneralMessages.Unexpected_Column_Index_ErrMsg") + ": " +columnIndex, AppDepConsole.MSG_ERROR); //$NON-NLS-1$ //$NON-NLS-2$ |
|
127 break; |
|
128 } |
|
129 |
|
130 return label; |
|
131 } |
|
132 |
|
133 } |