Search in sources :

Example 21 with BackingStoreException

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

the class PreferenceUtil method unsetPreference.

public static void unsetPreference(String name) {
    Preferences prefs = PluginUtil.getPrefs(com.microsoft.azuretools.core.utils.Messages.prefFileName);
    prefs.remove(name);
    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 22 with BackingStoreException

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

the class TalendPaletteViewer method setupPreferences.

private void setupPreferences() {
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    //$NON-NLS-1$
    final String firstTimeRunning = "org.talend.designer.core.ui.editor.palette.TalendPaletteViewer.isFirstTimeRunning";
    boolean isFirstTimeRunning = true;
    if (preferenceStore != null) {
        String value = preferenceStore.getString(firstTimeRunning);
        if (StringUtils.isNotEmpty(value)) {
            isFirstTimeRunning = Boolean.valueOf(value);
        }
    }
    if (isFirstTimeRunning) {
        PaletteViewerPreferences paletteViewerPreferences = this.getPaletteViewerPreferences();
        if (paletteViewerPreferences != null) {
            paletteViewerPreferences.setAutoCollapseSetting(PaletteViewerPreferences.COLLAPSE_NEVER);
            paletteViewerPreferences.getAutoCollapseSetting();
            if (preferenceStore != null) {
                preferenceStore.setValue(firstTimeRunning, Boolean.FALSE.toString());
                try {
                    InstanceScope.INSTANCE.getNode(DesignerPlugin.ID).flush();
                } catch (BackingStoreException e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) PaletteViewerPreferences(org.eclipse.gef.ui.palette.PaletteViewerPreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 23 with BackingStoreException

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

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

Example 25 with BackingStoreException

use of org.osgi.service.prefs.BackingStoreException in project sling by apache.

the class ProjectUtil method setPathPersistentProperty.

private static void setPathPersistentProperty(IProject project, IPath path, String propertyName) {
    IScopeContext projectScope = new ProjectScope(project);
    IEclipsePreferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
    if (projectNode != null) {
        projectNode.put(propertyName, path.toPortableString());
        try {
            projectNode.flush();
        } catch (BackingStoreException e) {
            Activator.getDefault().getPluginLogger().error(e.getMessage(), e);
        }
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) 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