Search in sources :

Example 11 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project xtext-eclipse by eclipse.

the class PreferenceStoreAccessImpl method getWritablePreferenceStore.

@Override
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore() {
    lazyInitialize();
    FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(new InstanceScope(), getQualifier());
    result.setSearchContexts(new IScopeContext[] { new InstanceScope(), new ConfigurationScope() });
    return result;
}
Also used : InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 12 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project xtext-eclipse by eclipse.

the class PreferenceStoreAccessImpl method getWritablePreferenceStore.

@Override
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore(Object context) {
    lazyInitialize();
    IProject project = getProject(context);
    if (project == null) {
        return getWritablePreferenceStore();
    }
    ProjectScope projectScope = new ProjectScope(project);
    FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(projectScope, getQualifier());
    result.setSearchContexts(new IScopeContext[] { projectScope, new InstanceScope(), new ConfigurationScope() });
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IProject(org.eclipse.core.resources.IProject) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 13 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project xtext-eclipse by eclipse.

the class AbstractPreferencePage method handleUseProjectSettings.

/**
 * Switches the search scope of the preference store to use [Project, Instance, Configuration] if values are project
 * specific, and [Instance, Configuration] otherwise. This implementation requires that the given preference store
 * is based on the Project preference store when the page is used as a Properties page. (This is done in
 * {@link #doGetPreferenceStore()}).
 */
@SuppressWarnings("deprecation")
private void handleUseProjectSettings() {
    // Note: uses the pre Eclipse 3.6 way of specifying search scopes (deprecated since 3.6)
    boolean isUseProjectSettings = useProjectSettingsButton.getSelection();
    link.setEnabled(!isUseProjectSettings);
    if (!isUseProjectSettings) {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] { new InstanceScope(), new ConfigurationScope() });
    } else {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] { new ProjectScope(currentProject()), new InstanceScope(), new ConfigurationScope() });
        setProjectSpecificValues();
    }
    updateFieldEditors(isUseProjectSettings);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 14 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project ecf by eclipse.

the class AccountStart method loadConnectionDetailsFromPreferenceStore.

public void loadConnectionDetailsFromPreferenceStore() {
    try {
        Preferences preferences = new InstanceScope().getNode(ClientPlugin.PLUGIN_ID);
        Preferences connections = preferences.node(SAVED);
        String[] targets = connections.childrenNames();
        for (int i = 0; i < targets.length; i++) {
            String target = targets[i];
            Preferences node = connections.node(target);
            if (node != null) {
                addConnectionDetails(new ConnectionDetails(node.get(ConnectionDetails.CONTAINER_TYPE, ""), // $NON-NLS-1$
                node.get(ConnectionDetails.TARGET_URI, ""), // $NON-NLS-1$
                node.get(ConnectionDetails.NICKNAME, ""), // $NON-NLS-1$
                node.get(ConnectionDetails.PASSWORD, // $NON-NLS-1$
                "")));
            }
        }
    } catch (BackingStoreException e) {
        ClientPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ClientPlugin.PLUGIN_ID, BACKING_STORE_LOAD_ERROR, Messages.AccountStart_EXCEPTION_LOADING_CONNECTION_DETAILS, e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 15 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project ecf by eclipse.

the class AccountStart method removeConnectionDetails.

public void removeConnectionDetails(ConnectionDetails cd) {
    try {
        Preferences preferences = new InstanceScope().getNode(ClientPlugin.PLUGIN_ID);
        Preferences connections = preferences.node(SAVED);
        String[] targets = connections.childrenNames();
        for (int i = 0; i < targets.length; i++) {
            String target = targets[i];
            Preferences node = connections.node(target);
            String cdTarget = normalizeURI(cd.getTargetURI());
            if (node != null && target != null && target.equals(cdTarget)) {
                node.removeNode();
            }
        }
        connections.flush();
    } catch (BackingStoreException e) {
        ClientPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ClientPlugin.PLUGIN_ID, BACKING_STORE_LOAD_ERROR, Messages.AccountStart_EXCEPTION_LOADING_CONNECTION_DETAILS, e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Aggregations

InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)54 ProjectScope (org.eclipse.core.resources.ProjectScope)30 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)16 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)16 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)15 IProject (org.eclipse.core.resources.IProject)11 BackingStoreException (org.osgi.service.prefs.BackingStoreException)9 IFile (org.eclipse.core.resources.IFile)7 ConfigurationScope (org.eclipse.core.runtime.preferences.ConfigurationScope)7 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 IResource (org.eclipse.core.resources.IResource)5 Preferences (org.osgi.service.prefs.Preferences)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 List (java.util.List)3