Source Code Cross Referenced for ConsolePlugin.java in  » IDE-Eclipse » ui » org » eclipse » ui » console » 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.console 
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.console;
011:
012:        import org.eclipse.core.runtime.CoreException;
013:        import org.eclipse.core.runtime.IStatus;
014:        import org.eclipse.core.runtime.Status;
015:        import org.eclipse.jface.dialogs.ErrorDialog;
016:        import org.eclipse.jface.resource.ImageDescriptor;
017:        import org.eclipse.swt.graphics.Image;
018:        import org.eclipse.swt.widgets.Display;
019:        import org.eclipse.swt.widgets.Shell;
020:        import org.eclipse.ui.internal.console.ConsoleManager;
021:        import org.eclipse.ui.internal.console.ConsolePluginImages;
022:        import org.eclipse.ui.plugin.AbstractUIPlugin;
023:        import org.osgi.framework.BundleContext;
024:
025:        /**
026:         * The console plug-in class.
027:         * 
028:         * @since 3.0
029:         */
030:
031:        public class ConsolePlugin extends AbstractUIPlugin {
032:
033:            /**
034:             * Singleton console manager
035:             */
036:            private IConsoleManager fConsoleManager = null;
037:
038:            /**
039:             * The singleton console plug-in instance
040:             */
041:            private static ConsolePlugin fgPlugin = null;
042:
043:            /**
044:             * Unique identifier constant (value <code>"org.eclipse.ui.console"</code>)
045:             * for the UI Console plug-in.
046:             */
047:            private static final String PI_UI_CONSOLE = "org.eclipse.ui.console"; //$NON-NLS-1$
048:
049:            /**
050:             * Returns the singleton instance of the console plug-in.
051:             */
052:            public static ConsolePlugin getDefault() {
053:                return fgPlugin;
054:            }
055:
056:            public ConsolePlugin() {
057:                super ();
058:                fgPlugin = this ;
059:            }
060:
061:            /**
062:             * Convenience method which returns the unique identifier of this plug-in.
063:             */
064:            public static String getUniqueIdentifier() {
065:                return PI_UI_CONSOLE;
066:            }
067:
068:            /**
069:             * Logs the specified status with this plug-in's log.
070:             * 
071:             * @param status status to log
072:             */
073:            public static void log(IStatus status) {
074:                getDefault().getLog().log(status);
075:            }
076:
077:            /**
078:             * Logs the specified throwable with this plug-in's log.
079:             * 
080:             * @param t throwable to log 
081:             */
082:            public static void log(Throwable t) {
083:                if (t instanceof  CoreException) {
084:                    log(((CoreException) t).getStatus());
085:                } else {
086:                    log(newErrorStatus("Error logged from Console plug-in: ", t)); //$NON-NLS-1$
087:                }
088:            }
089:
090:            /**
091:             * Returns a new error status for this plug-in with the given message
092:             * @param message the message to be included in the status
093:             * @param exception the exception to be included in the status or <code>null</code> if none
094:             * @return a new error status
095:             */
096:            public static IStatus newErrorStatus(String message,
097:                    Throwable exception) {
098:                return new Status(IStatus.ERROR, getUniqueIdentifier(),
099:                        IConsoleConstants.INTERNAL_ERROR, message, exception);
100:            }
101:
102:            /**
103:             * Returns the console manager. The manager will be created lazily on 
104:             * the first access.
105:             * 
106:             * @return IConsoleManager
107:             */
108:            public IConsoleManager getConsoleManager() {
109:                if (fConsoleManager == null) {
110:                    fConsoleManager = new ConsoleManager();
111:                }
112:                return fConsoleManager;
113:            }
114:
115:            /**
116:             * Returns the standard display to be used. The method first checks, if
117:             * the thread calling this method has an associated display. If so, this
118:             * display is returned. Otherwise the method returns the default display.
119:             */
120:            public static Display getStandardDisplay() {
121:                Display display = Display.getCurrent();
122:                if (display == null) {
123:                    display = Display.getDefault();
124:                }
125:                return display;
126:            }
127:
128:            /**
129:             * Utility method with conventions
130:             */
131:            public static void errorDialog(Shell shell, String title,
132:                    String message, Throwable t) {
133:                IStatus status;
134:                if (t instanceof  CoreException) {
135:                    status = ((CoreException) t).getStatus();
136:                    // if the 'message' resource string and the IStatus' message are the same,
137:                    // don't show both in the dialog
138:                    if (status != null && message.equals(status.getMessage())) {
139:                        message = null;
140:                    }
141:                } else {
142:                    status = new Status(IStatus.ERROR, getUniqueIdentifier(),
143:                            IConsoleConstants.INTERNAL_ERROR,
144:                            "Error within Debug UI: ", t); //$NON-NLS-1$
145:                    log(status);
146:                }
147:                ErrorDialog.openError(shell, title, message, status);
148:            }
149:
150:            /**
151:             * Returns the <code>Image</code> identified by the given key,
152:             * or <code>null</code> if it does not exist.
153:             * 
154:             * @return the <code>Image</code> identified by the given key,
155:             * or <code>null</code> if it does not exist
156:             * @since 3.1
157:             */
158:            public static Image getImage(String key) {
159:                return ConsolePluginImages.getImage(key);
160:            }
161:
162:            /**
163:             * Returns the <code>ImageDescriptor</code> identified by the given key,
164:             * or <code>null</code> if it does not exist.
165:             * 
166:             * @return the <code>ImageDescriptor</code> identified by the given key,
167:             * or <code>null</code> if it does not exist
168:             * @since 3.1
169:             */
170:            public static ImageDescriptor getImageDescriptor(String key) {
171:                return ConsolePluginImages.getImageDescriptor(key);
172:            }
173:
174:            /* (non-Javadoc)
175:             * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
176:             */
177:            public void stop(BundleContext context) throws Exception {
178:                if (fConsoleManager != null) {
179:                    IConsole[] consoles = fConsoleManager.getConsoles();
180:                    if (consoles != null) {
181:                        fConsoleManager.removeConsoles(consoles);
182:                    }
183:                }
184:                super.stop(context);
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.