Search in sources :

Example 1 with Preferences

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

the class Log4jPrefsSettingManager method saveLog4jNodeIntoPref.

public void saveLog4jNodeIntoPref(final String prefNode, final String value) {
    try {
        Preferences log4jSettings = null;
        if (!isLog4jPrefsExist()) {
            // if not exist,create it
            log4jSettings = getLog4jPreferences(prefNode, true);
        } else {
            log4jSettings = getLog4jPreferences(prefNode, false);
        }
        if (log4jSettings != null) {
            log4jSettings.put(prefNode, value);
            // save log4j activate to prefs
            log4jSettings.flush();
        }
    } catch (BackingStoreException e) {
        ExceptionHandler.process(e);
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 2 with Preferences

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

the class Log4jPrefsSettingManager method getValueOfPreNode.

public String getValueOfPreNode(String nodeName) {
    Preferences nodePre = null;
    nodePre = getLog4jPreferences(nodeName, false);
    if (nodePre == null) {
        return Boolean.FALSE.toString();
    }
    return nodePre.get(nodeName, null);
}
Also used : Preferences(org.osgi.service.prefs.Preferences)

Example 3 with Preferences

use of org.osgi.service.prefs.Preferences in project felix by apache.

the class PreferencesImpl method nodeExists.

/**
 * We do not synchronize this method to avoid dead locks as this
 * method might call another preferences object in the hierarchy.
 * @see org.osgi.service.prefs.Preferences#nodeExists(java.lang.String)
 */
public boolean nodeExists(String pathName) throws BackingStoreException {
    if (pathName == null) {
        throw new NullPointerException("Path must not be null.");
    }
    if (pathName.length() == 0) {
        return this.valid;
    }
    PreferencesImpl node = this;
    synchronized (this) {
        this.checkValidity();
        if (pathName.startsWith("/") && this.parent != null) {
            node = this.getRoot();
        }
        if (pathName.startsWith("/")) {
            pathName = pathName.substring(1);
        }
    }
    final Preferences searchNode = node.getNode(pathName, false, false);
    return searchNode != null;
}
Also used : Preferences(org.osgi.service.prefs.Preferences)

Example 4 with Preferences

use of org.osgi.service.prefs.Preferences in project felix by apache.

the class PreferencesImplTest method testAddRemoveAdd.

@Test
public void testAddRemoveAdd() throws Exception {
    final BackingStore store = new DataFileBackingStoreImpl(null, Files.createTempDirectory("prefs").toFile());
    final PreferencesImpl prefs = new PreferencesImpl(new PreferencesDescription(5L, null), new BackingStoreManager() {

        public BackingStore getStore() throws BackingStoreException {
            return store;
        }
    });
    Preferences firstA = prefs.node("A");
    firstA.node("1");
    firstA.node("2");
    assertEquals(1, prefs.childrenNames().length);
    assertEquals(2, firstA.childrenNames().length);
    firstA.removeNode();
    prefs.flush();
    assertEquals(0, prefs.childrenNames().length);
    firstA = prefs.node("A");
    assertEquals(1, prefs.childrenNames().length);
    assertEquals(0, firstA.childrenNames().length);
    firstA.node("1");
    firstA.node("2");
    assertEquals(2, firstA.childrenNames().length);
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences) DataFileBackingStoreImpl(org.apache.felix.prefs.impl.DataFileBackingStoreImpl) Test(org.junit.Test)

Example 5 with Preferences

use of org.osgi.service.prefs.Preferences in project knime-core by knime.

the class KNIMEApplicationWorkbenchAdvisor method changeDefaultPreferences.

@SuppressWarnings("restriction")
private void changeDefaultPreferences() {
    // enable automatic check for updates every day at 11:00
    Preferences node = DefaultScope.INSTANCE.getNode(AutomaticUpdatePlugin.PLUGIN_ID);
    node.putBoolean(org.eclipse.equinox.internal.p2.ui.sdk.scheduler.PreferenceConstants.PREF_AUTO_UPDATE_ENABLED, true);
    node.put(org.eclipse.equinox.internal.p2.ui.sdk.scheduler.PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE, org.eclipse.equinox.internal.p2.ui.sdk.scheduler.PreferenceConstants.PREF_UPDATE_ON_SCHEDULE);
    node.put(AutomaticUpdateScheduler.P_DAY, AutomaticUpdateMessages.SchedulerStartup_day);
    node.put(AutomaticUpdateScheduler.P_HOUR, AutomaticUpdateMessages.SchedulerStartup_11AM);
}
Also used : Preferences(org.osgi.service.prefs.Preferences)

Aggregations

Preferences (org.osgi.service.prefs.Preferences)157 BackingStoreException (org.osgi.service.prefs.BackingStoreException)81 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