Example usage for org.eclipse.jface.preference PreferenceConverter getStoredRepresentation

List of usage examples for org.eclipse.jface.preference PreferenceConverter getStoredRepresentation

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceConverter getStoredRepresentation.

Prototype

public static String getStoredRepresentation(FontData[] fontData) 

Source Link

Document

Returns the stored representation of the given array of FontData objects.

Usage

From source file:ch.elexis.core.ui.preferences.PreferenceInitializer.java

License:Open Source License

/**
 * Diese Funktion wird nach dem Erstellen des Display aufgerufen und dient zum Initialiseren
 * frh bentigter Einstellungen, die bereits ein Display bentigen
 * /*  w  w  w . java  2 s  .c om*/
 */
public void initializeDisplayPreferences(Display display) {
    UiDesk.getColorRegistry().put(UiDesk.COL_RED, new RGB(255, 0, 0));
    UiDesk.getColorRegistry().put(UiDesk.COL_GREEN, new RGB(0, 255, 0));
    UiDesk.getColorRegistry().put(UiDesk.COL_DARKGREEN, new RGB(0, 88, 0));
    UiDesk.getColorRegistry().put(UiDesk.COL_BLUE, new RGB(0, 0, 255));
    UiDesk.getColorRegistry().put(UiDesk.COL_SKYBLUE, new RGB(135, 206, 250));
    UiDesk.getColorRegistry().put(UiDesk.COL_LIGHTBLUE, new RGB(0, 191, 255));
    UiDesk.getColorRegistry().put(UiDesk.COL_BLACK, new RGB(0, 0, 0));
    UiDesk.getColorRegistry().put(UiDesk.COL_GREY, new RGB(0x60, 0x60, 0x60));
    UiDesk.getColorRegistry().put(UiDesk.COL_WHITE, new RGB(255, 255, 255));
    UiDesk.getColorRegistry().put(UiDesk.COL_DARKGREY, new RGB(50, 50, 50));
    UiDesk.getColorRegistry().put(UiDesk.COL_LIGHTGREY, new RGB(180, 180, 180));
    UiDesk.getColorRegistry().put(UiDesk.COL_GREY60, new RGB(153, 153, 153));
    UiDesk.getColorRegistry().put(UiDesk.COL_GREY20, new RGB(51, 51, 51));

    FontData[] small = new FontData[] { new FontData("Helvetica", 7, SWT.NORMAL) }; //$NON-NLS-1$
    CoreHub.userCfg.set(Preferences.USR_SMALLFONT + "_default", //$NON-NLS-1$
            PreferenceConverter.getStoredRepresentation(small));
}

From source file:ch.elexis.preferences.PreferenceInitializer.java

License:Open Source License

/**
 * Diese Funktion wird nach dem Erstellen des Display aufgerufen und dient zum Initialiseren
 * frh bentigter Einstellungen, die bereits ein Display bentigen
 * /*  ww w  .jav  a 2 s  .c  o m*/
 */
public void initializeDisplayPreferences(Display display) {
    Desk.getColorRegistry().put(Desk.COL_RED, new RGB(255, 0, 0));
    Desk.getColorRegistry().put(Desk.COL_GREEN, new RGB(0, 255, 0));
    Desk.getColorRegistry().put(Desk.COL_BLUE, new RGB(0, 0, 255));
    Desk.getColorRegistry().put(Desk.COL_SKYBLUE, new RGB(135, 206, 250));
    Desk.getColorRegistry().put(Desk.COL_LIGHTBLUE, new RGB(0, 191, 255));
    Desk.getColorRegistry().put(Desk.COL_BLACK, new RGB(0, 0, 0));
    Desk.getColorRegistry().put(Desk.COL_GREY, new RGB(0x60, 0x60, 0x60));
    Desk.getColorRegistry().put(Desk.COL_WHITE, new RGB(255, 255, 255));
    Desk.getColorRegistry().put(Desk.COL_DARKGREY, new RGB(50, 50, 50));
    Desk.getColorRegistry().put(Desk.COL_LIGHTGREY, new RGB(180, 180, 180));
    Desk.getColorRegistry().put(Desk.COL_GREY60, new RGB(153, 153, 153));
    Desk.getColorRegistry().put(Desk.COL_GREY20, new RGB(51, 51, 51));

    FontData[] small = new FontData[] { new FontData("Helvetica", 7, SWT.NORMAL) }; //$NON-NLS-1$
    Hub.userCfg.set(PreferenceConstants.USR_SMALLFONT + "_default", //$NON-NLS-1$
            PreferenceConverter.getStoredRepresentation(small));
}

From source file:com.apicloud.navigator.composite.ThemeUIComposite.java

License:Open Source License

private void setFont(String fontId, FontData[] data) {
    String fdString = PreferenceConverter.getStoredRepresentation(data);

    Font existing = JFaceResources.getFont(fontId);
    String existingString = "";
    if (!(existing.isDisposed())) {
        existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData());
    }// w w w.j  av a  2s .  com
    if (existingString.equals(fdString)) {
        return;
    }
    JFaceResources.getFontRegistry().put(fontId, data);

    ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
    String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId);
    IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
    store.setValue(key, fdString);
}

From source file:com.aptana.theme.internal.ThemeManager.java

License:Open Source License

private void forceFontsUpToDate() {
    final String[] fontIds = new String[] { IThemeManager.VIEW_FONT_NAME, JFaceResources.TEXT_FONT,
            "org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" }; //$NON-NLS-1$
    UIUtils.getDisplay().asyncExec(new Runnable() {

        public void run() {
            for (String fontId : fontIds) {
                Font fFont = JFaceResources.getFontRegistry().get(fontId);
                // Only set new values if they're different from existing!
                Font existing = JFaceResources.getFont(fontId);
                String existingString = StringUtil.EMPTY;
                if (!existing.isDisposed()) {
                    existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData());
                }/*  ww  w . j  a  v  a  2s .c  o m*/
                String fdString = PreferenceConverter.getStoredRepresentation(fFont.getFontData());
                if (!existingString.equals(fdString)) {
                    // put in registry...
                    JFaceResources.getFontRegistry().put(fontId, fFont.getFontData());
                }
            }
        }
    });
}

From source file:com.aptana.theme.preferences.ThemePreferencePage.java

License:Open Source License

private void setFont(String fontId, FontData[] data) {
    String fdString = PreferenceConverter.getStoredRepresentation(data);
    // Only set new values if they're different from existing!
    Font existing = JFaceResources.getFont(fontId);
    String existingString = ""; //$NON-NLS-1$
    if (!existing.isDisposed()) {
        existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData());
    }//ww  w  .ja  v a  2 s . c o  m
    if (!existingString.equals(fdString)) {
        // put in registry...
        JFaceResources.getFontRegistry().put(fontId, data);
        // Save to prefs...
        ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
        String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId);
        IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
        store.setValue(key, fdString);
    }
}

From source file:com.google.dart.tools.ui.internal.preferences.FontPreferencePage.java

License:Open Source License

private void persistFont(String fontKey, FontData[] fontData) {
    IPreferenceStore workbenchPrefStore = WorkbenchPlugin.getDefault().getPreferenceStore();

    IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
    ITheme theme = themeManager.getCurrentTheme();
    FontRegistry registry = theme.getFontRegistry();
    registry.put(fontKey, fontData);/*from w  w w  . j av a  2  s  .c o  m*/

    String key = ThemeElementHelper.createPreferenceKey(theme, fontKey);
    String fdString = PreferenceConverter.getStoredRepresentation(fontData);
    String storeString = workbenchPrefStore.getString(key);

    if (!fdString.equals(storeString)) {
        workbenchPrefStore.setValue(key, fdString);
    }
}

From source file:com.google.dart.tools.ui.internal.preferences.FontPreferencePage.java

License:Open Source License

@SuppressWarnings("unused")
private void scaleFontNamed(String name, int size) {
    IPreferenceStore workbenchPrefStore = WorkbenchPlugin.getDefault().getPreferenceStore();
    IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
    ITheme theme = themeManager.getCurrentTheme();
    FontRegistry registry = theme.getFontRegistry();
    FontData[] fds = registry.getFontData(name);
    FontData data = new FontData(fds[0].getName(), size, fds[0].getStyle());
    registry.put(name, new FontData[] { data });
    String key = ThemeElementHelper.createPreferenceKey(theme, name);
    String fdString = PreferenceConverter.getStoredRepresentation(new FontData[] { data });
    String storeString = workbenchPrefStore.getString(key);
    if (!fdString.equals(storeString)) {
        workbenchPrefStore.setValue(key, fdString);
    }//from www. j  av  a 2 s .co m
}

From source file:com.ibm.research.tours.fx.FontFx.java

License:Open Source License

/**
 * apply font setting via preferences/*from w  w  w  .ja v a  2  s . c  o m*/
 * @param prefId
 * @param font
 * @return previous font setting
 */
public static FontData setFont(String prefId, FontData font) {
    FontData oldFont = getFont(prefId);
    IPreferenceStore workbenchStore = WorkbenchPlugin.getDefault().getPreferenceStore();
    FontData[] newFontData = new FontData[1];
    newFontData[0] = font;
    String newFontPrefsStr = PreferenceConverter.getStoredRepresentation(newFontData);
    workbenchStore.setValue(prefId, newFontPrefsStr);
    return oldFont;
}

From source file:io.usethesource.impulse.preferences.fields.FontFieldEditor.java

License:Open Source License

protected void doStore() {
    if (chosenFont != null) {
        fieldModified = false;//from   w  w  w  .  j ava 2  s  .c  o m
        levelFromWhichLoaded = preferencesLevel;
        setInherited(false);
        String encodedFont = PreferenceConverter.getStoredRepresentation(chosenFont);
        preferencesService.setStringPreference("instance", getPreferenceName(), encodedFont);
    }
}

From source file:io.usethesource.impulse.preferences.fields.FontFieldEditor.java

License:Open Source License

/**
 * Store the default preference for the field
 * being edited//from w ww.  j  av a2s.com
 */
protected void setToDefault() {
    String defaultFontStr = PreferenceConverter.getStoredRepresentation(getDefaultFontData());
    preferencesService.setStringPreference(IPreferencesService.DEFAULT_LEVEL, getPreferenceName(),
            defaultFontStr);
}