Source Code Cross Referenced for WorkbenchPreview.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) 2004, 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.jface.preference.IPreferenceStore;
013:        import org.eclipse.jface.util.IPropertyChangeListener;
014:        import org.eclipse.jface.util.PropertyChangeEvent;
015:        import org.eclipse.swt.SWT;
016:        import org.eclipse.swt.custom.CLabel;
017:        import org.eclipse.swt.custom.CTabFolder;
018:        import org.eclipse.swt.custom.CTabItem;
019:        import org.eclipse.swt.custom.ViewForm;
020:        import org.eclipse.swt.graphics.Color;
021:        import org.eclipse.swt.graphics.Image;
022:        import org.eclipse.swt.widgets.Composite;
023:        import org.eclipse.swt.widgets.Label;
024:        import org.eclipse.swt.widgets.ToolBar;
025:        import org.eclipse.swt.widgets.ToolItem;
026:        import org.eclipse.ui.ISharedImages;
027:        import org.eclipse.ui.IWorkbenchPreferenceConstants;
028:        import org.eclipse.ui.internal.IPreferenceConstants;
029:        import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
030:        import org.eclipse.ui.internal.IWorkbenchThemeConstants;
031:        import org.eclipse.ui.internal.WorkbenchImages;
032:        import org.eclipse.ui.internal.WorkbenchPlugin;
033:        import org.eclipse.ui.internal.util.PrefUtil;
034:        import org.eclipse.ui.themes.ITheme;
035:        import org.eclipse.ui.themes.IThemePreview;
036:
037:        /**
038:         * @since 3.0
039:         */
040:        public class WorkbenchPreview implements  IThemePreview {
041:
042:            private static IPreferenceStore preferenceStore = WorkbenchPlugin
043:                    .getDefault().getPreferenceStore();
044:
045:            // don't reset this dynamically, so just keep the information static.
046:            // see bug:
047:            //   75422 [Presentations] Switching presentation to R21 switches immediately, but only partially
048:            private static int tabPos = preferenceStore
049:                    .getInt(IPreferenceConstants.VIEW_TAB_POSITION);
050:
051:            private IPreferenceStore apiStore = PrefUtil
052:                    .getAPIPreferenceStore();
053:
054:            private boolean disposed = false;
055:
056:            private CTabFolder folder;
057:
058:            private ITheme theme;
059:
060:            private ToolBar toolBar;
061:
062:            private CLabel viewMessage;
063:
064:            private ViewForm viewForm;
065:
066:            private IPropertyChangeListener fontAndColorListener = new IPropertyChangeListener() {
067:                public void propertyChange(PropertyChangeEvent event) {
068:                    if (!disposed) {
069:                        setColorsAndFonts();
070:                        //viewMessage.setSize(viewMessage.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
071:                        viewForm.layout(true);
072:                    }
073:                }
074:            };
075:
076:            /* (non-Javadoc)
077:             * @see org.eclipse.ui.IPresentationPreview#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.ui.themes.ITheme)
078:             */
079:            public void createControl(Composite parent, ITheme currentTheme) {
080:                this .theme = currentTheme;
081:                folder = new CTabFolder(parent, SWT.BORDER);
082:                folder.setUnselectedCloseVisible(false);
083:                folder.setEnabled(false);
084:                folder.setMaximizeVisible(true);
085:                folder.setMinimizeVisible(true);
086:
087:                viewForm = new ViewForm(folder, SWT.NONE);
088:                viewForm.marginHeight = 0;
089:                viewForm.marginWidth = 0;
090:                viewForm.verticalSpacing = 0;
091:                viewForm.setBorderVisible(false);
092:                toolBar = new ToolBar(viewForm, SWT.FLAT | SWT.WRAP);
093:                ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
094:
095:                Image hoverImage = WorkbenchImages
096:                        .getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU);
097:                toolItem.setImage(hoverImage);
098:
099:                viewForm.setTopRight(toolBar);
100:
101:                viewMessage = new CLabel(viewForm, SWT.NONE);
102:                viewMessage.setText("Etu?"); //$NON-NLS-1$
103:                viewForm.setTopLeft(viewMessage);
104:
105:                CTabItem item = new CTabItem(folder, SWT.CLOSE);
106:                item.setText("Lorem"); //$NON-NLS-1$
107:                Label text = new Label(viewForm, SWT.NONE);
108:                viewForm.setContent(text);
109:                text.setText("Lorem ipsum dolor sit amet"); //$NON-NLS-1$
110:                text.setBackground(parent.getDisplay().getSystemColor(
111:                        SWT.COLOR_WHITE));
112:                item = new CTabItem(folder, SWT.CLOSE);
113:                item.setText("Ipsum"); //$NON-NLS-1$
114:                item.setControl(viewForm);
115:                item.setImage(WorkbenchImages
116:                        .getImage(ISharedImages.IMG_TOOL_COPY));
117:
118:                folder.setSelection(item);
119:
120:                item = new CTabItem(folder, SWT.CLOSE);
121:                item.setText("Dolor"); //$NON-NLS-1$
122:                item = new CTabItem(folder, SWT.CLOSE);
123:                item.setText("Sit"); //$NON-NLS-1$
124:
125:                currentTheme.addPropertyChangeListener(fontAndColorListener);
126:                setColorsAndFonts();
127:                setTabPosition();
128:                setTabStyle();
129:            }
130:
131:            /**
132:             * Set the tab style from preferences.
133:             */
134:            protected void setTabStyle() {
135:                boolean traditionalTab = apiStore
136:                        .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS);
137:                folder.setSimple(traditionalTab);
138:            }
139:
140:            /**
141:             * Set the tab location from preferences.
142:             */
143:            protected void setTabPosition() {
144:                tabPos = preferenceStore
145:                        .getInt(IPreferenceConstants.VIEW_TAB_POSITION);
146:                folder.setTabPosition(tabPos);
147:            }
148:
149:            /**
150:             * Set the folder colors and fonts
151:             */
152:            private void setColorsAndFonts() {
153:                folder.setSelectionForeground(theme.getColorRegistry().get(
154:                        IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR));
155:                folder.setForeground(theme.getColorRegistry().get(
156:                        IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR));
157:
158:                Color[] colors = new Color[2];
159:                colors[0] = theme.getColorRegistry().get(
160:                        IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
161:                colors[1] = theme.getColorRegistry().get(
162:                        IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
163:                colors[0] = theme.getColorRegistry().get(
164:                        IWorkbenchThemeConstants.ACTIVE_TAB_BG_START);
165:                colors[1] = theme.getColorRegistry().get(
166:                        IWorkbenchThemeConstants.ACTIVE_TAB_BG_END);
167:                folder
168:                        .setSelectionBackground(
169:                                colors,
170:                                new int[] { theme
171:                                        .getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT) },
172:                                theme
173:                                        .getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL));
174:
175:                folder.setFont(theme.getFontRegistry().get(
176:                        IWorkbenchThemeConstants.TAB_TEXT_FONT));
177:                viewMessage.setFont(theme.getFontRegistry().get(
178:                        IWorkbenchThemeConstants.VIEW_MESSAGE_TEXT_FONT));
179:            }
180:
181:            /* (non-Javadoc)
182:             * @see org.eclipse.ui.IPresentationPreview#dispose()
183:             */
184:            public void dispose() {
185:                disposed = true;
186:                theme.removePropertyChangeListener(fontAndColorListener);
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.