private RGB getColorFromStore(IPreferenceStore store, String key) { RGB rgb= null; if (store.contains(key)) { if (store.isDefault(key)) rgb= PreferenceConverter.getDefaultColor(store, key); else rgb= PreferenceConverter.getColor(store, key); } return rgb; }
/** * Sets the default value and fires a property * change event if necessary. * * @param store the preference store * @param key the preference key * @param newValue the new value * @param fireEvent <code>false</code> if no event should be fired * @since 3.4 */ private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) { if (!fireEvent) { PreferenceConverter.setDefault(store, key, newValue); return; } RGB oldValue= null; if (store.isDefault(key)) oldValue= PreferenceConverter.getDefaultColor(store, key); PreferenceConverter.setDefault(store, key, newValue); if (oldValue != null && !oldValue.equals(newValue)) store.firePropertyChangeEvent(key, oldValue, newValue); }
public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); fOverlayStore.setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection()); } });
/** * Sets the current value of the preference with the given name * in the given preference store. This method does not update * the font registry or fire a property change event. * * @param store the preference store * @param name the name of the preference * @param value the new current value of the preference * * @see PreferenceConverter#setValue(IPreferenceStore, String, FontData[]) */ public static void putValue(IPreferenceStore store, String name, FontData[] value) { FontData[] oldValue = getFontDataArray(store, name); // see if the font has changed if (!Arrays.equals(oldValue, value)) { store.putValue(name, getStoredRepresentation(value)); } }
/** * Propagates the font set in the source store to the * target store using the given keys. * * @param source the store from which to read the text font * @param sourceKey the key under which the font can be found * @param target the store to which to propagate the font * @param targetKey the key under which to store the font */ private static void propagateFont(IPreferenceStore source, String sourceKey, IPreferenceStore target, String targetKey) { FontData fd= PreferenceConverter.getFontData(source, sourceKey); if (fd != null) { boolean isDefault= target.isDefault(targetKey); // save old state! PreferenceConverter.setDefault(target, targetKey, fd); if (isDefault) { // restore old state target.setToDefault(targetKey); } } }
private void updateQuickDiffControls() { boolean quickdiffOverviewRuler= false; for (int i= 0; i < fQuickDiffModel.length; i++) { fQuickDiffColorEditors[i].setColorValue(PreferenceConverter.getColor(fStore, fQuickDiffModel[i][0])); quickdiffOverviewRuler |= fStore.getBoolean(fQuickDiffModel[i][1]); } fQuickDiffOverviewRulerCheckBox.setSelection(quickdiffOverviewRuler); }
RGB fontColorDefaultDefault = editorsStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? getDisplay() .getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB() : PreferenceConverter.getColor(editorsStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND); RGB backgrounColorDefaultDefault = editorsStore .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? getDisplay().getSystemColor( SWT.COLOR_LIST_BACKGROUND).getRGB() : PreferenceConverter.getColor(editorsStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); FontData[] fontDataDefaultDefault = JFaceResources.getTextFont().getFontData(); PreferenceConverter.setDefault(preferenceStore, colorKey, defaults.getColor()); else { PreferenceConverter.setDefault(preferenceStore, colorKey, fontColorDefaultDefault); PreferenceConverter.setDefault(preferenceStore, backgroundKey, defaults.getBackgroundColor()); else { PreferenceConverter.setDefault(preferenceStore, backgroundKey, backgrounColorDefaultDefault); PreferenceConverter.setDefault(preferenceStore, fontKey, defaults.getFontData()); else { PreferenceConverter.setDefault(preferenceStore, fontKey, fontDataDefaultDefault); RGB color = PreferenceConverter.getColor(preferenceStore, colorKey); if (!color.equals(fontColorDefaultDefault)) style.setColor(color); RGB background = PreferenceConverter.getColor(preferenceStore, backgroundKey); if (!background.equals(backgrounColorDefaultDefault)) style.setBackgroundColor(background); FontData[] fontDataArray = PreferenceConverter.getFontDataArray(preferenceStore, fontKey); if (!Arrays.equals(fontDataArray, fontDataDefaultDefault)) {
/** * Sets the default value of the preference with the given name * in the given preference store. As FontDatas are stored as * arrays this method is only provided for backwards compatibility. * Use <code>setDefault(IPreferenceStore, String, FontData[])</code> * instead. * * @param store the preference store * @param name the name of the preference * @param value the new default value of the preference */ public static void setDefault(IPreferenceStore store, String name, FontData value) { FontData[] fontDatas = new FontData[1]; fontDatas[0] = value; setDefault(store, name, fontDatas); }
public void propertyChange(PropertyChangeEvent event) { if(event.getProperty().equals(ILogViewerConstants.PREF_CURSORLINE_COLOR)) { Color color = new Color(Display.getCurrent(),PreferenceConverter.getColor(store,ILogViewerConstants.PREF_CURSORLINE_COLOR)); cursorLinePainter.setHighlightColor(color); } if(event.getProperty().equals(ILogViewerConstants.PREF_EDITOR_FONT_STYLE)) { FontData[] fontData = PreferenceConverter.getFontDataArray(store,ILogViewerConstants.PREF_EDITOR_FONT_STYLE); txtViewer.getTextWidget().setFont(new Font(Display.getCurrent(),fontData)); } if(event.getProperty().equals(ILogViewerConstants.PREF_WORD_WRAP)) { boolean wordWrap = store.getBoolean(ILogViewerConstants.PREF_WORD_WRAP); txtViewer.getTextWidget().setWordWrap(wordWrap); } if(event.getProperty().equals(ILogViewerConstants.PREF_SHOW_WHEN_UPDATED)) { showWhenUpdated = store.getBoolean(ILogViewerConstants.PREF_SHOW_WHEN_UPDATED); } if(event.getProperty().equals(ILogViewerConstants.PREF_SHOW_TOP_OF_FILE)) { showTopOfFile = store.getBoolean(ILogViewerConstants.PREF_SHOW_TOP_OF_FILE); } } }
protected void doLoadDefault() { if (colorSelector == null) { return; } colorSelector.setColorValue(PreferenceConverter.getDefaultColor( getPreferenceStore(), getPreferenceName())); }
/** * @see org.eclipse.jface.preference.PreferencePage#performDefaults() */ @Override protected void performDefaults() { for (int i = 0; i < fAppearanceColorListModel.length; i++) { String key = fAppearanceColorListModel[i][1]; PreferenceConverter.setValue(getPreferenceStore(), key, PreferenceConverter.getDefaultColor(getPreferenceStore(), key)); } handleAppearanceColorListSelection(); super.performDefaults(); }
String key = createPreferenceKey(theme, id); FontData[] prefFont = store != null ? PreferenceConverter .getFontDataArray(store, key) : null; FontData[] defaultFont = null; if (definition.getValue() != null) { } else if (definition.getDefaultsTo() != null) { String defaultsToKey = createPreferenceKey(theme, definition.getDefaultsTo()); FontData[] defaultFontData = PreferenceConverter.getDefaultFontDataArray(store, defaultsToKey); defaultFont = registry.filterData(defaultFontData, display); } else { if (prefFont == null || prefFont == PreferenceConverter.getFontDataArrayDefaultDefault()) { if (definition.getValue() != null) { prefFont = definition.getValue(); PreferenceConverter.setDefault(store, key, defaultFont);
/** * {@inheritDoc} */ protected void performDefaults() { // Show Decorated Values showDecoratedValuesButton.setSelection( !getPreferenceStore().getDefaultBoolean( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) ); // Attributes Colors And Fonts for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ ) { FontData[] fontDatas = PreferenceConverter.getDefaultFontDataArray( BrowserCommonActivator.getDefault() .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] ); RGB rgb = PreferenceConverter.getDefaultColor( BrowserCommonActivator.getDefault().getPreferenceStore(), ATTRIBUTE_COLOR_CONSTANTS[i] ); setColorsAndFonts( i, fontDatas, rgb ); } super.performDefaults(); }
if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) { if (!store.getBoolean(fontPropagatedKey)) PreferenceConverter.setValue( getDeprecatedWorkbenchPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT, PreferenceConverter.getFontDataArray(store, JFaceResources.TEXT_FONT)); PreferenceConverter.putValue(store, JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT));
/** * Returns the current value of the first entry of the * font-valued preference with the * given name in the given preference store. * Returns the default-default value (<code>FONTDATA_ARRAY_DEFAULT_DEFAULT</code>) * if there is no preference with the given name, or if the current value * cannot be treated as font data. * This API is provided for backwards compatibility. It is * recommended that <code>getFontDataArray</code> is used instead. * * @param store the preference store * @param name the name of the preference * @return the font-valued preference */ public static FontData getFontData(IPreferenceStore store, String name) { return getFontDataArray(store, name)[0]; }
/** * {@inheritDoc} */ public boolean performOk() { // Show Decorated Values getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES, !showDecoratedValuesButton.getSelection() ); // Attributes Colors And Fonts for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ ) { FontData[] fontDatas = PreferenceConverter.getFontDataArray( BrowserCommonActivator.getDefault() .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] ); setFontData( fontDatas, attributeBoldButtons[i], attributeItalicButtons[i] ); RGB rgb = attributeColorSelectors[i].getColorValue(); PreferenceConverter.setValue( BrowserCommonActivator.getDefault().getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i], fontDatas ); PreferenceConverter.setValue( BrowserCommonActivator.getDefault().getPreferenceStore(), ATTRIBUTE_COLOR_CONSTANTS[i], rgb ); } return true; }
/** * Store the default preference for the field * being edited */ protected void setToDefault() { FontData[] defaultFontData = PreferenceConverter .getDefaultFontDataArray(getPreferenceStore(), getPreferenceName()); PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(), defaultFontData); }
FontData data= PreferenceConverter.getFontData(fPreferenceStore, JFaceResources.TEXT_FONT);
/** * Updates the viewer's font to match the preferences. */ private void updateViewerFont() { IPreferenceStore store= getPreferenceStore(); if (store != null) { FontData data= null; if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) { data= PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT); } else { data= PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT); } if (data != null) { Font font= new Font(getTextWidget().getDisplay(), data); applyFont(font); if (getFont() != null) { getFont().dispose(); } setFont(font); return; } } // if all the preferences failed applyFont(JFaceResources.getTextFont()); }
private void updateQuickDiffControls() { boolean quickdiffOverviewRuler= false; for (int i= 0; i < fQuickDiffModel.length; i++) { fQuickDiffColorEditors[i].setColorValue(PreferenceConverter.getColor(fStore, fQuickDiffModel[i][0])); quickdiffOverviewRuler |= fStore.getBoolean(fQuickDiffModel[i][1]); } fQuickDiffOverviewRulerCheckBox.setSelection(quickdiffOverviewRuler); }