Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2017-06-26 15:12:27 +0000
committerChristian W. Damus2017-06-27 16:57:33 +0000
commit3bcaf8681627650daf04c698c8fa49604420c1e4 (patch)
tree8eb73339c552afe3283244f417f11755b8ecb043 /plugins/infra/architecture
parentb51ecc973b3cc91a5da7b007d5ddceef71d18061 (diff)
downloadorg.eclipse.papyrus-3bcaf8681627650daf04c698c8fa49604420c1e4.tar.gz
org.eclipse.papyrus-3bcaf8681627650daf04c698c8fa49604420c1e4.tar.xz
org.eclipse.papyrus-3bcaf8681627650daf04c698c8fa49604420c1e4.zip
Bug 518789: [Architecture Framework] Preferences not customizable by Eclipse Products
Read preferences from a cascade of scopes including configuration. https://bugs.eclipse.org/bugs/show_bug.cgi?id=518789 Change-Id: Ie94d381514fb56f3b808361fdc1023931faa69f0
Diffstat (limited to 'plugins/infra/architecture')
-rw-r--r--plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainPreferences.java39
1 files changed, 29 insertions, 10 deletions
diff --git a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainPreferences.java b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainPreferences.java
index 2cd3440b4d5..d1cc29484bd 100644
--- a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainPreferences.java
+++ b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainPreferences.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017 CEA LIST.
+ * Copyright (c) 2017 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Maged Elaasar - Initial API and implementation
+ * Christian W. Damus - bug 518789
*
*
*/
@@ -19,8 +20,13 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.papyrus.infra.services.edit.context.TypeContext;
import org.osgi.service.prefs.BackingStoreException;
@@ -41,13 +47,19 @@ public class ArchitectureDomainPreferences implements Cloneable {
* The excludedContexts preference property name
*/
public static final String EXCLUDED_CONTEXTS = "excludedContexts"; //$NON-NLS-1$
-
+
/**
* The defaultContext preference property name
*/
public static final String DEFAULT_CONTEXT = "defaultContext"; //$NON-NLS-1$
/**
+ * The look-up order of preference scopes.
+ */
+ private final IScopeContext[] scopes = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE,
+ DefaultScope.INSTANCE };
+
+ /**
* The list of added architecture models in the preferences
*/
private List<String> addedModels;
@@ -56,7 +68,7 @@ public class ArchitectureDomainPreferences implements Cloneable {
* The set of excluded architecture contexts in the preferences
*/
private Set<String> excludedContexts;
-
+
/**
* The id of the default context in the preferences
*/
@@ -78,11 +90,17 @@ public class ArchitectureDomainPreferences implements Cloneable {
* Reads the state of the preferences
*/
public void read() {
- addedModels = Arrays.asList(getPreferences().get(ArchitectureDomainPreferences.ADDED_MODELS, "").split(" "));
- excludedContexts = new HashSet<String>(Arrays.asList(getPreferences().get(ArchitectureDomainPreferences.EXCLUDED_CONTEXTS, "").split(",")));
- defaultContext = getPreferences().get(ArchitectureDomainPreferences.DEFAULT_CONTEXT, defaultDefaultContext);
+ IPreferencesService preferences = Platform.getPreferencesService();
+
+ addedModels = Arrays.asList(preferences
+ .getString(Activator.PLUGIN_ID, ArchitectureDomainPreferences.ADDED_MODELS, "", scopes).split(" "));
+ excludedContexts = new HashSet<String>(Arrays.asList(
+ preferences.getString(Activator.PLUGIN_ID, ArchitectureDomainPreferences.EXCLUDED_CONTEXTS, "", scopes)
+ .split(",")));
+ defaultContext = preferences.getString(Activator.PLUGIN_ID, ArchitectureDomainPreferences.DEFAULT_CONTEXT,
+ defaultDefaultContext, scopes);
}
-
+
/**
* Writes the state of the preferences
*/
@@ -100,7 +118,7 @@ public class ArchitectureDomainPreferences implements Cloneable {
Activator.log.error(e);
}
}
-
+
/**
* Resets the state of this class to default
*/
@@ -109,7 +127,7 @@ public class ArchitectureDomainPreferences implements Cloneable {
excludedContexts.clear();
defaultContext = defaultDefaultContext;
}
-
+
/**
* Adds the given preference change listener
*
@@ -143,7 +161,8 @@ public class ArchitectureDomainPreferences implements Cloneable {
/**
* Sets the default context id
*
- * @param defaultContext the default context id
+ * @param defaultContext
+ * the default context id
*/
public void setDefaultContextId(String defaultContext) {
this.defaultContext = defaultContext;

Back to the top