List of usage examples for org.eclipse.jface.resource FontRegistry hasValueFor
@Override
public boolean hasValueFor(String fontKey)
From source file:ch.elexis.core.ui.UiDesk.java
License:Open Source License
public static Font getFont(String cfgName) { FontRegistry fr = JFaceResources.getFontRegistry(); if (!fr.hasValueFor(cfgName)) { FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg), cfgName);/*from ww w .j a v a 2 s . c o m*/ fr.put(cfgName, fd); } return fr.get(cfgName); }
From source file:ch.elexis.core.ui.UiDesk.java
License:Open Source License
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);//from w w w . ja v a 2 s . c o m } return fr.get(key); }
From source file:ch.elexis.Desk.java
License:Open Source License
public static Font getFont(String cfgName) { FontRegistry fr = JFaceResources.getFontRegistry(); if (!fr.hasValueFor(cfgName)) { FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(Hub.userCfg), cfgName); fr.put(cfgName, fd);/*from w w w . j a v a 2 s. com*/ } return fr.get(cfgName); }
From source file:com.archimatetool.editor.ui.FontFactory.java
License:Open Source License
/** * @param fontName/*from w w w . jav a 2 s. co m*/ * @return A FOnt for the fontName or the default user font if null or exception occurs */ public static Font get(String fontName) { if (fontName == null) { return getDefaultUserViewFont(); } if (!FontRegistry.hasValueFor(fontName)) { try { FontData fd = new FontData(fontName); FontRegistry.put(fontName, new FontData[] { fd }); } // Can cause exception if using font name from different OS platform catch (Exception ex) { return getDefaultUserViewFont(); } } return FontRegistry.get(fontName); }
From source file:com.archimatetool.editor.ui.FontFactory.java
License:Open Source License
public static Font getDefaultUserViewFont() { // We don't have it, so try to set it if (!FontRegistry.hasValueFor(DEFAULT_VIEW_FONT_NAME)) { getDefaultUserViewFontData();//from www .j a v a 2s .c om } return FontRegistry.get(DEFAULT_VIEW_FONT_NAME); }
From source file:com.archimatetool.editor.ui.FontFactory.java
License:Open Source License
public static FontData getDefaultUserViewFontData() { // We don't have it if (!FontRegistry.hasValueFor(DEFAULT_VIEW_FONT_NAME)) { // So check user prefs... String fontDetails = Preferences.getDefaultViewFont(); if (StringUtils.isSet(fontDetails)) { try { // Put font details from user prefs FontData fd = new FontData(fontDetails); FontRegistry.put(DEFAULT_VIEW_FONT_NAME, new FontData[] { fd }); } catch (Exception ex) { //ex.printStackTrace(); setDefaultViewOSFontData(); }//from w w w .ja v a2s .c o m } // Not set in user prefs, so set default font data else { setDefaultViewOSFontData(); } } return FontRegistry.getFontData(DEFAULT_VIEW_FONT_NAME)[0]; }
From source file:com.redhat.ceylon.eclipse.code.editor.CeylonEditor.java
License:Open Source License
private void setSourceFontFromPreference() { String fontName = WorkbenchPlugin.getDefault().getPreferenceStore().getString(JFaceResources.TEXT_FONT); FontRegistry fontRegistry = CeylonPlugin.getInstance().getFontRegistry(); if (!fontRegistry.hasValueFor(fontName)) { fontRegistry.put(fontName, PreferenceConverter.readFontData(fontName)); }/* www.j av a 2 s .c o m*/ Font sourceFont = fontRegistry.get(fontName); if (sourceFont != null) { getSourceViewer().getTextWidget().setFont(sourceFont); } }
From source file:de.walware.ecommons.ui.components.WidgetToolsButton.java
License:Open Source License
static Font getToolButtonFont() { final FontRegistry fontRegistry = JFaceResources.getFontRegistry(); if (!fontRegistry.hasValueFor(FONT_SYMBOLIC_NAME)) { fontRegistry.addListener(new IPropertyChangeListener() { @Override// w w w . j av a 2 s. c o m public void propertyChange(final PropertyChangeEvent event) { if (event.getProperty().equals(JFaceResources.DIALOG_FONT)) { updateFont(); } } }); updateFont(); } return fontRegistry.get(FONT_SYMBOLIC_NAME); }
From source file:it.albertus.eqbulletin.gui.AboutDialog.java
private void createContents(final Shell shell) { GridLayoutFactory.swtDefaults().applyTo(shell); final LinkSelectionListener linkSelectionListener = new LinkSelectionListener(); final Link info = new Link(shell, SWT.WRAP); final FontRegistry fontRegistry = JFaceResources.getFontRegistry(); if (!fontRegistry.hasValueFor(SYM_NAME_FONT_DEFAULT)) { fontRegistry.put(SYM_NAME_FONT_DEFAULT, info.getFont().getFontData()); }//w w w . j ava 2 s .co m info.setFont(fontRegistry.getBold(SYM_NAME_FONT_DEFAULT)); final Version version = Version.getInstance(); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(info); Date versionDate; try { versionDate = version.getDate(); } catch (final Exception e) { logger.log(Level.WARNING, e.toString(), e); versionDate = new Date(); } info.setText(buildAnchor(Messages.get("url"), Messages.get("msg.application.name")) + ' ' + Messages.get("msg.version", version.getNumber(), DateFormat.getDateInstance(DateFormat.MEDIUM, Messages.getLanguage().getLocale()) .format(versionDate))); info.addSelectionListener(linkSelectionListener); final Link acknowledgementsLocations = new Link(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false) .applyTo(acknowledgementsLocations); acknowledgementsLocations.setText(Messages.get("lbl.about.acknowledgements.locations", buildAnchor(Messages.get("url.geofon"), Messages.get("lbl.geofon")), buildAnchor(Messages.get("url.gfz"), Messages.get("lbl.gfz")), buildAnchor(Messages.get("url.gevn"), Messages.get("lbl.gevn")))); acknowledgementsLocations.addSelectionListener(linkSelectionListener); final Label acknowledgementsData = new Label(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(acknowledgementsData); acknowledgementsData.setText(Messages.get("lbl.about.acknowledgements.data", Messages.get("lbl.geofon"), Messages.get("lbl.gfz"))); final Link linkLicense = new Link(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(linkLicense); linkLicense.setText( Messages.get("lbl.about.license", buildAnchor(Messages.get("url.gpl"), Messages.get("lbl.gpl")))); linkLicense.addSelectionListener(linkSelectionListener); final Text appLicense = new Text(shell, SWT.BORDER | SWT.V_SCROLL); appLicense.setText(loadTextResource("/META-INF/LICENSE.txt")); appLicense.setEditable(false); appLicense.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER) .hint(SWT.DEFAULT, SwtUtils.convertVerticalDLUsToPixels(appLicense, 80)).applyTo(appLicense); final Link linkEclipseLicense = new Link(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(linkEclipseLicense); linkEclipseLicense.setText(Messages.get("lbl.about.license.thirdparty", buildAnchor(Messages.get("url.epl"), Messages.get("lbl.epl")))); linkEclipseLicense.addSelectionListener(linkSelectionListener); final Button okButton = new Button(shell, SWT.PUSH); okButton.setText(Messages.get("lbl.button.ok")); final int buttonWidth = SwtUtils.convertHorizontalDLUsToPixels(okButton, IDialogConstants.BUTTON_WIDTH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false) .minSize(buttonWidth, SWT.DEFAULT).applyTo(okButton); okButton.setFocus(); okButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { shell.close(); } }); shell.setDefaultButton(okButton); }
From source file:net.refractions.udig.ui.graphics.AWTSWTImageUtils.java
License:Open Source License
/** * Converts an AWTFont to a SWT Font//from ww w . j a v a 2s . co m * * @param font and AWT Font * @param fontRegistry * @return the equivalent SWT Font */ public static org.eclipse.swt.graphics.Font awtFontToSwt(java.awt.Font font, FontRegistry fontRegistry) { String fontName = font.getFontName(); if (fontRegistry.hasValueFor(fontName)) { return fontRegistry.get(fontName); } int style = 0; if ((font.getStyle() & java.awt.Font.BOLD) == java.awt.Font.BOLD) { style = SWT.BOLD; } if ((font.getStyle() & java.awt.Font.ITALIC) == java.awt.Font.ITALIC) { style |= SWT.ITALIC; } FontData data = new FontData(fontName, font.getSize(), style); fontRegistry.put(fontName, new FontData[] { data }); return fontRegistry.get(fontName); }