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


001:        /**
002:         * <copyright></copyright> $Id: ProjectPlugin.java 23333 2006-12-08 19:40:41Z jeichar $
003:         */package net.refractions.udig.project.internal;
004:
005:        import java.util.HashMap;
006:        import java.util.Iterator;
007:        import java.util.List;
008:        import java.util.Map;
009:
010:        import net.refractions.udig.project.internal.impl.ProjectRegistryImpl;
011:        import net.refractions.udig.ui.PostShutdownTask;
012:        import net.refractions.udig.ui.ShutdownTaskList;
013:
014:        import org.eclipse.core.runtime.IProgressMonitor;
015:        import org.eclipse.core.runtime.IStatus;
016:        import org.eclipse.core.runtime.Platform;
017:        import org.eclipse.core.runtime.Status;
018:        import org.eclipse.core.runtime.preferences.InstanceScope;
019:        import org.eclipse.emf.common.EMFPlugin;
020:        import org.eclipse.emf.common.notify.Notifier;
021:        import org.eclipse.emf.common.util.ResourceLocator;
022:        import org.eclipse.emf.ecore.EObject;
023:        import org.eclipse.emf.ecore.resource.Resource;
024:        import org.eclipse.emf.ecore.xmi.XMLResource;
025:        import org.eclipse.ui.IWorkbench;
026:        import org.eclipse.ui.preferences.ScopedPreferenceStore;
027:        import org.osgi.framework.BundleContext;
028:
029:        /**
030:         * This is the central singleton for the Project model plugin.
031:         * <!-- begin-user-doc --> <!--
032:         * end-user-doc -->
033:         * @generated
034:         */
035:        public final class ProjectPlugin extends EMFPlugin {
036:            /** Plugin ID */
037:            public final static String ID = "net.refractions.udig.project"; //$NON-NLS-1$
038:
039:            /**
040:             * <!-- begin-user-doc --> <!-- end-user-doc -->
041:             * @generated
042:             */
043:            public static final String copyright = "uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004, Refractions Research Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; //$NON-NLS-1$
044:
045:            /**
046:             * Keep track of the singleton.
047:             * <!-- begin-user-doc --> <!-- end-user-doc -->
048:             * @generated
049:             */
050:            public static final ProjectPlugin INSTANCE = new ProjectPlugin();
051:
052:            /**
053:             * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc -->
054:             * 
055:             * @generated NOT
056:             */
057:            static Implementation plugin;
058:
059:            /**
060:             * Create the instance.
061:             * <!-- begin-user-doc --> <!-- end-user-doc -->
062:             * @generated
063:             */
064:            public ProjectPlugin() {
065:                super (new ResourceLocator[] {});
066:            }
067:
068:            /**
069:             * Returns the singleton instance of the Eclipse plugin.
070:             * <!-- begin-user-doc --> <!--
071:             * end-user-doc -->
072:             * @return the singleton instance.
073:             * @generated
074:             */
075:            public ResourceLocator getPluginResourceLocator() {
076:                return plugin;
077:            }
078:
079:            /**
080:             * Returns the singleton instance of the Eclipse plugin.
081:             * <!-- begin-user-doc --> <!--
082:             * end-user-doc -->
083:             * @return the singleton instance.
084:             * @generated
085:             */
086:            public static Implementation getPlugin() {
087:                return plugin;
088:            }
089:
090:            /**
091:             * TODO Purpose of net.refractions.udig.project.internal <p> </p>
092:             * @author   Jesse
093:             * @since   1.0.0
094:             * @generated
095:             */
096:            public static class Implementation extends EclipsePlugin {
097:
098:                /**
099:                 * Creates an instance.
100:                 * <!-- begin-user-doc --> <!-- end-user-doc -->
101:                 * @generated
102:                 */
103:                public Implementation() {
104:                    super ();
105:
106:                    // Remember the static instance.
107:                    //
108:                    plugin = this ;
109:                }
110:
111:                /**
112:                 * Controls whether the warning message of non-undoable commands is shown.
113:                 * @deprecated Use the getter and setter methods.
114:                 */
115:                public boolean undoableCommandWarning = true;
116:
117:                public void setUndoableCommandWarning(boolean value) {
118:                    undoableCommandWarning = value;
119:                }
120:
121:                public boolean getUndoableCommandWarning() {
122:                    return undoableCommandWarning;
123:                }
124:
125:                /**
126:                 * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
127:                 */
128:                public void start(BundleContext context) throws Exception {
129:                    super .start(context);
130:                    ShutdownTaskList.instance().addPostShutdownTask(
131:                            new PostShutdownTask() {
132:
133:                                public int getProgressMonitorSteps() {
134:                                    List resources = getProjectRegistry()
135:                                            .eResource().getResourceSet()
136:                                            .getResources();
137:                                    return resources.size();
138:                                }
139:
140:                                public void handlePostShutdownException(
141:                                        Throwable t) {
142:                                    ProjectPlugin.log("", t); //$NON-NLS-1$
143:                                }
144:
145:                                public void postShutdown(
146:                                        IProgressMonitor monitor,
147:                                        IWorkbench workbench) throws Exception {
148:                                    monitor
149:                                            .beginTask(
150:                                                    Messages.ProjectPlugin_saving_task_name,
151:                                                    0);
152:                                    turnOffEvents();
153:                                    List resources = getProjectRegistry()
154:                                            .eResource().getResourceSet()
155:                                            .getResources();
156:                                    for (Iterator iter = resources.iterator(); iter
157:                                            .hasNext();) {
158:                                        Resource resource = (Resource) iter
159:                                                .next();
160:                                        if (resource.getContents().isEmpty())
161:                                            continue;
162:                                        Object next = resource.getAllContents()
163:                                                .next();
164:                                        if (resource.isModified()
165:                                                && next != null
166:                                                && !((EObject) next).eIsProxy()) {
167:                                            try {
168:                                                resource.save(saveOptions);
169:                                            } catch (Exception e) {
170:                                                ProjectPlugin.log(
171:                                                        "Error saving", e); //$NON-NLS-1$
172:                                            }
173:                                        }
174:                                        monitor.worked(1);
175:                                    }
176:                                }
177:
178:                            });
179:                    undoableCommandWarning = "true".equals(getString("net.refractions.udig.project.undoableCommandWarning")); //$NON-NLS-1$//$NON-NLS-2$
180:                }
181:
182:                protected static final String ENCODING = "UTF-8"; //$NON-NLS-1$
183:
184:                /**
185:                 * EMF save parameters.
186:                 * @uml.property   name="saveOptions"
187:                 * @uml.associationEnd   qualifier="key:java.lang.Object java.lang.String"
188:                 */
189:                public Map<String, String> saveOptions = new HashMap<String, String>();
190:
191:                private ScopedPreferenceStore preferenceStore;
192:
193:                {
194:                    saveOptions.put(XMLResource.OPTION_ENCODING, ENCODING);
195:                }
196:
197:                /**
198:                 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
199:                 */
200:                public void stop(BundleContext context) throws Exception {
201:                    super .stop(context);
202:                }
203:
204:                /**
205:                 * @see net.refractions.udig.project.internal.ProjectFactory#getProjectRegistry()
206:                 * @uml.property   name="projectRegistry"
207:                 */
208:                public ProjectRegistry getProjectRegistry() {
209:                    return ProjectRegistryImpl.getProjectRegistry();
210:                }
211:
212:                public void turnOffEvents() {
213:                    Iterator allIter = getProjectRegistry().eResource()
214:                            .getResourceSet().getAllContents();
215:                    while (allIter.hasNext()) {
216:                        Object tmp = allIter.next();
217:                        Notifier obj = (Notifier) tmp;
218:                        obj.eSetDeliver(false);
219:                    }
220:                }
221:
222:                /**
223:                 * Returns the preference store for this UI plug-in.
224:                 * This preference store is used to hold persistent settings for this plug-in in
225:                 * the context of a workbench. Some of these settings will be user controlled, 
226:                 * whereas others may be internal setting that are never exposed to the user.
227:                 * <p>
228:                 * If an error occurs reading the preference store, an empty preference store is
229:                 * quietly created, initialized with defaults, and returned.
230:                 * </p>
231:                 * <p>
232:                 * <strong>NOTE:</strong> As of Eclipse 3.1 this method is
233:                 * no longer referring to the core runtime compatibility layer and so
234:                 * plug-ins relying on Plugin#initializeDefaultPreferences
235:                 * will have to access the compatibility layer themselves.
236:                 * </p>
237:                 *
238:                 * @return the preference store 
239:                 */
240:                public synchronized ScopedPreferenceStore getPreferenceStore() {
241:                    // Create the preference store lazily.
242:                    if (preferenceStore == null) {
243:                        preferenceStore = new ScopedPreferenceStore(
244:                                new InstanceScope(), getBundle()
245:                                        .getSymbolicName());
246:
247:                    }
248:                    return preferenceStore;
249:                }
250:            }
251:
252:            /**
253:             * Writes an info log in the plugin's log.
254:             * @param message
255:             */
256:            public static void log(String message) {
257:                log(message, null);
258:            }
259:
260:            /**
261:             * Writes an info log in the plugin's log.
262:             * <p>
263:             * This should be used for user level messages.
264:             * </p>
265:             */
266:            public static void log(String message, Throwable e) {
267:                getPlugin().getLog().log(
268:                        new Status(IStatus.INFO, ID, 0,
269:                                message == null ? "" : message, e)); //$NON-NLS-1$
270:            }
271:
272:            /**
273:             * Messages that only engage if getDefault().isDebugging()
274:             * <p>
275:             * It is much prefered to do this:<pre><code>
276:             * private static final String RENDERING = "net.refractions.udig.project/render/trace";
277:             * if( ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase( RENDERING ) ){
278:             *      System.out.println( "your message here" );
279:             * 
280:             */
281:            private static void trace(String message, Throwable e) {
282:                if (getPlugin().isDebugging()) {
283:                    if (message != null)
284:                        System.out.println(message + "\n"); //$NON-NLS-1$
285:                    if (e != null)
286:                        e.printStackTrace(System.out);
287:                }
288:            }
289:
290:            /**
291:             * Messages that only engage if getDefault().isDebugging() and the trace option traceID is true.
292:             * Available trace options can be found in the Trace class.  (They must also be part of the .options file) 
293:             */
294:            public static void trace(String traceID, Class caller,
295:                    String message, Throwable e) {
296:                if (isDebugging(traceID)) {
297:                    trace(caller, message, e);
298:                }
299:            }
300:
301:            /**
302:             * Adds the name of the caller class to the message. 
303:             *
304:             * @param caller class of the object doing the trace.
305:             * @param message tracing message, may be null.
306:             * @param e exception, may be null.
307:             */
308:            public static void trace(Class caller, String message, Throwable e) {
309:                trace("Tracing - " + caller.getSimpleName() + ": " + message, e); //$NON-NLS-1$ //$NON-NLS-2$
310:            }
311:
312:            /**
313:             * Performs the Platform.getDebugOption true check on the provided trace
314:             * <p>
315:             * Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.
316:             * <ul>
317:             * <li>Trace.RENDER - trace rendering progress
318:             * </ul>
319:             * </p>
320:             * 
321:             * @param trace currently only RENDER is defined
322:             */
323:            public static boolean isDebugging(final String trace) {
324:                return getPlugin().isDebugging()
325:                        && "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$
326:
327:            }
328:
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.