Search in sources :

Example 46 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.

the class CubridStatusMonitorInstance method loadSetting.

/**
	 * Get the info of StatusMonInstanceData relevant to key from preference
	 * 
	 * @param key the key relevant to saving instance of StatusMonInstanceData
	 * @return the instance of StatusMonInstanceData
	 */
public StatusMonInstanceData loadSetting(String key) {
    StatusMonInstanceData data = null;
    synchronized (this) {
        IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
        byte[] bytes = preference.getByteArray(key, BYTE_ARRAY_DEFAULT_DEFAULT);
        if (bytes.length > 0) {
            try {
                ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));
                data = (StatusMonInstanceData) inputStream.readObject();
                inputStream.close();
            } catch (Exception ex) {
                LOGGER.error(ex.getMessage());
            }
        }
    }
    return data;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ByteArrayInputStream(java.io.ByteArrayInputStream) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException) ObjectInputStream(java.io.ObjectInputStream)

Example 47 with IEclipsePreferences

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

the class DisableDebugStatusHandlers method before.

@Override
protected void before() throws Throwable {
    IEclipsePreferences debugPrefs = InstanceScope.INSTANCE.getNode(DebugPlugin.getUniqueIdentifier());
    debugPrefs.putBoolean(IInternalDebugCoreConstants.PREF_ENABLE_STATUS_HANDLERS, false);
    debugPrefs.flush();
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 48 with IEclipsePreferences

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

Example 49 with IEclipsePreferences

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

the class PreferencesInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    IEclipsePreferences node = DefaultScope.INSTANCE.getNode(org.apache.sling.ide.eclipse.core.internal.Activator.PLUGIN_ID);
    node.put(Preferences.IGNORED_FILE_NAMES_FOR_SYNC, ".svn;.DS_Store;.gitignore;.vlt;.vltignore");
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 50 with IEclipsePreferences

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

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