1 /*******************************************************************************
2 * Copyright (c) 2010 SAP AG.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Mathias Kinzler (SAP AG) - initial implementation
10 *******************************************************************************/
11 package org
.eclipse
.egit
.ui
;
13 import org
.eclipse
.jface
.fieldassist
.ControlDecoration
;
14 import org
.eclipse
.jface
.fieldassist
.FieldDecorationRegistry
;
15 import org
.eclipse
.jface
.resource
.FontRegistry
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.graphics
.Font
;
18 import org
.eclipse
.swt
.widgets
.Control
;
19 import org
.eclipse
.ui
.PlatformUI
;
22 * Some utilities for UI code
24 public class UIUtils
{
27 * @param id see {@link FontRegistry#get(String)}
30 public static Font
getFont(final String id
) {
31 return PlatformUI
.getWorkbench().getThemeManager().getCurrentTheme()
32 .getFontRegistry().get(id
);
36 * @param id see {@link FontRegistry#getBold(String)}
39 public static Font
getBoldFont(final String id
) {
40 return PlatformUI
.getWorkbench().getThemeManager().getCurrentTheme()
41 .getFontRegistry().getBold(id
);
45 * Adds little bulb decoration to given control. Bulb will appear in top left
46 * corner of control after giving focus for this control.
48 * After clicking on bulb image text from <code>tooltip</code> will appear.
50 * @param control instance of {@link Control} object with should be decorated
51 * @param tooltip text value which should appear after clicking on bulb image.
53 public static void addBulbDecorator(final Control control
, final String tooltip
) {
54 ControlDecoration dec
= new ControlDecoration(control
, SWT
.TOP
| SWT
.LEFT
);
56 dec
.setImage(FieldDecorationRegistry
.getDefault().getFieldDecoration(
57 FieldDecorationRegistry
.DEC_CONTENT_PROPOSAL
).getImage());
59 dec
.setShowOnlyOnFocus(true);
60 dec
.setShowHover(true);
62 dec
.setDescriptionText(tooltip
);