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.ICellModifier;
20: import org.eclipse.swt.widgets.Item;
21: import org.eclipse.swt.widgets.TreeItem;
22:
23: /**
24: * Delegates to the {@link ICellModifier} 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 SummaryCellModifier implements ICellModifier {
31:
32: private Collection<SummaryData> data;
33:
34: public SummaryCellModifier(Collection<SummaryData> data) {
35: this .data = data;
36: }
37:
38: public boolean canModify(Object element, String property) {
39: for (SummaryData item : data) {
40: if (item == element)
41: return item.getModifier().canModify(element, property);
42: }
43: return false;
44: }
45:
46: public Object getValue(Object element, String property) {
47: for (SummaryData item : data) {
48: if (item == element)
49: return item.getModifier().getValue(element, property);
50: }
51:
52: return null;
53: }
54:
55: public void modify(Object element, String property, Object value) {
56: for (SummaryData item : data) {
57: if (item == ((Item) element).getData()) {
58: item.getModifier().modify(element, property, value);
59: }
60: }
61: }
62:
63: }
|