Search in sources :

Example 11 with BackingStoreException

use of org.osgi.service.prefs.BackingStoreException 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 12 with BackingStoreException

use of org.osgi.service.prefs.BackingStoreException 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 13 with BackingStoreException

use of org.osgi.service.prefs.BackingStoreException in project xtext-xtend by eclipse.

the class XtendProjectConfigurator method writePreferences.

private void writePreferences(OutputConfiguration configuration, IProject project) {
    ProjectScope projectPreferences = new ProjectScope(project);
    IEclipsePreferences languagePreferences = projectPreferences.getNode("org.eclipse.xtend.core.Xtend");
    languagePreferences.putBoolean(OptionsConfigurationBlock.isProjectSpecificPropertyKey(BuilderConfigurationBlock.PROPERTY_PREFIX), true);
    languagePreferences.putBoolean(getKey(configuration, INSTALL_DSL_AS_PRIMARY_SOURCE), configuration.isInstallDslAsPrimarySource());
    languagePreferences.putBoolean(getKey(configuration, HIDE_LOCAL_SYNTHETIC_VARIABLES), configuration.isHideSyntheticLocalVariables());
    languagePreferences.putBoolean(getKey(configuration, USE_OUTPUT_PER_SOURCE_FOLDER), true);
    for (SourceMapping sourceMapping : configuration.getSourceMappings()) {
        languagePreferences.put(getOutputForSourceFolderKey(configuration, sourceMapping.getSourceFolder()), Strings.nullToEmpty(sourceMapping.getOutputDirectory()));
    }
    try {
        languagePreferences.flush();
    } catch (BackingStoreException e) {
        throw new RuntimeIOException(e);
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) RuntimeIOException(org.eclipse.xtext.util.RuntimeIOException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException) SourceMapping(org.eclipse.xtext.generator.OutputConfiguration.SourceMapping)

Example 14 with BackingStoreException

use of org.osgi.service.prefs.BackingStoreException in project yamcs-studio by yamcs.

the class PreferencesHelper method putBoolean.

private static void putBoolean(String name, boolean value) {
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(OPIBuilderPlugin.PLUGIN_ID);
    prefs.putBoolean(name, value);
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        OPIBuilderPlugin.getLogger().log(Level.SEVERE, "Failed to store preferences.", e);
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 15 with BackingStoreException

use of org.osgi.service.prefs.BackingStoreException in project flux by eclipse.

the class Activator method addConnectedProjectPreference.

private void addConnectedProjectPreference(String projectName) {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(PLUGIN_ID);
    String currentPreferences = preferences.get(CONNECTED_PROJECTS_ID, "");
    String[] projects = StringUtils.split(currentPreferences, ";");
    for (String existingProjectName : projects) {
        if (existingProjectName.equals(projectName)) {
            return;
        }
    }
    currentPreferences += ";" + projectName;
    preferences.put(CONNECTED_PROJECTS_ID, currentPreferences);
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
    // We really don't care that much..
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Aggregations

BackingStoreException (org.osgi.service.prefs.BackingStoreException)27 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)13 Preferences (org.osgi.service.prefs.Preferences)8 IOException (java.io.IOException)6 ProjectScope (org.eclipse.core.resources.ProjectScope)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)2 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 JavaModelManager.getJavaModelManager (org.eclipse.jdt.internal.core.JavaModelManager.getJavaModelManager)2 Inject (com.google.inject.Inject)1 ApplicationInsightsResource (com.microsoft.applicationinsights.preference.ApplicationInsightsResource)1 FileNotFoundException (java.io.FileNotFoundException)1