Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2021-08-17 15:41:10 +0000
committerMaxime Porhel2021-08-18 07:17:46 +0000
commit20ac71eddf227b0c7a6dc52ac47723ce1dbc3089 (patch)
tree456ae92242fbb6f99ea650154bdeb3158991f0dc /plugins
parentb74f9199d5f114bf5c791c32bb8935b7e3587d24 (diff)
downloadorg.eclipse.sirius-20ac71eddf227b0c7a6dc52ac47723ce1dbc3089.tar.gz
org.eclipse.sirius-20ac71eddf227b0c7a6dc52ac47723ce1dbc3089.tar.xz
org.eclipse.sirius-20ac71eddf227b0c7a6dc52ac47723ce1dbc3089.zip
[531282] Optimize mappings checks in DDS::processEdgeMappingsRefresh
This change has no impact on DiagramDescription with no EdgeMapping with EdgeMapping references as source/target mapping. When a diagram description contains a EdgeMapping with another EdgeMapping as source or target mapping, there is no need to compute the full structure of edge, node and container mappings each time we want to test that the referenced mapping belongs to the current description. The predicate has been move to the calling method as those information is already available. It is now passed as parameter and only edge mappings checks are done. Bug: 531282 Change-Id: I28ab96dbdaa0e1b5137107829dae01d34446b288 Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/sync/DDiagramSynchronizer.java66
1 files changed, 26 insertions, 40 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/sync/DDiagramSynchronizer.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/sync/DDiagramSynchronizer.java
index 318609f64a..4ed91e2ab4 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/sync/DDiagramSynchronizer.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/sync/DDiagramSynchronizer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2009, 2021 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -74,7 +74,6 @@ import org.eclipse.sirius.diagram.business.api.query.IEdgeMappingQuery;
import org.eclipse.sirius.diagram.business.api.refresh.RefreshExtensionService;
import org.eclipse.sirius.diagram.business.internal.helper.decoration.DecorationHelperInternal;
import org.eclipse.sirius.diagram.business.internal.metamodel.description.operations.EdgeMappingImportWrapper;
-import org.eclipse.sirius.diagram.business.internal.metamodel.helper.ContentHelper;
import org.eclipse.sirius.diagram.business.internal.metamodel.helper.EdgeMappingHelper;
import org.eclipse.sirius.diagram.business.internal.metamodel.helper.LayerHelper;
import org.eclipse.sirius.diagram.business.internal.metamodel.helper.MappingHelper;
@@ -324,13 +323,9 @@ public class DDiagramSynchronizer {
EqualityHelper.setUriFragmentCacheEnabled(true);
LayerHelper.setActiveParentLayersCacheEnabled(diagramMappingsManager, true);
- // Semantic changes should be possible when a representation
- // representation
- // is locked (CDO)
- // We launch a refresh only if the diagram can be edited
- // so that the refresh does not lead to the modification of
- // non-editable
- // elements and hence cause a Rollback
+ // Semantic changes should be possible when a representation representation is locked (CDO).
+ // We launch a refresh only if the diagram can be edited so that the refresh does not lead to the
+ // modification of non-editable elements and hence cause a Rollback
if (this.accessor.getPermissionAuthority().canEditInstance(diagram)) {
RuntimeLoggerManager.INSTANCE.clear(this.description);
@@ -340,9 +335,7 @@ public class DDiagramSynchronizer {
final Map<EdgeMapping, Collection<MappingBasedDecoration>> edgeToMappingBasedDecoration = new HashMap<EdgeMapping, Collection<MappingBasedDecoration>>();
final Map<String, Collection<SemanticBasedDecoration>> edgeToSemanticBasedDecoration = new HashMap<String, Collection<SemanticBasedDecoration>>();
- /*
- * retrieve mappings
- */
+ // retrieve mappings
final List<NodeMapping> nodeMappings = diagramMappingsManager.getNodeMappings();
final List<EdgeMapping> edgeMappings = diagramMappingsManager.getEdgeMappings();
final List<ContainerMapping> containerMappings = diagramMappingsManager.getContainerMappings();
@@ -350,30 +343,27 @@ public class DDiagramSynchronizer {
RefreshExtensionService.getInstance().beforeRefresh(this.diagram);
boolean override = RefreshExtensionService.getInstance().aroundRefresh(this.diagram);
-
if (!override) {
final int mappingNumbers = nodeMappings.size() + edgeMappings.size() + containerMappings.size();
monitor.beginTask(Messages.DDiagramSynchronizer_refreshMappingsMsg, mappingNumbers);
- /*
- * compute a first time the cache with old mappings => updater need the cache
- */
+ // compute a first time the cache with old mappings => updater need the cache
computePreviousCandidatesCache();
- /* update mappings */
+ // update mappings
mappingsUpdater.updateMappings();
- /* compute a second time the cache with updated mapping */
+ // compute a second time the cache with updated mapping
computePreviousCandidatesCache();
fillIgnoredElements();
final Set<DNodeCandidate> elementsCreated = LayerService.withoutLayersMode(description) ? null : new HashSet<DNodeCandidate>();
- /* Let's refresh the node mappings. */
+ // Let's refresh the node mappings.
for (final NodeMapping mapping : nodeMappings) {
refreshNodeMapping(mappingsToEdgeTargets, this.diagram, mapping, elementsCreated, new SubProgressMonitor(monitor, 1));
}
- /* Let's refresh the container mappings */
+ // Let's refresh the container mappings
if (elementsCreated != null) {
elementsCreated.clear();
}
@@ -382,29 +372,31 @@ public class DDiagramSynchronizer {
refreshContainerMapping(mappingsToEdgeTargets, this.diagram, mapping, elementsCreated, false, false, new SubProgressMonitor(monitor, 1));
}
- /* handle multiple importers . */
+ // handle multiple importers.
handleImportersIssues();
- /* Compute the decorations. */
+ // Compute the decorations.
decorationHelper.computeDecorations(mappingsToEdgeTargets, edgeToSemanticBasedDecoration, edgeToMappingBasedDecoration);
- /*
- * now all the nodes/containers are done and ready in the mappintToEdgeTarget map.
- */
+ // now all the nodes/containers are done and ready in the mappintToEdgeTarget map.
edgesDones = new HashSet<DDiagramElement>();
- processEdgeMappingsRefresh(edgeMappings, mappingsToEdgeTargets, edgeToMappingBasedDecoration, edgeToSemanticBasedDecoration, monitor);
+ // @formatter:off
+ Predicate<EdgeMapping> isEdgeMappingOfCurrentDiagramDescription = edgeMapping -> edgeMappings.contains(edgeMapping);
+ // @formatter:on
+
+ processEdgeMappingsRefresh(edgeMappings, mappingsToEdgeTargets, edgeToMappingBasedDecoration, edgeToSemanticBasedDecoration, isEdgeMappingOfCurrentDiagramDescription, monitor);
edgesDones.clear();
deleteIgnoredElementsAndDuplicates();
- /* Garbage collect orphan computed StyleDescription. */
+ // Garbage collect orphan computed StyleDescription.
removeOrphanComputedStyleDescriptions();
}
RefreshExtensionService.getInstance().postRefresh(this.diagram);
- /* We can now clear the cache. */
+ // We can now clear the cache.
clearCache();
}
KeyCache.DEFAULT.clear();
@@ -424,27 +416,21 @@ public class DDiagramSynchronizer {
* map of refreshed EdgeMapping
* @param edgeToMappingBasedDecoration
* @param edgeToSemanticBasedDecoration
+ * @param isEdgeMappingOfCurrentDiagramDescription
* @param monitor
* the current Monitor
*/
private void processEdgeMappingsRefresh(List<EdgeMapping> edgeMappings, final Map<DiagramElementMapping, Collection<EdgeTarget>> mappingsToEdgeTargets,
Map<EdgeMapping, Collection<MappingBasedDecoration>> edgeToMappingBasedDecoration, Map<String, Collection<SemanticBasedDecoration>> edgeToSemanticBasedDecoration,
- final IProgressMonitor monitor) {
-
- // @formatter:off
- Predicate<DiagramElementMapping> isMappingOfCurrentDiagramDescription = diagramElementMapping ->
- ContentHelper.getAllEdgeMappings(description, false).contains(diagramElementMapping) ||
- ContentHelper.getAllNodeMappings(description, false).contains(diagramElementMapping) ||
- ContentHelper.getAllContainerMappings(description, false).contains(diagramElementMapping);
- // @formatter:on
+ final Predicate<EdgeMapping> isEdgeMappingOfCurrentDiagramDescription, final IProgressMonitor monitor) {
Predicate<EdgeMapping> edgeMappingWithoutEdgeAsSourceOrTarget = new Predicate<EdgeMapping>() {
@Override
public boolean apply(EdgeMapping input) {
// Valid if source mapping and target mapping are not
// EdgeMappings
- Iterable<EdgeMapping> edgeSourceMappings = Iterables.filter(Iterables.filter(input.getSourceMapping(), EdgeMapping.class), isMappingOfCurrentDiagramDescription);
- Iterable<EdgeMapping> edgeTargetMappings = Iterables.filter(Iterables.filter(input.getTargetMapping(), EdgeMapping.class), isMappingOfCurrentDiagramDescription);
+ Iterable<EdgeMapping> edgeSourceMappings = Iterables.filter(Iterables.filter(input.getSourceMapping(), EdgeMapping.class), isEdgeMappingOfCurrentDiagramDescription);
+ Iterable<EdgeMapping> edgeTargetMappings = Iterables.filter(Iterables.filter(input.getTargetMapping(), EdgeMapping.class), isEdgeMappingOfCurrentDiagramDescription);
return Iterables.isEmpty(edgeSourceMappings) && Iterables.isEmpty(edgeTargetMappings);
}
};
@@ -469,8 +455,8 @@ public class DDiagramSynchronizer {
// Valid if the EdgeMapping is not refresh and the source or
// target EdgeMapping has been refreshed
boolean result = !mappingsToEdgeTargets.keySet().contains(input);
- Iterable<EdgeMapping> edgeSourceMappings = Iterables.filter(Iterables.filter(input.getSourceMapping(), EdgeMapping.class), isMappingOfCurrentDiagramDescription);
- Iterable<EdgeMapping> edgeTargetMappings = Iterables.filter(Iterables.filter(input.getTargetMapping(), EdgeMapping.class), isMappingOfCurrentDiagramDescription);
+ Iterable<EdgeMapping> edgeSourceMappings = Iterables.filter(Iterables.filter(input.getSourceMapping(), EdgeMapping.class), isEdgeMappingOfCurrentDiagramDescription);
+ Iterable<EdgeMapping> edgeTargetMappings = Iterables.filter(Iterables.filter(input.getTargetMapping(), EdgeMapping.class), isEdgeMappingOfCurrentDiagramDescription);
return result && Iterables.all(edgeSourceMappings, refreshedEdgeMapping) && Iterables.all(edgeTargetMappings, refreshedEdgeMapping);
}
};

Back to the top