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


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 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.navigator;
011:
012:        import org.eclipse.core.runtime.ILog;
013:        import org.eclipse.core.runtime.IProgressMonitor;
014:        import org.eclipse.core.runtime.IStatus;
015:        import org.eclipse.core.runtime.ListenerList;
016:        import org.eclipse.core.runtime.Status;
017:        import org.eclipse.core.runtime.jobs.Job;
018:        import org.eclipse.jface.resource.ImageDescriptor;
019:        import org.eclipse.swt.graphics.Image;
020:        import org.eclipse.ui.plugin.AbstractUIPlugin;
021:        import org.osgi.framework.BundleContext;
022:        import org.osgi.framework.BundleEvent;
023:        import org.osgi.framework.BundleListener;
024:
025:        /**
026:         * The main plugin class for the Navigator. 
027:         *  
028:         * @since 3.2
029:         */
030:        public class NavigatorPlugin extends AbstractUIPlugin {
031:            // The shared instance.
032:            private static NavigatorPlugin plugin;
033:
034:            private static final int LOG_DELAY = 100;
035:
036:            private static class LogJob extends Job {
037:
038:                private ListenerList messages = new ListenerList() {
039:
040:                    public synchronized Object[] getListeners() {
041:                        Object[] mesgs = super .getListeners();
042:                        clear();
043:                        return mesgs;
044:                    }
045:                };
046:
047:                /**
048:                 * Creates a Job which offloads the logging work into a non-UI thread.
049:                 *
050:                 */
051:                public LogJob() {
052:                    super (""); //$NON-NLS-1$
053:                    setSystem(true);
054:                }
055:
056:                /* (non-Javadoc)
057:                 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
058:                 */
059:                protected IStatus run(IProgressMonitor monitor) {
060:
061:                    Object[] mesgs = messages.getListeners();
062:                    ILog pluginLog = getDefault().getLog();
063:                    for (int i = 0; i < mesgs.length; i++) {
064:                        pluginLog.log((IStatus) mesgs[i]);
065:                    }
066:                    return Status.OK_STATUS;
067:
068:                }
069:
070:                /**
071:                 * @param mesg The message to add to the Plugin's log.
072:                 */
073:                public void log(IStatus mesg) {
074:                    messages.add(mesg);
075:
076:                }
077:
078:            }
079:
080:            private static final LogJob logJob = new LogJob();
081:
082:            /** The id of the orge.eclipse.ui.navigator plugin. */
083:            public static String PLUGIN_ID = "org.eclipse.ui.navigator"; //$NON-NLS-1$
084:
085:            private BundleListener bundleListener = new BundleListener() {
086:                public void bundleChanged(BundleEvent event) {
087:                    NavigatorSaveablesService.bundleChanged(event);
088:                }
089:            };
090:
091:            /**
092:             * Creates a new instance of the receiver
093:             */
094:            public NavigatorPlugin() {
095:                super ();
096:                plugin = this ;
097:            }
098:
099:            /**
100:             * @return the shared instance.
101:             */
102:            public static NavigatorPlugin getDefault() {
103:                return plugin;
104:            }
105:
106:            /**
107:             * Returns an image descriptor for the image file at the given plug-in
108:             * relative path.
109:             * 
110:             * @param path
111:             *            the path
112:             * @return the image descriptor
113:             */
114:            public static ImageDescriptor getImageDescriptor(String path) {
115:                return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID,
116:                        path);
117:            }
118:
119:            /**
120:             * Returns an image descriptor for the image file at the given plug-in
121:             * relative path.
122:             * 
123:             * @param path
124:             *            the path
125:             * @return the image 
126:             */
127:            public Image getImage(String path) {
128:                Image image = getImageRegistry().get(path);
129:                if (image == null) {
130:                    ImageDescriptor descriptor = getImageDescriptor(path);
131:                    if (descriptor != null) {
132:                        getImageRegistry().put(path,
133:                                image = descriptor.createImage());
134:                    }
135:                }
136:                return image;
137:            }
138:
139:            /**
140:             * Record an error against this plugin's log. 
141:             * 
142:             * @param aCode
143:             * @param aMessage
144:             * @param anException
145:             */
146:            public static void logError(int aCode, String aMessage,
147:                    Throwable anException) {
148:                getDefault().getLog().log(
149:                        createErrorStatus(aCode, aMessage, anException));
150:            }
151:
152:            /**
153:             * 
154:             * Record a message against this plugin's log. 
155:             * 
156:             * @param severity
157:             * @param aCode
158:             * @param aMessage
159:             * @param exception
160:             */
161:            public static void log(int severity, int aCode, String aMessage,
162:                    Throwable exception) {
163:                log(createStatus(severity, aCode, aMessage, exception));
164:            }
165:
166:            /**
167:             * 
168:             * Record a status against this plugin's log. 
169:             * 
170:             * @param aStatus
171:             */
172:            public static void log(IStatus aStatus) {
173:                //getDefault().getLog().log(aStatus);
174:                logJob.log(aStatus);
175:                logJob.schedule(LOG_DELAY);
176:            }
177:
178:            /**
179:             * Create a status associated with this plugin.
180:             *  
181:             * @param severity
182:             * @param aCode
183:             * @param aMessage
184:             * @param exception
185:             * @return A status configured with this plugin's id and the given parameters.
186:             */
187:            public static IStatus createStatus(int severity, int aCode,
188:                    String aMessage, Throwable exception) {
189:                return new Status(severity, PLUGIN_ID, aCode,
190:                        aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
191:            }
192:
193:            /**
194:             * 
195:             * @param aCode
196:             * @param aMessage
197:             * @param exception
198:             * @return A status configured with this plugin's id and the given parameters.
199:             */
200:            public static IStatus createErrorStatus(int aCode, String aMessage,
201:                    Throwable exception) {
202:                return createStatus(IStatus.ERROR, aCode, aMessage, exception);
203:            }
204:
205:            public void start(BundleContext context) throws Exception {
206:                // System.out.println("Navigator plugin starting"); //$NON-NLS-1$
207:                super .start(context);
208:                context.addBundleListener(bundleListener);
209:            }
210:
211:            public void stop(BundleContext context) throws Exception {
212:                context.removeBundleListener(bundleListener);
213:                super .stop(context);
214:                // System.out.println("Navigator plugin stopped"); //$NON-NLS-1$
215:            }
216:
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.