Source Code Cross Referenced for ProjectUIPlugin.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 java.lang.reflect.InvocationTargetException;
012:        import java.net.URL;
013:        import java.util.ArrayList;
014:        import java.util.Collections;
015:        import java.util.List;
016:
017:        import net.refractions.udig.project.render.IRenderer;
018:        import net.refractions.udig.ui.PlatformGIS;
019:        import net.refractions.udig.ui.PreShutdownTask;
020:        import net.refractions.udig.ui.ShutdownTaskList;
021:
022:        import org.eclipse.core.runtime.CoreException;
023:        import org.eclipse.core.runtime.IConfigurationElement;
024:        import org.eclipse.core.runtime.IExtension;
025:        import org.eclipse.core.runtime.IExtensionPoint;
026:        import org.eclipse.core.runtime.IExtensionRegistry;
027:        import org.eclipse.core.runtime.IProgressMonitor;
028:        import org.eclipse.core.runtime.IStatus;
029:        import org.eclipse.core.runtime.Platform;
030:        import org.eclipse.core.runtime.Status;
031:        import org.eclipse.emf.common.notify.AdapterFactory;
032:        import org.eclipse.emf.ecore.resource.Resource;
033:        import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
034:        import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
035:        import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
036:        import org.eclipse.jface.action.IMenuManager;
037:        import org.eclipse.jface.action.IStatusLineManager;
038:        import org.eclipse.jface.action.IToolBarManager;
039:        import org.eclipse.jface.operation.IRunnableWithProgress;
040:        import org.eclipse.ui.IActionBars;
041:        import org.eclipse.ui.IWorkbench;
042:        import org.eclipse.ui.PlatformUI;
043:        import org.eclipse.ui.plugin.AbstractUIPlugin;
044:        import org.eclipse.ui.views.properties.IPropertySheetPage;
045:        import org.eclipse.ui.views.properties.PropertySheetPage;
046:        import org.osgi.framework.BundleContext;
047:
048:        /**
049:         * The Plugin class for the net.refractions.udig.project plugin. Provides access to plugin
050:         * resources.
051:         * 
052:         * @author Jesse Eichar
053:         * @version $Revision: 1.9 $
054:         */
055:        public class ProjectUIPlugin extends AbstractUIPlugin {
056:            /**
057:             * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc -->
058:             * 
059:             * @generated
060:             */
061:            public static final ProjectUIPlugin INSTANCE = new ProjectUIPlugin();
062:
063:            private static final String ICONS_PATH = "icons/"; //$NON-NLS-1$
064:
065:            /** The plugin ID */
066:            public static final String ID = "net.refractions.udig.project.ui"; //$NON-NLS-1$
067:
068:            /** Preference store for the last directory open by the file selection dialog */
069:            public static final String PREF_OPEN_DIALOG_DIRECTORY = "udig.preferences.openDialog.lastDirectory"; //$NON-NLS-1$
070:
071:            /**
072:             * The maximum number of resources per service that can be added to a map without asking the
073:             * user for permission.
074:             */
075:            public static final int MAX_RESOURCES_IN_SERVICE = 1;
076:
077:            private static ProjectUIPlugin plugin;
078:
079:            Images images = new Images();
080:
081:            List<AdapterFactory> adapterFactories;
082:
083:            private static final String ADAPTER_FACTORIES_ID = "net.refractions.udig.project.ui.itemProviderAdapterFactories"; //$NON-NLS-1$
084:
085:            private PropertySheetPage propertySheetPage;
086:
087:            /**
088:             * creates a plugin instance
089:             */
090:            public ProjectUIPlugin() {
091:                super ();
092:                plugin = this ;
093:            }
094:
095:            FeatureEditorExtensionProcessor featureEditProcessor = new FeatureEditorExtensionProcessor();
096:
097:            /**
098:             * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
099:             */
100:            public void start(BundleContext context) throws Exception {
101:                super .start(context);
102:
103:                final URL iconsUrl = context.getBundle().getEntry(ICONS_PATH);
104:
105:                PlatformGIS.syncInDisplayThread(new Runnable() {
106:                    public void run() {
107:                        images.initializeImages(iconsUrl, getImageRegistry());
108:                    }
109:                });
110:            }
111:
112:            /**
113:             * Returns the system created plugin object
114:             * 
115:             * @return the plugin object
116:             */
117:            public static ProjectUIPlugin getDefault() {
118:                return plugin;
119:            }
120:
121:            /**
122:             * @return Returns the images.
123:             */
124:            public Images getImages() {
125:                return images;
126:            }
127:
128:            /**
129:             * Returns the ToolManager singleton.
130:             * 
131:             * @return the ToolManager singleton.
132:             * @deprecated
133:             */
134:            // public ToolManager getToolManager() {
135:            // return UDIGApplicationUI.getToolManager()
136:            // }
137:            /**
138:             * @return Returns the adapterFactories.
139:             */
140:            public List<AdapterFactory> getAdapterFactories() {
141:                if (adapterFactories == null) {
142:                    adapterFactories = new ArrayList<AdapterFactory>();
143:
144:                    IExtensionRegistry registry = Platform
145:                            .getExtensionRegistry();
146:                    IExtensionPoint extensionPoint = registry
147:                            .getExtensionPoint(ADAPTER_FACTORIES_ID);
148:                    IExtension[] extensions = extensionPoint.getExtensions();
149:
150:                    for (int i = 0; i < extensions.length; i++) {
151:                        IConfigurationElement[] elements = extensions[i]
152:                                .getConfigurationElements();
153:
154:                        for (int j = 0; j < elements.length; j++) {
155:                            try {
156:                                Object adapterFactory = elements[j]
157:                                        .createExecutableExtension("class"); //$NON-NLS-1$
158:                                if (adapterFactory instanceof  AdapterFactory) {
159:                                    adapterFactories
160:                                            .add((AdapterFactory) adapterFactory);
161:                                }
162:                            } catch (CoreException e) {
163:                                e.printStackTrace();
164:                            }
165:                        }
166:                    }
167:
168:                }
169:                return Collections.unmodifiableList(adapterFactories);
170:            }
171:
172:            Object mutex = new Object();
173:
174:            /**
175:             * This accesses a cached version of the property sheet. <!-- begin-user-doc --> <!--
176:             * end-user-doc -->
177:             * 
178:             * @return An IProperty page for the selected object
179:             */
180:            public IPropertySheetPage getPropertySheetPage() {
181:                if (propertySheetPage == null) {
182:                    synchronized (mutex) {
183:
184:                        propertySheetPage = new PropertySheetPage() {
185:
186:                            public void makeContributions(
187:                                    IMenuManager menuManager,
188:                                    IToolBarManager toolBarManager,
189:                                    IStatusLineManager statusLineManager) {
190:                                super .makeContributions(menuManager,
191:                                        toolBarManager, statusLineManager);
192:                            }
193:
194:                            public void setActionBars(IActionBars actionBars) {
195:                                super .setActionBars(actionBars);
196:                            }
197:                        };
198:                        propertySheetPage
199:                                .setPropertySourceProvider(new AdapterFactoryContentProvider(
200:                                        getAdapterFactory()));
201:                    }
202:                }
203:
204:                return propertySheetPage;
205:            }
206:
207:            private AdapterFactory adapterFactory;
208:
209:            /**
210:             * Returns the adapterfactory instance.
211:             * 
212:             * @return the adapterfactory instance.
213:             */
214:            public AdapterFactory getAdapterFactory() {
215:                if (adapterFactory == null) {
216:                    synchronized (mutex) {
217:                        List<AdapterFactory> factories = new ArrayList<AdapterFactory>();
218:
219:                        factories.addAll(ProjectUIPlugin.getDefault()
220:                                .getAdapterFactories());
221:
222:                        // This one should be added last
223:                        factories
224:                                .add(new ReflectiveItemProviderAdapterFactory());
225:
226:                        adapterFactory = new ComposedAdapterFactory(factories);
227:                    }
228:                }
229:                return adapterFactory;
230:            }
231:
232:            /**
233:             * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
234:             */
235:
236:            public void stop(BundleContext context) throws Exception {
237:                featureEditProcessor.stopPartListener();
238:                if (LayerGeneratedGlyphDecorator.getInstance() != null)
239:                    LayerGeneratedGlyphDecorator.getInstance().dispose();
240:                super .stop(context);
241:            }
242:
243:            /**
244:             * Gets the FeatureEditorProcessor instance.
245:             * 
246:             * @return
247:             */
248:            public FeatureEditorExtensionProcessor getFeatureEditProcessor() {
249:                if (!featureEditProcessor.isRunning())
250:                    featureEditProcessor.startPartListener();
251:
252:                return featureEditProcessor;
253:            }
254:
255:            /**
256:             * Writes an info log in the plugin's log.
257:             * <p>
258:             * This should be used for user level messages.
259:             * </p>
260:             */
261:            public static void log(String message2, Throwable e) {
262:                String message = message2;
263:                if (message == null)
264:                    message = Messages.ProjectUIPlugin_error + e;
265:                getDefault().getLog().log(
266:                        new Status(IStatus.INFO, ID, IStatus.OK, message, e));
267:            }
268:
269:            /**
270:             * Messages that only engage if getDefault().isDebugging()
271:             * <p>
272:             * It is much prefered to do this:<pre><code>
273:             * private static final String RENDERING = "net.refractions.udig.project/render/trace";
274:             * if( ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase( RENDERING ) ){
275:             *      System.out.println( "your message here" );
276:             * 
277:             */
278:            private static void trace(String message, Throwable e) {
279:                if (getDefault().isDebugging()) {
280:                    if (message != null)
281:                        System.out.println(message + "\n"); //$NON-NLS-1$
282:                    if (e != null)
283:                        e.printStackTrace(System.out);
284:                }
285:            }
286:
287:            /**
288:             * Messages that only engage if getDefault().isDebugging() and the trace option traceID is true.
289:             * Available trace options can be found in the Trace class.  (They must also be part of the .options file) 
290:             */
291:            public static void trace(String traceID, Class caller,
292:                    String message, Throwable e) {
293:                if (isDebugging(traceID)) {
294:                    trace(caller, message, e);
295:                }
296:            }
297:
298:            /**
299:             * Adds the name of the caller class to the message. 
300:             *
301:             * @param caller class of the object doing the trace.
302:             * @param message tracing message, may be null.
303:             * @param e exception, may be null.
304:             */
305:            public static void trace(Class caller, String message, Throwable e) {
306:                trace("Tracing - " + caller.getSimpleName() + ": " + message, e); //$NON-NLS-1$ //$NON-NLS-2$
307:            }
308:
309:            /**
310:             * Performs the Platform.getDebugOption true check on the provided trace
311:             * <p>
312:             * Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.
313:             * <ul>
314:             * <li>Trace.RENDER - trace rendering progress
315:             * </ul>
316:             * </p>
317:             * 
318:             * @param trace currently only RENDER is defined
319:             */
320:            public static boolean isDebugging(final String trace) {
321:                return getDefault().isDebugging()
322:                        && "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$    
323:            }
324:
325:            public int getDoubleClickSpeed() {
326:                return 400;
327:            }
328:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.