01: package net.refractions.udig.validation.ui;
02:
03: import net.refractions.udig.validation.DTOUtils;
04:
05: import org.eclipse.jface.viewers.IColorProvider;
06: import org.eclipse.jface.viewers.ILabelProviderListener;
07: import org.eclipse.jface.viewers.LabelProvider;
08: import org.eclipse.swt.SWT;
09: import org.eclipse.swt.graphics.Color;
10: import org.eclipse.swt.graphics.Image;
11: import org.eclipse.swt.widgets.Display;
12: import org.geotools.validation.dto.PlugInDTO;
13: import org.geotools.validation.dto.TestDTO;
14:
15: public class ValidationTreeLabelProvider extends LabelProvider
16: implements IColorProvider {
17:
18: public ValidationTreeLabelProvider() {
19: }
20:
21: public Image getImage(Object element) {
22: return null;
23: }
24:
25: public String getText(Object element) {
26: if (element instanceof PlugInDTO) {
27: PlugInDTO plugin = (PlugInDTO) element;
28: return plugin.getName();
29: } else if (element instanceof TestDTO) {
30: TestDTO test = (TestDTO) element;
31: return test.getName();
32: }
33: return super .getText(element); //unknown type
34: }
35:
36: public void addListener(ILabelProviderListener listener) {
37: }
38:
39: public void dispose() {
40: }
41:
42: public boolean isLabelProperty(Object element, String property) {
43: return false;
44: }
45:
46: public void removeListener(ILabelProviderListener listener) {
47: }
48:
49: public Color getForeground(Object element) {
50: //check element to determine if it has bad args
51: if (element instanceof TestDTO) {
52: Color red = Display.getCurrent().getSystemColor(
53: SWT.COLOR_RED);
54: if (!(DTOUtils.noNullArguments((TestDTO) element))) {
55: return red;
56: }
57: }
58: return null;
59: }
60:
61: public Color getBackground(Object element) {
62: return null;
63: }
64: }
|