Search in sources :

Example 36 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences 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 37 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project che by eclipse.

the class ImportOrganizeTest method setOrganizeImportSettings.

protected void setOrganizeImportSettings(String[] order, int threshold, int staticThreshold, IJavaProject project) {
    IEclipsePreferences scope = new ProjectScope(project.getProject()).getNode("org.eclipse.jdt.ui");
    if (order == null) {
        scope.remove(PreferenceConstants.ORGIMPORTS_IMPORTORDER);
        scope.remove(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD);
    } else {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < order.length; i++) {
            buf.append(order[i]);
            buf.append(';');
        }
        scope.put(PreferenceConstants.ORGIMPORTS_IMPORTORDER, buf.toString());
        scope.put(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, String.valueOf(threshold));
        scope.put(PreferenceConstants.ORGIMPORTS_STATIC_ONDEMANDTHRESHOLD, String.valueOf(staticThreshold));
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 38 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences 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)

Example 39 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project flux by eclipse.

the class Activator method getConnectedProjectPreferences.

private String[] getConnectedProjectPreferences() {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(PLUGIN_ID);
    String[] projects = StringUtils.split(preferences.get(CONNECTED_PROJECTS_ID, ""), ";");
    return projects;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 40 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project che by eclipse.

the class JavaProject method getEclipsePreferences.

/**
     * Returns the project custom preference pool.
     * Project preferences may include custom encoding.
     * @return IEclipsePreferences or <code>null</code> if the project
     * 	does not have a java nature.
     */
public IEclipsePreferences getEclipsePreferences() {
    if (!org.eclipse.jdt.internal.core.JavaProject.hasJavaNature(this.project))
        return null;
    // Get cached preferences if exist
    PerProjectInfo perProjectInfo = getJavaModelManager().getPerProjectInfo(this.project, true);
    if (perProjectInfo.preferences != null)
        return perProjectInfo.preferences;
    // Init project preferences
    IScopeContext context = new ProjectScope(getProject());
    final IEclipsePreferences eclipsePreferences = context.getNode(JavaCore.PLUGIN_ID);
    //        updatePreferences(eclipsePreferences);
    perProjectInfo.preferences = eclipsePreferences;
    //        eclipsePreferences.addPreferenceChangeListener(this.preferencesChangeListener);
    return eclipsePreferences;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) PerProjectInfo(org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Aggregations

IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)79 BackingStoreException (org.osgi.service.prefs.BackingStoreException)15 Test (org.junit.Test)11 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 ProjectScope (org.eclipse.core.resources.ProjectScope)6 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)6 After (org.junit.After)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2