Search in sources :

Example 86 with IEclipsePreferences

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

the class NavigatorActivationService method persistExtensionActivations.

/**
 * Save the activation state for the given viewer.
 */
public void persistExtensionActivations() {
    IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot();
    synchronized (activatedExtensionsMap) {
        Iterator activatedExtensionsIterator = activatedExtensionsMap.keySet().iterator();
        /* ensure that the preference will be non-empty */
        StringBuffer preferenceValue = new StringBuffer();
        String navigatorExtensionId = null;
        boolean isActive = false;
        while (activatedExtensionsIterator.hasNext()) {
            navigatorExtensionId = (String) activatedExtensionsIterator.next();
            isActive = isNavigatorExtensionActive(navigatorExtensionId);
            preferenceValue.append(navigatorExtensionId).append(EQUALS).append(isActive ? Boolean.TRUE : Boolean.FALSE).append(DELIM);
        }
        prefs.put(getPreferenceKey(), preferenceValue.toString());
    }
    NavigatorContentService.flushPreferences(prefs);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Iterator(java.util.Iterator)

Example 87 with IEclipsePreferences

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

the class NavigatorActivationService method revertExtensionActivations.

private void revertExtensionActivations() {
    IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot();
    String activatedExtensionsString = prefs.get(getPreferenceKey(), null);
    if (activatedExtensionsString != null && activatedExtensionsString.length() > 0) {
        String[] contentExtensionIds = activatedExtensionsString.split(DELIM);
        String id = null;
        String booleanString = null;
        int indx = 0;
        for (int i = 0; i < contentExtensionIds.length; i++) {
            if ((indx = contentExtensionIds[i].indexOf(EQUALS)) > -1) {
                // up to but not including the equals
                id = contentExtensionIds[i].substring(0, indx);
                booleanString = contentExtensionIds[i].substring(indx + 1, contentExtensionIds[i].length());
                activatedExtensionsMap.put(id, Boolean.valueOf(booleanString));
            } else {
                // IS THIS THE RIGHT WAY TO HANDLE THIS CASE?
                NavigatorContentDescriptor descriptor = CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptor(contentExtensionIds[i]);
                if (descriptor != null)
                    activatedExtensionsMap.put(id, Boolean.valueOf(descriptor.isActiveByDefault()));
            }
        }
    } else {
        /*
			 * We add the default activation of every known extension, even
			 * though some may not be bound to the associated content service;
			 * this is because they could be bound at a later time through the
			 * programmatic binding mechanism in INavigatorContentService.
			 */
        INavigatorContentDescriptor[] contentDescriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
        for (int i = 0; i < contentDescriptors.length; i++) {
            if (contentDescriptors[i].isActiveByDefault()) {
                activatedExtensionsMap.put(contentDescriptors[i].getId(), Boolean.TRUE);
            }
        }
    }
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor)

Example 88 with IEclipsePreferences

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

the class NavigatorFilterService method persistFilterActivationState.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.navigator.INavigatorFilterService#persistFilterActivationState()
	 */
public void persistFilterActivationState() {
    synchronized (activeFilters) {
        CommonFilterDescriptorManager dm = CommonFilterDescriptorManager.getInstance();
        /*
			 * by creating a StringBuffer with DELIM, we ensure the string is
			 * not empty when persisted.
			 */
        StringBuffer activatedFiltersPreferenceValue = new StringBuffer(DELIM);
        for (Iterator activeItr = activeFilters.iterator(); activeItr.hasNext(); ) {
            String id = activeItr.next().toString();
            if (!dm.getFilterById(id).isVisibleInUi())
                continue;
            activatedFiltersPreferenceValue.append(id).append(DELIM);
        }
        IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot();
        prefs.put(getFilterActivationPreferenceKey(), activatedFiltersPreferenceValue.toString());
        NavigatorContentService.flushPreferences(prefs);
    }
}
Also used : CommonFilterDescriptorManager(org.eclipse.ui.internal.navigator.filters.CommonFilterDescriptorManager) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Iterator(java.util.Iterator)

Example 89 with IEclipsePreferences

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

the class PasswordProviderSelector method getDisabledModules.

protected HashSet getDisabledModules() {
    IEclipsePreferences node = new ConfigurationScope().getNode(AuthPlugin.PI_AUTH);
    String tmp = node.get(IStorageConstants.DISABLED_PROVIDERS_KEY, null);
    if (tmp == null || tmp.length() == 0)
        return null;
    HashSet disabledModules = new HashSet();
    // $NON-NLS-1$
    String[] disabledProviders = tmp.split(",");
    for (int i = 0; i < disabledProviders.length; i++) {
        disabledModules.add(disabledProviders[i]);
    }
    return disabledModules;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 90 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project eclipse-integration-commons by spring-projects.

the class CorePlugin method getUUID.

public static synchronized String getUUID() {
    ServiceReference ref = getDefault().getBundle().getBundleContext().getServiceReference(IPreferencesService.class.getName());
    IPreferencesService prefService = (IPreferencesService) getDefault().getBundle().getBundleContext().getService(ref);
    try {
        IEclipsePreferences prefs = (IEclipsePreferences) prefService.getRootNode().node(InstanceScope.SCOPE);
        Preferences p = prefs.node(PLUGIN_ID);
        if (StringUtils.isEmpty(p.get(UUID_PROPERTY_KEY, ""))) {
            p.put(UUID_PROPERTY_KEY, UUID.randomUUID().toString());
        }
        return p.get(UUID_PROPERTY_KEY, "");
    } finally {
        if (prefService != null) {
            getDefault().getBundle().getBundleContext().ungetService(ref);
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Preferences(org.osgi.service.prefs.Preferences) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)339 BackingStoreException (org.osgi.service.prefs.BackingStoreException)81 Test (org.junit.Test)37 ProjectScope (org.eclipse.core.resources.ProjectScope)24 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)24 CoreException (org.eclipse.core.runtime.CoreException)22 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)17 IStatus (org.eclipse.core.runtime.IStatus)16 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)15 IOException (java.io.IOException)13 IProject (org.eclipse.core.resources.IProject)13 Status (org.eclipse.core.runtime.Status)13 ArrayList (java.util.ArrayList)11 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)11 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)10 File (java.io.File)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 Job (org.eclipse.core.runtime.jobs.Job)8 Preferences (org.osgi.service.prefs.Preferences)8