diff options
| author | Laurent Redor | 2015-01-16 12:27:42 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-01-22 17:37:29 +0000 |
| commit | 7e115ca26ca2ada4f6e298cb627b066189a533b1 (patch) | |
| tree | a1ba9ecc4fcb0ceb76102a22af50cbfbc4b23372 | |
| parent | 9211b37ab242747dd461fdff9783118c14352c3c (diff) | |
| download | org.eclipse.sirius-7e115ca26ca2ada4f6e298cb627b066189a533b1.tar.gz org.eclipse.sirius-7e115ca26ca2ada4f6e298cb627b066189a533b1.tar.xz org.eclipse.sirius-7e115ca26ca2ada4f6e298cb627b066189a533b1.zip | |
[457678] Minimize calls to getDiagramElementMapping
Can be costly in some implementation, CDO Native for example
Bug: 457678
Change-Id: I04aeb1e014b88b0d77f7d219ab39c4314076216a
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
3 files changed, 31 insertions, 21 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java index de55cddeb0..6299e64894 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter; import org.eclipse.sirius.common.tools.api.profiler.ProfilerTask; import org.eclipse.sirius.common.tools.api.util.StringUtil; import org.eclipse.sirius.diagram.DDiagramElement; +import org.eclipse.sirius.diagram.description.DiagramElementMapping; import org.eclipse.sirius.diagram.sequence.business.internal.util.EventFinder; import org.eclipse.sirius.diagram.sequence.business.internal.util.ParentOperandFinder; import org.eclipse.sirius.diagram.sequence.description.DescriptionPackage; @@ -86,17 +87,20 @@ public abstract class AbstractFrame extends AbstractSequenceNode implements ISeq Collection<Lifeline> coveredLifelines = Lists.newArrayList(); EObject element = getNotationNode().getElement(); - if (element instanceof DDiagramElement && ((DDiagramElement) element).getDiagramElementMapping() instanceof FrameMapping) { + if (element instanceof DDiagramElement) { DDiagramElement dde = (DDiagramElement) element; - FrameMapping mapping = (FrameMapping) dde.getDiagramElementMapping(); - EObject semanticInteractionUse = dde.getTarget(); - IInterpreter interpreter = InterpreterUtil.getInterpreter(semanticInteractionUse); - - if (interpreter != null && !StringUtil.isEmpty(mapping.getCoveredLifelinesExpression())) { - try { - semLifelines = interpreter.evaluateCollection(semanticInteractionUse, mapping.getCoveredLifelinesExpression()); - } catch (final EvaluationException e) { - RuntimeLoggerManager.INSTANCE.error(mapping, DescriptionPackage.eINSTANCE.getFrameMapping_CoveredLifelinesExpression(), e); + DiagramElementMapping diagramElementMapping = dde.getDiagramElementMapping(); + if (diagramElementMapping instanceof FrameMapping) { + FrameMapping mapping = (FrameMapping) diagramElementMapping; + EObject semanticInteractionUse = dde.getTarget(); + IInterpreter interpreter = InterpreterUtil.getInterpreter(semanticInteractionUse); + + if (interpreter != null && !StringUtil.isEmpty(mapping.getCoveredLifelinesExpression())) { + try { + semLifelines = interpreter.evaluateCollection(semanticInteractionUse, mapping.getCoveredLifelinesExpression()); + } catch (final EvaluationException e) { + RuntimeLoggerManager.INSTANCE.error(mapping, DescriptionPackage.eINSTANCE.getFrameMapping_CoveredLifelinesExpression(), e); + } } } } diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractSequenceElement.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractSequenceElement.java index 9f3336e7f8..e48eeac2be 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractSequenceElement.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractSequenceElement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2013 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -61,12 +61,15 @@ public abstract class AbstractSequenceElement extends AdapterImpl implements ISe */ protected static final boolean isSequenceDiagramElement(DDiagramElement element, EClass mappingType) { Preconditions.checkNotNull(mappingType); - if (element == null || element.getDiagramElementMapping() == null) { - return false; - } else { - DiagramElementMapping mappingToCheck = new DiagramElementMappingQuery(element.getDiagramElementMapping()).getRootMapping(); - return mappingType.isInstance(mappingToCheck) && SequenceDiagram.viewpointElementPredicate().apply(element.getParentDiagram()); + boolean result = false; + if (element != null) { + DiagramElementMapping mapping = element.getDiagramElementMapping(); + if (mapping != null) { + DiagramElementMapping mappingToCheck = new DiagramElementMappingQuery(mapping).getRootMapping(); + result = mappingType.isInstance(mappingToCheck) && SequenceDiagram.viewpointElementPredicate().apply(element.getParentDiagram()); + } } + return result; } /** diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ISequenceElementSwitch.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ISequenceElementSwitch.java index 9fc06b9bec..0da4b0bfd4 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ISequenceElementSwitch.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ISequenceElementSwitch.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2013 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -66,9 +66,12 @@ public class ISequenceElementSwitch<T> { if (element.getNotationView().getElement() instanceof DDiagramElement) { dde = (DDiagramElement) element.getNotationView().getElement(); } - if (dde != null && dde.getDiagramElementMapping() != null) { - DiagramElementMapping mappingToCheck = new DiagramElementMappingQuery(dde.getDiagramElementMapping()).getRootMapping(); - return doSwitch(mappingToCheck, element); + if (dde != null) { + DiagramElementMapping mapping = dde.getDiagramElementMapping(); + if (mapping != null) { + DiagramElementMapping mappingToCheck = new DiagramElementMappingQuery(mapping).getRootMapping(); + return doSwitch(mappingToCheck, element); + } } return null; } |
