Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaged Elaasar2018-04-08 02:24:05 -0400
committerBenoit Maggi2018-06-19 07:09:44 -0400
commit49735abfa37bfec5ba8df800aae6f2e057d8469e (patch)
treed9dd24fe8cd731f7a0949a228c6c5947207b86b4
parent6eb8b72eb383542ced307cff0c4146f58f160204 (diff)
downloadorg.eclipse.papyrus-49735abfa37bfec5ba8df800aae6f2e057d8469e.tar.gz
org.eclipse.papyrus-49735abfa37bfec5ba8df800aae6f2e057d8469e.tar.xz
org.eclipse.papyrus-49735abfa37bfec5ba8df800aae6f2e057d8469e.zip
Bug 518022 [AFViewpoints] Diagram unusable if Papyrus Architecture
Context preference values are touched. - Fixed ElementTypeSetConfigurationRegistry.dispose() to properly deregister the dynamically registered element types and advices (avoiding many warnings thrown in console) - Made ElementTypeSetConfigurationRegistry only reload in response to the set of dynamically added architecture models changing - Fixed a problem with ArchitectureDomainPreferences loading/saving preferences - Deprecate the public API ArchitectureDomainManager.getPreferences() method to avoid changing the preferences through the object only as opposed to the preference store - Fixed the bolding of the default context's font style in the ArchitectureContextPreferencePage Change-Id: If0dd708c91d78ca90257516814d38510c0986ed1 Signed-off-by: Maged Elaasar <melaasar@gmail.com>
-rw-r--r--plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainManager.java56
-rw-r--r--plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainPreferences.java80
-rw-r--r--plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/registries/ElementTypeSetConfigurationRegistry.java103
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF1
-rwxr-xr-xplugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java47
-rw-r--r--tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableLabelProviderTest.java9
6 files changed, 177 insertions, 119 deletions
diff --git a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainManager.java b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainManager.java
index 8e63d4214e9..8906793ee18 100644
--- a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainManager.java
+++ b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDomainManager.java
@@ -72,6 +72,20 @@ public class ArchitectureDomainManager implements IPreferenceChangeListener {
}
/**
+ * An abstract class for listening to specific changes to architectural domains
+ */
+ public abstract static class SpecificListener implements Listener {
+ @Override
+ public void domainManagerChanged() {}
+ /** the set of excluded contexts in the preferences have changed */
+ public void excludedContextsChanged() {}
+ /** the set of architecture models added through preferences has changed */
+ public void addedModelsChanged() {}
+ /** the default architecture context set in preferences has changed */
+ public void defaultContextChanged() {}
+ }
+
+ /**
* The architecture domain preferences
*/
private ArchitectureDomainPreferences preferences;
@@ -90,10 +104,10 @@ public class ArchitectureDomainManager implements IPreferenceChangeListener {
* Constructs a new instance of this class
*/
private ArchitectureDomainManager() {
- listeners = new HashSet<Listener>();
+ listeners = new HashSet<>();
merger = new ArchitectureDomainMerger();
preferences = new ArchitectureDomainPreferences();
- preferences.addListener(this);
+ ArchitectureDomainPreferences.addListener(this);
initializeFromExtensions();
initializeFromPreferences();
merger.init(); // init as early as possible
@@ -103,7 +117,7 @@ public class ArchitectureDomainManager implements IPreferenceChangeListener {
* initialize the architecture domain merger from the registered extensions
*/
private void initializeFromExtensions() {
- List<URI> models = new ArrayList<URI>();
+ List<URI> models = new ArrayList<>();
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT);
for (IConfigurationElement element : elements) {
String path = element.getAttribute(PATH);
@@ -118,8 +132,7 @@ public class ArchitectureDomainManager implements IPreferenceChangeListener {
* initialize the architecture domain merger from the preferences
*/
private void initializeFromPreferences() {
- preferences.read();
- List<URI> models = new ArrayList<URI>();
+ List<URI> models = new ArrayList<>();
for (String value : preferences.getAddedModelURIs()) {
if (value.length()>0) {
models.add(URI.createURI(value, true));
@@ -135,7 +148,7 @@ public class ArchitectureDomainManager implements IPreferenceChangeListener {
* @since 2.0
*/
public Collection<URI> getRegisteredArchitectureModels() {
- return new ArrayList<URI>(merger.getExtensionModels());
+ return new ArrayList<>(merger.getExtensionModels());
}
/**
@@ -164,20 +177,37 @@ public class ArchitectureDomainManager implements IPreferenceChangeListener {
*/
@Override
public void preferenceChange(PreferenceChangeEvent event) {
- initializeFromPreferences();
- for (Listener listener : listeners)
+ preferences.read();
+
+ if (event.getKey().equals(ArchitectureDomainPreferences.ADDED_MODELS))
+ initializeFromPreferences();
+
+ for (Listener listener : listeners) {
+ if (listener instanceof SpecificListener) {
+ SpecificListener specificListener = (SpecificListener) listener;
+ if (event.getKey().equals(ArchitectureDomainPreferences.ADDED_MODELS))
+ specificListener.addedModelsChanged();
+ else if (event.getKey().equals(ArchitectureDomainPreferences.DEFAULT_CONTEXT))
+ specificListener.defaultContextChanged();
+ else if (event.getKey().equals(ArchitectureDomainPreferences.EXCLUDED_CONTEXTS))
+ specificListener.excludedContextsChanged();
+ }
listener.domainManagerChanged();
+ }
}
-
+
/**
* Gets the architecture domain preferences
- *
+ * @deprecated Deprecate the public API ArchitectureDomainManager.getPreferences()
+ * method to avoid changing the preferences through the object only as
+ * opposed to the preference store
* @return the architecture domain preferences
*/
+ @Deprecated
public ArchitectureDomainPreferences getPreferences() {
return preferences;
- }
-
+ }
+
/**
* Get the architecture domain merger
*
@@ -193,7 +223,7 @@ public class ArchitectureDomainManager implements IPreferenceChangeListener {
* @return a list of architecture contexts
*/
public Collection<MergedArchitectureContext> getVisibleArchitectureContexts() {
- Collection<MergedArchitectureContext> contexts = new ArrayList<MergedArchitectureContext>();
+ Collection<MergedArchitectureContext> contexts = new ArrayList<>();
for (MergedArchitectureDomain domain : merger.getDomains()) {
for (MergedArchitectureContext context : domain.getContexts()) {
if (!preferences.getExcludedContextIds().contains(context.getId()))
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 d1cc29484bd..33cab7a0f18 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
@@ -20,13 +20,8 @@ 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;
@@ -54,31 +49,32 @@ public class ArchitectureDomainPreferences implements Cloneable {
public static final String DEFAULT_CONTEXT = "defaultContext"; //$NON-NLS-1$
/**
- * The look-up order of preference scopes.
+ * The default value of the default context when not set
*/
- private final IScopeContext[] scopes = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE,
- DefaultScope.INSTANCE };
+ static final String DEFAULT_DEFAULT_CONTEXT_ID = TypeContext.getDefaultContextId();
/**
- * The list of added architecture models in the preferences
+ * The list of added architecture model URIs in the preferences
*/
- private List<String> addedModels;
+ private List<String> addedModelURIs = new ArrayList<>();
/**
- * The set of excluded architecture contexts in the preferences
+ * The set of excluded architecture context ids in the preferences
*/
- private Set<String> excludedContexts;
+ private Set<String> excludedContextIds = new HashSet<>();
/**
- * The id of the default context in the preferences
+ * The id of the default context id in the preferences
*/
- private String defaultContext;
+ private String defaultContextId = DEFAULT_DEFAULT_CONTEXT_ID;
/**
- * The default value of the default context when not set
+ * Constructor
*/
- private String defaultDefaultContext = TypeContext.getDefaultContextId();
-
+ public ArchitectureDomainPreferences() {
+ read();
+ }
+
/*
* Gets the preferences node
*/
@@ -90,28 +86,22 @@ public class ArchitectureDomainPreferences implements Cloneable {
* Reads the state of the preferences
*/
public void read() {
- 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);
+ String value;
+ value = getPreferences().get(ArchitectureDomainPreferences.ADDED_MODELS, "");
+ addedModelURIs = value.equals("")? new ArrayList<>() : Arrays.asList(value.split(" "));
+ value = getPreferences().get(ArchitectureDomainPreferences.EXCLUDED_CONTEXTS, "");
+ excludedContextIds = value.equals("")? new HashSet<>() : new HashSet<>(Arrays.asList(value.split(",")));
+ value = getPreferences().get(ArchitectureDomainPreferences.DEFAULT_CONTEXT, DEFAULT_DEFAULT_CONTEXT_ID);
+ defaultContextId = value;
}
/**
* Writes the state of the preferences
*/
public void write() {
- getPreferences().put(ArchitectureDomainPreferences.ADDED_MODELS, "");
- getPreferences().put(ArchitectureDomainPreferences.ADDED_MODELS, String.join(" ", addedModels));
- getPreferences().put(ArchitectureDomainPreferences.EXCLUDED_CONTEXTS, String.join(",", excludedContexts));
- if (defaultContext != null)
- getPreferences().put(ArchitectureDomainPreferences.DEFAULT_CONTEXT, defaultContext);
- else
- getPreferences().remove(ArchitectureDomainPreferences.DEFAULT_CONTEXT);
+ getPreferences().put(ArchitectureDomainPreferences.ADDED_MODELS, String.join(" ", addedModelURIs));
+ getPreferences().put(ArchitectureDomainPreferences.EXCLUDED_CONTEXTS, String.join(",", excludedContextIds));
+ getPreferences().put(ArchitectureDomainPreferences.DEFAULT_CONTEXT, defaultContextId);
try {
getPreferences().flush();
} catch (BackingStoreException e) {
@@ -123,9 +113,9 @@ public class ArchitectureDomainPreferences implements Cloneable {
* Resets the state of this class to default
*/
public void reset() {
- addedModels.clear();
- excludedContexts.clear();
- defaultContext = defaultDefaultContext;
+ addedModelURIs.clear();
+ excludedContextIds.clear();
+ defaultContextId = DEFAULT_DEFAULT_CONTEXT_ID;
}
/**
@@ -133,7 +123,7 @@ public class ArchitectureDomainPreferences implements Cloneable {
*
* @param listener
*/
- public void addListener(IPreferenceChangeListener listener) {
+ static void addListener(IPreferenceChangeListener listener) {
getPreferences().addPreferenceChangeListener(listener);
}
@@ -141,38 +131,38 @@ public class ArchitectureDomainPreferences implements Cloneable {
* @return the added model URIs
*/
public List<String> getAddedModelURIs() {
- return addedModels;
+ return addedModelURIs;
}
/**
* @return the excluded context ids
*/
public Set<String> getExcludedContextIds() {
- return excludedContexts;
+ return excludedContextIds;
}
/**
* @return the default context id
*/
public String getDefaultContextId() {
- return defaultContext;
+ return defaultContextId;
}
/**
* Sets the default context id
*
- * @param defaultContext
+ * @param defaultContextId
* the default context id
*/
- public void setDefaultContextId(String defaultContext) {
- this.defaultContext = defaultContext;
+ public void setDefaultContextId(String defaultContextId) {
+ this.defaultContextId = defaultContextId;
}
@Override
public ArchitectureDomainPreferences clone() {
ArchitectureDomainPreferences clone = new ArchitectureDomainPreferences();
- clone.addedModels = new ArrayList<String>(getAddedModelURIs());
- clone.excludedContexts = new HashSet<String>(getExcludedContextIds());
+ clone.addedModelURIs = new ArrayList<>(getAddedModelURIs());
+ clone.excludedContextIds = new HashSet<>(getExcludedContextIds());
clone.setDefaultContextId(getDefaultContextId());
return clone;
}
diff --git a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/registries/ElementTypeSetConfigurationRegistry.java b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/registries/ElementTypeSetConfigurationRegistry.java
index a2c3d46a824..7d549a9a56b 100644
--- a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/registries/ElementTypeSetConfigurationRegistry.java
+++ b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/registries/ElementTypeSetConfigurationRegistry.java
@@ -48,15 +48,16 @@ import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.IMetamodelType;
import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
import org.eclipse.gmf.runtime.emf.type.core.NullElementType;
-import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
-import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureDomain;
import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
import org.eclipse.papyrus.infra.architecture.ArchitectureDomainMerger;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureDomain;
import org.eclipse.papyrus.infra.types.AbstractAdviceBindingConfiguration;
import org.eclipse.papyrus.infra.types.AdviceConfiguration;
import org.eclipse.papyrus.infra.types.ElementTypeConfiguration;
import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration;
import org.eclipse.papyrus.infra.types.ExternallyRegisteredAdvice;
+import org.eclipse.papyrus.infra.types.ExternallyRegisteredType;
import org.eclipse.papyrus.infra.types.SpecializationTypeConfiguration;
import org.eclipse.papyrus.infra.types.core.Activator;
import org.eclipse.papyrus.infra.types.core.extensionpoints.IElementTypeSetExtensionPoint;
@@ -70,7 +71,7 @@ import org.osgi.framework.Bundle;
*/
public class ElementTypeSetConfigurationRegistry {
- private volatile static ElementTypeSetConfigurationRegistry elementTypeSetConfigurationRegistry;
+ private static volatile ElementTypeSetConfigurationRegistry elementTypeSetConfigurationRegistry;
/** Set of registered client contexts
* @since 3.0*/
@@ -84,7 +85,7 @@ public class ElementTypeSetConfigurationRegistry {
/** unique resource set to load all elementType sets models */
- protected ResourceSet elementTypeSetConfigurationResourceSet = null;
+ protected ResourceSet elementTypeSetConfigurationResourceSet = createResourceSet();
protected ElementTypeSetConfigurationRegistry() {
listenToArchitectureDomainManager();
@@ -107,14 +108,11 @@ public class ElementTypeSetConfigurationRegistry {
* Inits the registry.
*/
protected void init() {
- // 0. Resets values
- elementTypeSetConfigurationResourceSet = null;
- elementTypeSetConfigurations = new HashMap<String, Map<String, ElementTypeSetConfiguration>>();
- advicesDeps = new HashMap<String, Map<String, OrientedGraph<String>>>();
- clientContexts = new HashSet<IClientContext>();
- // 1. creates the resource set
- elementTypeSetConfigurationResourceSet = createResourceSet();
- // 2. creates the list only when registry is acceded for the first time,
+ // Resets values
+ elementTypeSetConfigurations = new HashMap<>();
+ advicesDeps = new HashMap<>();
+ clientContexts = new HashSet<>();
+ // creates the list only when registry is acceded for the first time,
Map<String, Set<ElementTypeSetConfiguration>> elementTypeSetConfigurationsToLoad = readElementTypeSetConfigurationModelsFromExtensionPoints();
readElementTypeSetConfigurationModelsFromArchitectureDomainManager(elementTypeSetConfigurationsToLoad);
// Try to load all elementType set definitions
@@ -125,8 +123,7 @@ public class ElementTypeSetConfigurationRegistry {
}
protected Map<String, Set<ElementTypeSetConfiguration>> readElementTypeSetConfigurationModels() {
- Map<String, Set<ElementTypeSetConfiguration>> elementTypeSetConfigurations = new HashMap<String, Set<ElementTypeSetConfiguration>>();
- return elementTypeSetConfigurations;
+ return new HashMap<>();
}
/**
@@ -137,18 +134,55 @@ public class ElementTypeSetConfigurationRegistry {
return;
}
+ // Remove adviceBindings
for (String contextId : elementTypeSetConfigurations.keySet()) {
- for (String elementTypeSetId : new HashSet<String>(elementTypeSetConfigurations.get(contextId).keySet())) {
- unload(contextId, elementTypeSetId);
+ ClientContext context = (ClientContext) ClientContextManager.getInstance().getClientContext(contextId);
+ for (ElementTypeSetConfiguration elementTypeSet : elementTypeSetConfigurations.get(contextId).values()) {
+ for (AbstractAdviceBindingConfiguration adviceBindingConfiguration : elementTypeSet.getAdviceBindingsConfigurations()) {
+ if (adviceBindingConfiguration instanceof ExternallyRegisteredAdvice) {
+ context.unbindId(adviceBindingConfiguration.getIdentifier());
+ } else {
+ IAdviceBindingDescriptor editHelperAdviceDecriptor = AdviceConfigurationTypeRegistry.getInstance().getEditHelperAdviceDecriptor(adviceBindingConfiguration);
+ ElementTypeRegistryUtils.removeAdviceDescriptorFromBindings(editHelperAdviceDecriptor);
+ context.unbindId(editHelperAdviceDecriptor.getId());
+ }
+ }
}
+ }
+ List<IElementType> elementTypes = new ArrayList<>();
+ ElementTypeRegistry registry = ElementTypeRegistry.getInstance();
+
+ // Remove elementTypes
+ for (String contextId : elementTypeSetConfigurations.keySet()) {
+ ClientContext context = (ClientContext) ClientContextManager.getInstance().getClientContext(contextId);
+ for (ElementTypeSetConfiguration elementTypeSet : elementTypeSetConfigurations.get(contextId).values()) {
+ for (ElementTypeConfiguration elementTypeConfiguration : elementTypeSet.getElementTypeConfigurations()) {
+ if (elementTypeConfiguration instanceof ExternallyRegisteredType) {
+ context.unbindId(elementTypeConfiguration.getIdentifier());
+ } else {
+ String configIdentifier = elementTypeConfiguration.getIdentifier();
+ IElementType elementType = registry.getType(configIdentifier);
+ if (elementType != null) {
+ elementTypes.add(elementType);
+ }
+ }
+ }
+ }
}
+ ElementTypeUtil.deregisterElementTypes(elementTypes, ElementTypeUtil.SPECIALIZATIONS | ElementTypeUtil.CLIENT_CONTEXTS);
+ //unregister our dynamic client contexts
for (IClientContext clientContext : clientContexts) {
ClientContextManager.getInstance().deregisterClientContext(clientContext);
}
- elementTypeSetConfigurationResourceSet = createResourceSet();
+ // unload all resources we loaded
+ for (Resource resource : new ArrayList<Resource>(elementTypeSetConfigurationResourceSet.getResources())) {
+ resource.unload();
+ elementTypeSetConfigurationResourceSet.getResources().remove(resource);
+ }
+
elementTypeSetConfigurations.clear();
advicesDeps.clear();
clientContexts.clear();
@@ -203,12 +237,12 @@ public class ElementTypeSetConfigurationRegistry {
public OrientedGraph<String> getAdvicesDeps(String elementTypeID, String clientContextID) {
Map<String, OrientedGraph<String>> allDependencies = advicesDeps.get(clientContextID);
if (allDependencies == null) {
- allDependencies = new HashMap<String, OrientedGraph<String>>();
+ allDependencies = new HashMap<>();
advicesDeps.put(clientContextID, allDependencies);
}
OrientedGraph<String> dependencies = allDependencies.get(elementTypeID);
if (dependencies == null) {
- dependencies = new OrientedGraph<String>();
+ dependencies = new OrientedGraph<>();
allDependencies.put(elementTypeID, dependencies);
}
return dependencies;
@@ -300,10 +334,10 @@ public class ElementTypeSetConfigurationRegistry {
clientContexts.add(context);
}
- Map<String, ElementTypeConfiguration> elementTypeConfigurationsDefinitions = new HashMap<String, ElementTypeConfiguration>();
+ Map<String, ElementTypeConfiguration> elementTypeConfigurationsDefinitions = new HashMap<>();
// Read from elementTypeSetConfigurations
- Set<ElementTypeSetConfiguration> registrableElementTypeSetConfiguration = new HashSet<ElementTypeSetConfiguration>();
+ Set<ElementTypeSetConfiguration> registrableElementTypeSetConfiguration = new HashSet<>();
for (ElementTypeSetConfiguration elementTypeSetConfiguration : elementTypeSetConfigurationsToRegister) {
if (elementTypeSetConfiguration == null) {
Activator.log.warn("The collection of elementTypesconfigurations contains a null value. Loading aborted. ");
@@ -325,7 +359,7 @@ public class ElementTypeSetConfigurationRegistry {
Activator.log.warn(diagnostic.getMessage());
Iterator<Diagnostic> it = diagnostic.getChildren().iterator();
while (it.hasNext()) {
- Diagnostic childDiagnostic = (Diagnostic) it.next();
+ Diagnostic childDiagnostic = it.next();
switch (childDiagnostic.getSeverity()) {
case Diagnostic.ERROR:
case Diagnostic.WARNING:
@@ -336,7 +370,7 @@ public class ElementTypeSetConfigurationRegistry {
}
// Check there is no cyclic dependencies among elementTypes introduced by this loading
- HashSet<ElementTypeConfiguration> elementTypesToCheck = new HashSet<ElementTypeConfiguration>();
+ HashSet<ElementTypeConfiguration> elementTypesToCheck = new HashSet<>();
// The old ones already registered
if (elementTypeSetConfigurations.containsKey(contextId)) {
for (ElementTypeSetConfiguration elementTypeSetConfiguration : elementTypeSetConfigurations.get(contextId).values()) {
@@ -354,13 +388,13 @@ public class ElementTypeSetConfigurationRegistry {
}
// Collect all advicesconfiguration
- HashSet<AdviceConfiguration> adviceToCheck = new HashSet<AdviceConfiguration>();
+ HashSet<AdviceConfiguration> adviceToCheck = new HashSet<>();
// The old ones already registered
if (elementTypeSetConfigurations.containsKey(contextId)) {
for (ElementTypeSetConfiguration elementTypeSetConfiguration : elementTypeSetConfigurations.get(contextId).values()) {
TreeIterator<EObject> it = elementTypeSetConfiguration.eAllContents();
while (it.hasNext()) {
- EObject element = (EObject) it.next();
+ EObject element = it.next();
if (element instanceof AdviceConfiguration) {
adviceToCheck.add((AdviceConfiguration) element);
}
@@ -372,7 +406,7 @@ public class ElementTypeSetConfigurationRegistry {
for (ElementTypeSetConfiguration elementTypeSetConfiguration : registrableElementTypeSetConfiguration) {
TreeIterator<EObject> it = elementTypeSetConfiguration.eAllContents();
while (it.hasNext()) {
- EObject element = (EObject) it.next();
+ EObject element = it.next();
if (element instanceof AdviceConfiguration) {
adviceToCheck.add((AdviceConfiguration) element);
@@ -439,7 +473,7 @@ public class ElementTypeSetConfigurationRegistry {
// Remove elementTypes
ElementTypeRegistry registry = ElementTypeRegistry.getInstance();
- List<IElementType> elementTypes = new ArrayList<IElementType>(elementTypeSet.getElementTypeConfigurations().size());
+ List<IElementType> elementTypes = new ArrayList<>(elementTypeSet.getElementTypeConfigurations().size());
for (ElementTypeConfiguration elementTypeConfiguration : elementTypeSet.getElementTypeConfigurations()) {
if (elementTypeConfiguration != null && elementTypeConfiguration.getIdentifier() != null) {
String configIdentifier = elementTypeConfiguration.getIdentifier();
@@ -472,12 +506,12 @@ public class ElementTypeSetConfigurationRegistry {
}
// Recompute adviceDependencies
- HashSet<AdviceConfiguration> advices = new HashSet<AdviceConfiguration>();
+ HashSet<AdviceConfiguration> advices = new HashSet<>();
// The ones still registered
for (ElementTypeSetConfiguration elementTypeSetConfiguration : elementTypeSetConfigurations.get(contextId).values()) {
TreeIterator<EObject> it = elementTypeSetConfiguration.eAllContents();
while (it.hasNext()) {
- EObject element = (EObject) it.next();
+ EObject element = it.next();
if (element instanceof AdviceConfiguration) {
advices.add((AdviceConfiguration) element);
}
@@ -490,8 +524,6 @@ public class ElementTypeSetConfigurationRegistry {
return true;
}
-
-
protected void addElementTypeSetConfigurationToDefinitions(ElementTypeSetConfiguration set, String clientContextId, Map<String, Set<ElementTypeSetConfiguration>> existingDefinitions) {
if (set != null) {
if (set.getIdentifier() == null) {
@@ -542,7 +574,7 @@ public class ElementTypeSetConfigurationRegistry {
for (MergedArchitectureContext context : domain.getContexts()) {
Set<ElementTypeSetConfiguration> set = map.get(context.getId());
if (set == null)
- map.put(context.getId(), set = new HashSet<ElementTypeSetConfiguration>());
+ map.put(context.getId(), set = new HashSet<>());
set.addAll(context.getElementTypes());
}
}
@@ -553,9 +585,9 @@ public class ElementTypeSetConfigurationRegistry {
*/
protected void listenToArchitectureDomainManager() {
ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance();
- manager.addListener(new ArchitectureDomainManager.Listener() {
+ manager.addListener(new ArchitectureDomainManager.SpecificListener() {
@Override
- public void domainManagerChanged() {
+ public void addedModelsChanged() {
dispose();
init();
}
@@ -655,8 +687,7 @@ public class ElementTypeSetConfigurationRegistry {
}
protected ResourceSet createResourceSet() {
- ResourceSet set = new ResourceSetImpl();
- return set;
+ return new ResourceSetImpl();
}
public Map<String, Map<String, ElementTypeSetConfiguration>> getElementTypeSetConfigurations() {
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF
index 69b4e7376cd..51df8401427 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.0.0,4.0.0)",
org.eclipse.emf.edit.ui;bundle-version="[2.0.0,3.0.0)",
org.eclipse.ui.ide;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.types.edit;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.jface.text;bundle-version="[3.13.0,4.0.0)",
org.eclipse.papyrus.infra.architecture;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.core.architecture.edit;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.architecture.representation.edit;bundle-version="[1.0.0,2.0.0)",
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java
index ec2c891d32e..bb6a5fc762f 100755
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java
@@ -20,7 +20,6 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
@@ -28,8 +27,8 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.contentassist.BoldStylerProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
@@ -45,31 +44,26 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.window.ToolTip;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainMerger;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainPreferences;
import org.eclipse.papyrus.infra.core.architecture.ADElement;
import org.eclipse.papyrus.infra.core.architecture.merged.MergedADElement;
import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureDomain;
import org.eclipse.papyrus.infra.ui.architecture.ArchitectureUIPlugin;
-import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
-import org.eclipse.papyrus.infra.architecture.ArchitectureDomainPreferences;
-import org.eclipse.papyrus.infra.architecture.ArchitectureDomainMerger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.ui.IWorkbench;
@@ -87,14 +81,7 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
public static final String PAGE_ID = ArchitectureContextPreferencePage.class.getName();
//A bold style
- private static final Styler BOLD_FONT_STYLER = new Styler() {
- @Override
- public void applyStyles(TextStyle textStyle) {
- FontDescriptor boldDescriptor = FontDescriptor.createFrom(new FontData()).setStyle(SWT.ITALIC|SWT.BOLD);
- Font boldFont = boldDescriptor.createFont(Display.getCurrent());
- textStyle.font = boldFont;
- }
- };
+ private BoldStylerProvider boldStylerProvider;
// Contexts viewer
private CheckboxTreeViewer fContextsViewer;
@@ -119,16 +106,28 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
public ArchitectureContextPreferencePage() {
fComposedAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
fMerger = ArchitectureDomainManager.getInstance().getMerger().clone();
- fPreferences = ArchitectureDomainManager.getInstance().getPreferences().clone();
+ fPreferences = new ArchitectureDomainPreferences();
}
@Override
public Control createContents(Composite parent) {
+ boldStylerProvider = new BoldStylerProvider(parent.getFont());
Composite container = createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
createArchitectureContextsGroup(container);
Dialog.applyDialogFont(container);
return container;
}
+
+ /**
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ if (boldStylerProvider != null)
+ boldStylerProvider.dispose();
+ super.dispose();
+ }
/**
* Creates the Architecture Context group in the page
@@ -154,7 +153,7 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
if (element instanceof MergedArchitectureContext) {
MergedArchitectureContext context = (MergedArchitectureContext)element;
if (context.getId() != null && context.getId().equals(fPreferences.getDefaultContextId()))
- return new StyledString(element.getName(), BOLD_FONT_STYLER);
+ return new StyledString(element.getName(), boldStylerProvider.getBoldStyler());
}
return new StyledString(element.getName());
}
@@ -164,7 +163,7 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
ADElement imageObject = element.getImageObject();
if (imageObject != null && imageObject.getIcon() != null) {
try {
- URL image = new URL(imageObject.getIcon().toString());
+ URL image = new URL(imageObject.getIcon());
return getImageFromObject(image);
} catch (MalformedURLException e) {
ArchitectureUIPlugin.log.error(e);
@@ -203,6 +202,7 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
});
fContextsViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider));
fContextsViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object e1, Object e2) {
String name1 = labelProvider.getStyledText(e1).getString();
String name2 = labelProvider.getStyledText(e2).getString();
@@ -255,6 +255,8 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
fOtherButton = createPushButton(buttonComposite, "Other Architecture Models...", null, SWT.PUSH);
fOtherButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
public void widgetSelected(SelectionEvent e) {
handleOther();
}
@@ -290,6 +292,7 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
}
});
fDescription.setLabelProvider(new LabelProvider() {
+ @Override
public String getText(Object element) {
return ((MergedADElement)element).getDescription();
}
@@ -331,8 +334,6 @@ public class ArchitectureContextPreferencePage extends PreferencePage implements
MergedADElement selected = (MergedADElement) selection.getFirstElement();
if (selected instanceof MergedArchitectureContext) {
fDefaultButton.setEnabled(true);
- //ArchitectureContext context = (ArchitectureContext)selected;
- //fDefaultButton.setSelection(context.getId().equals(fPreferences.getDefaultContextId()));
return;
}
}
diff --git a/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableLabelProviderTest.java b/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableLabelProviderTest.java
index 76532712468..d657d945d93 100644
--- a/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableLabelProviderTest.java
+++ b/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableLabelProviderTest.java
@@ -23,6 +23,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainPreferences;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureDescriptionLanguage;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureDomain;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureFactory;
@@ -55,6 +56,7 @@ public class TableLabelProviderTest {
private Package package_;
private PapyrusTable proto;
private Table table;
+ private ArchitectureDomainPreferences preferences;
@Test
public void getText_namedTable() {
@@ -140,7 +142,9 @@ public class TableLabelProviderTest {
language.getViewpoints().add(viewpoint);
ArchitectureDomainManager.getInstance().getMerger().setDynamicDomains(Collections.singleton(domain));
- ArchitectureDomainManager.getInstance().getPreferences().setDefaultContextId("Testing.TestTable");
+ preferences = new ArchitectureDomainPreferences();
+ preferences.setDefaultContextId("Testing.TestTable");
+ preferences.write();
package_ = UMLFactory.eINSTANCE.createPackage();
package_.setName("foo");
@@ -155,6 +159,7 @@ public class TableLabelProviderTest {
@After
public void teardown() {
ArchitectureDomainManager.getInstance().getMerger().setDynamicDomains(Collections.emptyList());
- ArchitectureDomainManager.getInstance().getPreferences().setDefaultContextId(TypeContext.getDefaultContextId());
+ preferences.setDefaultContextId(TypeContext.getDefaultContextId());
+ preferences.write();
}
}

Back to the top