01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.tool.info.internal.display;
18:
19: import java.io.IOException;
20:
21: import net.refractions.udig.project.ui.controls.FeatureTableControl;
22: import net.refractions.udig.tool.info.InfoDisplay;
23: import net.refractions.udig.tool.info.LayerPointInfo;
24:
25: import org.eclipse.swt.widgets.Composite;
26: import org.eclipse.swt.widgets.Control;
27: import org.geotools.data.FeatureReader;
28: import org.geotools.data.FeatureResults;
29: import org.geotools.feature.FeatureCollection;
30:
31: /**
32: * Nested browser used to display LayerPointInfo.
33: *
34: * @author Jody Garnett
35: * @since 0.3
36: */
37: public class FeatureInfoDisplay extends InfoDisplay {
38:
39: /** <code>content</code> field */
40: protected FeatureTableControl content;
41:
42: public Control getControl() {
43: return content.getControl();
44: }
45:
46: public void createDisplay(Composite parent) {
47: // content = new Text( parent, SWT.DEFAULT );
48: content = new FeatureTableControl();
49: content.createTableControl(parent);
50: }
51:
52: /**
53: * Focus the browser onto LayerPointInfo.getRequestURL.
54: *
55: * @see net.refractions.udig.tool.info.InfoDisplay#setInfo(net.refractions.udig.project.render.LayerPointInfo)
56: * @param info
57: */
58: public void setInfo(LayerPointInfo info) {
59: if (info == null) {
60: content.clear();
61: } else {
62: try {
63: Object value = info.acquireValue();
64: if (value == null) {
65: // make empty ?
66: content.clear();
67: }
68: if (value instanceof FeatureResults) {
69: content.setFeatures((FeatureResults) value);
70: } else if (value instanceof FeatureReader) {
71: content.setFeatures((FeatureReader) value);
72: } else if (value instanceof FeatureCollection) {
73: content.setFeatures((FeatureCollection) value);
74: } else {
75: content.clear();
76: }
77: } catch (IOException e) {
78: content.clear();
79: }
80: }
81: }
82: }
|