Source Code Cross Referenced for InfoView2.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:        /* uDig - User Friendly Desktop Internet GIS client
002:         * http://udig.refractions.net
003:         * (C) 2004, Refractions Research Inc.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation;
008:         * version 2.1 of the License.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         */
015:        package net.refractions.udig.tool.info.internal;
016:
017:        import java.io.IOException;
018:        import java.util.List;
019:
020:        import net.refractions.udig.project.AdaptableFeature;
021:        import net.refractions.udig.project.ILayer;
022:        import net.refractions.udig.project.internal.impl.LayerImpl;
023:        import net.refractions.udig.project.ui.ApplicationGIS;
024:        import net.refractions.udig.project.ui.internal.properties.FeaturePropertySource;
025:        import net.refractions.udig.tool.info.InfoPlugin;
026:        import net.refractions.udig.tool.info.InfoTool;
027:        import net.refractions.udig.tool.info.LayerPointInfo;
028:        import net.refractions.udig.tool.info.internal.display.BrowserInfoDisplay;
029:        import net.refractions.udig.tool.info.internal.display.TextInfoDisplay;
030:        import net.refractions.udig.ui.SearchPart;
031:
032:        import org.eclipse.core.runtime.IProgressMonitor;
033:        import org.eclipse.jface.action.IAction;
034:        import org.eclipse.jface.action.IToolBarManager;
035:        import org.eclipse.jface.viewers.IBaseLabelProvider;
036:        import org.eclipse.jface.viewers.IColorProvider;
037:        import org.eclipse.jface.viewers.ISelection;
038:        import org.eclipse.jface.viewers.IStructuredContentProvider;
039:        import org.eclipse.jface.viewers.ITreeContentProvider;
040:        import org.eclipse.jface.viewers.LabelProvider;
041:        import org.eclipse.jface.viewers.StructuredSelection;
042:        import org.eclipse.jface.viewers.StructuredViewer;
043:        import org.eclipse.jface.viewers.TreeViewer;
044:        import org.eclipse.jface.viewers.Viewer;
045:        import org.eclipse.swt.SWT;
046:        import org.eclipse.swt.custom.SashForm;
047:        import org.eclipse.swt.graphics.Color;
048:        import org.eclipse.swt.widgets.Composite;
049:        import org.eclipse.swt.widgets.Text;
050:        import org.eclipse.ui.IActionBars;
051:        import org.eclipse.ui.part.PageBook;
052:        import org.eclipse.ui.views.properties.PropertySheetPage;
053:        import org.geotools.data.FeatureSource;
054:        import org.geotools.data.ows.Layer;
055:        import org.geotools.feature.Feature;
056:        import org.geotools.geometry.jts.ReferencedEnvelope;
057:
058:        /**
059:         * Info recast as a search part.
060:         * 
061:         * @author jgarnett
062:         * @since 1.0.0
063:         */
064:        public class InfoView2 extends SearchPart {
065:            /** <code>VIEW_ID</code> field */
066:            public static final String VIEW_ID = "net.refractions.udig.tool.info.infoView"; //$NON-NLS-1$
067:            private Text information;
068:            private TextInfoDisplay textDisplay;
069:            private BrowserInfoDisplay browserDisplay;
070:            //private FeatureDisplay featureDisplay;
071:            private PropertySheetPage featureDisplay;
072:
073:            private static final class InfoViewLabelProvider extends
074:                    LabelProvider implements  IColorProvider {
075:                public String getText(Object element) {
076:                    if (element instanceof  Feature) {
077:                        return ((Feature) element).getID();
078:                    } else if (element instanceof  LayerPointInfo) {
079:                        LayerPointInfo info = (LayerPointInfo) element;
080:                        return info.getLayer().getName();
081:                    }
082:                    return super .getText(element);
083:                }
084:
085:                /**
086:                 * @see net.refractions.udig.project.internal.provider.LayerItemProvider
087:                 */
088:                public Color getBackground(Object element) {
089:                    if (element instanceof  AdaptableFeature) {
090:                        AdaptableFeature feature = (AdaptableFeature) element;
091:                        LayerImpl layer = (LayerImpl) feature
092:                                .getAdapter(ILayer.class);
093:                        IColorProvider colorProvider = (IColorProvider) layer
094:                                .getAdapter(IColorProvider.class);
095:                        if (colorProvider == null)
096:                            return null;
097:                        return colorProvider.getBackground(layer);
098:                    }
099:                    return null;
100:                }
101:
102:                /**
103:                 * @see net.refractions.udig.project.internal.provider.LayerItemProvider
104:                 */
105:                public Color getForeground(Object element) {
106:                    if (element instanceof  AdaptableFeature) {
107:                        AdaptableFeature feature = (AdaptableFeature) element;
108:                        LayerImpl layer = (LayerImpl) feature
109:                                .getAdapter(ILayer.class);
110:                        IColorProvider colorProvider = (IColorProvider) layer
111:                                .getAdapter(IColorProvider.class);
112:                        if (colorProvider == null)
113:                            return null;
114:                        return colorProvider.getForeground(layer);
115:                    }
116:                    return null;
117:                }
118:            }
119:
120:            public static class InfoRequest {
121:                public ReferencedEnvelope bbox;
122:                public List<ILayer> layers;
123:            };
124:
125:            /**
126:             * 
127:             */
128:            public InfoView2() {
129:                super (InfoPlugin.getDefault().getDialogSettings());
130:            }
131:
132:            @Override
133:            protected Composite createDetails(SashForm splitter) {
134:                PageBook book = new PageBook(splitter, SWT.NONE);
135:                splitter.setWeights(new int[] { 10, 90 });
136:
137:                {
138:                    information = new Text(book, SWT.WRAP);
139:                    information.setText(Messages.InfoView_instructions_text);
140:                    book.showPage(information);
141:                }
142:                {
143:                    textDisplay = new TextInfoDisplay();
144:                    textDisplay.createDisplay(book);
145:                    //textDisplay.getControl().setVisible(false);
146:                }
147:                {
148:                    browserDisplay = new BrowserInfoDisplay();
149:                    browserDisplay.createDisplay(book);
150:                    //browserDisplay.getControl().setVisible(false);
151:                }
152:                {
153:                    //featureDisplay = new FeatureDisplay();
154:                    //featureDisplay.createDisplay(book);
155:                    featureDisplay = new PropertySheetPage();
156:                    featureDisplay.createControl(book);
157:                    //featureDisplay.getControl().setVisible(false);
158:                }
159:                return book;
160:            }
161:
162:            @Override
163:            protected void fillActionBars() {
164:                IActionBars actionBars = getViewSite().getActionBars();
165:                IToolBarManager toolBar = actionBars.getToolBarManager();
166:
167:                IAction infoTool = ApplicationGIS.getToolManager().getTool(
168:                        InfoTool.ID, InfoTool.CATEGORY_ID);
169:                assert (infoTool != null);
170:                if (toolBar != null) {
171:                    toolBar.add(infoTool);
172:                }
173:                super .fillActionBars();
174:
175:            }
176:
177:            @Override
178:            protected PageBook getDetails() {
179:                return (PageBook) super .getDetails();
180:            }
181:
182:            @Override
183:            protected void showDetail(Object selection) {
184:                if (selection == null) {
185:                    getDetails().showPage(information);
186:                    return;
187:                }
188:                if (selection instanceof  Feature) {
189:                    getDetails().showPage(featureDisplay.getControl());
190:                    FeaturePropertySource source = new FeaturePropertySource(
191:                            (Feature) selection, false, false);
192:                    StructuredSelection sel = new StructuredSelection(source);
193:                    featureDisplay.selectionChanged(null, sel);
194:                    //featureDisplay.setInfo( (Feature) selection );
195:                }
196:                if (selection instanceof  LayerPointInfo) {
197:                    LayerPointInfo info = (LayerPointInfo) selection;
198:                    if (info.getMimeType() == null) {
199:                        getDetails().showPage(information);
200:                    } else if (info.getMimeType()
201:                            .startsWith(LayerPointInfo.GML)) {
202:                        getDetails().showPage(featureDisplay.getControl());
203:                        try {
204:                            Feature feature = (Feature) info.acquireValue();
205:                            FeaturePropertySource src = new FeaturePropertySource(
206:                                    feature);
207:                            StructuredSelection sel = new StructuredSelection(
208:                                    src);
209:                            featureDisplay.selectionChanged(null, sel);
210:                        } catch (IOException ex) {
211:                            InfoPlugin.log(
212:                                    "GML value could not be acquired.", ex); //$NON-NLS-1$
213:                        }
214:                        //featureDisplay.setInfo(info);
215:                    } else if (info.getRequestURL() != null
216:                            && info.getMimeType().startsWith(
217:                                    LayerPointInfo.HTML)) {
218:                        getDetails().showPage(browserDisplay.getControl());
219:                        browserDisplay.setInfo(info);
220:                    } else if (info.getRequestURL() != null
221:                            && info.getMimeType()
222:                                    .startsWith(LayerPointInfo.XML)) {
223:                        getDetails().showPage(browserDisplay.getControl());
224:                        browserDisplay.setInfo(info);
225:                    } else if (info.getRequestURL() != null
226:                            && info.getMimeType().startsWith(
227:                                    LayerPointInfo.ERROR)) {
228:                        getDetails().showPage(browserDisplay.getControl());
229:                        browserDisplay.setInfo(info);
230:                    } else {
231:                        getDetails().showPage(information);
232:                    }
233:                }
234:
235:            }
236:
237:            @Override
238:            public void createPartControl(Composite aParent) {
239:                super .createPartControl(aParent);
240:                ApplicationGIS.getToolManager().registerActionsWithPart(this );
241:            }
242:
243:            /**
244:             * Called by search( Object filter ) in a job to get stuff done.
245:             * <p>
246:             * Resulting like is provided to the viewer via setInput.
247:             * </p>
248:             */
249:            @Override
250:            protected void searchImplementation(Object filter,
251:                    IProgressMonitor monitor, ResultSet set) {
252:                InfoRequest request = (InfoRequest) filter;
253:
254:                if (monitor != null) {
255:                    monitor.beginTask(Messages.InfoView2_information_request,
256:                            request.layers.size());
257:                }
258:                int work = 0;
259:                for (int i = request.layers.size() - 1; i > -1; i--) {
260:                    ILayer layer = request.layers.get(i); //navigate the list backwards
261:                    monitor.subTask(layer.getName());
262:                    monitor.worked(++work);
263:
264:                    if (!layer.isVisible())
265:                        continue;
266:                    //if( !layer.isApplicable( "information" )) continue;
267:
268:                    if (layer.hasResource(FeatureSource.class)) {
269:                        try {
270:                            List<Feature> more = DataStoreDescribeLayer.info2(
271:                                    layer, request.bbox, monitor);
272:                            if (!more.isEmpty())
273:                                set.addAll(more);
274:                        } catch (Throwable t) {
275:                            InfoPlugin
276:                                    .log(
277:                                            "Information request " + layer.getName() + " failed " + t, t); //$NON-NLS-1$ //$NON-NLS-2$
278:                        }
279:                        continue;
280:                    }
281:                    if (layer.hasResource(Layer.class)) {
282:                        // TODO: freek out because WMS is so hard to use
283:                        try {
284:                            LayerPointInfo hit = WMSDescribeLayer.info2(layer,
285:                                    request.bbox);
286:                            if (hit != null)
287:                                set.add(hit);
288:                        } catch (Throwable t) {
289:                            InfoPlugin
290:                                    .log(
291:                                            "Information request " + layer.getName() + " failed " + t, t); //$NON-NLS-1$ //$NON-NLS-2$
292:                        }
293:                        continue;
294:                    }
295:                }
296:            }
297:
298:            @Override
299:            protected IBaseLabelProvider createLabelProvider() {
300:                return new InfoViewLabelProvider();
301:            }
302:
303:            @Override
304:            protected StructuredViewer createViewer(Composite parent) {
305:                TreeViewer viewer = new TreeViewer(parent);
306:                return viewer;
307:            }
308:
309:            @Override
310:            protected ISelection getSelection(List results) {
311:
312:                for (Object object : results) {
313:                    ILayer layer = null;
314:                    if (object instanceof  LayerPointInfo) {
315:                        LayerPointInfo info = (LayerPointInfo) object;
316:                        layer = info.getLayer();
317:                    }
318:                    if (object instanceof  AdaptableFeature) {
319:                        AdaptableFeature feature = (AdaptableFeature) object;
320:                        layer = (ILayer) feature.getAdapter(ILayer.class);
321:                    }
322:                    if (layer == ApplicationGIS.getActiveMap().getEditManager()
323:                            .getSelectedLayer()) {
324:                        return new StructuredSelection(object);
325:                    }
326:                }
327:                if (results.isEmpty())
328:                    return new StructuredSelection();
329:
330:                return new StructuredSelection(results.get(0));
331:            }
332:
333:            @Override
334:            protected IStructuredContentProvider createContentProvider() {
335:                return new ITreeContentProvider() {
336:                    public Object[] getElements(Object inputElement) {
337:                        if (inputElement instanceof  List) {
338:                            return ((List) inputElement).toArray();
339:                        }
340:                        return null;
341:                    }
342:
343:                    public void dispose() {
344:                    }
345:
346:                    public void inputChanged(Viewer viewer, Object oldInput,
347:                            Object newInput) {
348:                        //assert( newInput instanceof List );
349:                        // lists don't have events for us to watch
350:                    }
351:
352:                    public Object[] getChildren(Object parentElement) {
353:                        return null;
354:                    }
355:
356:                    public Object getParent(Object element) {
357:                        return null;
358:                    }
359:
360:                    public boolean hasChildren(Object element) {
361:                        return false;
362:                    }
363:                };
364:            }
365:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.