01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.project.ui.summary;
16:
17: import java.util.Collection;
18:
19: import org.eclipse.jface.viewers.ICellEditorValidator;
20: import org.eclipse.swt.widgets.Tree;
21: import org.eclipse.swt.widgets.TreeItem;
22:
23: /**
24: * Delegates to the {@link ICellEditorValidator} object responsible for the modifying the
25: * {@link SummaryData} object. (It is obtained from the {@link SummaryData})
26: *
27: * @author Jesse
28: * @since 1.1.0
29: */
30: public class SummaryCellEditorValidator implements ICellEditorValidator {
31:
32: private Collection<SummaryData> data;
33: private Tree tree;
34:
35: public SummaryCellEditorValidator(Collection<SummaryData> data,
36: Tree tree) {
37: this .data = data;
38: this .tree = tree;
39: }
40:
41: public String isValid(Object value) {
42: TreeItem[] selection = tree.getSelection();
43: Object element = selection[0].getData();
44: for (SummaryData item : data) {
45: if (item == element)
46: return item.getValidator().isValid(value);
47: }
48: return null;
49: }
50:
51: }
|