Search in sources :

Example 11 with ConfigurationScope

use of org.eclipse.core.runtime.preferences.ConfigurationScope in project xtext-eclipse by eclipse.

the class PreferenceStoreAccessTest method testChainedPreferenceStore.

@SuppressWarnings("deprecation")
@Test
public void testChainedPreferenceStore() {
    ScopedPreferenceStore configurationStore = new ScopedPreferenceStore(new ConfigurationScope(), LANGUAGE_ID);
    configurationStore.setValue("someInt", 12);
    configurationStore.setValue("anotherInt", 12);
    configurationStore.setDefault("thirdInt", 12);
    ScopedPreferenceStore instanceStore = new ScopedPreferenceStore(new InstanceScope(), LANGUAGE_ID);
    instanceStore.setValue("someInt", 13);
    instanceStore.setDefault("anotherInt", 13);
    ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { instanceStore, configurationStore });
    assertEquals(13, chainedStore.getInt("someInt"));
    assertEquals(13, chainedStore.getInt("anotherInt"));
    assertEquals(12, chainedStore.getInt("thirdInt"));
}
Also used : InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope) Test(org.junit.Test)

Aggregations

ConfigurationScope (org.eclipse.core.runtime.preferences.ConfigurationScope)11 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)7 ProjectScope (org.eclipse.core.resources.ProjectScope)3 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)3 ScopedPreferenceStore (org.eclipse.ui.preferences.ScopedPreferenceStore)3 ChainedPreferenceStore (org.eclipse.ui.texteditor.ChainedPreferenceStore)3 Test (org.junit.Test)3 IProject (org.eclipse.core.resources.IProject)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 FixedScopedPreferenceStore (org.eclipse.xtext.ui.editor.preferences.FixedScopedPreferenceStore)2 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)1 StorageException (org.eclipse.equinox.security.storage.StorageException)1 Preferences (org.osgi.service.prefs.Preferences)1