01: package net.refractions.udig.validation.ui;
02:
03: import net.refractions.udig.validation.internal.Messages;
04:
05: import org.eclipse.jface.viewers.ILabelProviderListener;
06: import org.eclipse.jface.viewers.ITableLabelProvider;
07: import org.eclipse.swt.graphics.Image;
08: import org.geotools.validation.dto.ArgumentDTO;
09:
10: public class ValidationTableLabelProvider implements
11: ITableLabelProvider {
12:
13: public ValidationTableLabelProvider() {
14: }
15:
16: public Image getImage(Object element) {
17: return null;
18: }
19:
20: public void addListener(ILabelProviderListener listener) {
21: }
22:
23: public void dispose() {
24: }
25:
26: public boolean isLabelProperty(Object element, String property) {
27: return false;
28: }
29:
30: public void removeListener(ILabelProviderListener listener) {
31: }
32:
33: public Image getColumnImage(Object element, int columnIndex) {
34: return null;
35: }
36:
37: public String getColumnText(Object element, int columnIndex) {
38: switch (columnIndex) {
39: case 0:
40: return ((ArgumentDTO) element).getName();
41: case 1:
42: Object value = ((ArgumentDTO) element).getValue();
43: if (value == null) {
44: return ""; //$NON-NLS-1$
45: }
46: ArgumentDTO arg = (ArgumentDTO) element;
47: //determine if the element came from a combobox or a textbox
48: if (ValidationDialog.isTypeRef(arg.getName())) {
49: //it's a typeRef, so this is a comboBox... get the label
50: // (we could try to chop up the string we have and to get the
51: // layer, but we'll play it safe and get it from the list of
52: // layers and typeRefs in ValidationDialog)
53: return ValidationDialog.getTypeRefLayer(value
54: .toString());
55: } else {
56: //just return the value of the arg
57: return value.toString();
58: }
59: default:
60: return Messages.ValidationTableLabelProvider_invalidColumn
61: + columnIndex;
62: }
63: }
64:
65: }
|