Source Code Cross Referenced for DeleteTool.java in  » GIS » udig-1.1 » net » refractions » udig » tools » edit » impl » 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.tools.edit.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003:         * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004:         * under the terms of the GNU Lesser General Public License as published by the Free Software
005:         * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006:         * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007:         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008:         */
009:        package net.refractions.udig.tools.edit.impl;
010:
011:        import java.awt.Point;
012:
013:        import net.refractions.udig.project.ILayer;
014:        import net.refractions.udig.project.command.MapCommand;
015:        import net.refractions.udig.project.ui.internal.commands.draw.DrawShapeCommand;
016:        import net.refractions.udig.project.ui.render.displayAdapter.MapMouseEvent;
017:        import net.refractions.udig.project.ui.tool.AbstractModalTool;
018:        import net.refractions.udig.project.ui.tool.ModalTool;
019:        import net.refractions.udig.tool.edit.internal.Messages;
020:        import net.refractions.udig.tools.edit.EditPlugin;
021:
022:        import org.eclipse.jface.action.IStatusLineManager;
023:        import org.geotools.feature.Feature;
024:        import org.geotools.feature.FeatureCollection;
025:        import org.geotools.feature.FeatureIterator;
026:        import org.geotools.geometry.jts.ReferencedEnvelope;
027:
028:        import com.vividsolutions.jts.geom.Envelope;
029:
030:        /**
031:         * Deletes a feature from the currently selected layer or the top layer.
032:         * 
033:         * @author Jesse
034:         * @since 0.8.1
035:         */
036:        public class DeleteTool extends AbstractModalTool implements  ModalTool {
037:
038:            /**
039:             * Construct <code>DeleteTool</code>.
040:             *
041:             */
042:            public DeleteTool() {
043:                super (MOUSE | MOTION);
044:            }
045:
046:            @Override
047:            public void setActive(final boolean active) {
048:                super .setActive(active);
049:                setStatusBarMessage(active);
050:            }
051:
052:            private void setStatusBarMessage(final boolean active) {
053:                getContext().updateUI(new Runnable() {
054:                    public void run() {
055:                        if (getContext().getActionBars() == null)
056:                            return;
057:                        IStatusLineManager bar = getContext().getActionBars()
058:                                .getStatusLineManager();
059:                        if (bar != null) {
060:                            if (active) {
061:                                if (getContext().getMapLayers().size() > 0)
062:                                    bar.setMessage(Messages.DeleteTool_status);
063:                            } else
064:                                bar.setMessage(""); //$NON-NLS-1$
065:                            bar.setErrorMessage(null);
066:                        }
067:                    }
068:                });
069:            }
070:
071:            @Override
072:            public void mousePressed(MapMouseEvent e) {
073:                draw.setValid(true); // make sure context.getViewportPane().repaint() knows about us        
074:                context.sendASyncCommand(draw); // should of isValided us       
075:                feedback(e);
076:
077:            }
078:
079:            @Override
080:            public void mouseDragged(MapMouseEvent e) {
081:                feedback(e);
082:
083:            }
084:
085:            DrawShapeCommand draw = new DrawShapeCommand();
086:
087:            /**
088:             * Provides user feedback
089:             * @param e 
090:             */
091:            public void feedback(MapMouseEvent e) {
092:                ReferencedEnvelope box = context.getBoundingBox(new Point(
093:                        e.x - 3, e.y - 3), 7);
094:                draw.setShape(context.toShape(box));
095:                context.getViewportPane().repaint();
096:
097:                super .mouseDragged(e);
098:            }
099:
100:            public void mouseReleased(MapMouseEvent e) {
101:                if (getContext().getMapLayers().size() == 0)
102:                    return;
103:                FeatureIterator reader = null;
104:                try {
105:
106:                    ILayer layer = getContext().getEditManager()
107:                            .getSelectedLayer();
108:                    if (layer == null)
109:                        layer = getContext().getMapLayers().get(0);
110:
111:                    if (layer == null)
112:                        throw new Exception("No layers in map"); //$NON-NLS-1$
113:
114:                    Envelope env = getContext().getBoundingBox(e.getPoint(), 6);
115:                    FeatureCollection results = getContext().getFeaturesInBbox(
116:                            layer, env);
117:
118:                    reader = results.features();
119:
120:                    final boolean found = !reader.hasNext();
121:                    getContext().updateUI(new Runnable() {
122:                        public void run() {
123:                            if (getContext().getActionBars() == null)
124:                                return;
125:                            IStatusLineManager bar = getContext()
126:                                    .getActionBars().getStatusLineManager();
127:                            if (bar != null) {
128:                                if (found)
129:                                    bar
130:                                            .setErrorMessage(Messages.DeleteTool_warning);
131:                                else
132:                                    bar.setErrorMessage(null);
133:                            }
134:                        }
135:                    });
136:
137:                    if (found)
138:                        return;
139:
140:                    Feature feature = reader.next();
141:
142:                    MapCommand deleteFeatureCommand = getContext()
143:                            .getEditFactory().createDeleteFeature(feature,
144:                                    layer);
145:                    getContext().sendASyncCommand(deleteFeatureCommand);
146:
147:                    getContext().getViewportPane().repaint();
148:                } catch (Exception e1) {
149:                    EditPlugin.log(null, e1);
150:                } finally {
151:                    try {
152:                        if (reader != null)
153:                            reader.close();
154:                    } catch (Exception e2) {
155:                        EditPlugin.log(null, e2);
156:                    }
157:                    draw.setValid(false); // get us off the draw stack for context.getViewportPane().repaint();
158:                    getContext().getViewportPane().repaint();
159:                }
160:            }
161:
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.