Source Code Cross Referenced for DefaultToolTip.java in  » IDE-Eclipse » jface » org » eclipse » jface » window » 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 » jface » org.eclipse.jface.window 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 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.jface.window;
011:
012:        import org.eclipse.swt.SWT;
013:        import org.eclipse.swt.custom.CLabel;
014:        import org.eclipse.swt.graphics.Color;
015:        import org.eclipse.swt.graphics.Font;
016:        import org.eclipse.swt.graphics.Image;
017:        import org.eclipse.swt.graphics.Point;
018:        import org.eclipse.swt.widgets.Composite;
019:        import org.eclipse.swt.widgets.Control;
020:        import org.eclipse.swt.widgets.Event;
021:
022:        /**
023:         * Default implementation of ToolTip that provides an iconofied label with font
024:         * and color controls by subclass.
025:         * 
026:         * @since 3.3
027:         */
028:        public class DefaultToolTip extends ToolTip {
029:            private String text;
030:
031:            private Color backgroundColor;
032:
033:            private Font font;
034:
035:            private Image backgroundImage;
036:
037:            private Color foregroundColor;
038:
039:            private Image image;
040:
041:            private int style = SWT.SHADOW_NONE;
042:
043:            /**
044:             * Create new instance which add TooltipSupport to the widget
045:             * 
046:             * @param control the control on whose action the tooltip is shown
047:             */
048:            public DefaultToolTip(Control control) {
049:                super (control);
050:            }
051:
052:            /**
053:             * Create new instance which add TooltipSupport to the widget
054:             * 
055:             * @param control the control to which the tooltip is bound
056:             * @param style style passed to control tooltip behaviour
057:             * @param manualActivation <code>true</code> if the activation is done manually using
058:             *            {@link #show(Point)}
059:             * @see #RECREATE
060:             * @see #NO_RECREATE
061:             */
062:            public DefaultToolTip(Control control, int style,
063:                    boolean manualActivation) {
064:                super (control, style, manualActivation);
065:            }
066:
067:            /**
068:             * Creates the content are of the the tooltip. By default this creates a
069:             * CLabel to display text. To customize the text Subclasses may override the
070:             * following methods
071:             * <ul>
072:             * <li>{@link #getStyle(Event)}</li>
073:             * <li>{@link #getBackgroundColor(Event)}</li>
074:             * <li>{@link #getForegroundColor(Event)}</li>
075:             * <li>{@link #getFont(Event)}</li>
076:             * <li>{@link #getImage(Event)}</li>
077:             * <li>{@link #getText(Event)}</li>
078:             * <li>{@link #getBackgroundImage(Event)}</li>
079:             * </ul>
080:             * 
081:             * @param event
082:             *            the event that triggered the activation of the tooltip
083:             * @param parent
084:             *            the parent of the content area
085:             * @return the content area created
086:             */
087:            protected Composite createToolTipContentArea(Event event,
088:                    Composite parent) {
089:                Image image = getImage(event);
090:                Image bgImage = getBackgroundImage(event);
091:                String text = getText(event);
092:                Color fgColor = getForegroundColor(event);
093:                Color bgColor = getBackgroundColor(event);
094:                Font font = getFont(event);
095:
096:                CLabel label = new CLabel(parent, getStyle(event));
097:                if (text != null) {
098:                    label.setText(text);
099:                }
100:
101:                if (image != null) {
102:                    label.setImage(image);
103:                }
104:
105:                if (fgColor != null) {
106:                    label.setForeground(fgColor);
107:                }
108:
109:                if (bgColor != null) {
110:                    label.setBackground(bgColor);
111:                }
112:
113:                if (bgImage != null) {
114:                    label.setBackgroundImage(image);
115:                }
116:
117:                if (font != null) {
118:                    label.setFont(font);
119:                }
120:
121:                return label;
122:            }
123:
124:            /**
125:             * The style used to create the {@link CLabel} in the default implementation
126:             * 
127:             * @param event
128:             *            the event triggered the popup of the tooltip
129:             * @return the style
130:             */
131:            protected int getStyle(Event event) {
132:                return style;
133:            }
134:
135:            /**
136:             * The {@link Image} displayed in the {@link CLabel} in the default
137:             * implementation implementation
138:             * 
139:             * @param event
140:             *            the event triggered the popup of the tooltip
141:             * @return the {@link Image} or <code>null</code> if no image should be
142:             *         displayed
143:             */
144:            protected Image getImage(Event event) {
145:                return image;
146:            }
147:
148:            /**
149:             * The foreground {@link Color} used by {@link CLabel} in the default
150:             * implementation
151:             * 
152:             * @param event
153:             *            the event triggered the popup of the tooltip
154:             * @return the {@link Color} or <code>null</code> if default foreground
155:             *         color should be used
156:             */
157:            protected Color getForegroundColor(Event event) {
158:                return (foregroundColor == null) ? event.widget.getDisplay()
159:                        .getSystemColor(SWT.COLOR_INFO_FOREGROUND)
160:                        : foregroundColor;
161:            }
162:
163:            /**
164:             * The background {@link Color} used by {@link CLabel} in the default
165:             * implementation
166:             * 
167:             * @param event
168:             *            the event triggered the popup of the tooltip
169:             * @return the {@link Color} or <code>null</code> if default background
170:             *         color should be used
171:             */
172:            protected Color getBackgroundColor(Event event) {
173:                return (backgroundColor == null) ? event.widget.getDisplay()
174:                        .getSystemColor(SWT.COLOR_INFO_BACKGROUND)
175:                        : backgroundColor;
176:            }
177:
178:            /**
179:             * The background {@link Image} used by {@link CLabel} in the default
180:             * implementation
181:             * 
182:             * @param event
183:             *            the event triggered the popup of the tooltip
184:             * @return the {@link Image} or <code>null</code> if no image should be
185:             *         displayed in the background
186:             */
187:            protected Image getBackgroundImage(Event event) {
188:                return backgroundImage;
189:            }
190:
191:            /**
192:             * The {@link Font} used by {@link CLabel} in the default implementation
193:             * 
194:             * @param event
195:             *            the event triggered the popup of the tooltip
196:             * @return the {@link Font} or <code>null</code> if the default font
197:             *         should be used
198:             */
199:            protected Font getFont(Event event) {
200:                return font;
201:            }
202:
203:            /**
204:             * The text displayed in the {@link CLabel} in the default implementation
205:             * 
206:             * @param event
207:             *            the event triggered the popup of the tooltip
208:             * @return the text or <code>null</code> if no text has to be displayed
209:             */
210:            protected String getText(Event event) {
211:                return text;
212:            }
213:
214:            /**
215:             * The background {@link Image} used by {@link CLabel} in the default
216:             * implementation
217:             * 
218:             * @param backgroundColor
219:             *            the {@link Color} or <code>null</code> if default background
220:             *            color ({@link SWT#COLOR_INFO_BACKGROUND}) should be used
221:             */
222:            public void setBackgroundColor(Color backgroundColor) {
223:                this .backgroundColor = backgroundColor;
224:            }
225:
226:            /**
227:             * The background {@link Image} used by {@link CLabel} in the default
228:             * implementation
229:             * 
230:             * @param backgroundImage
231:             *            the {@link Image} or <code>null</code> if no image should be
232:             *            displayed in the background
233:             */
234:            public void setBackgroundImage(Image backgroundImage) {
235:                this .backgroundImage = backgroundImage;
236:            }
237:
238:            /**
239:             * The {@link Font} used by {@link CLabel} in the default implementation
240:             * 
241:             * @param font
242:             *            the {@link Font} or <code>null</code> if the default font
243:             *            should be used
244:             */
245:            public void setFont(Font font) {
246:                this .font = font;
247:            }
248:
249:            /**
250:             * The foreground {@link Color} used by {@link CLabel} in the default
251:             * implementation
252:             * 
253:             * @param foregroundColor
254:             *            the {@link Color} or <code>null</code> if default foreground
255:             *            color should be used
256:             */
257:            public void setForegroundColor(Color foregroundColor) {
258:                this .foregroundColor = foregroundColor;
259:            }
260:
261:            /**
262:             * The {@link Image} displayed in the {@link CLabel} in the default
263:             * implementation implementation
264:             * 
265:             * @param image
266:             *            the {@link Image} or <code>null</code> if no image should be
267:             *            displayed
268:             */
269:            public void setImage(Image image) {
270:                this .image = image;
271:            }
272:
273:            /**
274:             * The style used to create the {@link CLabel} in the default implementation
275:             * 
276:             * @param style
277:             *            the event triggered the popup of the tooltip
278:             */
279:            public void setStyle(int style) {
280:                this .style = style;
281:            }
282:
283:            /**
284:             * The text displayed in the {@link CLabel} in the default implementation
285:             * 
286:             * @param text
287:             *            the text or <code>null</code> if no text has to be displayed
288:             */
289:            public void setText(String text) {
290:                this.text = text;
291:            }
292:
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.