List of usage examples for org.eclipse.jface.preference IPreferenceStore isDefault
boolean isDefault(String name);
From source file:com.imperial.fiksen.codesimilarity.compare.ParseTreeMergeViewer.java
License:Open Source License
/** * Creates a color from the information stored in the given preference * store. Returns <code>null</code> if there is no such information * available.//from ww w . j a va2s . c om * * @param store * preference store * @param key * preference key * @return the color or <code>null</code> */ private static RGB createColor(IPreferenceStore store, String key) { if (!store.contains(key)) return null; if (store.isDefault(key)) return PreferenceConverter.getDefaultColor(store, key); return PreferenceConverter.getColor(store, key); }
From source file:com.iw.plugins.spindle.editors.SummarySourceViewer.java
License:Mozilla Public License
private void initializeWidgetFont(StyledText styledText) { IPreferenceStore store = getPreferenceStore(); if (store != null) { FontData data = null;//from www . j a v a 2 s . c om 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(styledText.getDisplay(), data); styledText.setFont(font); if (currentFont != null) currentFont.dispose(); currentFont = font; return; } } // if all the preferences failed styledText.setFont(JFaceResources.getTextFont()); }
From source file:com.iw.plugins.spindle.ui.properties.ProjectTemplatesPropertyPage.java
License:Mozilla Public License
protected void exportProjectPreference(IPreferenceStore src, IPreferenceStore target, String key, PreferenceTemplateSelector selector) { boolean srcIsDefault = src.isDefault(key); boolean targetIsDefault = target.isDefault(key); if (srcIsDefault && targetIsDefault) return;// w w w . j av a2 s. c om if (srcIsDefault && !targetIsDefault) { target.setToDefault(key); return; } String value = selector.getSelectedTemplate().getName(); target.setValue(key, value); }
From source file:com.motorola.studio.android.common.preferences.DialogWithToggleUtils.java
License:Apache License
/** * Get a preference toggle dialog preference key * This key is used to toggle dialogs. Do not use it for general proposes * @param preferenceKey/*from w w w . jav a2 s . c om*/ * @return the key, or null if it is default (not set) */ public static String getToggleDialogPreferenceKey(final String preferenceKey) { final String prefKey = preferenceKey + TOGGLE_DIALOG; IPreferenceStore store = CommonPlugin.getDefault().getPreferenceStore(); String prefValue = null; if (!store.isDefault(prefKey)) { prefValue = store.getString(prefKey); } return prefValue; }
From source file:com.motorola.studio.android.localization.translators.GoogleTranslator.java
License:Apache License
private static String getApiKey() { String apiKey = GoogleTranslatorConstants.API_KEY; IPreferenceStore prefStore = TranslationPlugin.getDefault().getPreferenceStore(); if (!prefStore.isDefault(GoogleTranslatorConstants.API_KEY_VALUE_PREFERENCE)) { apiKey = prefStore.getString(GoogleTranslatorConstants.API_KEY_VALUE_PREFERENCE); if (apiKey == null) { apiKey = GoogleTranslatorConstants.API_KEY; }// www . j a va 2s. c o m } return apiKey; }
From source file:com.motorola.studio.android.localization.translators.preferences.ui.TranslationPreferencePage.java
License:Apache License
/** * get the apikey// www. ja va 2 s . c o m * @return the apikey or an empty string for the default one */ private static String getApiKey() { String apiKey = ""; //$NON-NLS-1$ IPreferenceStore prefStore = TranslationPlugin.getDefault().getPreferenceStore(); if (!prefStore.isDefault(GoogleTranslatorConstants.API_KEY_VALUE_PREFERENCE)) { apiKey = prefStore.getString(GoogleTranslatorConstants.API_KEY_VALUE_PREFERENCE); if (apiKey == null) { apiKey = ""; //$NON-NLS-1$ } } return apiKey; }
From source file:com.motorolamobility.studio.android.db.devices.model.DeviceDbNode.java
License:Apache License
/** * @return// w w w. j a v a 2 s .co m * @throws IOException */ private File getLocalTempFile() throws IOException { IPreferenceStore preferenceStore = DbDevicesPlugin.getDefault().getPreferenceStore(); File tempLocationFile = null; if (!preferenceStore.isDefault(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE)) { String tempLocation = preferenceStore.getString(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE); tempLocationFile = new File(tempLocation); if (!tempLocationFile.isDirectory() || !FileUtil.canWrite(tempLocationFile)) { EclipseUtils.showErrorDialog(DbDevicesNLS.ERR_DbUtils_Local_Db_Title, NLS.bind(DbDevicesNLS.ERR_DbUtils_Local_Db_Msg, tempLocation)); preferenceStore.setToDefault(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE); } } //If tempLocationFile is null the file will be created on system's default temp dir. File tempFile = File.createTempFile(serialNumber + "_" + remoteDbPath.segment(1) + "_" + getName(), //$NON-NLS-1$ //$NON-NLS-2$ "db", tempLocationFile); //$NON-NLS-1$ tempFile.deleteOnExit(); return tempFile; }
From source file:com.safi.workshop.sqlexplorer.preferences.OverlayPreferenceStore.java
License:Open Source License
void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { if (orgin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) target.setToDefault(key.fKey); return;/* w w w . j a va 2 s. c om*/ } TypeDescriptor d = key.fDescriptor; if (BOOLEAN == d) { boolean originValue = orgin.getBoolean(key.fKey); boolean targetValue = target.getBoolean(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (DOUBLE == d) { double originValue = orgin.getDouble(key.fKey); double targetValue = target.getDouble(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (FLOAT == d) { float originValue = orgin.getFloat(key.fKey); float targetValue = target.getFloat(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (INT == d) { int originValue = orgin.getInt(key.fKey); int targetValue = target.getInt(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (LONG == d) { long originValue = orgin.getLong(key.fKey); long targetValue = target.getLong(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (STRING == d) { String originValue = orgin.getString(key.fKey); String targetValue = target.getString(key.fKey); if (targetValue != null && originValue != null && !targetValue.equals(originValue)) target.setValue(key.fKey, originValue); } }
From source file:com.xored.glance.internal.ui.preferences.TreeColors.java
License:Open Source License
private static RGB createColor(IPreferenceStore store, String key) { RGB rgb = null;/*from www .j a v a 2s. c om*/ if (store.contains(key)) { if (store.isDefault(key)) { rgb = PreferenceConverter.getDefaultColor(store, key); } else { rgb = PreferenceConverter.getColor(store, key); } return rgb; } return null; }
From source file:com.zeus.eclipsePlugin.PreferenceManager.java
License:Open Source License
/** * Get if the preference is currently set to use the default value. * @param pref The preference you are checking * @return True if the preference is it's default value, false otherwise. *///from www . j av a 2 s . c o m public static boolean isPreferenceDefault(Preference pref) { if (ZXTMPlugin.getDefault() == null) { return false; } IPreferenceStore preferences = ZXTMPlugin.getDefault().getPreferenceStore(); return preferences.isDefault(pref.getKey()); }