Search in sources :

Example 6 with Preferences

use of org.osgi.service.prefs.Preferences in project azure-tools-for-java by Microsoft.

the class PreferenceUtil method getPreferenceKeys.

public static String[] getPreferenceKeys() {
    String[] keys = null;
    try {
        Preferences prefs = PluginUtil.getPrefs(com.microsoft.azuretools.core.utils.Messages.prefFileName);
        keys = prefs.keys();
    } catch (BackingStoreException e) {
        Activator.getDefault().log("Error", e);
    }
    return keys;
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 7 with Preferences

use of org.osgi.service.prefs.Preferences in project azure-tools-for-java by Microsoft.

the class PreferenceUtil method savePreferences.

public static void savePreferences(String name, String[] values) {
    Preferences prefs = PluginUtil.getPrefs(com.microsoft.azuretools.core.utils.Messages.prefFileName);
    prefs.put(name, convertToPreference(values));
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        Activator.getDefault().log("Error", e);
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 8 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 9 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 10 with Preferences

use of org.osgi.service.prefs.Preferences in project jop by jop-devel.

the class JOPUIUtils method getProjectSetting.

public static String getProjectSetting(ILaunchConfiguration configuration, String key, String def) {
    String projectName = getProjectName(configuration);
    if (projectName == null) {
        return def;
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    IScopeContext scopeContext = new ProjectScope(project);
    Preferences projectPrefs = scopeContext.getNode(IJOPUIConstants.PLUGIN_ID);
    return projectPrefs.get(key, def);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) Preferences(org.osgi.service.prefs.Preferences) IProject(org.eclipse.core.resources.IProject)

Aggregations

Preferences (org.osgi.service.prefs.Preferences)15 BackingStoreException (org.osgi.service.prefs.BackingStoreException)8 ProjectScope (org.eclipse.core.resources.ProjectScope)5 IProject (org.eclipse.core.resources.IProject)4 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)4 ApplicationInsightsResource (com.microsoft.applicationinsights.preference.ApplicationInsightsResource)2 IOException (java.io.IOException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInput (java.io.ObjectInput)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutput (java.io.ObjectOutput)1 ObjectOutputStream (java.io.ObjectOutputStream)1 IPath (org.eclipse.core.runtime.IPath)1 PersistenceException (org.talend.commons.exception.PersistenceException)1