Source Code Cross Referenced for IDEWorkbenchPlugin.java in  » IDE-Eclipse » ui-ide » org » eclipse » ui » internal » ide » 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 » IDE Eclipse » ui ide » org.eclipse.ui.internal.ide 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.ide;
011:
012:        import com.ibm.icu.text.MessageFormat;
013:        import java.util.ArrayList;
014:        import java.util.List;
015:
016:        import org.eclipse.core.resources.IWorkspace;
017:        import org.eclipse.core.resources.ResourcesPlugin;
018:        import org.eclipse.core.runtime.CoreException;
019:        import org.eclipse.core.runtime.IBundleGroup;
020:        import org.eclipse.core.runtime.IBundleGroupProvider;
021:        import org.eclipse.core.runtime.IConfigurationElement;
022:        import org.eclipse.core.runtime.IProduct;
023:        import org.eclipse.core.runtime.IStatus;
024:        import org.eclipse.core.runtime.Platform;
025:        import org.eclipse.jface.resource.ImageDescriptor;
026:        import org.eclipse.jface.resource.JFaceResources;
027:        import org.eclipse.jface.resource.LocalResourceManager;
028:        import org.eclipse.jface.resource.ResourceManager;
029:        import org.eclipse.swt.custom.BusyIndicator;
030:        import org.eclipse.ui.internal.ide.registry.MarkerImageProviderRegistry;
031:        import org.eclipse.ui.internal.ide.registry.ProjectImageRegistry;
032:        import org.eclipse.ui.plugin.AbstractUIPlugin;
033:        import org.osgi.framework.Bundle;
034:        import org.osgi.framework.BundleContext;
035:
036:        /**
037:         * This internal class represents the top of the IDE workbench.
038:         *
039:         * This class is responsible for tracking various registries
040:         * font, preference, graphics, dialog store.
041:         *
042:         * This class is explicitly referenced by the 
043:         * IDE workbench plug-in's  "plugin.xml"
044:         * 
045:         * @since 3.0
046:         */
047:        public class IDEWorkbenchPlugin extends AbstractUIPlugin {
048:            // Default instance of the receiver
049:            private static IDEWorkbenchPlugin inst;
050:
051:            // Global workbench ui plugin flag. Only workbench implementation is allowed to use this flag
052:            // All other plugins, examples, or test cases must *not* use this flag.
053:            public static boolean DEBUG = false;
054:
055:            /**
056:             * The IDE workbench plugin ID.
057:             */
058:            public static final String IDE_WORKBENCH = "org.eclipse.ui.ide"; //$NON-NLS-1$
059:
060:            /**
061:             * The ID of the default text editor.
062:             * This must correspond to EditorsUI.DEFAULT_TEXT_EDITOR_ID.
063:             */
064:            public static final String DEFAULT_TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
065:
066:            // IDE workbench extension point names
067:            public static final String PL_MARKER_IMAGE_PROVIDER = "markerImageProviders"; //$NON-NLS-1$
068:
069:            public static final String PL_MARKER_HELP = "markerHelp"; //$NON-NLS-1$
070:
071:            public static final String PL_MARKER_RESOLUTION = "markerResolution"; //$NON-NLS-1$
072:
073:            public static final String PL_CAPABILITIES = "capabilities"; //$NON-NLS-1$
074:
075:            public static final String PL_PROJECT_NATURE_IMAGES = "projectNatureImages"; //$NON-NLS-1$
076:
077:            private final static String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
078:
079:            /**
080:             * Project image registry; lazily initialized.
081:             */
082:            private ProjectImageRegistry projectImageRegistry = null;
083:
084:            /**
085:             * Marker image registry; lazily initialized.
086:             */
087:            private MarkerImageProviderRegistry markerImageProviderRegistry = null;
088:
089:            private ResourceManager resourceManager;
090:
091:            /**
092:             * Create an instance of the receiver.
093:             */
094:            public IDEWorkbenchPlugin() {
095:                super ();
096:                inst = this ;
097:            }
098:
099:            /**
100:             * Creates an extension.  If the extension plugin has not
101:             * been loaded a busy cursor will be activated during the duration of
102:             * the load.
103:             *
104:             * @param element the config element defining the extension
105:             * @param classAttribute the name of the attribute carrying the class
106:             * @return Object the extension object
107:             * @throws CoreException
108:             */
109:            public static Object createExtension(
110:                    final IConfigurationElement element,
111:                    final String classAttribute) throws CoreException {
112:                // If plugin has been loaded create extension.
113:                // Otherwise, show busy cursor then create extension.
114:                Bundle plugin = Platform.getBundle(element.getNamespace());
115:                if (plugin.getState() == Bundle.ACTIVE) {
116:                    return element.createExecutableExtension(classAttribute);
117:                } else {
118:                    final Object[] ret = new Object[1];
119:                    final CoreException[] exc = new CoreException[1];
120:                    BusyIndicator.showWhile(null, new Runnable() {
121:                        public void run() {
122:                            try {
123:                                ret[0] = element
124:                                        .createExecutableExtension(classAttribute);
125:                            } catch (CoreException e) {
126:                                exc[0] = e;
127:                            }
128:                        }
129:                    });
130:                    if (exc[0] != null) {
131:                        throw exc[0];
132:                    } else {
133:                        return ret[0];
134:                    }
135:                }
136:            }
137:
138:            /* Return the default instance of the receiver. This represents the runtime plugin.
139:             *
140:             * @see AbstractPlugin for the typical implementation pattern for plugin classes.
141:             */
142:            public static IDEWorkbenchPlugin getDefault() {
143:                return inst;
144:            }
145:
146:            /**
147:             * Return the workspace used by the workbench
148:             *
149:             * This method is internal to the workbench and must not be called
150:             * by any plugins.
151:             */
152:            public static IWorkspace getPluginWorkspace() {
153:                return ResourcesPlugin.getWorkspace();
154:            }
155:
156:            /**
157:             * Logs the given message to the platform log.
158:             * 
159:             * If you have an exception in hand, call log(String, Throwable) instead.
160:             * 
161:             * If you have a status object in hand call log(String, IStatus) instead.
162:             * 
163:             * This convenience method is for internal use by the IDE Workbench only and
164:             * must not be called outside the IDE Workbench.
165:             * 
166:             * @param message
167:             *            A high level UI message describing when the problem happened.
168:             */
169:            public static void log(String message) {
170:                getDefault().getLog().log(
171:                        StatusUtil.newStatus(IStatus.ERROR, message, null));
172:            }
173:
174:            /**
175:             * Logs the given message and throwable to the platform log.
176:             * 
177:             * If you have a status object in hand call log(String, IStatus) instead.
178:             * 
179:             * This convenience method is for internal use by the IDE Workbench only and
180:             * must not be called outside the IDE Workbench.
181:             * 
182:             * @param message
183:             *            A high level UI message describing when the problem happened.
184:             * @param t
185:             *            The throwable from where the problem actually occurred.
186:             */
187:            public static void log(String message, Throwable t) {
188:                IStatus status = StatusUtil
189:                        .newStatus(IStatus.ERROR, message, t);
190:                log(message, status);
191:            }
192:
193:            /**
194:             * Logs the given throwable to the platform log, indicating the class and
195:             * method from where it is being logged (this is not necessarily where it
196:             * occurred).
197:             * 
198:             * This convenience method is for internal use by the IDE Workbench only and
199:             * must not be called outside the IDE Workbench.
200:             * 
201:             * @param clazz
202:             *            The calling class.
203:             * @param methodName
204:             *            The calling method name.
205:             * @param t
206:             *            The throwable from where the problem actually occurred.
207:             */
208:            public static void log(Class clazz, String methodName, Throwable t) {
209:                String msg = MessageFormat.format("Exception in {0}.{1}: {2}", //$NON-NLS-1$
210:                        new Object[] { clazz.getName(), methodName, t });
211:                log(msg, t);
212:            }
213:
214:            /**
215:             * Logs the given message and status to the platform log.
216:             * 
217:             * This convenience method is for internal use by the IDE Workbench only and
218:             * must not be called outside the IDE Workbench.
219:             * 
220:             * @param message
221:             *            A high level UI message describing when the problem happened.
222:             *            May be <code>null</code>.
223:             * @param status
224:             *            The status describing the problem. Must not be null.
225:             */
226:            public static void log(String message, IStatus status) {
227:
228:                //1FTUHE0: ITPCORE:ALL - API - Status & logging - loss of semantic info
229:
230:                if (message != null) {
231:                    getDefault().getLog().log(
232:                            StatusUtil.newStatus(IStatus.ERROR, message, null));
233:                }
234:
235:                getDefault().getLog().log(status);
236:            }
237:
238:            /* (non-javadoc)
239:             * Method declared on AbstractUIPlugin
240:             */
241:            protected void refreshPluginActions() {
242:                // do nothing
243:            }
244:
245:            /**
246:             * Return the manager that maps project nature ids to images.
247:             */
248:            public ProjectImageRegistry getProjectImageRegistry() {
249:                if (projectImageRegistry == null) {
250:                    projectImageRegistry = new ProjectImageRegistry();
251:                    projectImageRegistry.load();
252:                }
253:                return projectImageRegistry;
254:            }
255:
256:            /**
257:             * Returns the marker image provider registry for the workbench.
258:             *
259:             * @return the marker image provider registry
260:             */
261:            public MarkerImageProviderRegistry getMarkerImageProviderRegistry() {
262:                if (markerImageProviderRegistry == null) {
263:                    markerImageProviderRegistry = new MarkerImageProviderRegistry();
264:                }
265:                return markerImageProviderRegistry;
266:            }
267:
268:            /**
269:             * Returns the about information of all known features,
270:             * omitting any features which are missing this information.
271:             * 
272:             * @return a possibly empty list of about infos
273:             */
274:            public AboutInfo[] getFeatureInfos() {
275:                // cannot be cached since bundle groups come and go
276:                List infos = new ArrayList();
277:
278:                // add an entry for each bundle group
279:                IBundleGroupProvider[] providers = Platform
280:                        .getBundleGroupProviders();
281:                if (providers != null) {
282:                    for (int i = 0; i < providers.length; ++i) {
283:                        IBundleGroup[] bundleGroups = providers[i]
284:                                .getBundleGroups();
285:                        for (int j = 0; j < bundleGroups.length; ++j) {
286:                            infos.add(new AboutInfo(bundleGroups[j]));
287:                        }
288:                    }
289:                }
290:
291:                return (AboutInfo[]) infos.toArray(new AboutInfo[infos.size()]);
292:            }
293:
294:            /**
295:             * Returns the about information of the primary feature.
296:             * 
297:             * @return info about the primary feature, or <code>null</code> if there 
298:             * is no primary feature or if this information is unavailable
299:             */
300:            public AboutInfo getPrimaryInfo() {
301:                IProduct product = Platform.getProduct();
302:                return product == null ? null : new AboutInfo(product);
303:            }
304:
305:            /**
306:             * Get the workbench image with the given path relative to
307:             * ICON_PATH.
308:             * @param relativePath
309:             * @return ImageDescriptor
310:             */
311:            public static ImageDescriptor getIDEImageDescriptor(
312:                    String relativePath) {
313:                return imageDescriptorFromPlugin(IDE_WORKBENCH, ICONS_PATH
314:                        + relativePath);
315:            }
316:
317:            /**
318:             * Return the resourceManager used by this plug-in.
319:             * @return
320:             */
321:            public ResourceManager getResourceManager() {
322:                if (resourceManager == null) {
323:                    resourceManager = new LocalResourceManager(JFaceResources
324:                            .getResources());
325:                }
326:                return resourceManager;
327:            }
328:
329:            /* (non-Javadoc)
330:             * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
331:             */
332:            public void stop(BundleContext context) throws Exception {
333:                super.stop(context);
334:                if (resourceManager != null)
335:                    resourceManager.dispose();
336:            }
337:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.