@Override public Font getFont(Object element) { if (element instanceof ModelChangeElement) { ModelChangeElement changeElement = (ModelChangeElement) element; if (changeElement.isExternalized()) { return fFontRegistry.getBold(JFaceResources.DIALOG_FONT); } } return null; } }
/** * Create a new instance of this class. * * @param parent the parent registry */ public CascadingFontRegistry(FontRegistry parent) { super(Display.getCurrent(), false); this.parent = parent; parent.addListener(listener); }
protected void internalDispose() { fText= null; fBrowser= null; if (fFontListener != null) { JFaceResources.getFontRegistry().removeListener(fFontListener); fFontListener= null; } }
@Override public Font get(String symbolicName) { if (super.hasValueFor(symbolicName)) { return super.get(symbolicName); } return parent.get(symbolicName); }
@Override public FontData[] getFontData(String symbolicName) { if (super.hasValueFor(symbolicName)) { return super.getFontData(symbolicName); } return parent.getFontData(symbolicName); }
/** * Use this method to get SWT fonts. A FontRegistry is used to manage * the FontData[]->Font mapping. * <p> * Note: Don't dispose the returned SWT Font. It is disposed * automatically when the plugin is stopped. * * @param fontData * the font data * @return The SWT Font */ public Font getFont( FontData[] fontData ) { if ( !fontRegistry.hasValueFor( fontData[0].toString() ) ) { fontRegistry.put( fontData[0].toString(), fontData ); } return fontRegistry.get( fontData[0].toString() ); }
private Font getFont(boolean hidden, boolean active) { ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); if (active) { return theme.getFontRegistry().getItalic(IWorkbenchThemeConstants.TAB_TEXT_FONT); } if (hidden) { return theme.getFontRegistry().getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT); } return theme.getFontRegistry().get(IWorkbenchThemeConstants.TAB_TEXT_FONT); }
if (! JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) { FontData[] fontData = JFaceResources.getFontRegistry().getBold( JFaceResources.DEFAULT_FONT).getFontData(); JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
Font monospaceFont = JFaceResources.getFontRegistry().hasValueFor(symbolicName) ? JFaceResources.getFontRegistry().get(symbolicName) : null; if (monospaceFont == null) { fontData = defaultMonospaceFont.getFontData(); } else { Font defaultFont = JFaceResources.getFontRegistry().defaultFont(); JFaceResources.getFontRegistry().put(symbolicName, fontData); monospaceFont = JFaceResources.getFontRegistry().get(symbolicName); Font font = JFaceResources.getFontRegistry().hasValueFor(symbolicName) ? JFaceResources.getFontRegistry() .get(symbolicName) : null; if (font == null) { FontData[] fontData = createFontData(fontState, defaultFont); JFaceResources.getFontRegistry().put(symbolicName, fontData); font = JFaceResources.getFontRegistry().get(symbolicName);
/** * Return whether or not the dialog font is currently the same as the * default font. * * @return boolean if the two are the same */ protected static boolean dialogFontIsDefault() { FontData[] dialogFontData = JFaceResources.getFontRegistry() .getFontData(JFaceResources.DIALOG_FONT); FontData[] defaultFontData = JFaceResources.getFontRegistry() .getFontData(JFaceResources.DEFAULT_FONT); return Arrays.equals(dialogFontData, defaultFontData); }
/** * Returns the JFace's banner font. Convenience method equivalent to * * <pre> * JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT) * </pre> * * @return the font */ public static Font getBannerFont() { return getFontRegistry().get(BANNER_FONT); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { AbstractTextEditor textEditor= getActiveTextEditor(event); if (textEditor == null) { return null; } FontRegistry fontRegistry= textEditor.getSite().getWorkbenchWindow().getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry(); String fontProperty= textEditor.getSymbolicFontName(); if (fontProperty == null) { fontProperty= JFaceResources.TEXT_FONT; } Set<String> fontsToSet= getAffectedFontNames(fontProperty, fontRegistry); FontData[] initialFontData= null; String currentFontName= fontProperty; while (currentFontName != null && (initialFontData= fontRegistry.getFontData(currentFontName)) == null) { currentFontName= fgFontToDefault.get(currentFontName); } FontData[] newFontData= createFontDescriptor(initialFontData).getFontData(); if (newFontData != null) { fontsToSet.stream().forEach(fontName -> fontRegistry.put(fontName, newFontData)); } return Status.OK_STATUS; }
/** * Adds (or replaces) a font to this font registry under the given * symbolic name. * <p> * A property change event is reported whenever the mapping from * a symbolic name to a font changes. The source of the event is * this registry; the property name is the symbolic font name. * </p> * * @param symbolicName the symbolic font name * @param fontData an Array of FontData */ public void put(String symbolicName, FontData[] fontData) { put(symbolicName, fontData, true); }
/** * Creates a new font with the given font datas or <code>null</code> * if there is no data. * @return FontRecord for the new Font or <code>null</code>. */ private FontRecord createFont(String symbolicName, FontData[] fonts) { Display display = Display.getCurrent(); if (display == null) { return null; } if (cleanOnDisplayDisposal && !displayDisposeHooked) { hookDisplayDispose(display); } FontData[] validData = filterData(fonts, display); if (validData.length == 0) { //Nothing specified return null; } //Do not fire the update from creation as it is not a property change put(symbolicName, validData, false); Font newFont = new Font(display, validData); return new FontRecord(newFont, validData); }
if (getFontRegistry().hasValueFor(key)) { FontData[] data = event.getNewValue() instanceof String ? PreferenceConverter.basicGetFontData((String) event.getNewValue()) : (FontData[]) event.getNewValue(); getFontRegistry().put(key, data); processDefaultsTo(key, data); return;
/** * Returns whether this cascading registry has an override for the provided * color key. * * @param fontKey the provided color key * @return hether this cascading registry has an override */ public boolean hasOverrideFor(String fontKey) { return super.hasValueFor(fontKey); }
public static Font fontFromFontData(FontData[] fontDataArray) { if (fontDataArray != null && fontDataArray.length > 0) { String fontData = PreferenceConverter.getStoredRepresentation(fontDataArray); if (!JFaceResources.getFontRegistry().hasValueFor(fontData)) { FontData[] fData = PreferenceConverter.basicGetFontData(fontData); JFaceResources.getFontRegistry().put(fontData, fData); } Font font = JFaceResources.getFontRegistry().get(fontData); return font; } return null; }
/** * Return whether or not the dialog font is currently the same as the * default font. * * @return boolean if the two are the same */ protected static boolean dialogFontIsDefault() { FontData[] dialogFontData = JFaceResources.getFontRegistry() .getFontData(JFaceResources.DIALOG_FONT); FontData[] defaultFontData = JFaceResources.getFontRegistry() .getFontData(JFaceResources.DEFAULT_FONT); return Arrays.equals(dialogFontData, defaultFontData); }
/** * Returns the JFace's dialog font. Convenience method equivalent to * * <pre> * JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT) * </pre> * * @return the font */ public static Font getDialogFont() { return getFontRegistry().get(DIALOG_FONT); }
public static Object getValue(ITheme targetTheme, String propertyId, Class propertyType) { if (propertyType.isAssignableFrom(String.class)) { return targetTheme.getString(propertyId); } if (propertyType.isAssignableFrom(Color.class)) { Color result = targetTheme.getColorRegistry().get(propertyId); if (result != null) { return result; } } if (propertyType.isAssignableFrom(Font.class)) { FontRegistry fonts = targetTheme.getFontRegistry(); if (fonts.hasValueFor(propertyId)) { return fonts.get(propertyId); } } if (propertyType == Integer.class) { return Integer.valueOf(targetTheme.getInt(propertyId)); } if (propertyType == Boolean.class) { return targetTheme.getBoolean(propertyId) ? Boolean.TRUE : Boolean.FALSE; } return null; }