org.eclipse.jface.resource.FontRegistry Java Examples

The following examples show how to use org.eclipse.jface.resource.FontRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XYGraphMediaFactory.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Private constructor to avoid instantiation.
 */
private XYGraphMediaFactory() {
	_colorRegistry = new ColorRegistry();
	_imageRegistry = new ImageRegistry();
	_fontRegistry = new FontRegistry();
	cursorRegistry = new HashMap<String, Cursor>();
	_imageCache = new HashMap<ImageDescriptor, Image>();

	// dispose all images from the image cache, when the display is disposed
	Display.getDefault().addListener(SWT.Dispose, new Listener() {
		public void handleEvent(final Event event) {
			for (Image img : _imageCache.values()) {
				img.dispose();
			}
			disposeResources();
		}
	});

}
 
Example #2
Source File: ErrorTraceTreeViewer.java    From tlaplus with MIT License 5 votes vote down vote up
private Font getFont(final Object element, final int columnIndex) {
	boolean returnBoldVersion = false;
	
	if (element instanceof TLCVariable) {
		if (((TLCVariable) element).isTraceExplorerVar()) {
			returnBoldVersion = true;
		}
	} else if (element instanceof RecordToSourceCoupler.LoaderTLCState) {
		returnBoldVersion = true;
	}

	final FontRegistry fr = JFaceResources.getFontRegistry();
	return returnBoldVersion ? fr.getBold(TLCErrorView.JFACE_ERROR_TRACE_ID)
							 : fr.get(TLCErrorView.JFACE_ERROR_TRACE_ID);
}
 
Example #3
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Initialize the fonts.
 */
private void initializeFonts() {
    FontRegistry fontRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
    fFont = fontRegistry.get(FONT_DEFINITION_ID);
    fBoldFont = fontRegistry.getBold(FONT_DEFINITION_ID);
    fTable.setFont(fFont);
    /* Column header font cannot be set. See Bug 63038 */
}
 
Example #4
Source File: DiffAttributeEditor.java    From git-appraise-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Starts a new {@link StyleRange} given a specific line type.
 */
private StyleRange initDiffStyleRangeForLineType(DiffLineType lineType, int startTextOffset) {
  ColorRegistry reg =
      PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
  StyleRange range = new StyleRange();
  range.start = startTextOffset;
  switch (lineType) {
    case ADD:
      range.foreground = reg.get(THEME_DiffAddForegroundColor);
      range.background = reg.get(THEME_DiffAddBackgroundColor);
      break;
    case REMOVE:
      range.foreground = reg.get(THEME_DiffRemoveForegroundColor);
      range.background = reg.get(THEME_DiffRemoveBackgroundColor);
      break;
    case HUNK:
      range.foreground = reg.get(THEME_DiffHunkForegroundColor);
      range.background = reg.get(THEME_DiffHunkBackgroundColor);
      break;
    case HEADLINE:
      range.foreground = reg.get(THEME_DiffHeadlineForegroundColor);
      range.background = reg.get(THEME_DiffHeadlineBackgroundColor);
      FontRegistry fontReg =
          PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
      range.font = fontReg.get(THEME_DiffHeadlineFont);
      break;
    default:
      break;
  }
  return range;
}
 
Example #5
Source File: Preferences.java    From Rel with Apache License 2.0 5 votes vote down vote up
public static Font getPreferenceFont(Display display, String name) {
	FontRegistry fontRegistry = JFaceResources.getFontRegistry();
	FontData[] fonts = fontRegistry.filterData(getPreferenceFont(name), display);
	if (fonts == null)
		return fontRegistry.defaultFont();
	return new Font(display, fonts);
}
 
Example #6
Source File: WidgetMessageDecorator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Font getMessageFont() {
    final FontRegistry fontRegistry = JFaceResources.getFontRegistry();
    if (fontRegistry.hasValueFor(WidgetMessageDecorator.class.getName())) {
        return fontRegistry.get(WidgetMessageDecorator.class.getName());
    }
    fontRegistry.put(WidgetMessageDecorator.class.getName(),
            new FontData[] { new FontData(WidgetMessageDecorator.class.getName(), 10, SWT.NORMAL) });
    return fontRegistry.get(WidgetMessageDecorator.class.getName());
}
 
Example #7
Source File: UiDesk.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public static void updateFont(String cfgName){
	FontRegistry fr = JFaceResources.getFontRegistry();
	FontData[] fd =
		PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
			cfgName);
	fr.put(cfgName, fd);
}
 
Example #8
Source File: UiDesk.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public static Font getFont(String cfgName){
	FontRegistry fr = JFaceResources.getFontRegistry();
	if (!fr.hasValueFor(cfgName)) {
		FontData[] fd =
			PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
				cfgName);
		fr.put(cfgName, fd);
	}
	return fr.get(cfgName);
}
 
Example #9
Source File: UiDesk.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public static Font getFont(String name, int height, int style){
	String key = name + ":" + Integer.toString(height) + ":" + Integer.toString(style); //$NON-NLS-1$ //$NON-NLS-2$
	FontRegistry fr = JFaceResources.getFontRegistry();
	if (!fr.hasValueFor(key)) {
		FontData[] fd = new FontData[] {
			new FontData(name, height, style)
		};
		fr.put(key, fd);
	}
	return fr.get(key);
}
 
Example #10
Source File: ErrorTraceTreeViewer.java    From tlaplus with MIT License 4 votes vote down vote up
void dispose() {
	final FontRegistry fr = JFaceResources.getFontRegistry();
	
       fr.removeListener(errorTraceFontChangeListener);
}
 
Example #11
Source File: TmfRawEventViewer.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Initialize the fonts.
 * @since 1.0
 */
protected void initializeFonts() {
    FontRegistry fontRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
    fFixedFont = fontRegistry.get(FONT_DEFINITION_ID);
    fStyledText.setFont(fFixedFont);
}