/** * Does its best at determining the default value for the given key. Checks the * given object's type and then looks in the list of defaults to see if a value * exists. If not or if there is a problem converting the value, the default default * value for that type is returned. */ private Object getDefault(String key, Object obj) { IEclipsePreferences defaults = getDefaultPreferences(); if (obj instanceof String) return defaults.get(key, STRING_DEFAULT_DEFAULT); else if (obj instanceof Integer) return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT)); else if (obj instanceof Double) return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT)); else if (obj instanceof Float) return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT)); else if (obj instanceof Long) return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT)); else if (obj instanceof byte[]) return defaults.getByteArray(key, BYTE_ARRAY_DEFAULT_DEFAULT); else if (obj instanceof Boolean) return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE : Boolean.FALSE; else return null; }
/** * Returns the default value for the string-valued property * with the given name. * Returns the default-default value (the empty string <code>""</code>) * is no default property with the given name, or if the default * value cannot be treated as a string. * * @param name the name of the property * @return the default value of the named property */ @Override public String getDefaultString(String name) { return getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT); }
private boolean showWizard() { IEclipsePreferences instanceNode= InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN); if (instanceNode.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null) return instanceNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); IEclipsePreferences defaultNode= DefaultScope.INSTANCE.getNode(JavaUI.ID_PLUGIN); return defaultNode.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true); }
/** * Sets the current value of the property with the given name back * to its default value. Has no effect if the property does not have * its own current value. * <p> * Note that the recommended way of re-initializing a property to the * appropriate default value is to call <code>setToDefault</code>. * This is implemented by removing the named value from the object, * thereby exposing the default value. * </p> * <p> * A property change event is always reported. In the event * object, the property name is the name of the property, and the * old and new values are either strings, or <code>null</code> * indicating the default-default value. * </p> * * @param name the name of the property */ @Override public void setToDefault(String name) { IEclipsePreferences preferences = getPluginPreferences(true); Object oldValue = preferences.get(name, null); if (oldValue != null) preferences.remove(name); }
private void doShowCleanUpWizard(boolean showWizard) { IEclipsePreferences preferences= fCurrContext.getNode(JavaUI.ID_PLUGIN); if (preferences.get(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, null) != null && preferences.getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true) == showWizard) return; preferences.putBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, showWizard); }
/** * Returns the current value of the string-valued property with the * given name. * Returns the default-default value (the empty string <code>""</code>) * if there is no property with the given name. * * @param name the name of the property * @return the string-valued property */ @Override public String getString(String name) { return getPluginPreferences(true).get(name, getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT)); }
/** * Returns whether the given property is known to this preference object, * either by having an explicit setting or by having a default * setting. * * @param name the name of the property * @return <code>true</code> if either a current value or a default * value is known for the named property, and <code>false</code>otherwise */ @Override public boolean contains(String name) { if (name == null) return false; String value = getPluginPreferences(true).get(name, null); if (value != null) return true; return getDefaultPreferences().get(name, null) != null; }
protected String getSelectedProfileId(IScopeContext instanceScope) { String profileId= instanceScope.getNode(JavaUI.ID_PLUGIN).get(fProfileKey, null); if (profileId == null) { // request from bug 129427 profileId= DefaultScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).get(fProfileKey, null); } return profileId; }
static String[] getUserDefinedContentTypeIds(IScopeContext context) { String ids = context.getNode(ContentType.PREF_USER_DEFINED) .get(ContentType.PREF_USER_DEFINED, ContentType.EMPTY_STRING); if (ids.isEmpty()) { return new String[0]; } return ids.split(ContentType.PREF_USER_DEFINED__SEPARATOR); } }
/** * {@inheritDoc} */ public boolean contains(String name) { return getNode().get(name, null) != null; }
protected String getSelectedProfileId(IScopeContext instanceScope) { String profileId= instanceScope.getNode(JavaUI.ID_PLUGIN).get(fProfileKey, null); if (profileId == null) { // request from bug 129427 profileId= new DefaultScope().getNode(JavaUI.ID_PLUGIN).get(fProfileKey, null); } return profileId; }
protected int[] getVisibilityOffsets() { int[] offsets= new int[N_VISIBILITIES]; String key= APPEARANCE_VISIBILITY_SORT_ORDER; boolean success= fillVisibilityOffsetsFromPreferenceString(fPreferences.get(key, ""), offsets); //$NON-NLS-1$ if (!success) { String defaultValue= fDefaultPreferenceStore.get(key, ""); //$NON-NLS-1$ fPreferences.put(key, defaultValue); fillVisibilityOffsetsFromPreferenceString(defaultValue, offsets); } return offsets; }
/** Set the initial values to the fields. */ protected void initFields() { final IEclipsePreferences prefs = SARLEclipsePlugin.getDefault().getPreferences(); this.trackerLogin.setText(prefs.get(PREFERENCE_LOGIN, "")); //$NON-NLS-1$ }
private void initDefault() { if (fFormatterCombo == null) { return; } String formatterID= fPrefs.get(JavaCore.JAVA_FORMATTER, fDefaultFormatterId); fFormatterCombo.select(getFormatterIndex(formatterID)); }
/** * @return Returns the collection of profiles currently stored in the preference store or * <code>null</code> if the loading failed. The elements are of type {@link ProfileManager.CustomProfile} * and are all updated to the latest version. * @throws CoreException */ public List<Profile> readProfiles(IScopeContext scope) throws CoreException { return readProfilesFromString(scope.getNode(JavaUI.ID_PLUGIN).get(fProfilesKey, null)); }
public BreakOnExceptions getBreakOnExceptions() { try { String value = getPrefs().get(PREFS_BREAK_ON_EXCEPTIONS, null); if (value == null) { return BreakOnExceptions.uncaught; } else { return BreakOnExceptions.valueOf(value); } } catch (IllegalArgumentException iae) { return BreakOnExceptions.uncaught; } }
public static boolean hasSettingsInScope(IScopeContext context) { IEclipsePreferences node= context.getNode(JavaUI.ID_PLUGIN); Set<String> keys= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getKeys(); for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) { String key= iterator.next(); if (node.get(SAVE_PARTICIPANT_KEY_PREFIX + key, null) != null) return true; } return false; }
public static boolean hasSettingsInScope(IScopeContext context) { IEclipsePreferences node= context.getNode(JavaUI.ID_PLUGIN); Set<String> keys= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getKeys(); for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) { String key= iterator.next(); if (node.get(SAVE_PARTICIPANT_KEY_PREFIX + key, null) != null) return true; } return false; }
public static void resetScalePercentage() { IEclipsePreferences iprefs = InstanceScope.INSTANCE.getNode(IntroPlugin.PLUGIN_ID); IEclipsePreferences dprefs = DefaultScope.INSTANCE.getNode(IntroPlugin.PLUGIN_ID); String defaultScale = dprefs.get(SCALE_FACTOR, "0"); //$NON-NLS-1$ iprefs.put(SCALE_FACTOR, defaultScale); }
public static String getStringPrefValue(IProject project, String key) { if (isUsingProjectSettings(project)) { IScopeContext projectScope = new ProjectScope(project); IEclipsePreferences projectNode = projectScope .getNode(AspectJPlugin.PLUGIN_ID); String v = projectNode.get(key, ""); //$NON-NLS-1$ return v; } IPreferenceStore store = AspectJUIPlugin.getDefault() .getPreferenceStore(); return store.getString(key); }