Source Code Cross Referenced for InfoTreeViewer.java in  » GIS » udig-1.1 » net » refractions » udig » tool » info » internal » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » udig 1.1 » net.refractions.udig.tool.info.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    uDig - User Friendly Desktop Internet GIS client
003:         *    http://udig.refractions.net
004:         *    (C) 2004, Refractions Research Inc.
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package net.refractions.udig.tool.info.internal;
018:
019:        import java.util.List;
020:
021:        import net.refractions.udig.tool.info.LayerPointInfo;
022:        import net.refractions.udig.ui.ImageCache;
023:
024:        import org.eclipse.jface.viewers.ILabelProvider;
025:        import org.eclipse.jface.viewers.ILabelProviderListener;
026:        import org.eclipse.jface.viewers.ITreeContentProvider;
027:        import org.eclipse.jface.viewers.TreeViewer;
028:        import org.eclipse.jface.viewers.Viewer;
029:        import org.eclipse.swt.graphics.Image;
030:        import org.eclipse.swt.widgets.Composite;
031:
032:        /**
033:         * Display Information from InfoTool as a Tree.
034:         * <p>
035:         * InfoTool currently grabs a list from the Renderstack, this may be replaced
036:         * with real Information object at somepoint in the future.
037:         * </p>
038:         * <p>
039:         * For the List&gt;LayerPointInfo&lt;:
040:         * <ul>
041:         * <li>Each LayerPointInfo is a node in the Tree
042:         * <li>LayerPointInfo of type gml the value will be a FeatureCollection, each Feature will
043:         * be a node in the tree (at least until we get a FeatureCollection Viewer)
044:         * </ul>
045:         * </p>
046:         * 
047:         * @author Jody Garnett, Refractions Research 
048:         * @since 0.6
049:         */
050:        public class InfoTreeViewer extends TreeViewer implements 
051:                ITreeContentProvider, ILabelProvider {
052:
053:            List<LayerPointInfo> information = null;
054:            ImageCache imageCache = new ImageCache();
055:
056:            /**
057:             * Construct <code>CatalogTreeViewer</code>.
058:             *
059:             * @param parent
060:             */
061:            public InfoTreeViewer(Composite parent) {
062:                super (parent);
063:                setContentProvider(this );
064:                setLabelProvider(this );
065:                setInput(information);
066:                expandToLevel(2);
067:            }
068:
069:            /**
070:             * @see org.eclipse.jface.viewers.IContentProvider#dispose()
071:             */
072:            public void dispose() {
073:                if (information != null) {
074:                    information.clear();
075:                    information = null;
076:                }
077:                if (imageCache != null) {
078:                    imageCache.dispose();
079:                    imageCache = null;
080:                }
081:            }
082:
083:            /**
084:             * Provides a mapping from Information to TreeViewer.
085:             * <p>
086:             * For the List&gt;LayerPointInfo&lt;:
087:             * <ul>
088:             * <li>Each LayerPointInfo is a node in the Tree
089:             * <li>LayerPointInfo of type gml the value will be a FeatureCollection, each Feature will
090:             * be a node in the tree (at least until we get a FeatureCollection Viewer)
091:             * </ul>
092:             * </p>
093:             */
094:
095:            /**
096:             * Returns the child elements of the given parent element.
097:             * <p>
098:             * The difference between this method and <code>IStructuredContentProvider.getElements</code> 
099:             * is that <code>getElements</code> is called to obtain the 
100:             * tree viewer's root elements, whereas <code>getChildren</code> is used
101:             * to obtain the children of a given parent element in the tree (including a root).
102:             * </p>
103:             * The result is not modified by the viewer.
104:             * </p>
105:             * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
106:             *
107:             * @param parent the parent element
108:             * @return an array of child elements
109:             * 
110:             */
111:            public Object[] getChildren(Object parent) {
112:                if (parent == information) {
113:                    return information.toArray();
114:                }
115:                return null;
116:            }
117:
118:            /**
119:             * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
120:             */
121:            public Object getParent(Object element) {
122:                if (element == information) {
123:                    return null;
124:                } else if (element instanceof  LayerPointInfo) {
125:                    return information;
126:                }
127:                return null;
128:            }
129:
130:            /**
131:             * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
132:             */
133:            public boolean hasChildren(Object element) {
134:                return (element == information);
135:            }
136:
137:            /**
138:             * Returns the elements to display in the viewer 
139:             * when its input is set to the given element. 
140:             * These elements can be presented as rows in a table, items in a list, etc.
141:             * The result is not modified by the viewer.
142:             *
143:             * @param inputElement the input element
144:             * @return the array of elements to display in the viewer
145:             */
146:            public Object[] getElements(Object inputElement) {
147:                return getChildren(inputElement);
148:            }
149:
150:            /**
151:             * Notificaiton that the input has been changed.
152:             * 
153:             * @see org.eclipse.jface.viewers.AbstractTreeViewer#inputChanged(java.lang.Object, java.lang.Object)
154:             * @param input
155:             * @param oldInput
156:             */
157:            @SuppressWarnings("unchecked")
158:            protected void inputChanged(Object input, Object oldInput) {
159:                if (oldInput != null && oldInput instanceof  List) {
160:                    List oldInformation = (List) oldInput;
161:                    oldInformation.clear();
162:                }
163:                if (input == null) {
164:                    information = null;
165:                } else if (input instanceof  List) {
166:                    information = (List<LayerPointInfo>) input;
167:                }
168:            }
169:
170:            /**
171:             * Reset the viewer to new information
172:             * 
173:             * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
174:             * @param viewer
175:             * @param oldInput
176:             * @param newInput
177:             */
178:            public void inputChanged(Viewer viewer, Object oldInput,
179:                    Object newInput) {
180:                // viewer should equal InfoTreeViewer.this
181:                inputChanged(newInput, oldInput);
182:            }
183:
184:            /*
185:             * Image based on layer of selected info
186:             */
187:            public Image getImage(Object element) {
188:                if (element == information) {
189:                    return null; // Use information symbol?
190:                }
191:                if (element instanceof  LayerPointInfo) {
192:                    LayerPointInfo info = (LayerPointInfo) element;
193:                    return imageCache.getImage(info.getLayer().getGlyph());
194:                }
195:                return null;
196:            }
197:
198:            public String getText(Object element) {
199:                if (element == information) {
200:                    return "information"; //$NON-NLS-1$
201:                }
202:                if (element instanceof  LayerPointInfo) {
203:                    LayerPointInfo info = (LayerPointInfo) element;
204:                    return info.getLayer().getName();
205:                }
206:                return null;
207:            }
208:
209:            public void addListener(ILabelProviderListener listener) {
210:                // ignore as we reset the information on each request
211:            }
212:
213:            public boolean isLabelProperty(Object element, String property) {
214:                return false; // we don't issue events
215:            }
216:
217:            public void removeListener(ILabelProviderListener listener) {
218:                // ignore as we reset the information on each request
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.