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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 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.decorators;
011:
012:        import org.eclipse.core.runtime.CoreException;
013:        import org.eclipse.core.runtime.IConfigurationElement;
014:        import org.eclipse.core.runtime.Platform;
015:        import org.eclipse.jface.util.SafeRunnable;
016:        import org.eclipse.jface.viewers.IBaseLabelProvider;
017:        import org.eclipse.jface.viewers.ILabelDecorator;
018:        import org.eclipse.osgi.util.NLS;
019:        import org.eclipse.swt.graphics.Image;
020:        import org.eclipse.ui.internal.WorkbenchMessages;
021:        import org.eclipse.ui.internal.WorkbenchPlugin;
022:
023:        /**
024:         * The RunnableDecoratorDefinition is the definition for 
025:         * decorators that have an ILabelDecorator class to instantiate.
026:         */
027:
028:        class FullDecoratorDefinition extends DecoratorDefinition {
029:
030:            ILabelDecorator decorator;
031:
032:            /**
033:             * Create a new instance of the receiver with the
034:             * supplied values.
035:             */
036:
037:            FullDecoratorDefinition(String identifier,
038:                    IConfigurationElement element) {
039:                super (identifier, element);
040:            }
041:
042:            /**
043:             * Gets the decorator and creates it if it does
044:             * not exist yet. Throws a CoreException if there is a problem
045:             * creating the decorator.
046:             * This method should not be called unless a check for
047:             * enabled to be true is done first.
048:             * @return Returns a ILabelDecorator
049:             */
050:            protected ILabelDecorator internalGetDecorator()
051:                    throws CoreException {
052:                if (labelProviderCreationFailed) {
053:                    return null;
054:                }
055:
056:                final CoreException[] exceptions = new CoreException[1];
057:
058:                if (decorator == null) {
059:                    Platform
060:                            .run(new SafeRunnable(
061:                                    NLS
062:                                            .bind(
063:                                                    WorkbenchMessages.DecoratorManager_ErrorActivatingDecorator,
064:                                                    getName())) {
065:                                public void run() {
066:                                    try {
067:                                        decorator = (ILabelDecorator) WorkbenchPlugin
068:                                                .createExtension(
069:                                                        definingElement,
070:                                                        DecoratorDefinition.ATT_CLASS);
071:                                        decorator.addListener(WorkbenchPlugin
072:                                                .getDefault()
073:                                                .getDecoratorManager());
074:                                    } catch (CoreException exception) {
075:                                        exceptions[0] = exception;
076:                                    }
077:                                }
078:                            });
079:                } else {
080:                    return decorator;
081:                }
082:
083:                if (decorator == null) {
084:                    this .labelProviderCreationFailed = true;
085:                    setEnabled(false);
086:                }
087:
088:                if (exceptions[0] != null) {
089:                    throw exceptions[0];
090:                }
091:
092:                return decorator;
093:            }
094:
095:            /* (non-Javadoc)
096:             * @see org.eclipse.ui.internal.decorators.DecoratorDefinition#refreshDecorator()
097:             */
098:            protected void refreshDecorator() {
099:                //Only do something if disabled so as to prevent
100:                //gratutitous activation
101:                if (!this .enabled && decorator != null) {
102:                    IBaseLabelProvider cached = decorator;
103:                    decorator = null;
104:                    disposeCachedDecorator(cached);
105:                }
106:            }
107:
108:            /**
109:             * Decorate the image provided for the element type.
110:             * This method should not be called unless a check for
111:             * isEnabled() has been done first.
112:             * Return null if there is no image or if an error occurs.
113:             */
114:            Image decorateImage(Image image, Object element) {
115:                try {
116:                    //Internal decorator might be null so be prepared
117:                    ILabelDecorator currentDecorator = internalGetDecorator();
118:                    if (currentDecorator != null) {
119:                        return currentDecorator.decorateImage(image, element);
120:                    }
121:
122:                } catch (CoreException exception) {
123:                    handleCoreException(exception);
124:                }
125:                return null;
126:            }
127:
128:            /**
129:             * Decorate the text provided for the element type.
130:             * This method should not be called unless a check for
131:             * isEnabled() has been done first.
132:             * Return null if there is no text or if there is an exception.
133:             */
134:            String decorateText(String text, Object element) {
135:                try {
136:                    //Internal decorator might be null so be prepared
137:                    ILabelDecorator currentDecorator = internalGetDecorator();
138:                    if (currentDecorator != null) {
139:                        return currentDecorator.decorateText(text, element);
140:                    }
141:                } catch (CoreException exception) {
142:                    handleCoreException(exception);
143:                }
144:                return null;
145:            }
146:
147:            /**
148:             * Returns the decorator, or <code>null</code> if not enabled.
149:             * 
150:             * @return the decorator, or <code>null</code> if not enabled
151:             */
152:            public ILabelDecorator getDecorator() {
153:                return decorator;
154:            }
155:
156:            /* (non-Javadoc)
157:             * @see org.eclipse.ui.internal.decorators.DecoratorDefinition#internalGetLabelProvider()
158:             */
159:            protected IBaseLabelProvider internalGetLabelProvider()
160:                    throws CoreException {
161:                return internalGetDecorator();
162:            }
163:
164:            /* (non-Javadoc)
165:             * @see org.eclipse.ui.internal.decorators.DecoratorDefinition#isFull()
166:             */
167:            public boolean isFull() {
168:                return true;
169:            }
170:
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.