Java Code Examples for org.eclipse.jface.preference.IPreferenceStore#setToDefault()

The following examples show how to use org.eclipse.jface.preference.IPreferenceStore#setToDefault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FindBugsPreferenceInitializer.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void restoreDefaults(IPreferenceStore store) {
    store.setToDefault(EXPORT_SORT_ORDER);
    store.setToDefault(DONT_REMIND_ABOUT_FULL_BUILD);
    store.setToDefault(DISABLED_CATEGORIES);
    store.setToDefault(RUN_ANALYSIS_AUTOMATICALLY);
    store.setToDefault(RUN_ANALYSIS_ON_FULL_BUILD);
    store.setToDefault(ASK_ABOUT_PERSPECTIVE_SWITCH);
    store.setToDefault(SWITCH_PERSPECTIVE_AFTER_ANALYSIS);
    store.setToDefault(RANK_OFCONCERN_MARKER_SEVERITY);
    store.setToDefault(RANK_TROUBLING_MARKER_SEVERITY);
    store.setToDefault(RANK_SCARY_MARKER_SEVERITY);
    store.setToDefault(RANK_SCARIEST_MARKER_SEVERITY);

    store.setToDefault(KEY_CACHE_CLASS_DATA);
    store.setToDefault(KEY_RUN_ANALYSIS_AS_EXTRA_JOB);
}
 
Example 2
Source File: UMLPreferencePage.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void performDefaults() {
    IPreferenceStore preferenceStore = getPreferenceStore();
    preferenceStore.setToDefault(SHOW_ASSOCIATION_END_OWNERSHIP);
    preferenceStore.setToDefault(SHOW_ASSOCIATION_END_MULTIPLICITY);
    preferenceStore.setToDefault(SHOW_ASSOCIATION_END_NAME);
    preferenceStore.setToDefault(SHOW_ASSOCIATION_NAME);
    preferenceStore.setToDefault(SHOW_FEATURE_VISIBILITY);
    preferenceStore.setToDefault(OMIT_CONSTRAINTS_FOR_NAVIGABILITY);
    preferenceStore.setToDefault(SHOW_PARAMETERS);
    preferenceStore.setToDefault(SHOW_PARAMETER_NAMES);
    preferenceStore.setToDefault(SHOW_PARAMETER_DIRECTION);
    preferenceStore.setToDefault(SHOW_CLASSIFIER_COMPARTMENT);
    preferenceStore.setToDefault(SHOW_CLASSIFIER_COMPARTMENT_FOR_PACKAGE);
    preferenceStore.setToDefault(SHOW_ELEMENTS_IN_OTHER_PACKAGES);
    super.performDefaults();
    loadPreferences();
}
 
Example 3
Source File: JavaFoldingStructureProviderRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Instantiates and returns the provider that is currently configured in the
 * preferences.
 *
 * @return the current provider according to the preferences
 */
public IJavaFoldingStructureProvider getCurrentFoldingProvider() {
	IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
	String currentProviderId= preferenceStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
	JavaFoldingStructureProviderDescriptor desc= getFoldingProviderDescriptor(currentProviderId);

	// Fallback to default if extension has gone
	if (desc == null) {
		String message= Messages.format(FoldingMessages.JavaFoldingStructureProviderRegistry_warning_providerNotFound_resetToDefault, currentProviderId);
		JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, null));

		String defaultProviderId= preferenceStore.getDefaultString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);

		desc= getFoldingProviderDescriptor(defaultProviderId);
		Assert.isNotNull(desc);

		preferenceStore.setToDefault(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
	}

	try {
		return desc.createProvider();
	} catch (CoreException e) {
		JavaPlugin.log(e);
		return null;
	}
}
 
Example 4
Source File: PyPreferenceInitializer.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static void initializeGeneralOptions(IPreferenceStore store) {
	String key;

	key = ExtraLanguagePreferenceAccess.getPrefixedKey(PyGeneratorPlugin.PREFERENCE_ID,
			ExtraLanguagePreferenceAccess.ENABLED_PROPERTY);
	store.setDefault(key, false);
	store.setToDefault(key);

	key = ExtraLanguagePreferenceAccess.getPrefixedKey(PyGeneratorPlugin.PREFERENCE_ID,
			PyPreferenceAccess.JYTHON_COMPLIANCE_PROPERTY);
	store.setDefault(key, true);
	store.setToDefault(key);
}
 
Example 5
Source File: GhidraProjectCreatorPreferences.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the last used Ghidra Gradle distribution that's defined in the preferences.
 * 
 * @param gradleDistribution The last used Ghidra Gradle distribution that's defined in the 
 *   preferences.  Could be null if the preference should be set to the default.
 */
public static void setGhidraLastGradleDistribution(GradleDistribution gradleDistribution) {
	IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
	if (gradleDistribution != null) {
		prefs.setValue(GHIDRA_LAST_GRADLE_DISTRIBUTION, gradleDistribution.toString());
	}
	else {
		prefs.setToDefault(GHIDRA_LAST_GRADLE_DISTRIBUTION);
	}
}
 
Example 6
Source File: PyPreferenceInitializer.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static void initializeFeatureNameConversion(IPreferenceStore store) {
	final IExtraLanguageConversionInitializer fnInitializer = PyInitializers.getFeatureNameConverterInitializer();
	final String preferenceValue = ExtraLanguagePreferenceAccess.toConverterPreferenceValue(fnInitializer);
	final String key = ExtraLanguagePreferenceAccess.getPrefixedKey(PyGeneratorPlugin.PREFERENCE_ID,
			ExtraLanguagePreferenceAccess.FEATURE_NAME_CONVERSION_PROPERTY);
	store.setDefault(key, preferenceValue);
	store.setToDefault(key);
}
 
Example 7
Source File: PyPreferenceInitializer.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static void initializeTypeConversion(IPreferenceStore store) {
	final IExtraLanguageConversionInitializer tcInitializer = PyInitializers.getTypeConverterInitializer();
	final String preferenceValue = ExtraLanguagePreferenceAccess.toConverterPreferenceValue(tcInitializer);
	final String key = ExtraLanguagePreferenceAccess.getPrefixedKey(PyGeneratorPlugin.PREFERENCE_ID,
			ExtraLanguagePreferenceAccess.TYPE_CONVERSION_PROPERTY);
	store.setDefault(key, preferenceValue);
	store.setToDefault(key);
}
 
Example 8
Source File: SARLSourceViewerPreferenceAccess.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Enable or disable the auto-formatting feature into the SARL editor.
 *
 * @param enable is {@code true} if it is enabled; {@code false} if it is disable; {@code null}
 *     to restore the default value.
 * @since 0.8
 * @see #getWritablePreferenceStore(Object)
 */
public void setAutoFormattingEnabled(Boolean enable) {
	final IPreferenceStore store = getWritablePreferenceStore(null);
	if (enable == null) {
		store.setToDefault(AUTOFORMATTING_PROPERTY);
	} else {
		store.setValue(AUTOFORMATTING_PROPERTY, enable.booleanValue());
	}
}
 
Example 9
Source File: SARLCodeminingPreferenceAccess.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Enable or disable the codemining feature into the SARL editor.
 *
 * @param enable is {@code true} if it is enabled; {@code false} if it is disable; {@code null}
 *     to restore the default value.
 * @since 0.8
 * @see #getWritablePreferenceStore(Object)
 */
public void setCodeminingEnabled(Boolean enable) {
	final IPreferenceStore store = getWritablePreferenceStore(null);
	if (enable == null) {
		store.setToDefault(CODEMINING_PROPERTY);
	} else {
		store.setValue(CODEMINING_PROPERTY, enable.booleanValue());
	}
}
 
Example 10
Source File: MembersOrderPreferenceCache.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int[] getVisibilityOffsets() {
	int[] offsets= new int[N_VISIBILITIES];
	IPreferenceStore store= fPreferenceStore;
	String key= PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER;
	boolean success= fillVisibilityOffsetsFromPreferenceString(store.getString(key), offsets);
	if (!success) {
		store.setToDefault(key);
		fillVisibilityOffsetsFromPreferenceString(store.getDefaultString(key), offsets);
	}
	return offsets;
}
 
Example 11
Source File: MembersOrderPreferenceCache.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int[] getCategoryOffsets() {
	int[] offsets= new int[N_CATEGORIES];
	IPreferenceStore store= fPreferenceStore;
	String key= PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER;
	boolean success= fillCategoryOffsetsFromPreferenceString(store.getString(key), offsets);
	if (!success) {
		store.setToDefault(key);
		fillCategoryOffsetsFromPreferenceString(store.getDefaultString(key), offsets);
	}
	return offsets;
}
 
Example 12
Source File: JavadocOptionsManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String initJavadocCommandDefault() {
	IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
	String cmd= store.getString(PreferenceConstants.JAVADOC_COMMAND);	// old location
	if (cmd != null && cmd.length() > 0) {
		store.setToDefault(PreferenceConstants.JAVADOC_COMMAND);
		return cmd;
	}

	File file= findJavaDocCommand();
	if (file != null) {
		return file.getPath();
	}
	return ""; //$NON-NLS-1$
}
 
Example 13
Source File: AbstractXtendContentAssistBugTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void tearDown() throws Exception {
	if (demandCreateProject != null)
		deleteProject(demandCreateProject);
	IPreferenceStore preferenceStore = preferenceStoreAccess.getWritablePreferenceStore(null);
	preferenceStore.setToDefault(XbaseBuilderPreferenceAccess.PREF_USE_COMPILER_SOURCE);
	preferenceStore.setToDefault(XbaseBuilderPreferenceAccess.PREF_JAVA_VERSION);
	super.tearDown();
}
 
Example 14
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Removes all consequent enumerated keys from given store staring with given prefix
 */
private static void resetStore(IPreferenceStore store, String prefix) {
    int start = 0;
    // 99 is paranoia.
    while (start < 99) {
        String name = prefix + start;
        if (store.contains(name)) {
            store.setToDefault(name);
        } else {
            break;
        }
        start++;
    }
}
 
Example 15
Source File: PreferenceStoreAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testDefault() {
	IPreferenceStore readable = getReadable();
	assertTrue(readable.getDefaultBoolean("someBoolean"));
	assertTrue(readable.getBoolean("someBoolean"));
	IPreferenceStore writable = getWritable();
	writable.setValue("someBoolean", "false");
	assertFalse(readable.getBoolean("someBoolean"));
	writable.setToDefault("someBoolean");
	assertTrue(readable.getBoolean("someBoolean"));
}
 
Example 16
Source File: SVNPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void performDefaults(IPreferenceStore store) {
	store.setToDefault(fKey);
	initializeValue(store);
}
 
Example 17
Source File: ProblemProfile.java    From cppcheclipse with Apache License 2.0 4 votes vote down vote up
public void loadDefaults(IPreferenceStore preferences) {
	preferences.setToDefault(IPreferenceConstants.P_PROBLEMS);
	for (Problem problem : problems.values()) {
		problem.setToDefault();
	}
}
 
Example 18
Source File: ColorPredicatePreferencePage.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * This method makes sure pairs of annotation types corresponding
 * to a given logical color are always bound to the same physical color.
 * When the color preference is changed for the key which is bound to the color
 * field editors for this page, this method sets the value for the partner key
 * to be the same.
 * See the documentation for this class to read more about this.
 */
public void propertyChange(PropertyChangeEvent event)
{
    if (event.getProperty().contains(COLOR_PREF_KEY_PREFIX) && event.getProperty().endsWith("A"))
    {
        /*
         * Setting preferences is a bit strange. The strangeness occurs
         * when calling IPreferenceStore.setValue(name,value) when the value
         * is equal to the default value for that name.
         * 
         * When the value is NOT equal to the default value and is not equal to the old
         * value, the preference store sets name to map to the new value and
         * informs all interested listeners of the change. I believe that
         * the eclipse text editors are among these interested listeners. This
         * is how they update the colors used for annotations.
         * 
         * However, when the value is equal to the default value for name, the preference
         * store removes the preference mapping for name (I assume the defaults are stored
         * somewhere else in the store) and informs all listeners that the preference
         * for name has been removed and does not inform them that it has been set to
         * the default value. The method comments for setValue() indicate that the correct
         * way to restore default preference values is to call store.setToDefault(). Thus,
         * it appears that we have to check whether the value we are setting is the default
         * value. If it is, we use setToDefault(). If it isn't, we use setValue().
         * 
         * Note that this strange behavior only seems to be for ScopedPreferenceStore, which
         * is the type of preference store used for this page.
         */
        int colorNum = getNumFromMainColorPref(event.getProperty());
        IPreferenceStore store = getPreferenceStore();
        String partnerPrefName = getPartnerColorPrefName(colorNum);
        /*
         * You might be wondering why in the following I did not use event.getNewValue() to
         * retrieve the new color value. It turns out that sometimes
         * that method returns an object of type RGB and sometimes a String.
         * For all I know, it could return another type entirely in certain
         * situations. Thus, it seems that the best thing is to get the value
         * directly from the preference store instead of from the event. The preference
         * store keeps the value of a color as a String, so the type returned is a string
         * and the type to set for the partner preference name is also a String.
         */
        String newValue = getPreferenceStore().getString(event.getProperty());
        if (store.getDefaultString(partnerPrefName).equals(newValue))
        {
            store.setToDefault(partnerPrefName);
        } else
        {
            getPreferenceStore().setValue(partnerPrefName, newValue);
        }
    }

    super.propertyChange(event);
}
 
Example 19
Source File: SARLSourceViewerPreferenceAccess.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public void setToDefault(Object context) {
	final IPreferenceStore store = getWritablePreferenceStore(context);
	store.setToDefault(AUTOFORMATTING_PROPERTY);
}
 
Example 20
Source File: SemanticHighlightings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * If the setting pointed to by <code>oldKey</code> is not the default
 * setting, store that setting under <code>newKey</code> and reset
 * <code>oldKey</code> to its default setting.
 * <p>
 * Returns <code>true</code> if any changes were made.
 * </p>
 *
 * @param store the preference store to read from and write to
 * @param oldKey the old preference key
 * @param newKey the new preference key
 * @return <code>true</code> if <code>store</code> was modified,
 *         <code>false</code> if not
 * @since 3.1
 */
private static boolean conditionalReset(IPreferenceStore store, String oldKey, String newKey) {
	if (!store.isDefault(oldKey)) {
		if (store.isDefault(newKey))
			store.setValue(newKey, store.getString(oldKey));
		store.setToDefault(oldKey);
		return true;
	}
	return false;
}