Search in sources :

Example 91 with Preferences

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

the class XSLValidationPreferencePage method initializeValues.

protected void initializeValues() {
    Preferences prefs = getModelPreferences();
    int maxErrors = prefs.getInt(ValidationPreferences.MAX_ERRORS, 100);
    maxErrorsText.setText(String.valueOf(maxErrors));
    for (Map.Entry<String, Combo> entry : combos.entrySet()) {
        int val = prefs.getInt(entry.getKey(), IMarker.SEVERITY_WARNING);
        if (val < 0) {
            val = IMarker.SEVERITY_WARNING;
        }
        entry.getValue().select(ERROR_MAP.get(val));
    }
}
Also used : Combo(org.eclipse.swt.widgets.Combo) ValidationPreferences(org.eclipse.wst.xsl.core.ValidationPreferences) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 92 with Preferences

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

the class ProfilerPreferences method setServerProfilerId.

/**
 * Sets the profiler to use when profiling on server
 * @param profilerId the id of the server profiler
 */
public void setServerProfilerId(String profilerId) {
    Preferences node = new InstanceScope().getNode(PREF_PROFILER_QUALIFIER);
    node.put(PREF_SELECTED_PROFILER, profilerId);
    try {
        node.flush();
    } catch (BackingStoreException e) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Could not save server profiler preference", e);
        }
    }
}
Also used : InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 93 with Preferences

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

the class ManualAssociationAwareWorkingSetManager method saveState.

@Override
public IStatus saveState(final IProgressMonitor monitor) {
    final IStatus superSaveResult = super.saveState(monitor);
    if (superSaveResult.isOK()) {
        final Preferences node = getPreferences();
        try {
            final String associationString = mapper.writeValueAsString(projectAssociations);
            node.put(ORDERED_ASSOCIATIONS_KEY, associationString);
            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);
        } catch (final IOException e) {
            final String message = "Error occurred while serializing project associations.";
            LOGGER.error(message, e);
            return statusHelper.createError(message, e);
        }
        resetEclipseWorkingSetsBaseOnCurrentState();
        return statusHelper.OK();
    }
    return superSaveResult;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) BackingStoreException(org.osgi.service.prefs.BackingStoreException) IOException(java.io.IOException) Preferences(org.osgi.service.prefs.Preferences)

Example 94 with Preferences

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

the class WorkingSetManagerBrokerImpl method restoreState.

private IStatus restoreState() {
    final Preferences node = getPreferences();
    // Top level element.
    workingSetTopLevel.set(node.getBoolean(IS_WORKINGSET_TOP_LEVEL_KEY, false));
    // Active working set manager.
    final String value = node.get(ACTIVE_MANAGER_KEY, "");
    WorkingSetManager workingSetManager = contributions.get().get(value);
    if (workingSetManager == null) {
        if (!contributions.get().isEmpty()) {
            workingSetManager = contributions.get().values().iterator().next();
        }
    }
    if (workingSetManager != null) {
        setActiveManager(workingSetManager);
    }
    return Status.OK_STATUS;
}
Also used : Preferences(org.osgi.service.prefs.Preferences)

Example 95 with Preferences

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

the class WorkingSetManagerImpl method saveState.

@Override
public IStatus saveState(final IProgressMonitor monitor) {
    final Preferences node = getPreferences();
    // Save ordered labels.
    node.put(ORDERED_IDS_KEY, Joiner.on(SEPARATOR).join(orderedWorkingSetIds));
    // Save visible labels.
    node.put(VISIBLE_IDS_KEY, Joiner.on(SEPARATOR).join(visibleWorkingSetIds));
    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();
}
Also used : 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