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


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 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.themes;
011:
012:        import org.eclipse.core.runtime.IStatus;
013:        import org.eclipse.jface.resource.DataFormatException;
014:        import org.eclipse.swt.graphics.RGB;
015:        import org.eclipse.ui.IPluginContribution;
016:        import org.eclipse.ui.internal.misc.StatusUtil;
017:        import org.eclipse.ui.statushandlers.StatusManager;
018:        import org.eclipse.ui.themes.ColorUtil;
019:
020:        /**
021:         * A <code>ColorDefiniton </code> is the representation of the extensions 
022:         * defined by the <code>org.eclipse.ui.colorDefinitions</code> extension point.
023:         * 
024:         *  @since 3.0
025:         */
026:        public class ColorDefinition implements  IPluginContribution,
027:                IHierarchalThemeElementDefinition,
028:                ICategorizedThemeElementDefinition, IEditable {
029:
030:            /**
031:             * Default color value - black - for colors that cannot be parsed.
032:             */
033:            private static final RGB DEFAULT_COLOR_VALUE = new RGB(0, 0, 0);
034:
035:            private String defaultsTo;
036:
037:            private String description;
038:
039:            private String id;
040:
041:            private String label;
042:
043:            private String pluginId;
044:
045:            private String rawValue;
046:
047:            private String categoryId;
048:
049:            boolean isEditable;
050:
051:            private RGB parsedValue;
052:
053:            /**
054:             * Create a new instance of the receiver.
055:             * 
056:             * @param label the label for this definition
057:             * @param id the identifier for this definition
058:             * @param defaultsTo the id of a definition that this definition will 
059:             * 		default to.
060:             * @param value the default value of this definition, either in the form 
061:             * rrr,ggg,bbb or the name of an SWT color constant. 
062:             * @param description the description for this definition.
063:             * @param pluginId the identifier of the plugin that contributed this 
064:             * 		definition.
065:             */
066:            public ColorDefinition(String label, String id, String defaultsTo,
067:                    String value, String categoryId, boolean isEditable,
068:                    String description, String pluginId) {
069:
070:                this .label = label;
071:                this .id = id;
072:                this .defaultsTo = defaultsTo;
073:                this .rawValue = value;
074:                this .categoryId = categoryId;
075:                this .description = description;
076:                this .isEditable = isEditable;
077:                this .pluginId = pluginId;
078:            }
079:
080:            /**
081:             * Create a new instance of the receiver.
082:             * 
083:             * @param original the original definition.  This will be used to populate 
084:             * all fields except defaultsTo and value.  defaultsTo will always be 
085:             * <code>null</code>.
086:             * @param value the RGB value
087:             */
088:            public ColorDefinition(ColorDefinition original, RGB value) {
089:
090:                this .label = original.getName();
091:                this .id = original.getId();
092:                this .categoryId = original.getCategoryId();
093:                this .description = original.getDescription();
094:                this .isEditable = original.isEditable();
095:                this .pluginId = original.getPluginId();
096:
097:                this .parsedValue = value;
098:            }
099:
100:            /**
101:             * @return the categoryId, or <code>null</code> if none was supplied.
102:             */
103:            public String getCategoryId() {
104:                return categoryId;
105:            }
106:
107:            /**
108:             * @return the defaultsTo value, or <code>null</code> if none was supplied.
109:             */
110:            public String getDefaultsTo() {
111:                return defaultsTo;
112:            }
113:
114:            /**
115:             * @return the description text, or <code>null</code> if none was supplied.
116:             */
117:            public String getDescription() {
118:                return description;
119:            }
120:
121:            /**
122:             * @return the id of this definition.  Should not be <code>null</code>.
123:             */
124:            public String getId() {
125:                return id;
126:            }
127:
128:            /**
129:             * @return the label text.  Should not be <code>null</code>.
130:             */
131:            public String getName() {
132:                return label;
133:            }
134:
135:            /* (non-Javadoc)
136:             * @see org.eclipse.ui.IPluginContribution#getLocalId()
137:             */
138:            public String getLocalId() {
139:                return getId();
140:            }
141:
142:            /* (non-Javadoc)
143:             * @see org.eclipse.ui.IPluginContribution#getPluginId()
144:             */
145:            public String getPluginId() {
146:                return pluginId;
147:            }
148:
149:            /**
150:             * @return the value. Any SWT constants  supplied to the constructor will be 
151:             * evaluated and converted into their RGB value.
152:             */
153:            public RGB getValue() {
154:                if (parsedValue == null) {
155:                    try {
156:                        parsedValue = ColorUtil.getColorValue(rawValue);
157:                    } catch (DataFormatException e) {
158:                        parsedValue = DEFAULT_COLOR_VALUE;
159:                        IStatus status = StatusUtil
160:                                .newStatus(
161:                                        IStatus.WARNING,
162:                                        "Could not parse value for theme color " + id, e); //$NON-NLS-1$
163:                        StatusManager.getManager().handle(status,
164:                                StatusManager.LOG);
165:                    }
166:                }
167:                return parsedValue;
168:            }
169:
170:            /*
171:             * (non-Javadoc)
172:             * 
173:             * @see java.lang.Object#toString()
174:             */
175:            public String toString() {
176:                return getId();
177:            }
178:
179:            /* (non-Javadoc)
180:             * @see org.eclipse.ui.internal.themes.IEditable#isEditable()
181:             */
182:            public boolean isEditable() {
183:                return isEditable;
184:            }
185:
186:            /* (non-Javadoc)
187:             * @see java.lang.Object#equals(java.lang.Object)
188:             */
189:            public boolean equals(Object obj) {
190:                if (obj instanceof  ColorDefinition) {
191:                    return getId().equals(((ColorDefinition) obj).getId());
192:                }
193:                return false;
194:            }
195:
196:            /* (non-Javadoc)
197:             * @see java.lang.Object#hashCode()
198:             */
199:            public int hashCode() {
200:                return id.hashCode();
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.