Search in sources :

Example 71 with Preferences

use of org.osgi.service.prefs.Preferences in project erlide_eclipse by erlang.

the class ErlidePreferencePage method performOk.

@Override
public boolean performOk() {
    putPreferences();
    try {
        final Preferences node = ErlideUIPlugin.getPrefsNode();
        node.flush();
    } catch (final BackingStoreException e) {
        ErlLogger.warn(e);
    }
    return true;
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 72 with Preferences

use of org.osgi.service.prefs.Preferences in project erlide_eclipse by erlang.

the class ErlidePreferencePage method getPreferences.

protected static List<String> getPreferences(final String dialogKey, final String[] keys, final String[] defaults) {
    final List<String> l = new ArrayList<>(keys.length);
    final Preferences node = ErlideUIPlugin.getPrefsNode();
    for (int i = 0; i < keys.length; ++i) {
        final String s = // $NON-NLS-1$
        node.get(// $NON-NLS-1$
        dialogKey + "/" + keys[i], defaults[i]);
        l.add(s);
    }
    return l;
}
Also used : ArrayList(java.util.ArrayList) Preferences(org.osgi.service.prefs.Preferences)

Example 73 with Preferences

use of org.osgi.service.prefs.Preferences in project erlide_eclipse by erlang.

the class ErlidePreferencePage method putIntPreferences.

protected void putIntPreferences(final String[] keys, final List<Text> textFields) {
    final Preferences node = ErlideUIPlugin.getPrefsNode();
    for (int i = 0; i < keys.length; ++i) {
        int n;
        n = Integer.parseInt(textFields.get(i).getText());
        // $NON-NLS-1$
        node.putInt(getDialogPreferenceKey() + "/" + keys[i], n);
    }
}
Also used : Preferences(org.osgi.service.prefs.Preferences)

Example 74 with Preferences

use of org.osgi.service.prefs.Preferences in project tdi-studio-se by Talend.

the class Log4jPrefsSettingManager method createTalendLog4jPrefs.

public Preferences createTalendLog4jPrefs(String prefNode, String value) {
    Preferences log4jSettings = null;
    try {
        log4jSettings = getLog4jPreferences(prefNode, true);
        if (log4jSettings != null) {
            log4jSettings.put(prefNode, value);
        }
        // create log4j prefs file
        log4jSettings.flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
    return log4jSettings;
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 75 with Preferences

use of org.osgi.service.prefs.Preferences in project tdi-studio-se by Talend.

the class Log4jPrefsSettingManager method getLog4jPreferences.

public Preferences getLog4jPreferences(String log4jPrefsNode, boolean create) {
    try {
        IProject project = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
        if (create) {
            return new ProjectScope(project).getNode(Log4jPrefsConstants.LOG4J_RESOURCES).node(log4jPrefsNode);
        }
        Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
        if (!node.nodeExists(project.getName())) {
            return null;
        }
        node = node.node(project.getName());
        if (!node.nodeExists(Log4jPrefsConstants.LOG4J_RESOURCES)) {
            return null;
        }
        node = node.node(Log4jPrefsConstants.LOG4J_RESOURCES);
        if (!node.nodeExists(log4jPrefsNode)) {
            return null;
        }
        return node.node(log4jPrefsNode);
    } catch (BackingStoreException e) {
        ExceptionHandler.process(e);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException) PersistenceException(org.talend.commons.exception.PersistenceException) Preferences(org.osgi.service.prefs.Preferences) IProject(org.eclipse.core.resources.IProject)

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