Search in sources :

Example 6 with ConfigurationScope

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

the class XtendPreferenceStoreAccess method getContextPreferenceStore.

@SuppressWarnings("all")
@Override
public IPreferenceStore getContextPreferenceStore(Object context) {
    IProject project = getProject(context);
    if (project == null)
        return getPreferenceStore();
    IPreferenceStore store = super.getContextPreferenceStore(context);
    ProjectScope projectScope = new ProjectScope(project);
    FixedScopedPreferenceStore jdtStore = new FixedScopedPreferenceStore(projectScope, JavaCore.PLUGIN_ID);
    jdtStore.setSearchContexts(new IScopeContext[] { projectScope, new InstanceScope(), new ConfigurationScope() });
    return new ChainedPreferenceStore(new IPreferenceStore[] { store, jdtStore, PreferenceConstants.getPreferenceStore() });
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FixedScopedPreferenceStore(org.eclipse.xtext.ui.editor.preferences.FixedScopedPreferenceStore) IProject(org.eclipse.core.resources.IProject) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 7 with ConfigurationScope

use of org.eclipse.core.runtime.preferences.ConfigurationScope in project webtools.sourceediting by eclipse.

the class PrefUtil method getProperty.

private static String getProperty(String property) {
    // Importance order is:
    // default-default < instanceScope < configurationScope < systemProperty
    // < envVar
    String value = null;
    if (value == null) {
        value = System.getenv(property);
    }
    if (value == null) {
        value = System.getProperty(property);
    }
    if (value == null) {
        IPreferencesService preferencesService = Platform.getPreferencesService();
        String key = property;
        if (property != null && property.startsWith(SSECorePlugin.ID)) {
            // +1, include the "."
            key = property.substring(SSECorePlugin.ID.length() + 1, property.length());
        }
        InstanceScope instance = new InstanceScope();
        ConfigurationScope config = new ConfigurationScope();
        Preferences instanceNode = instance.getNode(SSECorePlugin.ID);
        Preferences configNode = config.getNode(SSECorePlugin.ID);
        value = preferencesService.get(key, getDefault(property), new Preferences[] { configNode, instanceNode });
    }
    return value;
}
Also used : InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Preferences(org.osgi.service.prefs.Preferences) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 8 with ConfigurationScope

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

the class JavaEncryption method internalInitialize.

protected void internalInitialize() throws StorageException {
    if (cipherAlgorithm != null && keyFactoryAlgorithm != null) {
        if (roundtrip(cipherAlgorithm, keyFactoryAlgorithm))
            return;
        // this is a bad situation - JVM cipher no longer available. Both log and throw an exception
        String msg = NLS.bind(SecAuthMessages.noAlgorithm, cipherAlgorithm);
        StorageException e = new StorageException(StorageException.INTERNAL_ERROR, msg);
        AuthPlugin.getDefault().logError(msg, e);
        throw e;
    }
    if (cipherAlgorithm == null || keyFactoryAlgorithm == null) {
        IEclipsePreferences eclipseNode = new ConfigurationScope().getNode(AuthPlugin.PI_AUTH);
        cipherAlgorithm = eclipseNode.get(IStorageConstants.CIPHER_KEY, IStorageConstants.DEFAULT_CIPHER);
        keyFactoryAlgorithm = eclipseNode.get(IStorageConstants.KEY_FACTORY_KEY, IStorageConstants.DEFAULT_KEY_FACTORY);
    }
    if (roundtrip(cipherAlgorithm, keyFactoryAlgorithm))
        return;
    String unavailableCipher = cipherAlgorithm;
    detect();
    if (availableCiphers.size() == 0)
        throw new StorageException(StorageException.INTERNAL_ERROR, SecAuthMessages.noAlgorithms);
    // use first available
    cipherAlgorithm = (String) availableCiphers.keySet().iterator().next();
    keyFactoryAlgorithm = (String) availableCiphers.get(cipherAlgorithm);
    String msg = NLS.bind(SecAuthMessages.usingAlgorithm, unavailableCipher, cipherAlgorithm);
    AuthPlugin.getDefault().logMessage(msg);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) StorageException(org.eclipse.equinox.security.storage.StorageException) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 9 with ConfigurationScope

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

the class XtendPreferenceStoreAccess method getPreferenceStore.

@SuppressWarnings("all")
@Override
public IPreferenceStore getPreferenceStore() {
    IPreferenceStore store = super.getPreferenceStore();
    FixedScopedPreferenceStore jdtStore = new FixedScopedPreferenceStore(new InstanceScope(), JavaCore.PLUGIN_ID);
    jdtStore.setSearchContexts(new IScopeContext[] { new InstanceScope(), new ConfigurationScope() });
    return new ChainedPreferenceStore(new IPreferenceStore[] { store, jdtStore, PreferenceConstants.getPreferenceStore() });
}
Also used : InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FixedScopedPreferenceStore(org.eclipse.xtext.ui.editor.preferences.FixedScopedPreferenceStore) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 10 with ConfigurationScope

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

the class PreferenceStoreAccessTest method testScopeWithAnotherInstance.

@SuppressWarnings("deprecation")
@Test
public void testScopeWithAnotherInstance() {
    // ensure initialization
    getWritable();
    ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(new ConfigurationScope(), LANGUAGE_ID);
    assertTrue(scopedPreferenceStore.getBoolean("someBoolean"));
}
Also used : 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