Search in sources :

Example 41 with Preferences

use of org.osgi.service.prefs.Preferences in project webtools.servertools by eclipse.

the class ServerPreferenceModifyListener method preApply.

/* (non-Javadoc)
	 * @see org.eclipse.core.runtime.preferences.PreferenceModifyListener#preApply(org.eclipse.core.runtime.preferences.IEclipsePreferences)
	 */
public IEclipsePreferences preApply(IEclipsePreferences node) {
    Preferences instance = node.node(InstanceScope.SCOPE);
    Preferences runtimes = instance.node(ServerPlugin.PLUGIN_ID);
    if (runtimes != null)
        // $NON-NLS-1$
        removeLockedServerRuntimePreference(runtimes);
    return super.preApply(node);
}
Also used : Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 42 with Preferences

use of org.osgi.service.prefs.Preferences in project jbosstools-openshift by jbosstools.

the class Cluster method load.

public void load(Preferences clusterNode, ISecurePreferences secureClusterNode) throws StorageException {
    clusterNode.get(ENDPOINT_URL_KEY, OSIOCoreConstants.OSIO_ENDPOINT);
    try {
        String[] ids = clusterNode.childrenNames();
        for (String id : ids) {
            Account account = new Account(id, this);
            Preferences accountNode = clusterNode.node(id);
            ISecurePreferences secureAccountNode = secureClusterNode.node(id);
            try {
                account.load(accountNode, secureAccountNode);
                identities.add(account);
            } catch (StorageException e) {
                OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
            }
        }
    } catch (BackingStoreException e) {
        OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
    }
}
Also used : IAccount(org.jboss.tools.openshift.io.core.model.IAccount) BackingStoreException(org.osgi.service.prefs.BackingStoreException) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) Preferences(org.osgi.service.prefs.Preferences) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) StorageException(org.eclipse.equinox.security.storage.StorageException)

Example 43 with Preferences

use of org.osgi.service.prefs.Preferences in project jbosstools-openshift by jbosstools.

the class Cluster method save.

@Override
public void save() {
    try {
        Preferences accountsNode = AccountModel.getAccountsPreferences();
        Preferences clusterNode = accountsNode.node(getId());
        ISecurePreferences clusterSecureNode = AccountModel.getSecureAccountsPreferences().node(getId());
        clusterNode.put(ENDPOINT_URL_KEY, getEndpointURL());
        removed.forEach(id -> {
            try {
                clusterNode.node(id).removeNode();
                clusterSecureNode.node(id).removeNode();
            } catch (BackingStoreException e) {
                OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
            }
        });
        removed.clear();
        clusterNode.flush();
        clusterSecureNode.flush();
    } catch (BackingStoreException | IOException e) {
        OpenShiftIOCoreActivator.logError("Error saving cluster in storage", e);
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) IOException(java.io.IOException) Preferences(org.osgi.service.prefs.Preferences) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences)

Example 44 with Preferences

use of org.osgi.service.prefs.Preferences in project jbosstools-openshift by jbosstools.

the class Account method save.

@Override
public void save() {
    try {
        ISecurePreferences secureAccountsRoot = AccountModel.getSecureAccountsPreferences();
        Preferences accountsRoot = AccountModel.getAccountsPreferences();
        ISecurePreferences secureAccountNode = secureAccountsRoot.node(cluster.getId()).node(getId());
        Preferences accountNode = accountsRoot.node(cluster.getId()).node(getId());
        accountNode.putLong(ACCESS_TOKEN_EXPIRY_TIME_KEY, getAccessTokenExpiryTime());
        accountNode.putLong(KEYREFRESH_TOKEN_EXPIRY_TIME, getRefreshTokenExpiryTime());
        accountNode.putLong(LAST_REFRESHED_TIME_KEY, getLastRefreshedTime());
        secureAccountNode.put(ACCESS_TOKEN_KEY, getAccessToken(), true);
        secureAccountNode.put(REFRESH_TOKEN_KEY, getRefreshToken(), true);
        accountNode.flush();
        secureAccountNode.flush();
    } catch (StorageException | BackingStoreException | IOException e) {
        OpenShiftIOCoreActivator.logError("Error saving credentials ", e);
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) IOException(java.io.IOException) Preferences(org.osgi.service.prefs.Preferences) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) StorageException(org.eclipse.equinox.security.storage.StorageException)

Example 45 with Preferences

use of org.osgi.service.prefs.Preferences in project polymap4-core by Polymap4.

the class ProjectPreferences method deleted.

static void deleted(IFolder folder) throws CoreException {
    IPath path = folder.getFullPath();
    int count = path.segmentCount();
    if (count != 2)
        return;
    // check if we are the .settings directory
    if (!EclipsePreferences.DEFAULT_PREFERENCES_DIRNAME.equals(path.segment(1)))
        return;
    Preferences root = Platform.getPreferencesService().getRootNode();
    // The settings dir has been removed/moved so remove all project prefs
    // for the resource.
    String project = path.segment(0);
    Preferences projectNode = root.node(ProjectScope.SCOPE).node(project);
    // check if we need to notify the charset manager
    boolean hasResourcesSettings = getFile(folder, ResourcesPlugin.PI_RESOURCES).exists();
    // remove the preferences
    removeNode(projectNode);
    // notifies the CharsetManager
    if (hasResourcesSettings)
        preferencesChanged(folder.getProject());
}
Also used : Preferences(org.osgi.service.prefs.Preferences) IExportedPreferences(org.eclipse.core.runtime.preferences.IExportedPreferences) EclipsePreferences(org.eclipse.core.internal.preferences.EclipsePreferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ExportedPreferences(org.eclipse.core.internal.preferences.ExportedPreferences)

Aggregations

Preferences (org.osgi.service.prefs.Preferences)157 BackingStoreException (org.osgi.service.prefs.BackingStoreException)82 EclipsePreferences (org.eclipse.core.internal.preferences.EclipsePreferences)41 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)37 ProjectScope (org.eclipse.core.resources.ProjectScope)18 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)14 IStatus (org.eclipse.core.runtime.IStatus)10 IOException (java.io.IOException)7 Test (org.junit.Test)7 IProject (org.eclipse.core.resources.IProject)6 Status (org.eclipse.core.runtime.Status)6 PerformanceTestRunner (org.eclipse.core.tests.harness.PerformanceTestRunner)6 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)5 ISecurePreferences (org.eclipse.equinox.security.storage.ISecurePreferences)5 Field (java.lang.reflect.Field)4 ArrayList (java.util.ArrayList)4 ExportedPreferences (org.eclipse.core.internal.preferences.ExportedPreferences)4 IExportedPreferences (org.eclipse.core.runtime.preferences.IExportedPreferences)4 ContentTypeEncodingPreferences (org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences)4 IEncodedDocument (org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)4