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


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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.presentations.r33;
011:
012:        import org.eclipse.jface.resource.JFaceResources;
013:        import org.eclipse.swt.graphics.Color;
014:        import org.eclipse.swt.graphics.Font;
015:        import org.eclipse.swt.graphics.RGB;
016:        import org.eclipse.ui.internal.IWorkbenchThemeConstants;
017:        import org.eclipse.ui.internal.preferences.AbstractPropertyListener;
018:        import org.eclipse.ui.internal.preferences.IPropertyMap;
019:        import org.eclipse.ui.internal.preferences.PropertyUtil;
020:        import org.eclipse.ui.internal.themes.LightColorFactory;
021:        import org.eclipse.ui.presentations.StackPresentation;
022:
023:        /**
024:         * @since 3.1
025:         */
026:        public class DefaultThemeListener extends AbstractPropertyListener {
027:
028:            private DefaultTabFolder folder;
029:            private IPropertyMap theme;
030:
031:            public DefaultThemeListener(DefaultTabFolder folder,
032:                    IPropertyMap theme) {
033:                this .folder = folder;
034:                this .theme = theme;
035:            }
036:
037:            private Color getColor(String id, Color defaultValue) {
038:                Color value = (Color) theme.getValue(id, Color.class);
039:                if (value == null) {
040:                    value = defaultValue;
041:                }
042:
043:                return value;
044:            }
045:
046:            private int getInt(String id, int defaultValue) {
047:                Integer result = ((Integer) theme.getValue(id, Integer.class));
048:
049:                if (result == null) {
050:                    return defaultValue;
051:                }
052:
053:                return result.intValue();
054:            }
055:
056:            private boolean getBoolean(String id, boolean defaultValue) {
057:                Boolean result = ((Boolean) theme.getValue(id, Boolean.class));
058:
059:                if (result == null) {
060:                    return defaultValue;
061:                }
062:
063:                return result.booleanValue();
064:            }
065:
066:            /*
067:             * Update the ACTIVE_TAB_HIGHLIGHT_START color in the color registry.
068:             * Return true if we're using highlights on tabs, false otherwise.
069:             * The highlight color is computed based on the ACTIVE_TAB_BG_START.
070:             * We need to do this here, in the ThemeListener, so that we can catch
071:             * the change to the ACTIVE_TAB_BG_START begin color and update the
072:             * highlight color appropriately.
073:             * @return boolean use highlight color
074:             */
075:            private boolean updateHighlightColor() {
076:                if (!useHighlight())
077:                    return false;
078:                //get newTabBegin from theme, not from ColorRegistry, which may not have been updated yet
079:                RGB newTabBegin = getColor(
080:                        IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, null)
081:                        .getRGB();
082:                RGB newHighlight = LightColorFactory
083:                        .createHighlightStartColor(newTabBegin);
084:                //Registry handles lifecycle of colors so no leakage and if RGB s.equals then no change
085:                JFaceResources.getColorRegistry().put(
086:                        IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT_START,
087:                        newHighlight);
088:                return true;
089:            }
090:
091:            private boolean useHighlight() {
092:                return PropertyUtil.get(this .theme,
093:                        IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT, false);
094:            }
095:
096:            public void update() {
097:                Color[] activeFocusBackgroundColors = updateHighlightColor() ? new Color[] {
098:                        getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START,
099:                                null),
100:                        getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END,
101:                                null),
102:                        JFaceResources
103:                                .getColorRegistry()
104:                                .get(
105:                                        IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT_START) }
106:                        : new Color[] {
107:                                getColor(
108:                                        IWorkbenchThemeConstants.ACTIVE_TAB_BG_START,
109:                                        null),
110:                                getColor(
111:                                        IWorkbenchThemeConstants.ACTIVE_TAB_BG_END,
112:                                        null) };
113:
114:                folder
115:                        .setColors(
116:                                new DefaultTabFolderColors(
117:                                        getColor(
118:                                                IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR,
119:                                                null),
120:                                        activeFocusBackgroundColors,
121:                                        new int[] { getInt(
122:                                                IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT,
123:                                                0) },
124:                                        getBoolean(
125:                                                IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL,
126:                                                true)),
127:                                StackPresentation.AS_ACTIVE_FOCUS, true);
128:
129:                folder
130:                        .setColors(
131:                                new DefaultTabFolderColors(
132:                                        getColor(
133:                                                IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_TEXT_COLOR,
134:                                                null),
135:                                        new Color[] {
136:                                                getColor(
137:                                                        IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_BG_START,
138:                                                        null),
139:                                                getColor(
140:                                                        IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_BG_END,
141:                                                        null) },
142:                                        new int[] { getInt(
143:                                                IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_PERCENT,
144:                                                0) },
145:                                        getBoolean(
146:                                                IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_VERTICAL,
147:                                                true)),
148:                                StackPresentation.AS_ACTIVE_FOCUS, false);
149:
150:                folder
151:                        .setColors(
152:                                new DefaultTabFolderColors(
153:                                        getColor(
154:                                                IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR,
155:                                                null),
156:                                        new Color[] {
157:                                                getColor(
158:                                                        IWorkbenchThemeConstants.INACTIVE_TAB_BG_START,
159:                                                        null),
160:                                                getColor(
161:                                                        IWorkbenchThemeConstants.INACTIVE_TAB_BG_END,
162:                                                        null) },
163:                                        new int[] { getInt(
164:                                                IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT,
165:                                                0) },
166:                                        getBoolean(
167:                                                IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL,
168:                                                true)),
169:                                StackPresentation.AS_INACTIVE);
170:
171:                folder
172:                        .setColors(
173:                                new DefaultTabFolderColors(
174:                                        getColor(
175:                                                IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR,
176:                                                null),
177:                                        new Color[] { getColor(
178:                                                IWorkbenchThemeConstants.INACTIVE_TAB_BG_START,
179:                                                null) }, new int[0], true),
180:                                StackPresentation.AS_ACTIVE_NOFOCUS);
181:
182:                folder.setFont((Font) theme.getValue(
183:                        IWorkbenchThemeConstants.TAB_TEXT_FONT, Font.class));
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.