Source Code Cross Referenced for CRSPropertyPage.java in  » GIS » udig-1.1 » net » refractions » udig » project » ui » 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.project.ui.internal 
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.project.ui.internal;
010:
011:        import net.refractions.udig.project.ILayer;
012:        import net.refractions.udig.project.command.UndoableComposite;
013:        import net.refractions.udig.project.internal.Layer;
014:        import net.refractions.udig.project.internal.Map;
015:        import net.refractions.udig.project.internal.ProjectPlugin;
016:        import net.refractions.udig.project.internal.commands.ChangeCRSCommand;
017:        import net.refractions.udig.project.ui.internal.commands.SetLayerCRSCommand;
018:        import net.refractions.udig.ui.CRSChooser;
019:        import net.refractions.udig.ui.Controller;
020:
021:        import org.eclipse.jface.dialogs.IDialogConstants;
022:        import org.eclipse.jface.dialogs.MessageDialogWithToggle;
023:        import org.eclipse.jface.preference.IPreferenceStore;
024:        import org.eclipse.swt.graphics.Point;
025:        import org.eclipse.swt.widgets.Composite;
026:        import org.eclipse.swt.widgets.Control;
027:        import org.eclipse.swt.widgets.Shell;
028:        import org.eclipse.ui.IWorkbench;
029:        import org.eclipse.ui.PlatformUI;
030:        import org.eclipse.ui.dialogs.PropertyPage;
031:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
032:
033:        /**
034:         * A user interface that allow a user to modify/create and set the current and default
035:         * CoordinateReferenceSystems used for maps.
036:         * <p>
037:         * Responsibilities:
038:         * <ul>
039:         * <li>Allow creation of user defined CRSs</li>
040:         * <li>Allow modification of the current CRS</li>
041:         * <li>Allow the CRS of a map to be set</li>
042:         * <li>Allow the default CRS of a workbench to be set</li>
043:         * </ul>
044:         * </p>
045:         * 
046:         * @author jeichar
047:         * @since 0.3
048:         */
049:        public class CRSPropertyPage extends PropertyPage {
050:
051:            public static class MapStrategy implements  ApplyCRSStrategy {
052:
053:                Map map;
054:
055:                public MapStrategy(Map map) {
056:                    this .map = map;
057:                }
058:
059:                public void applyCoordinateReferenceSystem(
060:                        CoordinateReferenceSystem crs) {
061:                    map.sendCommandASync(new ChangeCRSCommand(map, crs));
062:                }
063:
064:                public CoordinateReferenceSystem getCurrentCoordinateReferenceSystem() {
065:                    return map.getViewportModel().getCRS();
066:                }
067:            }
068:
069:            public static class LayerStrategy implements  ApplyCRSStrategy {
070:                private static final String SHOW_DIALOG_KEY = "SHOW_DIALOG_WHEN_UPDATE_LAYER_CRS_KEY"; //$NON-NLS-1$
071:                private static final String UPDATE_MAP_CRS_KEY = "UPDATE_MAP_CRS_WHEN_UNKOWN_IS_CHANGED"; //$NON-NLS-1$
072:                Layer layer;
073:
074:                public LayerStrategy(Layer layer) {
075:                    this .layer = layer;
076:                }
077:
078:                public void applyCoordinateReferenceSystem(
079:                        CoordinateReferenceSystem crs) {
080:                    UndoableComposite commands = new UndoableComposite();
081:                    commands.getCommands().add(
082:                            new SetLayerCRSCommand(layer, crs));
083:                    if (layer.getCRS() == ILayer.UNKNOWN_CRS
084:                            && layer.getMap().getViewportModel().getCRS()
085:                                    .equals(ILayer.UNKNOWN_CRS)) {
086:                        IPreferenceStore store = ProjectUIPlugin.getDefault()
087:                                .getPreferenceStore();
088:                        store.setDefault(SHOW_DIALOG_KEY, true);
089:                        boolean openDialog = store.getBoolean(SHOW_DIALOG_KEY);
090:                        boolean updateMapCRS;
091:                        if (openDialog) {
092:                            Shell shell = PlatformUI.getWorkbench()
093:                                    .getActiveWorkbenchWindow().getShell();
094:                            MessageDialogWithToggle dialog = MessageDialogWithToggle
095:                                    .openYesNoQuestion(
096:                                            shell,
097:                                            Messages.CRSPropertyPage_title,
098:                                            Messages.CRSPropertyPage_message,
099:                                            Messages.CRSPropertyPage_toggle_message,
100:                                            false, store, SHOW_DIALOG_KEY);
101:                            int returnCode = dialog.getReturnCode();
102:                            updateMapCRS = returnCode == IDialogConstants.YES_ID ? true
103:                                    : false;
104:                            store.setValue(UPDATE_MAP_CRS_KEY, updateMapCRS);
105:                        } else {
106:                            updateMapCRS = store.getBoolean(UPDATE_MAP_CRS_KEY);
107:                        }
108:                        if (updateMapCRS) {
109:                            commands.getCommands().add(
110:                                    new ChangeCRSCommand(
111:                                            layer.getMapInternal(), crs));
112:                        }
113:                    }
114:                    layer.getMap().sendCommandASync(commands);
115:                }
116:
117:                public CoordinateReferenceSystem getCurrentCoordinateReferenceSystem() {
118:                    return layer.getCRS();
119:                }
120:            }
121:
122:            /**
123:             * In order to make CRSPropertyPage more re-usable this strategy is used to apply the CRS to the
124:             * object that this page applies to. In addition it retrieves the current CRS from the object.
125:             * 
126:             * @author Jesse
127:             * @since 1.1.0
128:             */
129:            public static interface ApplyCRSStrategy {
130:                /**
131:                 * Called when a new CRS has been chosen. Should set the crs on the object.
132:                 * 
133:                 * @param crs new CRS. Will not be the same as returned by
134:                 *        {@link #getCurrentCoordinateReferenceSystem()}
135:                 */
136:                public void applyCoordinateReferenceSystem(
137:                        CoordinateReferenceSystem crs);
138:
139:                /**
140:                 * Returns the current CRS. Should not return null.
141:                 * 
142:                 * @return current crs of object.
143:                 */
144:                public CoordinateReferenceSystem getCurrentCoordinateReferenceSystem();
145:            }
146:
147:            CRSChooser chooser = new CRSChooser(new Controller() {
148:
149:                public void handleClose() {
150:                    getControl().getShell().close();
151:                }
152:
153:                public void handleOk() {
154:                    CRSPropertyPage.this .performOk();
155:                }
156:
157:            });
158:
159:            private ApplyCRSStrategy strategy;
160:
161:            public CRSPropertyPage() {
162:                setTitle(Messages.CRSPropertyPage_coordinateSystems_title);
163:            }
164:
165:            public void setStrategy(ApplyCRSStrategy strategy) {
166:                this .strategy = strategy;
167:            }
168:
169:            /**
170:             * @see org.eclipse.jface.preference.IPreferencePage#performOk()
171:             */
172:            public boolean performOk() {
173:                CoordinateReferenceSystem crs = chooser.getCRS();
174:                if (crs == null)
175:                    return false;
176:
177:                if (crs.equals(strategy.getCurrentCoordinateReferenceSystem()))
178:                    return true;
179:
180:                strategy.applyCoordinateReferenceSystem(crs);
181:                // BasicCommandFactory factory = BasicCommandFactory.getInstance();
182:                // MapCommand command = factory.createChangeCRS(map, crs);
183:                // map.sendCommandSync(command);
184:
185:                return super .performOk();
186:            }
187:
188:            /**
189:             * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
190:             */
191:            protected void performDefaults() {
192:                chooser.clearSearch();
193:                chooser.gotoCRS(strategy.getCurrentCoordinateReferenceSystem());
194:            }
195:
196:            /**
197:             * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
198:             */
199:            public IPreferenceStore getPreferenceStore() {
200:                return ProjectPlugin.getPlugin().getPreferenceStore();
201:            }
202:
203:            /**
204:             * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
205:             * @param parent
206:             */
207:            protected Control createContents(Composite parent) {
208:                CoordinateReferenceSystem crs = null;
209:                Control control;
210:
211:                crs = strategy.getCurrentCoordinateReferenceSystem();
212:                if (crs == null)
213:                    control = chooser.createControl(parent);
214:                else
215:                    control = chooser.createControl(parent, crs);
216:                return control;
217:            }
218:
219:            /**
220:             * @see org.eclipse.jface.preference.PreferencePage#doComputeSize()
221:             */
222:            protected Point doComputeSize() {
223:                return new Point(200, 300);
224:            }
225:
226:            /**
227:             * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
228:             */
229:            public void init(IWorkbench workbench) {
230:            }
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.