Search in sources :

Example 26 with BackingStoreException

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

the class JavaProjectPreferencesInitializer method addOwnFileExtensionsToJavaBuildResourceCopyFilter.

@SuppressWarnings("restriction")
@Inject
public void addOwnFileExtensionsToJavaBuildResourceCopyFilter(FileExtensionProvider extensionProvider) {
    @SuppressWarnings("deprecation") IScopeContext defaultScope = new DefaultScope();
    // The class org.eclipse.jdt.internal.launching.LaunchingPreferenceInitializer has this very nasty habit
    // of replacing all RESOURCE_COPY_FILTERs with its own filter. Calling getNode(LaunchingPlugin.ID_PLUGIN)
    // causes LaunchingPreferenceInitializer to be executed that afterwards we can append our filters safely.
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395366
    defaultScope.getNode(org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN);
    IEclipsePreferences dnode = defaultScope.getNode(JavaCore.PLUGIN_ID);
    if (dnode == null)
        return;
    Set<String> filters = Sets.newLinkedHashSet();
    for (String filter : dnode.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "").split(",")) {
        String trimmed = filter.trim();
        if (!"".equals(trimmed))
            filters.add(trimmed);
    }
    for (String ext : extensionProvider.getFileExtensions()) filters.add("*." + ext);
    dnode.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(", ").join(filters));
    try {
        dnode.flush();
    } catch (BackingStoreException e) {
        log.error("Error saving preferences", e);
    }
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) Inject(com.google.inject.Inject)

Example 27 with BackingStoreException

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

the class STCSourceNotFoundEditor method addSourceMappingToCommon.

private void addSourceMappingToCommon(IPath missingPath, IPath newSourcePath) throws CoreException {
    AbstractSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
    addSourceMappingToDirector(missingPath, newSourcePath, director);
    try {
        InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).flush();
    } catch (BackingStoreException e) {
        IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.STCSourceNotFoundEditor_failed_saving_settings_for_content_type + CDebugCorePlugin.PLUGIN_ID, e);
        throw new CoreException(status);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) AbstractSourceLookupDirector(org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector) CoreException(org.eclipse.core.runtime.CoreException) 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