]> git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/runtime/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailLabelProvider.java
Clean and add some comments to the content providers
[gpl/argeo-slc.git] / eclipse / runtime / org.argeo.slc.client.core / src / main / java / org / argeo / slc / client / contentprovider / ResultDetailLabelProvider.java
1 package org.argeo.slc.client.contentprovider;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.argeo.eclipse.ui.TreeParent;
6 import org.argeo.slc.client.contentprovider.ResultDetailContentProvider.ResultPartNode;
7 import org.argeo.slc.client.contentprovider.ResultDetailContentProvider.StatusAware;
8 import org.eclipse.jface.viewers.ITableLabelProvider;
9 import org.eclipse.jface.viewers.LabelProvider;
10 import org.eclipse.swt.graphics.Image;
11
12 /**
13 * @author bsinou
14 *
15 * Fill ResultDetail view. Deported in an external bundle so that main
16 * slc ui bundle does not depend on DB implementation.
17 */
18 public class ResultDetailLabelProvider extends LabelProvider implements
19 ITableLabelProvider {
20 private static final Log log = LogFactory
21 .getLog(ResultDetailLabelProvider.class);
22
23 // TODO : find a solution to get the icons here.
24 // Images
25 // public final static Image FAILED = ClientUiPlugin.getImageDescriptor(
26 // "icons/failed.gif").createImage();
27 // public final static Image PASSED = ClientUiPlugin.getImageDescriptor(
28 // "icons/passed.gif").createImage();
29
30 public String getColumnText(Object obj, int index) {
31
32 if (obj instanceof ResultPartNode) {
33 ResultPartNode rpn = (ResultPartNode) obj;
34 switch (index) {
35 // case 0:
36 // if (log.isDebugEnabled())
37 // log.debug("Get col text, index = 0 & rpn.toString="
38 // + rpn.toString());
39 // return rpn.toString();
40 case 0:
41 return rpn.getStatus().toString();
42 case 1:
43 return rpn.getMessage();
44 case 2:
45 return rpn.getExceptionMessage();
46 }
47 return getText(obj);
48 }
49
50 if (obj instanceof TreeParent) {
51 if (index == 0) {
52 if (log.isDebugEnabled())
53 log.debug("In GetTreeParent text, index = 0 & label ="
54 + ((TreeParent) obj).getName());
55
56 return ((TreeParent) obj).getName();
57 } else
58 return null;
59 }
60
61 return null;
62 }
63
64 public Image getImage(Object element) {
65 if (element instanceof StatusAware) {
66 // Package use conflict problem when getting the icons, uncomment
67 // Images definition above and update Manifest to get it.
68
69 // if (((StatusAware) element).isPassed())
70 // return PASSED;
71 // else
72 // return FAILED;
73 }
74 return null;
75 }
76
77 public Image getColumnImage(Object obj, int index) {
78 if (index == 0)
79 return getImage(obj);
80 else
81 return null;
82 }
83 }