Source Code Cross Referenced for ToolContextImpl.java in  » GIS » udig-1.1 » net » refractions » udig » project » ui » internal » tool » 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.project.ui.internal.tool.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * <copyright>
003:         * </copyright>
004:         *
005:         * $Id: ToolContextImpl.java 22197 2006-10-17 16:48:42Z jeichar $
006:         */package net.refractions.udig.project.ui.internal.tool.impl;
007:
008:        import java.awt.Rectangle;
009:
010:        import net.refractions.udig.project.command.Command;
011:        import net.refractions.udig.project.command.EditCommand;
012:        import net.refractions.udig.project.command.MapCommand;
013:        import net.refractions.udig.project.command.NavCommand;
014:        import net.refractions.udig.project.command.factory.BasicCommandFactory;
015:        import net.refractions.udig.project.command.factory.EditCommandFactory;
016:        import net.refractions.udig.project.command.factory.NavigationCommandFactory;
017:        import net.refractions.udig.project.command.factory.SelectionCommandFactory;
018:        import net.refractions.udig.project.internal.impl.AbstractContextImpl;
019:        import net.refractions.udig.project.internal.render.RenderManager;
020:        import net.refractions.udig.project.ui.commands.DrawCommandFactory;
021:        import net.refractions.udig.project.ui.commands.IDrawCommand;
022:        import net.refractions.udig.project.ui.internal.MapEditor;
023:        import net.refractions.udig.project.ui.internal.MapEditorSite;
024:        import net.refractions.udig.project.ui.internal.tool.ToolContext;
025:        import net.refractions.udig.project.ui.render.displayAdapter.ViewportPane;
026:
027:        import org.eclipse.core.runtime.Plugin;
028:        import org.eclipse.core.runtime.Status;
029:        import org.eclipse.jface.action.IStatusLineManager;
030:        import org.eclipse.swt.widgets.Display;
031:        import org.eclipse.ui.IActionBars2;
032:        import org.eclipse.ui.IEditorPart;
033:        import org.eclipse.ui.IEditorSite;
034:        import org.eclipse.ui.IWorkbench;
035:        import org.eclipse.ui.IWorkbenchPage;
036:        import org.eclipse.ui.IWorkbenchWindow;
037:        import org.eclipse.ui.PlatformUI;
038:
039:        /**
040:         * <p>
041:         * The following features are implemented:
042:         * <ul>
043:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getContextModel <em>Context Model</em>}</li>
044:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getPixelSize <em>Pixel Size</em>}</li>
045:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getViewportModel <em>Viewport Model</em>}</li>
046:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getEditManager <em>Edit Manager</em>}</li>
047:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getRenderManager <em>Render Manager</em>}</li>
048:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getMapDisplay <em>Map Display</em>}</li>
049:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getMap <em>Map</em>}</li>
050:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getProject <em>Project</em>}</li>
051:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getViewportPane <em>Viewport Pane</em>}</li>
052:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getDrawFactory <em>Draw Factory</em>}</li>
053:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getEditFactory <em>Edit Factory</em>}</li>
054:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getNavigationFactory <em>Navigation Factory</em>}</li>
055:         * <li>{@link net.refractions.udig.project.ui.internal.tool.impl.ToolContextImpl#getSelectionFactory <em>Selection Factory</em>}</li>
056:         * </ul>
057:         * </p>
058:         * 
059:         */
060:        public class ToolContextImpl extends AbstractContextImpl implements 
061:                ToolContext {
062:
063:            /**
064:             * The cached value of the '{@link #getDrawFactory() <em>Draw Factory</em>}' attribute. 
065:             * 
066:             * @see #getDrawFactory()
067:             */
068:            private final DrawCommandFactory drawFactory = DrawCommandFactory
069:                    .getInstance();
070:
071:            /**
072:             * The cached value of the '{@link #getEditFactory() <em>Edit Factory</em>}' attribute. 
073:             * 
074:             * @see #getEditFactory()
075:             */
076:            private final EditCommandFactory editFactory = EditCommandFactory
077:                    .getInstance();
078:
079:            /**
080:             * The cached value of the '{@link #getNavigationFactory() <em>Navigation Factory</em>}'
081:             * attribute.
082:             * 
083:             * @see #getNavigationFactory()
084:             */
085:            private final NavigationCommandFactory navigationFactory = NavigationCommandFactory
086:                    .getInstance();
087:
088:            /**
089:             * The cached value of the '{@link #getSelectionFactory() <em>Selection Factory</em>}'
090:             * attribute. 
091:             * 
092:             * @see #getSelectionFactory()
093:             */
094:            private final SelectionCommandFactory selectionFactory = SelectionCommandFactory
095:                    .getInstance();
096:
097:            private final BasicCommandFactory basicCommandFactory = BasicCommandFactory
098:                    .getInstance();
099:
100:            public ToolContextImpl() {
101:                super ();
102:            }
103:
104:            public ToolContextImpl(ToolContextImpl impl) {
105:                super (impl);
106:            }
107:
108:            public DrawCommandFactory getDrawFactory() {
109:                return drawFactory;
110:            }
111:
112:            public EditCommandFactory getEditFactory() {
113:                return editFactory;
114:            }
115:
116:            public NavigationCommandFactory getNavigationFactory() {
117:                return navigationFactory;
118:            }
119:
120:            public SelectionCommandFactory getSelectionFactory() {
121:                return selectionFactory;
122:            }
123:
124:            public void sendCommand(IDrawCommand command) {
125:                command.setMap(getMap());
126:                ViewportPane viewportPane = ((ViewportPane) getRenderManagerInternal()
127:                        .getMapDisplay());
128:                viewportPane.addDrawCommand(command);
129:                Rectangle validArea;
130:                try {
131:                    validArea = command.getValidArea();
132:                } catch (Exception e) {
133:                    validArea = null;
134:                }
135:                if (validArea != null)
136:                    viewportPane.repaint(validArea.x, validArea.y,
137:                            validArea.width, validArea.height);
138:                else
139:                    viewportPane.repaint();
140:            }
141:
142:            public void sendASyncCommand(Command command) {
143:                if (command instanceof  NavCommand)
144:                    getMapInternal().sendCommandASync((NavCommand) command);
145:                else if (command instanceof  EditCommand)
146:                    getMapInternal().sendCommandASync((EditCommand) command);
147:                else if (command instanceof  IDrawCommand)
148:                    sendCommand((IDrawCommand) command);
149:                else if (command instanceof  MapCommand)
150:                    getMapInternal().sendCommandASync((MapCommand) command);
151:                else
152:                    getProjectInternal().sendASync(command);
153:            }
154:
155:            public void sendSyncCommand(Command command) {
156:                if (command instanceof  NavCommand)
157:                    getMapInternal().sendCommandSync((NavCommand) command);
158:                else if (command instanceof  EditCommand)
159:                    getMapInternal().sendCommandSync((EditCommand) command);
160:                else if (command instanceof  IDrawCommand)
161:                    sendCommand((IDrawCommand) command);
162:                else if (command instanceof  MapCommand)
163:                    getMapInternal().sendCommandSync((MapCommand) command);
164:                else
165:                    getProjectInternal().sendSync(command);
166:            }
167:
168:            public ViewportPane getViewportPane() {
169:                return (ViewportPane) getMapDisplay();
170:            }
171:
172:            public IWorkbench getWorkbench() {
173:                return PlatformUI.getWorkbench();
174:            }
175:
176:            public Display getDisplay() {
177:                return Display.getDefault();
178:            }
179:
180:            public void log(Plugin currentPlugin, String message, int severity,
181:                    Throwable exception) {
182:                String ID1 = currentPlugin.getBundle().getSymbolicName();
183:                currentPlugin.getLog().log(
184:                        new Status(severity, ID1, 0, message, exception));
185:            }
186:
187:            @Override
188:            public RenderManager getRenderManagerInternal() {
189:                return getMapInternal().getRenderManagerInternal();
190:            }
191:
192:            public IStatusLineManager getStatusBar() {
193:                MapEditorSite site = getEditorSite();
194:                if (site == null)
195:                    return null;
196:                return site.getActionBars().getStatusLineManager();
197:            }
198:
199:            public IActionBars2 getActionBars() {
200:                IEditorSite site = getEditorSite();
201:                if (site == null)
202:                    return null;
203:                return (IActionBars2) site.getActionBars();
204:            }
205:
206:            private MapEditorSite getEditorSite() {
207:                IWorkbenchWindow window = getWindow();
208:                if (window == null)
209:                    return null;
210:                IWorkbenchPage page = window.getActivePage();
211:                if (page == null)
212:                    return null;
213:                IEditorPart part = page.getActiveEditor();
214:                if (part == null || !(part instanceof  MapEditor))
215:                    return null;
216:                return ((MapEditor) part).getMapEditorSite();
217:            }
218:
219:            private IWorkbenchWindow getWindow() {
220:                IWorkbench bench = PlatformUI.getWorkbench();
221:                if (bench == null)
222:                    return null;
223:                IWorkbenchWindow window = bench.getActiveWorkbenchWindow();
224:                if (window == null) {
225:                    if (bench.getWorkbenchWindowCount() > 0)
226:                        window = bench.getWorkbenchWindows()[0];
227:                }
228:                return window;
229:            }
230:
231:            public void updateUI(Runnable runnable) {
232:                if (Display.getCurrent() != null) {
233:                    runnable.run();
234:                    return;
235:                }
236:                IWorkbench bench = PlatformUI.getWorkbench();
237:                Display display = null;
238:                if (bench != null)
239:                    display = bench.getDisplay();
240:
241:                if (display == null)
242:                    display = Display.getDefault();
243:
244:                display.asyncExec(runnable);
245:            }
246:
247:            public BasicCommandFactory getBasicCommandFactory() {
248:                return this .basicCommandFactory;
249:            }
250:
251:            public ToolContextImpl copy() {
252:                return new ToolContextImpl(this );
253:            }
254:        } // Impl
w_ww.__j_a__v_a2__s.___c___o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.