Search in sources :

Example 16 with Preferences

use of org.osgi.service.prefs.Preferences in project n4js by eclipse.

the class ProjectNameFilterAwareWorkingSetManager method restoreState.

@Override
public IStatus restoreState(final IProgressMonitor monitor) {
    final IStatus superRestoreResult = super.restoreState(monitor);
    if (superRestoreResult.isOK()) {
        final Preferences node = getPreferences();
        final String orderedFilters = node.get(ORDERED_FILTERS_KEY, EMPTY_STRING);
        if (!Strings.isNullOrEmpty(orderedFilters)) {
            orderedWorkingSetFilters.clear();
            orderedWorkingSetFilters.addAll(Arrays.asList(orderedFilters.split(SEPARATOR)));
        }
        discardWorkingSetCaches();
        return statusHelper.OK();
    }
    return superRestoreResult;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Preferences(org.osgi.service.prefs.Preferences)

Example 17 with Preferences

use of org.osgi.service.prefs.Preferences in project n4js by eclipse.

the class ProjectNameFilterAwareWorkingSetManager method saveState.

@Override
public IStatus saveState(final IProgressMonitor monitor) {
    final IStatus superSaveResult = super.saveState(monitor);
    if (superSaveResult.isOK()) {
        final Preferences node = getPreferences();
        node.put(ORDERED_FILTERS_KEY, Joiner.on(SEPARATOR).join(orderedWorkingSetFilters));
        try {
            node.flush();
        } catch (final BackingStoreException e) {
            final String message = "Error occurred while saving state to preference store.";
            LOGGER.error(message, e);
            return statusHelper.createError(message, e);
        }
        return statusHelper.OK();
    }
    return superSaveResult;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 18 with Preferences

use of org.osgi.service.prefs.Preferences in project n4js by eclipse.

the class OsgiBinariesPreferenceStore method init.

@Override
protected Map<Binary, URI> init() {
    final Map<Binary, URI> initState = super.init();
    final Preferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
    for (final Binary binary : binariesProvider.getRegisteredBinaries()) {
        recursivePreferencesRead(initState, node, binary);
    }
    return initState;
}
Also used : Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) URI(java.net.URI)

Example 19 with Preferences

use of org.osgi.service.prefs.Preferences in project n4js by eclipse.

the class OsgiExternalLibraryPreferenceStore method doLoad.

@Override
protected ExternalLibraryPreferenceModel doLoad() {
    final Preferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
    final String jsonString = node.get(CONFIGURATION_KEY, "");
    if (isNullOrEmpty(jsonString)) {
        return ExternalLibraryPreferenceModel.createDefaultForN4Product();
    }
    return ExternalLibraryPreferenceModel.createFromJson(jsonString);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Preferences(org.osgi.service.prefs.Preferences)

Example 20 with Preferences

use of org.osgi.service.prefs.Preferences in project ecf by eclipse.

the class AccountStart method loadConnectionDetailsFromPreferenceStore.

public void loadConnectionDetailsFromPreferenceStore() {
    try {
        Preferences preferences = new InstanceScope().getNode(ClientPlugin.PLUGIN_ID);
        Preferences connections = preferences.node(SAVED);
        String[] targets = connections.childrenNames();
        for (int i = 0; i < targets.length; i++) {
            String target = targets[i];
            Preferences node = connections.node(target);
            if (node != null) {
                addConnectionDetails(new ConnectionDetails(node.get(ConnectionDetails.CONTAINER_TYPE, ""), // $NON-NLS-1$
                node.get(ConnectionDetails.TARGET_URI, ""), // $NON-NLS-1$
                node.get(ConnectionDetails.NICKNAME, ""), // $NON-NLS-1$
                node.get(ConnectionDetails.PASSWORD, // $NON-NLS-1$
                "")));
            }
        }
    } catch (BackingStoreException e) {
        ClientPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ClientPlugin.PLUGIN_ID, BACKING_STORE_LOAD_ERROR, Messages.AccountStart_EXCEPTION_LOADING_CONNECTION_DETAILS, e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Aggregations

Preferences (org.osgi.service.prefs.Preferences)157 BackingStoreException (org.osgi.service.prefs.BackingStoreException)82 EclipsePreferences (org.eclipse.core.internal.preferences.EclipsePreferences)41 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)37 ProjectScope (org.eclipse.core.resources.ProjectScope)18 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)14 IStatus (org.eclipse.core.runtime.IStatus)10 IOException (java.io.IOException)7 Test (org.junit.Test)7 IProject (org.eclipse.core.resources.IProject)6 Status (org.eclipse.core.runtime.Status)6 PerformanceTestRunner (org.eclipse.core.tests.harness.PerformanceTestRunner)6 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)5 ISecurePreferences (org.eclipse.equinox.security.storage.ISecurePreferences)5 Field (java.lang.reflect.Field)4 ArrayList (java.util.ArrayList)4 ExportedPreferences (org.eclipse.core.internal.preferences.ExportedPreferences)4 IExportedPreferences (org.eclipse.core.runtime.preferences.IExportedPreferences)4 ContentTypeEncodingPreferences (org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences)4 IEncodedDocument (org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)4