Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src')
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramCommand.java57
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramWithNavigationHandler.java25
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/ObservationLinkMetamodelType.java38
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramCreationCondition.java35
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramEditorFactory.java30
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/UmlSequenceDiagramForMultiEditor.java117
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/ChangeEdgeTargetCommand.java79
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateElementAndNodeCommand.java185
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateLocatedConnectionViewCommand.java239
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java108
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomZOrderCommand.java57
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/PromptCreateElementAndNodeCommand.java139
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java796
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java390
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java194
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ExecutionSpecificationEndEditPart.java595
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java206
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentCreationEditPolicy.java162
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentItemComponentEditPolicy.java90
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java124
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomConnectionHandleEditPolicy.java64
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java1188
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExternalLabelPrimaryDragRoleEditPolicy.java67
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java461
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionEventComponentEditPolicy.java43
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ElementCreationWithMessageEditPolicy.java117
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationComponentEditPolicy.java71
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java69
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/HighlightConnectionPartEditPolicy.java46
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java789
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandComponentEditPolicy.java90
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java71
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandLayoutEditPolicy.java108
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineAppliedStereotypeNodeLabelDisplayEditPolicy.java39
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java237
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineCreationEditPolicy.java202
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java207
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java927
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionEditPolicy.java54
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java332
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java1000
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MoveableNonResizableLabelEditPolicy.java184
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java728
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java34
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java517
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java39
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CoRegionCombinedFragmentFigure.java129
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CombinedFragmentFigure.java56
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java66
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/EllipseDecoration.java51
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionOperandFigure.java45
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionUseRectangleFigure.java59
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineDotLineCustomFigure.java188
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java232
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/ContinuationLocator.java83
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeMarkElementPositionLocator.java386
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java120
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/InteractionUseCustomParsers.java146
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/LifelineCustomParsers.java198
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java111
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeConstraintParser.java273
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeObservationParser.java122
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java94
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java471
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentDeleteHelper.java323
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CommandHelper.java1203
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DestructionOccurrenceUtil.java71
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/EventHelper.java234
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/HighlightUtil.java272
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java40
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionUseUtil.java49
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineCoveredByUpdater.java138
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java170
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java263
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineModelChildrenHelper.java90
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java106
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LoopOperatorUtil.java53
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java56
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/NotificationHelper.java74
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java1126
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java837
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/PreferencesModelElementFactory.java14
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/ReconnectMessageHelper.java182
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectOrCreateDialog.java647
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java371
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceLinkMappingHelper.java126
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceRequestConstant.java54
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java1713
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/FragmentOrderingKeeper.java823
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/UMLValidationHelper.java106
90 files changed, 0 insertions, 23321 deletions
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramCommand.java
deleted file mode 100644
index 03e5c385d8c..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramCommand.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
-import org.eclipse.papyrus.uml.diagram.common.commands.CreateBehavioredClassifierDiagramCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Define a command to create a new Sequence Diagram. This command is used by all UI (toolbar,
- * outline, creation wizards) to create a new Sequence Diagram.
- */
-public class CreateSequenceDiagramCommand extends CreateBehavioredClassifierDiagramCommand {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getDiagramNotationID() {
- return PackageEditPart.MODEL_ID;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected PreferencesHint getPreferenceHint() {
- return UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getDefaultDiagramName() {
- return "SeqDiagram"; //$NON-NLS-1$
- }
-
- @Override
- protected EClass getBehaviorEClass() {
- return UMLPackage.eINSTANCE.getInteraction();
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramWithNavigationHandler.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramWithNavigationHandler.java
deleted file mode 100644
index 4b2f56c87c2..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/CreateSequenceDiagramWithNavigationHandler.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence;
-
-import org.eclipse.papyrus.infra.gmfdiag.navigation.CreateDiagramWithNavigationHandler;
-
-
-public class CreateSequenceDiagramWithNavigationHandler extends CreateDiagramWithNavigationHandler {
-
- public CreateSequenceDiagramWithNavigationHandler() {
- super(new CreateSequenceDiagramCommand(), new SequenceDiagramCreationCondition());
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/ObservationLinkMetamodelType.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/ObservationLinkMetamodelType.java
deleted file mode 100644
index b1b26cd645b..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/ObservationLinkMetamodelType.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence;
-
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.gmf.runtime.emf.type.core.MetamodelType;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
-import org.eclipse.gmf.runtime.emf.type.core.internal.descriptors.MetamodelTypeDescriptor;
-import org.eclipse.gmf.runtime.emf.type.core.internal.l10n.EMFTypeCoreMessages;
-
-public class ObservationLinkMetamodelType extends MetamodelType {
-
- public static final String ID = "org.eclipse.papyrus.uml.diagram.sequence.emf.type.core.observationlink"; //$NON-NLS-1$
-
- private static final ObservationLinkMetamodelType INSTANCE = new ObservationLinkMetamodelType();
- private static final MetamodelTypeDescriptor DESCRIPTOR_INSTANCE = new MetamodelTypeDescriptor(
- INSTANCE);
-
- /**
- * Initializes me.
- */
- private ObservationLinkMetamodelType() {
- super(ID, null, EMFTypeCoreMessages.defaultEditHelper_name,
- EcorePackage.Literals.EOBJECT, new DefaultEditHelper());
- }
-
- public static ObservationLinkMetamodelType getInstance() {
- return INSTANCE;
- }
-
- public static MetamodelTypeDescriptor getDescriptorInstance() {
- return DESCRIPTOR_INSTANCE;
- }
-
- private static class DefaultEditHelper extends AbstractEditHelper {
- DefaultEditHelper() {
- super();
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramCreationCondition.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramCreationCondition.java
deleted file mode 100644
index 51c75bae096..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramCreationCondition.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * Atos Origin - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.infra.core.extension.commands.PerspectiveContextDependence;
-import org.eclipse.uml2.uml.Interaction;
-
-/**
- * SequenceDiagramCreationCondition class allows to check if a Sequence diagram can be added to the
- * selected element.
- */
-public class SequenceDiagramCreationCondition extends PerspectiveContextDependence {
-
- /**
- * @return whether the diagram can be created.
- */
- public boolean create(EObject selectedElement) {
- if(super.create(selectedElement)) {
- // TODO : to specify according to the spec
- return selectedElement instanceof Interaction;
- }
- return false;
- }
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramEditorFactory.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramEditorFactory.java
deleted file mode 100644
index 32c702571bb..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/SequenceDiagramEditorFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence;
-
-import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.PackageEditPart;
-
-/**
- * The editor factory to launch the sequence diagram.
- */
-public class SequenceDiagramEditorFactory extends GmfEditorFactory {
-
- /**
- * Instantiates a new sequence diagram editor factory.
- */
- public SequenceDiagramEditorFactory() {
- super(UmlSequenceDiagramForMultiEditor.class, PackageEditPart.MODEL_ID);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/UmlSequenceDiagramForMultiEditor.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/UmlSequenceDiagramForMultiEditor.java
deleted file mode 100644
index 21941bf46e5..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/UmlSequenceDiagramForMultiEditor.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.ui.URIEditorInput;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.papyrus.infra.core.editor.BackboneException;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditor;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-
-/**
- * Editor used in multitabs editor.
- */
-public class UmlSequenceDiagramForMultiEditor extends UMLDiagramEditor {
-
- /**
- * The location of diagram icon in the plug-in
- */
- private static final String DIAG_IMG_PATH = "icons/obj16/Diagram_Sequence.gif";
-
- /**
- * The image descriptor of the diagram icon
- */
- private static final ImageDescriptor DIAG_IMG_DESC = UMLDiagramEditorPlugin.getBundledImageDescriptor(UmlSequenceDiagramForMultiEditor.DIAG_IMG_PATH);
-
- /** The editor splitter. */
- private Composite splitter;
-
- /**
- * Constructor for SashSystem v2. Context and required objects are retrieved from the
- * ServiceRegistry.
- *
- * @throws BackboneException
- * @throws ServiceException
- */
- public UmlSequenceDiagramForMultiEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws BackboneException, ServiceException {
- super(servicesRegistry, diagram);
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.init(site, input);
- setPartName(getDiagram().getName());
- setTitleImage(DIAG_IMG_DESC.createImage());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setInput(IEditorInput input) {
- try {
- // Provide an URI with fragment in order to reuse the same Resource
- // and set the diagram to the fragment.
- URIEditorInput uriInput = new URIEditorInput(EcoreUtil.getURI(getDiagram()));
- doSetInput(uriInput, true);
- } catch (CoreException x) {
- String title = "Problem opening";
- String msg = "Cannot open input element:";
- Shell shell = getSite().getShell();
- ErrorDialog.openError(shell, title, msg, x.getStatus());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void createGraphicalViewer(Composite parent) {
- splitter = parent;
- super.createGraphicalViewer(parent);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setFocus() {
- splitter.setFocus();
- super.setFocus();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getEditingDomainID() {
- return "org.eclipse.papyrus.uml.diagram.sequence.EditingDomain";
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/ChangeEdgeTargetCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/ChangeEdgeTargetCommand.java
deleted file mode 100644
index 2fe630f70dd..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/ChangeEdgeTargetCommand.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.IdentityAnchor;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-
-
-/**
- * Command used to change the target of an edge.
- * It create an IdentityAnchor to attach the edge.
- *
- * @author Mathieu Velten
- *
- */
-public class ChangeEdgeTargetCommand extends AbstractTransactionalCommand {
-
- protected CreateElementAndNodeCommand createElementAndNodeCommand;
-
- protected ConnectionViewDescriptor descriptor;
-
- protected String anchorId;
-
- /**
- *
- * @param editingDomain
- * the editing domain.
- * @param createElementAndNodeCommand
- * used to retrieve the target new node of the edge.
- * @param descriptor
- * used to retrieve the edge.
- * @param anchorId
- * the identity of the anchor which will be created to attach the edge.
- */
- public ChangeEdgeTargetCommand(TransactionalEditingDomain editingDomain, CreateElementAndNodeCommand createElementAndNodeCommand, ConnectionViewDescriptor descriptor, String anchorId) {
- super(editingDomain, "Change message graphical target", null);
- this.createElementAndNodeCommand = createElementAndNodeCommand;
- this.descriptor = descriptor;
- this.anchorId = anchorId;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
-
- // retrieve the edge from the descriptor
- Object obj = descriptor.getAdapter(Edge.class);
-
- if(obj instanceof Edge) {
- Edge edge = (Edge)obj;
- edge.setTarget(createElementAndNodeCommand.getCreatedView());
-
- IdentityAnchor anchor = NotationFactory.eINSTANCE.createIdentityAnchor();
- anchor.setId(anchorId);
-
- edge.setTargetAnchor(anchor);
- }
- return null;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateElementAndNodeCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateElementAndNodeCommand.java
deleted file mode 100644
index 2a65a13a786..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateElementAndNodeCommand.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.command;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
-import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * Command to create an element and its associated view.
- *
- * @author Mathieu Velten
- *
- */
-public class CreateElementAndNodeCommand extends AbstractTransactionalCommand {
-
- protected ShapeNodeEditPart nodeEditPart;
-
- protected Point location;
-
- protected EObject parent, element;
-
- protected TransactionalEditingDomain editingDomain;
-
- protected Command elementCreationCommand;
-
- protected Command nodeCreationCommand;
-
- protected Map<String, Object> createElementRequestParameters = new HashMap<String, Object>();
-
- protected IHintedType elementType;
-
- protected CreateViewRequest createViewRequest;
-
- private List affectedFiles;
-
- /**
- *
- * @param editingDomain
- * editingDomain the editing domain.
- * @param nodeEditPart
- * the editpart of the graphical parent of the node to create.
- * @param parent
- * the parent of the element to create.
- * @param elementType
- * the GMF type of the element which will be created.
- * @param location
- * the location where to create the element figure.
- */
- public CreateElementAndNodeCommand(TransactionalEditingDomain editingDomain, ShapeNodeEditPart nodeEditPart, EObject parent, IHintedType elementType, Point location) {
- super(editingDomain, "Create element and node command", null);
- this.nodeEditPart = nodeEditPart;
- this.location = location;
- this.parent = parent;
- this.editingDomain = editingDomain;
- this.elementType = elementType;
- }
-
- public List getAffectedFiles() {
- if (affectedFiles == null) {
- if (getCreatedView() != null) {
- affectedFiles = getWorkspaceFiles(getCreatedView());
- } else {
- affectedFiles = super.getAffectedFiles();
- }
- }
- return affectedFiles;
- }
-
- /**
- * put a parameter which will be add to the parameters of the element creation request.
- *
- * @param key
- * @param value
- */
- public void putCreateElementRequestParameter(String key, Object value) {
- createElementRequestParameters.put(key, value);
- }
-
- /**
- * retrieve the view associated with the created execution specification
- *
- * @return the view or null if not created/founded
- */
- public View getCreatedView() {
- if(createViewRequest != null) {
- List l = (List)createViewRequest.getNewObject();
- if(!l.isEmpty() && l.get(0) instanceof ViewDescriptor) {
- return (View)((ViewDescriptor)l.get(0)).getAdapter(View.class);
- }
- }
- return null;
- }
-
- public void undo() {
- if(nodeCreationCommand != null && nodeCreationCommand.canUndo()) {
- nodeCreationCommand.undo();
- }
- if(elementCreationCommand != null && elementCreationCommand.canUndo()) {
- elementCreationCommand.undo();
- }
- }
-
- /**
- * Create the element in the model.
- *
- * @return the element.
- */
- protected EObject createModelElement() {
-
- CreateElementRequest req = new CreateElementRequest(editingDomain, parent, elementType);
- req.addParameters(createElementRequestParameters);
-
- elementCreationCommand = nodeEditPart.getCommand(new EditCommandRequestWrapper(req));
-
- if(elementCreationCommand != null) {
- elementCreationCommand.execute();
- EObject result = req.getNewElement();
- if(result instanceof EObject) {
- return (EObject)result;
- }
- }
- return null;
- }
-
- /**
- * Create and execute the command to create the associated view.
- * The element needs to be created first using createModelElement.
- */
- protected void createElementView() {
- if(nodeEditPart != null) {
- // check if execution specification is already drawn
- if(getCreatedView() == null) {
- ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(new EObjectAdapter((EObject)element), Node.class, elementType.getSemanticHint(), nodeEditPart.getDiagramPreferencesHint());
- createViewRequest = new CreateViewRequest(descriptor);
- createViewRequest.setLocation(location);
- nodeCreationCommand = nodeEditPart.getCommand(createViewRequest);
- if(nodeCreationCommand != null && nodeCreationCommand.canExecute()) {
- nodeCreationCommand.execute();
- }
- }
- }
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- element = createModelElement();
- // create the view for the execution specification
- if(element != null) {
- createElementView();
- }
- return CommandResult.newOKCommandResult();
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateLocatedConnectionViewCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateLocatedConnectionViewCommand.java
deleted file mode 100644
index 5e180818161..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateLocatedConnectionViewCommand.java
+++ /dev/null
@@ -1,239 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.widgets.toolbox.notification.Type;
-import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
-import org.eclipse.papyrus.uml.diagram.common.commands.CommonDeferredCreateConnectionViewCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-
-/**
- * This class is used to create a connection view which source and target locations are defined. This is useful for connections linked to an
- * Occurrence Specification, which is located at a particular predefined point.
- *
- * @author vhemery
- */
-public class CreateLocatedConnectionViewCommand extends CommonDeferredCreateConnectionViewCommand {
-
- /** Point where source must be drawn */
- private Point sourceLocation;
-
- /** Point where target must be drawn */
- private Point targetLocation;
-
- /**
- * {@inheritDoc}
- */
- public CreateLocatedConnectionViewCommand(TransactionalEditingDomain editingDomain, String semanticHint, IAdaptable sourceViewAdapter, IAdaptable targetViewAdapter, EditPartViewer viewer, PreferencesHint preferencesHint, ConnectionViewDescriptor viewDescriptor, ICommand command) {
- super(editingDomain, semanticHint, sourceViewAdapter, targetViewAdapter, viewer, preferencesHint, viewDescriptor, command);
- }
-
- /**
- * {@inheritDoc}
- */
- public CreateLocatedConnectionViewCommand(TransactionalEditingDomain editingDomain, EObject element, IAdaptable sourceViewAdapter, IAdaptable targetViewAdapter, EditPartViewer viewer, PreferencesHint preferencesHint, ICommand command) {
- super(editingDomain, element, sourceViewAdapter, targetViewAdapter, viewer, preferencesHint, command);
- }
-
- /**
- * Creates a connection view between the source and target.
- *
- * @throws ExecutionException
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info, IGraphicalEditPart sourceEditPart, IGraphicalEditPart targetEditPart) throws ExecutionException {
-
- // If these are null, then the diagram's editparts may not
- // have been refreshed yet.
- Assert.isNotNull(sourceEditPart);
- Assert.isNotNull(targetEditPart);
-
- // use the String semanticHint to create a view
- // modification in order to fix the bug
- CreateConnectionViewRequest createRequest = new CreateConnectionViewRequest(viewDescriptor);
- createConnectionCmd = getCreateCommand(createRequest, sourceEditPart, targetEditPart);
-
- if(createConnectionCmd != null && createConnectionCmd.canExecute()) {
- createConnectionCmd.execute();
- if(element != null) {
- ((View)(createRequest.getConnectionViewDescriptor().getAdapter(View.class))).setElement(element);
- }
- } else {
- // connection can not be created
- handleErrorMessage(createRequest, sourceEditPart, targetEditPart);
- }
- viewer = null;// for garbage collection
- return CommandResult.newOKCommandResult();
- }
-
- /**
- * Method getCreateCommand Gets the command given a request, source and target edit parts. (No semantic element required.)
- * This method is similar to {@link CreateConnectionViewRequest#getCreateCommand(CreateConnectionViewRequest, EditPart, EditPart)}, except it
- * fixes source and target locations
- *
- * @param request
- * creation request
- * @param sourceEditPart
- * source edit part
- * @param targetEditPart
- * target edit part
- * @return <code>Command</code> to create the connection at appropriate locations
- */
- protected Command getCreateCommand(CreateConnectionViewRequest request, EditPart sourceEditPart, EditPart targetEditPart) {
- EditPart newSourceEditPart = sourceEditPart;
- // set appropriated source edit part
- if(sourceEditPart instanceof LifelineEditPart && sourceLocation != null) {
- newSourceEditPart = SequenceUtil.findPartToReconnectTo((LifelineEditPart)sourceEditPart, sourceLocation);
- }
- EditPart newTargetEditPart = targetEditPart;
- // set appropriated target edit part
- if(targetEditPart instanceof LifelineEditPart && targetLocation != null) {
- newTargetEditPart = SequenceUtil.findPartToReconnectTo((LifelineEditPart)targetEditPart, targetLocation);
- }
-
- Assert.isNotNull(request);
- Assert.isNotNull(sourceEditPart);
- Assert.isNotNull(targetEditPart);
- Assert.isNotNull(newSourceEditPart);
- Assert.isNotNull(newTargetEditPart);
-
- request.setSourceEditPart(sourceEditPart);
- request.setTargetEditPart(targetEditPart);
-
- request.setType(RequestConstants.REQ_CONNECTION_START);
- // set source location
- request.setLocation(sourceLocation);
- newSourceEditPart.getCommand(request);
-
- request.setType(RequestConstants.REQ_CONNECTION_END);
- // set target location
- request.setLocation(targetLocation);
- return newTargetEditPart.getCommand(request);
- }
-
- /**
- * Set the locations where source and target points must be drawn.
- *
- * @param sourcePoint
- * point where to draw source or null
- * @param targetPoint
- * point where to draw target or null
- */
- public void setLocations(Point sourcePoint, Point targetPoint) {
- sourceLocation = sourcePoint;
- targetLocation = targetPoint;
- }
-
- /**
- * Handle the failure by reporting an adequate error message
- *
- * @param createRequest
- * the creation request that didn't success
- * @param sourceEditPart
- * the link source edit part
- * @param targetEditPart
- * the target source edit part
- */
- private void handleErrorMessage(CreateConnectionViewRequest createRequest, IGraphicalEditPart sourceEditPart, IGraphicalEditPart targetEditPart) {
- String hint = createRequest.getConnectionViewDescriptor().getSemanticHint();
- boolean isMessage = isMessageHint(hint);
- boolean uphill = sourceLocation != null && targetLocation != null && sourceLocation.y > targetLocation.y;
- if(isMessage && uphill) {
- reportCanNotDropUphillMessage(sourceLocation.y - targetLocation.y, sourceEditPart, targetEditPart);
- } else {
- reportDefaultMessage(sourceEditPart, targetEditPart);
- }
- }
-
- /**
- * Test if hint is for a message creation
- *
- * @param hint
- * hint to test
- * @return true if message hint
- */
- private boolean isMessageHint(String hint) {
- List<String> messageHints = new ArrayList<String>(7);
- String messageHint = ((IHintedType)UMLElementTypes.Message_4003).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4004).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4005).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4006).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4007).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4008).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4009).getSemanticHint();
- messageHints.add(messageHint);
- return messageHints.contains(hint);
- }
-
- /**
- * Report a message telling that the message can not be dropped because it goes uphill.
- *
- * @param delta
- * the missing delta between the two lifelines
- * @param sourceEditPart
- * the source of the message
- * @param targetEditPart
- * the target of the message
- */
- private void reportCanNotDropUphillMessage(int delta, IGraphicalEditPart sourceEditPart, IGraphicalEditPart targetEditPart) {
- EObject source = sourceEditPart.resolveSemanticElement();
- String sourceText = EMFCoreUtil.getQualifiedName(source, true);
- EObject target = targetEditPart.resolveSemanticElement();
- String targetText = EMFCoreUtil.getQualifiedName(target, true);
- String txt = NLS.bind(Messages.DropError_UphillMessageTxt, new Object[]{ sourceText, targetText, delta });
- NotificationBuilder notif = NotificationBuilder.createAsyncPopup(Messages.DropError_UphillMessageTitle, txt);
- notif.setType(Type.WARNING);
- notif.run();
- }
-
- /**
- * Report a message telling that the link drop unexpectedly failed.
- *
- * @param sourceEditPart
- * the source of the link
- * @param targetEditPart
- * the target of the link
- */
- private void reportDefaultMessage(IGraphicalEditPart sourceEditPart, IGraphicalEditPart targetEditPart) {
- EObject source = sourceEditPart.resolveSemanticElement();
- String sourceText = EMFCoreUtil.getQualifiedName(source, true);
- EObject target = targetEditPart.resolveSemanticElement();
- String targetText = EMFCoreUtil.getQualifiedName(target, true);
- String txt = NLS.bind(Messages.DropError_DefaultTxt, sourceText, targetText);
- NotificationBuilder notif = NotificationBuilder.createAsyncPopup(Messages.DropError_DefaultTitle, txt);
- notif.setType(Type.ERROR);
- notif.run();
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java
deleted file mode 100644
index df47c81eb18..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.TimeObservation;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * Command for creating time observation element
- *
- */
-public class CustomTimeObservationCreateCommand extends EditElementCommand {
- private EClass eClass = null;
-
- private EObject eObject = null;
-
- public CustomTimeObservationCreateCommand(CreateElementRequest req, EObject eObject) {
- super(req.getLabel(), null, req);
- this.eObject = eObject;
- this.eClass = eObject != null ? eObject.eClass() : null;
- }
-
- public static CustomTimeObservationCreateCommand create(CreateElementRequest req, EObject eObject) {
- return new CustomTimeObservationCreateCommand(req, eObject);
- }
-
- public CustomTimeObservationCreateCommand(CreateElementRequest req) {
- super(req.getLabel(), null, req);
- }
-
- protected EObject getElementToEdit() {
-
- EObject container = ((CreateElementRequest)getRequest()).getContainer();
- if(container instanceof View) {
- container = ((View)container).getElement();
- }
- if(container != null) {
- return container;
- }
- return eObject;
- }
-
- public boolean canExecute() {
-
- return true;
-
- }
-
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
-
- TimeObservation newElement = UMLFactory.eINSTANCE.createTimeObservation();
-
- // get the parent package as owner
- EObject container = getElementToEdit();
- while(container != null && !(container instanceof Package)) {
- container = container.eContainer();
- }
- if(container == null) {
- return CommandResult.newCancelledCommandResult();
- }
- Package owner = (Package)container;
- owner.getPackagedElements().add(newElement);
-
- ElementInitializers.getInstance().init_TimeObservation_3020(newElement);
-
- doConfigure(newElement, monitor, info);
-
- ((CreateElementRequest)getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- protected void doConfigure(TimeObservation newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- IElementType elementType = ((CreateElementRequest)getRequest()).getElementType();
- ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
- configureRequest.setClientContext(((CreateElementRequest)getRequest()).getClientContext());
- configureRequest.addParameters(getRequest().getParameters());
- ICommand configureCommand = elementType.getEditCommand(configureRequest);
- if(configureCommand != null && configureCommand.canExecute()) {
- configureCommand.execute(monitor, info);
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomZOrderCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomZOrderCommand.java
deleted file mode 100644
index 3639ea8225b..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomZOrderCommand.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * ZOrder command with a custom index
- */
-public class CustomZOrderCommand extends AbstractTransactionalCommand {
-
- protected View view;
-
- protected View containerView;
-
- private int index;
-
- /**
- * @param editingDomain
- * the editing domain through which model changes are made
- * @param label
- * @param view
- */
- public CustomZOrderCommand(TransactionalEditingDomain editingDomain, View view, int index) {
- super(editingDomain, "change ZOrder", getWorkspaceFiles(view));
-
- this.view = view;
- this.index = index;
- containerView = ViewUtil.getContainerView(view);
-
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ViewUtil.repositionChildAt(containerView, view, index);
- return CommandResult.newOKCommandResult();
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/PromptCreateElementAndNodeCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/PromptCreateElementAndNodeCommand.java
deleted file mode 100644
index 52474d3a6d1..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/PromptCreateElementAndNodeCommand.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CreateOrSelectElementCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.uml2.uml.InteractionFragment;
-
-public class PromptCreateElementAndNodeCommand extends
- CreateOrSelectElementCommand {
- private static final List<IElementType> executionTypes = new ArrayList<IElementType>();
- static {
- executionTypes.add(UMLElementTypes.ActionExecutionSpecification_3006);
- executionTypes.add(UMLElementTypes.BehaviorExecutionSpecification_3003);
- }
- private final CompoundCommand command;
- private TransactionalEditingDomain editingDomain;
- private ConnectionViewDescriptor descriptor;
- private ShapeNodeEditPart targetEP;
- private EObject target;
- private Point location;
- private InteractionFragment container;
- private CreateConnectionRequest request;
- private EditPart sourceEP;
-
- public PromptCreateElementAndNodeCommand(Command createCommand,
- TransactionalEditingDomain editingDomain,
- ConnectionViewDescriptor descriptor, ShapeNodeEditPart targetEP,
- EObject target, EditPart sourceEP, CreateConnectionRequest request, InteractionFragment container) {
- super(Display.getCurrent().getActiveShell(), executionTypes);
- this.editingDomain = editingDomain;
- this.descriptor = descriptor;
- this.targetEP = targetEP;
- this.target = target;
- this.sourceEP = sourceEP;
- this.request = request;
- this.location = request.getLocation();
- this.container = container;
- command = new CompoundCommand();
- command.add(createCommand);
- }
-
- protected CommandResult doExecuteWithResult(
- IProgressMonitor progressMonitor, IAdaptable info)
- throws ExecutionException {
- sourceEP.eraseSourceFeedback(request);
- targetEP.eraseSourceFeedback(request);
-
- CommandResult cmdResult = super.doExecuteWithResult(progressMonitor,
- info);
- if (!cmdResult.getStatus().isOK()) {
- return cmdResult;
- }
- IHintedType connectionType = (IHintedType) cmdResult.getReturnValue();
-
- CreateElementAndNodeCommand createExecutionSpecificationCommand = new CreateElementAndNodeCommand(
- editingDomain, (ShapeNodeEditPart) targetEP, target,
- connectionType, location);
- createExecutionSpecificationCommand.putCreateElementRequestParameter(
- SequenceRequestConstant.INTERACTIONFRAGMENT_CONTAINER,
- container);
- command.add(new ICommandProxy(createExecutionSpecificationCommand));
-
- // put the anchor at the top of the figure
- ChangeEdgeTargetCommand changeTargetCommand = new ChangeEdgeTargetCommand(
- editingDomain, createExecutionSpecificationCommand, descriptor,
- "(0.5, 0.0)");
- command.add(new ICommandProxy(changeTargetCommand));
-
- command.execute();
-
- return CommandResult.newOKCommandResult(descriptor);
- }
-
- public boolean canUndo() {
- return command != null && command.canUndo();
- }
-
- protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor,
- IAdaptable info) throws ExecutionException {
- if (command != null) {
- command.redo();
- }
- return super.doRedoWithResult(progressMonitor, info);
- }
-
- protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor,
- IAdaptable info) throws ExecutionException {
- if (command != null) {
- command.undo();
- }
- return super.doUndoWithResult(progressMonitor, info);
- }
-
- protected ILabelProvider getLabelProvider() {
- return new LabelProvider() {
-
- @Override
- public String getText(Object object) {
- if (object instanceof IHintedType) {
- IHintedType elementType = (IHintedType) object;
- switch (UMLVisualIDRegistry.getVisualID(elementType
- .getSemanticHint())) {
- case ActionExecutionSpecificationEditPart.VISUAL_ID:
- return Messages.createActionExecutionSpecification2CreationTool_title;
- case BehaviorExecutionSpecificationEditPart.VISUAL_ID:
- return Messages.createBehaviorExecutionSpecification3CreationTool_title;
- }
- }
- return super.getText(object);
- }
- };
-
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
deleted file mode 100644
index a2c39fc6107..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
+++ /dev/null
@@ -1,796 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
-import org.eclipse.draw2d.geometry.PrecisionRectangle;
-import org.eclipse.draw2d.geometry.Ray;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.common.core.util.StringStatics;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.OrthogonalConnectionAnchor;
-import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities;
-import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter;
-import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.OrthogonalRouterUtilities;
-import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart.LifelineFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart.MessageCreate;
-
-/**
- * A multi behavior router which enable to draw message.
- * It can behave as an oblique router (with no bendpoint), or as an horizontal router (with no bendpoint),
- * or as a rectilinear router with 2 bendpoints.
- *
- * @author mvelten and vhemery
- */
-@SuppressWarnings({ "restriction", "deprecation" })
-public class MessageRouter extends ObliqueRouter {
-
- private static final int MAX_DELTA = 10;
-
- public static enum RouterKind {
- HORIZONTAL, OBLIQUE, SELF;
-
- public static RouterKind getKind(Connection conn, PointList newLine) {
- if(isSelfConnection(conn)) {
- return SELF;
- }
- if(isHorizontalConnection(conn, newLine)) {
- return HORIZONTAL;
- }
- return OBLIQUE;
- }
-
- private static boolean isHorizontalConnection(Connection conn, PointList newLine) {
- if(!(conn instanceof Message2EditPart.MessageAsync)) {
- return false;
- }
- Point sourcePoint = newLine.getFirstPoint();
- Point targetPoint = newLine.getLastPoint();
- return Math.abs(sourcePoint.y - targetPoint.y) <= MAX_DELTA;
- }
-
- /**
- * It is self if the parent lifeline is the same.
- */
- private static boolean isSelfConnection(Connection conn) {
- if(conn == null || conn.getSourceAnchor() == null || conn.getTargetAnchor() == null) {
- return false;
- }
- IFigure sourceLifeline = conn.getSourceAnchor().getOwner();
- while(sourceLifeline != null && !(sourceLifeline instanceof LifelineFigure)) {
- sourceLifeline = sourceLifeline.getParent();
- }
- IFigure targetLifeline = conn.getTargetAnchor().getOwner();
- while(targetLifeline != null && !(targetLifeline instanceof LifelineFigure)) {
- targetLifeline = targetLifeline.getParent();
- }
-
- return sourceLifeline != null && sourceLifeline.equals(targetLifeline);
- }
- }
-
- @Override
- public void routeLine(Connection conn, int nestedRoutingDepth, PointList newLine) {
- Point sourcePoint, targetPoint;
- switch(RouterKind.getKind(conn, newLine)) {
- case HORIZONTAL:
- originalRectilinearRouteLine(conn, nestedRoutingDepth, newLine);
-
- // force 2 bendpoints on the same Y coordinate
- sourcePoint = newLine.getFirstPoint();
- targetPoint = newLine.getLastPoint();
- targetPoint.y = sourcePoint.y;
- newLine.removeAllPoints();
- newLine.addPoint(sourcePoint);
- newLine.addPoint(targetPoint);
- break;
- case OBLIQUE:
- super.routeLine(conn, nestedRoutingDepth, newLine);
- adjustCreateEndpoint(conn, newLine);
-
- // force 2 bendpoints only
- if(newLine.size() > 2) {
- sourcePoint = newLine.getFirstPoint();
- targetPoint = newLine.getLastPoint();
- newLine.removeAllPoints();
- newLine.addPoint(sourcePoint);
- newLine.addPoint(targetPoint);
- }
- break;
- case SELF:
- // Handle special routing: self connections and intersecting shapes connections
- if(checkSelfRelConnection(conn, newLine)) {
- super.resetEndPointsToEdge(conn, newLine);
- OrthogonalRouterUtilities.transformToOrthogonalPointList(newLine, getOffShapeDirection(getAnchorOffRectangleDirection(newLine.getFirstPoint(), sourceBoundsRelativeToConnection(conn))), getOffShapeDirection(getAnchorOffRectangleDirection(newLine.getLastPoint(), targetBoundsRelativeToConnection(conn))));
- removeRedundantPoints(newLine);
- return;
- }
- break;
- }
- }
-
- protected boolean checkShapesIntersect(Connection conn, PointList newLine) {
- if(conn.getTargetAnchor().getOwner() instanceof AnchorHelper.CombinedFragmentNodeFigure){
- return false;
- }
- return super.checkShapesIntersect(conn, newLine);
- }
-
- protected void adjustCreateEndpoint(Connection conn, PointList newLine) {
- if(conn instanceof MessageCreate){
- if(newLine.size() >= 2){
- Point start = newLine.getFirstPoint();
- Point end = newLine.getLastPoint();
- if(start.y != end.y){
- start.y = end.y;
- newLine.setPoint(start, 0);
- }
- }
- }
- }
-
- @Override
- protected void getSelfRelVertices(Connection conn, PointList newLine) {
-
- rectilinearResetEndPointsToEdge(conn, newLine);
-
- IFigure owner = conn.getSourceAnchor().getOwner();
- Point middle = owner.getBounds().getCenter();
-
- // ensure that the end points are anchored properly to the shape.
- Point ptS2 = newLine.getPoint(0);
- Point ptS1 = conn.getSourceAnchor().getReferencePoint();
- conn.translateToRelative(ptS1);
- Point ptAbsS2 = new Point(ptS2);
- conn.translateToAbsolute(ptAbsS2);
- Point ptEdge = conn.getSourceAnchor().getLocation(ptAbsS2);
- conn.translateToRelative(ptEdge);
- ptS1 = getStraightEdgePoint(ptEdge, ptS1, ptS2);
-
- Point ptE2 = newLine.getPoint(newLine.size() - 1);
- Point ptE1 = conn.getTargetAnchor().getReferencePoint();
- conn.translateToRelative(ptE1);
- Point ptAbsE2 = new Point(ptE2);
- conn.translateToAbsolute(ptAbsE2);
- ptEdge = conn.getTargetAnchor().getLocation(ptAbsE2);
- conn.translateToRelative(ptEdge);
- ptE1 = getStraightEdgePoint(ptEdge, ptE1, ptE2);
-
- newLine.removeAllPoints();
- newLine.addPoint(ptS1);
-
- // insert two points
- Point extraPoint1 = ptS2.getTranslated(ptE2).scale(0.5);
- if(isOnRightHand(conn, owner, middle)){
- extraPoint1.translate(SELFRELSIZEINIT, 0);
- } else {
- extraPoint1.translate(-SELFRELSIZEINIT, 0);
- }
- Point extraPoint2 = extraPoint1.getCopy();
-
- if(isFeedback(conn)) {
- extraPoint1.y = ptS2.y;
- extraPoint2.y = ptE2.y;
- } else {
- extraPoint1.y = ptS1.y;
- extraPoint2.y = ptE1.y;
- }
- newLine.addPoint(extraPoint1);
- newLine.addPoint(extraPoint2);
-
- newLine.addPoint(ptE1);
- }
-
- protected boolean isOnRightHand(Connection conn, IFigure owner, Point middle) {
- boolean right = true;
- if(conn.getTargetAnchor() instanceof AnchorHelper.SideAnchor){
- AnchorHelper.SideAnchor anchor = ( AnchorHelper.SideAnchor) conn.getTargetAnchor();
- right = anchor.isRight();
- }else{
- PointList list = conn.getPoints();
- if(list.getPoint(0).x > list.getPoint(1).x)
- right = false;
- }
- return right;
- }
-
- @Override
- protected boolean checkSelfRelConnection(Connection conn, PointList newLine) {
- if(RouterKind.getKind(conn, newLine).equals(RouterKind.SELF)) {
- getSelfRelVertices(conn, newLine);
- return true;
- }
- return false;
- }
-
- /**
- * All the code after this comment is copied from RectilinearRouter and RouterHelper
- *
- * Copyright (c) 2002, 2010 IBM Corporation and others.
- */
-
- private void originalRectilinearRouteLine(Connection conn, int nestedRoutingDepth, PointList newLine) {
-
- boolean skipNormalization = (routerFlags & ROUTER_FLAG_SKIPNORMALIZATION) != 0;
-
- // if we are reorienting, then just default to the super class implementation and
- // don't try to do rectilinear routing.
- if(isReorienting(conn)) {
- super.routeLine(conn, nestedRoutingDepth, newLine);
- return;
- }
-
- /*
- * Remove and store former anchor points. Anchor points will be re-calculated anyway.
- * However, the old anchor points may be useful if connection didn't have any bend points
- * except the anchor points.
- */
- Point lastStartAnchor = newLine.removePoint(0);
- Point lastEndAnchor = newLine.removePoint(newLine.size() - 1);
-
- /*
- * Check if connection is rectilinear and if not make it rectilinear
- */
- if(!OrthogonalRouterUtilities.isRectilinear(newLine)) {
- OrthogonalRouterUtilities.transformToOrthogonalPointList(newLine, PositionConstants.NONE, PositionConstants.NONE);
- }
-
- removeRedundantPoints(newLine);
-
- /*
- * Remove unnecessary points that are contained within source and/or target shapes
- * as well as insert extra points if all points are within source and/or target shapes
- */
- removePointsInViews(conn, newLine, lastStartAnchor, lastEndAnchor);
-
- Dimension tolerance = new Dimension(3, 0);
- if(!isFeedback(conn))
- tolerance = (Dimension)MapModeUtil.getMapMode(conn).DPtoLP(tolerance);
-
- /*
- * Normalize polyline to eliminate extra segments. (This makes 3 segments collapsing into
- * one, while line segments are moved)
- */
- if(!skipNormalization) {
- if(PointListUtilities.normalizeSegments(newLine, tolerance.width)) {
- /*
- * Normalization can make our polyline not rectilinear. Hence, we need to normalize
- * segments of polyline to straight line tolerance.
- */
- normalizeToStraightLineTolerance(newLine, tolerance.width);
- }
- }
-
- /*
- * Normalization is not touching the end points, hence we'd like to handle this here.
- * If distance between start and end (which are the only points in a polyline) points
- * is too short we'll remove one of the points
- */
- if(newLine.size() == 2) {
- Ray middleSeg = new Ray(newLine.getFirstPoint(), newLine.getLastPoint());
- if(middleSeg.length() <= tolerance.width) {
- newLine.removePoint(0);
- }
- }
-
- /*
- * Calculate connection anchor points and possibly some extra routing work to keep
- * the connection rectilinear if anchor points make it not rectilinear.
- */
- rectilinearResetEndPointsToEdge(conn, newLine);
-
- if(nestedRoutingDepth < 1 && !isValidRectilinearLine(conn, newLine)) {
- routeLine(conn, ++nestedRoutingDepth, newLine);
- }
- }
-
- /**
- * Rectilinear polyline is invalid if:
- * 1. First bend point is within the source
- * 2. Last bend point is within the target
- * 3. First bend point and source anchor are on different sides of the source shape
- * 4. Last bend point and target anchor are on different sides of the target shape
- *
- * @param conn
- * connection
- * @param line
- * rectilinear polyline
- * @return <code>true</code> if the line is valid
- */
- private boolean isValidRectilinearLine(Connection conn, PointList line) {
- if(!(conn.getSourceAnchor().getOwner() instanceof Connection)) {
- Rectangle source = new PrecisionRectangle(FigureUtilities.getAnchorableFigureBounds(conn.getSourceAnchor().getOwner()));
- conn.getSourceAnchor().getOwner().translateToAbsolute(source);
- conn.translateToRelative(source);
- if(source.contains(line.getPoint(1))) {
- return false;
- }
- int firstSegmentOrientation = line.getFirstPoint().x == line.getPoint(1).x ? PositionConstants.VERTICAL : PositionConstants.HORIZONTAL;
- if(getOutisePointOffRectanglePosition(line.getPoint(1), source) != getAnchorLocationBasedOnSegmentOrientation(line.getFirstPoint(), source, firstSegmentOrientation)) {
- return false;
- }
- }
- if(!(conn.getTargetAnchor().getOwner() instanceof Connection)) {
- Rectangle target = new PrecisionRectangle(FigureUtilities.getAnchorableFigureBounds(conn.getTargetAnchor().getOwner()));
- conn.getTargetAnchor().getOwner().translateToAbsolute(target);
- conn.translateToRelative(target);
- if(target.contains(line.getPoint(line.size() - 2))) {
- return false;
- }
- int lastSegmentOrientation = line.getLastPoint().x == line.getPoint(line.size() - 2).x ? PositionConstants.VERTICAL : PositionConstants.HORIZONTAL;
- if(getOutisePointOffRectanglePosition(line.getPoint(line.size() - 2), target) != getAnchorLocationBasedOnSegmentOrientation(line.getLastPoint(), target, lastSegmentOrientation)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Calculates geographic position of a point located outside the given rectangle relative
- * to the rectangle
- *
- * @param p
- * point outside of rectangle
- * @param r
- * the rectangle
- * @return geographic position of the point relative to the recatangle
- */
- private int getOutisePointOffRectanglePosition(Point p, Rectangle r) {
- int position = PositionConstants.NONE;
- if(r.x > p.x) {
- position |= PositionConstants.WEST;
- } else if(r.x + r.width < p.x) {
- position |= PositionConstants.EAST;
- }
- if(r.y > p.y) {
- position |= PositionConstants.NORTH;
- } else if(r.y + r.height < p.y) {
- position |= PositionConstants.SOUTH;
- }
- return position;
- }
-
- /**
- * Given the coordinates of the connection anchor point the shape's rectangle and the
- * orientation of the first rectilinear connection segment that comes out from the anchor
- * point the method detemines on which geographic side of the rectangle the anchor point
- * is located on.
- *
- * @param anchorPoint
- * coordinates of the anchor point
- * @param rectangle
- * the shape's bounding rectangle
- * @param segmentOrientation
- * orinetation of the segment coming out from the anchor point
- * @return geographic position of the anchor point relative to the rectangle
- */
- private int getAnchorLocationBasedOnSegmentOrientation(Point anchorPoint, Rectangle rectangle, int segmentOrientation) {
- if(segmentOrientation == PositionConstants.VERTICAL) {
- if(Math.abs(anchorPoint.y - rectangle.y) < Math.abs(anchorPoint.y - rectangle.y - rectangle.height)) {
- return PositionConstants.NORTH;
- } else {
- return PositionConstants.SOUTH;
- }
- } else if(segmentOrientation == PositionConstants.HORIZONTAL) {
- if(Math.abs(anchorPoint.x - rectangle.x) < Math.abs(anchorPoint.x - rectangle.x - rectangle.width)) {
- return PositionConstants.WEST;
- } else {
- return PositionConstants.EAST;
- }
- }
- return PositionConstants.NONE;
- }
-
- /**
- * Goes through line segments of a polyline and makes strict straight segments
- * from nearly straight segments.
- *
- * @param line
- * polyline
- * @param tolerance
- * tolerance value specifying nearly straight lines.
- */
- private void normalizeToStraightLineTolerance(PointList line, int tolerance) {
- for(int i = 0; i < line.size() - 1; i++) {
- Point pt1 = line.getPoint(i);
- Point pt2 = line.getPoint(i + 1);
- if(Math.abs(pt1.x - pt2.x) < tolerance) {
- line.setPoint(new Point(pt1.x, pt2.y), i + 1);
- } else if(Math.abs(pt1.y - pt2.y) < tolerance) {
- line.setPoint(new Point(pt2.x, pt1.y), i + 1);
- }
- }
- }
-
- /**
- * Removes consecutive points contained within the source shape and removes consecutive
- * points contained within the target shape. If all points have been removed an extra point
- * outside source and target shapes will be added.
- *
- * @param conn
- * connection
- * @param newLine
- * polyline of the connection (routed connection)
- * @param start
- * old start anchor point
- * @param end
- * old end anchor point
- */
- private void removePointsInViews(Connection conn, PointList newLine, Point start, Point end) {
- /*
- * Get the bounds of anchorable figure of the source and target and translate it to
- * connection relative coordinates.
- */
- PrecisionRectangle source = conn.getSourceAnchor().getOwner() != null ? new PrecisionRectangle(FigureUtilities.getAnchorableFigureBounds(conn.getSourceAnchor().getOwner())) : null;
- PrecisionRectangle target = conn.getTargetAnchor().getOwner() != null ? new PrecisionRectangle(FigureUtilities.getAnchorableFigureBounds(conn.getTargetAnchor().getOwner())) : null;
- if(source != null) {
- conn.getSourceAnchor().getOwner().translateToAbsolute(source);
- conn.translateToRelative(source);
- }
- if(target != null) {
- conn.getTargetAnchor().getOwner().translateToAbsolute(target);
- conn.translateToRelative(target);
- }
-
- Point lastRemovedFromSource = null;
- Point lastRemovedFromTarget = null;
-
- /*
- * Starting from the first point of polyline remove points that are contained
- * within the source shape until the first point outside is found.
- * Remember the point that was removed from the source shape last for a possible
- * case of all points removed from polyline.
- */
- if(!(conn.getSourceAnchor().getOwner() instanceof Connection) && newLine.size() != 0 && source.contains(new PrecisionPoint(newLine.getFirstPoint()))) {
- lastRemovedFromSource = newLine.removePoint(0);
- for(int i = 0; i < newLine.size() && source.contains(new PrecisionPoint(newLine.getPoint(i))); i++) {
- lastRemovedFromSource = newLine.removePoint(i--);
- }
- }
-
- /*
- * Starting from the end point of polyline remove points that are contained
- * within the target shape until the first point outside is found.
- * Remember the point that was removed from the target shape last for a possible
- * case of all points removed from polyline.
- */
- if(!(conn.getTargetAnchor().getOwner() instanceof Connection) && newLine.size() != 0 && target.contains(new PrecisionPoint(newLine.getLastPoint()))) {
- lastRemovedFromTarget = newLine.removePoint(newLine.size() - 1);
- for(int i = newLine.size(); i > 0 && target.contains(new PrecisionPoint(newLine.getPoint(i - 1))); i--) {
- lastRemovedFromTarget = newLine.removePoint(i - 1);
- }
- }
-
- /*
- * Handle the special case of all points removed from polyline.
- */
- if(newLine.size() == 0) {
- Dimension tolerance = new Dimension(1, 0);
- if(!isFeedback(conn))
- tolerance = (Dimension)MapModeUtil.getMapMode(conn).DPtoLP(tolerance);
- int toleranceValue = tolerance.width;
- if(lastRemovedFromSource == null) {
- lastRemovedFromSource = start;
- }
- if(lastRemovedFromTarget == null) {
- lastRemovedFromTarget = end;
- }
- /*
- * If last point removed from source and the points removed from target form
- * a vertical or horizontal line we'll find a point located on this line and is
- * outside of source and target shape and insert it in the polyline.
- * The check for vertical and horizontal segment is using tolerance value, because
- * bend point location extracted from RelativeBendpoint can have precision errors due
- * to non-integer weight factors.
- */
- if(Math.abs(lastRemovedFromSource.x - lastRemovedFromTarget.x) < toleranceValue) {
- // Vertical
- if(source.preciseY < target.preciseY) {
- newLine.addPoint(lastRemovedFromSource.x, (source.getBottom().y + target.getTop().y) / 2);
- } else {
- newLine.addPoint(lastRemovedFromSource.x, (source.getTop().y + target.getBottom().y) / 2);
- }
- } else if(Math.abs(lastRemovedFromSource.y - lastRemovedFromTarget.y) < toleranceValue) {
- // Horizontal
- if(source.preciseX < target.preciseX) {
- newLine.addPoint((source.getRight().x + target.getLeft().x) / 2, lastRemovedFromSource.y);
- } else {
- newLine.addPoint((source.getLeft().x + target.getRight().x) / 2, lastRemovedFromSource.y);
- }
- } else if((conn.getSourceAnchor() instanceof BaseSlidableAnchor && StringStatics.BLANK.equals(((BaseSlidableAnchor)conn.getSourceAnchor()).getTerminal()) && (conn.getTargetAnchor() instanceof BaseSlidableAnchor && StringStatics.BLANK.equals(((BaseSlidableAnchor)conn.getTargetAnchor()).getTerminal())))) {
- /*
- * This a special case for old diagrams with rectilinear connections routed by
- * the old router to look good with the new router
- */
- if(lastRemovedFromSource != null && lastRemovedFromTarget != null) {
- newLine.addPoint((lastRemovedFromSource.x + lastRemovedFromTarget.x) / 2, (lastRemovedFromSource.y + lastRemovedFromTarget.y) / 2);
- } else {
- double startX = Math.max(source.preciseX, target.preciseX);
- double endX = Math.min(source.preciseX + source.preciseWidth, target.preciseX + target.preciseWidth);
- double startY = Math.max(source.preciseY, target.preciseY);
- double endY = Math.min(source.preciseY + source.preciseHeight, target.preciseY + target.preciseHeight);
- if(startX < endX) {
- if(source.preciseY < target.preciseY) {
- newLine.addPoint((int)Math.round((startX + endX) / 2.0), (source.getBottom().y + target.getTop().y) / 2);
- } else {
- newLine.addPoint((int)Math.round((startX + endX) / 2.0), (source.getTop().y + target.getBottom().y) / 2);
- }
- } else if(startY < endY) {
- if(source.preciseX < target.preciseX) {
- newLine.addPoint((source.getRight().x + target.getLeft().x) / 2, (int)Math.round((startY + endY) / 2.0));
- } else {
- newLine.addPoint((source.getLeft().x + target.getRight().x) / 2, (int)Math.round((startY + endY) / 2.0));
- }
- }
- }
- }
- }
- }
-
- protected void rectilinearResetEndPointsToEdge(Connection conn, PointList line) {
- if(isReorienting(conn)) {
- /*
- * If the connection doesn't have a shape as a source or target we'll
- * let the oblique router to do the work. The connection doesn't need to
- * be rectilinear at this point. There is no support for making a rectilinear
- * connection for which one of the ends is not connected to anything.
- */
- super.resetEndPointsToEdge(conn, line);
- return;
- }
- PrecisionRectangle source = sourceBoundsRelativeToConnection(conn);
- PrecisionRectangle target = targetBoundsRelativeToConnection(conn);
- int offSourceDirection = PositionConstants.NONE;
- int offTargetDirection = PositionConstants.NONE;
- int sourceAnchorRelativeLocation = PositionConstants.NONE;
- int targetAnchorRelativeLocation = PositionConstants.NONE;
- if(line.size() == 0) {
- /*
- * If there are no valid bend points, we'll use the oblique connection anchor points
- * and just convert the polyline from oblique to rectilinear.
- */
- // Need to add 2 dumb points to ensure that RouterHelper#resetEndPointsToEdge works
- line.addPoint(new Point());
- line.addPoint(new Point());
- super.resetEndPointsToEdge(conn, line);
- sourceAnchorRelativeLocation = getAnchorOffRectangleDirection(line.getFirstPoint(), source);
- targetAnchorRelativeLocation = getAnchorOffRectangleDirection(line.getLastPoint(), target);
- /*
- * We need to find two points offset from the source and target anchors outside the shapes
- * such that when the polyline is converted to rectilinear from oblique we won't have
- * rectilinear line segments alligned with source or target shapes edges.
- */
- Point offStart = line.getFirstPoint();
- Point offEnd = line.getLastPoint();
- Dimension offsetDim = offStart.getDifference(offEnd).scale(0.5);
- offStart.translate(getTranslationValue(sourceAnchorRelativeLocation, Math.abs(offsetDim.width), Math.abs(offsetDim.height)));
- offEnd.translate(getTranslationValue(targetAnchorRelativeLocation, Math.abs(offsetDim.width), Math.abs(offsetDim.height)));
- line.insertPoint(offStart, 1);
- line.insertPoint(offEnd, 2);
- offSourceDirection = getOffShapeDirection(sourceAnchorRelativeLocation);
- offTargetDirection = getOffShapeDirection(targetAnchorRelativeLocation);
- } else {
- Point start = line.getFirstPoint();
- Point end = line.getLastPoint();
- if(conn.getSourceAnchor() instanceof OrthogonalConnectionAnchor) {
- line.insertPoint(OrthogonalRouterUtilities.getOrthogonalLineSegToAnchorLoc(conn, conn.getSourceAnchor(), start).getOrigin(), 0);
- } else {
- /*
- * If anchor is not supporting orthogonal connections we'll use the oblique connection
- * anchors and then convert it to rectilinear.
- */
- PrecisionPoint reference = new PrecisionPoint(start);
- conn.getSourceAnchor().getOwner().translateToAbsolute(reference);
- PrecisionPoint anchorLocation = new PrecisionPoint(conn.getSourceAnchor().getLocation(reference));
- conn.translateToRelative(anchorLocation);
- line.insertPoint(anchorLocation, 0);
- }
- if(conn.getTargetAnchor() instanceof OrthogonalConnectionAnchor) {
- line.addPoint(OrthogonalRouterUtilities.getOrthogonalLineSegToAnchorLoc(conn, conn.getTargetAnchor(), end).getOrigin());
- } else {
- /*
- * If anchor is not supporting orthogonal connections we'll use the oblique connection
- * anchors and then convert it to rectilinear.
- */
- PrecisionPoint reference = new PrecisionPoint(end);
- conn.getSourceAnchor().getOwner().translateToAbsolute(reference);
- PrecisionPoint anchorLocation = new PrecisionPoint(conn.getTargetAnchor().getLocation(reference));
- conn.translateToRelative(anchorLocation);
- line.addPoint(anchorLocation);
- }
- sourceAnchorRelativeLocation = getAnchorOffRectangleDirection(line.getFirstPoint(), source);
- offSourceDirection = getOffShapeDirection(sourceAnchorRelativeLocation);
- targetAnchorRelativeLocation = getAnchorOffRectangleDirection(line.getLastPoint(), target);
- offTargetDirection = getOffShapeDirection(targetAnchorRelativeLocation);
- }
-
- /*
- * Convert the polyline to rectilinear. If the connection is rectilinear already then the
- * connection will remain as it is.
- */
- OrthogonalRouterUtilities.transformToOrthogonalPointList(line, offSourceDirection, offTargetDirection);
- removeRedundantPoints(line);
- }
-
- /**
- * Returns a translation dimension for the anchor point. Translation dimension
- * translates the anchor point off the shape. The off shape direction
- * is specified by the relative to the shape geographic position of the anchor
- *
- * @param position
- * relative to the shape geographic position of the anchor
- * @param xFactorValue
- * translation value along x-axis
- * @param yFactorValue
- * translation value along y-axis
- * @return
- */
- private Dimension getTranslationValue(int position, int xFactorValue, int yFactorValue) {
- Dimension translationDimension = new Dimension();
- if(position == PositionConstants.EAST) {
- translationDimension.width = xFactorValue;
- } else if(position == PositionConstants.SOUTH) {
- translationDimension.height = yFactorValue;
- } else if(position == PositionConstants.WEST) {
- translationDimension.width = -xFactorValue;
- } else if(position == PositionConstants.NORTH) {
- translationDimension.height = -yFactorValue;
- }
- return translationDimension;
- }
-
- /**
- * Target bounding rectangle relative to connection figure coordinates
- *
- * @param conn
- * connection
- * @return <code>PrecisionRectangle</code> target bounds relative to connection's coordinate
- * system
- */
- private PrecisionRectangle targetBoundsRelativeToConnection(Connection conn) {
- PrecisionRectangle target = new PrecisionRectangle(conn.getTargetAnchor().getOwner().getBounds());
- conn.getTargetAnchor().getOwner().translateToAbsolute(target);
- conn.translateToRelative(target);
- return target;
- }
-
- /**
- * Iterates through points of a polyline and does the following:
- * if 3 points lie on the same line the middle point is removed
- *
- * @param line
- * polyline's points
- */
- private boolean removeRedundantPoints(PointList line) {
- int initialNumberOfPoints = line.size();
- if(line.size() > 2) {
- PointList newLine = new PointList(line.size());
- newLine.addPoint(line.removePoint(0));
- while(line.size() >= 2) {
- Point p0 = newLine.getLastPoint();
- Point p1 = line.getPoint(0);
- Point p2 = line.getPoint(1);
- if(p0.x == p1.x && p0.x == p2.x) {
- // Have two vertical segments in a row
- // get rid of the point between
- line.removePoint(0);
- } else if(p0.y == p1.y && p0.y == p2.y) {
- // Have two horizontal segments in a row
- // get rid of the point between
- line.removePoint(0);
- } else {
- newLine.addPoint(line.removePoint(0));
- }
- }
- while(line.size() > 0) {
- newLine.addPoint(line.removePoint(0));
- }
- line.removeAllPoints();
- line.addAll(newLine);
- }
- return line.size() != initialNumberOfPoints;
- }
-
- /**
- * Determines whether the rectilinear line segment coming out of the shape should be
- * horizontal or vertical based on the anchor geographic position relative to the shape
- *
- * @param anchorRelativeLocation
- * @return
- */
- private int getOffShapeDirection(int anchorRelativeLocation) {
- if(anchorRelativeLocation == PositionConstants.EAST || anchorRelativeLocation == PositionConstants.WEST) {
- return PositionConstants.HORIZONTAL;
- } else if(anchorRelativeLocation == PositionConstants.NORTH || anchorRelativeLocation == PositionConstants.SOUTH) {
- return PositionConstants.VERTICAL;
- }
- return PositionConstants.NONE;
- }
-
- /**
- * Source bounding rectangle relative to connection figure coordinates
- *
- * @param conn
- * connection
- * @return <code>PrecisionRectangle</code> source bounds relative to connection's coordinate
- * system
- */
- private PrecisionRectangle sourceBoundsRelativeToConnection(Connection conn) {
- PrecisionRectangle source = new PrecisionRectangle(conn.getSourceAnchor().getOwner().getBounds());
- conn.getSourceAnchor().getOwner().translateToAbsolute(source);
- conn.translateToRelative(source);
- return source;
- }
-
- /**
- * Determines the relative to rectangle geographic location of a point.
- * Example: If shape is closer to the the top edge of the rectangle location
- * would be north.
- * Method used to determine which side of shape's bounding rectangle is closer
- * to connection's anchor point.
- * All geometric quantities must be in the same coordinate system.
- *
- * @param anchorPoint
- * location of the anchor point
- * @param rect
- * bounding rectangle of the shape
- * @return
- */
- private int getAnchorOffRectangleDirection(Point anchorPoint, Rectangle rect) {
- int position = PositionConstants.NORTH;
- int criteriaValue = Math.abs(anchorPoint.y - rect.y);
- int tempCriteria = Math.abs(anchorPoint.y - rect.y - rect.height);
- if(tempCriteria < criteriaValue) {
- criteriaValue = tempCriteria;
- position = PositionConstants.SOUTH;
- }
-
- tempCriteria = Math.abs(anchorPoint.x - rect.x);
- if(tempCriteria < criteriaValue) {
- criteriaValue = tempCriteria;
- position = PositionConstants.WEST;
- }
-
- tempCriteria = Math.abs(anchorPoint.x - rect.x - rect.width);
- if(tempCriteria < criteriaValue) {
- criteriaValue = tempCriteria;
- position = PositionConstants.EAST;
- }
-
- return position;
- }
-
- /**
- * @param conn
- * the <code>Connection</code> that is to be check if it is a feedback
- * connection or not.
- * @return <code>true</code> is it is a feedback connection, <code>false</code> otherwise.
- */
- private static boolean isFeedback(Connection conn) {
- Dimension dim = new Dimension(100, 100);
- Dimension dimCheck = dim.getCopy();
- conn.translateToRelative(dimCheck);
- return dim.equals(dimCheck);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
deleted file mode 100644
index ba373ecc69b..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
+++ /dev/null
@@ -1,390 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Locator;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.RelativeLocator;
-import org.eclipse.draw2d.TreeSearch;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
-import org.eclipse.draw2d.geometry.PrecisionRectangle;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.handles.HandleBounds;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
-import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.FillStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.runtime.notation.datatype.GradientData;
-import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineXYLayoutEditPolicy;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-
-public abstract class AbstractExecutionSpecificationEditPart extends ShapeNodeEditPart {
-
- private List executionSpecificationEndParts;
-
- public AbstractExecutionSpecificationEditPart(View view) {
- super(view);
- }
-
- @Override
- public List getChildren() {
- if(executionSpecificationEndParts == null) {
- initExecutionSpecificationEndEditPart();
- }
- return super.getChildren();
- }
-
- protected void initExecutionSpecificationEndEditPart() {
- executionSpecificationEndParts = new ArrayList();
-
- EObject element = this.resolveSemanticElement();
- if(!(element instanceof ExecutionSpecification)) {
- return;
- }
- ExecutionSpecification execution = (ExecutionSpecification)element;
- final ExecutionSpecificationEndEditPart startPart = new ExecutionSpecificationEndEditPart(execution.getStart(), this, new RelativeLocator(getFigure(), PositionConstants.NORTH));
- executionSpecificationEndParts.add(startPart);
-
- final ExecutionSpecificationEndEditPart finishPart = new ExecutionSpecificationEndEditPart(execution.getFinish(), this, new RelativeLocator(getFigure(), PositionConstants.SOUTH));
- executionSpecificationEndParts.add(finishPart);
-
- Diagram diagram = ((View)this.getModel()).getDiagram();
- startPart.rebuildLinks(diagram);
- finishPart.rebuildLinks(diagram);
-
- addChild(startPart, -1);
- addChild(finishPart, -1);
- }
-
- static class FillParentLocator implements Locator {
-
- public void relocate(IFigure target) {
- target.setBounds(target.getParent().getBounds());
- }
- }
-
- /**
- * Overrides to disable the defaultAnchorArea. The edge is now more stuck with the middle of the
- * figure.
- *
- * @generated NOT
- */
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(16, 60) {
-
- /**
- * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#isDefaultAnchorArea(org.eclipse.draw2d.geometry.PrecisionPoint)
- */
- @Override
- protected boolean isDefaultAnchorArea(PrecisionPoint p) {
- return false;
- }
- };
- result.setMinimumSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(20))); // min height 20
- return result;
- }
-
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableShapeEditPolicy() {
-
- @Override
- protected Command getResizeCommand(ChangeBoundsRequest request) {
- // Bugfix: Avoid resize ES with the child size is little than parent one.
- EditPart host = getHost();
- List<ShapeNodeEditPart> movedChildrenParts = LifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts((ShapeNodeEditPart)host);
- Rectangle r = getInitialFeedbackBounds().getCopy();
- getHostFigure().translateToAbsolute(r);
- r.translate(0, request.getMoveDelta().y);
- r.resize(0, request.getSizeDelta().height);
- for(ShapeNodeEditPart child : movedChildrenParts) {
- IFigure figure = child.getFigure();
- Rectangle rect = figure.getBounds().getCopy();
- if (figure instanceof HandleBounds) {
- rect = ((HandleBounds)figure).getBounds().getCopy();
- }
- figure.translateToAbsolute(rect);
- if(rect.y < r.y || rect.bottom() > r.bottom()) {
- return UnexecutableCommand.INSTANCE;
- }
- }
- return super.getResizeCommand(request);
- }
-
- @Override
- protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
- request.getMoveDelta().x = 0; // reset offset
-
- IFigure feedback = getDragSourceFeedbackFigure();
-
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
-
- IFigure f = getHostFigure();
- Dimension min = f.getMinimumSize().getCopy();
- Dimension max = f.getMaximumSize().getCopy();
- IMapMode mmode = MapModeUtil.getMapMode(f);
- min.height = mmode.LPtoDP(min.height);
- min.width = mmode.LPtoDP(min.width);
- max.height = mmode.LPtoDP(max.height);
- max.width = mmode.LPtoDP(max.width);
-
- Rectangle originalBounds = rect.getCopy();
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
-
- if(min.width > rect.width) {
- rect.width = min.width;
- } else if(max.width < rect.width) {
- rect.width = max.width;
- }
- if(min.height > rect.height) {
- rect.height = min.height;
- } else if(max.height < rect.height) {
- rect.height = max.height;
- }
-
- if(rect.height == min.height && request.getSizeDelta().height < 0 && request.getMoveDelta().y > 0) { //shrink at north
- Point loc = rect.getLocation();
- loc.y = originalBounds.getBottom().y - min.height;
- rect.setLocation(loc);
-
- request.getSizeDelta().height = min.height - originalBounds.height;
- request.getMoveDelta().y = loc.y - originalBounds.y;
- }
-
- if(request.getSizeDelta().height == 0) { // moving
- moveExecutionSpecificationFeedback(request, AbstractExecutionSpecificationEditPart.this, rect);
- }
- feedback.translateToRelative(rect);
- feedback.setBounds(rect);
- }
- });
- }
-
- @Override
- protected void setLineWidth(int width) {
- if(getPrimaryShape() instanceof NodeFigure) {
- ((NodeFigure)getPrimaryShape()).setLineWidth(width);
- }
- }
-
- protected final void refreshShadow() {
- getPrimaryShape().setShadow(AppearanceHelper.showShadow((View)getModel()));
- }
-
- /**
- * Override to set the transparency to the correct figure
- */
- @Override
- protected void setTransparency(int transp) {
- getPrimaryShape().setTransparency(transp);
- }
-
- /**
- * sets the back ground color of this edit part
- *
- * @param color
- * the new value of the back ground color
- */
- @Override
- protected void setBackgroundColor(Color color) {
- getPrimaryShape().setBackgroundColor(color);
- getPrimaryShape().setIsUsingGradient(false);
- getPrimaryShape().setGradientData(-1, -1, 0);
- }
-
- /**
- * Override to set the gradient data to the correct figure
- */
- @Override
- protected void setGradient(GradientData gradient) {
- IPapyrusNodeFigure fig = getPrimaryShape();
- FillStyle style = (FillStyle)getPrimaryView().getStyle(NotationPackage.Literals.FILL_STYLE);
- if(gradient != null) {
- fig.setIsUsingGradient(true);;
- fig.setGradientData(style.getFillColor(), gradient.getGradientColor1(), gradient.getGradientStyle());
- } else {
- fig.setIsUsingGradient(false);
- }
- }
-
- @Override
- public boolean supportsGradient() {
- return true;
- }
-
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
-
- Object feature = event.getFeature();
- if((getModel() != null) && (getModel() == event.getNotifier())) {
- if(NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)) {
- refreshLineWidth();
- } else if(NotationPackage.eINSTANCE.getLineTypeStyle_LineType().equals(feature)) {
- refreshLineType();
- }
- }
-
- refreshShadow();
- }
-
- public class ExecutionSpecificationRectangleFigure extends PapyrusNodeFigure { //RectangleFigure {
-
- public ExecutionSpecificationRectangleFigure() {
- this.setPreferredSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(60)));
- this.setMinimumSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(20)));
- }
-
- @Override
- public IFigure findMouseEventTargetAt(int x, int y) {
- // check children first instead of self
- IFigure f = findMouseEventTargetInDescendantsAt(x, y);
- if(f != null) {
- return f;
- }
- if(!containsPoint(x, y)) {
- return null;
- }
- if(isMouseEventTarget()) {
- return this;
- }
- return null;
- }
-
- @Override
- public IFigure findFigureAt(int x, int y, TreeSearch search) {
- if(search.prune(this)) {
- return null;
- }
- IFigure child = findDescendantAtExcluding(x, y, search);
- if(child != null) {
- return child;
- }
- if(!containsPoint(x, y)) {
- return null;
- }
- if(search.accept(this)) {
- return this;
- }
- return null;
- }
- }
-
- public abstract ExecutionSpecificationRectangleFigure getPrimaryShape();
-
- //see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=385604
- protected void moveExecutionSpecificationFeedback(ChangeBoundsRequest request, AbstractExecutionSpecificationEditPart movedPart, PrecisionRectangle rect) {
- LifelineEditPart lifelineEP = (LifelineEditPart)movedPart.getParent();
- Rectangle copy = rect.getCopy();
- lifelineEP.getPrimaryShape().translateToRelative(copy);
-
- List<ShapeNodeEditPart> executionSpecificationList = lifelineEP.getChildShapeNodeEditPart();
- List<ShapeNodeEditPart> movedChildrenParts = LifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts(AbstractExecutionSpecificationEditPart.this);
- executionSpecificationList.remove(movedPart); // ignore current action and its children
- executionSpecificationList.removeAll(movedChildrenParts);
- ShapeNodeEditPart parentBar = LifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList);
-
- Rectangle dotLineBounds = lifelineEP.getPrimaryShape().getFigureLifelineDotLineFigure().getBounds();
- int dotLineBarLocationX = dotLineBounds.x + dotLineBounds.width / 2 - LifelineXYLayoutEditPolicy.EXECUTION_INIT_WIDTH / 2;
- if(parentBar == null) {
- if(dotLineBarLocationX < copy.x) { // there is no parent bar, move to the center dotline position
- int dx = dotLineBarLocationX - copy.x;
- request.getMoveDelta().x += dx;
- rect.x += dx;
- }
- } else {
- while(!executionSpecificationList.isEmpty()) {
- Rectangle parentBounds = parentBar.getFigure().getBounds();
- int width = parentBounds.width > 0 ? parentBounds.width : LifelineXYLayoutEditPolicy.EXECUTION_INIT_WIDTH;
- int x = parentBounds.x + width / 2 + 1; // affixed to the parent bar
- int dx = x - copy.x;
- rect.x += dx;
- request.getMoveDelta().x += dx;
- copy.x = x;
-
- // check again to see if the new bar location overlaps with existing bars
- ShapeNodeEditPart part = LifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList);
- if(part == parentBar) {
- break;
- } else {
- parentBar = part;
- }
- }
- }
- }
-
- /**
- * Override for add elements on ExecutionSpecification
- */
- @Override
- public Command getCommand(Request request) {
- if(request instanceof CreateUnspecifiedTypeRequest) {
- return getParent().getCommand(request);
- }
- return super.getCommand(request);
- }
-
- /**
- * @generated NOT Override for redirecting creation request to the lifeline
- */
- @Override
- public void showSourceFeedback(Request request) {
- if(request instanceof CreateUnspecifiedTypeRequest) {
- getParent().showSourceFeedback(request);
- }
- super.showSourceFeedback(request);
- }
-
- /**
- * @generated NOT Override for redirecting creation request to the lifeline
- */
- @Override
- public void eraseSourceFeedback(Request request) {
- if(request instanceof CreateUnspecifiedTypeRequest) {
- getParent().eraseSourceFeedback(request);
- }
- super.eraseSourceFeedback(request);
- }
-
- @Override
- public void showTargetFeedback(Request request) {
- if(request instanceof CreateUnspecifiedTypeRequest) {
- getParent().showTargetFeedback(request);
- }
- super.showTargetFeedback(request);
- }
-
- @Override
- public void eraseTargetFeedback(Request request) {
- if(request instanceof CreateUnspecifiedTypeRequest) {
- getParent().eraseSourceFeedback(request);
- }
- super.eraseTargetFeedback(request);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
deleted file mode 100644
index 353cd16c66a..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Shape;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.uml2.uml.Message;
-
-public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart {
-
- private List messageEventParts;
-
- public AbstractMessageEditPart(View view) {
- super(view);
- }
-
- public View findChildByModel(EObject model) {
- List list = getModelChildren();
- if(list != null && list.size() > 0) {
- for(Object o : list) {
- if(!(o instanceof View) )
- continue;
-
- View view = (View) o;
- if(view.getElement() == model){
- return view;
- }
- }
- }
- return null;
- }
-
- @Override
- public List getChildren() {
- if (messageEventParts == null) {
- initMessageEventPart();
- }
- return super.getChildren();
- }
-
- protected void initMessageEventPart() {
- messageEventParts = new ArrayList();
-
- EObject element = this.resolveSemanticElement();
- if (!(element instanceof Message))
- return;
- Message message = (Message) element;
- UMLEdgeFigure edgeFigure = (UMLEdgeFigure) this.getFigure();
- final MessageEndEditPart sendEventPart = new MessageEndEditPart(
- message.getSendEvent(), this, new ConnectionLocator(edgeFigure,
- ConnectionLocator.SOURCE));
- messageEventParts.add(sendEventPart);
-
- final MessageEndEditPart receiveEventPart = new MessageEndEditPart(
- message.getReceiveEvent(), this, new ConnectionLocator(
- edgeFigure, ConnectionLocator.TARGET));
- messageEventParts.add(receiveEventPart);
-
- Diagram diagram = ((View) this.getModel()).getDiagram();
- sendEventPart.rebuildLinks(diagram);
- receiveEventPart.rebuildLinks(diagram);
-
- addChild(sendEventPart, -1);
- addChild(receiveEventPart, -1);
- }
-
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new MessageLabelEditPolicy());
- }
-
- @Override
- public EditPart getTargetEditPart(Request request) {
- if(request instanceof CreateUnspecifiedTypeConnectionRequest){
- List types = ((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes();
- if(types.contains(UMLElementTypes.Message_4009) || types.contains(UMLElementTypes.Message_4008)){
- return null;
- }
- }else if(request instanceof ReconnectRequest){
- ConnectionEditPart con = ((ReconnectRequest)request).getConnectionEditPart();
- if(con instanceof Message7EditPart || con instanceof Message6EditPart){
- return null;
- }
- }
- return super.getTargetEditPart(request);
- }
-
- protected void handleNotificationEvent(Notification notification) {
- super.handleNotificationEvent(notification);
- Object feature = notification.getFeature();
-
- MessageLabelEditPart labelPart = getMessageLabelEditPart();
- if(labelPart == null)
- return;
- if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
- labelPart.refreshFontColor();
- }else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
- labelPart.refreshFont();
- }
- }
-
- public MessageLabelEditPart getMessageLabelEditPart(){
- for(Object c : this.getChildren())
- if(c instanceof MessageLabelEditPart) {
- return (MessageLabelEditPart)c;
- }
- return null;
- }
-
- //public abstract IFigure getPrimaryShape() ;
-
- public void setLineWidth(int width) {
- if(getPrimaryShape() instanceof MessageFigure){
- MessageFigure edge = (MessageFigure)getPrimaryShape();
- edge.setLineWidth(width);
- }
- }
-
- public static class MessageFigure extends UMLEdgeFigure{
- @Override
- public void setLineWidth(int w) {
- super.setLineWidth(w);
- if(getSourceDecoration() instanceof Shape){
- ((Shape)getSourceDecoration()).setLineWidth(w);
- }
- if(getTargetDecoration() instanceof Shape){
- ((Shape)getTargetDecoration()).setLineWidth(w);
- }
- }
-
- @Override
- public void setForegroundColor(Color c) {
- super.setForegroundColor(c);
- if(getSourceDecoration() instanceof Shape){
- ((Shape)getSourceDecoration()).setForegroundColor(c);
- ((Shape)getSourceDecoration()).setBackgroundColor(c);
- }
- if(getTargetDecoration() instanceof Shape){
- ((Shape)getTargetDecoration()).setForegroundColor(c);
- ((Shape)getTargetDecoration()).setBackgroundColor(c);
- }
- }
- }
-
- static abstract class MessageLabelEditPart extends LabelEditPart {
-
- public MessageLabelEditPart(View view) {
- super(view);
- }
-
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if(NotationPackage.eINSTANCE.getLineStyle_LineColor().equals(feature)) {
- refreshFontColor();
- } else
- super.handleNotificationEvent(notification);
- }
-
- @Override
- public void refreshFontColor() {
- FontStyle style = (FontStyle)((org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart)getParent()).getPrimaryView().getStyle(NotationPackage.Literals.FONT_STYLE);
- if(style != null) {
- setFontColor(DiagramColorRegistry.getInstance().getColor(Integer.valueOf(style.getFontColor())));
- }
- }
-
- public void refreshFont() {
- super.refreshFont();
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ExecutionSpecificationEndEditPart.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ExecutionSpecificationEndEditPart.java
deleted file mode 100644
index fac23c92c04..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ExecutionSpecificationEndEditPart.java
+++ /dev/null
@@ -1,595 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Locator;
-import org.eclipse.draw2d.RelativeLocator;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gef.requests.DropRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.util.Log;
-import org.eclipse.gmf.runtime.common.core.util.Trace;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions;
-import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin;
-import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.IAnchorableFigure;
-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.gef.ui.figures.SlidableOvalAnchor;
-import org.eclipse.gmf.runtime.gef.ui.internal.figures.CircleFigure;
-import org.eclipse.gmf.runtime.notation.Anchor;
-import org.eclipse.gmf.runtime.notation.DecorationNode;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.IdentityAnchor;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.Shape;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-public class ExecutionSpecificationEndEditPart extends GraphicalEditPart
- implements INodeEditPart {
-
- private static final String DUMMY_TYPE = "999998";
- private static final int DEFAULT_SIZE = 16;
- private Locator locator;
- private OccurrenceSpecification executionSpecificationEnd;
-
- public ExecutionSpecificationEndEditPart(OccurrenceSpecification occurrenceSpecification, ShapeNodeEditPart parent, RelativeLocator locator ) {
- super(createDummyView(parent, occurrenceSpecification) );
- this.executionSpecificationEnd = occurrenceSpecification;
- this.setParent(parent);
- this.locator = locator;
- addToResource(parent.getNotationView(), this.getNotationView());
- }
-
- private static EObject createDummyView(ShapeNodeEditPart parent,
- EObject model) {
- final Shape node = new ShapeImpl() {
- public boolean eNotificationRequired() {
- return true;
- }
- };
-
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(DUMMY_TYPE);
- node.setElement(model);
-
- return node;
- }
-
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getView_SourceEdges().equals(feature))
- refreshSourceConnections();
- else if (NotationPackage.eINSTANCE.getView_TargetEdges()
- .equals(feature))
- refreshTargetConnections();
- else
- super.handleNotificationEvent(notification);
- }
-
- protected void addNotationalListeners() {
- if (hasNotationView()) {
- addListenerFilter("View", this,(View)getModel());
- }
- }
-
- static class DummyCommand extends org.eclipse.emf.common.command.AbstractCommand {
- public void execute() {
- }
-
- public void redo() {
- }
-
- public void undo() {
- }
-
- protected boolean prepare() {
- return true;
- }
- }
-
- private void addToResource(final View container, final View view) {
- CommandHelper.executeCommandWithoutHistory(getEditingDomain(), new DummyCommand() {
- public void execute() {
- ViewUtil.insertChildView(container, view,-1, false);
- }
- },true);
- }
-
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ExecutionSpecificationEndSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ExecutionSpecificationEndGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy(){
- protected void addSelectionHandles() { // remove handles
- }
- });
- }
-
- public void rebuildLinks(Diagram diagram) {
- helper.collectViews(diagram);
- EObject semanticModel = this.resolveSemanticElement();
- EAnnotation annotation = executionSpecificationEnd.getEAnnotation("Connections");
- if (annotation != null) {
- for (EObject eo : annotation.getReferences()) {
- View view = helper.findView(eo);
- if (view == null)
- continue; // should not happen
-
- EList edges = view.getSourceEdges();
- for (Object o : edges) {
- if (o instanceof Edge ) {
- if(needRestoreLink((Edge) o)) {
- restoreEdgeTarget((Edge) o);
- break;
- }
- }
- }
- }
- }
- }
-
- private boolean needRestoreLink(Edge e) {
- if(e.getTarget() == null)
- return true;
-
- EObject model = e.getTarget().getElement();
- if(!(model instanceof OccurrenceSpecification))
- return false;
-
- if(model == this.resolveSemanticElement()) {
- System.out.println( ((OccurrenceSpecification) model).getName() );
- if(!this.getNotationView().equals( e.getTarget()))
- return true;
- }
- return false;
- }
-
- private void restoreEdgeTarget(final Edge edge) {
- CommandHelper.executeCommandWithoutHistory(this.getEditingDomain(), new DummyCommand() {
- public void execute() {
- edge.setTarget((View) ExecutionSpecificationEndEditPart.this
- .getModel());
- }
- },true);
- }
-
- static ViewHelper helper = new ViewHelper();
-
- static class ViewHelper {
- Diagram diagram = null;
- Set<View> allViews = new HashSet<View>();
- Map<EObject, View> viewMaps = new HashMap<EObject, View>();
-
- View findView(EObject key) {
- return viewMaps.get(key);
- }
-
- void collectViews(Diagram d) {
- if (diagram != d) { // compare pointer ref
- diagram = d;
- allViews.clear();
- viewMaps.clear();
-
- getAllNestedViews(diagram, allViews);
- for (View v : allViews) {
- if (v instanceof DecorationNode)
- continue;
-
- viewMaps.put(v.getElement(), v);
- }
- }
- }
-
- static private void getAllNestedViews(View view, Set<View> allViews) {
- for (View childView : (List<View>) view.getChildren()) {
- getAllNestedViews(childView, allViews);
- allViews.add(childView);
- }
- }
- }
-
- static class ExecutionSpecificationEndGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
- IFigure executionSpecificationEndFeedback;
-
- @Override
- public void eraseTargetFeedback(Request request) {
- super.eraseSourceFeedback(request);
- if (executionSpecificationEndFeedback != null)
- removeFeedback(executionSpecificationEndFeedback);
- executionSpecificationEndFeedback = null;
- }
-
- protected void showTargetConnectionFeedback(
- DropRequest request) {
- if (executionSpecificationEndFeedback == null) {
- CircleFigure c = new CircleFigure(DEFAULT_SIZE,
- DEFAULT_SIZE);
- c.setForegroundColor(ColorConstants.black);
- ExecutionSpecificationEndEditPart p = (ExecutionSpecificationEndEditPart) getHost();
- IFigure parent = p.getFigure().getParent();
-
-
- Rectangle targetBounds = p.getFigure().getBounds().getCopy();
- p.getFigure().translateToAbsolute(targetBounds);
- //targetBounds.translate(0, DEFAULT_SIZE /2 );
-
- getFeedbackLayer().translateToRelative(targetBounds);
- getFeedbackLayer().translateFromParent(targetBounds);
-
- c.setBounds(targetBounds);
-
- addFeedback(c);
- executionSpecificationEndFeedback = c;
- }
- }
- }
-
- static class ReorientExecutionSpecificationEndCommand extends EditElementCommand{
- private ReorientReferenceRelationshipRequest request;
-
- public ReorientExecutionSpecificationEndCommand(ReorientReferenceRelationshipRequest request) {
- super(request.getLabel(), request.getNewRelationshipEnd(), request);
- this.request = request;
- }
-
- public boolean canExecute() {
- return true;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- // adding new end
- if(request.getNewRelationshipEnd() instanceof OccurrenceSpecification) {
- ExecutionSpecificationEndHelper.addConnectionSourceToExecutionSpecificationEnd((OccurrenceSpecification) request.getNewRelationshipEnd(), request.getReferenceOwner());
- // update uml model reference
- if(request.getReferenceOwner() instanceof Constraint) {
- ((Constraint)request.getReferenceOwner()).getConstrainedElements().add((OccurrenceSpecification) request.getNewRelationshipEnd());
- }else if(request.getReferenceOwner() instanceof Comment) {
- ((Comment) request.getReferenceOwner()).getAnnotatedElements().add( (OccurrenceSpecification) request.getNewRelationshipEnd());
- }
- }
- // removing old end
- if(request.getOldRelationshipEnd() instanceof OccurrenceSpecification) {
- ExecutionSpecificationEndHelper.removeConnectionSourceFromExecutionSpecificationEnd((OccurrenceSpecification) request.getOldRelationshipEnd(), request.getReferenceOwner());
- // update uml model reference
- if(request.getReferenceOwner() instanceof Constraint) {
- ((Constraint)request.getReferenceOwner()).getConstrainedElements().remove((OccurrenceSpecification) request.getOldRelationshipEnd());
- }else if(request.getReferenceOwner() instanceof Comment) {
- ((Comment) request.getReferenceOwner()).getAnnotatedElements().remove( (OccurrenceSpecification) request.getOldRelationshipEnd());
- }
- }
- return CommandResult.newOKCommandResult();
- }
- }
-
- static class ExecutionSpecificationEndSemanticEditPolicy extends SemanticEditPolicy{
-
- protected Command getSemanticCommand(
- final IEditCommandRequest request) {
- if (request instanceof CreateRelationshipRequest) {
- return getCreateRelationshipCommand((CreateRelationshipRequest) request);
- }
- else if( request instanceof ReorientReferenceRelationshipRequest) {
- return getGEFWrapper(new ReorientExecutionSpecificationEndCommand((ReorientReferenceRelationshipRequest) request ) ) ;
- }
- Command cmd = super.getSemanticCommand(request);
- return cmd;
- }
-
- protected Command getStartCreateRelationshipCommand(
- CreateRelationshipRequest req) {
- if (UMLElementTypes.ConstraintConstrainedElement_4011 == req
- .getElementType()) {
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommandEx(
- req, req.getSource(), req.getTarget()));
- }
- return null;
- }
-
- protected Command getCompleteCreateRelationshipCommand(
- CreateRelationshipRequest req) {
- if (UMLElementTypes.ConstraintConstrainedElement_4011 == req
- .getElementType()) {
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommandEx(
- req, req.getSource(), req.getTarget()));
- }else if(UMLElementTypes.CommentAnnotatedElement_4010 == req
- .getElementType()) {
- return getGEFWrapper(new CommentAnnotatedElementCreateCommandEx(req, req.getSource(), req.getTarget()));
- }
- return null;
- }
-
- protected Command getCreateRelationshipCommand(
- CreateRelationshipRequest req) {
- Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req)
- : getCompleteCreateRelationshipCommand(req);
- return command;
- }
-
- protected final Command getGEFWrapper(ICommand cmd) {
- return new ICommandProxy(cmd);
- }
- }
-
- public static class ExecutionSpecificationEndHelper{
- public static void removeConnectionSourceFromExecutionSpecificationEnd(OccurrenceSpecification executionOccurrence , EObject connectionSource) {
- EAnnotation annotation = executionOccurrence
- .getEAnnotation("Connections");
- if (annotation != null) {
- annotation.getReferences().remove( connectionSource);
- }
- }
-
- public static void addConnectionSourceToExecutionSpecificationEnd(OccurrenceSpecification executionOccurrence,EObject connectionSource) {
- EAnnotation annotation = executionOccurrence
- .getEAnnotation("Connections");
- if (annotation == null) {
- annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("Connections"); //$NON-NLS-1$
- executionOccurrence.getEAnnotations().add(annotation);
- }
- if( !annotation.getReferences().contains( connectionSource) )
- annotation.getReferences().add(connectionSource);
- }
- }
-
- static class CommentAnnotatedElementCreateCommandEx extends CommentAnnotatedElementCreateCommand{
-
- public CommentAnnotatedElementCreateCommandEx(
- CreateRelationshipRequest request, EObject source,
- EObject target) {
- super(request, source, target);
- }
-
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- CommandResult res = super.doExecuteWithResult(monitor, info);
- if (getTarget() instanceof OccurrenceSpecification) {
- ExecutionSpecificationEndHelper.addConnectionSourceToExecutionSpecificationEnd((OccurrenceSpecification) getTarget(), getSource());
- }
- return res;
- }
- }
-
- static class ConstraintConstrainedElementCreateCommandEx extends
- ConstraintConstrainedElementCreateCommand {
-
- public ConstraintConstrainedElementCreateCommandEx(
- CreateRelationshipRequest request, EObject source,
- EObject target) {
- super(request, source, target);
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
-
- CommandResult res = super.doExecuteWithResult(monitor, info);
- if (getTarget() instanceof OccurrenceSpecification) {
- ExecutionSpecificationEndHelper.addConnectionSourceToExecutionSpecificationEnd((OccurrenceSpecification) getTarget(), getSource());
- }
- return res;
- }
- }
-
- public Locator getLocator() {
- return locator;
- }
-
- protected IFigure createFigure() {
- IFigure fig = new ExecutionSpecificationEndFigure();
- fig.setForegroundColor(ColorConstants.black);
-// Rectangle b = fig.getBounds();
-// final ExecutionOccurrenceSpecification model = (ExecutionOccurrenceSpecification) this.resolveSemanticElement();
-// Label tooltip = new Label();
-// tooltip.setText(model.getName());
-// fig.setToolTip(tooltip);
-
- fig.setOpaque(false);
- return fig;
- }
-
- public boolean hasNotationView() {
- return true;
- }
-
- public ConnectionAnchor getSourceConnectionAnchor(
- ConnectionEditPart connection) {
- return null;
- }
-
- public ConnectionAnchor getTargetConnectionAnchor(
- ConnectionEditPart connEditPart) {
- final ConnectionNodeEditPart connection = (ConnectionNodeEditPart) connEditPart;
- String t = ""; //$NON-NLS-1$
- try {
- t = (String) getEditingDomain().runExclusive(
- new RunnableWithResult.Impl() {
-
- public void run() {
- Anchor a = ((Edge) connection.getModel())
- .getTargetAnchor();
- if (a instanceof IdentityAnchor)
- setResult(((IdentityAnchor) a).getId());
- else
- setResult(""); //$NON-NLS-1$
- }
- });
- } catch (InterruptedException e) {
- Trace.catching(DiagramUIPlugin.getInstance(),
- DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(),
- "getTargetConnectionAnchor", e); //$NON-NLS-1$
- Log.error(DiagramUIPlugin.getInstance(),
- DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
- "getTargetConnectionAnchor", e); //$NON-NLS-1$
- }
- IAnchorableFigure fig = ((IAnchorableFigure) getFigure());
- ConnectionAnchor a = fig.getConnectionAnchor(t);
- return a;
- }
-
- public ConnectionAnchor getTargetConnectionAnchor(Request request) {
- Point center = getFigure().getBounds().getCenter();
- getFigure().translateToAbsolute(center);
- Point pt = ((DropRequest) request).getLocation() == null ? center
- : new Point(((DropRequest) request).getLocation());
- if (request instanceof CreateRequest) {
- getFigure().translateToRelative(pt);
- }
- ConnectionAnchor a = ((IAnchorableFigure) getFigure())
- .getTargetConnectionAnchorAt(pt);
- return a;
- }
-
- public ConnectionAnchor getSourceConnectionAnchor(Request request) {
- return null;
- }
-
- public boolean canAttachNote() {
- return true;
- }
-
- public String mapConnectionAnchorToTerminal(ConnectionAnchor c) {
- return ((IAnchorableFigure) getFigure()).getConnectionAnchorTerminal(c);
- }
-
- /**
- * @see org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart#mapTerminalToConnectionAnchor(String)
- */
- public ConnectionAnchor mapTerminalToConnectionAnchor(String terminal) {
- return ((IAnchorableFigure) getFigure()).getConnectionAnchor(terminal);
- }
-
- protected List getModelSourceConnections() {
- return ViewUtil
- .getSourceConnectionsConnectingVisibleViews((View) getModel());
- }
-
- protected List getModelTargetConnections() {
- List list = ViewUtil
- .getTargetConnectionsConnectingVisibleViews((View) getModel());
- return list;
- }
-
- @Override
- public EditPart getTargetEditPart(Request request) {
- if(request instanceof CreateUnspecifiedTypeConnectionRequest){
- List types = ((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes();
- if(types.contains(UMLElementTypes.CommentAnnotatedElement_4010) || types.contains(UMLElementTypes.ConstraintConstrainedElement_4011)){
- return super.getTargetEditPart(request);
- }
- }else if(request instanceof ReconnectRequest){
- ConnectionEditPart con = ((ReconnectRequest)request).getConnectionEditPart();
- if(con instanceof CommentAnnotatedElementEditPart || con instanceof ConstraintConstrainedElementEditPart){
- return super.getTargetEditPart(request);
- }
- }
- return null;
- }
-
- static class ExecutionSpecificationEndAnchor extends SlidableOvalAnchor {
-
- public ExecutionSpecificationEndAnchor(CircleFigure circleFigure, PrecisionPoint p) {
- super(circleFigure, p);
- }
-
- public ExecutionSpecificationEndAnchor(CircleFigure circleFigure) {
- super(circleFigure);
- }
-
- public Point getLocation(Point reference) {
- return getBox().getCenter();
- }
- }
-
- class ExecutionSpecificationEndFigure extends CircleFigure {
- ExecutionSpecificationEndFigure() {
- super(DEFAULT_SIZE, DEFAULT_SIZE);
- }
-
- @Override
- protected void paintFigure(Graphics g) {
- Rectangle r = Rectangle.SINGLETON;
- r.setBounds(getBounds());
- r.width--;
- r.height--;
- // Hide
- //g.drawOval(r);
- }
-
- protected ConnectionAnchor createAnchor(PrecisionPoint p) {
- if (p == null)
- return createDefaultAnchor();
- return new ExecutionSpecificationEndAnchor(this, p);
- }
-
- protected ConnectionAnchor createDefaultAnchor() {
- return new ExecutionSpecificationEndAnchor(this);
- }
-
- public ConnectionAnchor getTargetConnectionAnchorAt(Point p) {
- try {
- return super.getTargetConnectionAnchorAt(p);
- } catch (Exception e) {
- return null;
- }
- };
-
- @Override
- public void validate() {
- locator.relocate(this); //place figure at north or south, ignore layout manager
- super.validate();
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java
deleted file mode 100644
index faa739a2ccb..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.notation.Bounds;
-import org.eclipse.gmf.runtime.notation.Shape;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.PartDecomposition;
-import org.eclipse.uml2.uml.UMLPackage;
-
-public abstract class InteractionFragmentEditPart extends ShapeNodeEditPart {
-
- public InteractionFragmentEditPart(View view) {
- super(view);
- }
-
- /**
- * Resize the InteractionFragmentFigure when the covered lifelines are selected in the
- * properties view.
- */
- public void resizeInteractionFragmentFigure() {
- Object obj = getModel();
- if(obj instanceof Shape) {
- // we get the element linked to this editpart
- EObject element = ((Shape)obj).getElement();
-
- if(element instanceof InteractionFragment) {
- // we get the list of the covered lifelinnes by the InteractionUse
- List<Lifeline> lifelineCoveredList = ((InteractionFragment)element).getCovereds();
-
- if(lifelineCoveredList != null && getParent() != null) {
- // we get the interactionCompartimentEditPart to have access to all lifelines
- // EditParts
- List<EditPart> childrenEditPart = getParent().getChildren();
- if(childrenEditPart != null) {
- // The max value guarantee that the first figure will set the minX value
- int minX = Integer.MAX_VALUE;
- int maxX = -Integer.MAX_VALUE;
- int maxR = -Integer.MAX_VALUE;
-
- for(EditPart childEditPart : childrenEditPart) {
- // we check all the EditParts to select only the lifelineEditParts
- if(childEditPart instanceof LifelineEditPart) {
- Object childModel = childEditPart.getModel();
- if(childModel instanceof Shape) {
- // we get the object Lifeline linked the selected
- // lifelineEditPart
- EObject childElement = ((Shape)childModel).getElement();
- if(childElement instanceof Lifeline) {
- Lifeline lifeline = (Lifeline)childElement;
- for(Lifeline lfn : lifelineCoveredList) {
- // we check if the lifeLine in the intreactionUse's
- // parent Interaction is a covered Lifeline
- if(lifeline.equals(lfn)) {
- LifelineEditPart liflelineEditPart = (LifelineEditPart)childEditPart;
- if(liflelineEditPart.getFigure().getBounds().x > maxX) {
- maxX = liflelineEditPart.getFigure().getBounds().x;
- // the maxR will represent the futur value of
- // the rectangle right value.
- maxR = liflelineEditPart.getFigure().getBounds().right();
-
- }
- if(liflelineEditPart.getFigure().getBounds().x < minX) {
- // the min value will represent the rectangle x
- // value.
- minX = liflelineEditPart.getFigure().getBounds().x;
- }
- }
- }
- }
- }
- }
- }
-
- if(minX != Integer.MAX_VALUE || maxR != -Integer.MAX_VALUE) {
- // after this loop we have the coordinate of two lifeline figure ,
- // even if we have more than two covered Lifelne we choose the
- // extremities.
- getNewSize(minX, maxR);
- }
- }
- }
- }
- }
- }
-
- /**
- * resize the interactinUse figure
- *
- * @param min
- * the min x position of a covered lifline
- * @param max
- * the max x position of a coverd lifeline
- *
- */
- private void getNewSize(int min, int max) {
- int h = getFigure().getBounds().height;
- int y = getFigure().getBounds().y;
-
- Dimension size = new Dimension(max - min, h);
-
- Point loc = new Point(min, y);
-
- ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * Update covered lifelines of a Interaction fragment
- *
- * @param newBounds
- */
- public void updateCoveredLifelines(Bounds newBounds) {
- Rectangle newBound = new Rectangle(newBounds.getX(), newBounds.getY(), newBounds.getWidth(), newBounds.getHeight());
- InteractionFragment combinedFragment = (InteractionFragment)resolveSemanticElement();
- EList<Lifeline> coveredLifelines = combinedFragment.getCovereds();
-
- List<Lifeline> coveredLifelinesToAdd = new ArrayList<Lifeline>();
- List<Lifeline> coveredLifelinesToRemove = new ArrayList<Lifeline>();
- EditPart interactionCompartment = getInteractionCompartment();
- if(interactionCompartment != null) {
- this.getFigure().translateToAbsolute(newBound);
- for(Object child : interactionCompartment.getChildren()) {
- if(child instanceof LifelineEditPart) {
- LifelineEditPart lifelineEditPart = (LifelineEditPart)child;
- updateCoveredLifelines(lifelineEditPart, newBound, coveredLifelinesToAdd, coveredLifelinesToRemove, coveredLifelines);
- }
- }
- }
- if(!coveredLifelinesToAdd.isEmpty()) {
- CommandHelper.executeCommandWithoutHistory(getEditingDomain(), AddCommand.create(getEditingDomain(), combinedFragment, UMLPackage.eINSTANCE.getInteractionFragment_Covered(), coveredLifelinesToAdd), true);
- }
- if(!coveredLifelinesToRemove.isEmpty()) {
- CommandHelper.executeCommandWithoutHistory(getEditingDomain(), RemoveCommand.create(getEditingDomain(), combinedFragment, UMLPackage.eINSTANCE.getInteractionFragment_Covered(), coveredLifelinesToRemove), true);
- }
-
- }
-
- // check lifelines in PartDecomposition, see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=364813
- private void updateCoveredLifelines(LifelineEditPart lifelineEditPart, Rectangle newBound, List<Lifeline> coveredLifelinesToAdd, List<Lifeline> coveredLifelinesToRemove, EList<Lifeline> coveredLifelines) {
- Lifeline lifeline = (Lifeline)lifelineEditPart.resolveSemanticElement();
-
- LifelineDotLineCustomFigure dotLineFigure = lifelineEditPart.getPrimaryShape().getFigureLifelineDotLineFigure();
- Rectangle dotLineBounds = dotLineFigure.getBounds().getCopy();
- Rectangle centralLineBounds = new Rectangle(dotLineBounds.x() + dotLineBounds.width() / 2, dotLineBounds.y(), 1, dotLineBounds.height());
- dotLineFigure.translateToAbsolute(centralLineBounds);
- if(newBound.intersects(centralLineBounds)) {
- if(!coveredLifelines.contains(lifeline)) {
- coveredLifelinesToAdd.add(lifeline);
- }
- } else if(coveredLifelines.contains(lifeline)) {
- coveredLifelinesToRemove.add(lifeline);
- }
-
- PartDecomposition partDecomposition = lifeline.getDecomposedAs();
- if(partDecomposition != null) {
- List subLifelines = lifelineEditPart.getChildren();
- for(Object child : subLifelines) {
- if(child instanceof LifelineEditPart) {
- updateCoveredLifelines((LifelineEditPart)child, newBound, coveredLifelinesToAdd, coveredLifelinesToRemove, coveredLifelines);
- }
- }
- }
- }
-
- /**
- * Find parent editpart of lifeline
- * @return EditPart
- */
- public EditPart getInteractionCompartment() {
- EditPart editPart = getParent();
- while (editPart != null
- && !(editPart instanceof InteractionInteractionCompartmentEditPart)) {
- editPart = editPart.getParent();
- }
- return editPart;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentCreationEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentCreationEditPolicy.java
deleted file mode 100644
index 54959d4084b..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentCreationEditPolicy.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Set;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OperandBoundsComputeHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.InteractionFragment;
-
-/**
- * This creation policy is used to move covered interaction fragments into the interaction operand
- * when creating a new combined fragment.
- *
- * @author mvelten
- *
- */
-public class CombinedFragmentCreationEditPolicy extends CreationEditPolicy {
-
- @SuppressWarnings("unchecked")
- @Override
- protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {
-
- Command createElementAndViewCmd = super.getCreateElementAndViewCommand(request);
-
- if(isDerivedCombinedFragment(request.getViewAndElementDescriptor().getSemanticHint())) {
-
- Rectangle selectionRect = getSelectionRectangle(request);
-
- Set<InteractionFragment> coveredInteractionFragments = SequenceUtil.getCoveredInteractionFragments(selectionRect, getHost(), null);
-
- request.getExtendedData().put(SequenceRequestConstant.COVERED_INTERACTIONFRAGMENTS, coveredInteractionFragments);
-
- // Add updating bounds command for Combined fragment createment
- String hint = request.getViewAndElementDescriptor().getSemanticHint();
- if(OperandBoundsComputeHelper.isDerivedCombinedFragment(hint)){
- if (createElementAndViewCmd instanceof ICommandProxy) {
- ICommandProxy commandProxy = (ICommandProxy) createElementAndViewCmd;
- ICommand realCmd = commandProxy.getICommand();
- if (realCmd instanceof CompositeCommand) {
- ICommand createUpdateBoundsCmd = OperandBoundsComputeHelper.createUpdateCFAndIOBoundsForCFCreationCommand(this.getHost(),request);
- if (createUpdateBoundsCmd != null)
- ((CompositeCommand) realCmd)
- .add(createUpdateBoundsCmd);
- }
- }
- }
- }
- return createElementAndViewCmd;
- }
-
- @Override
- protected Command getCreateCommand(CreateViewRequest request) {
- Command createViewCmd = super.getCreateCommand(request);
- if (createViewCmd instanceof ICommandProxy) {
- ICommandProxy commandProxy = (ICommandProxy) createViewCmd;
- CompositeCommand compositeCommand = null;
- ICommand realCmd = commandProxy.getICommand();
- if (realCmd instanceof CompositeCommand) {
- compositeCommand = (CompositeCommand) realCmd;
- } else {
- compositeCommand = new CompositeCommand(commandProxy.getLabel());
- compositeCommand.add(realCmd);
- realCmd = compositeCommand;
- }
- for (ViewDescriptor viewDescriptor : request.getViewDescriptors()) {
- String hint = viewDescriptor.getSemanticHint();
- if(isDerivedCombinedFragment(hint)) {
- // Add updating bounds command for Combined fragment createment
- if(OperandBoundsComputeHelper.isDerivedCombinedFragment(hint)){
- ICommand createUpdateBoundsCmd = OperandBoundsComputeHelper.createUpdateCFAndIOBoundsForCFCreationCommand(this.getHost(), request);
- if (createUpdateBoundsCmd != null)
- ((CompositeCommand) realCmd)
- .add(createUpdateBoundsCmd);
- }
- }
- }
-
- createViewCmd = new ICommandProxy(compositeCommand.reduce());
- }
- return createViewCmd;
- }
-
- /**
- * Retrieve the selection rectangle associated with the request.
- *
- * @param request
- * the request
- * @return
- */
- private Rectangle getSelectionRectangle(CreateViewAndElementRequest request) {
- Rectangle selectionRect = new Rectangle();
-
- Point location = request.getLocation();
- Dimension size = request.getSize();
-
- if(location != null) {
- selectionRect.x = location.x;
- selectionRect.y = location.y;
- } else {
- // default values (should not be triggered)
- selectionRect.x = 100;
- selectionRect.y = 100;
- }
-
- if(size != null) {
- selectionRect.height = size.height;
- selectionRect.width = size.width;
- } else {
- // default values hardcoded...
- selectionRect.height = 61;
- selectionRect.width = 112;
- }
-
- return selectionRect;
- }
-
- /**
- * Check if it is a combined fragment or something similar which needs this policy to move ift in the correct container.
- *
- * @param hint
- * the semantic hint
- * @return
- */
- private static boolean isDerivedCombinedFragment(String hint) {
- if(((IHintedType)UMLElementTypes.InteractionOperand_3005).getSemanticHint().equals(hint)) {
- return true;
- }
- if(((IHintedType)UMLElementTypes.CombinedFragment_3004).getSemanticHint().equals(hint)) {
- return true;
- }
- if(((IHintedType)UMLElementTypes.ConsiderIgnoreFragment_3007).getSemanticHint().equals(hint)) {
- return true;
- }
- return false;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentItemComponentEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentItemComponentEditPolicy.java
deleted file mode 100644
index 6f533edf68e..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentItemComponentEditPolicy.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ComponentEditPolicy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.util.CombinedFragmentDeleteHelper;
-import org.eclipse.uml2.uml.CombinedFragment;
-
-public class CombinedFragmentItemComponentEditPolicy extends ComponentEditPolicy {
-
- /**
- * Delete Combined fragment and child from the view. Also delete message if user wants. {@inheritDoc}
- */
- @Override
- protected Command createDeleteViewCommand(GroupRequest deleteRequest) {
-
- if(getEditingDomain() != null) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
-
- CommandProxy deleteView = new CommandProxy(super.createDeleteViewCommand(deleteRequest));
- if(getEObject() instanceof CombinedFragment) {
- CombinedFragment cf = (CombinedFragment)getEObject();
- CombinedFragmentEditPart host = (CombinedFragmentEditPart)getHost();
-
- ICommand prompt = CombinedFragmentDeleteHelper.createDeleteViewCommand(cf, getEditingDomain(), host);
- cmd.add(prompt);
- }
- cmd.add(deleteView);
- return new ICommandProxy(cmd.reduce());
- }
-
- return null;
- }
-
-
- /**
- * Copy from superclass as visibility is private
- *
- * @return the editing domain
- */
- private TransactionalEditingDomain getEditingDomain() {
- if(getHost() instanceof IGraphicalEditPart) {
- return ((IGraphicalEditPart)getHost()).getEditingDomain();
- } else if(getHost() instanceof IEditingDomainProvider) {
- Object domain = ((IEditingDomainProvider)getHost()).getEditingDomain();
- if(domain instanceof TransactionalEditingDomain) {
- return (TransactionalEditingDomain)domain;
- }
- }
- return null;
- }
-
- /**
- * Get the EObject of the host
- *
- * @return the EObject or null
- */
- private EObject getEObject() {
- if(getHost() instanceof GraphicalEditPart) {
- return ((GraphicalEditPart)getHost()).resolveSemanticElement();
- }
- return null;
- }
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java
deleted file mode 100644
index 9f32b299a1c..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-
-public class CreationOnMessageEditPolicy extends CreationEditPolicy {
-
- /**
- * Get the command after updating the request with appropriate occurrences
- *
- * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getCreateElementAndViewCommand(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest)
- *
- * @param request
- * the request
- * @return command or null
- */
- @Override
- protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {
- Map<String, Object> extendedData = request.getExtendedData();
-
- // record the nearest event if necessary
- String requestHint = request.getViewAndElementDescriptor().getSemanticHint();
- if(isCreatedOnOccurrenceSpecification(requestHint)) {
- EditPart hostPart = getHost();
- if(hostPart instanceof ConnectionNodeEditPart) {
- LifelineEditPart sourceLifeline = SequenceUtil.getParentLifelinePart(((ConnectionNodeEditPart)hostPart).getSource());
- LifelineEditPart targetLifeline = SequenceUtil.getParentLifelinePart(((ConnectionNodeEditPart)hostPart).getTarget());
- Entry<Point, List<OccurrenceSpecification>> eventAndLocation = null;
- if(sourceLifeline != null) {
- eventAndLocation = SequenceUtil.findNearestEvent(request.getLocation(), sourceLifeline);
- }
- if(targetLifeline != null && eventAndLocation == null) {
- eventAndLocation = SequenceUtil.findNearestEvent(request.getLocation(), targetLifeline);
- }
- // find an event near enough to create the constraint or observation
- List<OccurrenceSpecification> events = Collections.emptyList();
- Point location = null;
- if(eventAndLocation != null) {
- location = eventAndLocation.getKey();
- events = eventAndLocation.getValue();
- }
- if(extendedData.containsKey(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2)) {
- extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2, events);
- } else {
- extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, events);
- }
- if(extendedData.containsKey(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2)) {
- extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2, location);
- } else {
- extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION, location);
- }
- }
- }
- return super.getCreateElementAndViewCommand(request);
- }
-
- /**
- * Return true if creation must be performed on an occurrence specification
- *
- * @param requestHint
- * the hint of object to create
- * @return true if creation on an occurrence specification
- */
- private boolean isCreatedOnOccurrenceSpecification(String requestHint) {
- return isTimeHint(requestHint) || isDurationHint(requestHint);
- }
-
- /**
- * Return true if hint is for creating a duration observation/constraint
- *
- * @param requestHint
- * the hint of object to create
- * @return true if correct hint
- */
- private boolean isDurationHint(String requestHint) {
- String durCstOnLifelineHint = ((IHintedType)UMLElementTypes.DurationConstraint_3021).getSemanticHint();
- String durCstOnMessage = ((IHintedType)UMLElementTypes.DurationConstraint_3023).getSemanticHint();
- String durObsOnMessage = ((IHintedType)UMLElementTypes.DurationObservation_3024).getSemanticHint();
- return durCstOnLifelineHint.equals(requestHint) || durCstOnMessage.equals(requestHint) || durObsOnMessage.equals(requestHint);
- }
-
- /**
- * Return true if hint is for creating a time observation/constraint
- *
- * @param requestHint
- * the hint of object to create
- * @return true if correct hint
- */
- private boolean isTimeHint(String requestHint) {
- String timeConstraintHint = ((IHintedType)UMLElementTypes.TimeConstraint_3019).getSemanticHint();
- String timeObservationHint = ((IHintedType)UMLElementTypes.TimeObservation_3020).getSemanticHint();
- return timeConstraintHint.equals(requestHint) || timeObservationHint.equals(requestHint);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomConnectionHandleEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomConnectionHandleEditPolicy.java
deleted file mode 100644
index 552dfa53495..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomConnectionHandleEditPolicy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.requests.TargetRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConnectionHandleEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.handles.ConnectionHandle;
-import org.eclipse.gmf.runtime.diagram.ui.internal.tools.ConnectionHandleTool;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-
-public final class CustomConnectionHandleEditPolicy extends
- ConnectionHandleEditPolicy {
- protected List getHandleFigures() {
- List list = new ArrayList(2);
-
- String tooltip;
- tooltip = buildTooltip(ConnectionHandle.HandleDirection.INCOMING);
- if (tooltip != null) {
- list.add(new ConnectionHandle((IGraphicalEditPart) getHost(),
- ConnectionHandle.HandleDirection.INCOMING, tooltip));
- }
-
- tooltip = buildTooltip(ConnectionHandle.HandleDirection.OUTGOING);
- if (tooltip != null) {
- ConnectionHandle connectionHandle = new ConnectionHandle(
- (IGraphicalEditPart) getHost(),
- ConnectionHandle.HandleDirection.OUTGOING, tooltip);
- connectionHandle.setDragTracker(new ConnectionHandleTool(
- connectionHandle) {
- protected String getCommandName() {
- if (isInState(STATE_CONNECTION_STARTED
- | STATE_ACCESSIBLE_DRAG_IN_PROGRESS))
- return SequenceUtil.OBSERVATION_LINK_REQUEST_END;
- else
- return SequenceUtil.OBSERVATION_LINK_REQUEST_START;
- }
-
- // see also UMLPaletteFactory.createObservationLinkCreationTool()
- protected boolean updateTargetUnderMouse() {
- if (!isTargetLocked()) {
- EditPart editPart = getCurrentViewer()
- .findObjectAtExcluding(getLocation(), getExclusionSet(),
- getTargetingConditional());
- if (editPart != null)
- editPart = editPart.getTargetEditPart(getTargetRequest());
- // fix observation link moving over ExecutionSpecificationEditPart
- if (getTargetRequest() instanceof TargetRequest)
- ((TargetRequest) getTargetRequest()).setTargetEditPart(editPart);
- boolean changed = getTargetEditPart() != editPart;
- setTargetEditPart(editPart);
- return changed;
- } else
- return false;
- }
- });
- list.add(connectionHandle);
- }
-
- return list;
- }
-} \ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java
deleted file mode 100644
index 1d4ca1766c1..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java
+++ /dev/null
@@ -1,1188 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.commands.operations.IUndoableOperation;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
-import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.commands.wrappers.CommandProxyWithResult;
-import org.eclipse.papyrus.uml.diagram.common.commands.DeferredCreateCommand;
-import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.DurationObservationHelper;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.command.CreateLocatedConnectionViewCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragment2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentBodyEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConsiderIgnoreFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Constraint2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionUseEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message3EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message5EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message6EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message7EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceLinkMappingHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.uml2.uml.CombinedFragment;
-import org.eclipse.uml2.uml.ConnectableElement;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.DurationConstraint;
-import org.eclipse.uml2.uml.DurationObservation;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.GeneralOrdering;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-import org.eclipse.uml2.uml.IntervalConstraint;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.PackageableElement;
-import org.eclipse.uml2.uml.StateInvariant;
-import org.eclipse.uml2.uml.TimeObservation;
-
-/**
- * A policy to support dNd from the Model Explorer in the sequence diagram
- *
- */
-public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPolicy {
- public static final String LIFELINE_MISSING = "There is no representation of lifeline {0}";
-
- public static final String DIALOG_TITLE = "Element missing";
-
- public CustomDiagramDragDropEditPolicy() {
- super(SequenceLinkMappingHelper.getInstance());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Set<Integer> getDroppableElementVisualId() {
- Set<Integer> elementsVisualId = new HashSet<Integer>();
- elementsVisualId.add(LifelineEditPart.VISUAL_ID);
- elementsVisualId.add(ActionExecutionSpecificationEditPart.VISUAL_ID);
- elementsVisualId.add(BehaviorExecutionSpecificationEditPart.VISUAL_ID);
-
- elementsVisualId.add(InteractionUseEditPart.VISUAL_ID);
- elementsVisualId.add(InteractionEditPart.VISUAL_ID);
- elementsVisualId.add(InteractionOperandEditPart.VISUAL_ID);
-
- elementsVisualId.add(CombinedFragmentEditPart.VISUAL_ID);
-
- // CoRegion
- elementsVisualId.add(CombinedFragment2EditPart.VISUAL_ID);
-
- elementsVisualId.add(CommentAnnotatedElementEditPart.VISUAL_ID);
- elementsVisualId.add(ConsiderIgnoreFragmentEditPart.VISUAL_ID);
-
- elementsVisualId.add(ContinuationEditPart.VISUAL_ID);
- elementsVisualId.add(StateInvariantEditPart.VISUAL_ID);
- elementsVisualId.add(CommentEditPart.VISUAL_ID);
- elementsVisualId.add(CommentBodyEditPart.VISUAL_ID);
-
- elementsVisualId.add(ConstraintEditPart.VISUAL_ID);
- elementsVisualId.add(Constraint2EditPart.VISUAL_ID);
- elementsVisualId.add(ConstraintConstrainedElementEditPart.VISUAL_ID);
-
- elementsVisualId.add(DurationObservationEditPart.VISUAL_ID);
- elementsVisualId.add(TimeConstraintEditPart.VISUAL_ID);
- elementsVisualId.add(TimeObservationEditPart.VISUAL_ID);
- elementsVisualId.add(DurationConstraintEditPart.VISUAL_ID);
-
- elementsVisualId.add(PackageEditPart.VISUAL_ID);
-
- elementsVisualId.add(MessageEditPart.VISUAL_ID);
- elementsVisualId.add(Message2EditPart.VISUAL_ID);
- elementsVisualId.add(Message3EditPart.VISUAL_ID);
- elementsVisualId.add(Message4EditPart.VISUAL_ID);
- elementsVisualId.add(Message4EditPart.VISUAL_ID);
- elementsVisualId.add(Message5EditPart.VISUAL_ID);
- elementsVisualId.add(Message6EditPart.VISUAL_ID);
- elementsVisualId.add(Message7EditPart.VISUAL_ID);
- elementsVisualId.add(Message6EditPart.VISUAL_ID);
- elementsVisualId.add(GeneralOrderingEditPart.VISUAL_ID);
- elementsVisualId.add(DestructionOccurrenceSpecificationEditPart.VISUAL_ID);
- elementsVisualId.add(StateInvariantEditPart.VISUAL_ID);
- elementsVisualId.add(TimeConstraintEditPart.VISUAL_ID);
- elementsVisualId.add(DurationConstraintEditPart.VISUAL_ID);
- elementsVisualId.add(DurationConstraintInMessageEditPart.VISUAL_ID);
- elementsVisualId.add(TimeObservationEditPart.VISUAL_ID);
- elementsVisualId.add(DurationObservationEditPart.VISUAL_ID);
- elementsVisualId.add(LifelineEditPart.VISUAL_ID);
- // handle nodes on messages (no visual ID detected for them)
- elementsVisualId.add(-1);
- return elementsVisualId;
- }
-
-
- @Override
- protected IUndoableOperation getDropObjectCommand(
- DropObjectsRequest dropRequest, final EObject
- droppedObject) {
- IUndoableOperation dropObjectCommand = super.getDropObjectCommand(
- dropRequest, droppedObject);
- if (dropObjectCommand != null && dropObjectCommand.canExecute()) {
- return dropObjectCommand;
- }
- // fix bug 364696(https://bugs.eclipse.org/bugs/show_bug.cgi?id=364696)
- if (droppedObject instanceof ConnectableElement) {
- return doDropConnectableElement(dropRequest,
- (ConnectableElement) droppedObject);
- }
-
- return dropObjectCommand;
- }
-
- private IUndoableOperation doDropConnectableElement(
- DropObjectsRequest dropRequest,
- final ConnectableElement droppedObject) {
- Point location = dropRequest.getLocation();
- CreateViewRequest createShapeRequest = CreateViewRequestFactory
- .getCreateShapeRequest(UMLElementTypes.Lifeline_3001,
- UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
- createShapeRequest.setLocation(location);
-
- ViewDescriptor viewDescriptor =createShapeRequest.getViewDescriptors().get(0);
- CreateElementRequestAdapter elementAdapter =(CreateElementRequestAdapter) viewDescriptor.getElementAdapter();
- CreateElementRequest createElementRequest = (CreateElementRequest)elementAdapter.getAdapter(CreateElementRequest.class);
-
- // parameter "ConnectableElement" used in LifelineCreateCommand#doConfigure()
- createElementRequest.setParameter(SequenceRequestConstant.CONNECTABLE_ELEMENT,droppedObject);
- EditPart host = getHost();
- Command theRealCmd = ((IGraphicalEditPart) host)
- .getCommand(createShapeRequest);
-
- if (theRealCmd != null && theRealCmd.canExecute()) {
- return new CommandProxy(theRealCmd);
- }
- return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IElementType getUMLElementType(int elementID) {
- return UMLElementTypes.getElementType(elementID);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getNodeVisualID(View containerView, EObject domainElement) {
- return UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getLinkWithClassVisualID(EObject domainElement) {
- return UMLVisualIDRegistry.getLinkWithClassVisualID(domainElement);
- }
-
- @Override
- protected Command getSpecificDropCommand(DropObjectsRequest dropRequest, Element semanticElement, int nodeVISUALID, int linkVISUALID) {
- Point location = dropRequest.getLocation().getCopy();
-
- // handle specifically the case when node is on a message
- Command cmd = handleNodeOnMessage(semanticElement, nodeVISUALID, linkVISUALID);
- if(cmd != null) {
- return cmd;
- }
-
- if(nodeVISUALID != -1) {
- switch(nodeVISUALID) {
- case BehaviorExecutionSpecificationEditPart.VISUAL_ID:
- case ActionExecutionSpecificationEditPart.VISUAL_ID:
- return dropExecutionSpecification((ExecutionSpecification)semanticElement, nodeVISUALID, location);
- case DestructionOccurrenceSpecificationEditPart.VISUAL_ID:
- return dropDestructionOccurrence((DestructionOccurrenceSpecification)semanticElement, nodeVISUALID, location);
- case StateInvariantEditPart.VISUAL_ID:
- return dropStateInvariant((StateInvariant)semanticElement, nodeVISUALID, location);
- case TimeConstraintEditPart.VISUAL_ID:
- case DurationConstraintEditPart.VISUAL_ID:
- return dropIntervalConstraintInLifeline((IntervalConstraint)semanticElement, nodeVISUALID);
- case TimeObservationEditPart.VISUAL_ID:
- return dropTimeObservationInLifeline((TimeObservation)semanticElement, nodeVISUALID, location);
- case CombinedFragment2EditPart.VISUAL_ID:
- return dropCoRegion((CombinedFragment)semanticElement, nodeVISUALID, location);
- case CommentEditPart.VISUAL_ID:
- case ConstraintEditPart.VISUAL_ID:
- case Constraint2EditPart.VISUAL_ID:
- case InteractionUseEditPart.VISUAL_ID:
- case LifelineEditPart.VISUAL_ID:
- return dropNodeElement(semanticElement, nodeVISUALID, location);
- case ConsiderIgnoreFragmentEditPart.VISUAL_ID:
- case CombinedFragmentEditPart.VISUAL_ID:
- return dropCombinedFragment((CombinedFragment)semanticElement, nodeVISUALID, location);
- case ContinuationEditPart.VISUAL_ID:
- case InteractionOperandEditPart.VISUAL_ID:
- return dropCompartmentNodeElement(semanticElement, nodeVISUALID, location);
- default:
- return UnexecutableCommand.INSTANCE;
- }
- }
-
- if(linkVISUALID != -1) {
- switch(linkVISUALID) {
- case MessageEditPart.VISUAL_ID:
- case Message2EditPart.VISUAL_ID:
- case Message3EditPart.VISUAL_ID:
- case Message4EditPart.VISUAL_ID:
- case Message5EditPart.VISUAL_ID:
- case Message6EditPart.VISUAL_ID:
- case Message7EditPart.VISUAL_ID:
- return dropMessage(dropRequest, semanticElement, linkVISUALID);
- case GeneralOrderingEditPart.VISUAL_ID:
- return dropGeneralOrdering(dropRequest, semanticElement, linkVISUALID);
- default:
- return UnexecutableCommand.INSTANCE;
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the drop command for the Element
- *
- * @param element
- * the Element
- * @param nodeVISUALID
- * the node visual id
- * @return the drop command if the Element can be dropped
- */
- private Command dropNodeElement(Element element, int nodeVISUALID, Point location) {
- Element parent = element.getOwner();
- if (getHostObject().equals(parent)) {
- List<View> existingViews = DiagramEditPartsUtil.findViews(parent, getViewer());
- if (!existingViews.isEmpty()) {
- EditPart parentEditPart = lookForEditPart(parent);
- if (parentEditPart != null) {
- return new ICommandProxy(getDefaultDropNodeCommand(parentEditPart, nodeVISUALID, location, element));
- }
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the drop command for the Element
- *
- * @param element
- * the Element
- * @param nodeVISUALID
- * the node visual id
- * @return the drop command if the element can be dropped
- */
- private Command dropCombinedFragment(CombinedFragment combinedFragment, int nodeVISUALID, Point location) {
- Element parent = combinedFragment.getOwner();
- Element parentContainer = parent.getOwner();
- if (!(parentContainer instanceof CombinedFragment)) {
- parentContainer = parent;
- }
- if (getHostObject().equals(parentContainer)) {
- List<View> existingViews = DiagramEditPartsUtil.findViews(parent, getViewer());
- if (!existingViews.isEmpty()) {
- EditPart parentEditPart = lookForEditPart(parent);
- if (parentEditPart instanceof GraphicalEditPart) {
- // check if all lifelines coversby exist in diagram.
- Rectangle bounds = null;
- List<Lifeline> lifelines = combinedFragment.getCovereds();
- for (Lifeline lifeline : combinedFragment.getCovereds()) {
- EditPart lifelineEditPart = lookForEditPart(lifeline);
- if (lifelineEditPart == null) {
- Shell shell = Display.getCurrent().getActiveShell();
- MessageDialog.openError(shell, DIALOG_TITLE, NLS.bind(LIFELINE_MISSING, lifeline.getName()));
- return UnexecutableCommand.INSTANCE;
- }
- if (lifelineEditPart instanceof GraphicalEditPart) {
- GraphicalEditPart graphicalEditPart = (GraphicalEditPart) lifelineEditPart;
- Rectangle rectangle = graphicalEditPart.getFigure().getBounds().getCopy();
- graphicalEditPart.getFigure().translateToAbsolute(rectangle);
- if (bounds == null) {
- bounds = rectangle;
- } else {
- bounds = bounds.union(rectangle);
- }
- }
- }
- if (bounds == null) {
- return new ICommandProxy(getDefaultDropNodeCommand(parentEditPart, nodeVISUALID, location, combinedFragment));
- }
- location.x = bounds.x;
-
- return new ICommandProxy(dropCombinedFragment(getHost(), nodeVISUALID, location, new Dimension(bounds.width, 100), combinedFragment));
- }
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
-
- /*
- * To extend the method in superclass with an option Dimension size,
- *
- *
- * @param hostEP
- * @param nodeVISUALID
- * @param absoluteLocation
- * @param size
- * @param droppedObject
- * @return
- */
- protected ICommand dropCombinedFragment(EditPart hostEP, int nodeVISUALID, Point absoluteLocation, Dimension size, EObject droppedObject) {
- IHintedType type = ((IHintedType)getUMLElementType(nodeVISUALID));
-
- String semanticHint = null;
- if (type != null) {
- semanticHint = type.getSemanticHint();
- }
-
- List<View> existingViews = DiagramEditPartsUtil.findViews(droppedObject, getViewer());
-
- // only allow one view instance of a single element by diagram
- if(existingViews.isEmpty()) {
- IAdaptable elementAdapter = new EObjectAdapter(droppedObject);
-
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, semanticHint, ViewUtil.APPEND, true, getDiagramPreferencesHint());
- CreateViewRequest createViewRequest = new CreateViewRequest(descriptor);
- createViewRequest.setLocation(absoluteLocation);
- createViewRequest.setSize(size);
-
- // "ask" the host for a command associated with the
- // CreateViewRequest
- Command command = hostEP.getCommand(createViewRequest);
- if(createViewRequest.getNewObject() instanceof List) {
- for(Object object : (List<?>)createViewRequest.getNewObject()) {
- if(object instanceof IAdaptable) {
- DeferredCreateCommand createCommand2 = new DeferredCreateCommand(getEditingDomain(), droppedObject, (IAdaptable)object, getHost().getViewer());
- command.chain(new ICommandProxy(createCommand2));
- }
- }
- }
- // set the viewdescriptor as result
- // it then can be used as an adaptable to retrieve the View
- return new CommandProxyWithResult(command, descriptor);
- }
-
- return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the drop command in case the element can be handled as an element in a CombinedFragment
- *
- * @param element
- * @param nodeVISUALID
- * @param location
- * @return
- */
- private Command dropCompartmentNodeElement(Element element, int nodeVISUALID, Point location) {
- Element parent = element.getOwner();
- Element directParent = parent;
- if (parent instanceof InteractionOperand) {
- parent = parent.getOwner();
- }
- if (getHostObject().equals(parent)) {
- List<View> existingViews = DiagramEditPartsUtil.findViews(directParent, getViewer());
- if (!existingViews.isEmpty()) {
- EditPart parentEditPart = lookForEditPart(directParent);
- if (parentEditPart != null) {
- return new ICommandProxy(getDefaultDropNodeCommand(parentEditPart, nodeVISUALID, location, element));
- }
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the drop command in case the element can be handled as a node on a message
- *
- * @param semanticElement
- * the element being dropped from the model
- * @param nodeVISUALID
- * node visual id or -1
- * @param linkVISUALID
- * link visual id or -1
- * @return the drop command if the element can be dropped as a message label node, or null otherwise
- */
- private Command handleNodeOnMessage(Element semanticElement, int nodeVISUALID, int linkVISUALID) {
-
- if(nodeVISUALID == -1 && linkVISUALID == -1) {
- // detect duration observation on a message
- if(semanticElement instanceof DurationObservation) {
- List<NamedElement> events = ((DurationObservation)semanticElement).getEvents();
- if(events.size() >= 2) {
- return dropMessageNodeBetweenEvents(semanticElement, events.get(0), events.get(1));
- }
- }
- }
- if(isDurationConstraintHint(nodeVISUALID, linkVISUALID)) {
- // detect duration constraint on a message
- if(semanticElement instanceof DurationConstraint) {
- List<Element> events = ((DurationConstraint)semanticElement).getConstrainedElements();
- if(events.size() >= 2) {
- return dropMessageNodeBetweenEvents(semanticElement, events.get(0), events.get(1));
- }
- }
- }
- return null;
- }
-
- /**
- * Get the command to drop an element between two events in order to create a message label
- *
- * @param droppedElement
- * the dropped element
- * @param event1
- * first event (of type MessageOccurrenceSpecification)
- * @param event2
- * second event (of type MessageOccurrenceSpecification)
- * @param element
- * @return the command or false if the elements can not be dropped as message label
- */
- private Command dropMessageNodeBetweenEvents(Element droppedElement, Element event1, Element event2) {
- if(event1 instanceof MessageOccurrenceSpecification && event2 instanceof MessageOccurrenceSpecification) {
- if(!event1.equals(event2)) {
- boolean endsOfSameMessage = false;
- int visualId = -1;
- if(droppedElement instanceof DurationConstraint) {
- visualId = DurationConstraintInMessageEditPart.VISUAL_ID;
- endsOfSameMessage = DurationConstraintHelper.endsOfSameMessage((OccurrenceSpecification)event1, (OccurrenceSpecification)event2);
- } else if(droppedElement instanceof DurationObservation) {
- visualId = DurationObservationEditPart.VISUAL_ID;
- endsOfSameMessage = DurationObservationHelper.endsOfSameMessage((OccurrenceSpecification)event1, (OccurrenceSpecification)event2);
- }
- if(endsOfSameMessage) {
- Message message = ((MessageOccurrenceSpecification)event1).getMessage();
- // search a connection which matches the possessing message
- DiagramEditPart diag = DiagramEditPartsUtil.getDiagramEditPart(getHost());
- for(Object conn : diag.getConnections()) {
- if(conn instanceof ConnectionNodeEditPart) {
- EObject connElt = ((ConnectionNodeEditPart)conn).resolveSemanticElement();
- if(message.equals(connElt)) {
- // check that node isn't already represented, or dropping is impossible
- for(Object child : ((ConnectionNodeEditPart)conn).getChildren()) {
- if(child instanceof GraphicalEditPart) {
- EObject childElt = ((GraphicalEditPart)child).resolveSemanticElement();
- if(droppedElement.equals(childElt)) {
- return null;
- }
- }
- }
- return dropNodeOnMessage((PackageableElement)droppedElement, (ConnectionNodeEditPart)conn, visualId);
- }
- }
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Test whether visual ids are compatible with a duration constraint element
- *
- * @param nodeVISUALID
- * the detected node visual id
- * @param linkVISUALID
- * the detected link visual id
- * @return true if element may be a duration constraint
- */
- private boolean isDurationConstraintHint(int nodeVISUALID, int linkVISUALID) {
- if(linkVISUALID != -1) {
- return false;
- } else {
- return nodeVISUALID == -1 || nodeVISUALID == ConstraintEditPart.VISUAL_ID || nodeVISUALID == DurationConstraintEditPart.VISUAL_ID || nodeVISUALID == DurationConstraintInMessageEditPart.VISUAL_ID;
- }
- }
-
- /**
- * Drop a duration observation or a duration constraint on a message edit part
- *
- * @param durationLabelElement
- * the duration observation or duration constraint to display as message label
- * @param messageEditPart
- * the containing message edit part
- * @param nodeVISUALID
- * the label node visual id
- * @return the command or UnexecutableCommand
- */
- private Command dropNodeOnMessage(PackageableElement durationLabelElement, ConnectionNodeEditPart messageEditPart, int nodeVISUALID) {
- IAdaptable elementAdapter = new EObjectAdapter(durationLabelElement);
-
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType)getUMLElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, false, getDiagramPreferencesHint());
- return messageEditPart.getCommand(new CreateViewRequest(descriptor));
- }
-
- /**
- * Drop a time observation on a lifeline.
- *
- * @param observation
- * the time constraint
- * @param nodeVISUALID
- * the node visual id
- * @param dropLocation
- * @return the command if the lifeline is the correct one or UnexecutableCommand
- */
- private Command dropTimeObservationInLifeline(TimeObservation observation, int nodeVISUALID, Point dropLocation) {
- CompoundCommand cc = new CompoundCommand("Drop");
- IAdaptable elementAdapter = new EObjectAdapter(observation);
-
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType)getUMLElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
- cc.add(getHost().getCommand(new CreateViewRequest(descriptor)));
-
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(getHost());
- if(lifelinePart != null) {
- NamedElement occ1 = observation.getEvent();
- if(occ1 instanceof OccurrenceSpecification) {
- Point middlePoint = SequenceUtil.findLocationOfEvent(lifelinePart, (OccurrenceSpecification)occ1);
- if(middlePoint != null) {
- int height = getDefaultDropHeight(nodeVISUALID);
- Point startPoint = middlePoint.getCopy();
- if(height > 0) {
- startPoint.translate(0, -height / 2);
- }
- Rectangle newBounds = new Rectangle(startPoint, new Dimension(-1, height));
- lifelinePart.getFigure().translateToRelative(newBounds);
- Point parentLoc = lifelinePart.getLocation();
- newBounds.translate(parentLoc.getNegated());
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", descriptor, newBounds);
- cc.add(new ICommandProxy(setBoundsCommand));
- return cc;
- }
- }
- }
-
- if(getHost() instanceof InteractionInteractionCompartmentEditPart){
- Rectangle newBounds = new Rectangle(dropLocation, new Dimension(-1, -1));
- ((InteractionInteractionCompartmentEditPart)getHost()).getFigure().translateToRelative(newBounds);
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", descriptor, newBounds);
- cc.add(new ICommandProxy(setBoundsCommand));
- return cc;
- }
-
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Drop an interval constraint (duration or time) on a lifeline.
- *
- * @param constraint
- * the interval constraint
- * @param nodeVISUALID
- * the node visual id
- * @return the command if the lifeline is the correct one or UnexecutableCommand
- */
- private Command dropIntervalConstraintInLifeline(IntervalConstraint constraint, int nodeVISUALID) {
- CompoundCommand cc = new CompoundCommand("Drop");
- IAdaptable elementAdapter = new EObjectAdapter(constraint);
-
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType)getUMLElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
- cc.add(getHost().getCommand(new CreateViewRequest(descriptor)));
-
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(getHost());
- if(lifelinePart != null && constraint.getConstrainedElements().size() >= 2) {
- Element occ1 = constraint.getConstrainedElements().get(0);
- Element occ2 = constraint.getConstrainedElements().get(1);
- if(occ1 instanceof OccurrenceSpecification && occ2 instanceof OccurrenceSpecification) {
- Point startPoint = SequenceUtil.findLocationOfEvent(lifelinePart, (OccurrenceSpecification)occ1);
- Point endPoint = SequenceUtil.findLocationOfEvent(lifelinePart, (OccurrenceSpecification)occ2);
- if(startPoint != null && endPoint != null) {
- int height = endPoint.y - startPoint.y;
- Rectangle newBounds = null;
- if(height < 0) {
- newBounds = new Rectangle(endPoint, new Dimension(-1, -height));
- } else {
- newBounds = new Rectangle(startPoint, new Dimension(-1, height));
- }
- lifelinePart.getFigure().translateToRelative(newBounds);
- Point parentLoc = lifelinePart.getLocation();
- newBounds.translate(parentLoc.getNegated());
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", descriptor, newBounds);
- cc.add(new ICommandProxy(setBoundsCommand));
- return cc;
- }
- }
- } else if(lifelinePart != null && constraint.getConstrainedElements().size() == 1) {
- Element occ1 = constraint.getConstrainedElements().get(0);
- if(occ1 instanceof OccurrenceSpecification) {
- Point middlePoint = SequenceUtil.findLocationOfEvent(lifelinePart, (OccurrenceSpecification)occ1);
- if(middlePoint != null) {
- int height = getDefaultDropHeight(nodeVISUALID);
- Point startPoint = middlePoint.getCopy();
- if(height > 0) {
- startPoint.translate(0, -height / 2);
- }
- Rectangle newBounds = new Rectangle(startPoint, new Dimension(-1, height));
- lifelinePart.getFigure().translateToRelative(newBounds);
- Point parentLoc = lifelinePart.getLocation();
- newBounds.translate(parentLoc.getNegated());
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", descriptor, newBounds);
- cc.add(new ICommandProxy(setBoundsCommand));
- return cc;
- }
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the default height to set to a drop object. This method is useful for dropped objects which must be positioned relatively to their center.
- *
- * @param nodeVISUALID
- * the node visual id
- * @return arbitrary default height for the node visual id (eventually -1)
- */
- private int getDefaultDropHeight(int nodeVISUALID) {
- if(TimeConstraintEditPart.VISUAL_ID == nodeVISUALID || TimeObservationEditPart.VISUAL_ID == nodeVISUALID) {
- return 2;
- }
- return -1;
- }
-
- private Command dropStateInvariant(StateInvariant stateInvariant, int nodeVISUALID, Point location) {
-
- // an StateInvariant covereds systematically a unique lifeline
- Lifeline lifeline = stateInvariant.getCovereds().get(0);
- // Check that the container view is the view of the lifeline
- if(lifeline.equals(getHostObject())) {
- return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, location, stateInvariant));
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get lifelines element which contains these existingViews
- *
- * @param existingViews
- * the existing views.
- * @return the list of lifeline.
- */
- private List<Lifeline> getLifelines(List<View> existingViews) {
- List<Lifeline> lifelines = new ArrayList<Lifeline>();
- for(View view : existingViews) {
- EObject eObject = ViewUtil.resolveSemanticElement((View)view.eContainer());
- if(eObject instanceof Lifeline) {
- lifelines.add((Lifeline)eObject);
- }
- }
- return lifelines;
- }
-
- /**
- * Drop a destructionEvent on a lifeline
- *
- * @param destructionOccurence
- * the destructionEvent to drop
- * @param nodeVISUALID
- * the node visualID
- * @return the command to drop the destructionEvent on a lifeline if allowed.
- */
- private Command dropDestructionOccurrence(DestructionOccurrenceSpecification destructionOccurence, int nodeVISUALID, Point location) {
- // Get all the view of this destructionEvent.
- List<View> existingViews = DiagramEditPartsUtil.findViews(destructionOccurence, getViewer());
- // Get the lifelines containing the graphical destructionEvent
- List<Lifeline> lifelines = getLifelines(existingViews);
-
- // If the list of lifeline already containing the destructionEvent doesn't contain the lifeline targeted.
- if(!lifelines.contains(getHostObject())) {
- Lifeline lifeline = (Lifeline)getHostObject();
- for(InteractionFragment ift : lifeline.getCoveredBys()) {
- if(ift instanceof DestructionOccurrenceSpecification) {
- DestructionOccurrenceSpecification occurrenceSpecification = (DestructionOccurrenceSpecification)ift;
- // if the event of the occurrenceSpecification is the DestructionEvent, create the command
- if(destructionOccurence.equals(occurrenceSpecification)) {
- return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, location, destructionOccurence));
- }
- }
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the command to drop an execution specification node
- *
- * @param es
- * execution specification
- * @param nodeVISUALID
- * the execution specification's visual id
- * @param location
- * the location of the drop request
- * @return the drop command
- */
- private Command dropExecutionSpecification(ExecutionSpecification es, int nodeVISUALID, Point location) {
- List<View> existingViews = DiagramEditPartsUtil.findViews(es, getViewer());
- // only allow one view instance of a single element by diagram
- if(existingViews.isEmpty()) {
- // Find the lifeline of the ES
- if(es.getStart() != null && !es.getStart().getCovereds().isEmpty()) {
- // an Occurrence Specification covers systematically a unique lifeline
- Lifeline lifeline = es.getStart().getCovereds().get(0);
- // Check that the container view is the view of the lifeline
- if(lifeline.equals(getHostObject())) {
- //return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, location, es));
-
-
- IHintedType type = ((IHintedType)getUMLElementType(nodeVISUALID));
-
- String semanticHint = null;
- if(type != null) {
- semanticHint = type.getSemanticHint();
- }
-
- IAdaptable elementAdapter = new EObjectAdapter(es);
-
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, semanticHint, ViewUtil.APPEND, true, getDiagramPreferencesHint());
- CreateViewRequest createViewRequest = new CreateViewRequest(descriptor);
- // find best bounds
- Rectangle bounds = getExecutionSpecificationBounds(es);
- if(bounds != null) {
- createViewRequest.setLocation(bounds.getLocation());
- createViewRequest.setSize(bounds.getSize());
- } else {
- createViewRequest.setLocation(location);
- }
-
- // "ask" the host for a command associated with the CreateViewRequest
- Command command = getHost().getCommand(createViewRequest);
- // set the viewdescriptor as result
- // it then can be used as an adaptable to retrieve the View
- return new ICommandProxy(new CommandProxyWithResult(command, descriptor));
- }
- }
- }
-
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the command to drop an code region node
- *
- * @param combinedFragment
- * @param nodeVISUALID
- * @param location
- * @return
- */
- private Command dropCoRegion(CombinedFragment combinedFragment, int nodeVISUALID, Point location) {
- List<View> existingViews = DiagramEditPartsUtil.findViews(combinedFragment, getViewer());
- // only allow one view instance of a single element by diagram
- if(existingViews.isEmpty()) {
- IGraphicalEditPart hostEditpart = (IGraphicalEditPart) getHost();
- EObject element = hostEditpart.getNotationView().getElement();
- if (element instanceof Lifeline) {
- IHintedType type = ((IHintedType)getUMLElementType(nodeVISUALID));
-
- String semanticHint = null;
- if (type != null) {
- semanticHint = type.getSemanticHint();
- }
-
- IAdaptable elementAdapter = new EObjectAdapter(combinedFragment);
-
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, semanticHint, ViewUtil.APPEND, true, getDiagramPreferencesHint());
- CreateViewRequest createViewRequest = new CreateViewRequest(descriptor);
- createViewRequest.setLocation(location);
-
- // "ask" the host for a command associated with the CreateViewRequest
- Command command = getHost().getCommand(createViewRequest);
- // set the viewdescriptor as result
- // it then can be used as an adaptable to retrieve the View
- return new ICommandProxy(new CommandProxyWithResult(command, descriptor));
- }
- }
-
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Get the advised bounds to drop an execution specification
- *
- * @param es
- * the dropped execution specification
- * @return bounds of the es in absolute coordinates or null
- */
- private Rectangle getExecutionSpecificationBounds(ExecutionSpecification es) {
- Point startLocation = null;
- Point finishLocation = null;
- Rectangle possibleStartLocations = null;
- Rectangle possibleFinishLocations = null;
- // end events of the link
- OccurrenceSpecification startEvent = es.getStart();
- OccurrenceSpecification finishEvent = es.getFinish();
- if(startEvent != null && finishEvent != null && getHost() instanceof LifelineEditPart) {
- LifelineEditPart hostLifeline = (LifelineEditPart)getHost();
- // find location constraints for source
- startLocation = SequenceUtil.findLocationOfEvent((LifelineEditPart)getHost(), startEvent);
- if(startLocation == null) {
- possibleStartLocations = SequenceUtil.findPossibleLocationsForEvent(hostLifeline, startEvent);
- }
- // find location constraints for target
- finishLocation = SequenceUtil.findLocationOfEvent(hostLifeline, finishEvent);
- if(finishLocation == null) {
- possibleFinishLocations = SequenceUtil.findPossibleLocationsForEvent(hostLifeline, finishEvent);
- }
- // find start and finish locations with correct y (start.y < finish.y) and proportions
- if(startLocation == null) {
- if(finishLocation != null) {
- int top = possibleStartLocations.x;
- int bottom = possibleStartLocations.bottom();
- if(top > finishLocation.y) {
- return null;
- } else {
- startLocation = possibleStartLocations.getTop();
- startLocation.y = (top + Math.min(bottom, finishLocation.y)) / 2;
- }
- } else {
- int topS = possibleStartLocations.y;
- int bottomS = possibleStartLocations.bottom();
- int topF = possibleFinishLocations.y;
- int bottomF = possibleFinishLocations.bottom();
- if(topS > bottomF) {
- return null;
- } else {
- startLocation = possibleStartLocations.getTop();
- finishLocation = possibleFinishLocations.getBottom();
- if(bottomS<topF){
- startLocation.y = (topS + bottomS) / 2;
- finishLocation.y = (topF + bottomF) / 2;
- } else {
- startLocation.y = (topS + bottomS + topS + topF) / 4;
- finishLocation.y = (bottomF + topF + bottomF + bottomS) / 4;
- }
- }
- }
- }
- if(finishLocation == null) {
- // startLocation != null
- int top = possibleFinishLocations.y;
- int bottom = possibleFinishLocations.bottom();
- if(bottom < startLocation.y) {
- return null;
- } else {
- finishLocation = possibleFinishLocations.getBottom();
- finishLocation.y = (bottom + Math.max(top, startLocation.y)) / 2;
- }
- }
- // deduce bounds
- Rectangle result = new Rectangle(startLocation, finishLocation);
- result.width = LifelineXYLayoutEditPolicy.EXECUTION_INIT_WIDTH;
- return result;
- }
- return null;
- }
-
- /**
- * Get the command to drop a message link
- *
- * @param dropRequest
- * request to drop
- * @param semanticLink
- * message link
- * @param linkVISUALID
- * the message's visual id
- * @return the drop command
- */
- private Command dropMessage(DropObjectsRequest dropRequest, Element semanticLink, int linkVISUALID) {
- Collection<?> sources = SequenceLinkMappingHelper.getInstance().getSource(semanticLink);
- Collection<?> targets = SequenceLinkMappingHelper.getInstance().getTarget(semanticLink);
- if(!sources.isEmpty() && !targets.isEmpty()) {
- Element source = (Element)sources.toArray()[0];
- Element target = (Element)targets.toArray()[0];
- return getDropLocatedLinkCommand(dropRequest, source, target, linkVISUALID, semanticLink);
- } else {
- return UnexecutableCommand.INSTANCE;
- }
- }
-
- /**
- * The method provides command to create the binary link into the diagram. If the source and the
- * target views do not exist, these views will be created.
- *
- * This implementation is very similar to
- * {@link CommonDiagramDragDropEditPolicy#dropBinaryLink(CompositeCommand, Element, Element, int, Point, Element)}.
- *
- * @param dropRequest
- * the drop request
- * @param cc
- * the composite command that will contain the set of command to create the binary
- * link
- * @param source
- * the element source of the link
- * @param target
- * the element target of the link
- * @param linkVISUALID
- * the link VISUALID used to create the view
- * @param location
- * the location the location where the view will be be created
- * @param semanticLink
- * the semantic link that will be attached to the view
- *
- * @return the composite command
- */
- protected Command getDropLocatedLinkCommand(DropObjectsRequest dropRequest, Element source, Element target, int linkVISUALID, Element semanticLink) {
- // look for editpart
- GraphicalEditPart sourceEditPart = (GraphicalEditPart)lookForEditPart(source);
- GraphicalEditPart targetEditPart = (GraphicalEditPart)lookForEditPart(target);
-
- CompositeCommand cc = new CompositeCommand("Drop");
-
- // descriptor of the link
- CreateConnectionViewRequest.ConnectionViewDescriptor linkdescriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(getUMLElementType(linkVISUALID), ((IHintedType)getUMLElementType(linkVISUALID)).getSemanticHint(), getDiagramPreferencesHint());
-
- // get source and target adapters, creating the add commands if necessary
- IAdaptable sourceAdapter = null;
- IAdaptable targetAdapter = null;
- if(sourceEditPart == null) {
- ICommand createCommand = getDefaultDropNodeCommand(getLinkSourceDropLocation(dropRequest.getLocation(), source, target), source);
- cc.add(createCommand);
-
- sourceAdapter = (IAdaptable)createCommand.getCommandResult().getReturnValue();
- } else {
- sourceAdapter = new SemanticAdapter(null, sourceEditPart.getModel());
- }
- if(targetEditPart == null) {
- ICommand createCommand = getDefaultDropNodeCommand(getLinkTargetDropLocation(dropRequest.getLocation(), source, target), target);
- cc.add(createCommand);
-
- targetAdapter = (IAdaptable)createCommand.getCommandResult().getReturnValue();
- } else {
- targetAdapter = new SemanticAdapter(null, targetEditPart.getModel());
- }
-
- CreateLocatedConnectionViewCommand aLinkCommand = new CreateLocatedConnectionViewCommand(getEditingDomain(), ((IHintedType)getUMLElementType(linkVISUALID)).getSemanticHint(), sourceAdapter, targetAdapter, getViewer(), getDiagramPreferencesHint(), linkdescriptor, null);
- aLinkCommand.setElement(semanticLink);
- Point[] sourceAndTarget = getLinkSourceAndTargetLocations(semanticLink, sourceEditPart, targetEditPart);
- aLinkCommand.setLocations(sourceAndTarget[0], sourceAndTarget[1]);
- cc.compose(aLinkCommand);
- return new ICommandProxy(cc);
- }
-
- /**
- * Get the source and target recommended points for creating the link
- *
- * @param semanticLink
- * link to create
- * @param sourceEditPart
- * edit part source of the link
- * @param targetEditPart
- * edit part target of the link
- * @return a point array of size 2, with eventually null values (when no point constraint). Index 0 : source location, 1 : target location
- */
- private Point[] getLinkSourceAndTargetLocations(Element semanticLink, GraphicalEditPart sourceEditPart, GraphicalEditPart targetEditPart) {
- // index 0 : source location, 1 : target location
- Point[] sourceAndTarget = new Point[]{ null, null };
- // end events of the link
- OccurrenceSpecification sourceEvent = null;
- OccurrenceSpecification targetEvent = null;
- if(semanticLink instanceof Message) {
- MessageEnd sendEvent = ((Message)semanticLink).getSendEvent();
- if(sendEvent instanceof OccurrenceSpecification) {
- sourceEvent = (OccurrenceSpecification)sendEvent;
- }
- MessageEnd rcvEvent = ((Message)semanticLink).getReceiveEvent();
- if(rcvEvent instanceof OccurrenceSpecification) {
- targetEvent = (OccurrenceSpecification)rcvEvent;
- }
- } else if(semanticLink instanceof GeneralOrdering) {
- sourceEvent = ((GeneralOrdering)semanticLink).getBefore();
- targetEvent = ((GeneralOrdering)semanticLink).getAfter();
- }
- if(sourceEvent != null || targetEvent != null) {
- Rectangle possibleSourceLocations = null;
- Rectangle possibleTargetLocations = null;
- // find location constraints for source
- if(sourceEvent != null && sourceEditPart instanceof LifelineEditPart) {
- sourceAndTarget[0] = SequenceUtil.findLocationOfEvent((LifelineEditPart)sourceEditPart, sourceEvent);
- if(sourceAndTarget[0] == null) {
- possibleSourceLocations = SequenceUtil.findPossibleLocationsForEvent((LifelineEditPart)sourceEditPart, sourceEvent);
- }
- }
- // find location constraints for target
- if(targetEvent != null && targetEditPart instanceof LifelineEditPart) {
- sourceAndTarget[1] = SequenceUtil.findLocationOfEvent((LifelineEditPart)targetEditPart, targetEvent);
- if(sourceAndTarget[1] == null) {
- possibleTargetLocations = SequenceUtil.findPossibleLocationsForEvent((LifelineEditPart)targetEditPart, targetEvent);
- }
- }
- // deduce a possibility
- if(sourceAndTarget[0] == null && possibleSourceLocations != null) {
- // we must fix the source
- if(sourceAndTarget[1] == null && possibleTargetLocations == null) {
- // no target constraint, take center for source
- sourceAndTarget[0] = possibleSourceLocations.getCenter();
- } else if(sourceAndTarget[1] != null) {
- // target is fixed, find arranging source
- int topSource = possibleSourceLocations.y;
- int centerSource = possibleSourceLocations.getCenter().y;
- if(sourceAndTarget[1].y < topSource) {
- // we would draw an uphill message (forbidden).
- // return best locations (command will not execute correctly and handle error report)
- sourceAndTarget[0] = possibleSourceLocations.getTop();
- } else if(centerSource <= sourceAndTarget[1].y) {
- // simply fix to the center of constraint
- sourceAndTarget[0] = possibleSourceLocations.getCenter();
- } else {
- // horizontal message makes source as near as possible to the center
- sourceAndTarget[0] = possibleSourceLocations.getCenter();
- sourceAndTarget[0].y = sourceAndTarget[1].y;
- }
- } else {
- // possibleTargetLocations !=null
- // find arranging target and source
- int centerTarget = possibleTargetLocations.getCenter().y;
- int bottomTarget = possibleTargetLocations.bottom();
- int topSource = possibleSourceLocations.y;
- int centerSource = possibleSourceLocations.getCenter().y;
- if(bottomTarget < topSource) {
- // we would draw an uphill message (forbidden).
- // return best locations (command will not execute correctly and handle error report)
- sourceAndTarget[0] = possibleSourceLocations.getTop();
- sourceAndTarget[1] = possibleTargetLocations.getBottom();
- } else if(centerSource <= centerTarget) {
- // simply fix to centers
- sourceAndTarget[0] = possibleSourceLocations.getCenter();
- sourceAndTarget[1] = possibleTargetLocations.getCenter();
- } else {
- // horizontal message makes source and target as near as possible to the centers
- sourceAndTarget[0] = possibleSourceLocations.getCenter();
- sourceAndTarget[0].y = (topSource + bottomTarget) / 2;
- sourceAndTarget[1] = possibleTargetLocations.getCenter();
- sourceAndTarget[1].y = (topSource + bottomTarget) / 2;
- }
- }
- }
- if(sourceAndTarget[1] == null && possibleTargetLocations != null) {
- // we must fix the target
- // fixedSourceLocation == null => possibleSourceLocations == null
- // source is fixed, find arranging target
- int centerTarget = possibleTargetLocations.getCenter().y;
- int bottomTarget = possibleTargetLocations.bottom();
- if(sourceAndTarget[0] == null) {
- // simply fix to the center of constraint
- sourceAndTarget[1] = possibleTargetLocations.getCenter();
- } else if(bottomTarget < sourceAndTarget[0].y) {
- // we would draw an uphill message (forbidden).
- // return best locations (command will not execute correctly and handle error report)
- sourceAndTarget[1] = possibleTargetLocations.getBottom();
- } else if(sourceAndTarget[0].y <= centerTarget) {
- // simply fix to the center of constraint
- sourceAndTarget[1] = possibleTargetLocations.getCenter();
- } else {
- // horizontal message makes target as near as possible to the center
- sourceAndTarget[1] = possibleTargetLocations.getCenter();
- sourceAndTarget[1].y = sourceAndTarget[0].y;
- }
- }
- }
- return sourceAndTarget;
- }
-
- /**
- * Get the command to drop a general ordering link
- *
- * @param dropRequest
- * request to drop
- * @param semanticLink
- * general ordering link
- * @param linkVISUALID
- * the link's visual id
- * @return the drop command
- */
- private Command dropGeneralOrdering(DropObjectsRequest dropRequest, Element semanticLink, int linkVISUALID) {
- Collection<?> sources = SequenceLinkMappingHelper.getInstance().getSource(semanticLink);
- Collection<?> targets = SequenceLinkMappingHelper.getInstance().getTarget(semanticLink);
- if(!sources.isEmpty() && !targets.isEmpty()) {
- Element source = (Element)sources.toArray()[0];
- Element target = (Element)targets.toArray()[0];
- return getDropLocatedLinkCommand(dropRequest, source, target, linkVISUALID, semanticLink);
- } else {
- return UnexecutableCommand.INSTANCE;
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExternalLabelPrimaryDragRoleEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExternalLabelPrimaryDragRoleEditPolicy.java
deleted file mode 100644
index f79e0985b19..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExternalLabelPrimaryDragRoleEditPolicy.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.PrecisionRectangle;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * This policy provides the selection handles, feedback and move command for
- * external node label.
- */
-public class CustomExternalLabelPrimaryDragRoleEditPolicy extends ResizableEditPolicyEx {
-
- @Override
- protected List<?> createSelectionHandles() {
- MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost());
- mh.setBorder(null);
- return Collections.singletonList(mh);
- }
-
- @Override
- protected Command getMoveCommand(ChangeBoundsRequest request) {
- LabelEditPart editPart = (LabelEditPart)getHost();
-
- // FeedBack - Port + Delta
- Rectangle updatedRect = new Rectangle();
- PrecisionRectangle initialRect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- updatedRect = initialRect.getTranslated(getHostFigure().getParent().getBounds().getLocation().getNegated());
- updatedRect = updatedRect.getTranslated(request.getMoveDelta());
-
- // translate the feedback figure
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
- getHostFigure().translateToRelative(rect);
-
- ICommand moveCommand = new SetBoundsCommand(editPart.getEditingDomain(), DiagramUIMessages.MoveLabelCommand_Label_Location, new EObjectAdapter((View)editPart.getModel()), updatedRect);
- return new ICommandProxy(moveCommand);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java
deleted file mode 100644
index 85f62fa3560..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - additional features
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import static org.eclipse.papyrus.uml.diagram.common.Activator.log;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.Transaction;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.workspace.AbstractEMFOperation;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.editpolicies.AbstractEditPolicy;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.util.StringStatics;
-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
-import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
-import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer;
-import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.DurationConstraint;
-import org.eclipse.uml2.uml.DurationObservation;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.TimeConstraint;
-import org.eclipse.uml2.uml.TimeObservation;
-
-/**
- * Edit Policy in charge of the removal of time/duration constraint/observation which no longer have associated events.
- * <P>
- * This view checks that the host edit part, a time/duration constraint/observation edit part, has necessary associated events. It listens for model
- * notifications. As soon as it receives a remove event, it checks whether the time element should be also deleted.<BR/>
- * </P>
- */
-public class DeleteTimeElementWithoutEventPolicy extends AbstractEditPolicy implements NotificationListener, IPapyrusListener {
-
- /** The key to install this edit policy */
- public static final String KEY = "DeleteTimeElementWithoutEvent";
-
- /** list of element to listen */
- protected HashMap<EObject, List<View>> additionalParentToListen = new HashMap<EObject, List<View>>();
-
- /** stores the host associated semantic element */
- protected EObject hostSemanticElement;
-
- /**
- * Adds additional listeners to the diagram event broker.
- */
- @Override
- public void activate() {
-
- // retrieve the view and the element associated to the host edit part
- final View hostView = (View)getHost().getModel();
- hostSemanticElement = hostView.getElement();
-
- // adds listener to the event broker, listening for the view and the semantic element associated to the host edit part
- getDiagramEventBroker().addNotificationListener(hostView, this);
- getDiagramEventBroker().addNotificationListener(hostSemanticElement, this);
-
- // retrieve the list of linked view to listen parents
- for(View linkedView : getLinkedViews()) {
- getDiagramEventBroker().addNotificationListener(linkedView.eContainer(), this);
- }
- super.activate();
- }
-
- /**
- * Removes this edit policy as listener for changes to the specified semanticParent
- *
- * @param semanticParent
- * the semantic parent to stop listen
- * @param childView
- * the view that does not requires this additional listener
- */
- protected void removeAdditionalParentToListen(EObject semanticParent, View childView) {
- // removes the view from the list of views that requires a listener for the semantic parent
- if(additionalParentToListen.containsKey(semanticParent)) {
- List<View> views = additionalParentToListen.get(semanticParent);
- assert (views != null) : "list should not be null";
- views.remove(childView);
- if(views.isEmpty()) {
- additionalParentToListen.remove(semanticParent);
- // check this is not the parent semantic element of the host's semantic element
- if(!semanticParent.equals(((View)getHost().getModel()).getElement())) {
- getDiagramEventBroker().removeNotificationListener(semanticParent, this);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void deactivate() {
- // retrieve the view and the element associated to the host edit part
- final View hostView = (View)getHost().getModel();
-
- // removes all notification listeners for the additional parent to listen
- for(EObject parent : additionalParentToListen.keySet()) {
- getDiagramEventBroker().removeNotificationListener(parent, this);
- }
- additionalParentToListen.clear();
- additionalParentToListen = null;
-
- getDiagramEventBroker().removeNotificationListener(hostView, this);
- getDiagramEventBroker().removeNotificationListener(hostSemanticElement, this);
-
- // removes the reference to the semantic element
- hostSemanticElement = null;
-
- super.deactivate();
- }
-
- /**
- * Deletes the time element.
- */
- protected final void deleteTimeElement() {
- Command cmd = getDeleteElementCommand(false);
-
- if(cmd.canExecute()) {
- executeCommand(cmd);
- }
- }
-
- /**
- * Deletes a time element view.
- */
- protected final void deleteTimeView() {
- Command cmd = getDeleteElementCommand(true);
-
- if(cmd.canExecute()) {
- executeCommand(cmd);
- }
- }
-
- /**
- * Executes the supplied command inside an <code>unchecked action</code>
- *
- * @param cmd
- * command that can be executed (i.e., cmd.canExecute() == true)
- */
- protected void executeCommand(final Command cmd) {
- Map<String, Boolean> options = null;
- EditPart ep = getHost();
- boolean isActivating = true;
- // use the viewer to determine if we are still initializing the diagram
- // do not use the DiagramEditPart.isActivating since ConnectionEditPart's
- // parent will not be a diagram edit part
- EditPartViewer viewer = ep.getViewer();
- if(viewer instanceof DiagramGraphicalViewer) {
- isActivating = ((DiagramGraphicalViewer)viewer).isInitializing();
- }
-
- if(isActivating || !EditPartUtil.isWriteTransactionInProgress((IGraphicalEditPart)getHost(), false, false))
- options = Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
-
- AbstractEMFOperation operation = new AbstractEMFOperation(((IGraphicalEditPart)getHost()).getEditingDomain(), StringStatics.BLANK, options) {
-
- protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ((IGraphicalEditPart)getHost()).getDiagramEditDomain().getDiagramCommandStack().execute(cmd);
- return Status.OK_STATUS;
- }
-
- @Override
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- cmd.undo();
- return Status.OK_STATUS;
- }
- };
- try {
- operation.execute(new NullProgressMonitor(), null);
- } catch (ExecutionException e) {
- log.error(e);
- }
- }
-
- /**
- * Check if time element is correctly defined
- *
- * @return true if it has necessary information, false if it is to be deleted
- */
- protected boolean isTimeElementDefined() {
- if(hostSemanticElement instanceof TimeObservation) {
- return ((TimeObservation)hostSemanticElement).getEvent() != null;
- } else if(hostSemanticElement instanceof DurationObservation) {
- return ((DurationObservation)hostSemanticElement).getEvents().size() >= 2;
- } else if(hostSemanticElement instanceof TimeConstraint) {
- return ((TimeConstraint)hostSemanticElement).getConstrainedElements().size() > 0;
- } else if(hostSemanticElement instanceof DurationConstraint) {
- /*
- * Note that DurationConstraint may have only one ConstrainedElement.
- * But in such a case, we suppose it has not been created as one of the concerned edit parts.
- */
- return ((DurationConstraint)hostSemanticElement).getConstrainedElements().size() >= 2;
- }
- return true;
- }
-
- /**
- * Get the list of other required figures
- *
- * @return list of views
- */
- protected List<View> getLinkedViews() {
- if(getHost() instanceof TimeObservationEditPart && hostSemanticElement instanceof TimeObservation) {
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost());
- NamedElement occ = ((TimeObservation)hostSemanticElement).getEvent();
- if(occ instanceof OccurrenceSpecification) {
- EditPart part = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occ);
- if(part != null) {
- return Collections.singletonList((View)part.getModel());
- }
- }
- return Collections.emptyList();
- } else if(getHost() instanceof TimeConstraintEditPart && hostSemanticElement instanceof TimeConstraint) {
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost());
- List<Element> occs = ((TimeConstraint)hostSemanticElement).getConstrainedElements();
- if(occs.size() > 0 & occs.get(0) instanceof OccurrenceSpecification) {
- EditPart part = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(0));
- if(part != null) {
- return Collections.singletonList((View)part.getModel());
- }
- }
- return Collections.emptyList();
- } else if(getHost() instanceof DurationConstraintEditPart && hostSemanticElement instanceof TimeConstraint) {
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost());
- List<Element> occs = ((TimeConstraint)hostSemanticElement).getConstrainedElements();
- if(occs.size() >= 2 && occs.get(0) instanceof OccurrenceSpecification && occs.get(1) instanceof OccurrenceSpecification) {
- EditPart part1 = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(0));
- EditPart part2 = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(1));
- List<View> list = new ArrayList<View>(2);
- if(part1 != null) {
- list.add((View)part1.getModel());
- }
- if(part2 != null) {
- list.add((View)part2.getModel());
- }
- return list;
- }
- return Collections.emptyList();
- }
- // a label on a message always has its parent message
- return Collections.emptyList();
- }
-
- /**
- * Check if time element has required other figures
- *
- * @return true if the time element figure miss one of the figure representing its ends.
- */
- protected boolean timeElementMissAnEventFigure() {
- if(getHost() instanceof TimeObservationEditPart && hostSemanticElement instanceof TimeObservation) {
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost());
- NamedElement occ = ((TimeObservation)hostSemanticElement).getEvent();
- if(occ instanceof OccurrenceSpecification) {
- return SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occ) == null;
- }
- return true;
- } else if(getHost() instanceof TimeConstraintEditPart && hostSemanticElement instanceof TimeConstraint) {
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost());
- List<Element> occs = ((TimeConstraint)hostSemanticElement).getConstrainedElements();
- if(occs.size() > 0 && occs.get(0) instanceof OccurrenceSpecification) {
- return SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(0)) == null;
- }
- return true;
- } else if(getHost() instanceof DurationConstraintEditPart && hostSemanticElement instanceof DurationConstraint) {
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost());
- List<Element> occs = ((DurationConstraint)hostSemanticElement).getConstrainedElements();
- if(occs.size() >= 2 && occs.get(0) instanceof OccurrenceSpecification && occs.get(1) instanceof OccurrenceSpecification) {
- return SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(0)) == null || SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(1)) == null;
- }
- return true;
- }
- // a label on a message always has its parent message
- return false;
- }
-
- /**
- * Returns a {@link Command} to delete the host element
- *
- * @param graphOnly
- * true if the view only must be removed
- * @return the command that destroys the host element
- */
- protected Command getDeleteElementCommand(boolean graphOnly) {
- if(graphOnly) {
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
- return new ICommandProxy(new DeleteCommand(editingDomain, (View)getHost().getModel()));
- } else {
- DestroyElementRequest req = new DestroyElementRequest(hostSemanticElement, false);
- return getDestroyElementCommand(req);
- }
- }
-
- /**
- * Copied from a generated method from a semantic edit policy which supports the edit element service
- * @param req the DestroyElementRequest
- * @return the destroy command
- */
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- EObject selectedEObject = req.getElementToDestroy();
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(selectedEObject);
- if(provider != null) {
- // Retrieve delete command from the Element Edit service
- ICommand deleteCommand = provider.getEditCommand(req);
-
- if(deleteCommand != null) {
- return new ICommandProxy(deleteCommand);
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Gets the diagram event broker from the editing domain.
- *
- * @return the diagram event broker
- */
- protected DiagramEventBroker getDiagramEventBroker() {
- TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
- if(theEditingDomain != null) {
- return DiagramEventBroker.getInstance(theEditingDomain);
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void notifyChanged(Notification notification) {
- Object notifier = notification.getNotifier();
- if(notifier.equals(hostSemanticElement)) {
- if(Notification.REMOVE == notification.getEventType() || Notification.SET == notification.getEventType()) {
- deleteTimeElementIfNeeded();
- }
- } else if(notifier instanceof View) {
- // a view has been modified
- if(Notification.REMOVE == notification.getEventType()) {
- deleteTimeElementIfNeeded();
- }
- }
- }
-
- /**
- * Removes a listener for the specified view, if it exists.
- *
- * @param oldView
- * the old view to check
- */
- protected void removeListenerForView(View oldView) {
- // create a temp list of elements to delete (iterator concurrent modification..)
- Map<EObject, List<View>> parentsToDelete = new HashMap<EObject, List<View>>();
-
- for(EObject parent : additionalParentToListen.keySet()) {
- List<View> parentViews = additionalParentToListen.get(parent);
- if(parentViews.contains(oldView)) {
-
- List<View> views = parentsToDelete.get(parent);
- if(views == null) {
- views = new ArrayList<View>();
- }
- views.add(oldView);
- parentsToDelete.put(parent, views);
- }
- }
- }
-
- /**
- * Updates the listeners for the specified semantic parent
- */
- protected void removeListeners(List<View> impactedViews) {
- // create a temp list of elements to delete (iterator concurrent modification..)
- Map<EObject, List<View>> parentsToDelete = new HashMap<EObject, List<View>>();
-
- // collect the elements to delete
- for(View view : impactedViews) {
- for(EObject parent : additionalParentToListen.keySet()) {
- List<View> parentViews = additionalParentToListen.get(parent);
- if(parentViews.contains(view)) {
-
- List<View> views = parentsToDelete.get(parent);
- if(views == null) {
- views = new ArrayList<View>();
- }
- views.add(view);
- parentsToDelete.put(parent, views);
- }
- }
- }
-
- // do the job
- for(EObject object : parentsToDelete.keySet()) {
- List<View> views = parentsToDelete.get(object);
- for(View view : views) {
- removeAdditionalParentToListen(object, view);
- }
- }
- }
-
- /**
- * Check if the time element should be deleted and delete it if necessary.
- */
- protected void deleteTimeElementIfNeeded() {
- if(!isTimeElementDefined()) {
- // delete the time element
- deleteTimeElement();
- }
- if(timeElementMissAnEventFigure()) {
- // delete the view
- deleteTimeView();
- }
- }
-
- /**
- * launch a weak synchronization. It could be useful in order to clean a diagram by an external tool.
- */
- public void forceRefresh() {
- deleteTimeElementIfNeeded();
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionEventComponentEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionEventComponentEditPolicy.java
deleted file mode 100644
index 429dd145b63..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionEventComponentEditPolicy.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ComponentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDeleteHelper;
-
-/**
- * This edit policy also deletes time/duration edit parts which are linked with the deleted edit part.
- */
-public class DestructionEventComponentEditPolicy extends ComponentEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Command createDeleteViewCommand(GroupRequest deleteRequest) {
- CompoundCommand deleteViewsCommand = new CompoundCommand();
- Command deleteViewCommand = super.createDeleteViewCommand(deleteRequest);
- deleteViewsCommand.add(deleteViewCommand);
- if(getHost() instanceof ShapeNodeEditPart) {
- TransactionalEditingDomain editingDomain = ((ShapeNodeEditPart)getHost()).getEditingDomain();
- SequenceDeleteHelper.completeDeleteDestructionOccurenceViewCommand(deleteViewsCommand, editingDomain, getHost());
- }
- return deleteViewsCommand;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ElementCreationWithMessageEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ElementCreationWithMessageEditPolicy.java
deleted file mode 100644
index fae1cbee5dd..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ElementCreationWithMessageEditPolicy.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.command.PromptCreateElementAndNodeCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.Lifeline;
-
-/**
- * Edit Policy to create an element on a lifeline associated with the creation of a message.
- * For example it can be used to create a Destruction Event with a Message Delete
- * or the target Execution Specification with a Message Sync.
- *
- * @author Mathieu Velten
- *
- */
-public class ElementCreationWithMessageEditPolicy extends LifelineChildGraphicalNodeEditPolicy {
-
- @Override
- protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
-// CompoundCommand compound = new CompoundCommand();
-
- Command command = super.getConnectionCompleteCommand(request);
-
- if(command != null && command.canExecute()) {
-// compound.add(command);
-
- if(request instanceof CreateConnectionViewAndElementRequest) {
- CreateConnectionViewAndElementRequest viewRequest = (CreateConnectionViewAndElementRequest)request;
- EditPart targetEP = getTargetEditPart(viewRequest);
- EObject target = ViewUtil.resolveSemanticElement((View)targetEP.getModel());
- EditPart sourceEP = viewRequest.getSourceEditPart();
- EObject source = ViewUtil.resolveSemanticElement((View)sourceEP.getModel());
-
- if(getSyncMessageHint().equals(viewRequest.getConnectionViewDescriptor().getSemanticHint()) || getReplyMessageHint().equals(viewRequest.getConnectionViewDescriptor().getSemanticHint())) {
- if(target instanceof Lifeline ||
- // handle reflexive synch message by creating a new ES
- (target instanceof ExecutionSpecification && target.equals(source))) {
- InteractionFragment ift = SequenceUtil.findInteractionFragmentContainerAt(viewRequest.getLocation(), getHost());
-
- // retrieve the good execution specification type using the source of the message
- if(target instanceof ExecutionSpecification) {
- // retrieve its associated lifeline
- targetEP = targetEP.getParent();
- target = ViewUtil.resolveSemanticElement((View)targetEP.getModel());
- }
- EditPart sourceEditPart = request.getSourceEditPart();
- if (sourceEditPart instanceof ActionExecutionSpecificationEditPart || sourceEditPart instanceof BehaviorExecutionSpecificationEditPart) {
- return new ICommandProxy(new PromptCreateElementAndNodeCommand(command, getEditingDomain(),viewRequest.getConnectionViewDescriptor(),(ShapeNodeEditPart) targetEP, target,sourceEP,request, ift));
- }
-// IHintedType elementType = null;
-// if(sourceEditPart instanceof ActionExecutionSpecificationEditPart) {
-// elementType = (IHintedType)UMLElementTypes.ActionExecutionSpecification_3006;
-// } else if(request.getSourceEditPart() instanceof BehaviorExecutionSpecificationEditPart) {
-// elementType = (IHintedType)UMLElementTypes.BehaviorExecutionSpecification_3003;
-// }
-//
-//
-// if(elementType != null) {
-// CreateElementAndNodeCommand createExecutionSpecificationCommand = new CreateElementAndNodeCommand(getEditingDomain(), (ShapeNodeEditPart)targetEP, target, elementType, request.getLocation());
-// createExecutionSpecificationCommand.putCreateElementRequestParameter(SequenceRequestConstant.INTERACTIONFRAGMENT_CONTAINER, ift);
-// compound.add(createExecutionSpecificationCommand);
-//
-// // put the anchor at the top of the figure
-// ChangeEdgeTargetCommand changeTargetCommand = new ChangeEdgeTargetCommand(getEditingDomain(), createExecutionSpecificationCommand, viewRequest.getConnectionViewDescriptor(), "(0.5, 0.0)");
-// compound.add(new ICommandProxy(changeTargetCommand));
-// }
- }
- }
- }
- }
-
- return command;
- }
-
- private static String getSyncMessageHint() {
- IHintedType message = (IHintedType)UMLElementTypes.Message_4003;
- return message.getSemanticHint();
- }
-
- private static String getReplyMessageHint() {
- IHintedType message = (IHintedType)UMLElementTypes.Message_4005;
- return message.getSemanticHint();
- }
-
- private TransactionalEditingDomain getEditingDomain() {
- return ((IGraphicalEditPart)getHost()).getEditingDomain();
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationComponentEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationComponentEditPolicy.java
deleted file mode 100644
index f56a16ae63d..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationComponentEditPolicy.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.List;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ComponentEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDeleteHelper;
-
-/**
- * This edit policy also deletes time/duration edit parts which are linked with the deleted edit part.
- */
-public class ExecutionSpecificationComponentEditPolicy extends ComponentEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Command createDeleteViewCommand(GroupRequest deleteRequest) {
- CompoundCommand deleteViewsCommand = new CompoundCommand();
- Command deleteViewCommand = super.createDeleteViewCommand(deleteRequest);
- deleteViewsCommand.add(deleteViewCommand);
- if(getHost() instanceof ShapeNodeEditPart) {
- TransactionalEditingDomain editingDomain = ((ShapeNodeEditPart)getHost()).getEditingDomain();
- SequenceDeleteHelper.completeDeleteExecutionSpecificationViewCommand(deleteViewsCommand, editingDomain, getHost());
- addDeleteViewChildrenCommand(deleteViewsCommand, editingDomain, (ShapeNodeEditPart)getHost());
- }
- return deleteViewsCommand;
- }
-
- // support nested actions and behaviors execution, https://bugs.eclipse.org/bugs/show_bug.cgi?id=384616
- public static void addDeleteViewChildrenCommand(CompoundCommand deleteViewsCommand, TransactionalEditingDomain editingDomain, ShapeNodeEditPart part) {
- List<ShapeNodeEditPart> list = LifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts(part);
- for(ShapeNodeEditPart p : list){
- deleteViewsCommand.add( new ICommandProxy(new DeleteCommand(editingDomain, (View) p.getModel())));
- SequenceDeleteHelper.completeDeleteExecutionSpecificationViewCommand(deleteViewsCommand, editingDomain, p);
- addDeleteViewChildrenCommand(deleteViewsCommand,editingDomain, p); //recursive delete children
- }
- }
-
- public static void addDestroyElementChildrenCommand(CompoundCommand deleteElementsCommand, TransactionalEditingDomain editingDomain, EditPart part) {
- List<ShapeNodeEditPart> list = LifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts((ShapeNodeEditPart)part);
- for(ShapeNodeEditPart p : list){
- Request request = new EditCommandRequestWrapper(new DestroyElementRequest(p.resolveSemanticElement(), false));
- deleteElementsCommand.add(p.getCommand(request));
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java
deleted file mode 100644
index 644526d13a0..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExternalLabelPrimaryDragRoleEditPolicy.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.PrecisionRectangle;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * This policy provides the selection handles, feedback and move command for
- * external node label.
- * The expected behavior is to provide an external label that can freely move and with a link feedback
- * towards its parent figure during the move.
- */
-public class ExternalLabelPrimaryDragRoleEditPolicy extends NonResizableLabelEditPolicy {
-
- @Override
- protected List<?> createSelectionHandles() {
- MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost());
- mh.setBorder(null);
- return Collections.singletonList(mh);
- }
-
- @Override
- protected Command getMoveCommand(ChangeBoundsRequest request) {
- LabelEditPart editPart = (LabelEditPart)getHost();
-
- // FeedBack - Port + Delta
- Rectangle updatedRect = new Rectangle();
- PrecisionRectangle initialRect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- updatedRect = initialRect.getTranslated(getHostFigure().getParent().getBounds().getLocation().getNegated());
- updatedRect = updatedRect.getTranslated(request.getMoveDelta());
-
- // translate the feedback figure
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
- getHostFigure().translateToRelative(rect);
-
- ICommand moveCommand = new SetBoundsCommand(editPart.getEditingDomain(), DiagramUIMessages.MoveLabelCommand_Label_Location, new EObjectAdapter((View)editPart.getModel()), updatedRect);
- return new ICommandProxy(moveCommand);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/HighlightConnectionPartEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/HighlightConnectionPartEditPolicy.java
deleted file mode 100644
index 5fcfb78b436..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/HighlightConnectionPartEditPolicy.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.gef.Request;
-import org.eclipse.gef.editpolicies.AbstractEditPolicy;
-import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.papyrus.uml.diagram.sequence.util.HighlightUtil;
-
-public class HighlightConnectionPartEditPolicy extends AbstractEditPolicy {
-
- private HighlightUtil sourceHighlighter = new HighlightUtil();
-
- private HighlightUtil targetHighlighter = new HighlightUtil();
-
- @Override
- public void showSourceFeedback(Request request) {
- if(request instanceof CreateConnectionRequest) {
- sourceHighlighter.highlight(getHost());
- }
- }
-
- @Override
- public void showTargetFeedback(Request request) {
- if(request instanceof CreateConnectionRequest && ((CreateConnectionRequest)request).getSourceEditPart() != null) {
- targetHighlighter.highlight(getHost());
- } else if(request instanceof ReconnectRequest && ((ReconnectRequest)request).getTarget() != null) {
- targetHighlighter.highlight(((ReconnectRequest)request).getTarget());
- }
- }
-
- @Override
- public void eraseSourceFeedback(Request request) {
- if(request instanceof CreateConnectionRequest) {
- sourceHighlighter.unhighlight(getHost());
- }
- }
-
- @Override
- public void eraseTargetFeedback(Request request) {
- if(request instanceof CreateConnectionRequest && ((CreateConnectionRequest)request).getSourceEditPart() != null) {
- targetHighlighter.unhighlight(getHost());
- } else if(request instanceof ReconnectRequest && ((ReconnectRequest)request).getTarget() != null) {
- targetHighlighter.unhighlight(((ReconnectRequest)request).getTarget());
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java
deleted file mode 100644
index d7d3231e5b8..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java
+++ /dev/null
@@ -1,789 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
-import org.eclipse.draw2d.geometry.PrecisionRectangle;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.requests.AlignmentRequest;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.IdentityAnchor;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
-import org.eclipse.papyrus.uml.diagram.common.commands.PreserveAnchorsPositionCommand;
-import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool.CreateAspectUnspecifiedTypeRequest;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.HighlightUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineResizeHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OperandBoundsComputeHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.CombinedFragment;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-import org.eclipse.uml2.uml.Lifeline;
-
-/**
- * The customn XYLayoutEditPolicy for InteractionCompartmentEditPart.
- */
-public class InteractionCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
-
- protected Command getCreateCommand(CreateRequest request) {
- CreateViewRequest req = (CreateViewRequest) request;
- Command cmd = super.getCreateCommand(request);
-
- if(cmd != null && req.getSize() != null){ // create lifeline with specific size
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- Iterator iter = req.getViewDescriptors().iterator();
- while (iter.hasNext()) {
- CreateViewRequest.ViewDescriptor viewDescriptor = (CreateViewRequest.ViewDescriptor)iter.next();
- if (((IHintedType) UMLElementTypes.Lifeline_3001).getSemanticHint().equals(viewDescriptor.getSemanticHint())) {
- cmd = (new ICommandProxy(LifelineResizeHelper.createManualLabelSizeCommand(editingDomain, viewDescriptor))).chain(cmd);
- }
- }
- }
- return cmd;
- }
-
- /**
- * Handle lifeline and combined fragment resize
- */
- @Override
- protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
- CompoundCommand compoundCmd = new CompoundCommand();
- compoundCmd.setLabel("Move or Resize");
-
- IFigure figure = getHostFigure();
- Rectangle hostBounds = figure.getBounds();
-
- for(Object o : request.getEditParts()) {
- GraphicalEditPart child = (GraphicalEditPart)o;
- Object constraintFor = getConstraintFor(request, child);
- if (constraintFor instanceof Rectangle) {
- Rectangle childBounds = (Rectangle) constraintFor;
- if (childBounds.x < 0 || childBounds.y < 0) {
- return UnexecutableCommand.INSTANCE;
- }
-
- if(child instanceof LifelineEditPart) {
- if (isVerticalMove(request)) {
- addLifelineResizeChildrenCommand(compoundCmd, request, (LifelineEditPart)child, 1);
- }
- } else if(child instanceof CombinedFragmentEditPart) {
- // Add restrictions to change the size
- if(!OperandBoundsComputeHelper.checkRedistrictOnCFResize(request,child)){
- return null;
- }
- Command resizeChildrenCommand = getCombinedFragmentResizeChildrenCommand(request, (CombinedFragmentEditPart)child);
- if(resizeChildrenCommand != null && resizeChildrenCommand.canExecute()) {
- compoundCmd.add(resizeChildrenCommand);
- }
-// else if(resizeChildrenCommand != null) {
-// return UnexecutableCommand.INSTANCE;
-// }
- }
-
- boolean hasCreateLink = LifelineMessageCreateHelper.hasIncomingMessageCreate(child);
- if(hasCreateLink && !LifelineMessageCreateHelper.canMoveLifelineVertical((LifelineEditPart) child, (Rectangle) translateToModelConstraint(constraintFor)) ){
- return UnexecutableCommand.INSTANCE;
- }
- if(!(child instanceof LifelineEditPart) || isVerticalMove(request) || hasCreateLink) {
- Command changeConstraintCommand = createChangeConstraintCommand(request, child, translateToModelConstraint(constraintFor));
-
- // When we change the width by mouse, it passe to manual mode. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=383723
- if(child instanceof LifelineEditPart && changeConstraintCommand != null && request.getSizeDelta().width != 0){
- compoundCmd.add(new ICommandProxy(LifelineResizeHelper.createManualLabelSizeCommand((LifelineEditPart)child)));
- }
- compoundCmd.add(changeConstraintCommand);
- }
-
- if(child instanceof CombinedFragmentEditPart) {
- OperandBoundsComputeHelper.createUpdateIOBoundsForCFResizeCommand(compoundCmd,request,(CombinedFragmentEditPart)child);
- }
-
- int right = childBounds.right();
- int bottom = childBounds.bottom();
- int deltaX = 0;
- int deltaY = 0;
- if (right > hostBounds.width) {
- deltaX = right - hostBounds.width;
- }
- if (bottom > hostBounds.height) {
- deltaY = bottom - hostBounds.height;
- }
- if (deltaX != 0 || deltaY != 0) {
- ChangeBoundsRequest boundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
- boundsRequest.setSizeDelta(new Dimension(deltaX, deltaY));
- EditPart hostParent = getHost().getParent();
- boundsRequest.setEditParts(hostParent);
- Command cmd = hostParent.getCommand(boundsRequest);
- if (cmd != null && cmd.canExecute()) {
- compoundCmd.add(cmd);
- }
- }
- }
- }
- return compoundCmd.unwrap();
- }
-
- protected boolean isVerticalMove(ChangeBoundsRequest request) {
- if (request instanceof AlignmentRequest) {
- AlignmentRequest alignmentRequest = (AlignmentRequest) request;
- switch(alignmentRequest.getAlignment()) {
- case PositionConstants.BOTTOM:
- case PositionConstants.TOP:
- case PositionConstants.MIDDLE:
- case PositionConstants.VERTICAL:
- case PositionConstants.NORTH_EAST:
- case PositionConstants.NORTH_WEST:
- case PositionConstants.SOUTH_EAST:
- case PositionConstants.SOUTH_WEST:
- return false;
- }
- }
-
- Point point = request.getMoveDelta();
- return point.y == 0;
- }
-
- /**
- * Resize children of LifelineEditPart (Execution specification and lifeline)
- *
- * @param compoundCmd
- * The command
- * @param request
- * The request
- * @param lifelineEditPart
- * The lifelineEditPart to resize
- * @param number
- * The number of brother of the LifelineEditPart
- */
- public static void addLifelineResizeChildrenCommand(CompoundCommand compoundCmd, ChangeBoundsRequest request, LifelineEditPart lifelineEditPart, int number) {
- // If the width increases or decreases, ExecutionSpecification elements need to
- // be moved
- int widthDelta;
- for(ShapeNodeEditPart executionSpecificationEP : lifelineEditPart.getChildShapeNodeEditPart()) {
- if(executionSpecificationEP.resolveSemanticElement() instanceof ExecutionSpecification) {
- // Lifeline's figure where the child is drawn
- Rectangle rDotLine = lifelineEditPart.getContentPane().getBounds();
-
- // The new bounds will be calculated from the current bounds
- Rectangle newBounds = executionSpecificationEP.getFigure().getBounds().getCopy();
-
- widthDelta = request.getSizeDelta().width;
-
- if(widthDelta != 0) {
-
- if(rDotLine.getSize().width + widthDelta < newBounds.width * 2) {
- compoundCmd.add(UnexecutableCommand.INSTANCE);
- }
-
- // Apply SizeDelta to the children
- widthDelta = Math.round(widthDelta / ((float)2 * number));
-
- newBounds.x += widthDelta;
-
- // Convert to relative
- newBounds.x -= rDotLine.x;
- newBounds.y -= rDotLine.y;
-
- SetBoundsCommand setBoundsCmd = new SetBoundsCommand(executionSpecificationEP.getEditingDomain(), "Re-location of a ExecutionSpecification due to a Lifeline movement", executionSpecificationEP, newBounds);
- compoundCmd.add(new ICommandProxy(setBoundsCmd));
- }
-
- // update the enclosing interaction of a moved execution specification
- compoundCmd.add(SequenceUtil.createUpdateEnclosingInteractionCommand(executionSpecificationEP, request.getMoveDelta(), new Dimension(widthDelta, 0)));
- }
- }
-
-// List<LifelineEditPart> innerConnectableElementList = lifelineEditPart.getInnerConnectableElementList();
-// for(LifelineEditPart lifelineEP : innerConnectableElementList) {
-// addLifelineResizeChildrenCommand(compoundCmd, request, lifelineEP, number * innerConnectableElementList.size());
-// }
- // fixed bug (id=364711) when lifeline bounds changed update coveredBys'
- // bounds.
- addUpdateInteractionFragmentsLocationCommand(compoundCmd, request,
- lifelineEditPart);
-
- }
-
- /**
- * Resize InteractionFragments if the Lifeline has CoveredBys, while
- * Lifeline moving.
- *
- * @param compoundCmd
- * @param request
- * @param lifelineEditPart
- */
- private static void addUpdateInteractionFragmentsLocationCommand(
- CompoundCommand compoundCmd, ChangeBoundsRequest request,
- LifelineEditPart lifelineEditPart) {
- View shape = (View) lifelineEditPart.getModel();
- Lifeline element = (Lifeline) shape.getElement();
- EList<InteractionFragment> covereds = element.getCoveredBys();
- EditPart parent = lifelineEditPart.getParent();
- List<?> children = parent.getChildren();
- for (Object obj : children) {
- EditPart et = (EditPart) obj;
- View sp = (View) et.getModel();
- if (!covereds.contains(sp.getElement())) {
- continue;
- }
- ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_MOVE);
- req.setEditParts(et);
- req.setMoveDelta(request.getMoveDelta());
- Command command = et.getCommand(req);
- if (command != null && command.canExecute()) {
- compoundCmd.add(command);
- }
- }
- }
-
- /**
- * Handle the owning of interaction fragments when moving or resizing a CF.
- *
- * @param compoundCmd
- * The command
- * @param moveDelta
- * The move delta (given by the request).
- * @param sizeDelta
- * The size delta (given by the request).
- * @param combinedFragmentEditPart
- * The CF edit part.
- */
- @SuppressWarnings("unchecked")
- public static Command getCombinedFragmentResizeChildrenCommand(ChangeBoundsRequest request, CombinedFragmentEditPart combinedFragmentEditPart) {
- Point moveDelta = request.getMoveDelta();
- Dimension sizeDelta = request.getSizeDelta();
-
- IFigure cfFigure = combinedFragmentEditPart.getFigure();
- Rectangle origCFBounds = cfFigure.getBounds().getCopy();
-
- cfFigure.getParent().translateToAbsolute(origCFBounds);
- origCFBounds.translate(cfFigure.getParent().getBounds().getLocation());
-
- CompoundCommand compoundCmd = new CompoundCommand();
-
- // specific case for move :
- // we want the execution specifications graphically owned by the lifeline to move with the combined fragment, and the contained messages too
- if(sizeDelta.equals(0, 0)) {
- // retrieve all the edit parts in the registry
- Set<Entry<Object, EditPart>> allEditPartEntries = combinedFragmentEditPart.getViewer().getEditPartRegistry().entrySet();
- for(Entry<Object, EditPart> epEntry : allEditPartEntries) {
- EditPart ep = epEntry.getValue();
-
- // handle move of object graphically owned by the lifeline
- if(ep instanceof ShapeEditPart) {
- ShapeEditPart sep = (ShapeEditPart)ep;
- EObject elem = sep.getNotationView().getElement();
-
- if(elem instanceof InteractionFragment) {
- IFigure figure = sep.getFigure();
-
- Rectangle figureBounds = figure.getBounds().getCopy();
- figure.getParent().translateToAbsolute(figureBounds);
-
- if(origCFBounds.contains(figureBounds)) {
- EditPart parentEP = sep.getParent();
-
- if(parentEP instanceof LifelineEditPart) {
- ChangeBoundsRequest esRequest = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
- esRequest.setEditParts(sep);
- esRequest.setMoveDelta(moveDelta);
-
- Command moveESCommand = LifelineXYLayoutEditPolicy.getResizeOrMoveChildrenCommand((LifelineEditPart)parentEP, esRequest, true, false, true);
-
- if(moveESCommand != null && !moveESCommand.canExecute()) {
- // forbid move if the es can't be moved correctly
- return UnexecutableCommand.INSTANCE;
- } else if(moveESCommand != null) {
- compoundCmd.add(moveESCommand);
- }
- }
- }
-
- }
- }
-
- // handle move of messages directly attached to a lifeline
- if(ep instanceof ConnectionEditPart) {
- ConnectionEditPart cep = (ConnectionEditPart)ep;
-
- Connection msgFigure = cep.getConnectionFigure();
-
- ConnectionAnchor sourceAnchor = msgFigure.getSourceAnchor();
- ConnectionAnchor targetAnchor = msgFigure.getTargetAnchor();
-
- Point sourcePoint = sourceAnchor.getReferencePoint();
- Point targetPoint = targetAnchor.getReferencePoint();
-
- Edge edge = (Edge)cep.getModel();
-
- if(origCFBounds.contains(sourcePoint) && cep.getSource() instanceof LifelineEditPart) {
- IdentityAnchor gmfAnchor = (IdentityAnchor)edge.getSourceAnchor();
- Rectangle figureBounds = sourceAnchor.getOwner().getBounds();
- compoundCmd.add(new ICommandProxy(getMoveAnchorCommand(moveDelta.y, figureBounds, gmfAnchor)));
- }
- if(origCFBounds.contains(targetPoint) && cep.getTarget() instanceof LifelineEditPart) {
- IdentityAnchor gmfAnchor = (IdentityAnchor)edge.getTargetAnchor();
- Rectangle figureBounds = targetAnchor.getOwner().getBounds();
- compoundCmd.add(new ICommandProxy(getMoveAnchorCommand(moveDelta.y, figureBounds, gmfAnchor)));
- }
- }
-
- if (ep instanceof DurationConstraintEditPart) {
- DurationConstraintEditPart dcp = (DurationConstraintEditPart) ep;
- moveCoveredDurationConstraint(dcp, compoundCmd, origCFBounds, moveDelta);
- }
- }
-
- } else {
- // calculate the new CF bounds
- Rectangle newBoundsCF = origCFBounds.getCopy();
- newBoundsCF.translate(moveDelta);
- newBoundsCF.resize(sizeDelta);
-
- CombinedFragment cf = (CombinedFragment)((CombinedFragmentEditPart)combinedFragmentEditPart).resolveSemanticElement();
-
- if(combinedFragmentEditPart.getChildren().size() > 0 && combinedFragmentEditPart.getChildren().get(0) instanceof CombinedFragmentCombinedFragmentCompartmentEditPart) {
-
- CombinedFragmentCombinedFragmentCompartmentEditPart compartment = (CombinedFragmentCombinedFragmentCompartmentEditPart)combinedFragmentEditPart.getChildren().get(0);
- List<EditPart> combinedFragmentChildrenEditParts = compartment.getChildren();
- List<InteractionOperandEditPart> interactionOperandEditParts = new ArrayList<InteractionOperandEditPart>();
-
- InteractionOperand firstOperand = cf.getOperands().get(0);
-
- // interaction fragments which will not be covered by the operands
- Set<InteractionFragment> notCoveredAnymoreInteractionFragments = new HashSet<InteractionFragment>();
- int headerHeight = 0;
-
- for(EditPart ep : combinedFragmentChildrenEditParts) {
- if(ep instanceof InteractionOperandEditPart) {
- InteractionOperandEditPart ioEP = (InteractionOperandEditPart)ep;
- InteractionOperand io = (InteractionOperand)ioEP.resolveSemanticElement();
-
- if(cf.getOperands().contains(io)) {
- interactionOperandEditParts.add(ioEP);
- // fill with all current fragments (filter later)
- notCoveredAnymoreInteractionFragments.addAll(io.getFragments());
-
- if(firstOperand.equals(io)) {
- Rectangle boundsIO = ioEP.getFigure().getBounds().getCopy();
- ioEP.getFigure().getParent().translateToAbsolute(boundsIO);
- headerHeight = boundsIO.y - origCFBounds.y;
- }
- }
- }
- }
-
- double heightRatio = (double)(newBoundsCF.height - headerHeight) / (double)(origCFBounds.height - headerHeight);
- double widthRatio = (double)newBoundsCF.width / (double)origCFBounds.width;
-
- for(InteractionOperandEditPart ioEP : interactionOperandEditParts) {
- InteractionOperand io = (InteractionOperand)ioEP.resolveSemanticElement();
-
- Rectangle newBoundsIO = SequenceUtil.getAbsoluteBounds(ioEP);
-
- // apply the move delta which will impact all operands
- newBoundsIO.translate(moveDelta);
-
- // calculate the new bounds of the interaction operand
- // scale according to the ratio
- newBoundsIO.height = (int)(newBoundsIO.height * heightRatio);
- newBoundsIO.width = (int)(newBoundsIO.width * widthRatio);
-
- if(firstOperand.equals(io)) {
- // used to compensate the height of the "header" where the OperandKind is stored
- newBoundsIO.y -= headerHeight;
- newBoundsIO.height += headerHeight;
- }
-
- // ignore current CF and enclosed IO
- Set<InteractionFragment> ignoreSet = new HashSet<InteractionFragment>();
- ignoreSet.add(cf);
- ignoreSet.addAll(cf.getOperands());
-
- Set<InteractionFragment> coveredInteractionFragments = SequenceUtil.getCoveredInteractionFragments(newBoundsIO, combinedFragmentEditPart, ignoreSet);
-
- if(coveredInteractionFragments == null) {
- return UnexecutableCommand.INSTANCE;
- }
-
- // remove fragments that are covered by this operand from the notCovered set
- notCoveredAnymoreInteractionFragments.removeAll(coveredInteractionFragments);
-
- // set the enclosing operand to the moved/resized one if the current enclosing interaction is the enclosing interaction
- // of the moved/resized operand or of another.
- // => the interaction fragment that are inside an other container (like an enclosed CF) are not modified
- for(InteractionFragment ift : coveredInteractionFragments) {
- if(!cf.equals(ift)) {
- Interaction interactionOwner = ift.getEnclosingInteraction();
- InteractionOperand ioOwner = ift.getEnclosingOperand();
-
- if((ioOwner != null && (ioOwner.equals(cf.getEnclosingOperand()) || cf.equals(ioOwner.getOwner()))) || (interactionOwner != null && (interactionOwner.equals(cf.getEnclosingInteraction()) || cf.equals(interactionOwner.getOwner())))) {
- compoundCmd.add(new ICommandProxy(SequenceUtil.getSetEnclosingInteractionCommand(ioEP.getEditingDomain(), ift, io)));
- }
- }
- }
- }
-
- for(InteractionFragment ift : notCoveredAnymoreInteractionFragments) {
- if(cf.getEnclosingOperand() != null) {
- compoundCmd.add(new ICommandProxy(SequenceUtil.getSetEnclosingInteractionCommand(combinedFragmentEditPart.getEditingDomain(), ift, cf.getEnclosingOperand())));
- } else {
- compoundCmd.add(new ICommandProxy(SequenceUtil.getSetEnclosingInteractionCommand(combinedFragmentEditPart.getEditingDomain(), ift, cf.getEnclosingInteraction())));
- }
- }
- }
- }
-
- // Print a user notification when we are not sure the command is appropriated
- EObject combinedFragment = combinedFragmentEditPart.resolveSemanticElement();
- if(combinedFragment instanceof CombinedFragment && !sizeDelta.equals(0, 0)) {
- if(((CombinedFragment)combinedFragment).getOperands().size() > 1) {
- // append a command which notifies
- Command notifyCmd = new Command() {
-
- @Override
- public void execute() {
- NotificationBuilder warning = NotificationBuilder.createAsyncPopup(Messages.Warning_ResizeInteractionOperandTitle, NLS.bind(Messages.Warning_ResizeInteractionOperandTxt, System.getProperty("line.separator")));
- warning.run();
- }
-
- @Override
- public void undo() {
- execute();
- }
- };
- if(notifyCmd.canExecute()) {
- compoundCmd.add(notifyCmd);
- }
- }
- }
- // return null instead of unexecutable empty compound command
- if(compoundCmd.isEmpty()) {
- return null;
- }
- return compoundCmd;
- }
-
- private static void moveCoveredDurationConstraint(DurationConstraintEditPart dcp, CompoundCommand compoundCmd,
- Rectangle origCFBounds, Point moveDelta) {
- Rectangle r = dcp.getFigure().getBounds().getCopy();
- dcp.getFigure().translateToAbsolute(r);
- if (origCFBounds.contains(r)) {
- //see org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy.getMoveCommand(ChangeBoundsRequest)
- IBorderItemEditPart borderItemEP = (IBorderItemEditPart) dcp;
- IBorderItemLocator borderItemLocator = borderItemEP
- .getBorderItemLocator();
- Rectangle realLocation = borderItemLocator
- .getValidLocation(dcp.getFigure().getBounds()
- .getCopy(), borderItemEP.getFigure());
-
- Point parentOrigin = borderItemEP.getFigure()
- .getParent().getBounds().getTopLeft();
- Dimension d = realLocation.getTopLeft().getDifference(
- parentOrigin);
- Point location = new Point(d.width, d.height);
- location = location.translate(0, moveDelta.y);
-
- ICommandProxy resize = new ICommandProxy(
- new SetBoundsCommand(dcp.getEditingDomain(),
- DiagramUIMessages.Commands_MoveElement,
- new EObjectAdapter((View) dcp.getModel()),
- location));
- compoundCmd.add(resize);
- }
- }
-
- private static ICommand getMoveAnchorCommand(int yDelta, Rectangle figureBounds, IdentityAnchor gmfAnchor) {
- String oldTerminal = gmfAnchor.getId();
- PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(oldTerminal);
-
- int yPos = (int)Math.round(figureBounds.height * pp.preciseY);
- yPos += yDelta;
-
- pp.preciseY = (double)yPos / figureBounds.height;
-
- if(pp.preciseY > 1.0) {
- pp.preciseY = 1.0;
- } else if(pp.preciseY < 0.0) {
- pp.preciseY = 0.0;
- }
-
- String newTerminal = (new BaseSlidableAnchor(null, pp)).getTerminal();
-
- return new SetValueCommand(new SetRequest(gmfAnchor, NotationPackage.Literals.IDENTITY_ANCHOR__ID, newTerminal));
- }
-
- /**
- * Change constraint for comportment by return null if the resize is lower than the minimun
- * size.
- */
- @Override
- protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
- Rectangle rect = new PrecisionRectangle(child.getFigure().getBounds());
- child.getFigure().translateToAbsolute(rect);
- rect = request.getTransformedRectangle(rect);
- child.getFigure().translateToRelative(rect);
- rect.translate(getLayoutOrigin().getNegated());
-
- if(request.getSizeDelta().width == 0 && request.getSizeDelta().height == 0) {
- Rectangle cons = getCurrentConstraintFor(child);
- if(cons != null) {
- rect.setSize(cons.width, cons.height);
- }
- } else { // resize editpart
- boolean skipMinSize = false;
- if(child instanceof LifelineEditPart)// && LifelineResizeHelper.isManualSize((LifelineEditPart)child))
- skipMinSize = true;
-
- Dimension minSize = getMinimumSizeFor(child);
- if(rect.width < minSize.width && !skipMinSize) { // In manual mode, there is no minimal width
- return null;
- }
- if(rect.height < minSize.height ) {
- return null;
- }
- }
- rect = (Rectangle)getConstraintFor(rect);
-
- Rectangle cons = getCurrentConstraintFor(child);
- if(request.getSizeDelta().width == 0) {
- rect.width = cons.width;
- }
- if(request.getSizeDelta().height == 0) {
- rect.height = cons.height;
- }
-
- return rect;
- }
-
- /**
- * Handle mininum size for lifeline
- */
- @Override
- protected Dimension getMinimumSizeFor(GraphicalEditPart child) {
- Dimension minimunSize;
- if(child instanceof LifelineEditPart) {
- minimunSize = getMinimumSizeFor((LifelineEditPart)child);
- } else {
- minimunSize = super.getMinimumSizeFor(child);
- }
- return minimunSize;
- }
-
- /**
- * Get minimun for a lifeline
- *
- * @param child
- * The lifeline
- * @return The minimun size
- */
- private Dimension getMinimumSizeFor(LifelineEditPart child) {
- LifelineEditPart lifelineEditPart = child;
- Dimension minimunSize = lifelineEditPart.getFigure().getMinimumSize();
- for(LifelineEditPart lifelineEP : lifelineEditPart.getInnerConnectableElementList()) {
- minimunSize.union(getMinimumSizeFor(lifelineEP));
- }
- for(ShapeNodeEditPart executionSpecificationEP : lifelineEditPart.getChildShapeNodeEditPart()) {
- int minimunHeight = executionSpecificationEP.getFigure().getBounds().bottom();
- minimunSize.setSize(new Dimension(minimunSize.width, Math.max(minimunSize.height, minimunHeight)));
- }
- return minimunSize;
- }
-
- /**
- * Block adding element by movement on Interaction
- */
- @Override
- public Command getAddCommand(Request request) {
- if(request instanceof ChangeBoundsRequest) {
- return UnexecutableCommand.INSTANCE;
- }
-
- return super.getAddCommand(request);
- }
-
-
- /**
- * Overrides to change the policy of connection anchors when resizing the lifeline.
- * When resizing the lifeline, the connection must not move.
- *
- * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy#getCommand(org.eclipse.gef.Request)
- */
- @SuppressWarnings("unchecked")
- @Override
- public Command getCommand(Request request) {
- if(request instanceof ChangeBoundsRequest) {
- ChangeBoundsRequest cbr = (ChangeBoundsRequest)request;
-
- int resizeDirection = cbr.getResizeDirection();
-
- CompoundCommand compoundCmd = new CompoundCommand("Resize of Interaction Compartment Elements");
-
- for(EditPart ep : (List<EditPart>)cbr.getEditParts()) {
- if(ep instanceof LifelineEditPart && isVerticalMove(cbr)) {
- // Lifeline EditPart
- LifelineEditPart lifelineEP = (LifelineEditPart)ep;
-
- int preserveY = PreserveAnchorsPositionCommand.PRESERVE_Y;
- Dimension newSizeDelta = PreserveAnchorsPositionCommand.getSizeDeltaToFitAnchors(lifelineEP, cbr.getSizeDelta(), preserveY);
-
- // SetBounds command modifying the sizeDelta
- compoundCmd.add(getSetBoundsCommand(lifelineEP, cbr, newSizeDelta));
-
- // PreserveAnchors command
- compoundCmd.add(new ICommandProxy(new LifelineEditPart.PreserveAnchorsPositionCommandEx(lifelineEP, newSizeDelta, preserveY, lifelineEP.getPrimaryShape().getFigureLifelineDotLineFigure(), resizeDirection)));
- }
- }
-
- if(compoundCmd.size() == 0) {
- return super.getCommand(request);
- } else {
- return compoundCmd;
- }
- }
-
- return super.getCommand(request);
- }
-
- /**
- * It obtains an appropriate SetBoundsCommand for a LifelineEditPart. The
- * newSizeDelta provided should be equal o less than the one contained in
- * the request. The goal of this newDelta is to preserve the anchors'
- * positions after the resize. It is recommended to obtain this newSizeDelta
- * by means of calling
- * PreserveAnchorsPositionCommand.getSizeDeltaToFitAnchors() operation
- *
- * @param lifelineEP
- * The Lifeline that will be moved or resized
- * @param cbr
- * The ChangeBoundsRequest for moving or resized the lifelineEP
- * @param newSizeDelta
- * The sizeDelta to used instead of the one contained in the
- * request
- * @return The SetBoundsCommand
- */
- @SuppressWarnings("rawtypes")
- protected Command getSetBoundsCommand(LifelineEditPart lifelineEP, ChangeBoundsRequest cbr, Dimension newSizeDelta) {
- // Modify request
- List epList = cbr.getEditParts();
- Dimension oldSizeDelta = cbr.getSizeDelta();
- cbr.setEditParts(lifelineEP);
- cbr.setSizeDelta(newSizeDelta);
-
- // Obtain the command with the modified request
- Command cmd = super.getCommand(cbr);
-
- // Restore the request
- cbr.setEditParts(epList);
- cbr.setSizeDelta(oldSizeDelta);
-
- // Return the SetBoundsCommand only for the Lifeline and with the
- // sizeDelta modified in order to preserve the links' anchors positions
- return cmd;
- }
-
- /**
- * Align lifeline in vertical direction
- * Fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=364688
- */
- protected Rectangle getBoundsOffest(CreateViewRequest request,
- Rectangle bounds, CreateViewRequest.ViewDescriptor viewDescriptor) {
- int translate = request.getViewDescriptors().indexOf(viewDescriptor) * 10;
- Rectangle target = bounds.getCopy().translate(translate, translate);
-
- if (((IHintedType) UMLElementTypes.Lifeline_3001).getSemanticHint()
- .equals(viewDescriptor.getSemanticHint())) {
- target.setY(SequenceUtil.LIFELINE_VERTICAL_OFFSET);
- }
-
- return target;
- }
-
- @Override
- protected void showSizeOnDropFeedback(CreateRequest request) {
- super.showSizeOnDropFeedback(request);
- if(request instanceof CreateAspectUnspecifiedTypeRequest){
- CreateAspectUnspecifiedTypeRequest req = (CreateAspectUnspecifiedTypeRequest)request;
- if(req.getElementTypes().contains(UMLElementTypes.CombinedFragment_3004) || req.getElementTypes().contains(UMLElementTypes.ConsiderIgnoreFragment_3007)){
- IFigure feedback = getSizeOnDropFeedback(request);
- Rectangle b = feedback.getBounds().getCopy();
- feedback.translateToAbsolute(b);
-
- HighlightUtil.showSizeOnDropFeedback(request, getHost(),feedback,b);
- }
- }
- }
-
- @Override
- protected void eraseSizeOnDropFeedback(Request request) {
- HighlightUtil.eraseSizeOnDropFeedback(request, getHost());
- super.eraseSizeOnDropFeedback(request);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandComponentEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandComponentEditPolicy.java
deleted file mode 100644
index 32ea7746f2e..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandComponentEditPolicy.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ComponentEditPolicy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OperandBoundsComputeHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDeleteHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.InteractionOperand;
-
-public class InteractionOperandComponentEditPolicy extends ComponentEditPolicy {
- /**
- * Delete Combined fragment and child from the view. Also delete message if user wants. {@inheritDoc}
- */
- @Override
- protected Command createDeleteViewCommand(GroupRequest deleteRequest) {
-
- if(getEditingDomain() != null) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(false);
- cmd.add(new CommandProxy(super.createDeleteViewCommand(deleteRequest)));
-
- if(getEObject() instanceof InteractionOperand) {
- // Get the elements associated with the CF
- List<Element> elements = SequenceUtil.getInteractionOperandAssociatedElement((InteractionOperand)getEObject());
- // Create the delete view commands
- SequenceDeleteHelper.deleteView(cmd, elements, getEditingDomain());
- }
-
- OperandBoundsComputeHelper.addUpdateBoundsCommandForOperandDelelete(this.getHost(),cmd);
-
- return new ICommandProxy(cmd.reduce());
- }
-
- return null;
- }
-
- /**
- * Copy from superclass as visibility is private
- *
- * @return the editing domain
- */
- private TransactionalEditingDomain getEditingDomain() {
- if(getHost() instanceof IGraphicalEditPart) {
- return ((IGraphicalEditPart)getHost()).getEditingDomain();
- } else if(getHost() instanceof IEditingDomainProvider) {
- Object domain = ((IEditingDomainProvider)getHost()).getEditingDomain();
- if(domain instanceof TransactionalEditingDomain) {
- return (TransactionalEditingDomain)domain;
- }
- }
- return null;
- }
-
- /**
- * Get the EObject of the host
- *
- * @return the EObject or null
- */
- private EObject getEObject() {
- if(getHost() instanceof GraphicalEditPart) {
- return ((GraphicalEditPart)getHost()).resolveSemanticElement();
- }
- return null;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java
deleted file mode 100644
index 578ef15a6b4..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.ResizableEditPolicy;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OperandBoundsComputeHelper;
-
-/**
- * The customn DragDropEditPolicy for InteractionOperandEditPart.
- */
-public class InteractionOperandDragDropEditPolicy extends ResizableEditPolicy {
-
- /**
- * Disable drag and allow only south resize. {@inheritDoc}
- */
- public InteractionOperandDragDropEditPolicy() {
- super();
- setDragAllowed(false);
- }
-
- /**
- * Handle resize InteractionOperand {@inheritDoc}
- */
- @Override
- protected Command getResizeCommand(ChangeBoundsRequest request) {
- if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
- EditPart parent = getHost().getParent().getParent();
- return parent.getCommand(request);
- } else{
- if (this.getHost() instanceof InteractionOperandEditPart
- && this.getHost().getParent() instanceof CombinedFragmentCombinedFragmentCompartmentEditPart) {
- InteractionOperandEditPart currentIOEP = (InteractionOperandEditPart) this
- .getHost();
- CombinedFragmentCombinedFragmentCompartmentEditPart compartEP = (CombinedFragmentCombinedFragmentCompartmentEditPart) this
- .getHost().getParent();
- // if first interaction operand and resize direction is NORTH
- if(this.getHost() == OperandBoundsComputeHelper.findFirstIOEP(compartEP)&&(request.getResizeDirection() & PositionConstants.NORTH) != 0){
- return getHost().getParent().getParent().getCommand(request);
- }else{
- int heightDelta = request.getSizeDelta().height();
- if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) {
- return OperandBoundsComputeHelper.createIOEPResizeCommand(currentIOEP, heightDelta,
- compartEP,PositionConstants.NORTH);
- } else if ((request.getResizeDirection() & PositionConstants.SOUTH) != 0) {
- return OperandBoundsComputeHelper.createIOEPResizeCommand(currentIOEP, heightDelta,
- compartEP,PositionConstants.SOUTH);
- }
- }
- }
- return null;
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandLayoutEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandLayoutEditPolicy.java
deleted file mode 100644
index a7b0d897b1f..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandLayoutEditPolicy.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-
-/**
- * The customn LayoutEditPolicy for InteractionOperandEditPart.
- */
-public class InteractionOperandLayoutEditPolicy extends XYLayoutEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = super.createChildEditPolicy(child);
- if(result == null) {
- return new ResizableShapeEditPolicy();
- }
- return result;
- }
-
- /**
- * Handle create InteractionOperand hover InteractionOperand {@inheritDoc}
- */
- @Override
- public Command getCommand(Request request) {
- EditPart combinedFragmentCompartment = getHost().getParent();
- EditPart combinedFragment = combinedFragmentCompartment.getParent();
- EditPart interactionCompartment = combinedFragment.getParent();
- if(REQ_CREATE.equals(request.getType()) && request instanceof CreateUnspecifiedTypeRequest) {
- if(UMLElementTypes.InteractionOperand_3005.equals(((CreateUnspecifiedTypeRequest)request).getElementTypes().get(0))) {
- return combinedFragmentCompartment.getCommand(request);
- } else if(UMLElementTypes.CombinedFragment_3004.equals(((CreateUnspecifiedTypeRequest)request).getElementTypes().get(0))) {
- return interactionCompartment.getCommand(request);
- } else if(UMLElementTypes.Lifeline_3001.equals(((CreateUnspecifiedTypeRequest)request).getElementTypes().get(0))) {
- return interactionCompartment.getCommand(request);
- }
- } else if(request instanceof CreateConnectionViewAndElementRequest) {
- CreateConnectionRequest createConnectionRequest = (CreateConnectionRequest)request;
- if(getHost().equals(createConnectionRequest.getSourceEditPart())) {
- createConnectionRequest.setSourceEditPart(combinedFragment);
- }
- if(getHost().equals(createConnectionRequest.getTargetEditPart())) {
- createConnectionRequest.setTargetEditPart(combinedFragment);
- }
- return combinedFragment.getCommand(request);
- } else if (request instanceof CreateViewAndElementRequest ) {
- //FIXME If necessary
- return null;
- }else if (REQ_RESIZE_CHILDREN.equals(request.getType())){
- return interactionCompartment.getCommand(request);
- }
- return super.getCommand(request);
- }
-
-// /**
-// * Handle combined fragment resize
-// */
-// @Override
-// protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
-// CompoundCommand compoundCmd = new CompoundCommand();
-// compoundCmd.setLabel("Move or Resize");
-//
-// for(Object o : request.getEditParts()) {
-// GraphicalEditPart child = (GraphicalEditPart)o;
-// Object constraintFor = getConstraintFor(request, child);
-// if(constraintFor != null) {
-// if(child instanceof CombinedFragmentEditPart) {
-// Command resizeChildrenCommand = InteractionCompartmentXYLayoutEditPolicy.getCombinedFragmentResizeChildrenCommand(request, (CombinedFragmentEditPart)child);
-// if(resizeChildrenCommand != null && resizeChildrenCommand.canExecute()) {
-// compoundCmd.add(resizeChildrenCommand);
-// }
-// }
-//
-// Command changeConstraintCommand = createChangeConstraintCommand(request, child, translateToModelConstraint(constraintFor));
-// compoundCmd.add(changeConstraintCommand);
-// }
-// }
-// if(compoundCmd.isEmpty()) {
-// return null;
-// }
-// return compoundCmd.unwrap();
-// }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineAppliedStereotypeNodeLabelDisplayEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineAppliedStereotypeNodeLabelDisplayEditPolicy.java
deleted file mode 100644
index 89d286192d1..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineAppliedStereotypeNodeLabelDisplayEditPolicy.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-
-/**
- * This policy is used to automatically move a lifeline when a stereotype is changed.
- * this avoids the move of the dash line and its ES.
- *
- * @author mvelten
- *
- */
-public class LifelineAppliedStereotypeNodeLabelDisplayEditPolicy extends AppliedStereotypeNodeLabelDisplayEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void refreshDisplay() {
- super.refreshDisplay();
-
- if(getHost() instanceof LifelineEditPart) {
- ((LifelineEditPart)getHost()).updateLifelinePosition();
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java
deleted file mode 100644
index e8174e2c052..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionRouter;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.Polyline;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers.MessageRouter;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationMoveHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-
-/**
- * A specific policy to handle :
- * - Message aspects inherited from {@link SequenceGraphicalNodeEditPolicy}.
- * - Time/duration move when a message end or an execution is moved.
- * - Duration constraint/observation creation feedback.
- * - Creation of general ordering links.
- * This edit policy is intended to be installed on parts which represent a lifeline or which are contained within a lifeline part.
- */
-public class LifelineChildGraphicalNodeEditPolicy extends SequenceGraphicalNodeEditPolicy {
-
- /** the feedback for creating a duration constraint node */
- private Polyline durationCreationFeedback = null;
-
- /** the router to use for messages */
- public static ConnectionRouter messageRouter = new MessageRouter();
-
- @Override
- public Command getCommand(Request request) {
- if(RequestConstants.REQ_CONNECTION_START.equals(request.getType())) {
- if(request instanceof CreateConnectionViewAndElementRequest) {
- return getConnectionAndRelationshipCreateCommand((CreateConnectionViewAndElementRequest)request);
- } else if(request instanceof CreateUnspecifiedTypeConnectionRequest) {
- return getUnspecifiedConnectionCreateCommand((CreateUnspecifiedTypeConnectionRequest)request);
- }
- } else if(RequestConstants.REQ_CONNECTION_END.equals(request.getType())) {
- if(request instanceof CreateConnectionViewAndElementRequest) {
- return getConnectionAndRelationshipCompleteCommand((CreateConnectionViewAndElementRequest)request);
- } else if(request instanceof CreateUnspecifiedTypeConnectionRequest) {
- return getUnspecifiedConnectionCompleteCommand((CreateUnspecifiedTypeConnectionRequest)request);
- }
- }
- return super.getCommand(request);
- }
-
- /**
- * Gets the command to start the creation of a new connection and
- * relationship (if applicable) for a unspecified type request. This will
- * update all the individual requests appropriately.
- *
- * @param request
- * the unspecified type request
- * @return the command
- */
- private Command getUnspecifiedConnectionCreateCommand(final CreateUnspecifiedTypeConnectionRequest request) {
-
- if(request.isDirectionReversed()) {
- return new Command() {
-
- /**
- * All we know is the target and the possible relationship
- * types. At this point, there is no way to validate the
- * commands for this scenario.
- */
- public boolean canExecute() {
- return true;
- }
- };
- } else {
-
- // Get the start command for each individual request, this will
- // update each request as required.
- final List commands = new ArrayList();
- for(Iterator iter = request.getAllRequests().iterator(); iter.hasNext();) {
- Request individualRequest = (Request)iter.next();
- Command cmd = null;
- if(individualRequest instanceof CreateConnectionViewAndElementRequest) {
- cmd = getConnectionAndRelationshipCreateCommand((CreateConnectionViewAndElementRequest)individualRequest);
- } else if(individualRequest instanceof CreateConnectionViewRequest) {
- cmd = getConnectionCreateCommand((CreateConnectionViewRequest)individualRequest);
- }
- if(cmd != null && cmd.canExecute()) {
- commands.add(cmd);
- }
- }
-
- if(commands.isEmpty()) {
- // GEF's AbstractConnectionCreationTool expects a null command
- // when the gesture should be disabled.
- return null;
- }
-
- // return an executable command that does nothing
- return new Command() {/* do nothing */
- };
- }
- }
-
- /**
- * Get the command to reconnect the source and move associated time/duration constraints/observation.
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceGraphicalNodeEditPolicy#getReconnectSourceCommand(org.eclipse.gef.requests.ReconnectRequest)
- *
- * @param request
- * the reconnection request
- * @return the command
- */
- @Override
- protected Command getReconnectSourceCommand(ReconnectRequest request) {
- Command command = super.getReconnectSourceCommand(request);
- if(command != null) {
- command = OccurrenceSpecificationMoveHelper.completeReconnectConnectionCommand(command, request, getConnectableEditPart());
- if(request.getConnectionEditPart() instanceof Message4EditPart && request.getTarget() instanceof LifelineEditPart){
- LifelineEditPart newSource = (LifelineEditPart) request.getTarget();
- LifelineEditPart target = (LifelineEditPart) request.getConnectionEditPart().getTarget();
- command = LifelineMessageCreateHelper.moveLifelineDown(command, target, newSource.getFigure().getBounds().getLocation().getCopy());
- }
- }
- return command;
- }
-
- /**
- * Get the command to reconnect the target and move associated time/duration constraints/observation.
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceGraphicalNodeEditPolicy#getReconnectTargetCommand(org.eclipse.gef.requests.ReconnectRequest)
- *
- * @param request
- * the reconnection request
- * @return the command
- */
- @Override
- protected Command getReconnectTargetCommand(ReconnectRequest request) {
- Command command = super.getReconnectTargetCommand(request);
- if(command != null) {
- command = OccurrenceSpecificationMoveHelper.completeReconnectConnectionCommand(command, request, getConnectableEditPart());
- if(request.getConnectionEditPart() instanceof Message4EditPart && request.getTarget() instanceof LifelineEditPart){
- command = LifelineMessageCreateHelper.reconnectMessageCreateTarget(request, command);
- }
- }
- return command;
- }
-
- /**
- * Show the feedback for creating a duration constraint from this edit part
- *
- * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#showSourceFeedback(org.eclipse.gef.Request)
- * @param request
- * creation request
- */
- @Override
- public void showSourceFeedback(Request request) {
- if(request instanceof CreateUnspecifiedTypeRequest) {
- Object hintedType = ((CreateUnspecifiedTypeRequest)request).getElementTypes().get(0);
- CreateRequest req = null;
- if(UMLElementTypes.DurationConstraint_3021.equals(hintedType)) {
- req = ((CreateUnspecifiedTypeRequest)request).getRequestForType(UMLElementTypes.DurationConstraint_3021);
- } else if(UMLElementTypes.DurationObservation_3024.equals(hintedType)) {
- req = ((CreateUnspecifiedTypeRequest)request).getRequestForType(UMLElementTypes.DurationObservation_3024);
- }
- if(req != null) {
- Object initLocation = req.getExtendedData().get(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION);
- if(initLocation instanceof Point) {
- Point startPoint = ((Point)initLocation).getCopy();
- Point targetPoint = ((CreateUnspecifiedTypeRequest)request).getLocation().getCopy();
- getFeedbackLayer().translateToRelative(startPoint);
- getFeedbackLayer().translateToRelative(targetPoint);
- if(durationCreationFeedback == null) {
- durationCreationFeedback = new Polyline();
- durationCreationFeedback.setLineWidth(1);
- durationCreationFeedback.setLineStyle(Graphics.LINE_DASHDOT);
- durationCreationFeedback.setForegroundColor(((IGraphicalEditPart)getHost()).getFigure().getLocalForegroundColor());
- addFeedback(durationCreationFeedback);
- }
- durationCreationFeedback.setStart(startPoint);
- durationCreationFeedback.setEnd(targetPoint);
- return;
- }
- }
- }
- super.showSourceFeedback(request);
- }
-
- /**
- * Erase the feedback for creating a duration constraint from this edit part
- *
- * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#eraseSourceFeedback(org.eclipse.gef.Request)
- * @param request
- * creation request
- */
- @Override
- public void eraseSourceFeedback(Request request) {
- super.eraseSourceFeedback(request);
- if(durationCreationFeedback != null)
- removeFeedback(durationCreationFeedback);
- durationCreationFeedback = null;
- }
-
- /**
- * Get the replacing connection router for routing messages correctly
- *
- * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getDummyConnectionRouter(org.eclipse.gef.requests.CreateConnectionRequest)
- */
- protected ConnectionRouter getDummyConnectionRouter(CreateConnectionRequest req) {
- return messageRouter;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineCreationEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineCreationEditPolicy.java
deleted file mode 100644
index 81273970770..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineCreationEditPolicy.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SemanticCreateCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RefreshConnectionsRequest;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-/**
- * A specific creation edit policy for the Lifeline.
- * Execution Specification is created graphically on the lifeline, but depending on its graphical position determines also its model container.
- *
- * Occurrence Specification is located on the lifeline, but not visible. Though, elements must be created on it.
- */
-public class LifelineCreationEditPolicy extends CreationEditPolicy {
-
- @Override
- protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {
- // get the element descriptor
- CreateElementRequestAdapter requestAdapter = request.getViewAndElementDescriptor().getCreateElementRequestAdapter();
-
- // get the semantic request
- CreateElementRequest createElementRequest = (CreateElementRequest)requestAdapter.getAdapter(CreateElementRequest.class);
-
- if(createElementRequest.getContainer() == null) {
- // complete the semantic request by filling in the host's semantic
- // element as the context
- View view = (View)getHost().getModel();
- EObject hostElement = ViewUtil.resolveSemanticElement(view);
-
- if(hostElement == null && view.getElement() == null) {
- hostElement = view;
- }
-
- // Returns null if host is unresolvable so that trying to create a
- // new element in an unresolved shape will not be allowed.
- if(hostElement == null) {
- return null;
- }
- createElementRequest.setContainer(hostElement);
- }
-
- InteractionFragment ift = SequenceUtil.findInteractionFragmentContainerAt(request.getLocation(), getHost());
-
- Map<String, Object> extendedData = request.getExtendedData();
- extendedData.put(SequenceRequestConstant.INTERACTIONFRAGMENT_CONTAINER, ift);
-
- // record the nearest event if necessary
- String requestHint = request.getViewAndElementDescriptor().getSemanticHint();
- if(isCreatedOnOccurrenceSpecification(requestHint)) {
- EditPart hostPart = getHost();
- if(hostPart instanceof LifelineEditPart) {
- Entry<Point, List<OccurrenceSpecification>> eventAndLocation = SequenceUtil.findNearestEvent(request.getLocation(), (LifelineEditPart)hostPart);
- // find an event near enough to create the constraint or observation
- List<OccurrenceSpecification> events = Collections.emptyList();
- Point location = null;
- if(eventAndLocation != null) {
- location = eventAndLocation.getKey();
- events = eventAndLocation.getValue();
- }
- if(extendedData.containsKey(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2)) {
- extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2, events);
- } else {
- extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, events);
- }
- if(extendedData.containsKey(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2)) {
- extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2, location);
- } else {
- extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION, location);
- }
- }
- }
-
- // get the create element command based on the elementdescriptor's
- // request
- Command createElementCommand = getHost().getCommand(new EditCommandRequestWrapper((CreateElementRequest)requestAdapter.getAdapter(CreateElementRequest.class), request.getExtendedData()));
-
- if(createElementCommand == null) {
- return UnexecutableCommand.INSTANCE;
- }
- if(!createElementCommand.canExecute()) {
- return createElementCommand;
- }
- // create the semantic create wrapper command
- SemanticCreateCommand semanticCommand = new SemanticCreateCommand(requestAdapter, createElementCommand);
- Command viewCommand = getCreateCommand(request);
-
- Command refreshConnectionCommand = getHost().getCommand(new RefreshConnectionsRequest(((List)request.getNewObject())));
-
-
- // form the compound command and return
- CompositeCommand cc = new CompositeCommand(semanticCommand.getLabel());
- cc.compose(semanticCommand);
- cc.compose(new CommandProxy(viewCommand));
- if(refreshConnectionCommand != null) {
- cc.compose(new CommandProxy(refreshConnectionCommand));
- }
-
- LifelineEditPart parentPart = (LifelineEditPart)getHost();
- IHintedType type = (IHintedType)UMLElementTypes.Lifeline_3001;
- if(type.getSemanticHint().equals(request.getViewAndElementDescriptor().getSemanticHint())) {
- setChildLifelineBounds(cc, request, parentPart);
- }
-
- return new ICommandProxy(cc);
- }
-
- private void setChildLifelineBounds(CompositeCommand cc, CreateViewAndElementRequest request, LifelineEditPart parentPart) {
- Point location = request.getLocation().getCopy();
- LifelineDotLineCustomFigure parentFigure = (LifelineDotLineCustomFigure) parentPart.getContentPane();
- Rectangle parentBounds = parentFigure.getBounds().getCopy();
- parentFigure.translateToAbsolute(parentBounds );
-
- Rectangle childBounds = parentBounds.getCopy();
- childBounds.height = parentBounds.height;
- childBounds.width = -1; // default size
- childBounds.y = 0; // y offset from parent
- childBounds.x = location.x - parentBounds.x; // x offset from parent
-
- SetBoundsCommand cmd = new SetBoundsCommand(parentPart.getEditingDomain(), "set size", request.getViewAndElementDescriptor(), childBounds);
- cc.compose(cmd);
- }
-
- /**
- * Return true if creation must be performed on an occurrence specification
- *
- * @param requestHint
- * the hint of object to create
- * @return true if creation on an occurrence specification
- */
- private boolean isCreatedOnOccurrenceSpecification(String requestHint) {
- return isTimeHint(requestHint) || isDurationHint(requestHint);
- }
-
- /**
- * Return true if hint is for creating a duration observation/constraint
- *
- * @param requestHint
- * the hint of object to create
- * @return true if correct hint
- */
- private boolean isDurationHint(String requestHint) {
- String durCstOnLifelineHint = ((IHintedType)UMLElementTypes.DurationConstraint_3021).getSemanticHint();
- String durCstOnMessage = ((IHintedType)UMLElementTypes.DurationConstraint_3023).getSemanticHint();
- String durObsOnMessage = ((IHintedType)UMLElementTypes.DurationObservation_3024).getSemanticHint();
- return durCstOnLifelineHint.equals(requestHint) || durCstOnMessage.equals(requestHint) || durObsOnMessage.equals(requestHint);
- }
-
- /**
- * Return true if hint is for creating a time observation/constraint
- *
- * @param requestHint
- * the hint of object to create
- * @return true if correct hint
- */
- private boolean isTimeHint(String requestHint) {
- String timeConstraintHint = ((IHintedType)UMLElementTypes.TimeConstraint_3019).getSemanticHint();
- String timeObservationHint = ((IHintedType)UMLElementTypes.TimeObservation_3020).getSemanticHint();
- return timeConstraintHint.equals(requestHint) || timeObservationHint.equals(requestHint);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
deleted file mode 100644
index 76a3aaf1bb9..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
+++ /dev/null
@@ -1,207 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.sequence.preferences.LifelinePreferencePage;
-import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineLabelHelper;
-import org.eclipse.uml2.uml.ConnectableElement;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-
-public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- private IPropertyChangeListener preferenceListener;
-
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
-
- if(preferenceListener == null){
- preferenceListener = new IPropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent event) {
- handlePreferenceChange(event);
- }
- };
- IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
- store.addPropertyChangeListener(this.preferenceListener);
- }
-
- Lifeline lifeline = getUMLElement();
- // check host semantic element is not null
- if(lifeline == null) {
- return;
- }
- // adds a listener to the element itself, and to linked elements, like Type
- getDiagramEventBroker().addNotificationListener(lifeline, this);
-
- ConnectableElement ce = lifeline.getRepresents();
- if(ce != null){
- getDiagramEventBroker().addNotificationListener(ce, this);
- if(ce.getType() != null)
- getDiagramEventBroker().addNotificationListener(ce.getType(), this);
- }
- }
-
- protected void handlePreferenceChange(PropertyChangeEvent event) {
- EditPart part = getHost();
- if(part == null || part.getParent() == null)
- return;
-
- String key = event.getProperty();
- if(key.equals(LifelinePreferencePage.LABEL_DISPLAY_PREFERENCE)){
- refreshDisplay();
- }
- }
-
- @Override
- protected void removeAdditionalListeners() {
- super.removeAdditionalListeners();
- Lifeline lifeline = getUMLElement();
- // check host semantic element is not null
- if(lifeline == null) {
- return;
- }
- getDiagramEventBroker().removeNotificationListener(lifeline, this);
-
- ConnectableElement ce = lifeline.getRepresents();
- if(ce != null){
- getDiagramEventBroker().removeNotificationListener(ce, this);
- if(ce.getType() != null)
- getDiagramEventBroker().removeNotificationListener(ce.getType(), this);
- }
- }
-
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
-
- Object object = notification.getNotifier();
- if(object == null || getUMLElement() == null) {
- return;
- }
-
- if(notification.getFeature().equals(UMLPackage.eINSTANCE.getNamedElement_Name())) {
- refreshDisplay();
- } else if(notification.getFeature().equals(UMLPackage.Literals.LIFELINE__REPRESENTS)) {
- // change represent element
- if(notification.getNewValue() instanceof ConnectableElement){
- ConnectableElement ce = (ConnectableElement )notification.getNewValue();
- getDiagramEventBroker().addNotificationListener(ce, this);
- if(ce.getType() != null)
- getDiagramEventBroker().addNotificationListener(ce.getType(), this);
- }
-
- if(notification.getOldValue() instanceof ConnectableElement){
- ConnectableElement ce = (ConnectableElement )notification.getOldValue();
- getDiagramEventBroker().removeNotificationListener(ce, this);
-
- if(ce.getType() != null)
- getDiagramEventBroker().removeNotificationListener(ce.getType(), this);
- }
-
- refreshDisplay();
- }else if(isMaskManagedAnnotation(object) || isRemovedMaskManagedLabelAnnotation(object, notification)) {
- refreshDisplay();
- } else if(object.equals(getUMLElement().getRepresents()) ){
- // change represent type
- if(notification.getNewValue() instanceof Type && notification.getNewValue() instanceof EObject){
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- }
-
- if(notification.getOldValue() instanceof Type && notification.getOldValue() instanceof EObject){
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- }
-
- refreshDisplay();
- }
- }
-
-
- public void refreshDisplay() {
- // calls the helper for this edit Part
- LifelineEditPart lp = (LifelineEditPart)getHost();
- List children = lp.getChildren();
- for(Object p : children)
- if(p instanceof LifelineNameEditPart)
- LifelineLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart)p);
- }
-
- public int getCurrentDisplayValue() {
- EAnnotation customeDisplayAnnotation = ((View)getHost().getModel()).getEAnnotation(VisualInformationPapyrusConstants.CUSTOM_APPEARENCE_ANNOTATION);
- int displayValue = getDefaultDisplayValue();
- if(customeDisplayAnnotation != null && customeDisplayAnnotation.getDetails().get(VisualInformationPapyrusConstants.CUSTOM_APPEARANCE_MASK_VALUE) != null) {
- displayValue = Integer.parseInt(customeDisplayAnnotation.getDetails().get(VisualInformationPapyrusConstants.CUSTOM_APPEARANCE_MASK_VALUE));
- } else {
- // no specific information => look in preferences
- IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
- int displayValueTemp = store.getInt(LifelinePreferencePage.LABEL_DISPLAY_PREFERENCE);
- if(displayValueTemp != 0) {
- displayValue = displayValueTemp;
- }
- }
- return displayValue;
- }
-
- public int getDefaultDisplayValue() {
- return LifelinePreferencePage.DEFAULT_LABEL_DISPLAY;
- }
-
- public String getMaskLabel(int value) {
- return LifelineLabelHelper.getInstance().getMaskLabel(value);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<String> getMaskLabels() {
- return LifelineLabelHelper.getInstance().getMaskLabels();
- }
-
- /**
- * {@inheritDoc}
- */
- public Map<Integer, String> getMasks() {
- return LifelineLabelHelper.getInstance().getMasks();
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<Integer> getMaskValues() {
- return LifelineLabelHelper.getInstance().getMaskValues();
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPreferencePageID() {
- return "org.eclipse.papyrus.uml.diagram.sequence.preferences.LifelinePreferencePage";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Lifeline getUMLElement() {
- return (Lifeline)hostSemanticElement;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java
deleted file mode 100644
index 876f6034ff2..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java
+++ /dev/null
@@ -1,927 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.commands.PreserveAnchorsPositionCommand;
-import org.eclipse.papyrus.uml.diagram.common.draw2d.LifelineDotLineFigure;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.command.CustomZOrderCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragment2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart.StateInvariantResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.HighlightUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationMoveHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-
-/**
- * The custom LayoutEditPolicy for LifelineEditPart.
- */
-public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy {
-
- /** Initialization width of Execution Specification. */
- public final static int EXECUTION_INIT_WIDTH = 16;
-
- /** Initialization width of CoRegion. */
- public final static int COREGION_INIT_WIDTH = 30;
-
- /** Initialization height of Execution Specification. */
- private final static int EXECUTION_INIT_HEIGHT = 50;
-
- /** Initialization height of a time bar figure. */
- private static final int TIME_BAR_HEIGHT = 1;
-
- /** The default spacing used between Execution Specification */
- private final static int SPACING_HEIGHT = 5;
-
- // force location of time/duration elements and ES
- private static final String TIME_CONSTRAINT_HINT = ((IHintedType)UMLElementTypes.TimeConstraint_3019).getSemanticHint();
-
- private static final String TIME_OBSERVATION_HINT = ((IHintedType)UMLElementTypes.TimeObservation_3020).getSemanticHint();
-
- private static final String DURATION_CONSTRAINT_ON_LIFELINE_HINT = ((IHintedType)UMLElementTypes.DurationConstraint_3021).getSemanticHint();
-
- private static final String ACTION_EXECUTION_SPECIFICATION_HINT = ((IHintedType)UMLElementTypes.ActionExecutionSpecification_3006).getSemanticHint();
-
- private static final String BEHAVIOR_EXECUTION_SPECIFICATION_HINT = ((IHintedType)UMLElementTypes.BehaviorExecutionSpecification_3003).getSemanticHint();
-
- private static final String CO_REGION_HINT = ((IHintedType)UMLElementTypes.CombinedFragment_3018).getSemanticHint();
-
- private HighlightUtil highlightUtil = new HighlightUtil();
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- if(request instanceof CreateViewRequest) {
- CreateViewRequest cvr = (CreateViewRequest)request;
- if(cvr.getViewDescriptors().size() > 0) {
- ViewDescriptor viewDescriptor = cvr.getViewDescriptors().iterator().next();
- String semanticHint = viewDescriptor.getSemanticHint();
-
- if(TIME_CONSTRAINT_HINT.equals(semanticHint) || TIME_OBSERVATION_HINT.equals(semanticHint)) {
- Command cmd = getCommandForTimeObservationOrConstraint(cvr, viewDescriptor);
- if(cmd != null) {
- return cmd;
- }
- }
- if(DURATION_CONSTRAINT_ON_LIFELINE_HINT.equals(semanticHint)) {
- Command cmd = getCommandForDurationConstraint(cvr, viewDescriptor);
- if(cmd != null) {
- return cmd;
- }
- }
- if(ACTION_EXECUTION_SPECIFICATION_HINT.equals(semanticHint) || BEHAVIOR_EXECUTION_SPECIFICATION_HINT.equals(semanticHint)) {
- Command cmd = getCommandForExecutionSpecificationCreation(cvr, viewDescriptor);
- if(cmd != null) {
- return cmd;
- }
- }
- if(CO_REGION_HINT.equals(semanticHint)) {
- Command cmd = getCommandForCoRegionCreation(cvr, viewDescriptor);
- if(cmd != null) {
- return cmd;
- }
- }
- }
- }
-
- return super.getCreateCommand(request);
- }
-
- @Override
- protected void showLayoutTargetFeedback(Request request) {
- if(request instanceof CreateUnspecifiedTypeRequest) {
- CreateUnspecifiedTypeRequest cvr = (CreateUnspecifiedTypeRequest)request;
- if(!cvr.getElementTypes().isEmpty()) {
- IHintedType elementType = (IHintedType)cvr.getElementTypes().iterator().next();
- String semanticHint = elementType.getSemanticHint();
- EditPart editPartForHighlight = getHost();
- if(ACTION_EXECUTION_SPECIFICATION_HINT.equals(semanticHint) || BEHAVIOR_EXECUTION_SPECIFICATION_HINT.equals(semanticHint)) {
- ShapeNodeEditPart parentExecuteSpecification = getParentWhenCreationExecuteSpecification(cvr.getLocation(), cvr.getSize(), semanticHint);
- if(parentExecuteSpecification != null) {
- editPartForHighlight = parentExecuteSpecification;
- }
- }
- if(editPartForHighlight != null) {
- highlightUtil.unhighlight();
- highlightUtil.highlight(editPartForHighlight);
- }
- }
- }
- super.showLayoutTargetFeedback(request);
- }
-
- @Override
- protected void eraseLayoutTargetFeedback(Request request) {
- super.eraseLayoutTargetFeedback(request);
- highlightUtil.unhighlight();
- }
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- View childView = (View)child.getModel();
- switch(UMLVisualIDRegistry.getVisualID(childView)) {
- case StateInvariantEditPart.VISUAL_ID:
- return new StateInvariantResizableEditPolicy();
- case DestructionOccurrenceSpecificationEditPart.VISUAL_ID:
- return new BorderItemResizableEditPolicy();
- }
- return super.createChildEditPolicy(child);
- }
-
- @Override
- protected Rectangle getCurrentConstraintFor(GraphicalEditPart child) {
- IFigure fig = child.getFigure();
- Object con = fig.getParent().getLayoutManager().getConstraint(fig);
- if(con instanceof Rectangle) {
- return (Rectangle)con;
- }
- return fig.getBounds();
- }
-
- @Override
- protected Object getConstraintFor(CreateRequest request) {
- Rectangle constraint = (Rectangle)super.getConstraintFor(request);
- if(request instanceof CreateViewAndElementRequest) {
- CreateViewAndElementRequest req = (CreateViewAndElementRequest)request;
- IHintedType type = (IHintedType)UMLElementTypes.Lifeline_3001;
- if(type.getSemanticHint().equals(req.getViewAndElementDescriptor().getSemanticHint())) {
- constraint.y = 0; // fix layout offset
- }
-
- String destructionHint = ((IHintedType)UMLElementTypes.DestructionOccurrenceSpecification_3022).getSemanticHint();
- if(destructionHint.equals(req.getViewAndElementDescriptor().getSemanticHint()) && constraint.width < 0 && constraint.height < 0) {
- constraint.width = constraint.height = 20;// set initial size, same as DestructionOccurrenceSpecificationPreferencePage
- }
- }
- return constraint;
- }
-
- private static Rectangle getNewBoundsForCoRegion(LifelineEditPart lifelineEP, Rectangle bounds) {
- Rectangle newBounds = bounds.getCopy();
-
- // Get the dotline figure
- LifelineDotLineFigure figureLifelineDotLineFigure = lifelineEP.getPrimaryShape().getFigureLifelineDotLineFigure();
-
- // Translate the absolute location to relative
- figureLifelineDotLineFigure.translateToRelative(newBounds);
- newBounds.translate(figureLifelineDotLineFigure.getBounds().getLocation().getCopy().negate());
-
- Rectangle dotLineFigureBounds = figureLifelineDotLineFigure.getBounds();
-
- newBounds.x = dotLineFigureBounds.width / 2 - COREGION_INIT_WIDTH / 2;
- newBounds.width = COREGION_INIT_WIDTH;
-
- return newBounds;
- }
-
- private Command getCommandForCoRegionCreation(CreateViewRequest cvr, ViewDescriptor viewDescriptor) {
- Rectangle newBounds = new Rectangle();
- if(cvr.getLocation() != null) {
- newBounds.setLocation(cvr.getLocation());
- }
- if(cvr.getSize() != null) {
- newBounds.setSize(cvr.getSize());
- } else {
- newBounds.width = -1;
- newBounds.height = -1;
- }
-
- if(newBounds.x < 0 || newBounds.y < 0) {
- newBounds.x = newBounds.y = 0;
- }
-
- newBounds = getNewBoundsForCoRegion((LifelineEditPart)getHost(), newBounds);
-
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
- return new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, newBounds));
- }
-
- private Rectangle getCreateExecuteSpecificationBounds(Point location, Dimension size, String semanticHint) {
- Point newLocation = location == null ? new Point() : location.getCopy();
-
- if(newLocation.x < 0 || newLocation.y < 0) {
- newLocation.x = newLocation.y = 0;
- }
-
- LifelineEditPart editPart = (LifelineEditPart)getHost();
-
- // Get the dotline figure
- LifelineDotLineFigure figureLifelineDotLineFigure = editPart.getPrimaryShape().getFigureLifelineDotLineFigure();
- List<ShapeNodeEditPart> executionSpecificationList = editPart.getChildShapeNodeEditPart();
-
- // Translate the absolute location to relative
- figureLifelineDotLineFigure.translateToRelative(newLocation);
-
- Rectangle dotLineFigureBounds = figureLifelineDotLineFigure.getBounds();
- // If we are creating an ES from the popup menu bar
- // We need to get a valid location to be able to create the ES figure
- if(newLocation.y < dotLineFigureBounds.y) {
- int max = dotLineFigureBounds.y;
- for(ShapeNodeEditPart sp : executionSpecificationList) {
- int figureBottom = sp.getFigure().getBounds().y + sp.getFigure().getBounds().height;
- if(figureBottom > max) {
- max = figureBottom;
- }
- }
- // Vertically, the new ES is located after all existing ES on the lifeline
- newLocation.y = max + SPACING_HEIGHT;
- // Horizontally, the figure is placed at the center of the lifeline
- newLocation.x = dotLineFigureBounds.x + dotLineFigureBounds.width / 2 - EXECUTION_INIT_WIDTH / 2;
- }
-
- // Get the height of the Execution specification
- int newHeight = getFigureHeight(semanticHint, size);
-
- // Define the bounds of the new Execution specification
- return new Rectangle(newLocation.x, newLocation.y, -1, newHeight);
- }
-
- private ShapeNodeEditPart getParentWhenCreationExecuteSpecification(Point location, Dimension size, String semanticHint) {
-
- // Define the bounds of the new Execution specification
- Rectangle newBounds = getCreateExecuteSpecificationBounds(location, size, semanticHint);
- // Get the dotline figure
- List<ShapeNodeEditPart> executionSpecificationList = ((LifelineEditPart)getHost()).getChildShapeNodeEditPart();
-
- return getParent((LifelineEditPart)getHost(), newBounds, executionSpecificationList);
- }
-
- private Command getCommandForExecutionSpecificationCreation(CreateViewRequest cvr, ViewDescriptor viewDescriptor) {
-
- LifelineEditPart editPart = (LifelineEditPart)getHost();
-
- List<ShapeNodeEditPart> executionSpecificationList = editPart.getChildShapeNodeEditPart();
-
- Point location = cvr.getLocation();
- Dimension size = cvr.getSize();
- String semanticHint = viewDescriptor.getSemanticHint();
-
- // Define the bounds of the new Execution specification
- Rectangle newBounds = getCreateExecuteSpecificationBounds(location, size, semanticHint);
- ShapeNodeEditPart parent = getParentWhenCreationExecuteSpecification(location, size, semanticHint);
- newBounds = getExecutionSpecificationNewBounds(true, editPart, new Rectangle(), newBounds, new ArrayList<ShapeNodeEditPart>(0), false);
- if(newBounds == null) {
- return UnexecutableCommand.INSTANCE;
- }
- Command p = new ICommandProxy(new SetBoundsCommand(editPart.getEditingDomain(), "Creation of an ExecutionSpecification", viewDescriptor, newBounds));
-
- // resize parent bar
- if(parent != null) {
- p = p.chain(resizeParentExecutionSpecification((LifelineEditPart)getHost(), parent, newBounds.getCopy(), executionSpecificationList));
- }
- return p;
- }
-
- private static Command resizeParentExecutionSpecification(LifelineEditPart lifelinePart, ShapeNodeEditPart part, Rectangle childBounds, List<ShapeNodeEditPart> list) {
- Rectangle bounds = getRelativeBounds(part.getFigure());
-
- childBounds.x = bounds.x;
- childBounds.width = bounds.width;
- if(bounds.contains(childBounds)) {
- return null;
- }
- bounds.union(childBounds);
- Command c = new ICommandProxy(new SetBoundsCommand(part.getEditingDomain(), "Resize of Parent Bar", part, bounds.getCopy()));
-
- list.remove(part);
- ShapeNodeEditPart parent = getParent(lifelinePart, part.getFigure().getBounds(), list);
- if(parent == null) {
- return c;
- }
-
- return c.chain(resizeParentExecutionSpecification(lifelinePart, parent, bounds.getCopy(), list));
- }
-
- /**
- * Get the command for setting initial bounds of a Time Observation or Constraint representation
- *
- * @param cver
- * the request
- * @return command or null if none is appropriate
- */
- private Command getCommandForTimeObservationOrConstraint(CreateViewRequest cvr, ViewDescriptor viewDescriptor) {
- Object loc = cvr.getExtendedData().get(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION);
- if(loc instanceof Point) {
- IFigure parentFigure = ((IGraphicalEditPart)getHost()).getFigure();
- Point referencePoint = ((Point)loc).getCopy();
- parentFigure.translateToRelative(referencePoint);
- referencePoint.translate(parentFigure.getBounds().getLocation().getCopy().negate());
- // Get the height of the element
- int newHeight = getFigureHeight(viewDescriptor.getSemanticHint(), cvr.getSize());
- // Define the bounds of the new time element
- Rectangle newBounds = new Rectangle(referencePoint.x, referencePoint.y - newHeight / 2, -1, newHeight);
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
- return new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, newBounds));
- }
- return null;
- }
-
- /**
- * Get the command for setting initial bounds of a Duration Constraint representation
- *
- * @param cver
- * the request
- * @return command or null if none is appropriate
- */
- private Command getCommandForDurationConstraint(CreateViewRequest cvr, ViewDescriptor viewDescriptor) {
- Object locTop = cvr.getExtendedData().get(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION);
- Object locBottom = cvr.getExtendedData().get(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2);
- if(locTop instanceof Point && locBottom instanceof Point) {
- IFigure parentFigure = ((IGraphicalEditPart)getHost()).getFigure();
- Point referenceTop = ((Point)locTop).getCopy();
- Point referenceBottom = ((Point)locBottom).getCopy();
- // Get the height of the element
- int newHeight = referenceBottom.y - referenceTop.y;
- if(newHeight > 0) {
- parentFigure.translateToRelative(referenceTop);
- Point parentFigDelta = parentFigure.getBounds().getLocation().getCopy().negate();
- referenceTop.translate(parentFigDelta);
- // Define the bounds of the new time element
- Rectangle newBounds = new Rectangle(referenceTop.x, referenceTop.y, -1, newHeight);
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
- return new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, newBounds));
- } else if(newHeight < 0) {
- parentFigure.translateToRelative(referenceBottom);
- Point parentFigDelta = parentFigure.getBounds().getLocation().getCopy().negate();
- referenceBottom.translate(parentFigDelta);
- // Define the bounds of the new time element
- Rectangle newBounds = new Rectangle(referenceBottom.x, referenceBottom.y, -1, -newHeight);
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
- return new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, newBounds));
- }
- }
- return null;
- }
-
- /**
- * Get the adapted height, taking in account the represented figure
- *
- * @param cr
- * the create request
- * @return the height defined in the create request or a default value depending on the created figure
- */
- private int getFigureHeight(String semanticHint, Dimension size) {
- int newHeight;
- if(TIME_OBSERVATION_HINT.equals(semanticHint) || TIME_CONSTRAINT_HINT.equals(semanticHint)) {
- // height for a time bar (takes precedence on request's size)
- newHeight = TIME_BAR_HEIGHT;
- } else if(size != null) {
- // heigh from request
- newHeight = size.height;
- } else {
- newHeight = EXECUTION_INIT_HEIGHT;
- }
- return newHeight;
- }
-
- /**
- * Useful operation to know where the figure of a ExecutionSpecification EditPart should be
- * positioned within a Lifeline EditPart. The notToCheckList is needed to avoid checking those
- * ExecutionSpecification EditParts. The returned bounds are relative to the Lifeline figure so
- * they can be used, directly, within a SetBoundsCommand.
- *
- * @param lifelineEP
- * the lifeline ep
- * @param oldBounds
- * The old bounds of the ES
- * @param newBounds
- * The new initial bounds
- * @param notToCheckExecutionSpecificationList
- * The ExecutionSpecification EditPart's List that won't be checked
- *
- * @return The new bounds of the executionSpecificationEP figure
- */
- protected final static Rectangle getExecutionSpecificationNewBounds(boolean isMove, LifelineEditPart lifelineEP, Rectangle oldBounds, Rectangle newBounds, List<ShapeNodeEditPart> notToCheckExecutionSpecificationList, boolean useFixedXPos) {
- // Lifeline's figure where the child is drawn
- Rectangle dotLineBounds = lifelineEP.getPrimaryShape().getFigureLifelineDotLineFigure().getBounds();
-
- // if ExecutionSpecification is resize outside of the lifeline bounds
- if(newBounds.y <= dotLineBounds.y || newBounds.x < dotLineBounds.x || newBounds.x > dotLineBounds.right()) {
- return null;
- }
-
- List<ShapeNodeEditPart> toCheckExecutionSpecificationList = lifelineEP.getChildShapeNodeEditPart();
- toCheckExecutionSpecificationList.removeAll(notToCheckExecutionSpecificationList);
-
- if(isMove) {
- ShapeNodeEditPart parent = getParent(lifelineEP, newBounds, toCheckExecutionSpecificationList);
-
- if(useFixedXPos) {
- newBounds.x = oldBounds.x;
- } else if(parent == null) {
- // No mother, center position
- int width = newBounds.width > 0 ? newBounds.width : EXECUTION_INIT_WIDTH;
- newBounds.x = dotLineBounds.x + dotLineBounds.width / 2 - width / 2;
- } else {
- Rectangle parentBounds = parent.getFigure().getBounds();
- int width = parentBounds.width > 0 ? parentBounds.width : EXECUTION_INIT_WIDTH;
- newBounds.x = parentBounds.x + width / 2 + 1;
- }
- } else {
- ShapeNodeEditPart oldParent = getParent(lifelineEP, oldBounds, toCheckExecutionSpecificationList);
- // forbid resize if the new bounds exceed Y-wise the bounds of a non-parent ES
- for(ShapeNodeEditPart esPart : toCheckExecutionSpecificationList) {
- Rectangle esBounds = esPart.getFigure().getBounds();
- int esYBottom = esBounds.y + esBounds.height;
- if(esPart != oldParent) {
- if(((oldBounds.y + oldBounds.height) <= esBounds.y && (newBounds.y + newBounds.height) >= esBounds.y) || (oldBounds.y >= esYBottom && newBounds.y <= esYBottom)) {
- return null;
- }
- }
- }
- }
-
- // Change to relative bounds of the LifelineEP
- newBounds.x -= dotLineBounds.x;
- newBounds.y -= dotLineBounds.y;
-
- return newBounds;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
- // This policy is hosted in a LifelineEditPart
- LifelineEditPart lifelineEP = (LifelineEditPart)getHost();
- Command command = getResizeOrMoveChildrenCommand(lifelineEP, request, false, true, false);
-
- if(command == null) {
- command = super.getResizeChildrenCommand(request);
- }
- return command;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- // This policy is hosted in a LifelineEditPart
- LifelineEditPart lifelineEP = (LifelineEditPart)getHost();
- Command command = getResizeOrMoveChildrenCommand(lifelineEP, (ChangeBoundsRequest)request, true, true, false);
-
- if(command == null) {
- command = super.getMoveChildrenCommand(request);
- }
- return command;
- }
-
- @SuppressWarnings("unchecked")
- public static Command getResizeOrMoveChildrenCommand(LifelineEditPart lifelineEP, ChangeBoundsRequest request, boolean isMove, boolean updateEnclosingInteraction, boolean useFixedXPos) {
- List<EditPart> editParts = request.getEditParts();
-
- if(editParts != null) {
- CompoundCommand compoundCmd = new CompoundCommand();
- compoundCmd.setLabel("Move or resize");
- compoundCmd.setDebugLabel("Debug: Move or resize of an ExecutionSpecification");
-
- for(EditPart ep : editParts) {
-
- if(ep instanceof ActionExecutionSpecificationEditPart || ep instanceof BehaviorExecutionSpecificationEditPart) {
-
- // an execution specification have been moved or resized
- ShapeNodeEditPart executionSpecificationEP = (ShapeNodeEditPart)ep;
-
- // Check if height is within the limits of the figure
- Dimension newSizeDelta = adaptSizeDeltaToMaxHeight(executionSpecificationEP.getFigure(), request.getSizeDelta());
-
- // Current bounds of the ExecutionSpecification
- Rectangle oldBounds = executionSpecificationEP.getFigure().getBounds().getCopy();
-
- Rectangle newBounds = oldBounds.getCopy();
-
- // According to the parameters, the new bounds would be the following
- newBounds.x += request.getMoveDelta().x;
- newBounds.y += request.getMoveDelta().y;
- newBounds.height += newSizeDelta.height;
-
- // Not to check list
- List<ShapeNodeEditPart> notToCheckExecutionSpecificationList = new BasicEList<ShapeNodeEditPart>();
- // Affixed ExecutionSpecification List
- notToCheckExecutionSpecificationList.addAll(getAffixedExecutionSpecificationEditParts(executionSpecificationEP));
- // Add also current ExecutionSpecification EditPart
- notToCheckExecutionSpecificationList.add(executionSpecificationEP);
-
- // find parent bar
- List<ShapeNodeEditPart> executionSpecificationList = lifelineEP.getChildShapeNodeEditPart();
- executionSpecificationList.remove(executionSpecificationEP);
- ShapeNodeEditPart parentBar = getParent(lifelineEP, newBounds, executionSpecificationList);
-
- // change bounds to relative
- newBounds = getExecutionSpecificationNewBounds(isMove, lifelineEP, oldBounds, newBounds, notToCheckExecutionSpecificationList, useFixedXPos);
- if(newBounds == null) {
- return UnexecutableCommand.INSTANCE;
- }
-
- if(parentBar != null) {
- compoundCmd.add(resizeParentExecutionSpecification(lifelineEP, parentBar, newBounds.getCopy(), executionSpecificationList));
- }
-
- // Create and add the command to the compound command
- SetBoundsCommand setBoundsCmd = new SetBoundsCommand(executionSpecificationEP.getEditingDomain(), "Resize of a ExecutionSpecification", executionSpecificationEP, newBounds);
- compoundCmd.add(new ICommandProxy(setBoundsCmd));
-
- Rectangle realMoveDelta = getRealMoveDelta(getRelativeBounds(executionSpecificationEP.getFigure()), newBounds);
-
- if(isMove) {
- // Move also children
- compoundCmd.add(createMovingAffixedExecutionSpecificationCommand(executionSpecificationEP, realMoveDelta, newBounds));
-
- compoundCmd.add(createZOrderCommand(lifelineEP, executionSpecificationEP, newBounds, notToCheckExecutionSpecificationList));
- }
-
- // Move also linked Time elements
- compoundCmd = OccurrenceSpecificationMoveHelper.completeMoveExecutionSpecificationCommand(compoundCmd, executionSpecificationEP, newBounds, request);
-
- IFigure parentFigure = executionSpecificationEP.getFigure().getParent();
- parentFigure.translateToAbsolute(newBounds);
- // translateToAbsolute only does half of the work, I don't know why
- newBounds.translate(parentFigure.getBounds().getLocation());
-
- if(updateEnclosingInteraction) {
- // update the enclosing interaction of a moved execution specification
- compoundCmd.add(SequenceUtil.createUpdateEnclosingInteractionCommand(executionSpecificationEP, request.getMoveDelta(), newSizeDelta));
- }
-
- // keep absolute position of anchors
- compoundCmd.add(new ICommandProxy(new LifelineEditPart.PreserveAnchorsPositionCommandEx(executionSpecificationEP, new Dimension(realMoveDelta.width, realMoveDelta.height), PreserveAnchorsPositionCommand.PRESERVE_Y, executionSpecificationEP.getFigure(), request.getResizeDirection())));
- }
-
- if(ep instanceof CombinedFragment2EditPart) {
- CombinedFragment2EditPart cf2EP = (CombinedFragment2EditPart)ep;
- IFigure cf2Figure = cf2EP.getFigure();
- Rectangle bounds = cf2Figure.getBounds().getCopy();
- cf2Figure.getParent().translateToAbsolute(bounds);
-
- Dimension sizeDelta = request.getSizeDelta();
- if(sizeDelta != null) {
- if(sizeDelta.width != 0) {
- return UnexecutableCommand.INSTANCE;
- }
- bounds.resize(sizeDelta);
- }
- Point moveDelta = request.getMoveDelta();
- if(moveDelta != null) {
- bounds.translate(moveDelta);
- }
-
- // Create and add the set bounds command to the compound command
- SetBoundsCommand setBoundsCmd = new SetBoundsCommand(cf2EP.getEditingDomain(), "Resize of a CoRegion", cf2EP, getNewBoundsForCoRegion(lifelineEP, bounds));
- compoundCmd.add(new ICommandProxy(setBoundsCmd));
- }
- }
-
- if(!compoundCmd.isEmpty()) {
- return compoundCmd;
- }
- }
-
- return null;
- }
-
- /**
- * Command for change ZOrder of ExecutionSpecification ordered from parent to children.
- *
- * @param lifelineEP
- * the lifeline ep
- * @param executionSpecificationEP
- * the execution specification ep
- * @param newBounds
- * the new bounds
- * @param notToCheckExecutionSpecificationList
- * the not to check bes list
- *
- * @return the command
- */
- protected final static Command createZOrderCommand(LifelineEditPart lifelineEP, ShapeNodeEditPart executionSpecificationEP, Rectangle newBounds, List<ShapeNodeEditPart> notToCheckExecutionSpecificationList) {
- List<ShapeNodeEditPart> toCheckExecutionSpecificationList = lifelineEP.getChildShapeNodeEditPart();
- toCheckExecutionSpecificationList.removeAll(notToCheckExecutionSpecificationList);
- CompoundCommand cmd = new CompoundCommand();
- for(ShapeNodeEditPart externalExecutionSpecificationEP : toCheckExecutionSpecificationList) {
- Rectangle externalExecutionSpecificationBounds = getRelativeBounds(externalExecutionSpecificationEP.getFigure());
- // Check if there is any contact
- if(externalExecutionSpecificationBounds.touches(newBounds)) {
- View containerView = ViewUtil.getContainerView(executionSpecificationEP.getPrimaryView());
- if(containerView != null) {
- int i = 0;
- int parentIndex = -1;
- int childIndex = -1;
- for(Object child : containerView.getChildren()) {
- if(child == externalExecutionSpecificationEP.getPrimaryView()) {
- parentIndex = i;
- } else if(child == executionSpecificationEP.getPrimaryView()) {
- childIndex = i;
- }
- if(parentIndex != -1 && childIndex != -1) {
- if(childIndex > parentIndex) {
- cmd.add(new ICommandProxy(new CustomZOrderCommand(executionSpecificationEP.getEditingDomain(), executionSpecificationEP.getPrimaryView(), parentIndex)));
- cmd.add(new ICommandProxy(new CustomZOrderCommand(externalExecutionSpecificationEP.getEditingDomain(), externalExecutionSpecificationEP.getPrimaryView(), childIndex)));
- } else {
- break;
- }
- }
- i++;
- }
- }
- }
- }
-
- if(!cmd.isEmpty()) {
- return cmd;
- }
- return null;
- }
-
- /**
- * Useful operation to know where the figure of a ExecutionSpecification EditPart should be
- * positioned within a Lifeline EditPart. The notToCheckList is needed to avoid checking those
- * ExecutionSpecification EditParts. The returned bounds are relative to the Lifeline figure so
- * they can be used, directly, within a SetBoundsCommand.
- *
- * @param lifelineDotLineFigure
- * TODO
- * @param newBounds
- * The new initial bounds
- * @param executionSpecifactionEditPart
- * TODO
- * @param notToCheckExecutionSpecificationList
- * The ExecutionSpecification EditPart's List that won't be checked
- *
- * @return The new bounds of the executionSpecificationEP figure
- */
-
-
- /**
- * Get the (futur) parent of a ExecutionSpecification
- *
- * @param lifelinePart
- *
- * @param childBounds
- * the child bounds
- * @param toCheckExecutionSpecificationList
- * List of EditPart to check
- * @return The parent
- */
- public final static ShapeNodeEditPart getParent(LifelineEditPart lifelinePart, Rectangle childBounds, List<ShapeNodeEditPart> toCheckExecutionSpecificationList) {
- ShapeNodeEditPart parent = null;
- // Loop through the ExecutionSpecification list and try to find the most to the right
- // ExecutionSpecification within the executionSpecificationEP Y-axis bounds
- Rectangle externalBounds = childBounds.getCopy();
- for(ShapeNodeEditPart externalExecutionSpecificationEP : toCheckExecutionSpecificationList) {
- Rectangle externalExecutionSpecificationBounds = externalExecutionSpecificationEP.getFigure().getBounds();
- externalBounds.x = externalExecutionSpecificationBounds.x;
- externalBounds.width = externalExecutionSpecificationBounds.width;
- if(externalExecutionSpecificationBounds.touches(externalBounds) && externalExecutionSpecificationBounds.x <= childBounds.x) {
- if(parent == null || externalExecutionSpecificationBounds.x > parent.getFigure().getBounds().x) {
- parent = externalExecutionSpecificationEP;
- }
- }
- }
- return parent;
- }
-
- /**
- * Used to modify the sizeDelta if the given value is higher/lower than the highest/lowest
- * allowed values of the figure.
- *
- * @param figure
- * the figure
- * @param sizeDelta
- * the size delta
- *
- * @return a corrected sizeDelta
- */
- public final static Dimension adaptSizeDeltaToMaxHeight(IFigure figure, Dimension sizeDelta) {
- Dimension newSizeDelta = new Dimension(sizeDelta);
-
- int figureHeight = figure.getBounds().height;
- int maximunFigureHeight = figure.getMaximumSize().height;
- int minimunFigureHeight = figure.getMinimumSize().height;
-
- int height = figureHeight + newSizeDelta.height;
- if(height > maximunFigureHeight) {
- newSizeDelta.height = maximunFigureHeight - figureHeight;
- } else if(height < minimunFigureHeight) {
- newSizeDelta.height = minimunFigureHeight - figureHeight;
- }
-
- return newSizeDelta;
- }
-
- /**
- * Returns all the ExecutionSpecification EditParts that are affixed to the right side of the
- * given ExecutionSpecification EditPart. Not only the ones directly affixed to the
- * executionSpecificationEP are returned, but the ones that are indirectly affixed as well (this
- * is done recursively)
- *
- * @param executionSpecificationEP
- * the execution specification ep
- *
- * @return the list of affixed ExecutionSpecification. If there is no affixed
- * ExecutionSpecification, then an empty list will be returned
- */
- public final static List<ShapeNodeEditPart> getAffixedExecutionSpecificationEditParts(ShapeNodeEditPart executionSpecificationEP) {
- List<ShapeNodeEditPart> notToCheckExecutionSpecificationList = new ArrayList<ShapeNodeEditPart>();
- return getAffixedExecutionSpecificationEditParts(executionSpecificationEP, notToCheckExecutionSpecificationList);
-
- }
-
- /**
- * Operation used by the above operation. It's main goal is to obtain, recursively, all the
- * affixed ExecutionSpecification. In order to do so, it is needed a ExecutionSpecification
- * EditPart and the notToCheckList.
- *
- * @param executionSpecificationEP
- * the execution specification ep
- * @param notToCheckExecutionSpecificationList
- * the not to check ExecutionSpecification list
- *
- * @return the list of affixed ExecutionSpecification. If there is no affixed
- * ExecutionSpecification, then an empty list will be returned
- */
- protected final static List<ShapeNodeEditPart> getAffixedExecutionSpecificationEditParts(ShapeNodeEditPart executionSpecificationEP, List<ShapeNodeEditPart> notToCheckExecutionSpecificationList) {
- // Add itself to the notToCheck list
- List<ShapeNodeEditPart> newNotToCheckExecutionSpecificationList = new ArrayList<ShapeNodeEditPart>(notToCheckExecutionSpecificationList);
- newNotToCheckExecutionSpecificationList.add(executionSpecificationEP);
-
- // LifelineEditPart where the ExecutionSpecification EditPart is contained
- LifelineEditPart lifelineEP = (LifelineEditPart)executionSpecificationEP.getParent();
-
- // ExecutionSpecification EditParts list
- List<ShapeNodeEditPart> executionSpecificationList = lifelineEP.getChildShapeNodeEditPart();
- executionSpecificationList.remove(newNotToCheckExecutionSpecificationList);
-
- // List to store the Affixed ExecutionSpecification
- List<ShapeNodeEditPart> affixedExecutionSpecificationList = new ArrayList<ShapeNodeEditPart>();
-
- // Loop ExecutionSpecificationough the ExecutionSpecification list
- for(ShapeNodeEditPart childExecutionSpecificationEP : executionSpecificationList) {
- if(isAffixedToRight(executionSpecificationEP.getFigure().getBounds(), childExecutionSpecificationEP.getFigure().getBounds())) {
- affixedExecutionSpecificationList.add(childExecutionSpecificationEP);
- // Add also it's affixed ExecutionSpecification
- affixedExecutionSpecificationList.addAll(getAffixedExecutionSpecificationEditParts(childExecutionSpecificationEP, newNotToCheckExecutionSpecificationList));
- }
- }
-
- // To the ExecutionSpecification list
- return affixedExecutionSpecificationList;
- }
-
- /**
- * Checks whether the right EditPart is affixed to the left EditPart. In order to do so, the
- * operation checks if the right figure is really on the right and, if so, it just returns true
- * if figures touch each other.
- *
- * @param leftFigure
- * The left rectangle
- * @param rightFigure
- * The right rectangle
- *
- * @return true if the rectangles of both figures touch and the right figure is really on the
- * right. False otherwise
- */
- public final static boolean isAffixedToRight(Rectangle leftFigure, Rectangle rightFigure) {
- return leftFigure.touches(rightFigure) && leftFigure.x < rightFigure.x;
- }
-
- /**
- * If a ExecutionSpecification EditPart is going to be moved according to a moveDelta, this
- * operation returns a compoundCommand that also moves the affixed ExecutionSpecification
- * according to that delta.
- *
- * @param executionSpecificationEP
- * The ExecutionSpecification EditPart that is going to be moved
- * @param moveDelta
- * The moveDelta of the previous EditPart
- * @param newBounds
- * the new bounds
- *
- * @return the compound command
- */
- protected final static CompoundCommand createMovingAffixedExecutionSpecificationCommand(ShapeNodeEditPart executionSpecificationEP, Rectangle moveDelta, Rectangle newBounds) {
- if(moveDelta.y != 0 || moveDelta.height != 0) {
- CompoundCommand compoundCmd = new CompoundCommand();
- for(ShapeNodeEditPart childExecutionSpecificationEP : getAffixedExecutionSpecificationEditParts(executionSpecificationEP)) {
- // Get Relative Bounds
- Rectangle childBounds = getRelativeBounds(childExecutionSpecificationEP.getFigure());
- // Apply delta
- childBounds.y += moveDelta.y;
- childBounds.x += moveDelta.x;
-
- // Create the child's SetBoundsCommand
- SetBoundsCommand childSetBoundsCmd = new SetBoundsCommand(executionSpecificationEP.getEditingDomain(), "Movement of affixed ExecutionSpecification", childExecutionSpecificationEP, childBounds);
- compoundCmd.add(new ICommandProxy(childSetBoundsCmd));
-
-
- IFigure parentFigure = childExecutionSpecificationEP.getFigure().getParent();
- parentFigure.translateToAbsolute(newBounds);
- // translateToAbsolute only does half of the work, I don't know why
- newBounds.translate(parentFigure.getBounds().getLocation());
-
- // change the enclosing interaction of the moved affixed child if necessary
- compoundCmd.add(SequenceUtil.createUpdateEnclosingInteractionCommand(childExecutionSpecificationEP, moveDelta.getLocation(), moveDelta.getSize()));
-
- // Move it's children as well
- if(!getAffixedExecutionSpecificationEditParts(childExecutionSpecificationEP).isEmpty()) {
- compoundCmd.add(createMovingAffixedExecutionSpecificationCommand(childExecutionSpecificationEP, moveDelta, childBounds));
- }
- }
- if(!compoundCmd.isEmpty()) {
- return compoundCmd;
- }
- }
- return null;
- }
-
-
-
- /**
- * Given an AbstractGraphialEditPart and the new relative bounds that the EditPart will have, it
- * returns the real delta applied to the movement.
- *
- * @param oldRelativeBounds
- * The old position of the mentioned EditPart
- * @param newRelativeBounds
- * The new position of the mentioned EditPart
- *
- * @return The real MoveDelta applied
- */
- public final static Rectangle getRealMoveDelta(Rectangle oldRelativeBounds, Rectangle newRelativeBounds) {
- Rectangle realMoveDelta = new Rectangle();
- realMoveDelta.x = newRelativeBounds.x - oldRelativeBounds.x;
- realMoveDelta.y = newRelativeBounds.y - oldRelativeBounds.y;
- realMoveDelta.height = newRelativeBounds.height - oldRelativeBounds.height;
- realMoveDelta.width = newRelativeBounds.width - oldRelativeBounds.width;
- return realMoveDelta;
- }
-
- /**
- * It returns the relative bounds of an Figure.
- *
- * @param figure
- * The Figure
- *
- * @return The relative bounds regarding it's parent figure
- */
- public final static Rectangle getRelativeBounds(IFigure figure) {
- Rectangle relBounds = figure.getBounds().getCopy();
- Rectangle parentRectangle = figure.getParent().getBounds();
- relBounds.x -= parentRectangle.x;
- relBounds.y -= parentRectangle.y;
- return relBounds;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionEditPolicy.java
deleted file mode 100644
index 4f9a23d7ce0..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionEditPolicy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.ConnectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDeleteHelper;
-
-/**
- * This edit policy also deletes time/duration edit parts which are linked with the deleted edit part.
- */
-public class MessageConnectionEditPolicy extends ConnectionEditPolicy {
-
- @Override
- protected Command createDeleteSemanticCommand(GroupRequest deleteRequest) {
- CompoundCommand deleteSemanticsCommand = new CompoundCommand();
- Command deleteSemanticCommand = super.createDeleteSemanticCommand(deleteRequest);
- deleteSemanticsCommand.add(deleteSemanticCommand);
-
- return LifelineMessageCreateHelper.restoreLifelineOnMessageDelete(deleteSemanticsCommand, getHost());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Command createDeleteViewCommand(GroupRequest deleteRequest) {
- CompoundCommand deleteViewsCommand = new CompoundCommand();
- Command deleteViewCommand = super.createDeleteViewCommand(deleteRequest);
- deleteViewsCommand.add(deleteViewCommand);
- if(getHost() instanceof ConnectionNodeEditPart) {
- TransactionalEditingDomain editingDomain = ((ConnectionNodeEditPart)getHost()).getEditingDomain();
- SequenceDeleteHelper.completeDeleteMessageViewCommand(deleteViewsCommand, editingDomain, getHost());
- }
-
- return LifelineMessageCreateHelper.restoreLifelineOnMessageDelete(deleteViewsCommand, getHost());
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
deleted file mode 100644
index a2e57f864b0..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.AbstractRouter;
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.ConnectionRouter;
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.requests.BendpointRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConnectionBendpointEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.util.SelectInDiagramHelper;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
-import org.eclipse.gmf.runtime.gef.ui.internal.editpolicies.LineMode;
-import org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers.MessageRouter.RouterKind;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart.MessageCreate;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationMoveHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-/**
- * This bendpoint edit policy is used to allow drag of horizontal messages and forbid drag otherwise.
- *
- * @author mvelten
- *
- */
-@SuppressWarnings("restriction")
-public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditPolicy {
-
- public MessageConnectionLineSegEditPolicy() {
- super(LineMode.ORTHOGONAL_FREE);
- }
-
- @Override
- public Command getCommand(Request request) {
- RouterKind kind = RouterKind.getKind(getConnection(), getConnection().getPoints());
- if(kind == RouterKind.SELF || kind == RouterKind.HORIZONTAL || getConnection() instanceof MessageCreate){
- return super.getCommand(request);
- }
- return null;
- }
-
- /**
- * Move the anchors along with the line and update bendpoints accordingly.
- */
- @Override
- protected Command getBendpointsChangedCommand(BendpointRequest request) {
- if((getHost().getViewer() instanceof ScrollingGraphicalViewer) && (getHost().getViewer().getControl() instanceof FigureCanvas)) {
- SelectInDiagramHelper.exposeLocation((FigureCanvas)getHost().getViewer().getControl(), request.getLocation().getCopy());
- }
-
- if(getHost() instanceof ConnectionNodeEditPart) {
- ConnectionNodeEditPart connectionPart = (ConnectionNodeEditPart)getHost();
- EObject message = connectionPart.resolveSemanticElement();
- if(message instanceof Message) {
- MessageEnd send = ((Message)message).getSendEvent();
- MessageEnd rcv = ((Message)message).getReceiveEvent();
- EditPart srcPart = connectionPart.getSource();
- LifelineEditPart srcLifelinePart = SequenceUtil.getParentLifelinePart(srcPart);
- EditPart tgtPart = connectionPart.getTarget();
- LifelineEditPart tgtLifelinePart = SequenceUtil.getParentLifelinePart(tgtPart);
- if(send instanceof OccurrenceSpecification && rcv instanceof OccurrenceSpecification && srcLifelinePart != null && tgtLifelinePart != null) {
- RouterKind kind = RouterKind.getKind(getConnection(), getConnection().getPoints());
- if(getHost() instanceof Message2EditPart && kind == RouterKind.SELF){
- return getSelfLinkMoveCommand(request, connectionPart, send, rcv, srcLifelinePart);
- }else if(getHost() instanceof Message4EditPart){
- IFigure fig = tgtLifelinePart.getPrimaryShape().getFigureLifelineNameContainerFigure();
- Rectangle bounds = fig.getBounds().getCopy();
- fig.translateToAbsolute(bounds);
-
- PointList points = getConnection().getPoints();
- Point sourceRefPoint = points.getFirstPoint().getCopy();;
- getConnection().translateToAbsolute(sourceRefPoint);
-
- int dy = sourceRefPoint.y - bounds.getCenter().y;
- Point location = tgtLifelinePart.getFigure().getBounds().getLocation().getCopy().translate(0, dy);
- Command moveCmd = new ICommandProxy(new SetBoundsCommand(tgtLifelinePart.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(tgtLifelinePart.getNotationView()), location));
-
- // Take care of the order of commands, to make sure target is always bellow the source.
- if(dy < 0){ // move up
- return LifelineMessageCreateHelper.moveCascadeLifeline(tgtLifelinePart,moveCmd,dy);
- }else{ // move down
- Command cmd = LifelineMessageCreateHelper.moveCascadeLifeline(tgtLifelinePart,null,dy);
- cmd = cmd == null? moveCmd: cmd.chain(moveCmd);
- return cmd;
- }
- }else{
- int y = request.getLocation().y;
- List<EditPart> empty = Collections.emptyList();
- Command srcCmd = OccurrenceSpecificationMoveHelper.getMoveOccurrenceSpecificationsCommand((OccurrenceSpecification)send, null, y, -1, srcLifelinePart, empty);
- Command tgtCmd = OccurrenceSpecificationMoveHelper.getMoveOccurrenceSpecificationsCommand((OccurrenceSpecification)rcv, null, y, -1, tgtLifelinePart, empty);
- CompoundCommand compoudCmd = new CompoundCommand(Messages.MoveMessageCommand_Label);
- /*
- * Take care of the order of commands, to make sure target is always bellow the source.
- * Otherwise, moving the target above the source would cause order conflict with existing CF.
- */
- Point oldLocation = SequenceUtil.getAbsoluteEdgeExtremity(connectionPart, true);
- if(oldLocation != null) {
- int oldY = oldLocation.y;
- if(oldY < y) {
- compoudCmd.add(tgtCmd);
- compoudCmd.add(srcCmd);
- } else {
- compoudCmd.add(srcCmd);
- compoudCmd.add(tgtCmd);
- }
- return compoudCmd;
- }
- }
- }
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- protected Command getSelfLinkMoveCommand(BendpointRequest request, ConnectionNodeEditPart connectionPart, MessageEnd send, MessageEnd rcv, LifelineEditPart srcLifelinePart) {
- CompoundCommand compoudCmd = new CompoundCommand(Messages.MoveMessageCommand_Label);
- PointList points = getConnection().getPoints();
- Point sourceRefPoint = points.getFirstPoint();;
- Point targetRefPoint = points.getLastPoint();;
- getConnection().translateToAbsolute(sourceRefPoint);
- getConnection().translateToAbsolute(targetRefPoint);
-
- Point oldSourcePoint = SequenceUtil.findLocationOfEvent(srcLifelinePart, (OccurrenceSpecification)send);
- int dy = sourceRefPoint.y - oldSourcePoint.y;
- int dx = request.getLocation().x > sourceRefPoint.x ? 3 : -3;
-
- // check bounds
- NodeFigure fig = srcLifelinePart.getPrimaryShape().getFigureLifelineDotLineFigure().getDashLineRectangle();
- Rectangle bounds = fig.getBounds().getCopy();
- fig.translateToAbsolute(bounds);
-
- bounds.expand(6, 0);
- if(!bounds.contains(sourceRefPoint) || !bounds.contains(targetRefPoint)){
- return UnexecutableCommand.INSTANCE; // cannot move outside lifeline part
- }
- sourceRefPoint = sourceRefPoint.translate(dx, 0);
- targetRefPoint = targetRefPoint.translate(dx, 0);
- Command srcCmd = getReconnectCommand(connectionPart, srcLifelinePart, sourceRefPoint, RequestConstants.REQ_RECONNECT_SOURCE);
- Command tgtCmd = getReconnectCommand(connectionPart, srcLifelinePart, targetRefPoint, RequestConstants.REQ_RECONNECT_TARGET);
-
- if(dy < 0){ // move up
- compoudCmd.add(srcCmd);
- compoudCmd.add(tgtCmd);
- }else{ // move down
- compoudCmd.add(tgtCmd);
- compoudCmd.add(srcCmd);
- }
- return compoudCmd;
- }
-
- protected Command getReconnectCommand(ConnectionNodeEditPart connectionPart, LifelineEditPart targetPart, Point location, String requestType) {
- // Create and set the properties of the request
- ReconnectRequest reconnReq = new ReconnectRequest();
- reconnReq.setConnectionEditPart(connectionPart);
- reconnReq.setLocation(location);
- reconnReq.setTargetEditPart(targetPart);
- reconnReq.setType(requestType);
- // add a parameter to bypass the move impact to avoid infinite loop
- reconnReq.getExtendedData().put(SequenceRequestConstant.DO_NOT_MOVE_EDIT_PARTS, true);
- Command cmd = targetPart.getCommand(reconnReq);
- return cmd;
- }
-
- /**
- * don't show feedback if the drag is forbidden (message not horizontal).
- */
- @Override
- public void showSourceFeedback(Request request) {
- if(request instanceof BendpointRequest) {
- RouterKind kind = RouterKind.getKind(getConnection(), getConnection().getPoints());
- if(kind == RouterKind.SELF || kind == RouterKind.HORIZONTAL || getConnection() instanceof MessageCreate){
- super.showSourceFeedback(request);
- }
- }
- }
-
- private ConnectionRouter router;
-
- static class DummyRouter extends AbstractRouter {
-
- public void route(Connection conn) {
- }
- }
-
- protected void showMoveLineSegFeedback(BendpointRequest request) {
- RouterKind kind = RouterKind.getKind(getConnection(), getConnection().getPoints());
- if(getHost() instanceof Message2EditPart && kind == RouterKind.SELF ){
- if(router == null){
- router = getConnection().getConnectionRouter();
- getConnection().setConnectionRouter( new DummyRouter());
- }
- PointList linkPoints = getConnection().getPoints().getCopy();
-
- Point ptLoc = new Point(request.getLocation());
- getConnection().translateToRelative(ptLoc);
- int dy = 0;
- if(request.getIndex() == 0)
- dy = ptLoc.y - linkPoints.getFirstPoint().y;
- else if(request.getIndex() == 2)
- dy = ptLoc.y - linkPoints.getLastPoint().y;
-
- // move each point on link
- int size = linkPoints.size();
- for(int i = 0; i < size; i ++){
- Point p = linkPoints.getPoint(i).translate(0, dy);
- linkPoints.setPoint(p, i);
- }
-
- // link should not exceed lifeline bounds
- if(checkBounds(linkPoints)){
- getConnection().setPoints(linkPoints);
- getConnection().getLayoutManager().layout(getConnection());
- }
- return;
- }
- if(getHost() instanceof Message4EditPart){
- if(router == null){
- router = getConnection().getConnectionRouter();
- getConnection().setConnectionRouter( new DummyRouter());
- }
- PointList linkPoints = getConnection().getPoints().getCopy();
-
- Point ptLoc = new Point(request.getLocation());
- getConnection().translateToRelative(ptLoc);
- int dy = ptLoc.y - linkPoints.getFirstPoint().y;
- int size = linkPoints.size();
- for(int i = 0; i < size; i ++){
- Point p = linkPoints.getPoint(i).translate(0, dy);
- linkPoints.setPoint(p, i);
- }
- if(checkBounds(linkPoints)){
- getConnection().setPoints(linkPoints);
- getConnection().getLayoutManager().layout(getConnection());
- }
- return;
- }
- super.showMoveLineSegFeedback(request);
- }
-
- protected boolean checkBounds(PointList linkPoints) {
- EditPart sourcePart = ((ConnectionNodeEditPart)getHost()).getSource();
- if(sourcePart instanceof LifelineEditPart){
- LifelineEditPart lep = (LifelineEditPart)sourcePart;
- NodeFigure fig = lep.getPrimaryShape().getFigureLifelineDotLineFigure().getDashLineRectangle();
- Rectangle bounds = fig.getBounds().getCopy();
- fig.translateToAbsolute(bounds);
-
- Rectangle conBounds = linkPoints.getBounds();
- getConnection().translateToAbsolute(conBounds);
- // check top and bottom y limit
- if(conBounds.y <= bounds.y || conBounds.getBottom().y >= bounds.getBottom().y)
- return false;
- }
- return true;
- }
-
- @Override
- protected void eraseConnectionFeedback(BendpointRequest request, boolean removeFeedbackFigure) {
- getConnection().setVisible(true);
- super.eraseConnectionFeedback(request, removeFeedbackFigure);
-
- if(router != null)
- getConnection().setConnectionRouter(router);
- router = null;
- }
-
-// private boolean isHorizontal() {
-// Connection connection = getConnection();
-// RouterKind kind = RouterKind.getKind(connection, connection.getPoints());
-//
-// if(kind.equals(RouterKind.HORIZONTAL)) {
-// return true;
-// }
-// return false;
-// }
-//
-// final private static char TERMINAL_START_CHAR = '(';
-//
-// final private static char TERMINAL_DELIMITER_CHAR = ',';
-//
-// final private static char TERMINAL_END_CHAR = ')';
-//
-// private static String composeTerminalString(PrecisionPoint p) {
-// StringBuffer s = new StringBuffer(24);
-// s.append(TERMINAL_START_CHAR); // 1 char
-// s.append(p.preciseX); // 10 chars
-// s.append(TERMINAL_DELIMITER_CHAR); // 1 char
-// s.append(p.preciseY); // 10 chars
-// s.append(TERMINAL_END_CHAR); // 1 char
-// return s.toString(); // 24 chars max (+1 for safety, i.e. for string termination)
-// }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
deleted file mode 100644
index 9c68048832a..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
+++ /dev/null
@@ -1,1000 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.sequence.preferences.MessagePreferencePage;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
-import org.eclipse.papyrus.uml.tools.utils.MultiplicityElementUtil;
-import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
-import org.eclipse.papyrus.uml.tools.utils.ParameterUtil;
-import org.eclipse.papyrus.uml.tools.utils.PropertyUtil;
-import org.eclipse.papyrus.uml.tools.utils.TypeUtil;
-import org.eclipse.papyrus.uml.tools.utils.TypedElementUtil;
-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Signal;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-
-public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- public static interface ICustomMessageLabel{
-
- }
-
- private DefaultValueListener defaultValueListener;
-
- /**
- * Refreshes the display of the edit part
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- ConnectionEditPart lp = (ConnectionEditPart)getHost();
- List children = lp.getChildren();
- for(Object p : children)
- if(p instanceof ICustomMessageLabel){
- MessageLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart)p);
- }
- }
-
- public int getCurrentDisplayValue() {
- EAnnotation customeDisplayAnnotation = ((View)getHost().getModel()).getEAnnotation(VisualInformationPapyrusConstants.CUSTOM_APPEARENCE_ANNOTATION);
- int displayValue = getDefaultDisplayValue();
- if(customeDisplayAnnotation != null) {
- displayValue = Integer.parseInt(customeDisplayAnnotation.getDetails().get(VisualInformationPapyrusConstants.CUSTOM_APPEARANCE_MASK_VALUE));
- } else {
- // no specific information => look in preferences
- IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
- int displayValueTemp = store.getInt(MessagePreferencePage.LABEL_DISPLAY_PREFERENCE);
- if(displayValueTemp != 0) {
- displayValue = displayValueTemp;
- }
- }
- return displayValue;
- }
-
- public int getDefaultDisplayValue() {
- return MessagePreferencePage.DEFAULT_LABEL_DISPLAY;
- }
-
- public String getMaskLabel(int value) {
- return MessageLabelHelper.getInstance().getMaskLabel(value);
- }
-
- public Collection<String> getMaskLabels() {
- return MessageLabelHelper.getInstance().getMaskLabels();
- }
-
- public Map<Integer, String> getMasks() {
- return MessageLabelHelper.getInstance().getMasks();
- }
-
- public Collection<Integer> getMaskValues() {
- return MessageLabelHelper.getInstance().getMaskValues();
- }
-
- public String getPreferencePageID() {
- return "org.eclipse.papyrus.uml.diagram.sequence.preferences.MessagePreferencePage";
- }
-
- @Override
- public Message getUMLElement() {
- if(hostSemanticElement instanceof Message)
- return ((Message)hostSemanticElement);
- return null;
- }
-
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- this.defaultValueListener = new DefaultValueListener();
- Message e = getUMLElement();
- // check host semantic element is not null
- if(e == null || e.getSignature() == null) {
- return;
- }
- NamedElement sig = e.getSignature();
- if(sig instanceof Operation){
- Operation operation = (Operation)sig;
- getDiagramEventBroker().addNotificationListener(operation, this);
- // adds a listener to the element itself, and to linked elements, like Type
- for(Parameter parameter : operation.getOwnedParameters()) {
- getDiagramEventBroker().addNotificationListener(parameter, this);
- getDiagramEventBroker().addNotificationListener(parameter.getDefaultValue(), defaultValueListener);
-
- // should also add this element as a listener of parameter type
- getDiagramEventBroker().addNotificationListener(parameter.getType(), this);
- }
- }else if(sig instanceof Signal){
- Signal signal = (Signal)sig;
- getDiagramEventBroker().addNotificationListener(signal, this);
- for(Property property : signal.getOwnedAttributes()) {
- getDiagramEventBroker().addNotificationListener(property, this);
- getDiagramEventBroker().addNotificationListener(property.getDefaultValue(), defaultValueListener);
-
- // should also add this element as a listener of parameter type
- getDiagramEventBroker().addNotificationListener(property.getType(), this);
- }
- }
-
- EList<ValueSpecification> argments = e.getArguments();
- for(ValueSpecification v : argments)
- if(v instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject)v, this);
- }
- }
-
- @Override
- protected void removeAdditionalListeners() {
- super.removeAdditionalListeners();
- Message e = getUMLElement();
- // check host semantic element is not null
- if(e == null || e.getSignature() == null) {
- return;
- }
- NamedElement sig = e.getSignature();
- if(sig instanceof Operation){
- Operation operation = (Operation)sig;
- getDiagramEventBroker().removeNotificationListener(operation, this);
- for(Parameter parameter : operation.getOwnedParameters()) {
- getDiagramEventBroker().removeNotificationListener(parameter, this);
- getDiagramEventBroker().removeNotificationListener(parameter.getDefaultValue(), defaultValueListener);
-
- // remove parameter type listener
- getDiagramEventBroker().removeNotificationListener(parameter.getType(), this);
- }
- }else if(sig instanceof Signal){
- Signal signal = (Signal)sig;
- getDiagramEventBroker().removeNotificationListener(signal, this);
- for(Property property : signal.getOwnedAttributes()) {
- getDiagramEventBroker().removeNotificationListener(property, this);
- getDiagramEventBroker().removeNotificationListener(property.getDefaultValue(), defaultValueListener);
-
- // remove parameter type listener
- getDiagramEventBroker().removeNotificationListener(property.getType(), this);
- }
- }
-
- EList<ValueSpecification> argments = e.getArguments();
- for(ValueSpecification v : argments)
- if(v instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject)v, this);
- }
- }
-
- @Override
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
- final Object object = notification.getNotifier();
- Message e = getUMLElement();
- // check host semantic element is not null
- if(e == null) {
- return;
- }
- if(UMLPackage.Literals.MESSAGE__ARGUMENT.equals( notification.getFeature())){
- parameterListChange(notification);
- return;
- }else if(e.getArguments().contains(object)){
- refreshDisplay();
- return;
- }
-
- NamedElement sig = e.getSignature();
- if(sig instanceof Operation){
- Operation operation = (Operation)sig;
-
- if(object.equals(operation)) {
- notifyOperationChanged(operation, notification);
- } else if(isParameter(object, operation)) {
- notifyParameterChanged(notification);
- } else if(isParameterType(object, operation)) {
- notifyTypeChanged(notification);
- }
- }else if(sig instanceof Signal){
- Signal signal = (Signal)sig;
- if(object.equals(signal)) {
- notifySignalChanged(signal, notification);
- }else if(isProperty(object, signal)) {
- notifyPropertyChanged(notification);
- }else if(isPropertyType(object, signal)) {
- notifyTypeChanged(notification);
- }else if(object instanceof ValueSpecification){
- Element own = ((ValueSpecification)object).getOwner();
- if(isProperty(own, signal)){
- refreshDisplay(); // may be default value
- }
- }
- }
-
- if(isMaskManagedAnnotation(object) ){
- refreshDisplay();
- }else if(isRemovedMaskManagedLabelAnnotation(object, notification)) {
- refreshDisplay();
- }else if(sig == null && object instanceof Message && notification.getFeature().equals(UMLPackage.eINSTANCE.getNamedElement_Name())){
- refreshDisplay();
- }
- }
-
- class DefaultValueListener implements NotificationListener{
-
- public void notifyChanged(Notification notification) {
- refreshDisplay();
- }
- }
-
- private void notifyPropertyChanged(Notification notification) {
- switch(notification.getFeatureID(Property.class)) {
- case UMLPackage.PROPERTY__DEFAULT_VALUE: // set or unset default value
- if(notification.getOldValue() instanceof EObject)
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), defaultValueListener);
- if(notification.getNewValue() instanceof EObject)
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), defaultValueListener);
- refreshDisplay();
- break;
- case UMLPackage.PROPERTY__NAME:
- case UMLPackage.PROPERTY__IS_ORDERED:
- case UMLPackage.PROPERTY__LOWER:
- case UMLPackage.PROPERTY__UPPER:
- case UMLPackage.PROPERTY__LOWER_VALUE:
- case UMLPackage.PROPERTY__UPPER_VALUE:
- refreshDisplay();
- break;
- case UMLPackage.PROPERTY__TYPE:
- parameterListChange(notification);
-
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that a parameter of the operation has changed.
- *
- * @param parameter
- * the {@link Parameter} that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyParameterChanged(Notification notification) {
- switch(notification.getFeatureID(Parameter.class)) {
- case UMLPackage.PARAMETER__DEFAULT_VALUE:
- if(notification.getOldValue() instanceof EObject)
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), defaultValueListener);
- if(notification.getNewValue() instanceof EObject)
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), defaultValueListener);
- refreshDisplay();
- break;
- case UMLPackage.PARAMETER__NAME:
- case UMLPackage.PARAMETER__DIRECTION:
- case UMLPackage.PARAMETER__IS_STREAM:
- case UMLPackage.PARAMETER__IS_ORDERED:
- case UMLPackage.PARAMETER__LOWER:
- case UMLPackage.PARAMETER__UPPER:
- case UMLPackage.PARAMETER__LOWER_VALUE:
- case UMLPackage.PARAMETER__UPPER_VALUE:
- refreshDisplay();
- break;
- case UMLPackage.PARAMETER__TYPE:
- parameterListChange(notification);
-
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- protected void parameterListChange(Notification notification) {
- switch(notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY:
- if(notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>)notification.getNewValue();
- for(Object addedElement : addedElements) {
- if(addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject)addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY:
- if(notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>)notification.getOldValue();
- for(Object removedElement : removedElements) {
- if(removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject)removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if(notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- }
- if(notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- }
- refreshDisplay();
-
- default:
- break;
-
- }
- }
-
- /**
- * notifies that a parameter of the operation has changed.
- *
- * @param parameter
- * the {@link Parameter} that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyTypeChanged(Notification notification) {
- // should be type.class, but seems to be a bug if this is put instead.
- switch(notification.getFeatureID(notification.getNotifier().getClass())) {
- case UMLPackage.TYPE__NAME:
- case UMLPackage.TYPE__TEMPLATE_PARAMETER:
- case UMLPackage.TYPE__VISIBILITY:
- refreshDisplay();
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that the the property has changed.
- *
- * @param operation
- * the operation that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyOperationChanged(Operation operation, Notification notification) {
- switch(notification.getFeatureID(Operation.class)) {
- case UMLPackage.OPERATION__NAME:
- case UMLPackage.OPERATION__VISIBILITY:
- case UMLPackage.OPERATION__IS_UNIQUE:
- case UMLPackage.OPERATION__REDEFINED_OPERATION:
- case UMLPackage.OPERATION__IS_ORDERED:
- case UMLPackage.OPERATION__LOWER:
- case UMLPackage.OPERATION__UPPER:
- case UMLPackage.OPERATION__IS_STATIC:
- refreshDisplay();
- break;
- case UMLPackage.OPERATION__OWNED_PARAMETER:
- parameterListChange(notification);
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
-
- private void notifySignalChanged(Signal signal, Notification notification) {
- switch(notification.getFeatureID(Signal.class)) {
- case UMLPackage.SIGNAL__NAME:
- case UMLPackage.SIGNAL__VISIBILITY:
- refreshDisplay();
- break;
- case UMLPackage.SIGNAL__OWNED_ATTRIBUTE:
- parameterListChange(notification);
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * Checks if the given object is one of the parameter type of the operation
- *
- * @param object
- * the object to test
- * @param operation
- * @return <code>true</code> if the object corresponds to the type of a parameter of the
- * operation
- */
- protected boolean isParameterType(Object object, Operation operation) {
- if(!(object instanceof Type)) {
- return false;
- }
-
- for(Parameter parameter : operation.getOwnedParameters()) {
- if(object.equals(parameter.getType())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if the given object is one of the parameter of the operation
- *
- * @param object
- * the object to test
- * @param operation
- * @return <code>true</code> if the object is a parameter of the operation
- */
- protected boolean isParameter(Object object, Operation operation) {
- if(!(object instanceof Parameter)) {
- return false;
- }
-
- return operation.getOwnedParameters().contains(object);
- }
-
- private boolean isPropertyType(Object object, Signal signal) {
- if(!(object instanceof Type)) {
- return false;
- }
-
- for(Property property :signal.getOwnedAttributes()) {
- if(object.equals(property.getType())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isProperty(Object object, Signal signal) {
- if(!(object instanceof Property)) {
- return false;
- }
-
- return signal.getOwnedAttributes().contains(object);
- }
-
- static class MessageLabelHelper extends StereotypedElementLabelHelper{
- /**
- * singelton instance
- */
- private static MessageLabelHelper labelHelper;
-
- /** Map for masks */
- protected final Map<Integer, String> masks = new HashMap<Integer, String>(11);
-
- protected MessageLabelHelper() {
- // initialize the map
- masks.put(ICustomAppearence.DISP_VISIBILITY, "Visibility");
- masks.put(ICustomAppearence.DISP_NAME, "Name");
- masks.put(ICustomAppearence.DISP_PARAMETER_NAME, "Parameters Name");
- masks.put(ICustomAppearence.DISP_PARAMETER_DIRECTION, "Parameters Direction");
- masks.put(ICustomAppearence.DISP_PARAMETER_TYPE, "Parameters Type");
- masks.put(ICustomAppearence.DISP_RT_TYPE, "Return Type");
- masks.put(ICustomAppearence.DISP_PARAMETER_MULTIPLICITY, "Parameters Multiplicity");
- masks.put(ICustomAppearence.DISP_PARAMETER_DEFAULT, "Parameters Default Value");
- masks.put(ICustomAppearence.DISP_DERIVE, "Parameters Value");
- masks.put(ICustomAppearence.DISP_PARAMETER_MODIFIERS, "Parameters Modifiers");
- masks.put(ICustomAppearence.DISP_MOFIFIERS, "Modifiers");
-
- }
-
- /**
- * Returns the singleton instance of this class
- *
- * @return the singleton instance.
- */
- public static MessageLabelHelper getInstance() {
- if(labelHelper == null) {
- labelHelper = new MessageLabelHelper();
- }
- return labelHelper;
- }
-
- public Message getUMLElement(GraphicalEditPart editPart) {
- EObject e = ((View)editPart.getModel()).getElement();
- if(e instanceof Message)
- return ((Message)e);
- return null;
- }
-
- protected String elementLabel(GraphicalEditPart editPart) {
- if(editPart instanceof LabelEditPart)
- editPart = (GraphicalEditPart)editPart.getParent();
-
- int displayValue = MessagePreferencePage.DEFAULT_LABEL_DISPLAY;
-
- IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy)editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if(policy != null) {
- displayValue = policy.getCurrentDisplayValue();
- }
- Message e = getUMLElement(editPart);
- NamedElement signature = e.getSignature();
-
- if(signature instanceof Operation) {
- return OperationUtil.getCustomLabel(e, (Operation)signature, displayValue);
- }else if(signature instanceof Signal) {
- return SignalUtil.getCustomLabel(e, (Signal)signature, displayValue);
- } else if(signature != null) {
- return signature.getName();
- }
-
- return e.getName();
- }
-
- public String getMaskLabel(int value) {
- return masks.get(value);
- }
-
- public Collection<String> getMaskLabels() {
- return masks.values();
- }
-
- public Map<Integer, String> getMasks() {
- return masks;
- }
-
- public Set<Integer> getMaskValues() {
- return masks.keySet();
- }
- }
-
- static public class SignalUtil {
- private static String getCustomPropertyLabel(Message e, Property property, int style) {
- StringBuffer buffer = new StringBuffer();
- // visibility
-
- buffer.append(" ");
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(property));
- }
-
- // derived property
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
- if(property.isDerived()) {
- buffer.append("/");
- }
- }
-
- boolean showEqualMark = false;
- // name
- if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0) {
- buffer.append(" ");
- String name = trimToEmpty(property.getName());
- if(name.trim().length() > 0)
- showEqualMark = true;
- buffer.append(name);
- }
-
- if((style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0) {
- // type
- if(property.getType() != null) {
- buffer.append(": " + trimToEmpty(property.getType().getName()));
- } else {
- buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
- }
- showEqualMark = true;
- }
-
- if((style & ICustomAppearence.DISP_MULTIPLICITY) != 0) {
- // multiplicity -> do not display [1]
- String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
- buffer.append(multiplicity);
- }
-
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
- String value = getValue(e, property);
- if(value != null){
- if(showEqualMark)
- buffer.append(" = ");
- buffer.append(value);
- }
- }else if((style & ICustomAppearence.DISP_PARAMETER_DEFAULT) != 0) {
- // default value
- if(property.getDefault() != null) {
- if(showEqualMark)
- buffer.append(" = ");
- buffer.append(property.getDefault());
- }
- }
-
- if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
- boolean multiLine = ((style & ICustomAppearence.DISP_MULTI_LINE) != 0);
- // property modifiers
- String modifiers = PropertyUtil.getModifiersAsString(property, multiLine);
- if(!modifiers.equals("")) {
- if(multiLine) {
- buffer.append("\n");
- }
-
- if (!buffer.toString().endsWith(" ")){
- buffer.append(" ");
- }
-
- buffer.append(modifiers);
- }
- }
- return buffer.toString();
- }
-
- private static String getValue(Message e, Property property) {
- try {
- Signal signal = (Signal)property.getOwner();
- int index = signal.getOwnedAttributes().indexOf(property);
- EList<ValueSpecification> arguments = e.getArguments();
- if(arguments.size() > index){
- return ValueSpecificationUtil.getSpecificationValue( arguments.get(index) );
- }
- } catch (Exception e1) {
- }
- return null;
- }
-
- /**
- * return the custom label of the signal, given UML2 specification and a custom style.
- * @param e
- *
- * @param style
- * the integer representing the style of the label
- *
- * @return the string corresponding to the label of the signal
- */
- public static String getCustomLabel(Message e, Signal signal, int style) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(" "); // adds " " first for correct display considerations
-
- // visibility
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(signal));
- }
-
- // name
- if((style & ICustomAppearence.DISP_NAME) != 0) {
- buffer.append(" ");
- buffer.append(trimToEmpty(signal.getName()));
- }
-
- //
- // parameters : '(' parameter-list ')'
- buffer.append("(");
- buffer.append(getPropertiesAsString(e, signal, style));
- buffer.append(")");
-
- return buffer.toString();
- }
-
- /**
- * Returns signal properties as a string, the label is customized using a bit mask
- *
- * @return a string containing all properties separated by commas
- */
- private static String getPropertiesAsString(Message e, Signal signal, int style) {
- StringBuffer propertiesString = new StringBuffer();
- boolean firstProperty = true;
- for(Property property : signal.getOwnedAttributes()) {
- // get the label for this property
- String propertyString = getCustomPropertyLabel(e, property, style);
- if(!propertyString.trim().equals("")) {
- if(!firstProperty) {
- propertiesString.append(", ");
- }
- propertiesString.append(propertyString);
- firstProperty = false;
- }
- }
- return propertiesString.toString();
- }
- }
-
- static class OperationUtil {
- public static String getCustomLabel(Message e, int paramIndex, Parameter parameter, int style) {
- StringBuffer buffer = new StringBuffer();
- // visibility
- buffer.append(" ");
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
- }
-
- // direction property
- if((style & ICustomAppearence.DISP_PARAMETER_DIRECTION) != 0) {
- buffer.append(" ");
- buffer.append(parameter.getDirection().getLiteral());
- }
-
- boolean showEqualMark = false;
- // name
- if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0) {
- buffer.append(" ");
- String name = trimToEmpty(parameter.getName());
- if(name.trim().length() > 0)
- showEqualMark = true;
- buffer.append(name);
- }
-
- if((style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0) {
- // type
- if(parameter.getType() != null) {
- buffer.append(": " + trimToEmpty(parameter.getType().getName()));
- } else {
- buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
- }
- showEqualMark = true;
- }
-
- if((style & ICustomAppearence.DISP_PARAMETER_MULTIPLICITY) != 0) {
- // multiplicity -> do not display [1]
- String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
- buffer.append(multiplicity);
- }
-
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
- String value = getValue(e, paramIndex, parameter);
- if(value != null){
- if(showEqualMark)
- buffer.append(" = ");
- buffer.append(value);
- }
- }else if((style & ICustomAppearence.DISP_PARAMETER_DEFAULT) != 0) {
- // default value
- if(parameter.getDefault() != null) {
- if(showEqualMark)
- buffer.append(" = ");
- buffer.append(parameter.getDefault());
- }
- }
-
- if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
- boolean multiLine = ((style & ICustomAppearence.DISP_MULTI_LINE) != 0);
- // property modifiers
- String modifiers = ParameterUtil.getModifiersAsString(parameter, multiLine);
- if(!modifiers.equals("")) {
- if(multiLine) {
- buffer.append("\n");
- }
- buffer.append(modifiers);
- }
- }
- return buffer.toString();
- }
-
- private static String getValue(Message e, int paramIndex, Parameter parameter) {
- try {
- EList<ValueSpecification> arguments = e.getArguments();
- if(arguments.size() > paramIndex){
- return ValueSpecificationUtil.getSpecificationValue( arguments.get(paramIndex) );
- }
- } catch (Exception e1) {
- }
- return null;
- }
-
- public static String getCustomLabel(Message e, Operation operation, int style) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(" "); // adds " " first for correct display considerations
-
- // visibility
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(operation));
- }
-
- // name
- if((style & ICustomAppearence.DISP_NAME) != 0) {
- buffer.append(" ");
- buffer.append(trimToEmpty(operation.getName()));
- }
-
- //
- // parameters : '(' parameter-list ')'
- buffer.append("(");
- buffer.append(getParametersAsString(e, operation, style));
- buffer.append(")");
-
- // return type
- if((style & ICustomAppearence.DISP_RT_TYPE) != 0) {
- buffer.append(getReturnTypeAsString(operation, style));
- }
-
- // modifiers
- if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
- String modifiers = getModifiersAsString(operation);
- if(!modifiers.equals("")) {
- buffer.append("{");
- buffer.append(modifiers);
- buffer.append("}");
- }
- }
- return buffer.toString();
- }
-
- /**
- * Returns operation modifiers as string, separated with comma.
- *
- * @return a string containing the modifiers
- */
- private static String getModifiersAsString(Operation operation) {
- StringBuffer buffer = new StringBuffer();
- boolean needsComma = false;
-
- // Return parameter modifiers
- Parameter returnParameter = OperationUtil.getReturnParameter(operation);
- if(returnParameter != null) {
- // non unique parameter
- if(!returnParameter.isUnique()) {
- buffer.append("nonunique");
- needsComma = true;
- }
-
- // return parameter has ordered values
- if(returnParameter.isOrdered()) {
- if(needsComma) {
- buffer.append(", ");
- }
- buffer.append("ordered");
- needsComma = true;
- }
- }
-
- // is the operation a query ?
- if(operation.isQuery()) {
- if(needsComma) {
- buffer.append(", ");
- }
- buffer.append("query");
- needsComma = true;
- }
-
- // is the operation redefining another operation ?
- Iterator<Operation> it = operation.getRedefinedOperations().iterator();
- while(it.hasNext()) {
- Operation currentOperation = it.next();
- if(needsComma) {
- buffer.append(", ");
- }
- buffer.append("redefines ");
- buffer.append(currentOperation.getName());
- needsComma = true;
- }
-
- // has the operation a constraint ?
- Iterator<Constraint> it2 = operation.getOwnedRules().iterator();
- while(it2.hasNext()) {
- Constraint constraint = it2.next();
- if(needsComma) {
- buffer.append(", ");
- }
- if(constraint.getSpecification() != null) {
- buffer.append(constraint.getSpecification().stringValue());
- }
- needsComma = true;
- }
-
- return buffer.toString();
- }
-
- /**
- * Returns return parameter label as a string, string parametrized with a style mask.
- *
- * @param style
- * the mask that indicates which element to display
- * @return a string containing the return parameter type
- */
- private static String getReturnTypeAsString(Operation operation, int style) {
- boolean displayType = ((style & ICustomAppearence.DISP_RT_TYPE) != 0);
- boolean displayMultiplicity = ((style & ICustomAppearence.DISP_RT_MULTIPLICITY) != 0);
- StringBuffer label = new StringBuffer("");
-
- // Retrieve the return parameter (assume to be unique if defined)
- Parameter returnParameter = getReturnParameter(operation);
- // Create the string for the return type
- if(returnParameter == null) {
- // no-operation: label = ""
-
- } else if(!displayType && !displayMultiplicity) {
- // no-operation: label = ""
-
- } else {
- label.append(": ");
- if(displayType) {
- label.append(TypedElementUtil.getTypeAsString(returnParameter));
- }
-
- if(displayMultiplicity) {
- label.append(MultiplicityElementUtil.getMultiplicityAsString(returnParameter));
- }
- }
- return label.toString();
- }
-
- /**
- * Gives the return parameter for this operation, or <code>null</code> if none exists.
- *
- * @return the return parameter of the operation or <code>null</code>
- */
- private static Parameter getReturnParameter(Operation operation) {
- // Retrieve the return parameter (assume to be unique if defined)
- Parameter returnParameter = null;
-
- Iterator<Parameter> it = operation.getOwnedParameters().iterator();
- while((returnParameter == null) && (it.hasNext())) {
- Parameter parameter = it.next();
- if(parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
- returnParameter = parameter;
- }
- }
- return returnParameter;
- }
-
- /**
- * Returns operation parameters as a string, the label is customized using a bit mask
- * @param e
- *
- * @return a string containing all parameters separated by commas
- */
- private static String getParametersAsString(Message e, Operation operation, int style) {
- StringBuffer paramString = new StringBuffer();
- Iterator<Parameter> paramIterator = operation.getOwnedParameters().iterator();
- boolean firstParameter = true;
- int paramIndex = 0;
- while(paramIterator.hasNext()) {
- Parameter parameter = paramIterator.next();
- // Do not include return parameters
- if(!parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
- // get the label for this parameter
- String parameterString = getCustomLabel(e, paramIndex, parameter, style);
- paramIndex ++;
- if (!parameterString.trim().equals("")) {
- if (!firstParameter) {
- paramString.append(", ");
- }
- paramString.append(parameterString);
- firstParameter = false;
- }
- }
- }
- return paramString.toString();
- }
- }
-
- static String trimToEmpty(String str){
- return str == null? "" : str;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MoveableNonResizableLabelEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MoveableNonResizableLabelEditPolicy.java
deleted file mode 100644
index 70dd691b1e6..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MoveableNonResizableLabelEditPolicy.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Polyline;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.PrecisionRectangle;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editparts.AbstractConnectionEditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx;
-import org.eclipse.gmf.runtime.diagram.ui.internal.figures.LabelHelper;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
-import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * This class offers the same features as {@link NonResizableLabelEditPolicy}, except that move is privileged instead of drag and drop.
- * It is useful for edit parts on messages.
- */
-public class MoveableNonResizableLabelEditPolicy extends NonResizableEditPolicyEx {
-
- @Override
- protected List<?> createSelectionHandles() {
- MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost());
- mh.setBorder(null);
- mh.setDragTracker(createSelectionHandleDragTracker());
- return Collections.singletonList(mh);
- }
-
- private Polyline tether = null;
-
- protected void eraseChangeBoundsFeedback(ChangeBoundsRequest request) {
- super.eraseChangeBoundsFeedback(request);
- if(tether != null)
- removeFeedback(tether);
- tether = null;
- }
-
- protected IFigure createDragSourceFeedbackFigure() {
- IFigure feedback = super.createDragSourceFeedbackFigure();
- tether = new Polyline();
- tether.setLineStyle(Graphics.LINE_DASHDOT);
- tether.setForegroundColor(((IGraphicalEditPart)getHost()).getFigure().getForegroundColor());
- addFeedback(tether);
- return feedback;
- }
-
- /**
- * Calculates a point located at the middel of the parent connection
- *
- * @return the point
- */
- private Point getReferencePoint() {
- if(getHost().getParent() instanceof AbstractConnectionEditPart) {
- PointList ptList = ((Connection)((ConnectionEditPart)getHost().getParent()).getFigure()).getPoints();
- Point refPoint = PointListUtilities.calculatePointRelativeToLine(ptList, 0, 50, true);
- return refPoint;
- } else if(getHost().getParent() instanceof GraphicalEditPart) {
- return ((AbstractGraphicalEditPart)getHost().getParent()).getFigure().getBounds().getCenter();
- }
- return null;
- }
-
- protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
- super.showChangeBoundsFeedback(request);
-
- IFigure p = getDragSourceFeedbackFigure();
- Rectangle r = p.getBounds();
- Point refPoint = getReferencePoint();
-
- // translate the feedback figure
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
- p.translateToRelative(rect);
- p.setBounds(rect);
-
- Rectangle centerMain = null;
- // TODO: remove this hack. We should be using the reference point for
- // the teher end, however,
- // the reference point is causing miscaculation when positioning. This
- // has to be redone in version 2.
- if(((IGraphicalEditPart)getHost().getParent()).getFigure() instanceof Connection) {
- centerMain = new Rectangle(refPoint.x, refPoint.y, 0, 0);
- getHostFigure().translateToAbsolute(centerMain);
- p.translateToRelative(centerMain);
- } else {
- centerMain = ((IGraphicalEditPart)getHost().getParent()).getFigure().getBounds().getCopy();
- centerMain.translate(centerMain.width / 2, centerMain.height / 2);
- getHostFigure().translateToAbsolute(centerMain);
- p.translateToRelative(centerMain);
- }
-
- PrecisionRectangle ref = new PrecisionRectangle(centerMain);
-
- Point midTop = new Point(r.x + r.width / 2, r.y);
- Point midBottom = new Point(r.x + r.width / 2, r.y + r.height);
- Point midLeft = new Point(r.x, r.y + r.height / 2);
- Point midRight = new Point(r.x + r.width, r.y + r.height / 2);
-
- Point startPoint = midTop;
-
- int x = r.x + r.width / 2 - refPoint.x;
- int y = r.y + r.height / 2 - refPoint.y;
-
- if(y > 0 && y > x && y > -x)
- startPoint = midTop;
- else if(y < 0 && y < x && y < -x)
- startPoint = midBottom;
- else if(x < 0 && y > x && y < -x)
- startPoint = midRight;
- else
- startPoint = midLeft;
-
- tether.setStart(startPoint);
- tether.setEnd(ref.getLocation());
- }
-
- protected Command getMoveCommand(ChangeBoundsRequest request) {
- GraphicalEditPart editPart = (GraphicalEditPart)getHost();
- Point refPoint = getReferencePoint();
-
- // translate the feedback figure
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
- getHostFigure().translateToRelative(rect);
-
- Point normalPoint = LabelHelper.offsetFromRelativeCoordinate(getHostFigure(), rect, refPoint);
-
- ICommand moveCommand = new SetBoundsCommand(editPart.getEditingDomain(), DiagramUIMessages.MoveLabelCommand_Label_Location, new EObjectAdapter((View)editPart.getModel()), normalPoint);
- return new ICommandProxy(moveCommand);
- }
-
- /**
- * Overridden to use a customized drag tracker for the handles. The <code>isMove()</code> method of the drag tracker needs to be overridden
- * as the parent of the label and connection will not be the same as the
- * target editpart, instead it returns true always since labels can only be
- * moved and not resized.
- *
- * @return a drag tracker
- */
- protected DragTracker createSelectionHandleDragTracker() {
- return new DragEditPartsTrackerEx(getHost()) {
-
- protected boolean isMove() {
- return true;
- }
- };
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java
deleted file mode 100644
index f5cd849fe7b..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java
+++ /dev/null
@@ -1,728 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.FeedbackHelper;
-import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gef.requests.DropRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.IdentityAnchor;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
-import org.eclipse.gmf.runtime.notation.impl.ConnectorImpl;
-import org.eclipse.papyrus.uml.diagram.sequence.ObservationLinkMetamodelType;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.DurationObservation;
-import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.MessageSort;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.TimeObservation;
-
-/**
- * This policy is to process observation link creating, reconnecting
- *
- */
-public class ObservationLinkPolicy extends GraphicalNodeEditPolicy {
- private final EditPart editPart;
-
- public ObservationLinkPolicy(EditPart editPart) {
- this.editPart = editPart;
- }
-
- public Command getCommand(Request request) {
- if(request instanceof CreateUnspecifiedTypeConnectionRequest){
- if(((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes().contains(ObservationLinkMetamodelType.getInstance())){
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType()))
- return getConnectionCreateCommand((CreateConnectionRequest) request);
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType()))
- return getConnectionCompleteCommand((CreateConnectionRequest) request);
- }
- return null;
- }
- if(request instanceof CreateConnectionRequest){
- CreateConnectionRequest cc = (CreateConnectionRequest) request;
- if(cc.getNewObject()!=null){
- if(cc.getNewObject() instanceof ObservationLink){
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType()))
- return getConnectionCreateCommand((CreateConnectionRequest) request);
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType()))
- return getConnectionCompleteCommand((CreateConnectionRequest) request);
- }
- }
- return null;
- }
- if(request instanceof ReconnectRequest){
- ReconnectRequest rr = (ReconnectRequest) request;
- if(rr.getConnectionEditPart() instanceof ObservationLinkEditPart){
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType()))
- return getReconnectSourceCommand((ReconnectRequest) request);
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType()))
- return getReconnectTargetCommand((ReconnectRequest) request);
- }
-
- }
-
- return null;
- }
-
- public EditPart getTargetEditPart(Request request) {
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType())){
- if (request instanceof CreateConnectionRequest) {
- if (((CreateConnectionRequest) request).getSourceEditPart() instanceof TimeObservationLabelEditPart) {
- if (getHost() instanceof AbstractMessageEditPart) {
- return null;
- }
- }
- }
- if(SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType())){
- if (request instanceof ReconnectRequest) {
- if (((ReconnectRequest) request).getConnectionEditPart().getSource() instanceof TimeObservationLabelEditPart) {
- if (getHost() instanceof AbstractMessageEditPart) {
- return null;
- }
- }
- }
- }
- return getHost();
- }
- return null;
- }
-
- @Override
- protected Command getConnectionCreateCommand(
- CreateConnectionRequest request) {
- EditPart host = getHost();
- if(host instanceof TimeObservationLabelEditPart){
- TimeObservationLabelEditPart timeObservationLabelEditPart = (TimeObservationLabelEditPart)host;
- if(timeObservationLabelEditPart.getSourceConnections().size()>0){
- return null;
- }
- }else if(host instanceof DurationObservationEditPart){
- DurationObservationEditPart durationObservationEditPart = (DurationObservationEditPart)host;
- if(durationObservationEditPart.getSourceConnections().size()>0){
- return null;
- }
- }else{
- return null;
- }
-
- CompositeCommand cc = new CompositeCommand(
- DiagramUIMessages.Commands_CreateCommand_Connection_Label);
-
- CreateObservationLinkCommand cmd = new CreateObservationLinkCommand(((GraphicalEditPart) editPart).getEditingDomain(), "Create connection command", null);
-
- cmd.setSourceEditPart(host);
- cmd.setRequest(request);
-
- cc.compose(cmd);
- Command c = new ICommandProxy(cc);
- request.setStartCommand(c);
- return c;
- }
-
- @Override
- protected Command getConnectionCompleteCommand(
- final CreateConnectionRequest request) {
- EditPart sourceEditPart = request.getSourceEditPart();
-
- if((sourceEditPart instanceof TimeObservationLabelEditPart)&&!(getHost() instanceof LifelineEditPart)){
- return null;
- }else if(sourceEditPart instanceof DurationObservationEditPart&&!(getHost() instanceof AbstractMessageEditPart)){
- return null;
- }
-
- ICommandProxy proxy = (ICommandProxy) request
- .getStartCommand();
- if (proxy == null) {
- return null;
- }
-
- CompositeCommand result = new CompositeCommand("Add observation link command");
-
- if(sourceEditPart instanceof TimeObservationLabelEditPart){
- result.add(new UpdateTimeObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request,getHost()));
- }else if(sourceEditPart instanceof DurationObservationEditPart){
- result.add(new UpdateDurationObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request,getHost()));
- }
-
- //1:
- CompositeCommand cc = (CompositeCommand) proxy.getICommand();
- Iterator commandItr = cc.iterator();
- CreateObservationLinkCommand createConnectorViewCommand = (CreateObservationLinkCommand) commandItr.next();
- createConnectorViewCommand.setSourceEditPart(request.getSourceEditPart());
- createConnectorViewCommand.setTargetEditPart(request.getTargetEditPart());
-
- result.add(cc);
- return new ICommandProxy(result);
- }
-
- @Override
- protected Command getReconnectSourceCommand(final ReconnectRequest request) {
- Command reconnectSourceCommand = super
- .getReconnectSourceCommand(request);
- ICommandProxy proxy = (ICommandProxy) reconnectSourceCommand;
- CompositeCommand cc = (CompositeCommand) proxy.getICommand();
-
- // update semantic model
- if(request.getConnectionEditPart().getSource() instanceof TimeObservationLabelEditPart && getHost() instanceof TimeObservationLabelEditPart){
- TimeObservationLabelEditPart timeObservationLabelEditPart = (TimeObservationLabelEditPart)getHost();
- if(timeObservationLabelEditPart.getSourceConnections().size()>0){
- return null;
- }
- cc.add(new UpdateTimeObservationLinkSourceElementCommand(
- ((IGraphicalEditPart) getHost()).getEditingDomain(),
- "Update semantic model", null, request, getHost()));
- }else if(request.getConnectionEditPart().getSource() instanceof DurationObservationEditPart && getHost() instanceof DurationObservationEditPart){
- DurationObservationEditPart durationObservationEditPart = (DurationObservationEditPart)getHost();
- if(durationObservationEditPart.getSourceConnections().size()>0){
- return null;
- }
- cc.add(new UpdateDurationObservationLinkSourceElementCommand(
- ((IGraphicalEditPart) getHost()).getEditingDomain(),
- "Update semantic model", null, request, getHost()));
- }
-
- return reconnectSourceCommand;
- }
-
- @Override
- protected Command getReconnectTargetCommand(final ReconnectRequest request) {
- Command reconnectTargetCommand = super
- .getReconnectTargetCommand(request);
- ICommandProxy proxy = (ICommandProxy) reconnectTargetCommand;
- CompositeCommand cc = (CompositeCommand) proxy.getICommand();
-
- // update semantic model
- if(request.getConnectionEditPart().getSource() instanceof TimeObservationLabelEditPart){
- cc.add(new UpdateTimeObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request,getHost()));
- }else if(request.getConnectionEditPart().getSource() instanceof DurationObservationEditPart){
- cc.add(new UpdateDurationObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request,getHost()));
- }
-
- return proxy;
- }
-
- @Override
- public void showSourceFeedback(Request request) {
- if ((SequenceUtil.OBSERVATION_LINK_REQUEST_END).equals(request.getType()))
- showCreationFeedback((CreateConnectionRequest) request);
- }
-
- protected FeedbackHelper getFeedbackHelper(CreateConnectionRequest request) {
- if (feedbackHelper == null) {
- feedbackHelper = new FeedbackHelper();
- Point p = request.getLocation();
- connectionFeedback = createDummyConnection(request);
- connectionFeedback
- .setConnectionRouter(getDummyConnectionRouter(request));
- connectionFeedback
- .setSourceAnchor(getSourceConnectionAnchor(request));
- connectionFeedback.setForegroundColor(ColorConstants.black);
- feedbackHelper.setConnection(connectionFeedback);
- addFeedback(connectionFeedback);
- feedbackHelper.update(null, p);
- }
- return feedbackHelper;
- }
-
- @Override
- public void showTargetFeedback(Request request) {
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType()))
- showTargetConnectionFeedback((DropRequest) request);
- }
-
- @Override
- public void eraseSourceFeedback(Request request) {
- if ( SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType()))
- eraseCreationFeedback((CreateConnectionRequest) request);
- }
-
- @Override
- public void eraseTargetFeedback(Request request) {
- if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType())
- || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType()))
- eraseTargetConnectionFeedback((DropRequest) request);
- }
-
- private class UpdateDurationObservationLinkSourceElementCommand extends
- AbstractTransactionalCommand {
- private final ReconnectRequest request;
- private EditPart hostPart;
- private DurationObservationEditPart sourceTolEP;
-
- List<OccurrenceSpecification> occList = Collections.emptyList();
-
- public UpdateDurationObservationLinkSourceElementCommand(
- TransactionalEditingDomain domain, String label,
- List affectedFiles, ReconnectRequest request, EditPart hostPart) {
- super(domain, label, affectedFiles);
- this.request = request;
- sourceTolEP = (DurationObservationEditPart) request
- .getConnectionEditPart().getSource();
- this.hostPart = hostPart;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- if (sourceTolEP == hostPart) {
- return CommandResult.newCancelledCommandResult();
- }
-
- View sourceView = (View) sourceTolEP.getModel();
- DurationObservation sourceDurationObservation = (DurationObservation) sourceView
- .getElement();
-
- DurationObservationEditPart targetDoEP = (DurationObservationEditPart) hostPart;
- View targetView = (View) targetDoEP.getModel();
- DurationObservation targetDurationObservation = (DurationObservation) targetView
- .getElement();
- targetDurationObservation.getEvents().addAll(
- sourceDurationObservation.getEvents());
-
- sourceDurationObservation.getEvents().clear();
- return CommandResult.newOKCommandResult();
- }
-
- @Override
- public boolean canExecute() {
- if (hostPart instanceof DurationObservationEditPart) {
- return true;
- }
- return false;
- }
-
- }
-
- public class UpdateDurationObservationLinkTargetElementCommand extends
- AbstractTransactionalCommand {
- private final Request request;
- private EditPart hostPart;
-
- public UpdateDurationObservationLinkTargetElementCommand(
- TransactionalEditingDomain domain, String label,
- List affectedFiles, Request request, EditPart hostPart) {
- super(domain, label, affectedFiles);
- this.request = request;
- this.hostPart = hostPart;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- DurationObservationEditPart doEP = null;
- if (request instanceof CreateConnectionRequest) {
- doEP = (DurationObservationEditPart) (((CreateConnectionRequest) request).getSourceEditPart());
- } else if (request instanceof ReconnectRequest) {
- doEP = (DurationObservationEditPart) (((ReconnectRequest) request).getConnectionEditPart().getSource());
- }
- View view = (View) doEP.getModel();
- DurationObservation durationObservation = (DurationObservation) view.getElement();
- EList<NamedElement> events = durationObservation.getEvents();
- // if is reconnect operation, first remove orginal message event of DurationObservation
- if (request instanceof ReconnectRequest) {
- events.clear();
- }
- Map<String, Object> extendedData = request.getExtendedData();
- // assign the occurrence specification
- Object paramOcc1 = extendedData
- .get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION);
- Object paramOcc2 = extendedData
- .get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2);
- if (paramOcc1 != null && paramOcc2 != null) {
- events.add((OccurrenceSpecification) paramOcc1);
- events.add((OccurrenceSpecification) paramOcc2);
- }
- return CommandResult.newOKCommandResult();
- }
-
- @Override
- public boolean canExecute() {
- if (hostPart instanceof ConnectionNodeEditPart) {
- Map<String, Object> extendedData = request.getExtendedData();
-
- if (hostPart instanceof AbstractMessageEditPart) {
- AbstractMessageEditPart messageEP = (AbstractMessageEditPart) hostPart;
- View view = (View) messageEP.getModel();
- Message message = (Message) view.getElement();
-
- if (message.getSendEvent() != null)
- extendedData
- .put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION,
- message.getSendEvent());
- if (message.getReceiveEvent() != null)
- extendedData
- .put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2,
- message.getReceiveEvent());
- }
-
- if (extendedData
- .containsKey(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION)
- && extendedData
- .containsKey(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2)) {
- return true;
- }
- }
- return false;
- }
-
- }
-
- private class UpdateTimeObservationLinkSourceElementCommand extends
- AbstractTransactionalCommand {
- private final ReconnectRequest request;
- private EditPart hostPart;
- private TimeObservationLabelEditPart sourceTolEP;
-
- List<OccurrenceSpecification> occList = Collections.emptyList();
-
- public UpdateTimeObservationLinkSourceElementCommand(
- TransactionalEditingDomain domain, String label,
- List affectedFiles, ReconnectRequest request, EditPart hostPart) {
- super(domain, label, affectedFiles);
- this.request = request;
- sourceTolEP = (TimeObservationLabelEditPart) request
- .getConnectionEditPart().getSource();
- this.hostPart = hostPart;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- if (sourceTolEP == hostPart) {
- return CommandResult.newCancelledCommandResult();
- }
-
- View sourceView = (View) sourceTolEP.getModel();
- TimeObservation sourceTimeObservation = (TimeObservation) sourceView
- .getElement();
-
- TimeObservationLabelEditPart targetTolEP = (TimeObservationLabelEditPart) hostPart;
- View targetView = (View) targetTolEP.getModel();
- TimeObservation targetTimeObservation = (TimeObservation) targetView
- .getElement();
- targetTimeObservation.setEvent(sourceTimeObservation.getEvent());
-
- sourceTimeObservation.setEvent(null);
- return CommandResult.newOKCommandResult();
- }
-
- @Override
- public boolean canExecute() {
- if (hostPart instanceof TimeObservationLabelEditPart) {
- return true;
- }
- return false;
- }
- }
-
- private class UpdateTimeObservationLinkTargetElementCommand extends
- AbstractTransactionalCommand {
- private final Request request;
- private EditPart hostPart;
-
- List<OccurrenceSpecification> occList = Collections.emptyList();
-
- public UpdateTimeObservationLinkTargetElementCommand(
- TransactionalEditingDomain domain, String label,
- List affectedFiles, Request request, EditPart hostPart) {
- super(domain, label, affectedFiles);
- this.request = request;
- this.hostPart = hostPart;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- TimeObservationLabelEditPart tolEP = null;
- if (request instanceof CreateConnectionRequest) {
- tolEP = (TimeObservationLabelEditPart) (((CreateConnectionRequest) request)
- .getSourceEditPart());
- } else if (request instanceof ReconnectRequest) {
- tolEP = (TimeObservationLabelEditPart) (((ReconnectRequest) request)
- .getConnectionEditPart().getSource());
- }
- View view = (View) tolEP.getModel();
- TimeObservation timeObservation = (TimeObservation) view
- .getElement();
-
- // assign the occurrence specification
- if (!occList.isEmpty()) {
- for (OccurrenceSpecification occurrence : occList) {
- if (occurrence instanceof MessageOccurrenceSpecification) {
- Message mess = ((MessageOccurrenceSpecification) occurrence)
- .getMessage();
- if (mess.getReceiveEvent().equals(occurrence)
- && MessageSort.SYNCH_CALL_LITERAL.equals(mess
- .getMessageSort())) {
- // filter receive event, we prefer the corresponding
- // start event at the same location
- continue;
- }
- }
- // otherwise, first occ is just fine
- timeObservation.setEvent(occurrence);
- break;
- }
- }
-
- // reset request vertical location
- if (timeObservation.getEvent() instanceof MessageOccurrenceSpecification) {
- Point messageOccurrenceLoc = SequenceUtil
- .findLocationOfMessageOccurrence(
- (GraphicalEditPart) hostPart,
- (MessageOccurrenceSpecification) timeObservation
- .getEvent());
- setRequestLocation(messageOccurrenceLoc);
- } else if (timeObservation.getEvent() instanceof ExecutionOccurrenceSpecification) {
- Point executionOccurrenceLoc = SequenceUtil
- .findLocationOfExecutionOccurrence(
- (GraphicalEditPart) hostPart,
- (ExecutionOccurrenceSpecification) timeObservation
- .getEvent());
- setRequestLocation(executionOccurrenceLoc);
- }
-
- return CommandResult.newOKCommandResult();
- }
-
- private void setRequestLocation(Point occurrenceLoc) {
- if(occurrenceLoc == null)
- return;
-
- if (request instanceof CreateConnectionRequest) {
- CreateConnectionRequest req = (CreateConnectionRequest) request;
- req.setLocation(new Point(req.getLocation().x,
- occurrenceLoc.y));
- } else if (request instanceof ReconnectRequest) {
- ReconnectRequest req = (ReconnectRequest) request;
- req.setLocation(new Point(req.getLocation().x,
- occurrenceLoc.y));
- }
- }
-
- @Override
- public boolean canExecute() {
- if (hostPart instanceof LifelineEditPart) {
- Point location = null;
- if (request instanceof CreateConnectionRequest) {
- location = ((CreateConnectionRequest) request)
- .getLocation();
- } else if (request instanceof ReconnectRequest) {
- location = ((ReconnectRequest) request).getLocation();
- }
-
- Entry<Point, List<OccurrenceSpecification>> eventAndLocation = SequenceUtil
- .findNearestEvent(location, (LifelineEditPart) hostPart);
- // find an event near enough to create the
- // constraint or observation
- occList = Collections.emptyList();
- if (eventAndLocation != null) {
- occList = eventAndLocation.getValue();
- }
- if (!occList.isEmpty()) {
- for (OccurrenceSpecification occurrence : occList) {
- if (occurrence instanceof MessageOccurrenceSpecification) {
- Message mess = ((MessageOccurrenceSpecification) occurrence)
- .getMessage();
- if (mess.getReceiveEvent().equals(occurrence)
- && MessageSort.SYNCH_CALL_LITERAL
- .equals(mess.getMessageSort())) {
- // filter receive event, we prefer the
- // corresponding
- // start event at the same location
- continue;
- }
- }
- return true;
- }
- }
- }
- return false;
- }
- }
-
- private class CreateObservationLinkCommand extends AbstractTransactionalCommand {
-
- private EditPart sourceEditPart;
- private EditPart targetEditPart;
-
- private CreateConnectionRequest request;
- private ObservationLink c;
- private String newSourceTerminal;
-
- public CreateObservationLinkCommand(TransactionalEditingDomain domain,
- String label, List affectedFiles) {
- super(domain, label, affectedFiles);
- }
-
- public void setSourceEditPart(EditPart sourceEditPart) {
- this.sourceEditPart = sourceEditPart;
- }
-
- public void setTargetEditPart(EditPart targetEditPart) {
- this.targetEditPart = targetEditPart;
- }
-
- public void setRequest(CreateConnectionRequest request) {
- this.request = request;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- c = new ObservationLink();
- c.setType(SequenceUtil.OBSERVATION_LINK_TYPE);
- c.setElement(null);
-
- View newSourceView = (View) sourceEditPart.getModel();
- c.setSource(newSourceView);
-
- ViewUtil.insertChildView(newSourceView.getDiagram(), c, -1, true);
-
- INodeEditPart ce = (INodeEditPart) sourceEditPart;
- ConnectionAnchor sourceAnchor = ce.getSourceConnectionAnchor(request);
- newSourceTerminal = ce.mapConnectionAnchorToTerminal(sourceAnchor);
- if (newSourceTerminal != null) {
- if (newSourceTerminal.length() == 0)
- c.setSourceAnchor(null);
- else {
- IdentityAnchor a = (IdentityAnchor) c.getSourceAnchor();
- if (a == null)
- a = NotationFactory.eINSTANCE.createIdentityAnchor();
- a.setId(newSourceTerminal);
- c.setSourceAnchor(a);
- }
- }
-
- initCompleteCommand();
-
- return CommandResult.newOKCommandResult();
- }
-
- private void initCompleteCommand() {
- // reset the target edit-part for the request
- if (targetEditPart != null) {
- View newTargetView = ((IGraphicalEditPart) targetEditPart)
- .getNotationView();
- c.setTarget(newTargetView);
- // 3:
- INodeEditPart ce = (INodeEditPart) targetEditPart;
-
- ConnectionAnchor targetAnchor = null;
- if(ce instanceof LifelineEditPart){
- LifelineEditPart lifelinePart = (LifelineEditPart)ce;
- targetAnchor = lifelinePart.getNodeFigure().getTargetConnectionAnchorAt(request.getLocation());
- }else{
- targetAnchor = ce
- .getTargetConnectionAnchor(request);
- }
-
- String newTargetTerminal = ce
- .mapConnectionAnchorToTerminal(targetAnchor);
- if (newTargetTerminal != null) {
- if (newTargetTerminal.length() == 0)
- c.setTargetAnchor(null);
- else {
- IdentityAnchor a = (IdentityAnchor) c.getTargetAnchor();
- if (a == null)
- a = NotationFactory.eINSTANCE.createIdentityAnchor();
- a.setId(newTargetTerminal);
- c.setTargetAnchor(a);
- }
- }
- // 4:
- INodeEditPart sourceEditPart = (INodeEditPart) request
- .getSourceEditPart();
- ConnectionAnchor sourceAnchor = sourceEditPart
- .mapTerminalToConnectionAnchor(newSourceTerminal);
- PointList pointList = new PointList();
- if (request.getLocation() == null) {
- pointList.addPoint(sourceAnchor.getLocation(targetAnchor
- .getReferencePoint()));
- pointList.addPoint(targetAnchor.getLocation(sourceAnchor
- .getReferencePoint()));
- } else {
- pointList.addPoint(sourceAnchor.getLocation(request
- .getLocation()));
- pointList.addPoint(targetAnchor.getLocation(request
- .getLocation()));
- }
- List newBendpoints = new ArrayList();
- int numOfPoints = pointList.size();
- for (short i = 0; i < numOfPoints; i++) {
- Dimension s = pointList.getPoint(i).getDifference(
- sourceAnchor.getReferencePoint());
- Dimension t = pointList.getPoint(i).getDifference(
- targetAnchor.getReferencePoint());
- newBendpoints.add(new RelativeBendpoint(s.width, s.height,
- t.width, t.height));
- }
-
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE
- .createRelativeBendpoints();
- bendpoints.setPoints(newBendpoints);
- c.setBendpoints(bendpoints);
-
- }
-
- }
-
- }
-
- public static class ObservationLink extends ConnectorImpl {
- public ObservationLink() {
- super();
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java
deleted file mode 100644
index 981e3c2e9ce..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.OrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
-
-/**
- * this policy is used to suppress orphan node view in GMF view the policy to remove orphan
- * connection is more complex. It is dependent of the diagram. see remove OrphanConnectionView
- * policy
- *
- */
-public class RemoveOrphanViewPolicy extends OrphanViewPolicy {
-
- public int[] notOrphanNode = { LifelineNameEditPart.VISUAL_ID };
-
- public RemoveOrphanViewPolicy() {
- super();
- init(notOrphanNode);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java
deleted file mode 100644
index c0a156820f7..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Polyline;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.requests.CreateConnectionRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest.ConnectionViewAndElementDescriptor;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragment2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message3EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message5EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message6EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message7EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-
-/**
- * A specific policy to handle the message :
- * - Message cannot be uphill.
- * - Message Occurrence Specification which are created along the message may have a different container than the message.
- * - Message feedback on creation is always drawn in black (to avoid invisible feedback)
- *
- */
-@SuppressWarnings({ "restriction", "unchecked", "rawtypes" })
-public class SequenceGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
-
- /** A static margin to allow drawing of straight message */
- private static final int MARGIN = 2;
-
- /**
- * Gets the command to start the creation of a new connection and relationship. This will update the request appropriately. Also completes the
- * request with nearby occurrence specification information.
- *
- * @param request
- * creation request
- * @return Command
- */
- @Override
- protected Command getConnectionAndRelationshipCreateCommand(CreateConnectionViewAndElementRequest request) {
- Map<String, Object> extendedData = request.getExtendedData();
-
- // record the nearest event if necessary
- String requestHint = request.getConnectionViewAndElementDescriptor().getSemanticHint();
- if(isCreatedNearOccurrenceSpecification(requestHint)) {
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(getHost());
- if(lifelinePart != null) {
- Entry<Point, List<OccurrenceSpecification>> eventAndLocation = SequenceUtil.findNearestEvent(request.getLocation(), lifelinePart);
- // find an event near enough to create the constraint or observation
- List<OccurrenceSpecification> events = Collections.emptyList();
- Point location = null;
- if(eventAndLocation != null) {
- location = eventAndLocation.getKey();
- events = eventAndLocation.getValue();
- }
- extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, events);
- extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION, location);
- if(location != null) {
- request.setLocation(location);
- }
- }
- }
- return super.getConnectionAndRelationshipCreateCommand(request);
- }
-
- /**
- * Gets the command to complete the creation of a new connection and relationship. Also completes the request with nearby occurrence specification
- * information.
- *
- * @param request
- * the creation request
- * @return Command
- */
- @Override
- protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) {
- Map<String, Object> extendedData = request.getExtendedData();
-
- // record the nearest event if necessary
- String requestHint = request.getConnectionViewAndElementDescriptor().getSemanticHint();
- if(isCreatedNearOccurrenceSpecification(requestHint)) {
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(getHost());
- if(lifelinePart != null) {
- Entry<Point, List<OccurrenceSpecification>> eventAndLocation = SequenceUtil.findNearestEvent(request.getLocation(), lifelinePart);
- // find an event near enough to create the constraint or observation
- List<OccurrenceSpecification> events = Collections.emptyList();
- Point location = null;
- if(eventAndLocation != null) {
- location = eventAndLocation.getKey();
- events = eventAndLocation.getValue();
- }
- extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2, events);
- extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2, location);
- if(location != null) {
- request.setLocation(location);
- }
- }
- }
- return super.getConnectionAndRelationshipCompleteCommand(request);
- }
-
- /**
- * Return true if creation must be performed to or from an occurrence specification
- *
- * @param requestHint
- * the hint of object to create
- * @return true if creation to or from an occurrence specification
- */
- private boolean isCreatedNearOccurrenceSpecification(String requestHint) {
- String generalOrderingHint = ((IHintedType)UMLElementTypes.GeneralOrdering_4012).getSemanticHint();
- return generalOrderingHint.equals(requestHint);
- }
-
- /**
- * Return true if a message is being created
- *
- * @param requestHint
- * the hint of object to create
- * @return true if creation of a message
- */
- private boolean isMessageHint(String requestHint) {
- List<String> messageHints = new ArrayList<String>(7);
- String messageHint = ((IHintedType)UMLElementTypes.Message_4003).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4004).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4005).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4006).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4007).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4008).getSemanticHint();
- messageHints.add(messageHint);
- messageHint = ((IHintedType)UMLElementTypes.Message_4009).getSemanticHint();
- messageHints.add(messageHint);
- return messageHints.contains(requestHint);
- }
-
- @Override
- protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
- // move source point to the bottom if it is contained in LifelineNameContainerFigure
- EditPart targetEditPart = request.getTargetEditPart();
- if (targetEditPart != null
- && targetEditPart instanceof LifelineEditPart) {
- LifelineEditPart target = (LifelineEditPart) targetEditPart;
- if (target.getPrimaryShape() != null) {
- Rectangle sourceBounds = target.getPrimaryShape()
- .getFigureLifelineNameContainerFigure().getBounds()
- .getCopy();
- Point sourcePointCopy = request.getLocation().getCopy();
- target.getFigure().translateToRelative(sourcePointCopy);
- if (sourcePointCopy.y() < sourceBounds.getBottom().y()) {
- target.getFigure().translateToAbsolute(sourceBounds);
- request.getLocation()
- .setY(sourceBounds.getBottom().y()+1);
- }
- }
-
- }
-
- request.getExtendedData().put(
- SequenceRequestConstant.SOURCE_LOCATION_DATA,
- request.getLocation());
-
- return super.getConnectionCreateCommand(request);
- }
-
- /**
- * Overrides to disable uphill message
- */
- @Override
- protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
- Command command = super.getConnectionCompleteCommand(request);
- if(command == null) {
- return UnexecutableCommand.INSTANCE;
- }
- // disable the following code if we are not creating a message.
- String requestHint = null;
- if(request instanceof CreateConnectionViewRequest) {
- requestHint = ((CreateConnectionViewRequest)request).getConnectionViewDescriptor().getSemanticHint();
- if(!isMessageHint(requestHint)) {
- return command;
- }
- }
- // ICommandProxy proxy = (ICommandProxy)request.getStartCommand();
- // CompositeCommand cc = (CompositeCommand)proxy.getICommand();
- // Iterator<?> commandItr = cc.iterator();
- // while(commandItr.hasNext()) {
- // Object obj = commandItr.next();
- // if(obj instanceof SetConnectionBendpointsCommand) {
- // SetConnectionBendpointsCommand sbbCommand = (SetConnectionBendpointsCommand)obj;
- //final PointList pointList = sbbCommand.getNewPointList();
-
- Point sourcePoint = (Point)request.getExtendedData().get(SequenceRequestConstant.SOURCE_LOCATION_DATA);
- Point targetPoint = request.getLocation();
-
- // prevent uphill message (leave margin for horizontal messages)
- boolean messageCreate =((IHintedType)UMLElementTypes.Message_4006).getSemanticHint().equals(requestHint);
- if(sourcePoint == null || sourcePoint.y >= targetPoint.y + MARGIN) {
- if(!messageCreate && !isLostFoundMessage(requestHint))
- return UnexecutableCommand.INSTANCE;
- }
- // prevent uphill message (for self recursive message)
- if(request.getSourceEditPart().equals(request.getTargetEditPart()) && sourcePoint.y >= targetPoint.y) {
- return UnexecutableCommand.INSTANCE;
- }
- // prevent uphill message (for reply message)
- if(request instanceof CreateConnectionViewAndElementRequest) {
- ConnectionViewAndElementDescriptor desc = ((CreateConnectionViewAndElementRequest)request).getConnectionViewAndElementDescriptor();
- String replyHint = ((IHintedType)UMLElementTypes.Message_4005).getSemanticHint();
- if(replyHint.equals(desc.getSemanticHint()) && request.getSourceEditPart() instanceof IGraphicalEditPart) {
- Rectangle srcBounds = SequenceUtil.getAbsoluteBounds((IGraphicalEditPart)request.getSourceEditPart());
- int bottom = srcBounds.getBottom().y;
- if(bottom >= targetPoint.y + MARGIN) {
- return UnexecutableCommand.INSTANCE;
- }
- }
- }
-
- // prevent duplicate create link
- if( messageCreate && request.getSourceEditPart() != null && request.getTargetEditPart() != null){
- if(LifelineMessageCreateHelper.hasMessageCreate((GraphicalEditPart)request.getSourceEditPart(), request.getTargetEditPart()))
- return UnexecutableCommand.INSTANCE;
- }
-
- request.getExtendedData().put(SequenceRequestConstant.SOURCE_MODEL_CONTAINER, SequenceUtil.findInteractionFragmentContainerAt(sourcePoint, getHost()));
- request.getExtendedData().put(SequenceRequestConstant.TARGET_MODEL_CONTAINER, SequenceUtil.findInteractionFragmentContainerAt(targetPoint, getHost()));
- // In case we are creating a connection to/from a CoRegion, we will need the lifeline element where is drawn the CoRegion later in the process.
- EditPart targetEditPart = getTargetEditPart(request);
- if(targetEditPart instanceof CombinedFragment2EditPart) {
- request.getExtendedData().put(SequenceRequestConstant.LIFELINE_GRAPHICAL_CONTAINER, ((CombinedFragment2EditPart)targetEditPart).getAttachedLifeline());
- }
-
- // change constraint of the target lifeline after added a Create Message
- if (request.getTargetEditPart() instanceof LifelineEditPart
- && !(request.getSourceEditPart().equals(request
- .getTargetEditPart()))) {
- if (requestHint.equals((((IHintedType) UMLElementTypes.Message_4006).getSemanticHint()))) {
- LifelineEditPart target = (LifelineEditPart) request
- .getTargetEditPart();
- command = LifelineMessageCreateHelper.moveLifelineDown(command, target, sourcePoint.getCopy());
- }
- }
-
- return command;
- }
-
- /**
- * Override to disable uphill message
- */
- @Override
- protected Command getReconnectSourceCommand(ReconnectRequest request) {
- if(isUphillMessage(request) && !isLostFoundMessage(request)) {
- return UnexecutableCommand.INSTANCE;
- }
- // prevent duplicate link
- if(request.getConnectionEditPart() instanceof Message4EditPart && request.getTarget() != null && !LifelineMessageCreateHelper.canReconnectMessageCreate(request)){
- return UnexecutableCommand.INSTANCE;
- }
- return super.getReconnectSourceCommand(request);
- }
-
- private boolean isLostFoundMessage(ReconnectRequest request) {
- ConnectionEditPart connectionEditPart = request.getConnectionEditPart();
- if(connectionEditPart instanceof Message7EditPart || connectionEditPart instanceof Message6EditPart )
- return true;
- return false;
- }
-
- private boolean isLostFoundMessage(String requestHint) {
- if(((IHintedType)UMLElementTypes.Message_4008).getSemanticHint().equals(requestHint) || ((IHintedType)UMLElementTypes.Message_4009).getSemanticHint().equals(requestHint))
- return true;
- return false;
- }
-
- /**
- * Override to disable uphill message
- */
- @Override
- protected Command getReconnectTargetCommand(ReconnectRequest request) {
- if(isUphillMessage(request) && !isLostFoundMessage(request)) {
- return UnexecutableCommand.INSTANCE;
- }
- // prevent duplicate link
- if(request.getConnectionEditPart() instanceof Message4EditPart && request.getTarget() != null && !LifelineMessageCreateHelper.canReconnectMessageCreate(request)){
- return UnexecutableCommand.INSTANCE;
- }
-
- return super.getReconnectTargetCommand(request);
- }
-
- /**
- * Check that a message doesn't have its target point above its source point
- *
- * @param request
- * the ReconnectRequest
- * @return true if the target point is above the source point
- */
- protected boolean isUphillMessage(ReconnectRequest request) {
- ConnectionEditPart connectionEditPart = request.getConnectionEditPart();
- if(connectionEditPart.getModel() instanceof Edge) {
- Edge edge = (Edge)connectionEditPart.getModel();
- if(edge.getElement() instanceof Message) {
- if(connectionEditPart.getFigure() instanceof Polyline) {
- // get connection end points translated to absolute
- Polyline polyline = (Polyline)connectionEditPart.getFigure();
- Point end = polyline.getEnd().getCopy();
- Point start = polyline.getStart().getCopy();
- polyline.getParent().translateToAbsolute(end);
- polyline.getParent().translateToAbsolute(start);
-
- // look at the request rather than at both polyline ends which may not be up to date
- if(REQ_RECONNECT_SOURCE.equals(request.getType())) {
- return request.getLocation().y >= end.y + MARGIN;
- } else if(REQ_RECONNECT_TARGET.equals(request.getType())) {
- return start.y >= request.getLocation().y + MARGIN;
- } else {
- return start.y >= end.y + MARGIN;
- }
- }
- }
- }
- return false;
- }
-
-
- /**
- * Overrides to set the color of the dummyConnection to color black.
- * This allow to see the feedback of the connection when it is created.
- * By default, the color was the foreground color of the lifeline, which is always blank leading to an invisible feedback.
- *
- */
- @Override
- protected Connection createDummyConnection(Request req) {
- Connection conn = super.createDummyConnection(req);
- conn.setForegroundColor(org.eclipse.draw2d.ColorConstants.black);
- return conn;
- }
-
- /**
- * Gets a command that pops up a menu which allows the user to select which
- * type of connection to be created and then creates the connection.
- *
- * @param content
- * The list of items making up the content of the popup menu.
- * @param request
- * The relevant create connection request.
- * @return the command to popup up the menu and create the connection
- */
- protected ICommand getPromptAndCreateConnectionCommand(List content, CreateConnectionRequest request) {
- return new SequencePromptAndCreateConnectionCommand(content, request);
- }
-
-
- /**
- * Extends {@link PromptAndCreateConnectionCommand} to specify the type of message that can be selected.
- */
- protected class SequencePromptAndCreateConnectionCommand extends PromptAndCreateConnectionCommand {
-
- /**
- * @see {@link PromptAndCreateConnectionCommand#PromptAndCreateConnectionCommand(List, CreateConnectionRequest)}
- */
- public SequencePromptAndCreateConnectionCommand(List content, CreateConnectionRequest request) {
- super(content, request);
- }
-
-
- /**
- * Defines a specific label provider to handle message.
- */
- @Override
- protected ILabelProvider getLabelProvider() {
- return new LabelProvider() {
-
- @Override
- public String getText(Object object) {
- if(object instanceof IHintedType) {
- IHintedType elementType = (IHintedType)object;
- switch(UMLVisualIDRegistry.getVisualID(elementType.getSemanticHint())) {
- case MessageEditPart.VISUAL_ID:
- return Messages.createMessageSync1CreationTool_title;
- case Message2EditPart.VISUAL_ID:
- return Messages.createMessageAsync2CreationTool_title;
- case Message3EditPart.VISUAL_ID:
- return Messages.createMessageReply3CreationTool_title;
- case Message4EditPart.VISUAL_ID:
- return Messages.createMessageCreate4CreationTool_title;
- case Message5EditPart.VISUAL_ID:
- return Messages.createMessageDelete5CreationTool_title;
- case Message6EditPart.VISUAL_ID:
- return Messages.createMessageLost6CreationTool_title;
- case Message7EditPart.VISUAL_ID:
- return Messages.createMessageFound7CreationTool_title;
- }
- }
- return super.getText(object);
- }
- };
-
- }
- }
-
- public EditPart getTargetEditPart(Request request) {
- if (REQ_CONNECTION_START.equals(request.getType())
- || REQ_CONNECTION_END.equals(request.getType())
- || REQ_RECONNECT_SOURCE.equals(request.getType())
- || REQ_RECONNECT_TARGET.equals(request.getType())){
-
- EditPart host = getHost();
- if(request instanceof CreateConnectionRequest){
- if(host instanceof InteractionEditPart){
- if(REQ_CONNECTION_END.equals(request.getType()) && isCreateConnectionRequest(request,UMLElementTypes.Message_4008 )){
- return host;
- }
- if(REQ_CONNECTION_START.equals(request.getType()) && isCreateConnectionRequest(request,UMLElementTypes.Message_4009 )){
- return host;
- }
-
- InteractionEditPart interactionPart = (InteractionEditPart)host;
- CreateConnectionRequest req = (CreateConnectionRequest)request;
- IFigure figure = interactionPart.getFigure();
- Point location = req.getLocation().getCopy();
- figure.translateToRelative(location);
-
- // if mouse location is far from border, do not handle connection event
- Rectangle innerRetangle = figure.getBounds().getCopy().shrink(20, 20);
- if(innerRetangle.contains(location)){
- return null;
- }
- }else if(host instanceof InteractionOperandEditPart){
- return null;
- }else if(host instanceof CombinedFragmentEditPart){
- CreateConnectionRequest req = (CreateConnectionRequest)request;
- IFigure figure = ((GraphicalEditPart)host).getFigure();
- Point location = req.getLocation().getCopy();
- figure.translateToRelative(location);
-
- // if mouse location is far from border, do not handle connection event
- Rectangle innerRetangle = figure.getBounds().getCopy().shrink(10, 10);
- if(innerRetangle.contains(location)){
- return null;
- }
- }
- }
- return host;
- }
- return null;
- }
-
- protected boolean isCreateConnectionRequest(Request request, IElementType type) {
- if( request instanceof CreateAspectUnspecifiedTypeConnectionRequest){
- List types = ((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes();
- if(types.contains(type)){
- return true;
- }
- }
-
- if(request instanceof CreateConnectionViewRequest ){
- String requestHint = ((CreateConnectionViewRequest)request).getConnectionViewDescriptor().getSemanticHint();
- if(((IHintedType)type).getSemanticHint().equals(requestHint))
- return true;
- }
- return false;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java
deleted file mode 100644
index 49163add6b0..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationMoveHelper;
-
-/**
- * Edit policy to restrict border item movement. This edit policy moves the related events when a Time/Duration Observation/Constraint is moved.
- */
-public class TimeRelatedSelectionEditPolicy extends BorderItemSelectionEditPolicy {
-
- @Override
- protected Command getMoveCommand(ChangeBoundsRequest request) {
- // Prepare request
- if(getHost() instanceof IBorderItemEditPart) {
- OccurrenceSpecificationMoveHelper.prepareTimeRelatedElementMoveRequest(request, (IBorderItemEditPart)getHost());
- }
- Command command = super.getMoveCommand(request);
- if(command != null) {
- command = OccurrenceSpecificationMoveHelper.completeMoveTimeRelatedElementCommand(command, request, getHost(), getHostFigure());
- }
- return command;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CoRegionCombinedFragmentFigure.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CoRegionCombinedFragmentFigure.java
deleted file mode 100644
index 403afdfa100..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CoRegionCombinedFragmentFigure.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.figures;
-
-import java.util.List;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
-
-
-public class CoRegionCombinedFragmentFigure extends RectangleFigure {
-
- // The area (to the left,right, top and bottom) near the border of the Coregion that is sensible to the mouse
- private static final int COREGION_HIT_WIDTH = 6;
-
- private static final int BRACKET_HEIGHT = 7;
-
- private static final int BRACKET_LINE_WIDTH = 3;
-
- /** The DashLine figure where elements will be attached */
- private NodeFigure centralVerticalLine;
-
- /**
- * Constructor
- *
- * @generated
- */
- public CoRegionCombinedFragmentFigure() {
- super();
-
- // Init centralVerticalLine
- centralVerticalLine = new NodeFigure();
- centralVerticalLine.setParent(this);
- setLineWidth(BRACKET_LINE_WIDTH);
- }
-
- /**
- * Draw the vertical bracket
- *
- * @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics)
- */
- @Override
- public void paintFigure(Graphics graphics) {
- Rectangle r = getBounds().getCopy();
- graphics.setBackgroundColor(this.getBackgroundColor());
- graphics.setForegroundColor(this.getForegroundColor());
- graphics.setLineWidth(getLineWidth() );
- graphics.drawLine(r.x, r.y, r.right() - 1, r.y);
- graphics.drawLine(r.x, r.bottom() - 1, r.right() - 1, r.bottom() - 1);
- graphics.drawLine(r.x, r.y, r.x, r.y + BRACKET_HEIGHT);
- graphics.drawLine(r.right() - 1, r.y + BRACKET_HEIGHT, r.right() - 1, r.y);
- graphics.drawLine(r.right() - 1, r.bottom() - 1, r.right() - 1, r.bottom() - 1 - BRACKET_HEIGHT);
- graphics.drawLine(r.x, r.bottom() - 1, r.x, r.bottom() - 1 - BRACKET_HEIGHT);
-
- // Refresh the line
- int endY = r.height + r.x;
- Point pStart = new Point(r.x + r.width / 2, r.y + 1);
- centralVerticalLine.setSize(1, endY - pStart.y);
- centralVerticalLine.setLocation(pStart);
- }
-
- /**
- * @see org.eclipse.draw2d.Figure#containsPoint(int, int)
- */
- @Override
- public boolean containsPoint(int x, int y) {
- Rectangle rect = getBounds();
- // check if point is at the topline of the figure
- if(x > rect.x && x < rect.x + rect.width) {
- if(y > rect.y - COREGION_HIT_WIDTH && y < rect.y + COREGION_HIT_WIDTH) {
- return true;
- }
- }
-
- // check if point is at the bottom line of the figure
- if(x > rect.x && x < rect.x + rect.width) {
- if(y > rect.y + rect.height - COREGION_HIT_WIDTH && y < rect.y + rect.height + COREGION_HIT_WIDTH) {
- return true;
- }
- }
-
- // check if point is at the left line of the figure
- if(x > rect.x - COREGION_HIT_WIDTH && x < rect.x + COREGION_HIT_WIDTH) {
- if(y > rect.y && y < rect.y + rect.height) {
- return true;
- }
- }
-
- // check if point is at the right line of the figure
- if(x > rect.x + rect.width - COREGION_HIT_WIDTH && x < rect.x + rect.width + COREGION_HIT_WIDTH) {
- if(y > rect.y && y < rect.y + rect.height) {
- return true;
- }
- }
-
- for(IFigure child : (List<IFigure>)getChildren()) {
- Point local = new Point(x, y);
- translateFromParent(local);
- if(child.containsPoint(local)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Get a rectangleFigure representing a central vertical line
- */
- public NodeFigure getCentralVerticalLine() {
- return centralVerticalLine;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CombinedFragmentFigure.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CombinedFragmentFigure.java
deleted file mode 100644
index 8fb66ae998e..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CombinedFragmentFigure.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.figures;
-
-import org.eclipse.draw2d.BorderLayout;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.InteractionRectangleFigure;
-
-public class CombinedFragmentFigure extends InteractionRectangleFigure {
-
- private WrappingLabel titleLabel;
-
- @Override
- protected void createContents() {
- add(createHeaderPane(), BorderLayout.TOP);
- add(createContentPane(), BorderLayout.CENTER);
- setShadow(false);
- interactionContentPane.setOutline(false);
- interactionContentPane.setOpaque(false);
- interactionContentPane.setBorder(null);
- }
-
- protected Figure createHeaderPane() {
- titleLabel = new WrappingLabel();
- titleLabel.setAlignment(PositionConstants.RIGHT);
- titleLabel.setBorder(new MarginBorder(3, 0, 0, 3));
- titleLabel.setTextWrap(false);
- IFigure leftContainer = super.createHeader();
-
- Figure headerPane = new Figure();
- headerPane.setLayoutManager(new BorderLayout());
- headerPane.add(leftContainer, BorderLayout.LEFT);
- headerPane.add(titleLabel, BorderLayout.RIGHT);
-
- return headerPane;
- }
-
- public WrappingLabel getTitleLabel() {
- return titleLabel;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java
deleted file mode 100644
index 66d6f7057d2..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 AIRBUS FRANCE. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: David Sciamma (Anyware Technologies), Mathieu Garcia (Anyware
- * Technologies), Jacques Lescot (Anyware Technologies), Thomas Friol (Anyware
- * Technologies), Nicolas Lalevée (Anyware Technologies) - initial API and
- * implementation
- ******************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.sequence.figures;
-
-import org.eclipse.draw2d.Graphics;
-
-/**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
-public class DestructionEventFigure extends org.eclipse.draw2d.Figure {
-
- /**
- * Constructor <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public DestructionEventFigure() {
-
- super();
- }
-
- /**
- * The stop is a cross
- *
- * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
- */
- protected void paintFigure(Graphics graphics) {
- super.paintFigure(graphics);
- graphics.pushState();
-
- int width = bounds.width;
- int height = bounds.height;
- if(width > height) {
- width = height;
- } else if(width < height) {
- height = width;
- }
- int x = bounds.x + bounds.width / 2 - width / 2;
- int y = bounds.y + bounds.height / 2 - height / 2;
- graphics.setLineWidth(lineWidth);
- graphics.drawLine(x, y, x + width, y + height);
- graphics.drawLine(x + width, y, x, y + height);
- graphics.popState();
- }
-
- public void setLineWidth(int w) {
- if ((lineWidth == w) || (w < 0))
- return;
- lineWidth = w;
- repaint();
- }
-
- private int lineWidth = 1;
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/EllipseDecoration.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/EllipseDecoration.java
deleted file mode 100644
index 3f422fc08b1..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/EllipseDecoration.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009 Borland Software Corporation
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Golubev (Borland) - initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.sequence.figures;
-
-import org.eclipse.draw2d.Ellipse;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.RotatableDecoration;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.swt.graphics.Color;
-
-public class EllipseDecoration extends Ellipse implements RotatableDecoration {
-
- private boolean myAlwaysFill;
-
- public EllipseDecoration() {
- setPreferredSize(new Dimension(5, 5));
- }
-
- public void setAlwaysFill(boolean alwaysFill) {
- myAlwaysFill = alwaysFill;
- }
-
- public void setLocation(Point p) {
- Dimension delta = getPreferredSize().getScaled(0.5).getNegated();
- super.setLocation(p.getTranslated(delta));
- }
-
- public void setReferencePoint(Point p) {
- }
-
- @Override
- protected void outlineShape(Graphics graphics) {
- if(myAlwaysFill) {
- Color oldBack = graphics.getBackgroundColor();
- graphics.setBackgroundColor(graphics.getForegroundColor());
- fillShape(graphics);
- graphics.setBackgroundColor(oldBack);
- }
- super.outlineShape(graphics);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionOperandFigure.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionOperandFigure.java
deleted file mode 100644
index 0d3144a04de..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionOperandFigure.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.figures;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure;
-
-public class InteractionOperandFigure extends PapyrusNodeFigure {
-
- /**
- * True if line separator is printed
- */
- private boolean lineSeparator = true;
-
- @Override
- public void paintFigure(Graphics graphics) {
- super.paintFigure(graphics);
- if(lineSeparator) {
- graphics.setLineStyle(getLineStyle());
- graphics.setLineWidth(getLineWidth());
- graphics.drawLine(getBounds().getTopLeft(), getBounds().getTopRight());
- }
- }
-
- /**
- * Set the line separator
- *
- * @param lineSeparator
- */
- public void setLineSeparator(boolean lineSeparator) {
- this.lineSeparator = lineSeparator;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionUseRectangleFigure.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionUseRectangleFigure.java
deleted file mode 100644
index 27bf1932f18..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/InteractionUseRectangleFigure.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.figures;
-
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.StackLayout;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.InteractionRectangleFigure;
-
-/**
- * The figure of the InteractionUse
- */
-public class InteractionUseRectangleFigure extends InteractionRectangleFigure {
-
- /** A centered label */
- protected WrappingLabel centerLabel;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.figures.InteractionRectangleFigure#createContentPane()
- */
- @Override
- protected RectangleFigure createContentPane() {
-
- // Create the ContentPane
- RectangleFigure contentPane = new RectangleFigure();
- contentPane.setOutline(false);
- contentPane.setFill(false);
- contentPane.setLayoutManager(new StackLayout());
-
- // Create the centered label
- centerLabel = new WrappingLabel();
- centerLabel.setAlignment(PositionConstants.CENTER);
-
- // Add the label to the contentPane
- contentPane.add(centerLabel);
-
- return contentPane;
- }
-
- public WrappingLabel getCenterLabel() {
- return centerLabel;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineDotLineCustomFigure.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineDotLineCustomFigure.java
deleted file mode 100644
index bda9b86f576..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineDotLineCustomFigure.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.figures;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.LayoutManager;
-import org.eclipse.draw2d.TreeSearch;
-import org.eclipse.draw2d.XYLayout;
-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.draw2d.LifelineDotLineFigure;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure;
-
-/**
- * The figure of the LifelineDotLine
- */
-public class LifelineDotLineCustomFigure extends LifelineDotLineFigure {
-
- /**
- * Layout manager for the inline mode
- */
- private LayoutManager inlineModeManager;
-
- /**
- * Layout manager for the inline mode
- */
- private LayoutManager normalModeManager;
-
- /**
- * True if the lifeline is in inline mode
- */
- private boolean inlineMode;
-
- /**
- * Number of inner ConnectableElements
- */
- private int innerConnectableElementsNumber;
-
- /**
- * Default constructor
- */
- public LifelineDotLineCustomFigure() {
- super();
- normalModeManager = new XYLayout();
-
- /*
- inlineModeManager = new FlowLayout(true) {
-
- {
- majorSpacing = 10;
- minorSpacing = 10;
- fill = true;
- }
-
- @Override
- protected Dimension getChildSize(IFigure child, int wHint, int hHint) {
- wHint = getParent().getBounds().width;
- hHint = getParent().getBounds().height;
- if(innerConnectableElementsNumber > 0) {
- wHint /= innerConnectableElementsNumber;
- }
- if(!child.getParent().getChildren().get(innerConnectableElementsNumber - 1).equals(child)) {
- wHint = wHint - majorSpacing;
- }
-
- ((Figure)child).setPreferredSize(wHint, hHint);
- Dimension childSize = super.getChildSize(child, wHint, hHint);
- return childSize;
- }
-
- @Override
- protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
- Dimension calculatePreferredSize = super.calculatePreferredSize(container, wHint, hHint);
- calculatePreferredSize.width = wHint;
- calculatePreferredSize.height = hHint;
- return calculatePreferredSize;
- }
- };
- */
- inlineModeManager = new XYLayout();
- setLayoutManager(normalModeManager);
- }
-
- /**
- * Configure the lifeline figure
- *
- * @param inlineMode
- * true if inline mode enabled
- * @param innerConnectableElementsNumber
- * Number of children
- */
- public void configure(boolean inlineMode, int innerConnectableElementsNumber) {
- if(inlineMode) {
- this.innerConnectableElementsNumber = innerConnectableElementsNumber;
- }
- if(this.inlineMode != inlineMode) {
- this.inlineMode = inlineMode;
- if(inlineMode) {
- setLayoutManager(inlineModeManager);
- } else {
- setLayoutManager(normalModeManager);
- }
- }
- }
-
- /**
- * Print lifeline if the edit part is not in inline mode
- */
- protected void outlineShape(Graphics graphics) {
- if(!inlineMode) {
- super.outlineShape(graphics);
- }
- }
-
- // fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=384616
- public static class DefaultSizeNodeFigureEx extends DefaultSizeNodeFigure {
-
- public DefaultSizeNodeFigureEx(int width, int height) {
- super(width, height);
- }
-
- public IFigure findMouseEventTargetAt(int x, int y) {
- // check children first instead of self
- IFigure f = findMouseEventTargetInDescendantsAt(x, y);
- if (f != null)
- return f;
- if (!containsPoint(x, y))
- return null;
- if (isMouseEventTarget())
- return this;
- return null;
- }
-
- public IFigure findFigureAt(int x, int y, TreeSearch search) {
- if (search.prune(this))
- return null;
- IFigure child = findDescendantAtExcluding(x, y, search);
- if (child != null)
- return child;
- if (!containsPoint(x, y))
- return null;
- if (search.accept(this))
- return this;
- return null;
- }
- };
-
- public static class NodeNamedElementFigureEx extends NodeNamedElementFigure{
-
- public IFigure findMouseEventTargetAt(int x, int y) {
- // check children first instead of self
- IFigure f = findMouseEventTargetInDescendantsAt(x, y);
- if (f != null)
- return f;
- if (!containsPoint(x, y))
- return null;
- if (isMouseEventTarget())
- return this;
- return null;
- }
-
- public IFigure findFigureAt(int x, int y, TreeSearch search) {
- if (search.prune(this))
- return null;
- IFigure child = findDescendantAtExcluding(x, y, search);
- if (child != null)
- return child;
- if (!containsPoint(x, y))
- return null;
- if (search.accept(this))
- return this;
- return null;
- }
- }
-}
-
-
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java
deleted file mode 100644
index d99d5a64e07..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.locator;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator;
-import org.eclipse.gmf.runtime.diagram.ui.internal.figures.BorderItemContainerFigure;
-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart.LifelineFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
-
-
-public class CenterLocator extends BorderItemLocator {
-
- /**
- * The LifelineDotLineFigure. It must be access through the method {@link #getLifelineDotLineFigure()}
- */
- private LifelineDotLineCustomFigure lifelineDotLineFigure = null;
-
- /**
- * The BorderItemContainerFigure. It must be access through the method {@link #getBorderItemContainerFigure()}
- */
- private BorderItemContainerFigure borderItemContainerFigure = null;
-
- /**
- * The DestructionEventFigure.
- *
- * It must be access through the method {@link #getDestructionEventFigure()}
- */
- private DestructionEventFigure destructionEventFigure = null;
-
- /**
- * Constructor
- *
- * @param parentFigure
- * the parent figure
- * @param location
- * ContinuationLocator.TOP or ContinuationLocator.BOTTOM
- */
- public CenterLocator(IFigure parentFigure, int location) {
- super(parentFigure, location);
- }
-
- /**
- * Get the LifelineDotLineFigure
- *
- * @return the lifelineDotLineFigure or null
- */
- private LifelineDotLineCustomFigure getLifelineDotLineFigure() {
- if(lifelineDotLineFigure == null) {
- for(Object childFig : getParentFigure().getChildren()) {
- if(childFig instanceof LifelineFigure) {
- lifelineDotLineFigure = ((LifelineFigure)childFig).getFigureLifelineDotLineFigure();
- return lifelineDotLineFigure;
- }
- }
- }
- return lifelineDotLineFigure;
- }
-
- /**
- * Get the BorderItemContainerFigure
- *
- * @return the borderItemContainerFigure or null
- */
- private BorderItemContainerFigure getBorderItemContainerFigure() {
- if(borderItemContainerFigure == null) {
- IFigure figure = getParentFigure().getParent();
- for(Object object : figure.getChildren()) {
- if(object instanceof BorderItemContainerFigure) {
- borderItemContainerFigure = (BorderItemContainerFigure)object;
- return borderItemContainerFigure;
- }
- }
- }
- return borderItemContainerFigure;
- }
-
- /**
- * Get the DestructionEventFigure of the lifeline, if it is drawn.
- *
- * @return the DestructionEventFigure or null
- */
- private DestructionEventFigure getDestructionEventFigure() {
- if(destructionEventFigure == null) {
- BorderItemContainerFigure borderItemContainerFigure = getBorderItemContainerFigure();
- if(borderItemContainerFigure != null) {
- for(Object child : borderItemContainerFigure.getChildren()) {
- if(child instanceof DefaultSizeNodeFigure) {
- for(Object figure : ((DefaultSizeNodeFigure)child).getChildren()) {
- if(figure instanceof DestructionEventFigure) {
- destructionEventFigure = (DestructionEventFigure)figure;
- return destructionEventFigure;
- }
- }
- }
- }
- }
- }
- return destructionEventFigure;
- }
-
- /**
- * Overrides :
- * - the destructionEventFigure is always drawn at the end of the figure
- *
- * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
- */
- public void relocate(IFigure borderItem) {
- if(getDestructionEventFigure() != null) {
- if(borderItem.equals(getDestructionEventFigure().getParent())) {
- borderItem.setLocation(new Point(getHorizontalPosition(borderItem), getParentBorder().y + getParentBorder().height - borderItem.getBounds().height / 2));
- return;
- }
- }
- super.relocate(borderItem);
-
- }
-
- public Rectangle getValidLocation(Rectangle proposedLocation,
- IFigure borderItem) {
- if(getDestructionEventFigure() != null) {
- if(borderItem.equals(getDestructionEventFigure().getParent())) {
- Rectangle realLocation = new Rectangle(proposedLocation);
- Point point = new Point(getParentBorder().getCenter().x - realLocation.getSize().width / 2, getParentBorder().y + getParentBorder().height - realLocation.height / 2);
- realLocation.setLocation(point);
- return realLocation;
- }
- }
- return super.getValidLocation(proposedLocation, borderItem);
- }
-
- /**
- * Get the parent dotLine border
- *
- * @return <code>Rectangle</code> that is the bounds of the parent dot line.
- */
- protected Rectangle getParentDotLineBorder() {
- LifelineDotLineCustomFigure dotline = getLifelineDotLineFigure();
- if(dotline != null) {
- return dotline.getBounds().getCopy();
- }
- return super.getParentBorder();
- }
-
-
-
-
- /**
- * Locate the figure on its parent
- *
- * @param suggestedLocation
- * @param suggestedSide
- * @return point
- */
- protected Point locateOnParent(Point suggestedLocation, int suggestedSide, IFigure borderItem) {
-
- Dimension borderItemSize = getSize(borderItem);
-
- int y = getVerticalPosition(suggestedLocation.y, borderItemSize.height);
- int x = getHorizontalPosition(borderItem);
- return new Point(x, y);
- }
-
- /**
- * Get the vertical position of the itemBorder
- *
- * @param y
- * the suggested location
- * @param height
- * the border item height
- * @return the vertical position of the item border on the lifeline
- */
- private int getVerticalPosition(int y, int height) {
- int validY = y;
- Rectangle parentDotLineBorder = getParentDotLineBorder();
- int maxY = parentDotLineBorder.y + parentDotLineBorder.height - getSouthInsets();
- if(y + height > maxY) {
- validY = maxY - height;
- } else if(y < parentDotLineBorder.y) {
- validY = parentDotLineBorder.y;
- }
- return validY;
- }
-
-
- /**
- * Get the horizontal position of the borderItem drawn on a lifeline.
- * Those elements are drawn at the center of the lifeline, ie on the dot line.
- *
- * @param borderItem
- * the borderItem
- * @return the horizontal position of the border item
- */
- private int getHorizontalPosition(IFigure borderItem) {
- return getParentBorder().getCenter().x - borderItem.getSize().width / 2;
- }
-
-
- /**
- * Get the insets to use at the bottom of the figure.
- * It is used to prevent others borderItems to be drawn on or below the destructionEventFigure
- *
- * @return If a destructionEventFigure is drawn, it returns the height of its figure, otherwise it returns 0
- */
- private int getSouthInsets() {
- DestructionEventFigure destructionEventFigure = getDestructionEventFigure();
- if(destructionEventFigure != null) {
- return destructionEventFigure.getBounds().height;
- }
- return 0;
- }
-
-
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/ContinuationLocator.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/ContinuationLocator.java
deleted file mode 100644
index 62d6d068400..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/ContinuationLocator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.locator;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator;
-
-/**
- * A specific locator for Continuation.
- * This locator is in charge of positioning the continuation at the top or the bottom of its container.
- *
- */
-public class ContinuationLocator extends BorderItemLocator {
-
- private static final int MARGIN = 2;
-
- /**
- * Constructor
- *
- * @param parentFigure
- * the parent figure
- * @param location
- * ContinuationLocator.TOP or ContinuationLocator.BOTTOM
- */
- public ContinuationLocator(IFigure parentFigure, int location) {
- super(parentFigure, location);
- }
-
- /**
- * Locate the figure on its parent
- *
- * @param suggestedLocation
- * @param suggestedSide
- * @return point
- */
- protected Point locateOnParent(Point suggestedLocation, int suggestedSide, IFigure borderItem) {
-
- Rectangle bounds = getParentBorder();
- Dimension borderItemSize = getSize(borderItem);
- if(getPreferredSideOfParent() == PositionConstants.SOUTH) {
- return new Point(bounds.x + MARGIN, bounds.y + bounds.height - borderItemSize.height - MARGIN);
- }
- return new Point(bounds.x + MARGIN, bounds.y + MARGIN);
- }
-
- /**
- * Overrides :
- * - the width of the borderItem is equivalent to its parentBorder width - MARGIN * 2
- * - the CurrentSide and PreferredSide are no more needed.
- *
- * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
- */
- public void relocate(IFigure borderItem) {
-
- // Determines the size of the figure
- Dimension size = getParentBorder().getSize().getCopy();
- size.width = size.width - MARGIN * 2;
- size.height = getSize(borderItem).height;
-
- // Set figure bounds
- Point ptNewLocation = locateOnBorder(getPreferredLocation(borderItem), getPreferredSideOfParent(), 0, borderItem);
- borderItem.setBounds(new Rectangle(ptNewLocation, size));
-
- }
-
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeMarkElementPositionLocator.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeMarkElementPositionLocator.java
deleted file mode 100644
index 703eb28a068..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeMarkElementPositionLocator.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.locator;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart.LifelineFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.uml2.uml.DurationConstraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.IntervalConstraint;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.TimeConstraint;
-import org.eclipse.uml2.uml.TimeObservation;
-
-/**
- * This class is used to constrain the position of a Time/Duration related object on a Lifeline.
- */
-public class TimeMarkElementPositionLocator extends AdvancedBorderItemLocator {
-
- /**
- * The edit part which figure is located.
- * Used to know the horizontal gap or whether the occurrence specifies a destruction event.
- */
- private EditPart editPart = null;
-
- /** Constructor **/
- public TimeMarkElementPositionLocator(IFigure parentFigure) {
- super(parentFigure);
- }
-
- /** Constructor **/
- public TimeMarkElementPositionLocator(IFigure borderItem, IFigure parentFigure, Rectangle constraint) {
- super(borderItem, parentFigure, constraint);
- }
-
- /** Constructor **/
- public TimeMarkElementPositionLocator(IFigure parentFigure, int preferredSide) {
- super(parentFigure, preferredSide);
- }
-
- /** Set the edit part which figure is placed by this locator */
- public void setEditPart(EditPart part) {
- editPart = part;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) {
- Rectangle realLocation = new Rectangle(proposedLocation);
- int side = findClosestSideOfParent(realLocation, getParentBorder());
- Point newTopLeft = locateOnBorder(realLocation.getTopLeft(), side, 0, borderItem);
- // correct in case the figure is linked to a destruction event
- if(timeElementPointsDestructionEvent()) {
- Point destr = getDestructionEventCenter();
- if(destr != null) {
- if(editPart instanceof DurationConstraintEditPart) {
- // bottom is at the destruction event y
- realLocation.height = destr.y - newTopLeft.y;
- } else if(editPart instanceof TimeObservationEditPart || editPart instanceof TimeConstraintEditPart) {
- // center is at the destruction event y
- newTopLeft.y = destr.y - realLocation.height / 2;
- }
- }
- }
- realLocation.setLocation(newTopLeft);
- return realLocation;
- }
-
- /**
- * The y location takes precedence on the preferred side or on collision.
- *
- * @param suggestedLocation
- * the suggester location (y must be respected)
- * @param suggestedSide
- * the suggested side
- * @param circuitCount
- * recursion count to avoid an infinite loop
- * @return point
- */
- protected Point locateOnBorder(Point suggestedLocation, int suggestedSide, int circuitCount, IFigure borderItem) {
- Point recommendedLocation = locateOnParent(suggestedLocation, suggestedSide, borderItem);
-
- IFigure conflictingBorderItem = getConflictingBorderItemFigure(recommendedLocation, borderItem);
- // max circuit count of 2 allows to try other side, then go back to original side if occupied
- if(circuitCount < 2 && conflictingBorderItem != null) {
- if(suggestedSide == PositionConstants.WEST) {
- // west is occupied, try east
- return locateOnBorder(recommendedLocation, PositionConstants.EAST, circuitCount + 1, borderItem);
- } else { //EAST
- // east is occupied, try west
- return locateOnBorder(recommendedLocation, PositionConstants.WEST, circuitCount + 1, borderItem);
- }
- }
- return recommendedLocation;
- }
-
- /**
- * Utility to calculate the bounds of the dot line to use as parent with consideration for the handle
- * bounds inset.
- *
- * @return <code>Rectangle</code> that is the bounds of the parent dot line.
- */
- protected Rectangle getParentDotLineBorder() {
- // get the dot line of the lifeline if available
- for(Object childFig : getParentFigure().getChildren()) {
- if(childFig instanceof LifelineFigure) {
- LifelineDotLineCustomFigure dotline = ((LifelineFigure)childFig).getFigureLifelineDotLineFigure();
- return dotline.getBounds().getCopy();
- }
- }
- return super.getParentBorder();
- }
-
- /**
- * Ensure the suggested location actually lies on the parent boundary. The
- * side takes precedence.
- *
- * @param suggestedLocation
- * @param suggestedSide
- * @return point
- */
- protected Point locateOnParent(Point suggestedLocation, int suggestedSide, IFigure borderItem) {
- int[] horizontalGap = getHorizontalGap();
- Rectangle bounds = getParentDotLineBorder();
- int parentFigureXCenter = bounds.getCenter().x;
- int parentFigureHeight = bounds.height;
- int parentFigureY = bounds.y;
- Dimension borderItemSize = getCorrectSize(borderItem);
- int newX = suggestedLocation.x;
- int newY = suggestedLocation.y;
- int westX = parentFigureXCenter - borderItemSize.width + horizontalGap[0];
- int eastX = parentFigureXCenter + horizontalGap[1];
- int southY = parentFigureY + parentFigureHeight - getBorderItemOffset().height;
- int northY = parentFigureY + getBorderItemOffset().height;
- if(suggestedSide == PositionConstants.WEST) {
- if(suggestedLocation.x != westX) {
- newX = westX;
- }
- if(suggestedLocation.y < bounds.getTopLeft().y) {
- newY = northY;
- } else if(suggestedLocation.y > bounds.getBottomLeft().y - borderItemSize.height) {
- newY = southY - borderItemSize.height;
- }
- } else { // EAST
- if(suggestedLocation.x != eastX) {
- newX = eastX;
- }
- if(suggestedLocation.y < bounds.getTopLeft().y) {
- newY = northY;
- } else if(suggestedLocation.y > bounds.getBottomLeft().y - borderItemSize.height) {
- newY = southY - borderItemSize.height;
- }
- }
- return new Point(newX, newY);
- }
-
- /**
- * Get the center of the destruction event figure (relative)
- *
- * @return the destruction center or null
- */
- private Point getDestructionEventCenter() {
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(editPart);
- if(lifeline != null) {
- for(Object child : lifeline.getChildren()) {
- if(child instanceof DestructionOccurrenceSpecificationEditPart) {
- return ((DestructionOccurrenceSpecificationEditPart)child).getFigure().getBounds().getCenter();
- }
- }
- }
- return null;
- }
-
- /**
- * Know whether the figure must be located all down because its element references a destruction event
- *
- * @return true if destruction event is referenced
- */
- private boolean timeElementPointsDestructionEvent() {
- if(editPart instanceof GraphicalEditPart) {
- // get event occurrence(s)
- EObject element = ((GraphicalEditPart)editPart).resolveSemanticElement();
- List<? extends Element> occurrences = Collections.emptyList();
- if(element instanceof TimeObservation) {
- NamedElement occurence = ((TimeObservation)element).getEvent();
- occurrences = Collections.singletonList(occurence);
- } else if(element instanceof TimeConstraint || element instanceof DurationConstraint) {
- occurrences = ((IntervalConstraint)element).getConstrainedElements();
- }
- for(Element occurrence : occurrences) {
- if(occurrence instanceof DestructionOccurrenceSpecificationEditPart) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Get the gaps to know how the figure must be translated from the center of the lifeline, taking in account executions.
- *
- * @return a size 2 array with left translation at index 0 et right at index 1
- */
- private int[] getHorizontalGap() {
- int[] horizontalGap = new int[]{ 0, 0 };
- if(editPart instanceof GraphicalEditPart) {
- // get event occurrence(s)
- LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(editPart);
- EObject element = ((GraphicalEditPart)editPart).resolveSemanticElement();
- List<? extends Element> occurrences = Collections.emptyList();
- if(element instanceof TimeObservation) {
- NamedElement occurence = ((TimeObservation)element).getEvent();
- occurrences = Collections.singletonList(occurence);
- } else if(element instanceof TimeConstraint || element instanceof DurationConstraint) {
- occurrences = ((IntervalConstraint)element).getConstrainedElements();
- }
- boolean horizontalGapSet = false;
- // check bounds of event's execution
- for(Element occurrence : occurrences) {
- if(occurrence instanceof OccurrenceSpecification) {
- EditPart part = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occurrence);
- if(part instanceof ConnectionEditPart && occurrence instanceof MessageOccurrenceSpecification) {
- // get the bounds of the execution on which the connection is connected
- ConnectionEditPart conn = (ConnectionEditPart)part;
- Message message = ((MessageOccurrenceSpecification)occurrence).getMessage();
- if(message != null) {
- boolean start = message.getSendEvent() != null && message.getSendEvent().equals(occurrence);
- if(start) {
- part = conn.getSource();
- } else {
- part = conn.getTarget();
- }
- }
- }
- if(part instanceof ShapeNodeEditPart && !lifeline.equals(part)) {
- Rectangle execBounds = ((ShapeNodeEditPart)part).getFigure().getBounds();
- Rectangle parentBounds = getParentBorder();
- int leftGap = execBounds.getLeft().x - parentBounds.getCenter().x;
- int rightGap = execBounds.getRight().x - parentBounds.getCenter().x;
- if(part instanceof DestructionOccurrenceSpecificationEditPart) {
- // center of destruction event is considered
- leftGap = 0;
- rightGap = 0;
- }
- if(!horizontalGapSet) {
- horizontalGap[0] = leftGap;
- horizontalGap[1] = rightGap;
- horizontalGapSet = true;
- } else {
- // take the more exterior gap of all events
- horizontalGap[0] = Math.min(horizontalGap[0], leftGap);
- horizontalGap[1] = Math.max(horizontalGap[1], rightGap);
- }
- }
- }
- }
- }
- return horizontalGap;
- }
-
- /**
- * Find the closest side when x,y is inside parent.
- *
- * @param proposedLocation
- * @param parentBorder
- * @return draw constant
- */
- public static int findClosestSideOfParent(Rectangle proposedLocation, Rectangle parentBorder) {
- // Rectangle parentBorder = getParentBorder();
- Point parentCenter = parentBorder.getCenter();
- Point childCenter = proposedLocation.getCenter();
- if(childCenter.x < parentCenter.x) // West, North or South.
- {
- return PositionConstants.WEST;
- } else { // EAST, NORTH or SOUTH
- return PositionConstants.EAST;
- }
- }
-
- /**
- * Relocate the child border item within the parent
- *
- * @see org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator#relocate(org.eclipse.draw2d.IFigure)
- *
- * @param borderItem
- * the item to relocate
- */
- @Override
- public void relocate(IFigure borderItem) {
- // reset bounds of borderItem
- Dimension size = getCorrectSize(borderItem);
- Rectangle rectSuggested = getConstraint().getCopy();
- if(rectSuggested.getTopLeft().x == 0 && rectSuggested.getTopLeft().y == 0) {
- rectSuggested.setLocation(getPreferredLocation(borderItem));
- } else {
- // recovered constraint must be translated with the parent location to be absolute
- rectSuggested.setLocation(rectSuggested.getLocation().translate(getParentBorder().getTopLeft()));
- }
- rectSuggested.setSize(size);
- Rectangle validLocation = getValidLocation(rectSuggested, borderItem);
- // the constraint is not reset, but the item bounds are
- borderItem.setBounds(validLocation);
- if(timeElementPointsDestructionEvent() && editPart instanceof DurationConstraintEditPart) {
- // except when duration constraint is reduced ...
- int w = getConstraint().getSize().width;
- getConstraint().setSize(w, validLocation.height);
- }
- // ensure the side property is correctly set
- setCurrentSideOfParent(findClosestSideOfParent(borderItem.getBounds(), getParentBorder()));
-
- // redraw time mark if necessary
- redrawTimeMarks(borderItem, validLocation);
- }
-
- /**
- * Gets the size of the border item figure. Take in account the constraint as a minimum size.
- *
- * @param borderItem
- * @return the size of the border item figure.
- */
- protected final Dimension getCorrectSize(IFigure borderItem) {
- Dimension size = getConstraint().getSize();
- if(size.isEmpty()) {
- size.union(borderItem.getPreferredSize(size.width, size.height));
- }
- return size;
- }
-
- /**
- * Redraw the time marks
- *
- * @param borderItem
- * the relocated border item
- * @param location
- * the new location
- */
- private void redrawTimeMarks(IFigure borderItem, Rectangle location) {
- for(Object child : borderItem.getChildren()) {
- if(child instanceof TimeConstraintEditPart.TimeMarkElementFigure) {
- ((TimeConstraintEditPart.TimeMarkElementFigure)child).setCurrentSideOfFigure(getCurrentSideOfParent(), location);
- } else if(child instanceof TimeObservationEditPart.TimeMarkElementFigure) {
- ((TimeObservationEditPart.TimeMarkElementFigure)child).setCurrentSideOfFigure(getCurrentSideOfParent(), location);
- } else if(child instanceof DurationConstraintEditPart.DurationConstraintFigure) {
- ((DurationConstraintEditPart.DurationConstraintFigure)child).updateArrow(location.width, location.height);
- } else if(child instanceof DefaultSizeNodeFigure) {
- redrawTimeMarks((IFigure)child, location);
- }
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java
deleted file mode 100644
index 9d3e75c3a76..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.common.helper.DurationObservationHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.DurationObservation;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLPackage;
-
-
-/**
- * Specific Parser for the DurationObservation.
- */
-public class DurationObservationParser extends MessageFormatParser implements ISemanticParser {
-
- /** The String for displaying a line break */
- private static final String LINE_BREAK = System.getProperty("line.separator");
-
- public DurationObservationParser() {
- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- public DurationObservationParser(EAttribute[] features) {
- super(features);
- }
-
- public DurationObservationParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- /**
- * Gets the e structural feature.
- *
- * @param notification
- * @return the structural feature
- */
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if(notification instanceof Notification) {
- Object feature = ((Notification)notification).getFeature();
- if(feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature)feature;
- }
- }
- return featureImpl;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPrintString(IAdaptable element, int flags) {
- Object adapter = element.getAdapter(EObject.class);
- if(adapter instanceof DurationObservation) {
- return DurationObservationHelper.getLabelString((DurationObservation)adapter);
- }
- return "";
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public List getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if(element instanceof DurationObservation) {
- DurationObservation observation = (DurationObservation)element;
- semanticElementsBeingParsed.add(observation);
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getMessage_SendEvent().equals(feature) || UMLPackage.eINSTANCE.getMessage_ReceiveEvent().equals(feature) || UMLPackage.eINSTANCE.getDurationObservation_Event().equals(feature);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/InteractionUseCustomParsers.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/InteractionUseCustomParsers.java
deleted file mode 100644
index 0eb25997237..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/InteractionUseCustomParsers.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionUse;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for the InteractionUse. This parser of refreshing the text displayed by the
- * InteractionUse.
- */
-public class InteractionUseCustomParsers extends MessageFormatParser implements ISemanticParser {
-
- public InteractionUseCustomParsers(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public InteractionUseCustomParsers(EAttribute[] features) {
- super(features);
- }
-
- public InteractionUseCustomParsers() {
- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if(notification instanceof Notification) {
- Object feature = ((Notification)notification).getFeature();
- if(feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature)feature;
-
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent(java.lang.Object
- * , int)
- */
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#getPrintString(org.eclipse
- * .core.runtime.IAdaptable, int)
- */
- public String getPrintString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- StringBuffer sb = new StringBuffer();
-
- if(obj instanceof InteractionUse) {
- InteractionUse interactionUse = (InteractionUse)obj;
- Interaction interaction = interactionUse.getRefersTo();
-
- if(interaction != null) {
- String interactionName = interaction.getName();
- if(interactionName != null) {
- sb.append(interaction.getName());
- }
- }
- }
- return sb.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#areSemanticElementsAffected
- * (org.eclipse.emf.ecore.EObject, java.lang.Object)
- */
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#getSemanticElementsBeingParsed
- * (org.eclipse.emf.ecore.EObject)
- */
- public List getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if(element instanceof InteractionUse) {
- InteractionUse interactionUse = (InteractionUse)element;
- semanticElementsBeingParsed.add(interactionUse);
-
- Interaction interaction = interactionUse.getRefersTo();
- if(interaction != null) {
- // Add the interaction refered.
- semanticElementsBeingParsed.add(interaction);
-
- // TODO : Collaboration and interactionUse
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getInteractionFragment_Covered().equals(feature) || UMLPackage.eINSTANCE.getInteractionUse_RefersTo().equals(feature);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/LifelineCustomParsers.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/LifelineCustomParsers.java
deleted file mode 100644
index e4ad3e6508e..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/LifelineCustomParsers.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
-import org.eclipse.uml2.uml.ConnectableElement;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Expression;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.LiteralSpecification;
-import org.eclipse.uml2.uml.OpaqueExpression;
-import org.eclipse.uml2.uml.PartDecomposition;
-import org.eclipse.uml2.uml.TimeExpression;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-/**
- * A specific parser for the Lifeline header. This parser of refreshing the text displayed by the
- * lifeline.
- */
-public class LifelineCustomParsers extends MessageFormatParser implements ISemanticParser {
-
- public LifelineCustomParsers(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public LifelineCustomParsers(EAttribute[] features) {
- super(features);
- }
-
- public LifelineCustomParsers() {
- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if(notification instanceof Notification) {
- Object feature = ((Notification)notification).getFeature();
- if(feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature)feature;
- }
- }
- return featureImpl;
- }
-
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /**
- * Information identifying the lifeline displayed inside the rectangle
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#getPrintString(org.eclipse.core.runtime.IAdaptable, int)
- */
- public String getPrintString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- StringBuffer sb = new StringBuffer();
-
- if(obj instanceof Lifeline) {
- Lifeline lifeline = (Lifeline)obj;
- ConnectableElement connectableElement = lifeline.getRepresents();
- ValueSpecification selector = lifeline.getSelector();
-
- if(connectableElement != null) {
- // Add ConnectableElement Name
- String connectableElementName = connectableElement.getName();
- if(connectableElementName != null) {
- sb.append(connectableElementName);
- }
-
- // Add the selector if it is a LiteralSpecification
- if(selector instanceof LiteralSpecification) {
- sb.append("[").append(ValueSpecificationUtil.getSpecificationValue(selector)).append("]");
- }
-
- // Add the type name
- Type type = connectableElement.getType();
- if(type != null && type.getName() != null && type.getName().length() > 0) {
- sb.append(" : ").append(type.getName());
- }
- }
-
- // Add the selector if it is an Expression
- if(selector instanceof Expression || selector instanceof OpaqueExpression || selector instanceof TimeExpression) {
- String specificationValue = ValueSpecificationUtil.getSpecificationValue(selector);
- if(specificationValue != null && specificationValue.length() > 0) {
- sb.append("\n").append(specificationValue);
- }
- }
-
- // Add the decomposition
- PartDecomposition partDecomposition = lifeline.getDecomposedAs();
- if(partDecomposition != null) {
- Interaction refersTo = partDecomposition.getRefersTo();
- if(refersTo != null) {
- sb.append("\nref ").append(refersTo.getName());
- }
- }
-
- // LifelineIndent cannot be empty so if the stringBuffer is empty we add the name of the
- // lifeline
- // This case occurs when creating the lifeline for example
- if(sb.length() == 0) {
- sb.append(lifeline.getName());
- }
- }
-
- return sb.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#areSemanticElementsAffected
- * (org.eclipse.emf.ecore.EObject, java.lang.Object)
- */
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#getSemanticElementsBeingParsed
- * (org.eclipse.emf.ecore.EObject)
- */
- public List getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if(element instanceof Lifeline) {
- Lifeline lifeline = (Lifeline)element;
-
- // Add the lifeline
- semanticElementsBeingParsed.add(lifeline);
- // Add the selector
- if(lifeline.getSelector() != null) {
- semanticElementsBeingParsed.add(lifeline.getSelector());
- }
-
- // Add the partDecomposition
- PartDecomposition partDecomposition = lifeline.getDecomposedAs();
- if(partDecomposition != null) {
- semanticElementsBeingParsed.add(partDecomposition);
- // Add the Interaction refered by the partDecomposition
- if(partDecomposition.getRefersTo() != null) {
- semanticElementsBeingParsed.add(partDecomposition.getRefersTo());
- }
- }
-
- // Add the connectableElement and its type if it has any
- ConnectableElement connectableElement = lifeline.getRepresents();
- if(connectableElement != null) {
- semanticElementsBeingParsed.add(connectableElement);
- if(connectableElement.getType() != null) {
- semanticElementsBeingParsed.add(connectableElement.getType());
- }
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getLiteralInteger_Value().equals(feature) || UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value().equals(feature) || UMLPackage.eINSTANCE.getLiteralBoolean_Value().equals(feature) || UMLPackage.eINSTANCE.getLiteralString_Value().equals(feature) || UMLPackage.eINSTANCE.getOpaqueExpression_Body().equals(feature) || UMLPackage.eINSTANCE.getLifeline_Selector().equals(feature) || UMLPackage.eINSTANCE.getLifeline_DecomposedAs().equals(feature) || UMLPackage.eINSTANCE.getLifeline_Represents().equals(feature) || UMLPackage.eINSTANCE.getInteractionUse_RefersTo().equals(feature);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java
deleted file mode 100644
index 4272425d703..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
-import org.eclipse.papyrus.uml.tools.utils.OperationUtil;
-import org.eclipse.papyrus.uml.tools.utils.SignalUtil;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageSort;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Signal;
-import org.eclipse.uml2.uml.UMLPackage;
-
-public class MessageCustomParser extends MessageFormatParser implements ISemanticParser {
-
- public MessageCustomParser(EAttribute[] features) {
- super(features);
- }
-
- public MessageCustomParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public MessageCustomParser() {
- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- @Override
- public String getPrintString(IAdaptable adapter, int flags) {
- Object obj = adapter.getAdapter(EObject.class);
- String result = null;
-
- if(obj instanceof Message) {
- Message message = (Message)obj;
- NamedElement signature = message.getSignature();
-
- if(signature instanceof Operation) {
- Operation operation = (Operation)signature;
- if(MessageSort.REPLY_LITERAL.equals(message.getMessageSort())) {
- result = OperationUtil.getCustomLabel(operation, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_RT_TYPE);
- } else if(MessageSort.SYNCH_CALL_LITERAL.equals(message.getMessageSort())) {
- result = OperationUtil.getCustomLabel(operation, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_PARAMETER_NAME | ICustomAppearence.DISP_PARAMETER_TYPE);
- } else {
- result = OperationUtil.getCustomLabel(operation, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_PARAMETER_NAME | ICustomAppearence.DISP_PARAMETER_TYPE | ICustomAppearence.DISP_RT_TYPE);
- }
- } else if(signature instanceof Signal) {
- result = SignalUtil.getCustomLabel((Signal)signature, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_TYPE);
- } else if(signature != null) {
- result = signature.getName();
- }
-
- // If the String is empty, we add the name of the message
- if(result == null || result.equals("")) {
- result = message.getName();
- }
- }
-
- return result;
- }
-
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- return true;
- }
-
- public List getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if(element instanceof Message) {
- Message message = (Message)element;
- semanticElementsBeingParsed.add(message);
- NamedElement signature = message.getSignature();
- semanticElementsBeingParsed.add(signature);
-
- if(signature instanceof Operation) {
- for(Parameter parameter : ((Operation)signature).getOwnedParameters()) {
- semanticElementsBeingParsed.add(parameter);
- }
- }
- if(signature instanceof Signal) {
- for(Property property : ((Signal)signature).getOwnedAttributes()) {
- semanticElementsBeingParsed.add(property);
- }
- }
-
- }
- return semanticElementsBeingParsed;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeConstraintParser.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeConstraintParser.java
deleted file mode 100644
index 3a168c29ec6..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeConstraintParser.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Duration;
-import org.eclipse.uml2.uml.DurationConstraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Interval;
-import org.eclipse.uml2.uml.LiteralInteger;
-import org.eclipse.uml2.uml.LiteralString;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.TimeConstraint;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-
-/**
- * Specific Parser for the TimeConstraint and DurationConstraint.
- */
-public class TimeConstraintParser extends MessageFormatParser implements ISemanticParser {
-
- /** The String for displaying a line break */
- private static final String LINE_BREAK = System.getProperty("line.separator");
-
- /** The format for displaying time constraint text */
- private static final String FORMAT = "{%s}";
-
- public TimeConstraintParser() {
- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- public TimeConstraintParser(EAttribute[] features) {
- super(features);
- }
-
- public TimeConstraintParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- /**
- * Gets the e structural feature.
- *
- * @param notification
- * @return the structural feature
- */
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if(notification instanceof Notification) {
- Object feature = ((Notification)notification).getFeature();
- if(feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature)feature;
- }
- }
- return featureImpl;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPrintString(IAdaptable element, int flags) {
- Object adapter = element.getAdapter(EObject.class);
- if(adapter instanceof TimeConstraint) {
- TimeConstraint constraint = (TimeConstraint)adapter;
- ValueSpecification spec = constraint.getSpecification();
- return String.format(FORMAT, ValueSpecificationUtil.getSpecificationValue(spec));
- } else if(adapter instanceof DurationConstraint) {
- String value = getDurationConstraint((DurationConstraint)adapter);
- return String.format(FORMAT, value);
- } else if(adapter instanceof Message) {
- StringBuffer result = new StringBuffer();
- Message message = (Message)adapter;
- MessageEnd event1 = message.getSendEvent();
- MessageEnd event2 = message.getReceiveEvent();
- List<DurationConstraint> constraints = DurationConstraintHelper.getDurationConstraintsBetween(event1, event2);
- for(DurationConstraint constraint : constraints) {
- if(result.length() > 0) {
- result.append(LINE_BREAK);
- }
- ValueSpecification spec = constraint.getSpecification();
- result.append(String.format(FORMAT, ValueSpecificationUtil.getSpecificationValue(spec)));
- }
- return result.toString();
- }
- return "";
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public List getSemanticElementsBeingParsed(EObject element) {
- HashSet<Element> semanticElementsBeingParsed = new HashSet<Element>();
- if(element instanceof Constraint) {
- Constraint constraint = (Constraint)element;
- ValueSpecificationUtil.addEnclosedValueSpecificationToCollection(constraint.getSpecification(), semanticElementsBeingParsed);
- } else if(element instanceof Message) {
- Message message = (Message)element;
- semanticElementsBeingParsed.add(message);
- MessageEnd event1 = message.getSendEvent();
- semanticElementsBeingParsed.add(event1);
- MessageEnd event2 = message.getReceiveEvent();
- semanticElementsBeingParsed.add(event2);
- List<DurationConstraint> constraints = DurationConstraintHelper.getDurationConstraintsBetween(event1, event2);
- for(DurationConstraint constraint : constraints) {
- semanticElementsBeingParsed.add(constraint);
- // owner for listening DurationConstraint deletion
- semanticElementsBeingParsed.add(constraint.getOwner());
- }
- }
- return new ArrayList(semanticElementsBeingParsed);
- }
-
- /**
- * Determines if the given feature has to be taken into account in this parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getConstraint_Specification().equals(feature) || ValueSpecification.class.isAssignableFrom(feature.getContainerClass());
- }
-
- @Override
- public String getEditString(IAdaptable adapter, int flags) {
- EObject element = (EObject)adapter.getAdapter(EObject.class);
- if(element instanceof DurationConstraint) {
- return getDurationConstraint((DurationConstraint)element);
- }
- return super.getEditString(adapter, flags);
- }
-
- protected String getDurationConstraint(DurationConstraint constraint) {
- ValueSpecification spec = constraint.getSpecification();
- if(spec instanceof Interval){
- Interval interval = (Interval)spec;
- String min = ValueSpecificationUtil.getSpecificationValue(interval.getMin());
- String max = ValueSpecificationUtil.getSpecificationValue(interval.getMax());
- if(min.equals(max))
- return min;
- }
- String value = ValueSpecificationUtil.getSpecificationValue(spec);
- return value;
- }
-
- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
- EObject element = (EObject)adapter.getAdapter(EObject.class);
- if(element instanceof DurationConstraint){
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
- if(editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- Object[] values = parseInterval(newString);
- if(values == null || values.length != 2) {
- return UnexecutableCommand.INSTANCE;
- }
- return new UpdateDurationConstraintCommand(editingDomain, (DurationConstraint)element, values[0], values[1] );
- }
- return super.getParseCommand(adapter, newString, flags);
- }
-
- private Object[] parseInterval(String newString) {
- int pos = newString.indexOf("..");
- if(pos > -1){
- String[] part = {newString.substring(0, pos), newString.substring(pos + 2)};
- try {
- int min = Integer.parseInt( part[0].trim());
- int max = Integer.parseInt( part[1].trim());
- return new Integer[]{min, max};
- } catch (Exception e) {
- }
- return part;
- }else{
- try {
- int value = Integer.parseInt(newString);
- return new Integer[]{value, value};
- } catch (Exception e) {
- }
-
- // same value for min and max
- return new String[]{newString, newString};
- }
- }
-
- static class UpdateDurationConstraintCommand extends AbstractTransactionalCommand {
- private DurationConstraint constraint;
- private Object min;
- private Object max;
-
- public UpdateDurationConstraintCommand(TransactionalEditingDomain domain, DurationConstraint constraint, Object min, Object max) {
- super(domain, "Set Values", null);
- this.constraint = constraint;
- this.min = min;
- this.max = max;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ValueSpecification spec = constraint.getSpecification();
- if(spec instanceof Interval){
- Interval interval = (Interval)spec;
- setValue(interval.getMin(), min );
- setValue(interval.getMax(), max );
- }
- return CommandResult.newOKCommandResult();
- }
-
- private void setValue(ValueSpecification spec, Object val) {
- if(spec instanceof Duration){
- Duration dur = (Duration)spec;
- if( dur.getExpr() instanceof LiteralInteger && val instanceof Integer){
- ((LiteralInteger)dur.getExpr()).setValue((Integer)val);
- }else{
- LiteralString str = UMLFactory.eINSTANCE.createLiteralString();
- str.setValue(val.toString());
- dur.setExpr(str);
- }
- }
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeObservationParser.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeObservationParser.java
deleted file mode 100644
index 90ea480b526..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/TimeObservationParser.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.TimeObservation;
-import org.eclipse.uml2.uml.UMLPackage;
-
-
-/**
- * Specific Parser for the TimeObservation.
- */
-public class TimeObservationParser extends MessageFormatParser implements ISemanticParser {
-
- /** The String for displaying a time observation */
- private static final String FORMAT = "@%s";
-
- public TimeObservationParser() {
- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- public TimeObservationParser(EAttribute[] features) {
- super(features);
- }
-
- public TimeObservationParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- /**
- * Gets the e structural feature.
- *
- * @param notification
- * @return the structural feature
- */
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if(notification instanceof Notification) {
- Object feature = ((Notification)notification).getFeature();
- if(feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature)feature;
- }
- }
- return featureImpl;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPrintString(IAdaptable element, int flags) {
- StringBuffer result = new StringBuffer();
- Object adapter = element.getAdapter(EObject.class);
- if(adapter instanceof TimeObservation) {
- TimeObservation observation = (TimeObservation)adapter;
- if(observation.getName() != null) {
- return String.format(FORMAT, observation.getName());
- }
- }
- return result.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public List getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if(element instanceof TimeObservation) {
- semanticElementsBeingParsed.add((TimeObservation)element);
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java
deleted file mode 100644
index 27ad7cf233e..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.providers;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.HighlightConnectionPartEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-
-/**
- * this is an editpolicy provider in charge to install a policy to navigate between diagrams and elements
- *
- */
-public class CustomEditPolicyProvider implements IEditPolicyProvider {
-
- /**
- *
- * {@inheritDoc}
- */
- public void addProviderChangeListener(IProviderChangeListener listener) {
-
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public void createEditPolicies(final EditPart editPart) {
-
- installPopupbarPolicy(editPart);
- installHighlightPolicy(editPart);
-
- SequenceUtil.installObservationLinkPolicy(editPart);
- }
-
- private void installHighlightPolicy(EditPart editPart) {
- if(editPart instanceof LifelineEditPart || editPart instanceof AbstractExecutionSpecificationEditPart || editPart instanceof CombinedFragmentEditPart || editPart instanceof InteractionOperandEditPart || editPart instanceof ConstraintEditPart || editPart instanceof CommentEditPart) {
- editPart.installEditPolicy("highlight", new HighlightConnectionPartEditPolicy());
- }
- }
-
- private void installPopupbarPolicy(final EditPart editPart) {
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public boolean provides(IOperation operation) {
- CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation)operation;
- if(!(epOperation.getEditPart() instanceof GraphicalEditPart)) {
- return false;
- }
- GraphicalEditPart gep = (GraphicalEditPart)epOperation.getEditPart();
- String diagramType = gep.getNotationView().getDiagram().getType();
- if(PackageEditPart.MODEL_ID.equals(diagramType)) {
- return true;
- }
-
-
- return false;
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public void removeProviderChangeListener(IProviderChangeListener listener) {
-
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java
deleted file mode 100644
index 5bf7085774f..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.service;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.draw2d.Viewport;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartListener;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gef.NodeEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.SharedCursors;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gef.tools.TargetingTool;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper;
-import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-
-public class DurationCreationTool extends AspectUnspecifiedTypeCreationTool {
-
-
- static private Cursor CURSOR_TARGET_MENU = new Cursor(Display.getDefault(), SWT.CURSOR_HAND);
-
- /**
- * The state which indicates that the duration creation has begun. This means that the
- * source of the duration has been identified, and the user is still to determine the
- * target.
- */
- protected static final int STATE_CONNECTION_STARTED = TargetingTool.MAX_STATE << 1;
-
- /**
- * The flag which indicates that feedback figure must be shown
- */
- private static final int FLAG_SOURCE_FEEDBACK = TargetingTool.MAX_FLAG << 1;
-
- /**
- * The max state.
- */
- protected static final int MAX_STATE = STATE_CONNECTION_STARTED;
-
- /**
- * The max flag.
- */
- protected static final int MAX_FLAG = FLAG_SOURCE_FEEDBACK;
-
- /**
- * The first element constrained by the duration constraint
- */
- private EditPart connectionSource;
-
- /**
- * The viewer
- */
- private EditPartViewer viewer;
-
- /**
- * Listener for the edit part deactivation
- */
- private EditPartListener.Stub deactivationListener = new EditPartListener.Stub() {
-
- public void partDeactivated(EditPart editpart) {
- handleSourceDeactivated();
- }
- };
-
- /**
- * Constructor of the creation tool.
- *
- * @param elementTypes
- * element types the tool can create
- */
- public DurationCreationTool(List<IElementType> elementTypes) {
- super(elementTypes);
- setDefaultCursor(SharedCursors.CURSOR_PLUG);
- setDisabledCursor(SharedCursors.CURSOR_PLUG_NOT);
- }
-
- /**
- * @see org.eclipse.gef.tools.AbstractTool#handleDrag()
- */
- protected boolean handleDrag() {
- if(isInState(STATE_CONNECTION_STARTED))
- return handleMove();
- return false;
- }
-
- /**
- * @see org.eclipse.gef.tools.AbstractTool#handleDragInProgress()
- */
- protected boolean handleDragInProgress() {
- if(isInState(STATE_ACCESSIBLE_DRAG_IN_PROGRESS))
- return handleMove();
- return false;
- }
-
- /**
- * @see org.eclipse.gef.tools.AbstractTool#getDebugNameForState(int)
- */
- protected String getDebugNameForState(int s) {
- if(s == STATE_CONNECTION_STARTED || s == STATE_ACCESSIBLE_DRAG_IN_PROGRESS)
- return "Connection Started";//$NON-NLS-1$
- return super.getDebugNameForState(s);
- }
-
- /**
- * Sets the location of the request.
- *
- * @see org.eclipse.gef.tools.TargetingTool#updateTargetRequest()
- */
- protected void updateTargetRequest() {
- CreateRequest req = getCreateRequest();
- req.setLocation(getLocation());
- }
-
- /**
- * Sets the target request. This method is typically not called; subclasses normally override {@link #createTargetRequest()}.
- *
- * @see org.eclipse.gef.tools.TargetingTool#setTargetRequest(org.eclipse.gef.Request)
- * @param req
- * the target request
- */
- @Override
- protected void setTargetRequest(Request req) {
- if(req == null && connectionSource != null) {
- // do not erase the request when target changes (behavior inherited from CreationTool)
- return;
- }
- super.setTargetRequest(req);
- }
-
- /**
- * Called if the source editpart is deactivated for some reason during the creation
- * process. For example, the user performs an Undo while in the middle of creating a
- * connection, which undoes a prior command which created the source.
- */
- protected void handleSourceDeactivated() {
- setState(STATE_INVALID);
- handleInvalidInput();
- handleFinished();
- }
-
- /**
- * Method that is called when the gesture to create the connection has been received.
- * Subclasses may extend or override this method to do additional creation setup, such as
- * prompting the user to choose an option about the connection being created. Returns <code>true</code> to indicate that the connection creation
- * succeeded.
- *
- * @return <code>true</code> if the connection creation was performed
- */
- protected boolean handleCreateConnection() {
- eraseSourceFeedback();
- Command endCommand = getCommand();
- setCurrentCommand(endCommand);
- executeCurrentCommand();
- return true;
- }
-
- /**
- * @see org.eclipse.gef.tools.TargetingTool#handleInvalidInput()
- */
- protected boolean handleInvalidInput() {
- eraseSourceFeedback();
- setConnectionSource(null);
- return super.handleInvalidInput();
- }
-
- /**
- * When the button is first pressed, the source node and its command contribution are
- * determined and locked in. After that time, the tool will be looking for the target
- * node to complete the connection
- *
- * @see org.eclipse.gef.tools.AbstractTool#handleButtonDown(int)
- * @param button
- * which button is pressed
- * @return <code>true</code> if the button down was processed
- */
- protected boolean handleButtonDown(int button) {
- if(button == 1 && stateTransition(STATE_CONNECTION_STARTED, STATE_TERMINAL)) {
- return handleCreateConnection();
- }
- if(isInState(STATE_INITIAL) && button == 1) {
- updateTargetRequest();
- updateTargetUnderMouse();
- setConnectionSource(getTargetEditPart());
- Command command = getCommand();
- Request request = getTargetRequest();
- //target elements of request have been set
- if(command != null) {
- setState(STATE_CONNECTION_STARTED);
- setCurrentCommand(command);
- viewer = getCurrentViewer();
- // update request : initialize required extended data
- Map extendedData = request.getExtendedData();
- extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2, null);
- extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2, null);
- }
- }
- if(isInState(STATE_INITIAL) && button != 1) {
- setState(STATE_INVALID);
- handleInvalidInput();
- }
- if(isInState(STATE_CONNECTION_STARTED))
- //Fake a drag to cause feedback to be displayed immediately on mouse down.
- handleDrag();
- return true;
- }
-
- /**
- * @see org.eclipse.gef.tools.AbstractTool#handleMove()
- */
- protected boolean handleMove() {
- if(isInState(STATE_CONNECTION_STARTED) && viewer != getCurrentViewer())
- return false;
- if(isInState(STATE_CONNECTION_STARTED | STATE_INITIAL | STATE_ACCESSIBLE_DRAG_IN_PROGRESS)) {
- updateTargetRequest();
- updateTargetUnderMouse();
- showSourceFeedback();
- showTargetFeedback();
- setCurrentCommand(getCommand());
- }
- if(isInState(STATE_CONNECTION_STARTED)) {
- // Expose the diagram as the user scrolls in the area handled by the
- // autoexpose helper.
- updateAutoexposeHelper();
- }
- return true;
- }
-
- /**
- * Sets the source editpart for the creation
- *
- * @param source
- * the source editpart node
- */
- protected void setConnectionSource(EditPart source) {
- if(connectionSource != null) {
- connectionSource.removeEditPartListener(deactivationListener);
- }
- connectionSource = source;
- if(connectionSource != null) {
- connectionSource.addEditPartListener(deactivationListener);
- }
- }
-
- /**
- * Returns <code>true</code> if feedback is being shown.
- *
- * @return <code>true</code> if showing source feedback
- */
- protected boolean isShowingSourceFeedback() {
- return getFlag(FLAG_SOURCE_FEEDBACK);
- }
-
- /**
- * Asks the source editpart to erase connection creation feedback.
- */
- protected void eraseSourceFeedback() {
- if(!isShowingSourceFeedback())
- return;
- setFlag(FLAG_SOURCE_FEEDBACK, false);
- if(connectionSource != null) {
- connectionSource.eraseSourceFeedback(getSourceRequest());
- }
- }
-
- /**
- * Scrolling can happen either in the {@link AbstractTool#STATE_INITIAL initial} state or
- * once the source of the connection has been {@link AbstractConnectionCreationTool#STATE_CONNECTION_STARTED identified}.
- *
- * @see org.eclipse.gef.Tool#mouseWheelScrolled(org.eclipse.swt.widgets.Event, org.eclipse.gef.EditPartViewer)
- */
- public void mouseWheelScrolled(Event event, EditPartViewer viewer) {
- if(isInState(STATE_INITIAL | STATE_CONNECTION_STARTED))
- performViewerMouseWheel(event, viewer);
- }
-
- /**
- * Returns the request sent to the source node. The source node receives the same request
- * that is used with the target node. The only difference is that at that time the
- * request will be typed as {@link RequestConstants#REQ_CONNECTION_START}.
- *
- * @return the request used with the source node editpart
- */
- protected Request getSourceRequest() {
- return getTargetRequest();
- }
-
- /**
- * Sends a show feedback request to the source editpart and sets the feedback flag.
- */
- protected void showSourceFeedback() {
- if(connectionSource != null) {
- connectionSource.showSourceFeedback(getSourceRequest());
- }
- setFlag(FLAG_SOURCE_FEEDBACK, true);
- }
-
- /**
- * Unloads or resets the tool if the state is in the terminal or invalid state.
- *
- * @see org.eclipse.gef.tools.AbstractTool#handleButtonUp(int)
- */
- protected boolean handleButtonUp(int button) {
- if(isInState(STATE_CONNECTION_STARTED)) {
- handleCreateConnection();
- }
- setState(STATE_TERMINAL);
- if(isInState(STATE_TERMINAL | STATE_INVALID)) {
- handleFinished();
- }
- return true;
- }
-
- /**
- * @see org.eclipse.gef.tools.AbstractTool#handleCommandStackChanged()
- */
- protected boolean handleCommandStackChanged() {
- if(!isInState(STATE_INITIAL)) {
- if(getCurrentInput().isMouseButtonDown(1)) {
- setState(STATE_INVALID);
- } else {
- setState(STATE_INITIAL);
- }
- handleInvalidInput();
- return true;
- }
- return false;
- }
-
- /**
- * @see org.eclipse.gef.Tool#deactivate()
- */
- public void deactivate() {
- eraseSourceFeedback();
- setConnectionSource(null);
- super.deactivate();
- setState(STATE_TERMINAL);
- viewer = null;
- }
-
- /**
- * Calculate the cursor to display
- *
- * @see org.eclipse.gef.tools.AbstractConnectionCreationTool#calculateCursor()
- */
- protected Cursor calculateCursor() {
- if(isInState(STATE_CONNECTION_STARTED)) {
- // Give some feedback so the user knows the area where autoscrolling
- // will occur.
- if(getAutoexposeHelper() != null) {
- return SharedCursors.HAND;
- } else {
-
- // Give some feedback so the user knows that they can't drag
- // outside the viewport.
- if(getCurrentViewer() != null) {
- Control control = getCurrentViewer().getControl();
- if(control instanceof FigureCanvas) {
- Viewport viewport = ((FigureCanvas)control).getViewport();
- Rectangle rect = Rectangle.SINGLETON;
- viewport.getClientArea(rect);
- viewport.translateToParent(rect);
- viewport.translateToAbsolute(rect);
-
- if(!rect.contains(getLocation())) {
- return getDisabledCursor();
- }
- }
- }
- }
- }
- Command command = getCurrentCommand();
- if(command != null && command.canExecute()) {
- EditPart ep = getTargetEditPart();
- if(ep instanceof DiagramEditPart || ep instanceof CompartmentEditPart)
- return CURSOR_TARGET_MENU;
- }
- return super.calculateCursor();
- }
-
- /**
- * Get the command to execute
- *
- * @see org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool#getCommand()
- *
- * @return the command
- */
- @Override
- protected Command getCommand() {
- if(!antiScroll) {
- EditPart targetPart = getTargetEditPart();
- if(targetPart == null) {
- return null;
- }
- Request req = getTargetRequest();
- if(targetPart instanceof ConnectionNodeEditPart) {
- // a message part is targeted. Instead, we must take the nearby lifeline part.
- // redirect to the message part will be performed later in case we really want to draw a duration on a message
- ConnectionNodeEditPart conn = (ConnectionNodeEditPart)targetPart;
- EditPart source = ((ConnectionNodeEditPart)targetPart).getSource();
- EditPart target = ((ConnectionNodeEditPart)targetPart).getTarget();
- if(source instanceof NodeEditPart && target instanceof NodeEditPart) {
- ConnectionAnchor sourceAnch = ((NodeEditPart)source).getSourceConnectionAnchor(conn);
- ConnectionAnchor targetAnch = ((NodeEditPart)target).getSourceConnectionAnchor(conn);
- double sourceDist = getLocation().getDistance(sourceAnch.getReferencePoint());
- double targetDist = getLocation().getDistance(targetAnch.getReferencePoint());
- if(sourceDist > targetDist) {
- targetPart = target;
- } else {
- targetPart = source;
- }
- }
- }
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(targetPart);
- if(lifelinePart instanceof LifelineEditPart) {
- Object paramOcc1 = req.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION);
- List<OccurrenceSpecification> occ1List = SequenceUtil.getAsOccSpecList(paramOcc1);
- Object paramOcc2 = req.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2);
- List<OccurrenceSpecification> occ2List = SequenceUtil.getAsOccSpecList(paramOcc2);
- if(!occ1List.isEmpty() && !occ2List.isEmpty() && Collections.disjoint(occ1List, occ2List)) {
- OccurrenceSpecification[] pair = SequenceUtil.getPairOfCorrespondingOccSpec(occ1List, occ2List);
- if(pair != null && pair.length > 1) {
- OccurrenceSpecification occ1 = pair[0];
- OccurrenceSpecification occ2 = pair[1];
- if(DurationConstraintHelper.endsOfSameMessage(occ1, occ2)) {
- // call request on the link
- EditPart part = SequenceUtil.getLinkedEditPart(lifelinePart, occ2);
- if(part != null) {
- return part.getCommand(req);
- }
- }
- }
- }
- }
- return targetPart.getCommand(req);
- }
- return null;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentDeleteHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentDeleteHelper.java
deleted file mode 100644
index 5ca5564929a..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentDeleteHelper.java
+++ /dev/null
@@ -1,323 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.PopupMenuCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.menus.PopupMenu;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.EditHelperContext;
-import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.Bounds;
-import org.eclipse.gmf.runtime.notation.Shape;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.CombinedFragment;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-
-public class CombinedFragmentDeleteHelper {
-
- public static class EditRequest extends AbstractEditCommandRequest {
-
- /** element to edit */
- private Element elementToEdit;
-
- public EditRequest(TransactionalEditingDomain editingDomain, Element elementToEdit) {
- super(editingDomain);
- this.elementToEdit = elementToEdit;
- }
-
- public Object getEditHelperContext() {
- IClientContext context = getClientContext();
-
- if(context == null) {
- return getElementToEdit();
- } else {
- return new EditHelperContext(getElementToEdit(), context);
- }
- }
-
- public Element getElementToEdit() {
- return elementToEdit;
- }
- }
-
- public static class MoveOperandFragmentsCommand extends EditElementCommand {
-
- private InteractionFragment parent;
-
- private EList<InteractionFragment> fragmentsToMove;
-
- private InteractionOperand sourceOperand;
-
- private CombinedFragment combinedFragment;
-
- private CombinedFragmentEditPart host;
-
- public MoveOperandFragmentsCommand(CombinedFragmentEditPart host, CombinedFragment cf, InteractionOperand op, EditRequest editRequest) {
- super(null, editRequest.getElementToEdit(), editRequest);
- InteractionOperand enclosingOp = cf.getEnclosingOperand();
- if(enclosingOp != null) {
- Element owner = enclosingOp.getOwner();
- if(owner instanceof CombinedFragment) {
- this.parent = enclosingOp;
- }
- } else {
- Element owner = cf.getOwner();
- if(owner instanceof Interaction) {
- this.parent = (InteractionFragment)owner;
- }
- }
- this.host = host;
- this.sourceOperand = op;
- this.combinedFragment = cf;
- fragmentsToMove = op.getFragments();
- }
-
- public boolean canExecute() {
- return (sourceOperand != null && combinedFragment != null);
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- if(parent != null && !fragmentsToMove.isEmpty()) {
- List<CombinedFragmentEditPart> parts = collectCombinedFragmentParts();
- if(parent instanceof InteractionOperand) {
- ((InteractionOperand)parent).getFragments().addAll(fragmentsToMove);
- moveToOperandPart((InteractionOperandEditPart)host.getParent(), parts);
- } else if(parent instanceof Interaction) {
- ((Interaction)parent).getFragments().addAll(fragmentsToMove);
- moveToInteractionPart((InteractionInteractionCompartmentEditPart)host.getParent(), parts);
- }
- }
- sourceOperand.getFragments().clear();
- return CommandResult.newOKCommandResult();
- }
-
- private void moveToOperandPart(GraphicalEditPart op, List<CombinedFragmentEditPart> keepParts) {
- if(!keepParts.isEmpty()) {
- Rectangle parentBounds = getAbsoluteBounds((AbstractGraphicalEditPart)op.getParent());
- for(CombinedFragmentEditPart cef : keepParts) {
- View view = cef.getNotationView();
- op.getNotationView().getPersistedChildren().add(view);
-
- Bounds bounds = (Bounds)((Shape)cef.getNotationView()).getLayoutConstraint();
- Rectangle absolute = getAbsoluteBounds(cef);
- bounds.setX(absolute.x() - parentBounds.x());
- bounds.setY(absolute.y() - parentBounds.y());
- }
- }
- }
-
- private void moveToInteractionPart(GraphicalEditPart op, List<CombinedFragmentEditPart> keepParts) {
- if(!keepParts.isEmpty()) {
- Rectangle b = getAbsoluteBounds(op);
- for(CombinedFragmentEditPart cef : keepParts) {
- View view = cef.getNotationView();
- op.getNotationView().getPersistedChildren().add(view);
- Bounds bounds = (Bounds)((Shape)cef.getNotationView()).getLayoutConstraint();
-
- Rectangle absolute = getAbsoluteBounds(cef);
- absolute.performTranslate(-b.x, -b.y);
-
- bounds.setX(absolute.x() - 5);
- bounds.setY(absolute.y() - 6);
- }
- }
- }
-
- private List<CombinedFragmentEditPart> collectCombinedFragmentParts() {
- List<CombinedFragmentEditPart> parts = new ArrayList<CombinedFragmentEditPart>();
- for(InteractionFragment f : fragmentsToMove) {
- if(f instanceof CombinedFragment) {
- EditPart p = findEditPartByModel(host, f);
- if(p instanceof CombinedFragmentEditPart)
- parts.add((CombinedFragmentEditPart)p);
- }
- }
- return parts;
- }
- }
-
- static public class SelectLabelProvider extends org.eclipse.jface.viewers.LabelProvider {
-
- public String getText(Object object) {
- return object.toString();
- }
-
- public Image getImage(Object object) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE);
- }
- }
-
- public static class SelectAndDeleteCommand extends PopupMenuCommand {
-
- private String choice;
-
- private CompositeTransactionalCommand deletaAllCommand;
-
- private CompositeTransactionalCommand keepCommand;
-
- private String[] labels;
-
- public SelectAndDeleteCommand(CompositeTransactionalCommand deletaAllCommand, CompositeTransactionalCommand keepCommand, String[] labels) {
- super("prompt for delete", Display.getCurrent().getActiveShell());
- PopupMenu popupMenu = new PopupMenu(Arrays.asList(labels), new SelectLabelProvider());
- setPopupMenu(popupMenu);
- this.labels = labels;
- this.deletaAllCommand = deletaAllCommand;
- this.keepCommand = keepCommand;
- }
-
- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) throws ExecutionException {
- CommandResult cmdResult = super.doExecuteWithResult(progressMonitor, info);
- if(!cmdResult.getStatus().isOK()) {
- return cmdResult;
- }
- this.choice = cmdResult.getReturnValue().toString();
- if(choice.contains(labels[0])) {
- deletaAllCommand.execute(progressMonitor, info);
- return deletaAllCommand.getCommandResult();
- } else {
- keepCommand.execute(progressMonitor, info);
- return keepCommand.getCommandResult();
- }
- }
-
- protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- if(choice.contains(labels[0])) {
- deletaAllCommand.undo(progressMonitor, info);
- return deletaAllCommand.getCommandResult();
- } else {
- keepCommand.undo(progressMonitor, info);
- return keepCommand.getCommandResult();
- }
- }
-
- protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- if(choice.contains(labels[0])) {
- deletaAllCommand.redo(progressMonitor, info);
- return deletaAllCommand.getCommandResult();
- } else {
- keepCommand.redo(progressMonitor, info);
- return keepCommand.getCommandResult();
- }
- }
- }
-
- static class DeleteCombinedFragmentCommand extends AbstractTransactionalCommand {
-
- private IElementEditService provider;
-
- private DestroyElementRequest req;
-
- public DeleteCombinedFragmentCommand(TransactionalEditingDomain domain, IElementEditService provider, DestroyElementRequest req) {
- super(domain, null, null);
- this.provider = provider;
- this.req = req;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ICommand deleteCommand = provider.getEditCommand(req);
- try {
- deleteCommand.execute(monitor, info);
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
- return CommandResult.newOKCommandResult();
- }
- }
-
-
- public static ICommand createDestroyElementCommand(CombinedFragment cf, TransactionalEditingDomain transactionalEditingDomain, IElementEditService provider, DestroyElementRequest req, ICommand deleteCommand, CombinedFragmentEditPart host) {
- CompositeTransactionalCommand deleteAll = new CompositeTransactionalCommand(transactionalEditingDomain, null);
- deleteAll.add(deleteCommand);
-
- CompositeTransactionalCommand deleteCfOnly = new CompositeTransactionalCommand(transactionalEditingDomain, null);
- {
- // remove children from operands and append to parent combined fragment
- for(InteractionOperand op : cf.getOperands()) {
- deleteCfOnly.add(new MoveOperandFragmentsCommand(host, cf, op, new EditRequest(transactionalEditingDomain, cf)));
- }
-
- deleteCfOnly.add(new DeleteCombinedFragmentCommand(transactionalEditingDomain, provider, req));
- }
- return new SelectAndDeleteCommand(deleteAll, deleteCfOnly, new String[]{ "Delete all", "Keep contents" });
- }
-
- public static ICommand createDeleteViewCommand(CombinedFragment cf, TransactionalEditingDomain transactionalEditingDomain, CombinedFragmentEditPart host) {
- CompositeTransactionalCommand deleteAll = new CompositeTransactionalCommand(transactionalEditingDomain, null);
- {
- // Get the elements associated with the CF
- List<Element> elements = SequenceUtil.getCombinedFragmentAssociatedElement(cf);
- // Create the delete view commands
- SequenceDeleteHelper.deleteView(deleteAll, elements, transactionalEditingDomain);
- }
-
- CompositeTransactionalCommand deleteCfOnly = new CompositeTransactionalCommand(transactionalEditingDomain, null);
- {
- // remove children from operands and append to parent combined fragment
- for(InteractionOperand op : cf.getOperands()) {
- deleteCfOnly.add(new MoveOperandFragmentsCommand(host, cf, op, new EditRequest(transactionalEditingDomain, cf)));
- }
-
- // delete operands from combined fragment
- for(Element element : cf.getOperands()) {
- SequenceDeleteHelper.deleteView(deleteCfOnly, element, transactionalEditingDomain);
- }
- }
- return new SelectAndDeleteCommand(deleteAll, deleteCfOnly, new String[]{ "Hide all", "Keep contents" });
- }
-
- static Rectangle getAbsoluteBounds(AbstractGraphicalEditPart part) {
- Rectangle b = part.getFigure().getBounds().getCopy();
- part.getFigure().translateToAbsolute(b);
- return b;
- }
-
- public static EditPart findEditPartByModel(EditPart part, EObject m) {
- List children = part.getChildren();
- if(children != null && children.size() > 0) {
- for(Object o : children) {
- EditPart p = (EditPart)o;
-
- Object model = p.getModel();
- if(model != null && model instanceof View && m.equals(((View)model).getElement()))
- return p;
-
- EditPart res = findEditPartByModel(p, m);
- if(res != null)
- return res;
- }
- }
- return null;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CommandHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CommandHelper.java
deleted file mode 100644
index d46c58acc6f..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CommandHelper.java
+++ /dev/null
@@ -1,1203 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.emf.transaction.RollbackException;
-import org.eclipse.emf.transaction.Transaction;
-import org.eclipse.emf.transaction.TransactionalCommandStack;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
-import org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl;
-import org.eclipse.gef.EditDomain;
-import org.eclipse.gef.Tool;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.uml.diagram.common.util.MessageDirection;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLPaletteFactory.AspectUnspecifiedTypeConnectionToolEx;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.ElementInitializers;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.uml2.uml.ActionExecutionSpecification;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.CombinedFragment;
-import org.eclipse.uml2.uml.ConnectableElement;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Event;
-import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.Gate;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-import org.eclipse.uml2.uml.InteractionOperatorKind;
-import org.eclipse.uml2.uml.InteractionUse;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.MessageSort;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Signal;
-import org.eclipse.uml2.uml.StateInvariant;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A helper class for the command.
- *
- */
-public class CommandHelper {
-
-
- /**
- * Title for dialog of no referenced interaction error
- */
- private static final String NO_REFERENCED_INTERACTION_DIALOG_TITLE = "No referenced interaction"; //$NON-NLS-1$
-
- /**
- * Message for dialog of no referenced interaction error
- */
- private static final String NO_REFERENCED_INTERACTION_DIALOG_MSG = "Couldn't had message if there isn't referenced interaction"; //$NON-NLS-1$
-
- /**
- * Message for wrong gate container type error
- */
- private static final String WRONG_GATE_CONTAINER_TYPE_ERROR_MSG = "Wrong element UML type for create a gate"; //$NON-NLS-1$
-
- /**
- * Title for dialog of choose actual gate
- */
- private static final String CHOOSE_GATE_DIALOG_TITLE = "Actual gates of the interaction use"; //$NON-NLS-1$
-
- /**
- * Message for dialog of choose actual gate
- */
- private static final String CHOOSE_GATE_DIALOG_MSG = "Choose the gate to attach the message"; //$NON-NLS-1$
-
-
-
- /**
- * Create a message on the given interaction. It only creates the message and not its messages end.
- *
- * @param interaction
- * the containing interaction
- * @param messageSort
- * the messageSort.
- * @return the created message
- */
- public static Message doCreateMessage(Interaction interaction, MessageSort messageSort, NamedElement signature) {
- Message message = interaction.createMessage(null);
-
- // Set the interaction that will contain the message
- message.setInteraction(interaction);
-
- // Set MessageSort
- message.setMessageSort(messageSort);
-
- String prefix = "";
-
- if(signature != null) {
- prefix = signature.getName() + "_";
- }
-
- ElementInitializers.init_NamedElement(message, prefix);
-
- if(signature != null) {
- message.setSignature(signature);
- }
-
- return message;
- }
-
- /**
- * Create message occurence specification
- *
- * @param interaction
- * The interaction
- * @param event
- * The event to attach
- * @return The message occurence specification
- */
- public static MessageOccurrenceSpecification doCreateMessageOccurrence(InteractionFragment fragment, Event event, Lifeline lifeline) {
-
- // Create the MOS
- MessageOccurrenceSpecification mos = UMLFactory.eINSTANCE.createMessageOccurrenceSpecification();
-
- // Configure the MOS
- doConfigureOccurenceSpecification(mos, event, fragment, lifeline);
-
- return mos;
- }
-
-
- /**
- * Create an ExecutionOccurrenceSpecification
- *
- * @param es
- * the ExecutionSpecification associated with this ExecutionOccurrenceSpecification.
- * @param event
- * the event associated with this OccurrenceSpecification. It must be of type ExecutionEvent.
- * @param fragment
- * the fragment enclosing this OccurenceSpecifcation. It must be an Interaction or an Operand.
- * @return the Execution Occurrence Specification
- */
- public static ExecutionOccurrenceSpecification doCreateExecutionOccurenceSpecification(ExecutionSpecification es, InteractionFragment fragment, Lifeline lifeline) {
-
- // Create the ExecutionOccurrenceSpecification
- ExecutionOccurrenceSpecification eos = UMLFactory.eINSTANCE.createExecutionOccurrenceSpecification();
-
- // Configure the EOS.
- // The event is an ExecutionEvent
- doConfigureOccurenceSpecification(eos, null, fragment, lifeline);
-
- // Set the executionSpecification of the ExecutionOccurrenceSpecification
- eos.setExecution(es);
-
- return eos;
- }
-
- /**
- * Configure an OccurrenceSpecification
- *
- * @param os
- * the occurrenceSpecification to configure
- * @param event
- * the event to associated with the {@link OccurrenceSpecification}
- * @param fragment
- * the fragment containing the {@link OccurrenceSpecification}. It can be an {@link Interaction} or an {@link InteractionOperand}
- * @param lifeline
- * the covered lifeline
- */
- private static void doConfigureOccurenceSpecification(OccurrenceSpecification os, Event event, InteractionFragment fragment, Lifeline lifeline) {
-
- // Set the Container of the OccurrenceSpecification
- if(fragment instanceof Interaction) {
- os.setEnclosingInteraction((Interaction)fragment);
- } else if(fragment instanceof InteractionOperand) {
- os.setEnclosingOperand((InteractionOperand)fragment);
- }
-
- // Set the covered lifeline
- os.getCovereds().add(lifeline);
-
- // Set the event of the OccurrenceSpecification
- //now it doesn't exist
- //os.setEvent(event);
-
- }
-
- /**
- * Attach an Interaction on a Lifeline
- *
- * @param lifeline
- * The lifeline
- * @param fragment
- * The interaction fragment
- */
- public static void setSingleCovered(Lifeline lifeline, InteractionFragment fragment) {
- if(!fragment.getCovereds().contains(lifeline)) {
- fragment.getCovereds().add(lifeline);
- }
- }
-
-
-
- /**
- * Get the signature of the message. Opens a dialog box to select a signature.
- *
- * @param model
- * The model
- * @param source
- * The source of the message
- * @param target
- * The target of the message
- * @return null, if cancel has been pressed. An empty list if the null Element has been
- * selected, or a list with the selected element.
- */
- public static List<NamedElement> getSignature(Element model, Element source, Element target) {
- return getSignature(model, source, target, null);
- }
-
- /**
- * Get the signature of the message. Opens a dialog box to select a signature. Inputs depends on
- * the messageSort, if any.
- *
- * @param model
- * The model
- * @param source
- * The source of the message
- * @param target
- * The target of the message
- * @param messageSort
- * true if message sort is set
- * @return null, if cancel has been pressed. An empty list if the null Element has been
- * selected, or a list with the selected element.
- */
- public static List<NamedElement> getSignature(Element model, Element source, Element target, MessageSort messageSort) {
-
- // element where to look for parents
- Element parentsOwner = target;
-
- // default values
- // used for asynch message where messageSort = null
- boolean useOperations = true;
- boolean useSignals = true;
-
- // according to the type of the message
- // choose which types we should care of
- if(MessageSort.SYNCH_CALL_LITERAL.equals(messageSort)) {
- useSignals = false;
- } else if(MessageSort.CREATE_MESSAGE_LITERAL.equals(messageSort) || MessageSort.DELETE_MESSAGE_LITERAL.equals(messageSort)) {
- useOperations = false;
- } else if(MessageSort.REPLY_LITERAL.equals(messageSort)) {
- parentsOwner = source;
- useSignals = false;
- }
-
- LinkedHashMap<EClass, List<EObject>> mapTypesPossibleParents = new LinkedHashMap<EClass, List<EObject>>();
-
- if(useSignals) {
- mapTypesPossibleParents.put(UMLPackage.eINSTANCE.getSignal(), new LinkedList<EObject>());
- }
- if(useOperations) {
- mapTypesPossibleParents.put(UMLPackage.eINSTANCE.getOperation(), new LinkedList<EObject>());
- }
-
- // add the parents we can find
- boolean existingParent = false;
- List<Type> types = new ArrayList<Type>();
- if(parentsOwner instanceof InteractionFragment) {
- EList<Lifeline> lifelines = ((InteractionFragment)parentsOwner).getCovereds();
- for(Lifeline l : lifelines) {
- if(l.getRepresents() != null && l.getRepresents().getType() != null) {
- types.add(l.getRepresents().getType());
- }
- boolean result = addParentsFromLifeline(l, mapTypesPossibleParents);
- if(result) {
- existingParent = true;
- }
- }
- } else if(parentsOwner instanceof Lifeline) {
- Lifeline l = (Lifeline)parentsOwner;
- if(l.getRepresents() != null && l.getRepresents().getType() != null) {
- types.add(l.getRepresents().getType());
- }
- existingParent = addParentsFromLifeline(l, mapTypesPossibleParents);
- }
-
-
- // if no parent available => no signature
- if(!existingParent) {
- return new ArrayList<NamedElement>();
- }
-
- Set<EObject> existingElements = getExistingElementsFromParents(mapTypesPossibleParents);
-
- // fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=383420, remove connection feedbacks before opening dialog
- clearConnectionFeedback();
-
- TransactionalEditingDomain editingDomain;
- try {
- editingDomain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(model);
- } catch (ServiceException ex) {
- UMLDiagramEditorPlugin.log.error(ex);
- return Collections.<NamedElement> emptyList();
- }
-
- // Open the selection dialog
- SelectOrCreateDialog dialog = new SelectOrCreateDialog(Display.getCurrent().getActiveShell(), Messages.CommandHelper_CreateMessage, createTypeLabelProvider(), new AdapterFactoryLabelProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()), editingDomain, existingElements, mapTypesPossibleParents, types);
-
- // Get the selected result
- if(dialog.open() == Window.OK) {
- // list to return
- List<NamedElement> returnElements = new ArrayList<NamedElement>();
- EObject element = dialog.getSelected();
- if(element instanceof NamedElement) {
-
- returnElements.add((NamedElement)element);
- return returnElements;
- }
- return returnElements;
- }
-
- return null;
- }
-
- private static void clearConnectionFeedback() {
- AspectUnspecifiedTypeConnectionToolEx conTool = null;
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if(editor instanceof CoreMultiDiagramEditor) {
- editor = ((CoreMultiDiagramEditor)editor).getActiveEditor();
- if(editor instanceof DiagramEditor) {
- DiagramEditor de = (DiagramEditor)editor;
- DiagramEditPart diagramEP = de.getDiagramEditPart();
- EditDomain domain = diagramEP.getRoot().getViewer().getEditDomain();
- Tool tool = domain.getActiveTool();
- if(tool instanceof AspectUnspecifiedTypeConnectionToolEx) {
- conTool = (AspectUnspecifiedTypeConnectionToolEx)tool;
- conTool.clearConnectionFeedback();
- }
- }
- }
- }
-
- /**
- * find the existing elements from the possible parents
- *
- * @param mapTypesPossibleParents
- * map of list containing the possible parents
- * @return
- */
- private static Set<EObject> getExistingElementsFromParents(Map<EClass, List<EObject>> mapTypesPossibleParents) {
- // find the existing elements using the parents we just found
- Set<EObject> existingElements = new HashSet<EObject>();
- for(EClass eClass : mapTypesPossibleParents.keySet()) {
- List<EObject> parents = mapTypesPossibleParents.get(eClass);
- for(EObject parent : parents) {
- if(parent instanceof Classifier) {
- existingElements.addAll(((Classifier)parent).getAllOperations());
-
- // add operations from port
- EList<Property> attrs = ((Classifier)parent).getAllAttributes();
- for(Property p : attrs) {
- if(p instanceof Port && p.getType() instanceof Classifier) {
- existingElements.addAll(((Classifier)p.getType()).getAllOperations());
- }
- }
-
- } else if(parent instanceof Package) {
- EList<Element> ownedElements = ((Package)parent).allOwnedElements();
- for(Element e : ownedElements) {
- if(e instanceof Signal) {
- existingElements.add(e);
- }
- }
- }
- }
- }
- return existingElements;
- }
-
- /**
- * Create a specific label provider for types
- * which remove everything after the first space
- *
- * @return the label provider
- */
- private static AdapterFactoryLabelProvider createTypeLabelProvider() {
- AdapterFactoryLabelProvider typeLabelProvider = new AdapterFactoryLabelProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()) {
-
- @Override
- public String getText(Object object) {
- // remove the supertypes from the label
- // => keep only the first word
- String text = super.getText(object);
- int index = text.indexOf(" "); //$NON-NLS-1$
- if(index != -1) {
- text = text.substring(0, index);
- }
- return text;
- }
- };
- return typeLabelProvider;
- }
-
- /**
- * add to the map the possible parents (classes, packages)
- * founded "in" the lifeline
- *
- * @param l
- * The lifeline where to look for possible parents
- * @param mapTypesPossibleParents
- * The map where to store this parents
- * @return true if at least one parent was added
- */
- private static boolean addParentsFromLifeline(Lifeline l, Map<EClass, List<EObject>> mapTypesPossibleParents) {
- ConnectableElement e = l.getRepresents();
-
- boolean existingParent = false;
-
- // If there is no connectable element (ie : lifeline doesn't have a represents property yet)
- if(e == null) {
- return false;
- }
-
- Type type = e.getType();
- if(type == null) {
- return false;
- }
-
- // the classes are related to operation
- List<EObject> possibleClassifier = mapTypesPossibleParents.get(UMLPackage.eINSTANCE.getOperation());
- if(possibleClassifier != null) {
- if(type instanceof Classifier) {
- Classifier classifier = (Classifier)type;
- possibleClassifier.add(classifier);
-
- // add the supertypes of the class
- possibleClassifier.addAll(classifier.allParents());
- existingParent = true;
- }
- }
-
- // and the packages to signal
- List<EObject> possiblePackages = mapTypesPossibleParents.get(UMLPackage.eINSTANCE.getSignal());
- if(possiblePackages != null && type.getPackage() != null) {
- Package package_ = type.getPackage();
- possiblePackages.add(package_);
- // add the owners of the package
- possiblePackages.addAll(package_.allOwningPackages());
- existingParent = true;
- }
-
- return existingParent;
- }
-
- /**
- * Get the signature of the message. Opens a dialog box to select a signature. Inputs depends on
- * the messageSort, if any.
- *
- * @param availableProperties
- * list of available properties
- * @return null, if cancel has been pressed. An empty list if the null Element has been
- * selected, or a list with the selected element.
- */
- public static Property getProperties(List<Property> availableProperties) {
-
- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(Display.getCurrent().getActiveShell(), labelProvider);
- dialog.setTitle("Property Selection"); //$NON-NLS-1$
- dialog.setMessage("Select a property (* = any string, ? = any char):"); //$NON-NLS-1$
-
- if(availableProperties == null || availableProperties.isEmpty()) {
- return null;
- }
-
- dialog.setElements(availableProperties.toArray());
-
- Property element = null;
- int dialogResult = dialog.open();
- if(dialogResult == Window.OK) {
- if(!"".equals(dialog.getFirstResult())) { //$NON-NLS-1$
- element = (Property)dialog.getFirstResult();
- }
- }
- return element;
- }
-
- /**
- * Execute a EMF command without history (cancelation usage)
- *
- * @param editingDomain
- * The editing domain
- * @param command
- * The command
- */
- public static void executeCommandWithoutHistory(EditingDomain editingDomain, org.eclipse.emf.common.command.Command command) {
- try {
- CommandStack commandStack = editingDomain.getCommandStack();
- if(commandStack instanceof TransactionalCommandStack) {
- ((TransactionalCommandStack)commandStack).execute(command, Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE));
- } else {
- commandStack.execute(command);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (RollbackException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Execute a EMF command without history
- *
- * @param editingDomain
- * The editing domain
- * @param command
- * The command
- * @param flag
- */
- public static void executeCommandWithoutHistory(EditingDomain editingDomain, org.eclipse.emf.common.command.Command command, boolean flag) {
- TransactionalCommandStackImpl stack = new TransactionalCommandStackImpl();
- stack.setEditingDomain((InternalTransactionalEditingDomain)editingDomain);
- try {
- stack.execute(command, Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE));
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (RollbackException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Retrieve the Lifeline associated with an ExecutionSpecification.
- * According to the UML Specification, an ExecutionSpecification must have a start and a finish.
- *
- * In Papyrus, an ExecutionSpecification may not have a start and finish.
- * To handle this specific case, we return the first lifeline that the ES covered.
- *
- * @param es
- * the targeted execution specification
- * @return the associated lifeline, or null if the ES has no start, no finish, no covered lifelines.
- */
- public static Lifeline getExecutionSpecificationLifeline(ExecutionSpecification es) {
- Lifeline lifeline = null;
- if(es.getStart() != null) {
- lifeline = es.getStart().getCovereds().get(0);
- } else if(es.getFinish() != null) {
- lifeline = es.getFinish().getCovereds().get(0);
- }
-
- if(lifeline == null) {
- if(!es.getCovereds().isEmpty()) {
- lifeline = es.getCovereds().get(0);
- }
- }
- return lifeline;
- }
-
- /**
- * Create an DestructionEvent and an occurrenceSpecification bounds to the lifeline
- *
- * @param destructionEvent
- * the destructionEvent
- * @param lifeline
- * the lifeline associated with the destructionEvent
- * @param modelContainer
- * the container of the occurrenceSpecification that will bound the lifeline and the destructionEvent.
- * @return
- */
- // public static DestructionEvent doCreateDestructionEvent(Lifeline lifeline, Object modelContainer) {
- //
- // // Get the nearest package
- // Package pack = lifeline.getNearestPackage();
- //
- // EClass destructionEventEClass = UMLPackage.eINSTANCE.getDestructionEvent();
- // // Add the destructionEvent to the Package
- // DestructionEvent destructionEvent = (DestructionEvent)pack.createPackagedElement(ElementInitializers.getNextNumberedName(pack.getOwnedElements(), destructionEventEClass.getName()), destructionEventEClass);
- //
- // // Create an occurrenceSpecification
- // Element element = createElement(modelContainer, UMLPackage.eINSTANCE.getOccurrenceSpecification());
- // OccurrenceSpecification os = null;
- // if(element instanceof OccurrenceSpecification) {
- // os = (OccurrenceSpecification)element;
- // doConfigureOccurenceSpecification(os, destructionEvent, (InteractionFragment)modelContainer, lifeline);
- // }
- //
- // return destructionEvent;
- // }
-
- /**
- * Create an DestructionOccurrenceSpecification bounds to the lifeline
- *
- * @param lifeline
- * the lifeline associated with the destructionEvent
- * @param modelContainer
- * the container of the occurrenceSpecification that will bound the lifeline and the destructionEvent.
- * @return
- */
- public static DestructionOccurrenceSpecification doCreateDestructionOccurrenceSpecification(Lifeline lifeline, Object modelContainer) {
-
- // Get the nearest package
- Package pack = lifeline.getNearestPackage();
-
- // Create an occurrenceSpecification
- Element element = createElement(modelContainer, UMLPackage.eINSTANCE.getDestructionOccurrenceSpecification());
- DestructionOccurrenceSpecification os = null;
- if(element instanceof DestructionOccurrenceSpecification) {
- os = (DestructionOccurrenceSpecification)element;
- doConfigureOccurenceSpecification(os, null, (InteractionFragment)modelContainer, lifeline);
- }
-
- return os;
- }
-
-
-
-
-
- /**
- * Create an StateInvariant
- *
- * @param lifeline
- * the lifeline on which the stateInvariant is created (or which is covered by the StateInvariant).
- * @param modelContainer
- * the model container
- * @return the created stateInvariant or null
- */
- public static StateInvariant doCreateStateInvariant(Lifeline lifeline, Object modelContainer) {
- StateInvariant stateInvariant = null;
-
- Element element = createElement(modelContainer, UMLPackage.eINSTANCE.getStateInvariant());
-
- if(element instanceof StateInvariant) {
- stateInvariant = (StateInvariant)element;
- // Get the covered lifeline
- stateInvariant.getCovereds().add(lifeline);
-
- // Create the associated invariant
- stateInvariant.createInvariant("");
- }
-
- return stateInvariant;
- }
-
- private static Element createElement(Object modelContainer, EClass eClass) {
-
- // Get the enclosing interaction fragment
- if(modelContainer instanceof InteractionOperand) {
- InteractionOperand interactionOperand = (InteractionOperand)modelContainer;
- // Create the ES
- return interactionOperand.createFragment(ElementInitializers.getNextNumberedName(interactionOperand.getFragments(), eClass.getName()), eClass);
- } else if(modelContainer instanceof Interaction) {
- Interaction interaction = (Interaction)modelContainer;
- // Create the ES
- return interaction.createFragment(ElementInitializers.getNextNumberedName(interaction.getFragments(), eClass.getName()), eClass);
- }
- return null;
- }
-
-
- /**
- * Create a CombinedFragment and its associated interaction Operand
- *
- * @param modelContainer
- * the container of the CF. It could be an InteractionOperand or an Interaction.
- * @param operatorKind
- * the operatorKind of the combinedFragment
- * @return the created CombinedFragment or null
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public static CombinedFragment doCreateCombinedFragment(Object modelContainer, InteractionOperatorKind operatorKind, Collection coveredLifelines) {
- CombinedFragment combinedFragment = null;
-
- Element element = createElement(modelContainer, UMLPackage.eINSTANCE.getCombinedFragment());
- if(element instanceof CombinedFragment) {
- combinedFragment = (CombinedFragment)element;
- combinedFragment.getCovereds().addAll(coveredLifelines);
-
- // Set the operator kind
- combinedFragment.setInteractionOperator(operatorKind);
-
- // Create the operand
- createCoRegionInteractionOperand(combinedFragment);
- }
- return combinedFragment;
- }
-
- /**
- * Create a CoRegion element :
- * a CombinedFragment with InteractionOperator set to 'Parallel'
- *
- * @param modelContainer
- * the parent element of the CoRegion
- * @param coveredLifeline
- * the lifeline on which the CoRegion is created
- * @return the created CoRegion or null
- */
- public static CombinedFragment doCreateCoRegion(Object modelContainer, Lifeline coveredLifeline) {
-
- // Create a Parallel CombinedFragment
- Element element = createElement(modelContainer, UMLPackage.eINSTANCE.getCombinedFragment());
- if(element instanceof CombinedFragment) {
- CombinedFragment combinedFragment = (CombinedFragment)element;
- combinedFragment = (CombinedFragment)element;
- combinedFragment.getCovereds().add(coveredLifeline);
-
- // Set the operator kind
- combinedFragment.setInteractionOperator(InteractionOperatorKind.PAR_LITERAL);
-
- return combinedFragment;
- }
- return null;
- }
-
-
- /**
- * Create an ExecutionSpecification. It also creates the start and finish ExecutionOccurenceSpecification of the ExecutionSpecification, and their
- * corresponding events.
- *
- * @param es
- * the executionSpecification to create.
- * @param lifeline
- * the lifeline covered by the ExecutionSpecification.
- * @return the created executionSpecification
- */
- public static ExecutionSpecification doCreateExecutionSpecification(ExecutionSpecification es, Lifeline lifeline, Object modelContainer) {
- InteractionFragment interactionFragment = null;
- // Get the enclosing interaction fragment
- if(modelContainer instanceof InteractionOperand) {
- InteractionOperand interactionOperand = (InteractionOperand)modelContainer;
- interactionFragment = interactionOperand;
- } else {
- Interaction interaction = lifeline.getInteraction();
- interactionFragment = interaction;
- }
-
- // Create events
- org.eclipse.uml2.uml.Package eventContainer = interactionFragment.getNearestPackage();
-
- // ExecutionEvent startingExecutionEvent = EventHelper.doCreateExecutionEvent(eventContainer);
- // ExecutionEvent finishingExecutionEvent = EventHelper.doCreateExecutionEvent(eventContainer);
-
- // Create fragments in the correct order : start OccurenceSpecification, ExecutionSpecification, finish OccurenceSpecification
- // start
- ExecutionOccurrenceSpecification start = CommandHelper.doCreateExecutionOccurenceSpecification(null, interactionFragment, lifeline);
-
- // Create the ExecutionSpecification
- if(modelContainer instanceof InteractionOperand) {
- InteractionOperand interactionOperand = (InteractionOperand)modelContainer;
- // Create the ES
- es = (ExecutionSpecification)interactionOperand.createFragment(null, es.eClass());
- } else {
- Interaction interaction = lifeline.getInteraction();
- // Create the ES
- es = (ExecutionSpecification)interaction.createFragment(null, es.eClass());
- }
-
- // finish
- ExecutionOccurrenceSpecification finish = CommandHelper.doCreateExecutionOccurenceSpecification(es, interactionFragment, lifeline);
-
- // Get the covered lifeline
- es.getCovereds().add(lifeline);
-
- // Set the start and the finish ExecutionOccurrenceSpecification
- es.setStart(start);
- es.setFinish(finish);
- start.setExecution(es);
-
- // Init the name of the ES and its EOS
- initExecutionSpecificationName(es);
-
- return es;
- }
-
-
- private static void initExecutionSpecificationName(ExecutionSpecification es) {
-
- String body = ""; //$NON-NLS-1$
- if(es instanceof ActionExecutionSpecification) {
- body = "ActionExecSpec"; //$NON-NLS-1$
- } else {
- body = "BehaviorExecSpec"; //$NON-NLS-1$
- }
- // Init the name
- ElementInitializers.init_NamedElement(es, "", body, ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Init the name of the related executionOccurrenceSpecification
- ElementInitializers.init_NamedElement(es.getStart(), "", es.getName(), "Start"); //$NON-NLS-1$ //$NON-NLS-2$
- ElementInitializers.init_NamedElement(es.getFinish(), "", es.getName(), "Finish"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- /**
- * Create a MessageEnd
- *
- * @param interaction
- * fragment
- * The Interaction fragment
- * @param callEvent
- * The call event
- * @param element
- * The element
- * @param direction
- * The message direction
- * @return A MessageOccurrenceSpecification if element is ExecutionSpecification or Lifeline. A
- * Gate if element is Interaction or CombinedFragment or InteractionUse
- */
- public static MessageEnd createMessageEnd(InteractionFragment interactionFragment, Event event, Element element, MessageDirection direction) {
- MessageEnd endMsg = null;
- if(element instanceof Lifeline) {
- endMsg = doCreateMessageOccurrence(interactionFragment, event, (Lifeline)element);
- } else if(element instanceof ExecutionSpecification) {
- Lifeline lifeline = getExecutionSpecificationLifeline((ExecutionSpecification)element);
- endMsg = doCreateMessageOccurrence(interactionFragment, event, lifeline);
- } else if(element instanceof Interaction || element instanceof CombinedFragment || element instanceof InteractionUse) {
- endMsg = doCreateGate(element, direction);
- }
- return endMsg;
- }
-
- /**
- * Create gate if element is a Interaction, a Combined Fragment or a Interaction Use
- *
- * @param element
- * The element
- * @param direction
- * The message direction
- * @return The gate
- * @throws IllegalArgumentException
- * if the element is not a right element type
- */
- public static Gate doCreateGate(Element element, MessageDirection direction) {
- Gate gate = null;
-
- if(element instanceof Interaction) {
- gate = ((Interaction)element).createFormalGate(null);
- } else if(element instanceof CombinedFragment) {
- CombinedFragment combinedFragment = (CombinedFragment)element;
- EList<Gate> cfragmentGates = combinedFragment.getCfragmentGates();
- if(cfragmentGates.isEmpty()) {
- gate = ((CombinedFragment)element).createCfragmentGate(null);
- } else {
- // remove connection feedbacks before opening dialog
- clearConnectionFeedback();
-
- Shell shell = Display.getCurrent().getActiveShell();
- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, labelProvider);
- dialog.setTitle("Gates of the CombinedFragment has");
- dialog.setMessage(CHOOSE_GATE_DIALOG_MSG);
- dialog.setMultipleSelection(false);
-
- List<Gate> gates = new ArrayList<Gate>();
- for(Gate actualGate : cfragmentGates) {
- gates.add(actualGate);
- }
-
- dialog.setElements(gates.toArray());
- if(dialog.open() == Window.OK) {
- gate = (Gate)dialog.getFirstResult();
- } else { // cancel button
- throw new OperationCanceledException();
- }
- }
- } else if(element instanceof InteractionUse) {
- Shell shell = Display.getCurrent().getActiveShell();
- InteractionUse interactionUse = (InteractionUse)element;
-
- if(interactionUse.getRefersTo() == null) {
- MessageDialog.openError(shell, NO_REFERENCED_INTERACTION_DIALOG_TITLE, NO_REFERENCED_INTERACTION_DIALOG_MSG);
- return null;
- }
-
- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, labelProvider);
- dialog.setTitle(CHOOSE_GATE_DIALOG_TITLE);
- dialog.setMessage(CHOOSE_GATE_DIALOG_MSG);
- dialog.setMultipleSelection(false);
-
- List<Gate> gates = new ArrayList<Gate>();
- for(Gate actualGate : ((InteractionUse)element).getActualGates()) {
- if(actualGate.getName().startsWith(direction.getName())) {
- gates.add(actualGate);
- }
- }
- dialog.setElements(gates.toArray());
- if(dialog.open() == Window.OK) {
- gate = (Gate)dialog.getFirstResult();
- }
- } else {
- throw new IllegalArgumentException(WRONG_GATE_CONTAINER_TYPE_ERROR_MSG);
- }
-
- if(gate != null) {
- ElementInitializers.init_NamedElement(gate, direction.toString().toLowerCase() + "_"); //$NON-NLS-1$
- }
-
- return gate;
- }
-
- /**
- * Creates a message and manage the creation of a message from/to a CoRegion
- *
- * @param interaction
- * the interaction containing the message.
- * @param messageSort
- * the messageSort of the message, it can be null
- * @param source
- * the source of the message, it can be null
- * @param target
- * the target of the message, it can be null
- * @param params
- * a map of params. It must at least contain the source and target container;
- * @return the created message.
- */
- public static Message doCreateMessage(Interaction interaction, MessageSort messageSort, Element source, Element target, Map<Object, Object> params) {
- InteractionFragment sourceContainer = (InteractionFragment)params.get(SequenceRequestConstant.SOURCE_MODEL_CONTAINER);
- InteractionFragment targetContainer = (InteractionFragment)params.get(SequenceRequestConstant.TARGET_MODEL_CONTAINER);
-
- Lifeline lifeline = (Lifeline)params.get(SequenceRequestConstant.LIFELINE_GRAPHICAL_CONTAINER);
- if(lifeline != null) {
- if(source instanceof CombinedFragment) {
- CombinedFragment cf = (CombinedFragment)source;
-
- if(InteractionOperatorKind.PAR_LITERAL.equals(cf.getInteractionOperator())) {
- InteractionOperand interactionOperand = getCoRegionInteractionOperand(cf);
- sourceContainer = interactionOperand;
- targetContainer = interactionOperand;
- source = lifeline;
- if(target instanceof Lifeline) {
- addCoveredLifelineToCombinedFragment((Lifeline)target, cf);
- }
- }
- } else if(target instanceof CombinedFragment) {
- CombinedFragment cf = (CombinedFragment)target;
- if(InteractionOperatorKind.PAR_LITERAL.equals(cf.getInteractionOperator())) {
- InteractionOperand interactionOperand = getCoRegionInteractionOperand(cf);
- sourceContainer = interactionOperand;
- targetContainer = interactionOperand;
- target = lifeline;
- if(source instanceof Lifeline) {
- addCoveredLifelineToCombinedFragment((Lifeline)source, cf);
- }
- }
- }
- }
- return doCreateMessage(interaction, messageSort, source, target, sourceContainer, targetContainer);
- }
-
- private static void addCoveredLifelineToCombinedFragment(Lifeline coveredLifeline, CombinedFragment cf) {
- cf.getCovereds().add(coveredLifeline);
-
- for(InteractionOperand io : cf.getOperands()) {
- io.getCovereds().add(coveredLifeline);
- }
- }
-
- /**
- * Get the interactionOperand where the occurrenceSpecification will be created
- */
- public static InteractionOperand getCoRegionInteractionOperand(CombinedFragment cf) {
- InteractionOperand interactionOperand = null;
-
- // Search in the existing operands if there are any operand without fragments.
- for(InteractionOperand existingOperand : cf.getOperands()) {
- if(existingOperand.getFragments().isEmpty()) {
- interactionOperand = existingOperand;
- break;
- }
- }
-
- // If the operand is still null, we create a new operand in the combinedFragment.
- if(interactionOperand == null) {
- interactionOperand = createCoRegionInteractionOperand(cf);
- }
- return interactionOperand;
- }
-
- private static InteractionOperand createCoRegionInteractionOperand(CombinedFragment cf) {
- InteractionOperand interactionOperand = cf.createOperand("");
- interactionOperand.getCovereds().addAll(cf.getCovereds());
- interactionOperand.setName(ElementInitializers.getNextNumberedName(cf.getOperands(), interactionOperand.eClass().getName()));
- return interactionOperand;
- }
-
- /**
- * Create a message. It also creates its message end, their corresponding events and updates the signature of the message.
- *
- * @param container
- * the interaction containing the message.
- * @param messageSort
- * the messageSort of the message, it can be null
- * @param source
- * the source of the message, it can be null
- * @param target
- * the target of the message, it can be null
- * @return the created message
- */
- public static Message doCreateMessage(Interaction container, MessageSort messageSort, Element source, Element target, InteractionFragment sourceContainer, InteractionFragment targetContainer) {
- return doCreateMessage(container, messageSort, source, target, sourceContainer, targetContainer, null, null);
- }
-
- /**
- * Create a message. It also creates its message end (if not provided), their corresponding events and updates the signature of the message.
- *
- * @param container
- * the interaction containing the message.
- * @param messageSort
- * the messageSort of the message, it can be null
- * @param source
- * the source of the message, it can be null
- * @param target
- * the target of the message, it can be null
- * @param sendMessageEnd
- * the existing Send MessageEnd of the message
- * @param receiveMessageEnd
- * the existing Receive MessageEnd of the message
- * @return the created message
- */
- public static Message doCreateMessage(Interaction container, MessageSort messageSort, Element source, Element target, InteractionFragment sourceContainer, InteractionFragment targetContainer, MessageEnd sendMessageEnd, MessageEnd receiveMessageEnd) {
-
- List<NamedElement> signatures = getSignature(container.getModel(), source, target, messageSort);
-
- // If signatures == null, means the user click on cancel button during selection --> Cancel the whole process of creation
- if(signatures == null) {
- return null;
- }
-
- NamedElement signature = null;
- if(!signatures.isEmpty()) {
- signature = signatures.get(0);
- }
-
- // Get the correct MessageSort
- messageSort = getMessageSort(signature, messageSort);
-
- // Create the message
- Message message = doCreateMessage(container, messageSort, signature);
-
- // Create the two message ends
- if(sendMessageEnd == null && source != null) {
- sendMessageEnd = createMessageEnd(sourceContainer, EventHelper.doCreateSendEvent(messageSort, container, signature), source, MessageDirection.OUT);
- }
- if(receiveMessageEnd == null && target != null) {
- receiveMessageEnd = createMessageEnd(targetContainer, EventHelper.doCreateReceiveEvent(messageSort, container, signature), target, MessageDirection.IN);
- }
-
- // Update the messages end with the message
- if(sendMessageEnd != null) {
- sendMessageEnd.setMessage(message);
- ElementInitializers.init_NamedElement(sendMessageEnd, "", message.getName(), "Send"); //$NON-NLS-1$ //$NON-NLS-2$
- // Update the message with the messages end
- message.setSendEvent(sendMessageEnd);
- }
- if(receiveMessageEnd != null) {
- receiveMessageEnd.setMessage(message);
- ElementInitializers.init_NamedElement(receiveMessageEnd, "", message.getName(), "Recv"); //$NON-NLS-1$ //$NON-NLS-2$
- // Update the message with the messages end
- message.setReceiveEvent(receiveMessageEnd);
- }
-
- return message;
- }
-
-
- /**
- * Get the messageSort of a message if it doesn't exist yet depending of the messageSignature.
- * If no messageSort exists, and if the signature is null, then return a MessageSort.ASYNCH_CALL_LITERAL
- *
- * @param signature
- * the signature of the message or null
- * @param messageSort
- * a messageSort or null
- * @return the messageSort
- */
- private static MessageSort getMessageSort(NamedElement signature, MessageSort messageSort) {
- if(messageSort == null) {
- if(signature instanceof Signal) {
- return MessageSort.ASYNCH_SIGNAL_LITERAL;
- } else {
- return MessageSort.ASYNCH_CALL_LITERAL;
- }
- }
- return messageSort;
- }
-
- /**
- * A method to validate that both source and target of a request have valid container for the creation of a message.
- *
- * @param request
- * the request
- * @return false if the container of the source or the target is null and if the two container are not equals
- */
- public static boolean hasValidContainer(IEditCommandRequest request) {
- Object srcEndContainer = request.getParameter(SequenceRequestConstant.SOURCE_MODEL_CONTAINER);
- Object tgtEndContainer = request.getParameter(SequenceRequestConstant.TARGET_MODEL_CONTAINER);
- if(srcEndContainer == null || tgtEndContainer == null) {
- return false;
- }
-
- /*
- * Message cannot cross InteractionFragment.
- * Either the two message ends are contained into the same InteractionFragment,
- * or one is a gate and the other is in the InteractionFragment containing the gate's CF,
- * or one is a gate and the other is a gate in a CF containing the first gate's CF.
- */
- // into the same InteractionFragment
- if(srcEndContainer.equals(tgtEndContainer)) {
- return true;
- }
- // one is a gate
- if(request instanceof CreateRelationshipRequest) {
- EObject src = ((CreateRelationshipRequest)request).getSource();
- EObject tgt = ((CreateRelationshipRequest)request).getTarget();
- if(!(src instanceof Lifeline)) {
- // send is a gate
- if(src instanceof InteractionOperand) {
- // consider the containing CF
- src = src.eContainer();
- }
- if(src instanceof InteractionFragment) {
- // check whether container of gate is in the target's fragment container
- if(tgtEndContainer instanceof Interaction) {
- if(((Interaction)tgtEndContainer).getFragments().contains(src)) {
- return true;
- }
- }
- if(tgtEndContainer instanceof InteractionOperand) {
- if(((InteractionOperand)tgtEndContainer).getFragments().contains(src)) {
- return true;
- }
- }
- }
- }
- if(!(tgt instanceof Lifeline)) {
- // receive is a gate
- if(tgt instanceof InteractionOperand) {
- // consider the containing CF
- tgt = tgt.eContainer();
- }
- if(tgt instanceof InteractionFragment) {
- // check whether container of gate is in the source's fragment container
- if(srcEndContainer instanceof Interaction && ((Interaction)srcEndContainer).getFragments().contains(tgt)) {
- return true;
- }
- if(srcEndContainer instanceof InteractionOperand && ((InteractionOperand)srcEndContainer).getFragments().contains(tgt)) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DestructionOccurrenceUtil.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DestructionOccurrenceUtil.java
deleted file mode 100644
index 0cc381e0c1a..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DestructionOccurrenceUtil.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageSort;
-
-
-public class DestructionOccurrenceUtil {
- public static void reorderDestructionOccurrence(List<InteractionFragment> reorderedFragments) {
- int size = reorderedFragments.size();
- List<InteractionFragment> destructionOccurrenceList = new ArrayList<InteractionFragment>(size);
- for(int i = 0; i < size; i++) {
- InteractionFragment o = reorderedFragments.get(i);
- if(o instanceof DestructionOccurrenceSpecification){
- destructionOccurrenceList.add(o);
- }
- }
-
- reorderedFragments.removeAll(destructionOccurrenceList);
- reorderedFragments.addAll(destructionOccurrenceList);
- }
-
- public static void constraintDestructionOccurrence(Message mess, List<InteractionFragment> constraint) {
- if(mess.getMessageSort() != MessageSort.DELETE_MESSAGE_LITERAL)
- return;
- addDestructionOccurrenceConstraint(mess.getReceiveEvent(), constraint);
- addDestructionOccurrenceConstraint(mess.getSendEvent(), constraint);
- }
-
- public static void addDestructionOccurrenceConstraint(MessageEnd end, List<InteractionFragment> constraint) {
- if(end instanceof InteractionFragment){
- InteractionFragment frag = (InteractionFragment) end;
- if(frag.getCovereds().size() > 0){
- Lifeline lifeline = ((InteractionFragment)frag).getCovereds().get(0);
- DestructionOccurrenceSpecification d = findDestructionOccurrence(lifeline);
- if(d != null)
- constraint.add(d);
- }
- }
- }
-
- public static DestructionOccurrenceSpecification findDestructionOccurrence(Lifeline lifeline) {
- EList<InteractionFragment> list = lifeline.getCoveredBys();
- for(InteractionFragment f : list)
- if(f instanceof DestructionOccurrenceSpecification){
- return (DestructionOccurrenceSpecification)f;
- }
-
- return null;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/EventHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/EventHelper.java
deleted file mode 100644
index b84370f89f1..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/EventHelper.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.ElementInitializers;
-import org.eclipse.uml2.uml.CallEvent;
-import org.eclipse.uml2.uml.Event;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.MessageSort;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * An utility class to create event elements.
- *
- */
-public class EventHelper {
-
- /**
- * Create an event
- *
- * @param eventContainer
- * the container
- * @return the event
- */
- public static Event doCreateEvent(Package eventContainer, EClass eClass) {
- Event event = (Event)eventContainer.createPackagedElement(null, eClass);
- ElementInitializers.init_NamedElement(event);
- return event;
- }
-
- /**
- * Create an event
- *
- * @param eventContainer
- * the container
- * @return the event
- */
- public static CallEvent doCreateCallEvent(Package eventContainer, Operation operation) {
- CallEvent event = (CallEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getCallEvent());
- event.setOperation(operation);
- return event;
- }
-
-
- /**
- * Create a SendOperation event and initializes its name
- *
- * @param eventContainer
- * the container
- * @param operation
- * the operation of the event. Can't be null
- * @return the sendOperation event
- */
- // Does not exist anymore in UML 2.4
- // public static SendOperationEvent doCreateSendOperationEvent(Package eventContainer, Operation operation) {
- // SendOperationEvent sendOperationEvent = (SendOperationEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getSendOperationEvent());
- // sendOperationEvent.setOperation(operation);
- // return sendOperationEvent;
- // }
-
- /**
- * Create a ReceiveOperation event and initializes its name
- *
- * @param eventContainer
- * the container
- * @param operation
- * the operation of the event. Can't be null
- * @return the receiveOperation event
- */
- // Does not exist anymore in UML 2.4
- // public static ReceiveOperationEvent doCreateReceiveOperationEvent(Package eventContainer, Operation operation) {
- // ReceiveOperationEvent receiveOperationEvent = (ReceiveOperationEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getReceiveOperationEvent());
- // receiveOperationEvent.setOperation(operation);
- // return receiveOperationEvent;
- // }
-
- /**
- * Create a send signal event and initializes its name
- *
- * @param eventContainer
- * the container
- * @param signal
- * the signal of the event. Can't be null
- * @return the send signal event
- */
- // Does not exist anymore in UML 2.4
- // public static SendSignalEvent doCreateSendSignalEvent(Package eventContainer, Signal signal) {
- // SendSignalEvent sendSignalEvent = (SendSignalEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getSendSignalEvent());
- // sendSignalEvent.setSignal(signal);
- // return sendSignalEvent;
- // }
-
- /**
- * Create a ReceiveSignal event and initializes its name
- *
- * @param eventContainer
- * the container
- * @param signal
- * the signal of the event. Can't be null
- * @return the ReceiveSignal event
- */
- // Does not exist anymore in UML 2.4
- // public static ReceiveSignalEvent doCreateReceiveSignalEvent(Package eventContainer, Signal signal) {
- // ReceiveSignalEvent receiveSignalEvent = (ReceiveSignalEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getReceiveSignalEvent());
- // receiveSignalEvent.setSignal(signal);
- // return receiveSignalEvent;
- // }
-
- // Does not exist anymore in UML 2.4
- // /**
- // * Create a receive signal event
- // *
- // * @param eventContainer
- // * the container
- // * @return the receive signal event
- // */
- // public static CreationEvent doCreateCreationEvent(Package eventContainer) {
- // return (CreationEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getCreationEvent());
- // }
- //
- // /**
- // * Create a destruction event
- // *
- // * @param eventContainer
- // * the container
- // * @return the destruction event
- // */
- // public static DestructionEvent doCreateDestructionEvent(Package eventContainer) {
- // return (DestructionEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getDestructionEvent());
- // }
- //
- // /**
- // * Create an execution event
- // *
- // * @param eventContainer
- // * the container
- // * @return the executionEvent
- // */
- // public static ExecutionEvent doCreateExecutionEvent(Package eventContainer) {
- // return (ExecutionEvent)doCreateEvent(eventContainer, UMLPackage.eINSTANCE.getExecutionEvent());
- // }
-
-
- /**
- * Create a receive event in the package containing the interaction
- * If the messageSort is ASYNCH_SIGNAL, it creates a ReceiveSignalEvent
- * If the messageSort is ASYNCH_CALL or SYNCH_CALL or REPLY_LITERAL, it creates a ReceiveOperationEvent
- * If the messageSort is CREATE_MESSAGE, it creates a CreationEvent.
- * If the messageSort is DELETE_MESSAGE, it creates a DestructionEvent.
- *
- * @param messageSort
- * the messageSort
- * @param interaction
- * the interaction
- * @param signature
- * the signature of the message
- * @return the created receive event or null
- */
- public static Event doCreateReceiveEvent(MessageSort messageSort, Interaction interaction, NamedElement signature) {
- Package eventContainer = interaction.getNearestPackage();
- Event event = null;
-
- switch(messageSort) {
- case ASYNCH_SIGNAL_LITERAL:
- //event = doCreateReceiveSignalEvent(eventContainer, (Signal)signature);
- break;
- case ASYNCH_CALL_LITERAL:
- case SYNCH_CALL_LITERAL:
- case REPLY_LITERAL:
- //event = doCreateReceiveOperationEvent(eventContainer, (Operation)signature);
- break;
- case CREATE_MESSAGE_LITERAL:
- //event = doCreateCreationEvent(eventContainer);
- break;
- case DELETE_MESSAGE_LITERAL:
- //event = doCreateDestructionEvent(eventContainer);
- break;
- default:
- break;
-
- }
- return event;
- }
-
- /**
- * Create a sending event in the package containing the interaction.
- * If the messageSort is ASYNCH_SIGNAL, CREATE_MESSAGE, DELETE_MESSAGE, it creates a SendSignalEvent
- * If the messageSort is ASYNCH_CALL, SYNCH_CALL, REPLY_LITERAL, it creates a SendOperationEvent.
- *
- * @param messageSort
- * the messageSort
- * @param interaction
- * the interaction
- * @param signature
- * the signature of the message
- * @return the created send event or null
- */
- public static Event doCreateSendEvent(MessageSort messageSort, Interaction interaction, NamedElement signature) {
- Package eventContainer = interaction.getNearestPackage();
- Event event = null;
- switch(messageSort) {
- case ASYNCH_SIGNAL_LITERAL:
- case CREATE_MESSAGE_LITERAL:
- case DELETE_MESSAGE_LITERAL:
- //event = doCreateSendSignalEvent(eventContainer, (Signal)signature);
- break;
- case ASYNCH_CALL_LITERAL:
- case SYNCH_CALL_LITERAL:
- case REPLY_LITERAL:
- //event = doCreateSendOperationEvent(eventContainer, (Operation)signature);
- break;
- default:
- break;
-
- }
- return event;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/HighlightUtil.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/HighlightUtil.java
deleted file mode 100644
index ccde9d88e8e..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/HighlightUtil.java
+++ /dev/null
@@ -1,272 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.eclipse.draw2d.Border;
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.draw2d.Polyline;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.Shape;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.swt.graphics.Color;
-
-
-public class HighlightUtil {
-
- private static class FigureState {
-
- private Color bgColor;
-
- private Color fgColor;
-
- private int lineWidth;
-
- public FigureState(Color bgColor, Color fgColor, int lineWidth) {
- this.bgColor = bgColor;
- this.fgColor = fgColor;
- this.lineWidth = lineWidth;
- }
- }
-
- public static final Color COVER_COLOR = ColorConstants.cyan;
-
- public static final Color TARGET_COLOR = ColorConstants.cyan;
-
- public static final Color SOURCE_COLOR = ColorConstants.cyan;
-
- static Map<LifelineEditPart, Rectangle> lifelines;
-
- static List<LifelineEditPart> highlightLifelines = new ArrayList<LifelineEditPart>();
-
- static Map<EditPart, FigureState> feedbackStates = new HashMap<EditPart, HighlightUtil.FigureState>();
-
- public static Map<LifelineEditPart, Rectangle> collectAllLifelines(EditPart part) {
- Map<LifelineEditPart, Rectangle> lifelines = new HashMap<LifelineEditPart, Rectangle>();
- Set<Entry<Object, EditPart>> allEditPartEntries = part.getViewer().getEditPartRegistry().entrySet();
- for(Entry<Object, EditPart> epEntry : allEditPartEntries) {
- EditPart ep = epEntry.getValue();
- if(!(ep instanceof LifelineEditPart))
- continue;
-
- LifelineEditPart lp = (LifelineEditPart)ep;
- IFigure figure = lp.getFigure();
- Rectangle childBounds = figure.getBounds().getCopy();
- figure.translateToAbsolute(childBounds);
- Rectangle centralLineBounds = new Rectangle(childBounds.x() + childBounds.width() / 2, childBounds.y(), 1, childBounds.height());
-
- lifelines.put(lp, centralLineBounds);
- }
- return lifelines;
- }
-
- public static void eraseSizeOnDropFeedback(Request request, EditPart host) {
- for(LifelineEditPart lp : highlightLifelines) {
- FigureState s = feedbackStates.get(lp);
- if(s == null)
- continue;
-
- RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
- rect.setBackgroundColor(s.bgColor);
- rect.setFill(true);
- }
-
- lifelines = null;
- highlightLifelines = new ArrayList<LifelineEditPart>();
- }
-
- public static void showSizeOnDropFeedback(CreateRequest request, EditPart host, IFigure feedback, Rectangle bounds) {
- if(lifelines == null) {
- lifelines = collectAllLifelines(host);
- highlightLifelines = new ArrayList<LifelineEditPart>();
- }
-
- List<LifelineEditPart> addLifelines = new ArrayList<LifelineEditPart>();
- List<LifelineEditPart> removeLifelines = new ArrayList<LifelineEditPart>();
-
- Iterator<Entry<LifelineEditPart, Rectangle>> it = lifelines.entrySet().iterator();
- while(it.hasNext()) {
- Entry<LifelineEditPart, Rectangle> en = it.next();
-
- if(bounds.intersects(en.getValue())) {
- if(!highlightLifelines.contains(en.getKey()))
- addLifelines.add(en.getKey());
- } else {
- if(highlightLifelines.contains(en.getKey()))
- removeLifelines.add(en.getKey());
- }
- }
-
- highlightLifelines.removeAll(removeLifelines);
- highlightLifelines.addAll(addLifelines);
-
- // highlight lifeline inside
- for(LifelineEditPart lp : addLifelines) {
- RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
- feedbackStates.put(lp, new FigureState(rect.getBackgroundColor(), rect.getForegroundColor(), rect.getLineWidth()));
- rect.setBackgroundColor(COVER_COLOR);
- rect.setFill(true);
- }
-
- // restore lifeline outside
- for(LifelineEditPart lp : removeLifelines) {
- FigureState s = feedbackStates.get(lp);
- if(s == null)
- continue;
-
- RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
- rect.setBackgroundColor(s.bgColor);
- rect.setFill(true);
- }
- }
-
- private Map<Object, FigureState> figureState = new HashMap<Object, FigureState>();
-
- /**
- * Maybe this value can be managed by preferences.
- */
- private Color getHighlightBackground() {
- return null;
- }
-
- /**
- * Maybe this value can be managed by preferences.
- */
- private int getHighlightBorderWidth() {
- return 2;
- }
-
- private List<IFigure> getHighlightFigures(EditPart host) {
- List<IFigure> figures = new ArrayList<IFigure>();
- if(host instanceof LifelineEditPart) {
- LifelineEditPart part = (LifelineEditPart)host;
- figures.add(part.getPrimaryShape().getFigureLifelineNameContainerFigure());
- figures.add(part.getPrimaryShape().getFigureLifelineDotLineFigure());
- } else if(host instanceof AbstractExecutionSpecificationEditPart) {
- figures.add(((AbstractExecutionSpecificationEditPart)host).getPrimaryShape());
- } else if(host instanceof CombinedFragmentEditPart) {
- figures.add(((CombinedFragmentEditPart)host).getPrimaryShape());
- } else if(host instanceof InteractionOperandEditPart) {
- InteractionOperandEditPart op = (InteractionOperandEditPart)host;
- CombinedFragmentEditPart cep = (CombinedFragmentEditPart)op.getParent().getParent();
- figures.add(cep.getPrimaryShape());
- } else if(host instanceof CommentEditPart) {
- figures.add(((CommentEditPart)host).getPrimaryShape());
- } else if(host instanceof ConstraintEditPart) {
- figures.add(((ConstraintEditPart)host).getPrimaryShape());
- } else if(host instanceof IPapyrusEditPart) {
- figures.add(((IPapyrusEditPart)host).getPrimaryShape());
- }
- return figures;
- }
-
- /**
- * Maybe this value can be managed by preferences.
- */
- private Color getHighlightForeground() {
- return null;
- }
-
- public void highlight(EditPart host) {
- List<IFigure> highlightFigures = getHighlightFigures(host);
- if(highlightFigures.isEmpty()) {
- return;
- }
-
- Color background = getHighlightBackground();
- Color foreground = getHighlightForeground();
- int lineWidth = getHighlightBorderWidth();
- for(IFigure figure : highlightFigures) {
- saveIfNotExist(figure, figure);
- updateFigure(figure, background, foreground, lineWidth);
- }
- }
-
- protected void saveIfNotExist(Object host, IFigure fig) {
- if(!figureState.containsKey(host)) {
- int lineWidth = 1;
- Border border = fig.getBorder();
- if(border instanceof LineBorder) {
- lineWidth = ((LineBorder)border).getWidth();
- } else if(fig instanceof Shape) {
- lineWidth = ((Shape)fig).getLineWidth();
- }
- figureState.put(host, new FigureState(fig.getBackgroundColor(), fig.getForegroundColor(), lineWidth));
- }
- }
-
- public void unhighlight() {
- if(figureState == null || figureState.isEmpty()) {
- return;
- }
- Set<Entry<Object, FigureState>> entrySet = figureState.entrySet();
- for(Entry<Object, FigureState> entry : entrySet) {
- Object key = entry.getKey();
- FigureState value = entry.getValue();
- if(key instanceof IFigure) {
- IFigure fig = (IFigure)key;
- updateFigure(fig, value.bgColor, value.fgColor, value.lineWidth);
- } else if(key instanceof EditPart) {
- List<IFigure> figures = getHighlightFigures((EditPart)key);
- for(IFigure fig : figures) {
- updateFigure(fig, value.bgColor, value.fgColor, value.lineWidth);
- }
- }
- }
- figureState.clear();
- }
-
- public void unhighlight(EditPart host) {
- List<IFigure> highlightFigures = getHighlightFigures(host);
- if(highlightFigures.isEmpty()) {
- return;
- }
- for(IFigure figure : highlightFigures) {
- FigureState s = figureState.remove(figure);
- if(s == null) {
- continue;
- }
- updateFigure(figure, s.bgColor, s.fgColor, s.lineWidth);
- }
- }
-
- private void updateFigure(IFigure fig, Color bgColor, Color fgColor, int lineWidth) {
- if(fig == null) {
- return;
- }
- if(lineWidth > 0) {
- Border border = fig.getBorder();
- if(border != null && border instanceof LineBorder) {
- ((LineBorder)border).setWidth(lineWidth);
- } else if(fig instanceof Shape) {
- ((Shape)fig).setLineWidth(lineWidth);
- } else if(fig instanceof Polyline) {
- ((Polyline)fig).setLineWidth(lineWidth);
- }
- }
- if(bgColor != null) {
- fig.setBackgroundColor(bgColor);
- }
- if(fgColor != null) {
- fig.setForegroundColor(fgColor);
- }
- fig.repaint();
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java
deleted file mode 100644
index 859b6776e16..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.uml2.uml.InteractionOperatorKind;
-
-public class InteractionOperatorKindCompatibleMapping {
- /**
- * Set the true if the kind of InteractionOperator supports multi operand
- */
- private static final Map<InteractionOperatorKind, Boolean> map = new HashMap<InteractionOperatorKind, Boolean>();
-
- static {
- map.put(InteractionOperatorKind.SEQ_LITERAL, true);
- map.put(InteractionOperatorKind.ALT_LITERAL, true);
- map.put(InteractionOperatorKind.OPT_LITERAL, false);
- map.put(InteractionOperatorKind.BREAK_LITERAL, false);
- map.put(InteractionOperatorKind.PAR_LITERAL, true);
- map.put(InteractionOperatorKind.STRICT_LITERAL, true);
- map.put(InteractionOperatorKind.LOOP_LITERAL, false);
- map.put(InteractionOperatorKind.CRITICAL_LITERAL, true);
- map.put(InteractionOperatorKind.NEG_LITERAL, false);
- map.put(InteractionOperatorKind.ASSERT_LITERAL, true);
- map.put(InteractionOperatorKind.IGNORE_LITERAL, true);
- map.put(InteractionOperatorKind.CONSIDER_LITERAL, true);
- }
-
- /**
- * Check if the InteractionOperator supports multi operand
- *
- * @param kind
- * @return
- */
- public static boolean supportMultiOperand(InteractionOperatorKind kind) {
- Boolean multiOperandSupport = map.get(kind);
- return multiOperandSupport == null ? false : multiOperandSupport;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionUseUtil.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionUseUtil.java
deleted file mode 100644
index 44278c7d059..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionUseUtil.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.uml2.uml.Interaction;
-
-
-public class InteractionUseUtil {
-
- public static Diagram findDiagram(View view, Interaction refInteraction) {
- Diagram diagram = view.getDiagram();
- EList<EObject> list = diagram.eResource().getContents();
- for(EObject o : list) {
- if(o instanceof Diagram) {
- Diagram ref = (Diagram)o;
- if(refInteraction.equals(ref.getElement())) {
- return ref;
- }
- }
- }
-
- return null;
- }
-
- public static void openDiagram(Diagram diag) {
- IPageManager pageMngr;
- try {
- pageMngr = ServiceUtilsForEObject.getInstance().getIPageManager(diag);
- } catch (Exception e) {
- return;
- }
- if(pageMngr != null) {
- if(pageMngr.allPages().contains(diag)) {
- /**
- * Close the diagram if it was already open
- */
- if(pageMngr.isOpen(diag)) {
- pageMngr.selectPage(diag);
- } else {
- pageMngr.openPage(diag);
- }
- }
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineCoveredByUpdater.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineCoveredByUpdater.java
deleted file mode 100644
index 98a310bc186..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineCoveredByUpdater.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * This class updates the property CoveredBy of Lifeline when a Lifeline gets created, moved/resize and also the resize of moving of each CombinedFragment
- *
- * @author yyang
- *
- */
-public class LifelineCoveredByUpdater {
- protected GraphicalEditPart context;
- protected Map<LifelineEditPart, Rectangle> lifelines = new HashMap<LifelineEditPart, Rectangle>();
- protected HashMap<InteractionFragmentEditPart, Rectangle> interactionFragments = new HashMap<InteractionFragmentEditPart, Rectangle>();
-
- protected List<InteractionFragment> coveredByLifelinesToAdd = new ArrayList<InteractionFragment>();
- protected List<InteractionFragment> coveredByLifelinesToRemove = new ArrayList<InteractionFragment>();
-
- protected TransactionalEditingDomain editingDomain;
-
- public LifelineCoveredByUpdater() {
- }
-
- protected void init() {
- editingDomain = this.context.getEditingDomain();
- GraphicalEditPart parent = context;
- while (true) {
- EditPart editPart = parent.getParent();
- if (editPart instanceof GraphicalEditPart) {
- parent = (GraphicalEditPart) editPart;
- } else {
- break;
- }
- }
- childrenCollect(parent);
- }
-
- private void childrenCollect(GraphicalEditPart editPart) {
- if (editPart instanceof LifelineEditPart) {
- IFigure figure = editPart.getFigure();
- Rectangle childBounds = figure.getBounds().getCopy();
- figure.translateToAbsolute(childBounds);
- Rectangle centralLineBounds = new Rectangle(
- childBounds.x() + childBounds.width() / 2,
- childBounds.y(), 1, childBounds.height());
-
- lifelines.put((LifelineEditPart)editPart, centralLineBounds);
- }
- if (editPart instanceof InteractionFragmentEditPart) {
- IFigure figure = editPart.getFigure();
- Rectangle childBounds = figure.getBounds().getCopy();
- figure.translateToAbsolute(childBounds);
- interactionFragments.put((InteractionFragmentEditPart)editPart, childBounds);
- }
- for (Object child : editPart.getChildren()) {
- if (child instanceof GraphicalEditPart) {
- childrenCollect((GraphicalEditPart)child);
- }
- }
- }
-
- public void update(GraphicalEditPart context) {
- this.context = context;
- this.init();
-
- for (Map.Entry<LifelineEditPart, Rectangle> entry : lifelines.entrySet()) {
- LifelineEditPart editPart = entry.getKey();
- Rectangle childBounds = entry.getValue();
- updateLifeline(editPart, childBounds);
- }
- }
-
- public void updateLifeline(LifelineEditPart lifelineEditpart, Rectangle rect) {
- Lifeline lifeline = (Lifeline) lifelineEditpart.resolveSemanticElement();
- EList<InteractionFragment> coveredByLifelines = lifeline
- .getCoveredBys();
-
- coveredByLifelinesToAdd.clear();
- coveredByLifelinesToRemove.clear();
-
- for (Map.Entry<InteractionFragmentEditPart, Rectangle> entry : interactionFragments.entrySet()) {
- InteractionFragmentEditPart editPart = entry.getKey();
- Rectangle childBounds = entry.getValue();
- InteractionFragment interactionFragment = (InteractionFragment) editPart
- .resolveSemanticElement();
- if (rect.intersects(childBounds)) {
- if (!coveredByLifelines.contains(interactionFragment)) {
- coveredByLifelinesToAdd.add(interactionFragment);
- }
- } else if (coveredByLifelines.contains(interactionFragment)) {
- coveredByLifelinesToRemove.add(interactionFragment);
- }
- }
-
- if (!coveredByLifelinesToAdd.isEmpty()) {
- CommandHelper.executeCommandWithoutHistory(editingDomain,
- AddCommand.create(editingDomain, lifeline,
- UMLPackage.eINSTANCE.getLifeline_CoveredBy(),
- coveredByLifelinesToAdd), true);
- }
- if (!coveredByLifelinesToRemove.isEmpty()) {
- CommandHelper.executeCommandWithoutHistory(editingDomain,
- RemoveCommand.create(editingDomain, lifeline,
- UMLPackage.eINSTANCE.getLifeline_CoveredBy(),
- coveredByLifelinesToRemove), true);
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
deleted file mode 100644
index f2910a79850..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.preferences.LifelinePreferencePage;
-import org.eclipse.uml2.uml.ConnectableElement;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Type;
-
-
-public class LifelineLabelHelper extends StereotypedElementLabelHelper {
-
- /**
- * singelton instance
- */
- private static LifelineLabelHelper labelHelper;
-
- /**
- * Returns the singleton instance of this class
- *
- * @return the singleton instance.
- */
- public static LifelineLabelHelper getInstance() {
- if(labelHelper == null) {
- labelHelper = new LifelineLabelHelper();
- }
- return labelHelper;
- }
-
- /** Map for masks */
- protected final Map<Integer, String> masks = new HashMap<Integer, String>(7);
-
- /**
- * Creates a new Operation label helper.
- */
- protected LifelineLabelHelper() {
- // initialize the map
- masks.put(LifelinePreferencePage.SHOW_REPRESENT_NAME, "Show represent name");
- masks.put(LifelinePreferencePage.SHOW_REPRESENT_TYPE, "Show represent type");
- masks.put(LifelinePreferencePage.SHOW_UNDEFINED_TYPE, "Always show undefined type");
- masks.put(LifelinePreferencePage.SHOW_LIFELINE_NAME, "Always show lifeline name");
- }
-
-
- /**
- * Returns the mask name given the value of the mask
- *
- * @return the mask name or <code>null</code> if no masks has been found
- */
- public String getMaskLabel(int value) {
- return masks.get(value);
- }
-
- /**
- * Returns the collection of mask names
- *
- * @return the collection of mask names
- */
- public Collection<String> getMaskLabels() {
- return masks.values();
- }
-
- /**
- * Returns the map of masks used to display
- *
- * @return the map of masks used to display
- */
- public Map<Integer, String> getMasks() {
- return masks;
- }
-
- /**
- * Returns the collection of mask values
- *
- * @return the collection of mask values
- */
- public Set<Integer> getMaskValues() {
- return masks.keySet();
- }
-
- /**
- * {@inheritDoc}
- */
- public Lifeline getUMLElement(GraphicalEditPart editPart) {
- return (Lifeline)((View)editPart.getModel()).getElement();
- }
-
- protected String elementLabel(GraphicalEditPart editPart) {
- if(editPart instanceof LifelineNameEditPart)
- editPart = (GraphicalEditPart)editPart.getParent();
- int displayValue = LifelinePreferencePage.DEFAULT_LABEL_DISPLAY;
-
- IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy)editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if(policy != null) {
- displayValue = policy.getCurrentDisplayValue();
- }
- return getCustomLabel(getUMLElement(editPart), displayValue);
- }
-
- private static final String UNAMED = "<Unnamed>";
- private static final String UNDEFINED = "<Undefined>";
-
- //https://bugs.eclipse.org/bugs/show_bug.cgi?id=383722
- private String getCustomLabel(Lifeline lifeline, int displayValue) {
- StringBuilder sb = new StringBuilder();
- appendName(lifeline, displayValue, sb);
- boolean displayType = isCheck(displayValue , LifelinePreferencePage.SHOW_REPRESENT_TYPE );
- if( lifeline.getRepresents() == null || isCheck(displayValue , LifelinePreferencePage.SHOW_LIFELINE_NAME ) ){
- displayType = false;
- }
- if(displayType){
- // handle represent type label
- appendType(lifeline, displayValue, sb);
- }
- return sb.toString();
- }
-
-
- protected void appendName(Lifeline lifeline, int displayValue, StringBuilder sb) {
- ConnectableElement element = lifeline.getRepresents();
- String lifelineName = lifeline.getName();
- if( element == null || isCheck(displayValue , LifelinePreferencePage.SHOW_LIFELINE_NAME ) ){
- appendString(sb, lifelineName, UNAMED);
- return;
- }else{
- // represents is not null
- if(isCheck(displayValue , LifelinePreferencePage.SHOW_REPRESENT_NAME )){
- appendString(sb, element.getName(), UNAMED);
- }
- // if neither <1> or <2> are checked, show lifeline name (or <unnamed> when the lifeline has no name)
- else if(!isCheck(displayValue , LifelinePreferencePage.SHOW_REPRESENT_TYPE ))
- appendString(sb, lifelineName, UNAMED);
- }
- }
-
- protected void appendType(Lifeline lifeline, int displayValue, StringBuilder sb) {
- ConnectableElement element = lifeline.getRepresents();
- if(element == null)
- return;
-
- Type type = element.getType();
- if(isCheck(displayValue , LifelinePreferencePage.SHOW_REPRESENT_TYPE )){
- if(type == null ){
- if(isCheck(displayValue , LifelinePreferencePage.SHOW_UNDEFINED_TYPE ))
- sb.append(":").append(UNDEFINED);
- }else{
- appendString(sb.append(":") , type.getName(), UNAMED);
- }
- }
- }
-
- private static boolean isCheck(int value, int mask){
- return (value & mask) != 0;
- }
-
- private void appendString(StringBuilder sb, String str, String defaultValue) {
- if(str != null)
- sb.append(str);
- else
- sb.append(defaultValue);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java
deleted file mode 100644
index e28f20055ff..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.DropRequest;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ComponentEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.Bounds;
-import org.eclipse.gmf.runtime.notation.Shape;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
-import org.eclipse.papyrus.uml.diagram.common.draw2d.anchors.LifelineAnchor;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart;
-
-public class LifelineMessageCreateHelper {
-
- public static class ComponentEditPolicyEx extends ComponentEditPolicy {
-
- @Override
- protected Command createDeleteViewCommand(GroupRequest deleteRequest) {
- Command command = super.createDeleteViewCommand(deleteRequest);
- if(command != null && getHost() instanceof LifelineEditPart)
- command = restoreLifelineOnDelete(command, (LifelineEditPart)getHost());
- return command;
- }
- }
-
- public static ConnectionAnchor getCreateMessageAnchor(LifelineEditPart part, Request request, Point location) {
- IFigure fig = part.getPrimaryShape().getFigureLifelineNameContainerFigure();
- fig.translateToRelative(location);
- if(fig.containsPoint(location)) {// move to header
- return new LifelineAnchor(part.getPrimaryShape().getFigureLifelineNameContainerFigure());
- }
- // move to dash line
- return getTargetConnectionAnchor(part, request);
- }
-
- static ConnectionAnchor getTargetConnectionAnchor(LifelineEditPart part, Request request) {
- if (request instanceof ReconnectRequest) {
- if (((DropRequest) request).getLocation() == null) {
- return part.getNodeFigure().getTargetConnectionAnchorAt(null);
- }
- Point pt = ((DropRequest) request).getLocation().getCopy();
- return part.getNodeFigure().getTargetConnectionAnchorAt(pt);
- }
- else if (request instanceof DropRequest){
- return part.getNodeFigure().getTargetConnectionAnchorAt(
- ((DropRequest) request).getLocation());
- }
- return part.getNodeFigure().getTargetConnectionAnchorAt(null);
- }
-
- //when a create message is deleted, move its target lifelines up
- public static Command restoreLifelineOnMessageDelete(Command commands, EditPart editPart){
- if(editPart instanceof Message4EditPart) {
- Message4EditPart part = (Message4EditPart)editPart;
- if(part.getTarget() instanceof LifelineEditPart && LifelineMessageCreateHelper.getIncomingMessageCreate(part.getTarget()).size() == 1){
- LifelineEditPart target = (LifelineEditPart)part.getTarget();
- if(target.getModel() instanceof Shape){
- Shape view = (ShapeImpl) target.getModel();
- if(view.getLayoutConstraint() instanceof Bounds){
- Bounds bounds = (Bounds) view.getLayoutConstraint();
- ICommand boundsCommand = new SetBoundsCommand(
- target.getEditingDomain(),
- DiagramUIMessages.SetLocationCommand_Label_Resize,
- new EObjectAdapter(view), new Point(bounds.getX(),SequenceUtil.LIFELINE_VERTICAL_OFFSET));
- commands = commands.chain(new ICommandProxy(boundsCommand));
- int dy = SequenceUtil.LIFELINE_VERTICAL_OFFSET - bounds.getY();
- commands = moveCascadeLifeline(target, commands, dy);
- }
- }
- }
- }
- return commands;
- }
-
- // when a lifleine is deleted, move its created lifelines up
- public static Command restoreLifelineOnDelete(Command command, LifelineEditPart part) {
- List list = part.getSourceConnections();
- if(list != null && list.size() > 0) {
- for(Object l : list)
- if(l instanceof Message4EditPart) {
- EditPart target = ((Message4EditPart)l).getTarget();
- if(target instanceof LifelineEditPart && getIncomingMessageCreate(target).size() == 1) {
- LifelineEditPart lp = (LifelineEditPart)target;
- Rectangle bounds = lp.getPrimaryShape().getBounds();
- Point location = new Point(bounds.x, SequenceUtil.LIFELINE_VERTICAL_OFFSET);
- int dy = location.y - bounds.y;
- ICommand boundsCommand = new SetBoundsCommand(lp.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(lp.getNotationView()), location);
- command = command.chain(new ICommandProxy(boundsCommand));
- command = moveCascadeLifeline(lp, command, dy);
- }
- }
- }
- return command;
- }
-
- public static boolean hasMessageCreate(GraphicalEditPart sourceEditPart, EditPart targetEditPart) {
- List list = sourceEditPart.getSourceConnections();
- for(Object o : list)
- if(o instanceof Message4EditPart && targetEditPart.equals(((Message4EditPart)o).getTarget())){
- return true;
- }
- return false;
- }
-
- public static boolean hasIncomingMessageCreate(EditPart target) {
- return getIncomingMessageCreate(target).size() > 0;
- }
-
- public static List getIncomingMessageCreate(EditPart target) {
- List create = new ArrayList();
- if(target instanceof LifelineEditPart) {
- List list = ((LifelineEditPart)target).getTargetConnections();
- if(list != null && list.size() > 0) {
- for(Object l : list)
- if(l instanceof Message4EditPart) {
- create.add(l);
- }
- }
- }
- return create;
- }
-
- public static boolean canReconnectMessageCreate(ReconnectRequest request){
- Message4EditPart connPart = (Message4EditPart)request.getConnectionEditPart();
- if(request.isMovingStartAnchor()){ // reconnect source
- if( hasMessageCreate( (GraphicalEditPart)request.getTarget(), (GraphicalEditPart)connPart.getTarget()))
- return false;
- }else{ // reconnect target
- if( hasMessageCreate((GraphicalEditPart)connPart.getSource(), request.getTarget()))
- return false;
- }
- return true;
- }
-
- public static Command reconnectMessageCreateTarget(ReconnectRequest request, Command command) {
- LifelineEditPart oldTarget = (LifelineEditPart)request.getConnectionEditPart().getTarget();
- LifelineEditPart source = (LifelineEditPart)request.getConnectionEditPart().getSource();
- LifelineEditPart newTarget = (LifelineEditPart)request.getTarget();
- // move up the original connection target lifeline, it has only one create message, which will be removed
- if(getIncomingMessageCreate(oldTarget).size() == 1) {
- Rectangle bounds = oldTarget.getPrimaryShape().getBounds();
- Point location = new Point(bounds.x, SequenceUtil.LIFELINE_VERTICAL_OFFSET);
- int dy = location.y - bounds.y;
- ICommand boundsCommand = new SetBoundsCommand(oldTarget.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(oldTarget.getNotationView()), location);
- command = command.chain(new ICommandProxy(boundsCommand));
- command = moveCascadeLifeline(oldTarget, command, dy);
- }
-
- //move down the new connection target lifeline
- command = moveLifelineDown(command, newTarget, request.getLocation().getCopy());
- return command;
- }
-
- public static Command moveLifelineDown(Command command, LifelineEditPart part, Point sourcePointCopy) {
- IFigure fig = part.getFigure();
- Rectangle bounds = fig.getBounds().getCopy();
- fig.translateToAbsolute(bounds);
- int height = part.getPrimaryShape().getFigureLifelineNameContainerFigure().getBounds().height;
- Point location = new Point(bounds.x, Math.max(bounds.y, sourcePointCopy.y() - height / 2));
-
- View targetView = part.getNotationView();
- if(location.y != bounds.y) {
- int dy = location.y - bounds.y;
- fig.translateToRelative(location);
- fig.translateToParent(location);
-
- ICommand boundsCommand = new SetBoundsCommand(part.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(targetView), location);
- command = command.chain(new ICommandProxy(boundsCommand));
- command = moveCascadeLifeline(part, command, dy);
- }
-
- return command;
- }
-
- // move all lifelines which has incoming create link from part
- public static Command moveCascadeLifeline(LifelineEditPart part, Command command, int dy) {
- List list = part.getSourceConnections();
- if(list != null && list.size() > 0) {
- for(Object l : list)
- if(l instanceof Message4EditPart) {
- EditPart target = ((Message4EditPart)l).getTarget();
- if(target instanceof LifelineEditPart) {
- LifelineEditPart lp = (LifelineEditPart)target;
- Rectangle bounds = lp.getFigure().getBounds().getCopy();
- View targetView = lp.getNotationView();
- Point location = bounds.getLocation().getCopy().translate(0, dy);
- Command boundsCommand = new ICommandProxy(new SetBoundsCommand(part.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(targetView), location));
- // Take care of the order of commands, to make sure target is always bellow the source.
- if(dy < 0){ // move up
- command = command == null? boundsCommand: command.chain(boundsCommand);
- command = moveCascadeLifeline(lp, command, dy);
- }else{ // move down
- command = moveCascadeLifeline(lp, command, dy);
- command = command == null? boundsCommand: command.chain(boundsCommand);
- }
- }
- }
- }
- return command;
- }
-
- public static boolean canMoveLifelineVertical(LifelineEditPart child, Rectangle newBounds) {
- int halfHeight = child.getPrimaryShape().getFigureLifelineNameContainerFigure().getBounds().height / 2;
- // check outgoing links
- List list = child.getSourceConnections();
- if(list != null && list.size() > 0) {
- for(Object l : list)
- if(l instanceof Message4EditPart && ((Message4EditPart)l).getTarget() instanceof LifelineEditPart) {
- LifelineEditPart lowPart = (LifelineEditPart)((Message4EditPart)l).getTarget();
- Rectangle outBounds = lowPart.getFigure().getBounds();
- if(outBounds.y - newBounds.y < halfHeight)
- return false;
- }
- }
- // check incoming links
- list = child.getTargetConnections();
- if(list != null && list.size() > 0) {
- for(Object l : list)
- if(l instanceof Message4EditPart && ((Message4EditPart)l).getSource() instanceof LifelineEditPart) {
- LifelineEditPart highPart = (LifelineEditPart)((Message4EditPart)l).getSource();
- Rectangle inBounds = highPart.getFigure().getBounds();
- if(newBounds.y - inBounds.y < halfHeight)
- return false;
-
- if(newBounds.y > inBounds.getBottom().y - halfHeight)
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineModelChildrenHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineModelChildrenHelper.java
deleted file mode 100644
index 6e4b1b9be65..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineModelChildrenHelper.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-
-
-public class LifelineModelChildrenHelper {
-
- /**
- * Try to fixed the bug about display ExecutionSpecifications(ES).
- *
- * At some times, the child ES would be displayed under the parent ES.
- *
- * Fixed to sort them with bounds in model before creating.
- */
- public static List<View> getModelChildren(View lifeline) {
- if(lifeline == null) {
- return Collections.emptyList();
- }
- @SuppressWarnings("unchecked")
- List<View> children = new ArrayList<View>(lifeline.getVisibleChildren());
- sortChildren(children);
- return children;
- }
-
- private static void sortChildren(List<View> children) {
- Collections.sort(children, new Comparator<Object>() {
-
- public int compare(Object o1, Object o2) {
- if(!(o1 instanceof View && o2 instanceof View)) {
- return 0;
- }
- View v1 = (View)o1;
- View v2 = (View)o2;
- EObject e1 = ViewUtil.resolveSemanticElement(v1);
- EObject e2 = ViewUtil.resolveSemanticElement(v2);
- if(!(e1 instanceof ExecutionSpecification && e2 instanceof ExecutionSpecification)) {
- return 0;
- }
- Rectangle r1 = getViewBounds(v1);
- Rectangle r2 = getViewBounds(v2);
- if(r1 == null || r2 == null) {
- return 0;
- }
- if(r1.width <= 0) {
- r1.width = 16;
- }
- if(r2.width <= 0) {
- r2.width = 16;
- }
-
- if((r1.x < r2.x) || r1.right() < r2.right()) {
- return -1;
- }
- return 1;
- }
- });
- }
-
- private static Rectangle getViewBounds(View view) {
- if(view == null) {
- return null;
- }
- Integer x = getFeatureValue(view, NotationPackage.eINSTANCE.getLocation_X());
- Integer y = getFeatureValue(view, NotationPackage.eINSTANCE.getLocation_Y());
- Integer width = getFeatureValue(view, NotationPackage.eINSTANCE.getSize_Width());
- Integer height = getFeatureValue(view, NotationPackage.eINSTANCE.getSize_Height());
- if(x == null && y == null && width == null && height == null) {
- return null;
- }
- return new Rectangle(x == null ? 0 : x.intValue(), y == null ? 0 : y.intValue(), width == null ? -1 : width.intValue(), height == null ? -1 : height.intValue());
- }
-
- private static Integer getFeatureValue(View view, EStructuralFeature feature) {
- if(view == null || feature == null) {
- return null;
- }
- return (Integer)ViewUtil.getPropertyValue(view, feature, feature.getEContainingClass());
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java
deleted file mode 100644
index a7728f520b2..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineResizeHelper.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-
-
-public class LifelineResizeHelper {
-
- private static final String MANUAL_LABEL_SIZE = "manual.label.size";
- private static final String CUSTOM_EXTENSION_INFO = "CustomExtensionInfo";
-
- public static boolean isManualSize(LifelineEditPart lp){
- View view = lp.getNotationView();
- EAnnotation oldAnnotation = view.getEAnnotation(CUSTOM_EXTENSION_INFO);
- if(oldAnnotation != null) {
- String val = oldAnnotation.getDetails().get(MANUAL_LABEL_SIZE);
- return "true".equalsIgnoreCase(val);
- }
- return false;
- }
-
- public static ICommand createManualLabelSizeCommand(TransactionalEditingDomain domain, IAdaptable adapter){
- return new ManualLabelSizeCommand(domain, adapter, CUSTOM_EXTENSION_INFO);
- }
-
- public static ICommand createManualLabelSizeCommand(LifelineEditPart lifelineEP){
- return new ManualLabelSizeCommand(lifelineEP.getEditingDomain(), lifelineEP.getNotationView(), CUSTOM_EXTENSION_INFO);
- }
-
- public static class ManualLabelSizeCommand extends AbstractTransactionalCommand {
-
- public EModelElement getObject() {
- if(object != null)
- return object;
- if(adapter != null){
- return (View)adapter.getAdapter(View.class);
- }
- return null;
- }
-
- /** The object. */
- private EModelElement object;
-
- /** The e annotation name. */
- private String eAnnotationName;
-
- private IAdaptable adapter;
-
- public ManualLabelSizeCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
- super(domain,"manual size", null);
- this.object = object;
- this.eAnnotationName = eannotationName;
- }
-
- public ManualLabelSizeCommand(TransactionalEditingDomain domain, IAdaptable adapter, String eannotationName) {
- super(domain,"manual size", null);
- this.adapter = adapter;
- this.eAnnotationName = eannotationName;
- }
-
- protected EAnnotation createEAnnotation() {
- EAnnotation eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
- eannotation.setSource(eAnnotationName);
- return eannotation;
- }
-
- protected void attachEannotation(EAnnotation annotation, EModelElement object) {
- object.getEAnnotations().add(annotation);
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- EAnnotation oldAnnotation = getObject().getEAnnotation(eAnnotationName);
- if(oldAnnotation == null) {
- oldAnnotation = createEAnnotation();
- attachEannotation(oldAnnotation, getObject());
- }
- oldAnnotation.getDetails().put(MANUAL_LABEL_SIZE, "true");
- return CommandResult.newOKCommandResult();
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LoopOperatorUtil.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LoopOperatorUtil.java
deleted file mode 100644
index f29e528dc37..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LoopOperatorUtil.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import org.eclipse.papyrus.uml.service.types.utils.InteractionConstraintUtil;
-import org.eclipse.uml2.uml.InteractionConstraint;
-
-/**
- * Loop operand could have iteration bounds which may include a lower and an upper number of iterations of the loop. Textual syntax of the loop is:
- * loop-operand ::= loop [ '(' min-int [ ',' max-int ] ')' ]
- * min-int ::= non-negative-integer
- * max-int ::= positive-integer | '*'
- *
- * 1. If loop has no bounds specified, it means potentially infinite loop with zero as lower bound and infinite upper bound..
- * 2. If only min-int is specified, it means that upper bound is equal to the lower bound, and loop will be executed exactly the specified
- * number of times.
- * 3. If max-int is specified, it should be greater than or equal to min-int. Loop will iterate minimum the min-int number of times and at
- * most the max-int number of times.
- *
- * @author Jin Liu (jin.liu@soyatec.com)
- */
-public class LoopOperatorUtil {
-
- public static String getLoopCondition(InteractionConstraint guard) {
- if(guard == null) {
- return null;
- }
- Integer minint = InteractionConstraintUtil.getMinintValue(guard);
- Integer maxint = InteractionConstraintUtil.getMaxintValue(guard);
-
- if(minint == null && maxint == null) {
- return "";
- }
- if(minint != null && maxint == null && minint.intValue() == 0) {
- maxint = Integer.MAX_VALUE;
- }
- if(minint == null) {
- minint = Integer.valueOf(0);
- }
- StringBuffer buf = new StringBuffer("(");
- buf.append(minint.intValue());
- if(maxint != null) {
- if(maxint.intValue() != minint.intValue()) {
- buf.append(", ");
- if(Integer.MAX_VALUE == maxint) {
- buf.append("*");
- } else {
- buf.append(maxint);
- }
- }
- }
- buf.append(")");
- return new String(buf);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java
deleted file mode 100644
index 80f89be9a51..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import org.eclipse.core.databinding.observable.IObservable;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.Style;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
-import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
-import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
-import org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement;
-import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
-import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
-
-
-public class MessageStyleElementFactory implements ModelElementFactory {
-
- public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
- View view = NotationHelper.findView(sourceElement);
- if(view != null && view instanceof Edge) {
- return new MessageStyleModelElement((Edge)view, context);
- }
- return null;
- }
-
- static class MessageStyleModelElement extends AbstractModelElement {
-
- protected DataContextElement context;
-
- private Edge source;
-
- public MessageStyleModelElement(Edge source, DataContextElement context) {
- this.context = context;
- this.source = source;
- }
-
- @Override
- protected IObservable doGetObservable(String propertyPath) {
- EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(source);
- Style style = null;
- if(context.getName().equals("LineStyle")) {
- style = source.getStyle(NotationPackage.Literals.LINE_STYLE);
- } else if(context.getName().equals("FontStyle")) {
- style = source.getStyle(NotationPackage.Literals.FONT_STYLE);
- }
- if(style != null) {
- EStructuralFeature feature = style.eClass().getEStructuralFeature(propertyPath);
- return new PapyrusObservableValue(style, feature, domain);
- }
- return null;
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/NotificationHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/NotificationHelper.java
deleted file mode 100644
index 116a4cdaf9a..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/NotificationHelper.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl;
-
-public class NotificationHelper {
-
- private UIAdapterImpl modelListener;
-
- private List<Notifier> listeners = new ArrayList<Notifier>();
-
- public NotificationHelper(UIAdapterImpl modelListener) {
- this.modelListener = modelListener;
- }
-
- /**
- * Add listener on a element
- *
- * @param element
- * The object to listen
- */
- public void listenObject(Notifier element) {
- // Only listen the object if it isn't yet listened
- if(element != null && !element.eAdapters().contains(modelListener)) {
- element.eAdapters().add(modelListener);
- listeners.add(element);
- }
- }
-
- /**
- * Remove listener on a element
- *
- * @param element
- * The object to unlisten
- */
- public void unlistenObject(Notifier element) {
- // Only listen the object if it isn't yet listened
- if(element != null && element.eAdapters().contains(modelListener)) {
- element.eAdapters().remove(modelListener);
- }
- listeners.remove(element);
- }
-
- /**
- * Remove all listeners
- */
- public void unlistenAll() {
- if(listeners.size() > 0) {
- for(Notifier listener : listeners) {
- if(listener != null && listener.eAdapters().contains(modelListener)) {
- listener.eAdapters().remove(modelListener);
- }
- }
- listeners.clear();
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java
deleted file mode 100644
index c08af5a6d40..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java
+++ /dev/null
@@ -1,1126 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.IdentityAnchor;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.runtime.notation.impl.ConnectorImpl;
-import org.eclipse.papyrus.uml.diagram.common.helper.InteractionFragmentHelper;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart;
-import org.eclipse.uml2.common.util.CacheAdapter;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.DurationConstraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.GeneralOrdering;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.IntervalConstraint;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.TimeConstraint;
-import org.eclipse.uml2.uml.TimeObservation;
-
-/**
- * This Helper must be used for performing move/reconnect operations which modify the location of an OccurrenceSpecification.
- *
- * @author vhemery
- */
-public class OccurrenceSpecificationMoveHelper {
-
- /**
- * Get the complete command to move or reconnect all edit parts attached to one or two occurrence specification(s).
- *
- * @param movedOccurrenceSpecification1
- * first moved occurrence specification
- * @param movedOccurrenceSpecification2
- * second moved occurrence specification (or null)
- * @param yLocation1
- * y location where first occurrence specification is moved
- * @param yLocation2
- * y location where second occurrence specification is moved (or -1)
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @param notToMoveEditParts
- * list of edit parts which must not be moved in the created command
- * @return command to move all edit parts linked to the occurrence specifications or null
- */
- public static Command getMoveOccurrenceSpecificationsCommand(OccurrenceSpecification movedOccurrenceSpecification1, OccurrenceSpecification movedOccurrenceSpecification2, int yLocation1, int yLocation2, LifelineEditPart lifelinePart, List<EditPart> notToMoveEditParts) {
- // the global command which shall be completed and returned
- CompoundCommand globalCmd = new CompoundCommand();
- // move the corresponding execution specification if necessary
- Command command = getMoveExecutionSpecificationCommand(movedOccurrenceSpecification1, movedOccurrenceSpecification2, yLocation1, yLocation2, lifelinePart, notToMoveEditParts);
- if(command != null) {
- globalCmd.add(command);
- }
- // reconnect the corresponding message(s) if necessary
- if(movedOccurrenceSpecification1 instanceof MessageOccurrenceSpecification) {
- command = getReconnectMessageCommand(movedOccurrenceSpecification1, yLocation1, lifelinePart, notToMoveEditParts);
- if(command != null) {
- globalCmd.add(command);
- }
- }
- if(movedOccurrenceSpecification2 instanceof MessageOccurrenceSpecification) {
- command = getReconnectMessageCommand(movedOccurrenceSpecification2, yLocation2, lifelinePart, notToMoveEditParts);
- if(command != null) {
- globalCmd.add(command);
- }
- }
- // move the corresponding time/duration constraints/observations if necessary
- command = getMoveTimeElementsCommand(movedOccurrenceSpecification1, movedOccurrenceSpecification2, yLocation1, yLocation2, lifelinePart, notToMoveEditParts);
- if(command != null) {
- globalCmd.add(command);
- }
- // reconnect the corresponding general ordering(s) if necessary
- command = getReconnectGeneralOrderingCommand(movedOccurrenceSpecification1, yLocation1, lifelinePart, notToMoveEditParts);
- if(command != null) {
- globalCmd.add(command);
- }
- if(movedOccurrenceSpecification2 != null) {
- command = getReconnectGeneralOrderingCommand(movedOccurrenceSpecification2, yLocation2, lifelinePart, notToMoveEditParts);
- if(command != null) {
- globalCmd.add(command);
- }
- }
- // return null rather than an empty non executable command
- if(globalCmd.isEmpty()) {
- return null;
- }
- return globalCmd;
- }
-
- /**
- * Get the command to reconnect general ordering attached to a moved occurrence specification
- *
- * @param movedOccurrenceSpecification
- * moving occurrence specification
- * @param yLocation
- * y location where occurrence specification is moved
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @param notToMoveEditParts
- * list of edit parts which must not be moved in the created command
- * @return command to reconnect general ordering edit parts linked to the occurrence specification or null
- */
- private static Command getReconnectGeneralOrderingCommand(OccurrenceSpecification movedOccurrenceSpecification, int yLocation, LifelineEditPart lifelinePart, List<EditPart> notToMoveEditParts) {
- // the global command which shall be completed and returned
- CompoundCommand command = new CompoundCommand();
- Point referencePoint = getReferencePoint(lifelinePart, movedOccurrenceSpecification, yLocation);
- EditPart childToReconnectTo = SequenceUtil.findPartToReconnectTo(lifelinePart, referencePoint);
- // if referencePoint is on a moved part, it must be translated with the location delta of this part
- if(!notToMoveEditParts.isEmpty() && childToReconnectTo != lifelinePart) {
- Point oldLoc = SequenceUtil.findLocationOfEvent(lifelinePart, movedOccurrenceSpecification);
- referencePoint.y = oldLoc.y;
- }
- // reconnect general ordering from the event
- for(GeneralOrdering go : movedOccurrenceSpecification.getToAfters()) {
- Collection<Setting> settings = CacheAdapter.INSTANCE.getNonNavigableInverseReferences(go);
- for(Setting ref : settings) {
- if(NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View)ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the general ordering part must start or finish on the lifeline (with the event)
- if(part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) {
- Request reconnectRequest = makeReconnectRequest((ConnectionEditPart)part, true, referencePoint, childToReconnectTo);
- Command reconnect = childToReconnectTo.getCommand(reconnectRequest);
- if(reconnect.canExecute()) {
- command.add(reconnect);
- }
- }
- }
- }
- }
- // reconnect general ordering to the event
- for(GeneralOrdering go : movedOccurrenceSpecification.getToBefores()) {
- Collection<Setting> settings = CacheAdapter.INSTANCE.getNonNavigableInverseReferences(go);
- for(Setting ref : settings) {
- if(NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View)ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the general ordering part must start or finish on the lifeline (with the event)
- if(part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) {
- Request reconnectRequest = makeReconnectRequest((ConnectionEditPart)part, false, referencePoint, childToReconnectTo);
- Command reconnect = childToReconnectTo.getCommand(reconnectRequest);
- if(reconnect.canExecute()) {
- command.add(reconnect);
- }
- }
- }
- }
- }
- // return null rather than an empty non executable command
- if(command.isEmpty()) {
- return null;
- }
- return command;
- }
-
- /**
- * Get the command to reconnect message attached to a moved occurrence specification
- *
- * @param movedOccurrenceSpecification
- * moving occurrence specification
- * @param yLocation
- * y location where occurrence specification is moved
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @param notToMoveEditParts
- * list of edit parts which must not be moved in the created command
- * @return command to reconnect message edit part linked to the occurrence specification or null
- */
- private static Command getReconnectMessageCommand(OccurrenceSpecification movedOccurrenceSpecification, int yLocation, LifelineEditPart lifelinePart, List<EditPart> notToMoveEditParts) {
- // the global command which shall be completed and returned
- CompoundCommand command = new CompoundCommand();
- if(movedOccurrenceSpecification instanceof MessageOccurrenceSpecification) {
- Point referencePoint = getReferencePoint(lifelinePart, movedOccurrenceSpecification, yLocation);
- EditPart childToReconnectTo = SequenceUtil.findPartToReconnectTo(lifelinePart, referencePoint);
- // reconnect message from the event
- Message message = ((MessageOccurrenceSpecification)movedOccurrenceSpecification).getMessage();
- if(message != null && movedOccurrenceSpecification.equals(message.getSendEvent())) {
- Collection<Setting> settings = CacheAdapter.INSTANCE.getNonNavigableInverseReferences(message);
- for(Setting ref : settings) {
- if(NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View)ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the message part must start or finish on the lifeline (with the event)
- if(part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) {
- Request reconnectRequest = makeReconnectRequest((ConnectionEditPart)part, true, referencePoint, childToReconnectTo);
- Command reconnect = childToReconnectTo.getCommand(reconnectRequest);
- command.add(reconnect);
- // update enclosing interaction fragment
- Command updateIFrag = SequenceUtil.createUpdateEnclosingInteractionCommand((MessageOccurrenceSpecification)movedOccurrenceSpecification, referencePoint, lifelinePart);
- if(updateIFrag != null && updateIFrag.canExecute()) {
- command.add(updateIFrag);
- }
- }
- }
- }
- }
- // reconnect message to the event
- if(message != null && movedOccurrenceSpecification.equals(message.getReceiveEvent())) {
- Collection<Setting> settings = CacheAdapter.INSTANCE.getNonNavigableInverseReferences(message);
- for(Setting ref : settings) {
- if(NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View)ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the message part must start or finish on the lifeline (with the event)
- if(part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) {
- Request reconnectRequest = makeReconnectRequest((ConnectionEditPart)part, false, referencePoint, childToReconnectTo);
- Command reconnect = childToReconnectTo.getCommand(reconnectRequest);
- command.add(reconnect);
- // update enclosing interaction fragment
- Command updateIFrag = SequenceUtil.createUpdateEnclosingInteractionCommand((MessageOccurrenceSpecification)movedOccurrenceSpecification, referencePoint, lifelinePart);
- if(updateIFrag != null && updateIFrag.canExecute()) {
- command.add(updateIFrag);
- }
- }
- }
- }
- }
- }
-
- // return null rather than an empty non executable command
- if(command.isEmpty()) {
- return null;
- }
- return command;
- }
-
- /**
- * Get the command to move time/duration observations/constraints attached to a moved occurrence specification
- *
- * @param movedOccurrenceSpecification1
- * first moved occurrence specification
- * @param movedOccurrenceSpecification2
- * second moved occurrence specification (or null)
- * @param yLocation1
- * y location where first occurrence specification is moved
- * @param yLocation2
- * y location where second occurrence specification is moved (or -1)
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @param notToMoveEditParts
- * list of edit parts which must not be moved in the created command
- * @return command to move time edit parts linked to the occurrence specification or null
- */
- private static Command getMoveTimeElementsCommand(OccurrenceSpecification movedOccurrenceSpecification1, OccurrenceSpecification movedOccurrenceSpecification2, int yLocation1, int yLocation2, LifelineEditPart lifelinePart, List<EditPart> notToMoveEditParts) {
- // the global command which shall be completed and returned
- CompoundCommand globalCmd = new CompoundCommand();
- IFigure lifelineFigure = lifelinePart.getFigure();
- // relocate each linked time element contained within the lifeline part
- for(Object lifelineChild : lifelinePart.getChildren()) {
- if(lifelineChild instanceof IBorderItemEditPart && !notToMoveEditParts.contains(lifelineChild)) {
- final IBorderItemEditPart timePart = (IBorderItemEditPart)lifelineChild;
- Command cmd = getMoveSingleTimeRelatedElementCommand(timePart, movedOccurrenceSpecification1, movedOccurrenceSpecification2, yLocation1, yLocation2, lifelinePart);
- if(cmd != null) {
- globalCmd.add(cmd);
- }
- }
- }
-
- // relocate each observation linked time element
- for(Object targetConnection : lifelinePart.getTargetConnections()){
- if(targetConnection instanceof ObservationLinkEditPart){
- Command cmd = getMoveSingleTimeRelatedElementCommand((ObservationLinkEditPart)targetConnection, movedOccurrenceSpecification1, movedOccurrenceSpecification2, yLocation1, yLocation2, lifelinePart);
- if(cmd != null) {
- globalCmd.add(cmd);
- }
- }
- }
-
- // refresh layout commands :
- // one before the commands for the undo and one after for classic execution
- if(!globalCmd.isEmpty() && lifelineFigure instanceof BorderedNodeFigure) {
- Command relayout = getReLayoutCmd((BorderedNodeFigure)lifelineFigure, false);
- Command relayoutUndo = getReLayoutCmd((BorderedNodeFigure)lifelineFigure, true);
- if(relayout != null && relayoutUndo != null) {
- CompoundCommand commandWithRelayout = new CompoundCommand();
- commandWithRelayout.add(relayoutUndo);
- commandWithRelayout.add(globalCmd);
- commandWithRelayout.add(relayout);
- return commandWithRelayout;
- }
- }
- // return null rather than an empty non executable command
- if(globalCmd.isEmpty()) {
- return null;
- }
- return globalCmd;
- }
-
- private static Command getMoveSingleTimeRelatedElementCommand(
- final ObservationLinkEditPart targetConnection,
- final OccurrenceSpecification movedOccurrenceSpecification1,
- final OccurrenceSpecification movedOccurrenceSpecification2,
- final int yLocation1, final int yLocation2,final LifelineEditPart lifelinePart) {
-
- AbstractTransactionalCommand updateTargetAnchorCommand = new AbstractTransactionalCommand(((IGraphicalEditPart) targetConnection).getEditingDomain(),"update target anchor",null) {
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
-
- // both bounds may have changed
- Point referencePoint1 = getReferencePoint(lifelinePart, movedOccurrenceSpecification1, yLocation1);
- Point referencePoint2 = getReferencePoint(lifelinePart, movedOccurrenceSpecification2, yLocation2);
-
- int position1 = PositionConstants.NONE;
- int position2 = PositionConstants.NONE;
- TimeObservationLabelEditPart tolEP = (TimeObservationLabelEditPart)targetConnection.getSource();
- if(tolEP == null){
- return CommandResult.newCancelledCommandResult();
- }
-
- if(movedOccurrenceSpecification1 != null) {
- position1 = SequenceUtil.positionWhereEventIsLinkedToPart(movedOccurrenceSpecification1, tolEP);
- }
- if(movedOccurrenceSpecification2 != null) {
- position2 = SequenceUtil.positionWhereEventIsLinkedToPart(movedOccurrenceSpecification2, tolEP);
- }
- ConnectionAnchor targetAnchor = null;
- if(position1 == PositionConstants.CENTER){
- targetAnchor = lifelinePart.getNodeFigure().getSourceConnectionAnchorAt(referencePoint1);
- }else if(position2 == PositionConstants.CENTER){
- targetAnchor = lifelinePart.getNodeFigure().getSourceConnectionAnchorAt(referencePoint2);
- }
-
- if(targetAnchor!= null){
- String newTargetTerminal = lifelinePart.mapConnectionAnchorToTerminal(targetAnchor);
- ConnectorImpl c = (ConnectorImpl)targetConnection.getModel();
- if (newTargetTerminal != null) {
- if (newTargetTerminal.length() == 0)
- c.setTargetAnchor(null);
- else {
- IdentityAnchor a = (IdentityAnchor) c.getTargetAnchor();
- if (a == null)
- a = NotationFactory.eINSTANCE.createIdentityAnchor();
- a.setId(newTargetTerminal);
- c.setTargetAnchor(a);
- }
- }
-
- }
-
- return CommandResult.newOKCommandResult();
- }
- };
-
-
- // return the resize command
- ICommandProxy resize = new ICommandProxy(updateTargetAnchorCommand);
- return resize;
- }
-
- /**
- * Get a command to move the time related element's edit part
- *
- * @param timePart
- * time related element's edit part to move
- * @param movedOccurrenceSpecification1
- * first moved occurrence specification
- * @param movedOccurrenceSpecification2
- * second moved occurrence specification (or null)
- * @param yLocation1
- * y location where first occurrence specification is moved
- * @param yLocation2
- * y location where second occurrence specification is moved (or -1)
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @return
- */
- private static Command getMoveSingleTimeRelatedElementCommand(IBorderItemEditPart timePart, OccurrenceSpecification movedOccurrenceSpecification1, OccurrenceSpecification movedOccurrenceSpecification2, int yLocation1, int yLocation2, LifelineEditPart lifelinePart) {
- IFigure lifelineFigure = lifelinePart.getFigure();
- // get positions where edit part is attached to events
- int position1 = PositionConstants.NONE;
- int position2 = PositionConstants.NONE;
- if(movedOccurrenceSpecification1 != null) {
- position1 = SequenceUtil.positionWhereEventIsLinkedToPart(movedOccurrenceSpecification1, timePart);
- }
- if(movedOccurrenceSpecification2 != null) {
- position2 = SequenceUtil.positionWhereEventIsLinkedToPart(movedOccurrenceSpecification2, timePart);
- }
- // move necessary bounds
- Rectangle newBounds = null;
- if(position1 != PositionConstants.NONE && position2 != PositionConstants.NONE) {
- // both bounds may have changed
- Point referencePoint1 = getReferencePoint(lifelinePart, movedOccurrenceSpecification1, yLocation1);
- Point referencePoint2 = getReferencePoint(lifelinePart, movedOccurrenceSpecification2, yLocation2);
- makeRelativeToLifeline(referencePoint1, lifelinePart, false);
- makeRelativeToLifeline(referencePoint2, lifelinePart, false);
- // Get old bounds information by consulting old figure
- int oldY = timePart.getFigure().getBounds().getLocation().y - lifelineFigure.getBounds().getLocation().y;
- int oldHeight = timePart.getFigure().getSize().height;
- // Compute new bounds of the time element
- if(position1 == PositionConstants.CENTER || position2 == PositionConstants.CENTER) {
- // should not happen, except if both events are merged at the same location
- newBounds = new Rectangle(referencePoint1.x, referencePoint1.y - oldHeight / 2, -1, oldHeight);
- } else {
- int top = oldY;
- int bottom = oldY + oldHeight;
- // bound is based on two events. Recompute it according to moved event(s).
- if(position1 == PositionConstants.TOP) {
- top = referencePoint1.y;
- } else if(position1 == PositionConstants.BOTTOM) {
- bottom = referencePoint1.y;
- }
- if(position2 == PositionConstants.TOP) {
- top = referencePoint2.y;
- } else if(position2 == PositionConstants.BOTTOM) {
- bottom = referencePoint2.y;
- }
- // top and bottom may have been inverted during the move.
- // restore x position, fix time duration always move to east
- int viewX = (Integer) ViewUtil.getPropertyValue((View) timePart.getModel(), NotationPackage.eINSTANCE
- .getLocation_X(), NotationPackage.eINSTANCE.getLocation_X().getEContainingClass());
-
- newBounds = new Rectangle(viewX, Math.min(top, bottom), -1, Math.abs(bottom - top));
-// newBounds = new Rectangle(referencePoint1.x, Math.min(top, bottom), -1, Math.abs(bottom - top));
- }
- } else if(position1 != PositionConstants.NONE) {
- Point referencePoint1 = getReferencePoint(lifelinePart, movedOccurrenceSpecification1, yLocation1);
- makeRelativeToLifeline(referencePoint1, lifelinePart, false);
- // Get old bounds information by consulting old figure
- int oldY = timePart.getFigure().getBounds().getLocation().y - lifelineFigure.getBounds().getLocation().y;
- int oldHeight = timePart.getFigure().getSize().height;
- // Compute new bounds of the time element
- if(position1 == PositionConstants.CENTER) {
- newBounds = new Rectangle(referencePoint1.x, referencePoint1.y - oldHeight / 2, -1, oldHeight);
- } else {
- int top = oldY;
- int bottom = oldY + oldHeight;
- // bound is based on two events. Recompute it according to moved event(s).
- if(position1 == PositionConstants.TOP) {
- top = referencePoint1.y;
- } else if(position1 == PositionConstants.BOTTOM) {
- bottom = referencePoint1.y;
- }
- // top and bottom may have been inverted during the move.
- newBounds = new Rectangle(referencePoint1.x, Math.min(top, bottom), -1, Math.abs(bottom - top));
- }
- } else if(position2 != PositionConstants.NONE) {
- Point referencePoint2 = getReferencePoint(lifelinePart, movedOccurrenceSpecification2, yLocation2);
- makeRelativeToLifeline(referencePoint2, lifelinePart, false);
- // Get old bounds information by consulting old figure
- int oldY = timePart.getFigure().getBounds().getLocation().y - lifelineFigure.getBounds().getLocation().y;
- int oldHeight = timePart.getFigure().getSize().height;
- // Compute new bounds of the time element
- if(position2 == PositionConstants.CENTER) {
- newBounds = new Rectangle(referencePoint2.x, referencePoint2.y - oldHeight / 2, -1, oldHeight);
- } else {
- int top = oldY;
- int bottom = oldY + oldHeight;
- // bound is based on two events. Recompute it according to moved event(s).
- if(position2 == PositionConstants.TOP) {
- top = referencePoint2.y;
- } else if(position2 == PositionConstants.BOTTOM) {
- bottom = referencePoint2.y;
- }
- // top and bottom may have been inverted during the move.
- newBounds = new Rectangle(referencePoint2.x, Math.min(top, bottom), -1, Math.abs(bottom - top));
- }
- }
- if(newBounds != null) {
- TransactionalEditingDomain editingDomain = timePart.getEditingDomain();
- // return the resize command
- ICommandProxy resize = new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter((View)timePart.getModel()), newBounds));
- return resize;
- }
- return null;
- }
-
- /**
- * Make an absolute point relative to a lifeline figure.
- *
- * @param absolutePoint
- * the absolute point to translate
- * @param lifelinePart
- * the containing lifeline edit part
- */
- private static void makeRelativeToLifeline(Point absolutePoint, LifelineEditPart lifelinePart, boolean relativeToContentPane) {
- IFigure figure;
- if(relativeToContentPane) {
- figure = lifelinePart.getContentPane();
- } else {
- figure = lifelinePart.getFigure();
- }
- figure.translateToRelative(absolutePoint);
- absolutePoint.translate(figure.getBounds().getLocation().getNegated());
- }
-
- /**
- * Get the command to move execution specification(s) attached to moved occurrence specification(s)
- *
- * @param movedOccurrenceSpecification1
- * first moved occurrence specification
- * @param movedOccurrenceSpecification2
- * second moved occurrence specification (or null)
- * @param yLocation1
- * y location where first occurrence specification is moved
- * @param yLocation2
- * y location where second occurrence specification is moved (or -1)
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @param notToMoveEditParts
- * list of edit parts which must not be moved in the created command
- * @return command to move execution specification edit part linked to the occurrence specification or null
- */
- private static Command getMoveExecutionSpecificationCommand(OccurrenceSpecification movedOccurrenceSpecification1, OccurrenceSpecification movedOccurrenceSpecification2, int yLocation1, int yLocation2, LifelineEditPart lifelinePart, List<EditPart> notToMoveEditParts) {
- // the global command which shall be completed and returned
- CompoundCommand globalCmd = new CompoundCommand();
- // execution(s) linked to the event must be resized
- EditPart node1 = null;
- if(movedOccurrenceSpecification1 != null) {
- node1 = SequenceUtil.getLinkedEditPart(lifelinePart, movedOccurrenceSpecification1);
- }
- EditPart node2 = null;
- if(movedOccurrenceSpecification2 != null) {
- node2 = SequenceUtil.getLinkedEditPart(lifelinePart, movedOccurrenceSpecification2);
- }
- if(node1 instanceof GraphicalEditPart && !notToMoveEditParts.contains(node1)) {
- Command cmd = getMoveSingleExecutionSpecificationCommand((GraphicalEditPart)node1, movedOccurrenceSpecification1, movedOccurrenceSpecification2, yLocation1, yLocation2, lifelinePart);
- if(cmd != null) {
- globalCmd.add(cmd);
- }
- }
- if(node2 != node1 && node2 instanceof GraphicalEditPart && !notToMoveEditParts.contains(node2)) {
- Command cmd = getMoveSingleExecutionSpecificationCommand((GraphicalEditPart)node2, movedOccurrenceSpecification2, null, yLocation2, -1, lifelinePart);
- if(cmd != null) {
- globalCmd.add(cmd);
- }
- }
- // return null rather than an empty non executable command
- if(globalCmd.isEmpty()) {
- return null;
- }
- return globalCmd;
- }
-
- /**
- * Get the command to move an execution specification attached to moved occurrence specification(s)
- *
- * @param executionSpecificationPart
- * the execution specification edit part to move
- * @param movedOccurrenceSpecification1
- * first moved occurrence specification
- * @param movedOccurrenceSpecification2
- * second moved occurrence specification (or null)
- * @param yLocation1
- * y location where first occurrence specification is moved
- * @param yLocation2
- * y location where second occurrence specification is moved (or -1)
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @return command to move the execution specification edit part or null
- */
- private static Command getMoveSingleExecutionSpecificationCommand(GraphicalEditPart executionSpecificationPart, OccurrenceSpecification movedOccurrenceSpecification1, OccurrenceSpecification movedOccurrenceSpecification2, int yLocation1, int yLocation2, LifelineEditPart lifelinePart) {
- // execution linked to the event must be resized
- EObject execution = executionSpecificationPart.resolveSemanticElement();
- if(execution instanceof ExecutionSpecification) {
- // finish or start events of the execution have been moved
- // get positions where execution edit part is attached to events
- int position1 = PositionConstants.NONE;
- int position2 = PositionConstants.NONE;
- OccurrenceSpecification start = ((ExecutionSpecification)execution).getStart();
- OccurrenceSpecification finish = ((ExecutionSpecification)execution).getFinish();
- if(start != null && start.equals(movedOccurrenceSpecification1)) {
- position1 = PositionConstants.TOP;
- } else if(finish != null && finish.equals(movedOccurrenceSpecification1)) {
- position1 = PositionConstants.BOTTOM;
- }
- if(start != null && start.equals(movedOccurrenceSpecification2)) {
- position2 = PositionConstants.TOP;
- } else if(finish != null && finish.equals(movedOccurrenceSpecification2)) {
- position2 = PositionConstants.BOTTOM;
- }
- // move necessary bounds
- Rectangle newBounds = null;
- int heighDelta = 0;
- if(position1 != PositionConstants.NONE && position2 != PositionConstants.NONE) {
- // both bounds have changed
- Point referencePoint1 = getReferencePoint(lifelinePart, movedOccurrenceSpecification1, yLocation1);
- Point referencePoint2 = getReferencePoint(lifelinePart, movedOccurrenceSpecification2, yLocation2);
- makeRelativeToLifeline(referencePoint1, lifelinePart, true);
- makeRelativeToLifeline(referencePoint2, lifelinePart, true);
- // Get old bounds information by consulting old figure
- Rectangle esBounds = SequenceUtil.getAbsoluteBounds(executionSpecificationPart);
- Point esLoc = esBounds.getLocation();
- makeRelativeToLifeline(esLoc, lifelinePart, true);
- esBounds.setLocation(esLoc);
- int oldX = esBounds.x;
- int oldY = esBounds.y;
- int oldWidth = esBounds.width;
- int oldHeight = esBounds.height;
- // Compute new bounds of the time element
- int top = oldY;
- int bottom = oldY + oldHeight;
- // bound is based on two events. Recompute it according to moved event(s).
- if(position1 == PositionConstants.TOP) {
- top = referencePoint1.y;
- } else if(position1 == PositionConstants.BOTTOM) {
- bottom = referencePoint1.y;
- }
- if(position2 == PositionConstants.TOP) {
- top = referencePoint2.y;
- } else if(position2 == PositionConstants.BOTTOM) {
- bottom = referencePoint2.y;
- }
- // top and bottom may have been inverted during the move.
- newBounds = new Rectangle(oldX, Math.min(top, bottom), oldWidth, Math.abs(bottom - top));
- } else if(position1 != PositionConstants.NONE) {
- Point referencePoint1 = getReferencePoint(lifelinePart, movedOccurrenceSpecification1, yLocation1);
- makeRelativeToLifeline(referencePoint1, lifelinePart, true);
- // Get old bounds information by consulting old figure
- Rectangle esBounds = SequenceUtil.getAbsoluteBounds(executionSpecificationPart);
- Point esLoc = esBounds.getLocation();
- makeRelativeToLifeline(esLoc, lifelinePart, true);
- esBounds.setLocation(esLoc);
- int oldX = esBounds.x;
- int oldY = esBounds.y;
- int oldWidth = esBounds.width;
- int oldHeight = esBounds.height;
- // Compute new bounds of the time element
- int top = oldY;
- int bottom = oldY + oldHeight;
- // bound is based on two events. Recompute it according to moved event(s).
- if(position1 == PositionConstants.TOP) {
- top = referencePoint1.y;
- } else if(position1 == PositionConstants.BOTTOM) {
- bottom = referencePoint1.y;
- }
- // top and bottom may have been inverted during the move.
- newBounds = new Rectangle(oldX, Math.min(top, bottom), oldWidth, Math.abs(bottom - top));
- } else if(position2 != PositionConstants.NONE) {
- Point referencePoint2 = getReferencePoint(lifelinePart, movedOccurrenceSpecification2, yLocation2);
- makeRelativeToLifeline(referencePoint2, lifelinePart, true);
- // Get old bounds information by consulting old figure
- Rectangle esBounds = SequenceUtil.getAbsoluteBounds(executionSpecificationPart);
- Point esLoc = esBounds.getLocation();
- makeRelativeToLifeline(esLoc, lifelinePart, true);
- esBounds.setLocation(esLoc);
- int oldX = esBounds.x;
- int oldY = esBounds.y;
- int oldWidth = esBounds.width;
- int oldHeight = esBounds.height;
- // Compute new bounds of the time element
- int top = oldY;
- int bottom = oldY + oldHeight;
- // bound is based on two events. Recompute it according to moved event(s).
- if(position2 == PositionConstants.TOP) {
- top = referencePoint2.y;
- } else if(position2 == PositionConstants.BOTTOM) {
- bottom = referencePoint2.y;
- }
- // top and bottom may have been inverted during the move.
- newBounds = new Rectangle(oldX, Math.min(top, bottom), oldWidth, Math.abs(bottom - top));
- }
- if(newBounds != null) {
- // adjust bounds for execution specification
- newBounds.height -= heighDelta;
- TransactionalEditingDomain editingDomain = executionSpecificationPart.getEditingDomain();
- // return the resize command
- ICommandProxy resize = new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter((View)executionSpecificationPart.getModel()), newBounds));
- return resize;
- }
- }
- return null;
- }
-
- /**
- * Get the reference point to reconnect or resize edit parts at the given y location
- *
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @param movedOccurrenceSpecification
- * the moving occurrence specification which a reference point is searched for
- * @param yLocation
- * y location
- * @return reference point on the lifeline
- */
- private static Point getReferencePoint(LifelineEditPart lifelinePart, OccurrenceSpecification movedOccurrenceSpecification, int yLocation) {
- Point referencePoint = SequenceUtil.findLocationOfEvent(lifelinePart, movedOccurrenceSpecification);
- if(referencePoint == null) {
- referencePoint = lifelinePart.getFigure().getBounds().getCenter().getCopy();
- }
- referencePoint.y = yLocation;
- return referencePoint;
- }
-
- /**
- * Chain the commands to move associated parts when a connection end is reconnected.
- *
- * @param command
- * existing reconnection command
- * @param request
- * the reconnection request
- * @param connectableNode
- * the node edit part connected to the moved connection
- * @return the completed command
- */
- public static Command completeReconnectConnectionCommand(Command command, ReconnectRequest request, INodeEditPart connectableNode) {
- if(chainEffectIsDisabled(request)) {
- return command;
- }
- CompoundCommand globalCmd = new CompoundCommand();
- globalCmd.add(command);
- List<EditPart> notToMoveEditParts = new ArrayList<EditPart>(1);
- notToMoveEditParts.add(request.getConnectionEditPart());
- // move time related elements linked with the event
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(connectableNode);
- MessageEnd event = getMessageEndFromReconnectMessage(request);
- if(event instanceof OccurrenceSpecification) {
- Command cmd = getMoveOccurrenceSpecificationsCommand((OccurrenceSpecification)event, null, request.getLocation().y, -1, lifelinePart, notToMoveEditParts);
- if(cmd != null) {
- globalCmd.add(cmd);
- }
- }
- OccurrenceSpecification event2 = getOccurrenceSpecificationFromReconnectGeneralOrdering(request);
- if(event2 instanceof OccurrenceSpecification) {
- Command cmd = getMoveOccurrenceSpecificationsCommand((OccurrenceSpecification)event2, null, request.getLocation().y, -1, lifelinePart, notToMoveEditParts);
- if(cmd != null) {
- globalCmd.add(cmd);
- }
- }
- return globalCmd;
- }
-
- /**
- * Check if moving chain effect has been disabled to avoid an infinite loop.
- *
- * @param request
- * the request wich initiated the move
- * @return true if no additional command must be performed.
- */
- private static boolean chainEffectIsDisabled(Request request) {
- Object doNotToMoveEditParts = request.getExtendedData().get(SequenceRequestConstant.DO_NOT_MOVE_EDIT_PARTS);
- return Boolean.TRUE.equals(doNotToMoveEditParts);
- }
-
- /**
- * Complete a command to move time/duration constraints/observation which are linked to the moved edit part
- *
- * @param compoundCmd
- * existing command to complete
- * @param executionSpecificationEP
- * the moved edit part representing an execution specification
- * @param newBounds
- * the new part's bounds (relative to the figure's parent)
- * @param request
- * the change bounds request which originated this move
- * @return the updated parameter compoundCmd for convenience
- */
- public static CompoundCommand completeMoveExecutionSpecificationCommand(CompoundCommand compoundCmd, ShapeNodeEditPart executionSpecificationEP, Rectangle newBounds, ChangeBoundsRequest request) {
- if(chainEffectIsDisabled(request)) {
- return compoundCmd;
- }
- // Move events delimiting the ExecutionSpecification
- EObject execSpec = executionSpecificationEP.resolveSemanticElement();
- if(execSpec instanceof ExecutionSpecification) {
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(executionSpecificationEP);
- // first, get absolute bounds
- newBounds = newBounds.getCopy();
- IFigure parentFig = executionSpecificationEP.getFigure().getParent();
- parentFig.translateToAbsolute(newBounds);
- newBounds.translate(parentFig.getBounds().getLocation());
-
- // move start and finish events
- OccurrenceSpecification start = ((ExecutionSpecification)execSpec).getStart();
- int startY = newBounds.getTop().y;
- OccurrenceSpecification finish = ((ExecutionSpecification)execSpec).getFinish();
- int finishY = newBounds.getBottom().y;
- List<EditPart> notToMoveEditParts = new ArrayList<EditPart>(1);
- notToMoveEditParts.add(executionSpecificationEP);
- Command cmd = getMoveOccurrenceSpecificationsCommand(start, finish, startY, finishY, lifelinePart, notToMoveEditParts);
- if(cmd != null) {
- compoundCmd.add(cmd);
- }
-
- if(request.getSizeDelta().height == 0) {
- // move time elements for events between start and finish
- InteractionFragment nextOccSpec = InteractionFragmentHelper.findNextFragment(start, start.eContainer());
- while(nextOccSpec != null && nextOccSpec != finish) {
- Point occSpecLocation = SequenceUtil.findLocationOfEvent(lifelinePart, nextOccSpec);
- if(nextOccSpec instanceof OccurrenceSpecification && occSpecLocation != null) {
- int occSpecY = occSpecLocation.y + request.getMoveDelta().y;
- cmd = getMoveTimeElementsCommand((OccurrenceSpecification)nextOccSpec, null, occSpecY, -1, lifelinePart, notToMoveEditParts);
- if(cmd != null) {
- compoundCmd.add(cmd);
- }
- }
- nextOccSpec = InteractionFragmentHelper.findNextFragment(nextOccSpec, start.eContainer());
- }
- }
- }
- return compoundCmd;
- }
-
- /**
- * Prepare a request which is supposed to move a time/duration constraints/observation edit part.
- * The request will be updated if some operations are forbidden.
- *
- * @param request
- * the move request
- * @param movedTimePart
- * the moved time/duration constraints/observation edit part.
- */
- public static void prepareTimeRelatedElementMoveRequest(ChangeBoundsRequest request, IBorderItemEditPart movedTimePart) {
- // Erase the y move if element can not be moved on y axe
- if(!canTimeElementPartBeYMoved(movedTimePart)) {
- request.getMoveDelta().y = 0;
- }
- }
-
- /**
- * Complete the command to move an edit part representing a time/duration constraints/observation.
- *
- * @param moveCommand
- * the move command to complete with chaining
- * @param request
- * the request which initiated the move
- * @param hostFigure
- * figure which is being moved
- * @param hostEditPart
- * edit part which is being moved
- * @return the complete command.
- */
- public static Command completeMoveTimeRelatedElementCommand(Command moveCommand, ChangeBoundsRequest request, EditPart hostEditPart, IFigure hostFigure) {
- if(chainEffectIsDisabled(request)) {
- return moveCommand;
- }
- Rectangle bounds = request.getTransformedRectangle(hostFigure.getBounds());
- hostFigure.getParent().translateToAbsolute(bounds);
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(hostEditPart);
- if(lifelinePart != null && hostEditPart instanceof IBorderItemEditPart) {
- IBorderItemEditPart timeElementEditPart = (IBorderItemEditPart)hostEditPart;
- EObject timeElement = timeElementEditPart.resolveSemanticElement();
- OccurrenceSpecification occSpec1 = null;
- int yLocation1 = -1;
- OccurrenceSpecification occSpec2 = null;
- int yLocation2 = -1;
- // find occurrence specifications of the time element
- if(timeElement instanceof TimeConstraint) {
- Iterator<Element> it = ((TimeConstraint)timeElement).getConstrainedElements().iterator();
- while(it.hasNext() && occSpec1 == null) {
- Element elem = it.next();
- if(elem instanceof OccurrenceSpecification) {
- int position1 = whereEventIsLinked((OccurrenceSpecification)elem, timeElementEditPart);
- if(position1 != PositionConstants.NONE) {
- occSpec1 = (OccurrenceSpecification)elem;
- yLocation1 = getLocation(bounds, position1).y;
- }
- }
- }
- } else if(timeElement instanceof TimeObservation) {
- NamedElement event = ((TimeObservation)timeElement).getEvent();
- if(event instanceof OccurrenceSpecification) {
- int position1 = whereEventIsLinked((OccurrenceSpecification)event, timeElementEditPart);
- if(position1 != PositionConstants.NONE) {
- occSpec1 = (OccurrenceSpecification)event;
- yLocation1 = getLocation(bounds, position1).y;
- }
- }
- } else if(timeElement instanceof DurationConstraint) {
- Iterator<Element> it = ((DurationConstraint)timeElement).getConstrainedElements().iterator();
- while(it.hasNext() && (occSpec1 == null || occSpec2 == null)) {
- Element elem = it.next();
- if(elem instanceof OccurrenceSpecification && occSpec1 != null) {
- int position2 = whereEventIsLinked((OccurrenceSpecification)elem, timeElementEditPart);
- if(position2 != PositionConstants.NONE) {
- occSpec2 = (OccurrenceSpecification)elem;
- yLocation2 = getLocation(bounds, position2).y;
- }
- } else if(elem instanceof OccurrenceSpecification) {
- int position1 = whereEventIsLinked((OccurrenceSpecification)elem, timeElementEditPart);
- if(position1 != PositionConstants.NONE) {
- occSpec1 = (OccurrenceSpecification)elem;
- yLocation1 = getLocation(bounds, position1).y;
- }
- }
- }
- }
- if(occSpec1 != null) {
- List<EditPart> notToMoveEditParts = Collections.singletonList(hostEditPart);
- Command cmd = getMoveOccurrenceSpecificationsCommand(occSpec1, occSpec2, yLocation1, yLocation2, lifelinePart, notToMoveEditParts);
- if(cmd != null) {
- return moveCommand.chain(cmd);
- }
- }
- }
- return null;
- }
-
- /**
- * Make the request to reconnect the connection
- *
- * @param connection
- * connection part
- * @param isSource
- * true if the source must be reconnect, false for target
- * @param location
- * the location where to reconnect
- * @param partToReconnectTo
- * the part which the connection must be reconnected to (or null if unknown or of no importance)
- * @return the reconnection request
- */
- @SuppressWarnings("unchecked")
- private static ReconnectRequest makeReconnectRequest(ConnectionEditPart connection, boolean isSource, Point location, EditPart partToReconnectTo) {
- // Obtain the target edit part
- EditPart targetEP = partToReconnectTo;
- String type;
- if(isSource) {
- type = RequestConstants.REQ_RECONNECT_SOURCE;
- if(targetEP == null) {
- targetEP = connection.getSource();
- }
- } else {
- type = RequestConstants.REQ_RECONNECT_TARGET;
- if(targetEP == null) {
- targetEP = connection.getTarget();
- }
- }
-
- // Create and set the properties of the request
- ReconnectRequest reconnReq = new ReconnectRequest();
- reconnReq.setConnectionEditPart(connection);
- reconnReq.setLocation(location);
- reconnReq.setTargetEditPart(targetEP);
- reconnReq.setType(type);
- // add a parameter to bypass the move impact to avoid infinite loop
- reconnReq.getExtendedData().put(SequenceRequestConstant.DO_NOT_MOVE_EDIT_PARTS, true);
-
- // Return the request
- return reconnReq;
- }
-
- /**
- * Get the location on the bounds
- *
- * @param bounds
- * the rectangle bounds
- * @param position
- * one of {@link PositionConstants#TOP}, {@link PositionConstants#CENTER}, {@link PositionConstants#BOTTOM}
- * @return the point at the given position or null if position is incorrect
- */
- private static Point getLocation(Rectangle bounds, int position) {
- if(position == PositionConstants.TOP) {
- return bounds.getTop();
- } else if(position == PositionConstants.CENTER) {
- return bounds.getCenter();
- } else if(position == PositionConstants.BOTTOM) {
- return bounds.getBottom();
- }
- return null;
- }
-
- /**
- * The position of the host where the event is linked
- *
- * @param event
- * the occurrence specification
- * @param hostEditPart
- * the host edit part which is linked to the occurrence specification
- * @return one of {@link PositionConstants#TOP}, {@link PositionConstants#CENTER}, {@link PositionConstants#BOTTOM},
- * {@link PositionConstants#NONE}
- */
- private static int whereEventIsLinked(OccurrenceSpecification event, EditPart hostEditPart) {
- if(hostEditPart instanceof IBorderItemEditPart) {
- return SequenceUtil.positionWhereEventIsLinkedToPart(event, (IBorderItemEditPart)hostEditPart);
- }
- return PositionConstants.NONE;
- }
-
- /**
- * Get the occurrence specification which correspond to the moved general ordering end
- *
- * @param request
- * the general odering reconnection request
- * @return moved OccurrenceSpecification or null
- */
- private static OccurrenceSpecification getOccurrenceSpecificationFromReconnectGeneralOrdering(ReconnectRequest request) {
- if(request.getConnectionEditPart() instanceof ConnectionEditPart) {
- EObject generalOrdering = ((ConnectionEditPart)request.getConnectionEditPart()).resolveSemanticElement();
- if(generalOrdering instanceof GeneralOrdering) {
- if(RequestConstants.REQ_RECONNECT_SOURCE.equals(request.getType())) {
- return ((GeneralOrdering)generalOrdering).getBefore();
- } else if(RequestConstants.REQ_RECONNECT_TARGET.equals(request.getType())) {
- return ((GeneralOrdering)generalOrdering).getAfter();
- }
- }
- }
- return null;
- }
-
- /**
- * Get the message end which correspond to the moved message end
- *
- * @param request
- * the message reconnection request
- * @return moved MessageEnd or null
- */
- private static MessageEnd getMessageEndFromReconnectMessage(ReconnectRequest request) {
- if(request.getConnectionEditPart() instanceof ConnectionEditPart) {
- EObject message = ((ConnectionEditPart)request.getConnectionEditPart()).resolveSemanticElement();
- if(message instanceof Message) {
- if(RequestConstants.REQ_RECONNECT_SOURCE.equals(request.getType())) {
- return ((Message)message).getSendEvent();
- } else if(RequestConstants.REQ_RECONNECT_TARGET.equals(request.getType())) {
- return ((Message)message).getReceiveEvent();
- }
- }
- }
- return null;
- }
-
- /**
- * Know whether this time element part can be moved within the lifeline or not.
- * Parts linked with a destruction event can not be moved since the destruction event is always at the end.
- *
- * @param timeElementPart
- * the part representing a time/duration constraint/observation
- * @return true if the part can be moved
- */
- public static boolean canTimeElementPartBeYMoved(IBorderItemEditPart timeElementPart) {
- EObject timeElement = timeElementPart.resolveSemanticElement();
- List<? extends Element> occurrences = Collections.emptyList();
- if(timeElement instanceof TimeObservation) {
- NamedElement occurence = ((TimeObservation)timeElement).getEvent();
- occurrences = Collections.singletonList(occurence);
- } else if(timeElement instanceof TimeConstraint || timeElement instanceof DurationConstraint) {
- occurrences = ((IntervalConstraint)timeElement).getConstrainedElements();
- }
- // check whether one of the time occurrences correspond to a DestructionEvent
- for(Element occurrence : occurrences) {
- if(occurrence instanceof DestructionOccurrenceSpecification) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Get a command which refreshes the bordered layout of the node.
- *
- * @param node
- * the node figure with bordered items (including time-related parts)
- * @param onUndo
- * if true the relayout will be done on undo only, if false it will be done on classic execute only
- * @return the refresh command
- */
- private static Command getReLayoutCmd(BorderedNodeFigure node, boolean onUndo) {
- // relayout the border container figure so that time elements are refreshed
- final IFigure container = node.getBorderItemContainer();
-
- if(onUndo) {
- return new Command() {
-
- @Override
- public void undo() {
- container.getLayoutManager().layout(container);
- }
- };
- } else {
- return new Command() {
-
- @Override
- public void execute() {
- container.getLayoutManager().layout(container);
- }
- };
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java
deleted file mode 100644
index f52c251d9f0..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java
+++ /dev/null
@@ -1,837 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.notation.Bounds;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.Shape;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.uml2.uml.CombinedFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-
-public class OperandBoundsComputeHelper {
-
- /**
- * Default height of Interaction Operand
- */
- public static final int DEFAULT_INTERACTION_OPERAND_HEIGHT = 61;
-
- public static final int MIN_INTERACTION_OPERAND_HEIGHT = 10;
- /**
- * Default width of Interaction Operand
- */
- public static final int DEFAULT_INTERACTION_OPERAND_WIDTH = 210;
- /**
- * Border width of CombinedFragmentFigure
- */
- public static final int COMBINED_FRAGMENT_FIGURE_BORDER = 1;
-
- /**
- * Find first Interaction Operand EditpPart of CombinedFragmentCombinedFragmentCompartmentEditPart
- * @param compartEP
- * @return InteractionOperandEditPart
- */
- public static InteractionOperandEditPart findFirstIOEP(
- CombinedFragmentCombinedFragmentCompartmentEditPart compartEP) {
- InteractionOperandEditPart firstIOEP = null;
- List children = compartEP.getChildren();
- for (int i = 0; i < children.size(); i++) {
- if (children.get(i) instanceof InteractionOperandEditPart) {
- firstIOEP = (InteractionOperandEditPart) children.get(i);
- break;
- }
- }
- return firstIOEP;
- }
-
- /**
- * Find Last Interaction Operand EditpPart of CombinedFragmentCombinedFragmentCompartmentEditPart
- * @param compartEP
- * @return InteractionOperandEditPart
- */
- public static InteractionOperandEditPart findLastIOEP(
- CombinedFragmentCombinedFragmentCompartmentEditPart compartEP) {
- InteractionOperandEditPart lastIOEP = null;
- List children = compartEP.getChildren();
- for (int i = children.size() - 1; i >= 0; i--) {
- if (children.get(i) instanceof InteractionOperandEditPart) {
- lastIOEP = (InteractionOperandEditPart) children.get(i);
- break;
- }
- }
- return lastIOEP;
- }
-
- /**
- * Find Previous Interaction Operand EditpPart of current given InteractionOperandEditPart
- * @param compartEP
- * @param currentIOEP
- * @return InteractionOperandEditPart
- */
- public static InteractionOperandEditPart findPreviousIOEP(
- CombinedFragmentCombinedFragmentCompartmentEditPart compartEP,
- InteractionOperandEditPart currentIOEP) {
- InteractionOperandEditPart previousIOEP = null;
- List children = compartEP.getChildren();
- for (int i = 0; i < children.size() - 1; i++) {
- if (children.get(i) instanceof InteractionOperandEditPart) {
- if (children.get(i) == currentIOEP) {
- break;
- } else {
- previousIOEP = (InteractionOperandEditPart) children.get(i);
- }
- }
- }
- return previousIOEP;
- }
-
- /**
- * Find Latter Interaction Operand EditpPart of current given InteractionOperandEditPart
- * @param compartEP
- * @param currentIOEP
- * @return InteractionOperandEditPart
- */
- public static InteractionOperandEditPart findLatterIOEP(
- CombinedFragmentCombinedFragmentCompartmentEditPart compartEP,
- InteractionOperandEditPart currentIOEP) {
- InteractionOperandEditPart latterIOEP = null;
- List children = compartEP.getChildren();
- for (int i = children.size() - 1; i > 0; i--) {
- if (children.get(i) instanceof InteractionOperandEditPart) {
- if (children.get(i) == currentIOEP) {
- break;
- } else {
- latterIOEP = (InteractionOperandEditPart) children.get(i);
- }
- }
- }
- return latterIOEP;
- }
-
- /**
- * Update EditPart bounds using new rect
- * @param parent
- * @param rect
- */
- public static void updateEditPartBounds(GraphicalEditPart editpart,
- final Rectangle rect) {
- if (editpart.getModel() instanceof Node) {
- Node node = (Node) editpart.getModel();
- if (node.getLayoutConstraint() instanceof Bounds) {
- Bounds bounds = (Bounds) node.getLayoutConstraint();
- updateBounds(bounds, rect, editpart.getEditingDomain());
- }
- }
- }
-
- /**
- * Update EditPart bounds using new rect
- * @param parent
- * @param rect
- */
- public static ICommand createUpdateEditPartBoundsCommand(
- final GraphicalEditPart editpart, final Rectangle rect) {
- ICommand cmd = new AbstractTransactionalCommand(
- editpart.getEditingDomain(),
- "Update Operand Bounds", null) {
- @Override
- protected CommandResult doExecuteWithResult(
- IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- if (editpart.getModel() instanceof Node) {
- Node node = (Node) editpart.getModel();
- if (node.getLayoutConstraint() instanceof Bounds) {
- Bounds bounds = (Bounds) node.getLayoutConstraint();
- fillBounds(bounds, rect);
- }
- }
- return CommandResult.newOKCommandResult();
- }
- };
- return cmd;
- }
-
- /**
- * Create command for updating Interaction Operand EditpPart bounds after the CombinedFragment to be created.
- * @param editPart
- * @param request
- * @return ICommand
- */
- public static ICommand createUpdateCFAndIOBoundsForCFCreationCommand(final EditPart editPart, final CreateViewRequest request) {
- if (!(editPart instanceof GraphicalEditPart)) {
- return null;
- }
- GraphicalEditPart graphicalEditPart= (GraphicalEditPart)editPart;
- ICommand cmd = new AbstractTransactionalCommand(graphicalEditPart.getEditingDomain(),"Create update operand bounds command",null) {
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- OperandBoundsComputeHelper.updateCFAndIOBoundsForCFCreation(
- (GraphicalEditPart) editPart, request);
- return CommandResult.newOKCommandResult();
- }
- };
- return cmd;
- }
-
- /**
- * Update Interaction Operand EditpPart bounds after the CombinedFragment to be created.
- * @param parent
- * @param request
- * @param selectionRect
- */
- private static void updateCFAndIOBoundsForCFCreation(GraphicalEditPart parent, CreateViewRequest request) {
- Object subEditPart = null;
- if (parent instanceof InteractionInteractionCompartmentEditPart) {
- InteractionInteractionCompartmentEditPart interactionInteractionCompartmentEditPart = (InteractionInteractionCompartmentEditPart) parent;
- subEditPart = interactionInteractionCompartmentEditPart
- .getChildren().get(
- interactionInteractionCompartmentEditPart
- .getChildren().size() - 1);
-
- }else if (parent instanceof InteractionOperandEditPart) {
- InteractionOperandEditPart interactionOperandEditPart = (InteractionOperandEditPart) parent;
- subEditPart = interactionOperandEditPart
- .getChildren().get(
- interactionOperandEditPart
- .getChildren().size() - 1);
- }
- if (subEditPart != null
- && subEditPart instanceof CombinedFragmentEditPart) {
- CombinedFragmentEditPart combinedFragmentEditPart = (CombinedFragmentEditPart) subEditPart;
- // set bounds for CombinedFragmentEditPart
- Rectangle cfEPAbsoluteRect = null;
- int labelContainerHeight = computeCombinedFragementHeaderHeight(combinedFragmentEditPart);
- Shape cfEPShape = (Shape) combinedFragmentEditPart.getModel();
- if (cfEPShape.getLayoutConstraint() instanceof Bounds) {
- if(request.getSize() == null){
- Dimension cfEPDefaultSize = new Dimension();
- cfEPDefaultSize.setWidth(DEFAULT_INTERACTION_OPERAND_WIDTH+COMBINED_FRAGMENT_FIGURE_BORDER*2);
- cfEPDefaultSize.setHeight(DEFAULT_INTERACTION_OPERAND_HEIGHT+labelContainerHeight+COMBINED_FRAGMENT_FIGURE_BORDER*2);
- cfEPAbsoluteRect = new Rectangle(request.getLocation(),cfEPDefaultSize);
- }else{
- cfEPAbsoluteRect = new Rectangle(request.getLocation(),request.getSize());
- }
- Rectangle cfEPRelativeRect = cfEPAbsoluteRect.getCopy();
- combinedFragmentEditPart.getFigure().translateToRelative(cfEPRelativeRect);
- Bounds cfEPBounds = (Bounds) cfEPShape.getLayoutConstraint();
- fillBounds(cfEPBounds,cfEPRelativeRect);
- }
-
- // set bounds for new added Operand
- InteractionOperandEditPart lastOperand = OperandBoundsComputeHelper
- .findLastIOEP((CombinedFragmentCombinedFragmentCompartmentEditPart) combinedFragmentEditPart.getChildBySemanticHint(UMLVisualIDRegistry
- .getType(CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID)));
- Shape shape = (Shape) lastOperand.getModel();
- if (shape.getLayoutConstraint() instanceof Bounds) {
- Bounds bounds = (Bounds) shape.getLayoutConstraint();
- Rectangle rect = new Rectangle(bounds.getX(), bounds.getY(),
- cfEPAbsoluteRect.width()-COMBINED_FRAGMENT_FIGURE_BORDER*2, cfEPAbsoluteRect.height()
- - labelContainerHeight-COMBINED_FRAGMENT_FIGURE_BORDER*2);
- fillBounds(bounds,rect);
- }
- }
- }
-
- /**
- * Create command for updating Interaction Operand EditpPart bounds after CombinedFragment to be resized.
- * @param compoundCmd
- * @param request
- * @param combinedFragmentEditPart
- * @return Command
- */
- public static Command createUpdateIOBoundsForCFResizeCommand(
- CompoundCommand compoundCmd, final ChangeBoundsRequest request,
- CombinedFragmentEditPart combinedFragmentEditPart) {
- if (combinedFragmentEditPart.getChildren().size() > 0
- && combinedFragmentEditPart.getChildren().get(0) instanceof CombinedFragmentCombinedFragmentCompartmentEditPart) {
- CombinedFragmentCombinedFragmentCompartmentEditPart compartment = (CombinedFragmentCombinedFragmentCompartmentEditPart) combinedFragmentEditPart
- .getChildren().get(0);
- CombinedFragment cf = (CombinedFragment) ((CombinedFragmentEditPart) combinedFragmentEditPart)
- .resolveSemanticElement();
- InteractionOperandEditPart targetIOEP = null;
- if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) {
- targetIOEP = findFirstIOEP(compartment);
- } else if ((request.getResizeDirection() & PositionConstants.SOUTH) != 0) {
- targetIOEP = findLastIOEP(compartment);
- }
- updateIOBoundsForCFResize(
- request,
- compoundCmd,
- compartment.getChildren(),
- cf,
- targetIOEP != null ? (InteractionOperand) targetIOEP
- .resolveSemanticElement() : null,
- request.getSizeDelta(), request.getResizeDirection());
- }
- return compoundCmd;
- }
-
- /**
- * Update Interaction Operand EditpPart bounds after CombinedFragment to be resized.
- * @param request
- * @param compoundCmd
- * @param combinedFragmentChildrenEditParts
- * @param cf
- * @param targetOperand
- * @param sizeDelta
- * @param direction
- */
- private static void updateIOBoundsForCFResize(final ChangeBoundsRequest request,
- CompoundCommand compoundCmd,
- List<EditPart> combinedFragmentChildrenEditParts,
- CombinedFragment cf, InteractionOperand targetOperand,
- final Dimension sizeDelta, int direction) {
- InteractionOperandEditPart targetOperandEditPart = findTargetOperandEditPart(
- cf, targetOperand, combinedFragmentChildrenEditParts);
- for (EditPart ep : combinedFragmentChildrenEditParts) {
- if (ep instanceof InteractionOperandEditPart) {
- InteractionOperandEditPart ioEP = (InteractionOperandEditPart) ep;
- Object ioEPModel = ioEP.getModel();
- if (ioEPModel instanceof Shape) {
- Shape ioEPShape = (Shape) ioEPModel;
- if (ioEPShape.getLayoutConstraint() instanceof Bounds) {
- final Bounds ioEPOriginalBounds = (Bounds) ioEPShape
- .getLayoutConstraint();
- ICommand cmd = new UpdateIOBoundsForCFResizeCommand(
- ioEP.getEditingDomain(),
- "Update operand bounds interaction command",
- ioEPOriginalBounds, request, sizeDelta,
- ioEP == targetOperandEditPart, direction);
- compoundCmd.add(new ICommandProxy(cmd));
- }
- }
- }
- }
-
- }
-
- /**
- * Update bounds using new rect
- * @param bounds
- * @param rect
- * @param transactionalEditingDomain
- */
- public static void updateBounds(final Bounds bounds, final Rectangle rect,
- TransactionalEditingDomain transactionalEditingDomain) {
- if (bounds != null) {
- final Rectangle originalBounds = new Rectangle();
- originalBounds.setX(bounds.getX());
- originalBounds.setY(bounds.getY());
- originalBounds.setWidth(bounds.getWidth());
- originalBounds.setHeight(bounds.getHeight());
- AbstractCommand cmd = new AbstractCommand() {
- public boolean canExecute() {
- return true;
- }
-
- public void execute() {
- exec(rect);
- }
-
- public void redo() {
- execute();
- }
-
- public void undo(){
- exec(originalBounds);
- }
-
- public void exec(Rectangle rect){
- fillBounds(bounds,rect);
- }
-
- public boolean canUndo() {
- return true;
- }
- };
- CommandHelper.executeCommandWithoutHistory(
- transactionalEditingDomain, cmd,true);
- }
- }
-
- /**
- * Get InteractionOperandEditPart from its model object InteractionOperand.
- * @param cf
- * @param targetOperand
- * @param combinedFragmentChildrenEditParts
- * @return InteractionOperandEditPart
- */
- public static InteractionOperandEditPart findTargetOperandEditPart(CombinedFragment cf,
- InteractionOperand targetOperand,
- List<EditPart> combinedFragmentChildrenEditParts) {
- if(targetOperand == null)
- return null;
- for(EditPart ep : combinedFragmentChildrenEditParts) {
- if(ep instanceof InteractionOperandEditPart) {
- InteractionOperandEditPart ioEP = (InteractionOperandEditPart)ep;
- InteractionOperand io = (InteractionOperand)ioEP.resolveSemanticElement();
- if(cf.getOperands().contains(io)) {
- if(targetOperand.equals(io)) {
- return ioEP;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Get graphical edit part bounds
- * @param editPart
- * @return
- */
- public static Bounds getEditPartBounds(GraphicalEditPart editPart){
- if (editPart.getModel() instanceof Node) {
- Node node = (Node) editPart.getModel();
- if (node.getLayoutConstraint() instanceof Bounds) {
- Bounds bounds = (Bounds) node.getLayoutConstraint();
- return bounds;
- }
- }
- return null;
- }
-
- /**
- * Fill data from Bounds to Rectangle
- * @param source
- * @return Rectangle
- */
- public static Rectangle fillRectangle(Bounds source) {
- if (source == null) {
- return null;
- }
- Rectangle target = new Rectangle();
- target.setX(source.getX());
- target.setY(source.getY());
- target.setWidth(source.getWidth());
- target.setHeight(source.getHeight());
- return target;
- }
-
- /**
- * Fill data from Rectangle to Bounds
- * @param bounds
- * @param source
- * @return Bounds
- */
- public static Bounds fillBounds(Bounds bounds,Rectangle source) {
- if (bounds == null || source == null) {
- return null;
- }
- bounds.setX(source.x());
- bounds.setY(source.y());
- bounds.setWidth(source.width());
- bounds.setHeight(source.height());
- return bounds;
- }
-
- /**
- * Get interaction operand bounds
- * @param operandEP
- * @return Bounds
- */
- public static Bounds getInteractionOperandEPBounds(GraphicalEditPart operandEP){
- Object lastChildModel = operandEP.getModel();
- if (lastChildModel instanceof Shape) {
- Shape lastOperandShape = (Shape) lastChildModel;
- if (lastOperandShape.getLayoutConstraint() instanceof Bounds) {
- return (Bounds)lastOperandShape.getLayoutConstraint();
- }
- }
- return null;
- }
-
- /**
- * Create interaction operand resize command
- * @param currentIOEP
- * @param heightDelta
- * @param compartEP
- * @param direction
- * @return
- */
- public static Command createIOEPResizeCommand(
- InteractionOperandEditPart currentIOEP, int heightDelta,
- CombinedFragmentCombinedFragmentCompartmentEditPart compartEP,
- int direction) {
- Bounds currentIOEPBounds = OperandBoundsComputeHelper
- .getEditPartBounds(currentIOEP);
- if (currentIOEPBounds == null) {
- return null;
- }
- InteractionOperandEditPart targetIOEP = null;
- if ((direction & PositionConstants.NORTH) != 0) {
- targetIOEP = OperandBoundsComputeHelper.findPreviousIOEP(compartEP,
- currentIOEP);
- } else if ((direction & PositionConstants.SOUTH) != 0) {
- targetIOEP = OperandBoundsComputeHelper.findLatterIOEP(compartEP,
- currentIOEP);
- }
-
- CompositeCommand compositeCommand = new CompositeCommand(
- "Resize Operand");
- // if last operand
- if(targetIOEP == null){
- if (heightDelta < 0) {
- if (currentIOEPBounds.getHeight() - Math.abs(heightDelta) < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
- return null;
- }
- }
- Rectangle currentIOEPRect = OperandBoundsComputeHelper
- .fillRectangle(currentIOEPBounds);
- currentIOEPRect.setHeight(currentIOEPBounds.getHeight() + heightDelta);
- ICommand currentIOEPCommand = OperandBoundsComputeHelper
- .createUpdateEditPartBoundsCommand(currentIOEP, currentIOEPRect);
- compositeCommand.add(currentIOEPCommand);
- // auto update CombinedFragmentEditPart bounds after resize the last operand
- if(compartEP.getParent() instanceof CombinedFragmentEditPart){
- CombinedFragmentEditPart parent = (CombinedFragmentEditPart) compartEP.getParent();
- if (parent.getModel() instanceof Node) {
- Node node = (Node) parent.getModel();
- if (node.getLayoutConstraint() instanceof Bounds) {
- Bounds containerBounds = (Bounds) node
- .getLayoutConstraint();
- Dimension preferredSize = parent.getFigure().getPreferredSize();
- int width = containerBounds.getWidth()!=-1? containerBounds.getWidth() : preferredSize.width();
- int height = containerBounds.getHeight()!=-1? containerBounds.getHeight() : preferredSize.height();
- height = height + heightDelta;
- Rectangle containerRect = new Rectangle(containerBounds.getX(),containerBounds.getY(),width,height);
- compositeCommand.add(OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(parent, containerRect));
- }
- }
- }
- }else{
- Bounds targetIOEPBounds = OperandBoundsComputeHelper
- .getEditPartBounds(targetIOEP);
- if (targetIOEPBounds == null) {
- return null;
- }
- if (heightDelta > 0) {
- if (targetIOEPBounds.getHeight() - heightDelta < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
- return null;
- }
- } else {
- if (currentIOEPBounds.getHeight() - Math.abs(heightDelta) < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
- return null;
- }
- }
- Rectangle targetIOEPRect = OperandBoundsComputeHelper
- .fillRectangle(targetIOEPBounds);
- Rectangle currentIOEPRect = OperandBoundsComputeHelper
- .fillRectangle(currentIOEPBounds);
- targetIOEPRect.setHeight(targetIOEPBounds.getHeight() - heightDelta);
- currentIOEPRect.setHeight(currentIOEPBounds.getHeight() + heightDelta);
- if ((direction & PositionConstants.NORTH) != 0) {
- currentIOEPRect.setY(currentIOEPRect.y() - heightDelta);
- }else if ((direction & PositionConstants.SOUTH) != 0) {
- targetIOEPRect.setY(targetIOEPRect.y() + heightDelta);
- }
-
- ICommand previousIOEPCommand = OperandBoundsComputeHelper
- .createUpdateEditPartBoundsCommand(targetIOEP, targetIOEPRect);
- ICommand currentIOEPCommand = OperandBoundsComputeHelper
- .createUpdateEditPartBoundsCommand(currentIOEP, currentIOEPRect);
-
- compositeCommand.add(previousIOEPCommand);
- compositeCommand.add(currentIOEPCommand);
- }
-
- return new ICommandProxy(compositeCommand);
- }
-
- /**
- * Compute CombinedFragement's header height
- * @param combinedFragmentEditPart
- * @return int
- */
- public static int computeCombinedFragementHeaderHeight(
- CombinedFragmentEditPart combinedFragmentEditPart) {
- int headerHeight = 0;
- IFigure labelContainer = combinedFragmentEditPart.getPrimaryShape().getHeaderLabel().getParent();
- if(labelContainer!=null){
- headerHeight = labelContainer.getPreferredSize().height();
- }
- return headerHeight;
- }
-
- /**
- * Check if operation resizing on CombinedFragment is allowed
- * @param request
- * @param child
- * @return boolean
- */
- public static boolean checkRedistrictOnCFResize(ChangeBoundsRequest request,
- EditPart child) {
- if(child instanceof CombinedFragmentEditPart){
- if ((request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0) {
- CombinedFragmentEditPart combinedFragmentEditPart = (CombinedFragmentEditPart)child;
- if (combinedFragmentEditPart.getChildren().size() > 0
- && combinedFragmentEditPart.getChildren()
- .get(0) instanceof CombinedFragmentCombinedFragmentCompartmentEditPart) {
- CombinedFragmentCombinedFragmentCompartmentEditPart compartment = (CombinedFragmentCombinedFragmentCompartmentEditPart) combinedFragmentEditPart
- .getChildren().get(0);
- List<EditPart> combinedFragmentChildrenEditParts = compartment
- .getChildren();
- CombinedFragment cf = (CombinedFragment) ((CombinedFragmentEditPart) combinedFragmentEditPart)
- .resolveSemanticElement();
- InteractionOperand targetOperand = null;
- if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) {
- targetOperand = cf.getOperands().get(0);
- } else if ((request.getResizeDirection() & PositionConstants.SOUTH) != 0) {
- targetOperand = cf.getOperands().get(
- cf.getOperands().size() - 1);
- }
- InteractionOperandEditPart targetOperandEditPart = OperandBoundsComputeHelper.findTargetOperandEditPart(
- cf, targetOperand, combinedFragmentChildrenEditParts);
- int heightDelta = request.getSizeDelta().height();
- if(targetOperandEditPart!=null && heightDelta<0){
- int height = targetOperandEditPart.getFigure().getBounds().height();
- if(height-Math.abs(heightDelta) < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT){
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- /**
- * Add command for updating adjacent interaction operand bounds after deleting a interaction operand
- * @param editPart
- * @param cmd
- */
- public static void addUpdateBoundsCommandForOperandDelelete(EditPart editPart,ICompositeCommand cmd) {
- if(editPart instanceof InteractionOperandEditPart){
- if(editPart.getParent() instanceof CombinedFragmentCombinedFragmentCompartmentEditPart){
- CombinedFragmentCombinedFragmentCompartmentEditPart compartment = (CombinedFragmentCombinedFragmentCompartmentEditPart)editPart.getParent();
- if(compartment.getParent() instanceof CombinedFragmentEditPart){
- List<EditPart> combinedFragmentChildrenEditParts = compartment
- .getChildren();
- InteractionOperandEditPart previousIOEP = null;
- InteractionOperandEditPart latterIOEP = null;
- boolean isFirstOperand = false;
-
- InteractionOperandEditPart currentioEP = (InteractionOperandEditPart)editPart;
- final Rectangle currentioEPBounds = currentioEP.getFigure().getBounds();
-
- for(int i = 0;i<combinedFragmentChildrenEditParts.size();i++) {
- EditPart ep = combinedFragmentChildrenEditParts.get(i);
- if(ep instanceof InteractionOperandEditPart) {
- InteractionOperandEditPart ioEP = (InteractionOperandEditPart)ep;
- if(currentioEP == ioEP){
- if(previousIOEP!=null){
- Object previousIOEPModel = previousIOEP.getModel();
- if (previousIOEPModel instanceof Shape) {
- Shape previousIOEPShape = (Shape) previousIOEPModel;
- if (previousIOEPShape.getLayoutConstraint() instanceof Bounds) {
- final Bounds previousIOEPOriginalBounds = (Bounds) previousIOEPShape.getLayoutConstraint();
- ICommand command = new AbstractTransactionalCommand(previousIOEP.getEditingDomain(),"Merge operand bounds command",null){
- @Override
- protected CommandResult doExecuteWithResult(
- IProgressMonitor monitor,
- IAdaptable info)
- throws ExecutionException {
- previousIOEPOriginalBounds.setHeight(previousIOEPOriginalBounds.getHeight() + currentioEPBounds.height());
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.add(command);
- }
- }
- break;
- }else{
- isFirstOperand = true;
- continue;
- }
- }else{
- previousIOEP = ioEP;
- }
- if(isFirstOperand){
- latterIOEP = ioEP;
- break;
- }
- }
- }
- if(isFirstOperand && latterIOEP!=null){
- Object latterIOEPModel = latterIOEP.getModel();
- if (latterIOEPModel instanceof Shape) {
- Shape latterIOEPShape = (Shape) latterIOEPModel;
- if (latterIOEPShape.getLayoutConstraint() instanceof Bounds) {
- final Bounds latterIOEPOriginalBounds = (Bounds) latterIOEPShape.getLayoutConstraint();
- ICommand command = new AbstractTransactionalCommand(previousIOEP.getEditingDomain(),"Merge operand bounds command",null){
- @Override
- protected CommandResult doExecuteWithResult(
- IProgressMonitor monitor,
- IAdaptable info)
- throws ExecutionException {
- latterIOEPOriginalBounds.setY(0);
- latterIOEPOriginalBounds.setHeight(latterIOEPOriginalBounds.getHeight() + currentioEPBounds.height());
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.add(command);
- }
- }
- }
- }
- }
- }
-
- }
-
- /**
- * Add update InteractionOperand bounds command after IO is created
- * @param compartment
- * @param request
- * @param command
- */
- public static void addUpdateBoundsForIOCreationCommand(
- CombinedFragmentCombinedFragmentCompartmentEditPart compartment, ViewDescriptor viewDescriptor,
- CompositeCommand command) {
- List children = compartment.getChildren();
- if (children != null && children.size() > 0) {
- InteractionOperandEditPart lastOperandEP = OperandBoundsComputeHelper.findLastIOEP(compartment);
- // update bounds
- if (lastOperandEP != null) {
- Bounds lastOperandBounds = OperandBoundsComputeHelper.getInteractionOperandEPBounds(lastOperandEP);
- if (lastOperandBounds!= null) {
- Rectangle rect = new Rectangle(
- lastOperandBounds.getX(),
- lastOperandBounds.getY()+lastOperandBounds.getHeight(), lastOperandBounds.getWidth(), OperandBoundsComputeHelper.DEFAULT_INTERACTION_OPERAND_HEIGHT);
- // auto update CombinedFragmentEditPart bounds after added new operand
- if(compartment.getParent() instanceof CombinedFragmentEditPart){
- CombinedFragmentEditPart parent = (CombinedFragmentEditPart) compartment
- .getParent();
- if (parent.getModel() instanceof Node) {
- Node node = (Node) parent.getModel();
- if (node.getLayoutConstraint() instanceof Bounds) {
- Bounds containerBounds = (Bounds) node.getLayoutConstraint();
- Dimension preferredSize = parent.getFigure().getPreferredSize();
- int width = containerBounds.getWidth()!=-1? containerBounds.getWidth() : preferredSize.width();
- int height = containerBounds.getHeight()!=-1? containerBounds.getHeight() : preferredSize.height();
- height = height + OperandBoundsComputeHelper.DEFAULT_INTERACTION_OPERAND_HEIGHT;
- View shapeView = (View) parent.getModel();
- ICommand setParentBoundsCmd = new SetBoundsCommand(compartment.getEditingDomain(),
- DiagramUIMessages.SetLocationCommand_Label_Resize,
- new EObjectAdapter(shapeView), new Rectangle(containerBounds.getX(),containerBounds.getY(),width,height));
- command.add(setParentBoundsCmd);
- }
- }
- }
- command.add(new SetBoundsCommand(compartment.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, rect));
- }
- }
- }else{ // first add operand
- if(compartment.getParent() instanceof CombinedFragmentEditPart){
- CombinedFragmentEditPart parent = (CombinedFragmentEditPart) compartment
- .getParent();
- if (parent.getModel() instanceof Node) {
- Node node = (Node) parent.getModel();
- if (node.getLayoutConstraint() instanceof Bounds) {
- Bounds containerBounds = (Bounds) node.getLayoutConstraint();
- Dimension preferredSize = parent.getFigure().getPreferredSize();
- int width = containerBounds.getWidth()!=-1? containerBounds.getWidth() : preferredSize.width();
- int height = containerBounds.getHeight()!=-1? containerBounds.getHeight() : preferredSize.height();
- height = height - computeCombinedFragementHeaderHeight(parent);
- command.add(new SetBoundsCommand(compartment.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, new Rectangle(0,0,width-COMBINED_FRAGMENT_FIGURE_BORDER*2,height-COMBINED_FRAGMENT_FIGURE_BORDER*2)));
- }
- }
- }
- }
- }
-
- /**
- * Check if it is a combined fragment.
- *
- * @param hint
- * the semantic hint
- * @return
- */
- public static boolean isDerivedCombinedFragment(String hint) {
- if(((IHintedType)UMLElementTypes.CombinedFragment_3004).getSemanticHint().equals(hint)) {
- return true;
- }
- if(((IHintedType)UMLElementTypes.ConsiderIgnoreFragment_3007).getSemanticHint().equals(hint)) {
- return true;
- }
- return false;
- }
-
- /**
- * Command class for updating Interaction Operand EditpPart bounds after CombinedFragment to be resized.
- *
- */
- private static final class UpdateIOBoundsForCFResizeCommand extends
- AbstractTransactionalCommand {
- private final Bounds ioEPOriginalBounds;
- private final ChangeBoundsRequest request;
- private final Dimension sizeDelta;
- private boolean updateHeight = false;
- private int direction;
-
- private UpdateIOBoundsForCFResizeCommand(TransactionalEditingDomain domain,
- String label, Bounds ioEPOriginalBounds,
- ChangeBoundsRequest request, Dimension sizeDelta,
- boolean updateHeight, int direction) {
- super(domain, label, null);
- this.ioEPOriginalBounds = ioEPOriginalBounds;
- this.request = request;
- this.sizeDelta = sizeDelta;
- this.updateHeight = updateHeight;
- this.direction = direction;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
- IAdaptable info) throws ExecutionException {
- if (updateHeight) {
- ioEPOriginalBounds.setHeight(ioEPOriginalBounds.getHeight()
- + sizeDelta.height());
- } else if ((direction & PositionConstants.NORTH) != 0) {
- ioEPOriginalBounds.setY(ioEPOriginalBounds.getY()
- + sizeDelta.height());
- }
- if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
- ioEPOriginalBounds.setWidth(ioEPOriginalBounds.getWidth()
- + sizeDelta.width());
- }
-
- return CommandResult.newOKCommandResult();
- }
-
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/PreferencesModelElementFactory.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/PreferencesModelElementFactory.java
deleted file mode 100644
index 298a508db92..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/PreferencesModelElementFactory.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
-import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
-import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
-import org.eclipse.papyrus.views.properties.modelelement.PreferencesModelElement;
-
-
-public class PreferencesModelElementFactory implements ModelElementFactory {
-
- public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
- return new PreferencesModelElement(context);
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/ReconnectMessageHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/ReconnectMessageHelper.java
deleted file mode 100644
index 5eeb317ca74..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/ReconnectMessageHelper.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import org.eclipse.uml2.uml.CombinedFragment;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.Gate;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-import org.eclipse.uml2.uml.InteractionOperatorKind;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.MessageSort;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-/**
- * An helper class to reconnect message.
- * TODO : finish the implementation of this class
- */
-public class ReconnectMessageHelper {
-
- /**
- * Update Message :
- * - Update its signature
- *
- * @param message
- */
- public static void updateMessage(Message message) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * Update the message end :
- *
- * @param messageEnd
- * @param oldElement
- * @param newElement
- */
- public static void updateMessageEnd(MessageEnd messageEnd, Element oldElement, Element newElement) {
- if(messageEnd instanceof MessageOccurrenceSpecification) {
- updateMos((MessageOccurrenceSpecification)messageEnd, oldElement, newElement);
- } else if(messageEnd instanceof Gate) {
- updateGate((Gate)messageEnd, oldElement, newElement);
- }
- }
-
- public static void updateGate(Gate messageEnd, Element oldElement, Element newElement) {
- // TODO Auto-generated method stub
-
- }
-
- public static void updateMos(MessageOccurrenceSpecification messageEnd, Element oldElement, Element newElement) {
- if(newElement instanceof Lifeline && !(oldElement instanceof CombinedFragment && InteractionOperatorKind.PAR_LITERAL.equals(((CombinedFragment)oldElement).getInteractionOperator()))) {
- updateOccurenceSpecification(messageEnd, (Lifeline)newElement);
- } else if(newElement instanceof ExecutionSpecification && !(oldElement instanceof CombinedFragment && InteractionOperatorKind.PAR_LITERAL.equals(((CombinedFragment)oldElement).getInteractionOperator()))) {
- Lifeline lifeline = CommandHelper.getExecutionSpecificationLifeline((ExecutionSpecification)newElement);
- if(lifeline != null) {
- updateOccurenceSpecification(messageEnd, lifeline);
- }
- } else if(newElement instanceof CombinedFragment && InteractionOperatorKind.PAR_LITERAL.equals(((CombinedFragment)newElement).getInteractionOperator())) {
- // handle reorient on coregion
- CombinedFragment cf = (CombinedFragment)newElement;
- InteractionOperand io = CommandHelper.getCoRegionInteractionOperand(cf);
- messageEnd.setEnclosingOperand(io);
-
- // try to find and put in the operand the other mos of the message
- MessageEnd messageEnd2 = findSecondMessageEnd(messageEnd);
-
- if(messageEnd2 instanceof MessageOccurrenceSpecification) {
- ((MessageOccurrenceSpecification)messageEnd2).setEnclosingOperand(io);
- }
- // update interaction operands covered lifelines
- updateCoveredLifelinesOfCoregionOperand(cf);
- } else if(oldElement instanceof CombinedFragment && InteractionOperatorKind.PAR_LITERAL.equals(((CombinedFragment)oldElement).getInteractionOperator())) {
- // handle reorient from coregion
- CombinedFragment cf = (CombinedFragment)oldElement;
- Element backInteraction = cf.getOwner();
-
- SequenceUtil.setEnclosingInteraction(messageEnd, backInteraction, true);
-
- MessageEnd messageEnd2 = findSecondMessageEnd(messageEnd);
- if(messageEnd2 instanceof MessageOccurrenceSpecification) {
- SequenceUtil.setEnclosingInteraction((MessageOccurrenceSpecification)messageEnd2, backInteraction, true);
- }
- // update interaction operands covered lifelines
- updateCoveredLifelinesOfCoregionOperand(cf);
- }
- }
-
- public static MessageEnd findSecondMessageEnd(MessageEnd messageEnd) {
- Message msg = messageEnd.getMessage();
-
- MessageEnd messageEnd2 = null;
- if(msg != null) {
- if(messageEnd.equals(msg.getSendEvent())) {
- messageEnd2 = msg.getReceiveEvent();
- } else {
- messageEnd2 = msg.getSendEvent();
- }
- }
- return messageEnd2;
- }
-
-
- /**
- * OccurrenceSpecification cover a unique lifeline.
- *
- * @param os
- * the occurrence specification to update
- * @param newLifeline
- * the new lifeline covered by the OS
- */
- public static void updateOccurenceSpecification(OccurrenceSpecification os, Lifeline newLifeline) {
-
- // An occurrence specification covers a unique lifeline
- os.getCovereds().clear();
- os.getCovereds().add(newLifeline);
- }
-
- /**
- * Update the list of lifelines covered by the Interaction Operands of a coregion.
- * These are the lifelines covered by all contained Message Occurrence Specifications.
- *
- * @param coregion
- * the coregion to update operands
- */
- public static void updateCoveredLifelinesOfCoregionOperand(CombinedFragment coregion) {
- coregion.getCovereds().clear();
- for(InteractionOperand operand : coregion.getOperands()) {
- operand.getCovereds().clear();
- for(InteractionFragment fragment : operand.getFragments()) {
- if(fragment instanceof MessageOccurrenceSpecification) {
- operand.getCovereds().addAll(fragment.getCovereds());
- coregion.getCovereds().addAll(fragment.getCovereds());
- }
- }
- }
- }
-
- /**
- * It seems that OCL constraints can not hold everything about reconnecting messages.
- *
- * @param message
- * @param newTarget
- */
- public static boolean canReorientTarget(Message message, Element newTarget) {
- if(message == null || newTarget == null) {
- return false;
- }
- MessageSort messageSort = message.getMessageSort();
- if(MessageSort.SYNCH_CALL_LITERAL == messageSort) {
- return newTarget instanceof ExecutionSpecification;
- }
- return true;
- }
-
- public static boolean canReorientSource(Message message, Element newSource) {
- if(message == null || newSource == null) {
- return false;
- }
- MessageSort messageSort = message.getMessageSort();
- if(MessageSort.SYNCH_CALL_LITERAL == messageSort) {
- return newSource instanceof ExecutionSpecification;
- }
- return true;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectOrCreateDialog.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectOrCreateDialog.java
deleted file mode 100644
index 3d68a6f0024..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectOrCreateDialog.java
+++ /dev/null
@@ -1,647 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.forms.FormDialog;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Reception;
-import org.eclipse.uml2.uml.Signal;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * This class provides a generic dialog to select or create an element.
- */
-public class SelectOrCreateDialog extends FormDialog {
-
- private EObject selectedElement = null;
-
- private EClass selectedType = null;
-
- private String selectedName = null;
-
- private EObject selectedParent = null;
-
- private Collection<EObject> existingElements;
-
- private LinkedHashMap<EClass, List<EObject>> mapTypesPossibleParents;
-
- private Button nothingRadio;
-
- private Button selectionRadio;
-
- private Text selectionText;
-
- private Button selectionButton;
-
- private Button creationRadio;
-
- private Text creationNameText;
-
- private ComboViewer typeComboViewer = null;
-
- private Combo creationTypeCombo = null;
-
- private Button creationParentButton;
-
- private Text creationParentText;
-
- private String title;
-
- private ILabelProvider typeLabelProvider;
-
- private ILabelProvider elementLabelProvider;
-
- private final TransactionalEditingDomain transactionalEditingDomain;
-
- private Button filterSignalButton;
-
- private List<Type> types;
-
- /**
- *
- * @param shell
- * parent shell
- * @param title
- * The title of the dialog
- * @param typeLabelProvider
- * The label provider to generate type label
- * @param elementLabelProvider
- * The label provider to generate elements label
- * @param transactionalEditingDomain
- * The domain where to create the element if necessary.
- * @param existingElements
- * The list of existing elements that can be selected.
- * @param mapTypesPossibleParents
- * The map of possible types for the element
- * and the possible parents where the element
- * can be created.
- * @param types
- */
- public SelectOrCreateDialog(Shell shell, String title, ILabelProvider typeLabelProvider, ILabelProvider elementLabelProvider, TransactionalEditingDomain transactionalEditingDomain, Collection<EObject> existingElements, LinkedHashMap<EClass, List<EObject>> mapTypesPossibleParents, List<Type> types) {
- super(shell);
- this.typeLabelProvider = typeLabelProvider;
- this.elementLabelProvider = elementLabelProvider;
- this.existingElements = existingElements;
- this.mapTypesPossibleParents = mapTypesPossibleParents;
- this.title = title;
- this.transactionalEditingDomain = transactionalEditingDomain;
- this.types = types;
- }
-
- /**
- * Adds buttons to this dialog's button bar.
- *
- * @param parent
- * the button bar composite
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- refreshOkButton();
- }
-
- /**
- * Create the form to :
- *
- * - ask the user to select or create an element.
- *
- * - decide whether the action is synchronous.
- *
- * @see org.eclipse.ui.forms.FormDialog#createFormContent(org.eclipse.ui.forms.IManagedForm)
- */
- @Override
- protected void createFormContent(IManagedForm pForm) {
- ScrolledForm scrolledForm = pForm.getForm();
- scrolledForm.setText(title);
-
- FormToolkit toolkit = pForm.getToolkit();
- Composite parent = scrolledForm.getBody();
- parent.setLayout(new GridLayout());
-
- // Create the selection section
- createSelectionSection(scrolledForm.getBody(), toolkit);
- // Create the creation section
- createCreationSection(scrolledForm.getBody(), toolkit);
-
-
- // Create the nothing section
- createNothingSection(scrolledForm.getBody(), toolkit);
-
-
- refreshSectionsEnable(selectionRadio);
- hookListeners();
-
- // name is set after listeners, since we count on listener to update it properly
- setName(null);
-
- scrolledForm.reflow(true);
- }
-
- private void createNothingSection(Composite pParent, FormToolkit pToolkit) {
- // create the section
- Section lSection = pToolkit.createSection(pParent, Section.EXPANDED | Section.TITLE_BAR);
- lSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- ScrolledForm lInsideScrolledForm = pToolkit.createScrolledForm(lSection);
- lInsideScrolledForm.setExpandHorizontal(true);
- lInsideScrolledForm.setExpandVertical(true);
- Composite lBody = lInsideScrolledForm.getBody();
-
- lBody.setLayout(new GridLayout(1, false));
-
- // content of the section
- nothingRadio = pToolkit.createButton(lBody, Messages.SelectOrCreateDialog_NothingLabel, SWT.RADIO);
- nothingRadio.setSelection(true);
- nothingRadio.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
-
- lInsideScrolledForm.reflow(true);
- lSection.setClient(lInsideScrolledForm);
- }
-
- /**
- * Create the section to ask the user to select or create an element.
- *
- * @param pParent
- * the section's parent widget
- * @param pToolkit
- * the form toolkit
- */
- private void createSelectionSection(Composite pParent, FormToolkit pToolkit) {
- // create the section
- Section lSection = pToolkit.createSection(pParent, Section.EXPANDED | Section.TITLE_BAR);
- lSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- ScrolledForm lInsideScrolledForm = pToolkit.createScrolledForm(lSection);
- lInsideScrolledForm.setExpandHorizontal(true);
- lInsideScrolledForm.setExpandVertical(true);
- Composite lBody = lInsideScrolledForm.getBody();
-
- lBody.setLayout(new GridLayout(3, false));
-
- // content of the section
- selectionRadio = pToolkit.createButton(lBody, Messages.SelectOrCreateDialog_SelectLabel, SWT.RADIO);
- selectionRadio.setSelection(true);
- selectionRadio.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
-
- selectionText = pToolkit.createText(lBody, "", SWT.BORDER | SWT.READ_ONLY); //$NON-NLS-1$
- selectionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
- selectionButton = pToolkit.createButton(lBody, "...", SWT.FLAT); //$NON-NLS-1$
-
- // find the first non null eobject and use its associated image
- if(existingElements != null) {
- Iterator<EObject> it = existingElements.iterator();
- while(it.hasNext()) {
- EObject next = it.next();
- if(next != null) {
- selectionButton.setImage(UMLElementTypes.getImage(next.eClass()));
- break;
- }
- }
- }
-
- selectionButton.setLayoutData(new GridData(SWT.NONE));
-
- filterSignalButton = pToolkit.createButton(lBody, "filter out all signals which are not receivable", SWT.CHECK);
-
- lInsideScrolledForm.reflow(true);
- lSection.setClient(lInsideScrolledForm);
- }
-
- /**
- * Create the section to ask the user to select or create an element.
- *
- * @param pParent
- * the section's parent widget
- * @param pToolkit
- * the form toolkit
- */
- private void createCreationSection(Composite pParent, FormToolkit pToolkit) {
- // create the section
- Section lSection = pToolkit.createSection(pParent, Section.EXPANDED | Section.TITLE_BAR);
- lSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- ScrolledForm lInsideScrolledForm = pToolkit.createScrolledForm(lSection);
- lInsideScrolledForm.setExpandHorizontal(true);
- lInsideScrolledForm.setExpandVertical(true);
- Composite lBody = lInsideScrolledForm.getBody();
-
- lBody.setLayout(new GridLayout(3, false));
-
- // content of the section
- creationRadio = pToolkit.createButton(lBody, Messages.SelectOrCreateDialog_CreateLabel, SWT.RADIO);
- creationRadio.setSelection(false);
- creationRadio.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
-
- EClass defaultType = null;
- Set<EClass> possibleTypes = mapTypesPossibleParents.keySet();
-
- // only create the type selection buttons if more than one type
- // is possible
- if(possibleTypes.size() == 1) {
- defaultType = (EClass)possibleTypes.toArray()[0];
- } else {
- pToolkit.createLabel(lBody, Messages.SelectOrCreateDialog_TypeLabel, SWT.NONE);
- creationTypeCombo = new Combo(lBody, SWT.DROP_DOWN | SWT.READ_ONLY);
- typeComboViewer = new ComboViewer(creationTypeCombo);
- pToolkit.adapt(creationTypeCombo);
- creationTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
- typeComboViewer.setLabelProvider(typeLabelProvider);
- typeComboViewer.add(possibleTypes.toArray());
- if(possibleTypes.size() > 1) {
- // initialize selection
- defaultType = (EClass)possibleTypes.toArray()[0];
- typeComboViewer.setSelection(new StructuredSelection(defaultType));
- }
- }
-
- pToolkit.createLabel(lBody, Messages.SelectOrCreateDialog_NameLabel, SWT.NONE);
- creationNameText = pToolkit.createText(lBody, "", SWT.BORDER); //$NON-NLS-1$
- creationNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
-
- pToolkit.createLabel(lBody, Messages.SelectOrCreateDialog_OwnerLabel + ":", SWT.NONE); //$NON-NLS-1$
- creationParentText = pToolkit.createText(lBody, elementLabelProvider.getText(selectedParent), SWT.BORDER | SWT.READ_ONLY);
- creationParentText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- creationParentButton = pToolkit.createButton(lBody, "...", SWT.FLAT); //$NON-NLS-1$
- creationParentButton.setLayoutData(new GridData(SWT.NONE));
-
- setType(defaultType);
-
- lInsideScrolledForm.reflow(true);
- lSection.setClient(lInsideScrolledForm);
- }
-
- /**
- * Add listeners to widgets
- */
- private void hookListeners() {
- // listener to choose active section
- SelectionListener radioListener = new SelectionAdapter() {
-
- /**
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- refreshSectionsEnable(e.getSource());
- refreshOkButton();
- }
- };
- selectionRadio.addSelectionListener(radioListener);
- creationRadio.addSelectionListener(radioListener);
- nothingRadio.addSelectionListener(radioListener);
-
- // listener to select existing element
- SelectionListener selectBtnListener = new SelectionAdapter() {
-
- /**
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleSelectElement();
- }
- };
- selectionButton.addSelectionListener(selectBtnListener);
-
- if(creationTypeCombo != null && typeComboViewer != null) {
- // listener to select invocation type
- ModifyListener lTypeListener = new ModifyListener() {
-
- /**
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- public void modifyText(ModifyEvent e) {
- ISelection sel = typeComboViewer.getSelection();
- if(sel instanceof StructuredSelection) {
- Object type = ((StructuredSelection)sel).getFirstElement();
- if(type instanceof EClass) {
- setType((EClass)type);
- } else {
- setType(null);
- }
- // reset name
- setName(null);
- }
- }
- };
- creationTypeCombo.addModifyListener(lTypeListener);
- }
-
- // listener to invocation element name
- ModifyListener lNameListener = new ModifyListener() {
-
- /**
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- public void modifyText(ModifyEvent e) {
- selectedName = creationNameText.getText();
- refreshOkButton();
- }
- };
- creationNameText.addModifyListener(lNameListener);
-
- // listener to select new element parent
- SelectionListener selectParentBtnListener = new SelectionAdapter() {
-
- /**
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleSelectParent();
- }
- };
- creationParentButton.addSelectionListener(selectParentBtnListener);
- }
-
- /**
- * Refresh the OK button activation
- */
- private void refreshOkButton() {
- Button okButton = getButton(IDialogConstants.OK_ID);
- if(okButton != null && !okButton.isDisposed()) {
- if(selectionRadio.getSelection()) {
- okButton.setEnabled(selectedElement != null);
- } else if(nothingRadio.getSelection()) {
- okButton.setEnabled(true);
- } else {
- okButton.setEnabled(selectedType != null && selectedParent != null && selectedName != null && !"".equals(selectedName)); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Add the created element to its selected parent
- */
- protected void addElementInParent(EObject selectedParent, EObject createdElement) {
- // Let the command find the relation on its own.
- Command addCmd = AddCommand.create(transactionalEditingDomain, selectedParent, null, Collections.singleton(createdElement));
- if(addCmd.canExecute()) {
- addCmd.execute();
- }
- }
-
- /**
- * Set correctly the element, by creating it if needed.
- * Then, notifies that the ok button of this dialog has been pressed.
- *
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- *
- */
- @Override
- protected void okPressed() {
- // create element if needed
- if(creationRadio.getSelection()) {
- selectedElement = UMLFactory.eINSTANCE.create(selectedType);
- if(selectedElement instanceof NamedElement) {
- ((NamedElement)selectedElement).setName(selectedName);
- }
- addElementInParent(selectedParent, selectedElement);
- } else if(nothingRadio.getSelection()) {
- selectedElement = null;
- }
- super.okPressed();
- }
-
- /**
- * Open the dialog to choose the existing element to select
- *
- */
- private void handleSelectElement() {
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), elementLabelProvider);
- dialog.setMessage(Messages.SelectOrCreateDialog_SelectLabel);
- dialog.setMultipleSelection(false);
- dialog.setElements(filterElements(existingElements));
- if(dialog.open() == Window.OK) {
- setElementSelection((EObject)dialog.getFirstResult());
- }
- }
-
- private Set<Signal> getAllSignals(List<Type> types){
- Set<Signal> accept = new HashSet<Signal>();
- Set<Classifier> collected = new HashSet<Classifier>();
- for(Type t: types)
- if(t instanceof Classifier){
- Classifier c = (Classifier)t;
- collectSignals(c, accept, collected);
- }
-
- return accept;
- }
-
- protected void collectSignals(Classifier c, Set<Signal> accept, Set<Classifier> collected) {
- if(collected.contains(c))
- return;
- collected.add(c);
- if(c instanceof org.eclipse.uml2.uml.Class){
- EList<Reception> receptions = ((org.eclipse.uml2.uml.Class)c).getOwnedReceptions();
- for(Reception r : receptions)
- accept.add(r.getSignal());
- }
-
- EList<Property> attrs = c.getAllAttributes();
- for(Property p : attrs)
- if(p.getType() instanceof Signal){
- accept.add((Signal)p.getType());
- }else if(p.getType() instanceof Classifier){
- collectSignals((Classifier)p.getType(), accept, collected);
- }
- }
-
- private Object[] filterElements(Collection<EObject> elements) {
- if(!filterSignalButton.getSelection() || types == null || types.isEmpty())
- return elements.toArray(new EObject[elements.size()]);
-
- Set<Signal> accept = getAllSignals(types);
-
- List<EObject> result = new ArrayList<EObject>();
- for(EObject o:elements)
- if(!(o instanceof Signal))
- result.add(o);
- else if( accept.contains(o))
- result.add(o);
- return result.toArray(new EObject[result.size()]);
- }
-
- /**
- * Open the dialog to choose the parent of element to create
- *
- */
- private void handleSelectParent() {
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), elementLabelProvider);
- dialog.setMessage(Messages.SelectOrCreateDialog_OwnerLabel);
- dialog.setMultipleSelection(false);
- List<EObject> possibleParents = mapTypesPossibleParents.get(selectedType);
- if(possibleParents != null) {
- dialog.setElements(possibleParents.toArray());
- }
- if(dialog.open() == Window.OK) {
- setParent((EObject)dialog.getFirstResult());
- }
- }
-
- /**
- * Define the object in which element will be created (if creation mode is chosen)
- *
- * @param parent
- * the selected parent
- */
- private void setParent(EObject parent) {
- selectedParent = parent;
- if(selectedParent instanceof NamedElement) {
- creationParentText.setText(elementLabelProvider.getText(selectedParent));
- creationParentButton.setImage(UMLElementTypes.getImage(parent.eClass()));
- } else {
- creationParentText.setText(""); //$NON-NLS-1$
- }
- refreshOkButton();
- }
-
- /**
- * Define the name of the object that will be created by the action
- *
- * @param name
- * the name of the element
- */
- private void setName(String name) {
- selectedName = name;
- if(name != null) {
- creationNameText.setText(name);
- } else {
- creationNameText.setText(""); //$NON-NLS-1$
- }
- refreshOkButton();
- }
-
- /**
- * Define the type of the object that will be created by the action
- *
- * @param type
- * the type of the element
- */
- private void setType(EClass type) {
- selectedType = type;
- List<EObject> possibleParents = mapTypesPossibleParents.get(type);
- if(possibleParents != null && possibleParents.size() > 0) {
- setParent(possibleParents.get(0));
- } else {
- setParent(null);
- }
- refreshOkButton();
- }
-
- /**
- * Define the object that will be returned by the action (if selection mode is chosen)
- *
- * @param element
- * the selected element
- */
- private void setElementSelection(EObject element) {
- selectedElement = element;
- if(selectedElement instanceof NamedElement) {
- selectionText.setText(elementLabelProvider.getText(selectedElement));
- } else {
- selectionText.setText(""); //$NON-NLS-1$
- }
- refreshOkButton();
- }
-
- /**
- * Refresh the enabled and disabled elements in various sections
- *
- */
- private void refreshSectionsEnable(Object radioObject) {
- boolean nothingSelected = false;
- boolean selectionSelected = false;
- boolean creationSelected = false;
- if(selectionRadio.equals(radioObject)) {
- selectionSelected = true;
- } else if(creationRadio.equals(radioObject)) {
- creationSelected = true;
- } else {
- nothingSelected = true;
- }
-
- // Selection widgets
- selectionRadio.setSelection(selectionSelected);
- selectionText.setEnabled(selectionSelected);
- selectionButton.setEnabled(selectionSelected);
-
- // Creation widgets
- creationRadio.setSelection(creationSelected);
- if(creationTypeCombo != null) {
- creationTypeCombo.setEnabled(creationSelected);
- }
- creationNameText.setEnabled(creationSelected);
- creationParentText.setEnabled(creationSelected);
- creationParentButton.setEnabled(creationSelected);
-
- // Nothing widgets
- nothingRadio.setSelection(nothingSelected);
- }
-
- /**
- * Get the object that have been selected or created.
- *
- * @return the object to use.
- */
- public EObject getSelected() {
- return selectedElement;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java
deleted file mode 100644
index 11be8bbe97e..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.TimeObservation;
-
-/**
- * An Helper to get deleting command for the sequence diagram elements.
- */
-
-public class SequenceDeleteHelper {
-
- /**
- * Complete an ICommand which destroys an DestructionEvent element to also destroy dependent time/duration constraint/observation linked with
- * these ends
- *
- * @param deleteViewsCmd
- * the command to complete
- * @param editingDomain
- * the editing domain
- * @param destructionEventPart
- * the execution specification edit part on which the request is called
- * @return the deletion command deleteViewsCmd for convenience
- */
- public static CompoundCommand completeDeleteDestructionOccurenceViewCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, EditPart destructionEventPart) {
- if(destructionEventPart instanceof IGraphicalEditPart) {
- EObject obj = ((IGraphicalEditPart)destructionEventPart).resolveSemanticElement();
-
- if(obj instanceof DestructionOccurrenceSpecification) {
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(destructionEventPart);
- if(lifelinePart != null) {
- for(Object lifelineChild : lifelinePart.getChildren()) {
- if(lifelineChild instanceof IBorderItemEditPart) {
- final IBorderItemEditPart timePart = (IBorderItemEditPart)lifelineChild;
- //At most one destruction event. Only parts linked to it can not move for now.
- boolean isNotLinked = OccurrenceSpecificationMoveHelper.canTimeElementPartBeYMoved(timePart);
- if(!isNotLinked) {
- // time part is linked, delete the view
- Command deleteTimeViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View)timePart.getModel()));
- deleteViewsCmd.add(deleteTimeViewCommand);
- }
- }
- }
- }
- }
- }
- return deleteViewsCmd;
- }
-
- /**
- * Complete an ICommand which destroys an ExecutionSpecification element to also destroy dependent finish and start events and time/duration
- * constraint/observation linked with these ends
- *
- * @param deleteViewsCmd
- * the command to complete
- * @param editingDomain
- * the editing domain
- * @param executionPart
- * the execution specification edit part on which the request is called
- * @return the deletion command deleteViewsCmd for convenience
- */
- public static CompoundCommand completeDeleteMessageViewCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, EditPart messagePart) {
- if(messagePart instanceof IGraphicalEditPart) {
- EObject obj = ((IGraphicalEditPart)messagePart).resolveSemanticElement();
- if(obj instanceof Message) {
- Message message = (Message)obj;
- LifelineEditPart srcLifelinePart = SequenceUtil.getParentLifelinePart(((ConnectionNodeEditPart)messagePart).getSource());
- MessageEnd send = message.getSendEvent();
- addDeleteRelatedTimePartsToCommand(deleteViewsCmd, editingDomain, srcLifelinePart, send);
-
- LifelineEditPart tgtLifelinePart = SequenceUtil.getParentLifelinePart(((ConnectionNodeEditPart)messagePart).getTarget());
- MessageEnd receive = message.getReceiveEvent();
- addDeleteRelatedTimePartsToCommand(deleteViewsCmd, editingDomain, tgtLifelinePart, receive);
-
- // also delete time observation links which are related to message end
- if (send instanceof OccurrenceSpecification) {
- addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain,(OccurrenceSpecification) send, srcLifelinePart,false);
- }
- if (receive instanceof OccurrenceSpecification) {
- addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain,(OccurrenceSpecification) receive, tgtLifelinePart,false);
- }
- }
- }
- return deleteViewsCmd;
- }
-
- private static void addDeleteRelatedTimePartsToCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, LifelineEditPart lifelineEP, MessageEnd messageEnd) {
- if(lifelineEP != null && messageEnd instanceof OccurrenceSpecification) {
- for(Object lifelineChild : lifelineEP.getChildren()) {
- if(lifelineChild instanceof IBorderItemEditPart) {
- final IBorderItemEditPart timePart = (IBorderItemEditPart)lifelineChild;
- int positionForEvent = SequenceUtil.positionWhereEventIsLinkedToPart((OccurrenceSpecification)messageEnd, timePart);
- if(positionForEvent != PositionConstants.NONE) {
- // time part is linked, delete the view
- Command deleteTimeViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View)timePart.getModel()));
- deleteViewsCmd.add(deleteTimeViewCommand);
- }
- }
- }
- }
- }
-
- /**
- * Complete an ICommand which destroys an ExecutionSpecification element to also destroy dependent finish and start events and time/duration
- * constraint/observation linked with these ends
- *
- * @param deleteViewsCmd
- * the command to complete
- * @param editingDomain
- * the editing domain
- * @param executionPart
- * the execution specification edit part on which the request is called
- * @return the deletion command deleteViewsCmd for convenience
- */
- public static CompoundCommand completeDeleteExecutionSpecificationViewCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, EditPart executionPart) {
- if(executionPart instanceof IGraphicalEditPart) {
- EObject obj = ((IGraphicalEditPart)executionPart).resolveSemanticElement();
-
- if(obj instanceof ExecutionSpecification) {
- ExecutionSpecification execution = (ExecutionSpecification)obj;
- LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(executionPart);
- if(lifelinePart != null) {
- for(Object lifelineChild : lifelinePart.getChildren()) {
- if(lifelineChild instanceof IBorderItemEditPart) {
- final IBorderItemEditPart timePart = (IBorderItemEditPart)lifelineChild;
- OccurrenceSpecification start = execution.getStart();
- OccurrenceSpecification finish = execution.getStart();
- int positionForStart = SequenceUtil.positionWhereEventIsLinkedToPart(start, timePart);
- int positionForFinish = SequenceUtil.positionWhereEventIsLinkedToPart(finish, timePart);
- if(positionForStart != PositionConstants.NONE || positionForFinish != PositionConstants.NONE) {
- // time part is linked, delete the view
- Command deleteTimeViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View)timePart.getModel()));
- deleteViewsCmd.add(deleteTimeViewCommand);
- }
- }
- }
-
- // delete each observation linked time element
- for(Object targetConnection : lifelinePart.getTargetConnections()){
- if(targetConnection instanceof ObservationLinkEditPart){
- ObservationLinkEditPart observationLinkEditPart = (ObservationLinkEditPart)targetConnection;
- TimeObservationLabelEditPart source = (TimeObservationLabelEditPart)observationLinkEditPart.getSource();
- OccurrenceSpecification start = execution.getStart();
- OccurrenceSpecification finish = execution.getFinish();
- int positionForStart = SequenceUtil.positionWhereEventIsLinkedToPart(start, source);
- int positionForFinish = SequenceUtil.positionWhereEventIsLinkedToPart(finish, source);
- if(positionForStart != PositionConstants.NONE) {
- // time part is linked, delete the view
- //Command deleteTimeViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View)source.getModel()));
- //deleteViewsCmd.add(deleteTimeViewCommand);
- addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd,
- editingDomain, start, lifelinePart,false);
- }
- if(positionForFinish != PositionConstants.NONE) {
- addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd,
- editingDomain, finish, lifelinePart,false);
- }
- }
- }
- }
- }
- }
- return deleteViewsCmd;
- }
-
- /**
- * Delete the views associated with a list of elements.
- *
- * @param cmd
- * the CompositeTransactionalCommand
- * @param element
- * the list of model elements
- * @param editingDomain
- * the editing domain to use.
- */
- public static void deleteView(CompositeTransactionalCommand cmd, List<Element> elements, TransactionalEditingDomain editingDomain) {
- for(Element element : elements) {
- deleteView(cmd, element, editingDomain);
- }
- }
-
- /**
- * Delete the views associated with an element.
- *
- * @param cmd
- * the CompositeTransactionalCommand
- * @param element
- * the model element referenced by the views
- * @param editingDomain
- * the editing domain to use.
- */
- public static void deleteView(CompositeTransactionalCommand cmd, Element element, TransactionalEditingDomain editingDomain) {
- // Destroy its views
- @SuppressWarnings("rawtypes")
- List views = DiagramEditPartsUtil.getEObjectViews(element);
- for(Object object : views) {
- if(object instanceof View) {
- cmd.add(new DeleteCommand(editingDomain, (View)object));
- }
- }
- }
-
- /**
- * Add complete delete message command
- * @param req
- * @param editPart
- * @return Command
- */
- public static Command completeDeleteMessageCommand(DestroyElementRequest req,EditPart editPart) {
- EObject selectedEObject = req.getElementToDestroy();
- IElementEditService provider = ElementEditServiceUtils
- .getCommandProvider(selectedEObject);
- if (provider != null) {
- // Retrieve delete command from the Element Edit service
- ICommand deleteCommand = provider.getEditCommand(req);
- if (deleteCommand != null) {
- CompositeCommand command = new CompositeCommand(
- deleteCommand.getLabel());
- command.add(deleteCommand);
- Message message = (Message) selectedEObject;
- MessageEnd receiveEvent = message.getReceiveEvent();
- if (receiveEvent != null) {
- DestroyElementRequest myReq = new DestroyElementRequest(
- req.getEditingDomain(), receiveEvent, false);
- command.add(new DestroyElementCommand(myReq));
- }
- MessageEnd sendEvent = message.getSendEvent();
- if (sendEvent != null) {
- DestroyElementRequest myReq = new DestroyElementRequest(
- req.getEditingDomain(), sendEvent, false);
- command.add(new DestroyElementCommand(myReq));
- }
-
- addDeleteMessageRelatedTimeObservationLinkCommand(req.getEditingDomain(), editPart, command,
- receiveEvent,true);
- addDeleteMessageRelatedTimeObservationLinkCommand(req.getEditingDomain(), editPart, command,
- sendEvent,true);
-
- return new ICommandProxy(command);
- }
- }
-
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * Add delete message related time observation link command
- * @param editingDomain
- * @param editPart
- * @param command
- * @param messageEnd
- * @param deleteRelatedEvent
- */
- public static void addDeleteMessageRelatedTimeObservationLinkCommand(
- TransactionalEditingDomain editingDomain, EditPart editPart,
- CompositeCommand command, MessageEnd messageEnd,boolean deleteRelatedEvent) {
- //Bug fix: messageEnd maybe a Gate instance.
- if(messageEnd != null && messageEnd instanceof OccurrenceSpecification){
- OccurrenceSpecification occurrenceSpecification = (OccurrenceSpecification) messageEnd;
- EList<Lifeline> receiveCovereds = occurrenceSpecification.getCovereds();
- CompoundCommand CompoundCommand = new CompoundCommand();
- CompoundCommand.add(new ICommandProxy(command));
- LifelineEditPart srcLifelinePart = (LifelineEditPart) SequenceUtil.getEditPart(editPart,receiveCovereds.get(0), LifelineEditPart.class);
- addDeleteRelatedTimeObservationLinkCommand(CompoundCommand, editingDomain, occurrenceSpecification, srcLifelinePart,deleteRelatedEvent);
- }
- }
-
- /**
- * Add command for deleting time observation link which related to occurence specification
- * @param deleteViewsCmd
- * @param editingDomain
- * @param os
- * @param srcLifelinePart
- * @param deleteRelatedEvent
- */
- private static void addDeleteRelatedTimeObservationLinkCommand(
- CompoundCommand deleteViewsCmd,
- TransactionalEditingDomain editingDomain, OccurrenceSpecification os,
- LifelineEditPart srcLifelinePart,boolean deleteRelatedEvent) {
- List<OccurrenceSpecification> oss = new ArrayList<OccurrenceSpecification>();
- oss.add(os);
- addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain,srcLifelinePart, oss,deleteRelatedEvent);
- }
-
- /**
- * Add command for deleting time observation link which related to occurence specification
- * @param deleteViewsCmd
- * @param editingDomain
- * @param srcLifelinePart
- * @param oss
- * @param deleteRelatedEvent
- */
- public static void addDeleteRelatedTimeObservationLinkCommand(
- CompoundCommand deleteViewsCmd,
- TransactionalEditingDomain editingDomain,LifelineEditPart srcLifelinePart,List<OccurrenceSpecification> oss,boolean deleteRelatedEvent) {
- List<TimeObservationLabelEditPart> timeObservationEditParts = SequenceUtil.findOccurenceSpecificationRelatedTimeObservationPart(srcLifelinePart,oss);
- for (final TimeObservationLabelEditPart timeObservationEditPart : timeObservationEditParts) {
- View view = (View) timeObservationEditPart.getModel();
- EList sourceEdges = view.getSourceEdges();
- for (Object sourceEdge : sourceEdges) {
- Command deleteTimeViewCommand = new ICommandProxy(
- new DeleteCommand(editingDomain, (View) sourceEdge));
- deleteViewsCmd.add(deleteTimeViewCommand);
- }
- if(deleteRelatedEvent){
- deleteViewsCmd.add(new ICommandProxy(new AbstractTransactionalCommand(editingDomain,"Remove TimeObservation related event",null){
- @Override
- protected CommandResult doExecuteWithResult(
- IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- TimeObservation timeObservation = (TimeObservation)(timeObservationEditPart.resolveSemanticElement());
- timeObservation.setEvent(null);
- return CommandResult.newOKCommandResult();
- }
- }));
- }
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceLinkMappingHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceLinkMappingHelper.java
deleted file mode 100644
index 0e239e232aa..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceLinkMappingHelper.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.papyrus.uml.diagram.common.helper.ILinkMappingHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper.CommonSourceUMLSwitch;
-import org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper.CommonTargetUMLSwitch;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Gate;
-import org.eclipse.uml2.uml.GeneralOrdering;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-/**
- * A link mapping helper used for dNd.
- *
- * See {@link CustomDiagramDragDropEditPolicy}
- */
-public class SequenceLinkMappingHelper implements ILinkMappingHelper {
-
- /**
- * SingletonHolder is loaded at the first execution of getInstance() method
- */
- private static class SingletonHolder {
-
- private final static SequenceLinkMappingHelper instance = new SequenceLinkMappingHelper();
- }
-
- /**
- * Gets the single instance of ClassLinkMappingHelper.
- *
- * @return single instance of ClassLinkMappingHelper
- */
- public static SequenceLinkMappingHelper getInstance() {
- return SingletonHolder.instance;
- }
-
- /**
- * private constructor
- */
- private SequenceLinkMappingHelper() {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<?> getSource(Element link) {
- return LinkMappingHelper.getSource(link, new CommonSourceUMLSwitch() {
-
- public java.util.Collection<?> caseMessage(org.eclipse.uml2.uml.Message object) {
- if(object.getSendEvent() != null) {
- MessageEnd messageEnd = object.getSendEvent();
- if(messageEnd instanceof MessageOccurrenceSpecification) {
- return ((MessageOccurrenceSpecification)messageEnd).getCovereds();
- } else if(messageEnd instanceof Gate) {
- ArrayList<Element> sources = new ArrayList<Element>();
- sources.add(((Gate)messageEnd).getOwner());
- return sources;
- }
- } else {
- return Collections.singletonList(object.getInteraction());
- }
- return Collections.EMPTY_LIST;
- };
-
- public Collection<?> caseGeneralOrdering(GeneralOrdering object) {
- if(object.getBefore() != null) {
- OccurrenceSpecification before = object.getBefore();
- return before.getCovereds();
- }
- return Collections.EMPTY_LIST;
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<?> getTarget(Element link) {
- return LinkMappingHelper.getTarget(link, new CommonTargetUMLSwitch() {
-
- public java.util.Collection<?> caseMessage(org.eclipse.uml2.uml.Message object) {
- if(object.getReceiveEvent() != null) {
- MessageEnd messageEnd = (MessageEnd)object.getReceiveEvent();
- if(messageEnd instanceof MessageOccurrenceSpecification) {
- return ((MessageOccurrenceSpecification)messageEnd).getCovereds();
- } else if(messageEnd instanceof Gate) {
- ArrayList<Element> sources = new ArrayList<Element>();
- sources.add(((Gate)messageEnd).getOwner());
- return sources;
- }
- } else {
- return Collections.singletonList(object.getInteraction());
- }
- return Collections.EMPTY_LIST;
- };
-
- public Collection<?> caseGeneralOrdering(GeneralOrdering object) {
- if(object.getAfter() != null) {
- OccurrenceSpecification after = object.getAfter();
- return after.getCovereds();
- }
- return Collections.EMPTY_LIST;
- }
-
- });
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceRequestConstant.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceRequestConstant.java
deleted file mode 100644
index 52fa63e7408..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceRequestConstant.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-/**
- * Constants used in the sequence diagram
- */
-public interface SequenceRequestConstant {
-
- /** A constant representing the container of an interactionFragment. It can be an Interaction or an InteractionOperand */
- public static final String INTERACTIONFRAGMENT_CONTAINER = "InteractionFragment Container"; //$NON-NLS-1$
-
- /** key for a set of covered InteractionFragment which needs to be moved inside a new container. */
- public static final String COVERED_INTERACTIONFRAGMENTS = "Covered InteractionFragments"; //$NON-NLS-1$
-
- public static final String SOURCE_MODEL_CONTAINER = "Source model container"; //$NON-NLS-1$
-
- public static final String TARGET_MODEL_CONTAINER = "Target model container"; //$NON-NLS-1$
-
- /** A key used in the creation of a CORegion to identify the lifeline graphically containing the CoRegion */
- public static final String LIFELINE_GRAPHICAL_CONTAINER = "Lifeline graphical container"; //$NON-NLS-1$
-
- /** The occurrence specification(s) which are the nearest from a creation request */
- public static final String NEAREST_OCCURRENCE_SPECIFICATION = "Nearest occurrence specification"; //$NON-NLS-1$
-
- /** The location of the occurrence specification which is the nearest from a creation request */
- public static final String OCCURRENCE_SPECIFICATION_LOCATION = "Nearest occurrence specification location"; //$NON-NLS-1$
-
- /** The occurrence specification(s) which are the nearest from a creation request (2nd end of creation) */
- public static final String NEAREST_OCCURRENCE_SPECIFICATION_2 = "Nearest occurrence specification (end)"; //$NON-NLS-1$
-
- /** The location of the occurrence specification which is the nearest from a creation request (2nd end of creation) */
- public static final String OCCURRENCE_SPECIFICATION_LOCATION_2 = "Nearest occurrence specification location (end)"; //$NON-NLS-1$
-
- /** Tag signifying that the edit parts must not be moved when an occurrence specification is moved (to avoid loop in chain effects) */
- public static final String DO_NOT_MOVE_EDIT_PARTS = "Do not move these edit parts"; //$NON-NLS-1$
-
- /** The location of the connection start creation request */
- public static final String SOURCE_LOCATION_DATA = "Location of connection source point"; //$NON-NLS-1$
-
- /** update connectable element reference */
- public static final String CONNECTABLE_ELEMENT = "Connectable Element"; //$NON-NLS-1$
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java
deleted file mode 100644
index 734e61a2ac8..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java
+++ /dev/null
@@ -1,1713 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- * Camille Letavernier (camille.letavernier@cea.fr) - Loosen the MessageSortChange restriction
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.draw2d.AbstractPointListShape;
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.notation.Anchor;
-import org.eclipse.gmf.runtime.notation.Bounds;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.IdentityAnchor;
-import org.eclipse.gmf.runtime.notation.LayoutConstraint;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.InteractionFragmentHelper;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragment2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionUseEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message3EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message5EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message6EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message7EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageAsyncAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageFoundAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageLostAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageName2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageName3EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageName4EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageName5EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageName6EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageName7EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageNameEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ObservationLinkPolicy;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.uml2.common.util.CacheAdapter;
-import org.eclipse.uml2.uml.CombinedFragment;
-import org.eclipse.uml2.uml.Continuation;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.DurationConstraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-import org.eclipse.uml2.uml.InteractionOperatorKind;
-import org.eclipse.uml2.uml.InteractionUse;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.MessageSort;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.StateInvariant;
-import org.eclipse.uml2.uml.TimeConstraint;
-import org.eclipse.uml2.uml.TimeObservation;
-import org.eclipse.uml2.uml.UMLPackage;
-
-
-public class SequenceUtil {
-
- private static final double MAXIMAL_DISTANCE_FROM_EVENT = 10;
-
- /**
- * Request type of observation link
- */
- public static final String OBSERVATION_LINK_TYPE = "observation link"; //$NON-NLS-1$
-
- public static final String OBSERVATION_LINK_REQUEST_START = "observation connection start"; //$NON-NLS-1$
-
- public static final String OBSERVATION_LINK_REQUEST_END = "observation connection end"; //$NON-NLS-1$
-
- public static final String OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE = "observation reconnect source"; //$NON-NLS-1$
-
- public static final String OBSERVATION_LINK_REQUEST_RECONNECT_TARGET = "observation reconnect target"; //$NON-NLS-1$
-
- /**
- * Default vertical offset of lifeline
- */
- public static final int LIFELINE_VERTICAL_OFFSET = 10;
-
- /**
- * Title for dialog of block message sort modification error
- */
- private static final String BLOCK_SORT_MODIFICATION_TITLE = "Forbidden action"; //$NON-NLS-1$
-
- /**
- * Message for dialog of block message sort modification error
- */
- private static final String BLOCK_SORT_MODIFICATION_MSG = "It's impossible to change the message sort."; //$NON-NLS-1$
-
- /**
- * Find the container interaction fragment at the given location.
- * The elements are drawn under the lifeline, but their model container is an interaction.
- * It can be of type Interaction or InteractionOperand.
- *
- * @param location
- * the location
- * @return the interaction or null
- */
- public static InteractionFragment findInteractionFragmentContainerAt(Point location, EditPart hostEditPart) {
- Rectangle bounds = new Rectangle();
- bounds.setLocation(location);
- return findInteractionFragmentContainerAt(bounds, hostEditPart);
- }
-
- /**
- * Find the container interaction fragment for the given bounds.
- * The elements are drawn under the lifeline, but their model container is an interaction.
- * It can be of type Interaction or InteractionOperand.
- *
- * @param bounds
- * the bounds
- * @param hostEditPart
- * any adit part in the corresponding diagram
- * @return the interaction or null
- */
- @SuppressWarnings("unchecked")
- public static InteractionFragment findInteractionFragmentContainerAt(Rectangle bounds, EditPart hostEditPart) {
-
- if(hostEditPart == null) {
- return null;
- }
-
- InteractionFragment container = null;
- Set<InteractionFragment> coveredInteractions = new HashSet<InteractionFragment>();
- Set<CombinedFragment> coveredCF = new HashSet<CombinedFragment>();
-
- Set<Entry<Object, EditPart>> allEditPartEntries = hostEditPart.getViewer().getEditPartRegistry().entrySet();
- for(Entry<Object, EditPart> epEntry : allEditPartEntries) {
- EditPart ep = epEntry.getValue();
-
- if(ep instanceof ShapeEditPart) {
- ShapeEditPart sep = (ShapeEditPart)ep;
- EObject eObject = sep.resolveSemanticElement();
-
- if(eObject instanceof Interaction || eObject instanceof InteractionOperand) {
-
- Rectangle figureBounds = getAbsoluteBounds(sep);
-
- if(figureBounds.contains(bounds)) {
- coveredInteractions.add((InteractionFragment)eObject);
- }
- } else if(eObject instanceof CombinedFragment) {
- // handle case when the figure is located in the CF header as if it were in the first Interaction Operand
- Rectangle figureBounds = getAbsoluteBounds(sep);
- if(figureBounds.contains(bounds)) {
- coveredCF.add((CombinedFragment)eObject);
- }
- }
- }
- }
-
- // inspect coveredCF to ensure at least on child operand is in coveredInteractions list
- for(CombinedFragment cf : coveredCF) {
- List<InteractionOperand> operands = cf.getOperands();
- if(operands.size() > 0 && Collections.disjoint(operands, coveredInteractions)) {
- // bounds are in the header, add the first operand
- coveredInteractions.add(operands.get(0));
- }
- }
-
- // for each interaction verify if its children list does not contain an other covered interaction
- // if it doesn't we have found the top-level interaction
- for(InteractionFragment ift : coveredInteractions) {
- boolean subiftFounded = false;
- if(ift instanceof Interaction) {
- for(InteractionFragment subift : ((Interaction)ift).getFragments()) {
- if(subift instanceof CombinedFragment) {
- for(InteractionOperand io : ((CombinedFragment)subift).getOperands()) {
- if(coveredInteractions.contains(io)) {
- subiftFounded = true;
- }
- }
- }
- }
- }
- if(!subiftFounded && ift instanceof InteractionOperand) {
- for(InteractionFragment subift : ((InteractionOperand)ift).getFragments()) {
- if(subift instanceof CombinedFragment) {
- for(InteractionOperand io : ((CombinedFragment)subift).getOperands()) {
- if(coveredInteractions.contains(io)) {
- subiftFounded = true;
- }
- }
- }
- }
- }
- if(!subiftFounded) {
- container = ift;
- break;
- }
- }
-
- return container;
- }
-
- /**
- * Find the location on the lifeline of an interaction fragment
- *
- * @param lifelineEditPart
- * the lifeline edit part
- * @param fragment
- * the searched interaction fragment
- * @return the absolute location or null if not found
- */
- public static Point findLocationOfEvent(LifelineEditPart lifelineEditPart, InteractionFragment fragment) {
- if(lifelineEditPart == null) {
- return null;
- }
- // Search for corresponding node edit part out of the lifeline.
- if(fragment instanceof CombinedFragment || fragment instanceof Continuation || fragment instanceof InteractionOperand || fragment instanceof InteractionUse || fragment instanceof Interaction) {
- List<View> views = DiagramEditPartsUtil.findViews(fragment, lifelineEditPart.getViewer());
- for(View view : views) {
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelineEditPart);
- boolean isCombinedFragment = part instanceof CombinedFragmentEditPart || part instanceof CombinedFragment2EditPart;
- boolean isContinuation = part instanceof ContinuationEditPart;
- boolean isInteractionOperand = part instanceof InteractionOperandEditPart;
- boolean isInteractionUse = part instanceof InteractionUseEditPart;
- boolean isInteraction = part instanceof InteractionEditPart;
- if(isCombinedFragment || isContinuation || isInteractionOperand || isInteractionUse || isInteraction) {
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)part);
- return bounds.getTop();
- }
- }
- } else {
- // search on graphical children of the lifeline
- List<?> children = lifelineEditPart.getChildren();
- for(Object child : children) {
- // check destruction event
- if(child instanceof DestructionOccurrenceSpecificationEditPart) {
- EObject destructionOccurence = ((GraphicalEditPart)child).resolveSemanticElement();
- EObject lifeline = lifelineEditPart.resolveSemanticElement();
- if(destructionOccurence instanceof DestructionOccurrenceSpecification && lifeline instanceof Lifeline && fragment instanceof DestructionOccurrenceSpecification) {
- DestructionOccurrenceSpecification destEvent = ((DestructionOccurrenceSpecification)fragment);
- if(destEvent != null && destEvent.equals(destructionOccurence)) {
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)child);
- return bounds.getCenter();
- }
- }
- }
- // check in children executions
- if(child instanceof ActionExecutionSpecificationEditPart || child instanceof BehaviorExecutionSpecificationEditPart) {
- if(fragment instanceof ExecutionSpecification) {
- // check the execution
- EObject element = ((GraphicalEditPart)child).resolveSemanticElement();
- if(element instanceof ExecutionSpecification) {
- if(fragment.equals(element)) {
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)child);
- return bounds.getTop();
- }
- }
- } else if(fragment instanceof ExecutionOccurrenceSpecification) {
- // check start and finish events of the execution
- EObject element = ((GraphicalEditPart)child).resolveSemanticElement();
- if(element instanceof ExecutionSpecification) {
- if(fragment.equals(((ExecutionSpecification)element).getStart())) {
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)child);
- return bounds.getTop();
- } else if(fragment.equals(((ExecutionSpecification)element).getFinish())) {
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)child);
- return bounds.getBottom();
- }
- }
- } else if(fragment instanceof MessageOccurrenceSpecification) {
- // check messages to and from the execution
- Point loc = findLocationOfMessageOccurrence((GraphicalEditPart)child, (MessageOccurrenceSpecification)fragment);
- if(loc != null) {
- return loc;
- }
- }
- }
- // check in children StateInvariant
- if(child instanceof StateInvariantEditPart) {
- if(fragment instanceof StateInvariant) {
- // check the StateInvariant
- EObject element = ((GraphicalEditPart)child).resolveSemanticElement();
- if(element instanceof StateInvariant) {
- if(fragment.equals(element)) {
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)child);
- return bounds.getTop();
- }
- }
- } else if(fragment instanceof MessageOccurrenceSpecification) {
- // check messages to and from the execution
- Point loc = findLocationOfMessageOccurrence((GraphicalEditPart)child, (MessageOccurrenceSpecification)fragment);
- if(loc != null) {
- return loc;
- }
- }
- }
- }
- if(fragment instanceof MessageOccurrenceSpecification) {
- // check messages to and from the lifeline
- Point loc = findLocationOfMessageOccurrence(lifelineEditPart, (MessageOccurrenceSpecification)fragment);
- if(loc != null) {
- return loc;
- }
- }
- }
- // If we found nothing, this may be a sync message receive
- if(fragment instanceof MessageOccurrenceSpecification) {
- boolean isSync = ((MessageOccurrenceSpecification)fragment).getMessage() != null && MessageSort.SYNCH_CALL_LITERAL.equals(((MessageOccurrenceSpecification)fragment).getMessage().getMessageSort());
- if(isSync) {
- // sync message should trigger an execution specification start. Find and return the corresponding start.
- EObject container = fragment.eContainer();
- EObject lifeline = lifelineEditPart.resolveSemanticElement();
- InteractionFragment nextFragment = InteractionFragmentHelper.findNextFragment(fragment, container);
- while(nextFragment != null && nextFragment.getCovereds().contains(lifeline)) {
- if(nextFragment.getCovereds().contains(lifeline)) {
- // Found next event of lifeline. Check if it really is a start.
- if(nextFragment instanceof ExecutionOccurrenceSpecification) {
- ExecutionSpecification exe = ((ExecutionOccurrenceSpecification)nextFragment).getExecution();
- if(exe != null && EcoreUtil.equals(exe.getStart(), nextFragment)) {
- // return location of the start.
- return findLocationOfEvent(lifelineEditPart, nextFragment);
- }
- }
- break;
- } else {
- nextFragment = InteractionFragmentHelper.findNextFragment(nextFragment, container);
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Get the bounds of an edit part
- *
- * @param part
- * edit part to find bounds
- * @return part's bounds in absolute coordinates
- */
- public static Rectangle getAbsoluteBounds(IGraphicalEditPart part) {
- // take bounds from figure
- Rectangle bounds = part.getFigure().getBounds().getCopy();
-
- if(part.getNotationView() instanceof Node) {
- // rather update with up to date model bounds
- Node node = (Node)part.getNotationView();
- LayoutConstraint cst = node.getLayoutConstraint();
- if(cst instanceof Bounds) {
- Bounds b = (Bounds)cst;
- Point parentLoc = part.getFigure().getParent().getBounds().getLocation();
- if(b.getX() > 0) {
- bounds.x = b.getX() + parentLoc.x;
- }
- if(b.getY() > 0) {
- bounds.y = b.getY() + parentLoc.y;
- }
- if(b.getHeight() != -1) {
- bounds.height = b.getHeight();
- }
- if(b.getWidth() != -1) {
- bounds.width = b.getWidth();
- }
- }
- }
-
- part.getFigure().getParent().translateToAbsolute(bounds);
- return bounds;
- }
-
- /**
- * Get the extremity of a connection edit part
- *
- * @param connection
- * the connection edit part to find extremity
- * @param isStart
- * true to find the start, false for the end
- * @return connection's extremity in absolute coordinates or null
- */
- public static Point getAbsoluteEdgeExtremity(ConnectionNodeEditPart connection, boolean isStart) {
- Connection msgFigure = connection.getConnectionFigure();
- if(connection.getNotationView() instanceof Edge) {
- // rather take up to date model information
- Edge edge = (Edge)connection.getNotationView();
- Anchor idAnchor = null;
- ConnectionAnchor conAnchor = null;
- Object part = null;
- if(isStart && connection.getSource() instanceof IGraphicalEditPart) {
- View linkedFigure = edge.getSource();
- // connection.getSource() may be not up to date, get part for linkedFigure
- part = connection.getSource().getViewer().getEditPartRegistry().get(linkedFigure);
- idAnchor = edge.getSourceAnchor();
- conAnchor = msgFigure.getSourceAnchor();
- } else if(!isStart && connection.getTarget() instanceof IGraphicalEditPart) {
- View linkedFigure = edge.getTarget();
- // connection.getTarget() may be not up to date, get part for linkedFigure
- part = connection.getTarget().getViewer().getEditPartRegistry().get(linkedFigure);
- idAnchor = edge.getTargetAnchor();
- conAnchor = msgFigure.getTargetAnchor();
- }
- if(part instanceof IGraphicalEditPart && idAnchor instanceof IdentityAnchor && conAnchor != null) {
- // take up to date bounds of the linked part in case it is moved
- Rectangle linkedPartBounds = getAbsoluteBounds((IGraphicalEditPart)part);
-
- IFigure anchorOwningFigure = conAnchor.getOwner();
- IFigure partFigure = ((IGraphicalEditPart)part).getFigure();
- Dimension delta = anchorOwningFigure.getBounds().getLocation().getDifference(partFigure.getBounds().getLocation());
- // get position from anchor id
- String oldTerminal = ((IdentityAnchor)idAnchor).getId();
- PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(oldTerminal);
- int xPos = linkedPartBounds.x + delta.width + (int)Math.round(anchorOwningFigure.getBounds().width * pp.preciseX);
- int yPos = linkedPartBounds.y + delta.height + (int)Math.round(anchorOwningFigure.getBounds().height * pp.preciseY);
- return new Point(xPos, yPos);
- }
- }
- // can not get from model, rely on figure
- if(msgFigure instanceof AbstractPointListShape) {
- Point extremity;
- if(isStart) {
- // start event of the message
- extremity = ((AbstractPointListShape)msgFigure).getStart().getCopy();
- } else {
- // finish event of the message
- extremity = ((AbstractPointListShape)msgFigure).getEnd().getCopy();
- }
- msgFigure.getParent().translateToAbsolute(extremity);
- return extremity;
- }
- return null;
- }
-
- /**
- * Find the location on a node of a message occurrence specification
- *
- * @param nodeEditPart
- * the node edit part which to check incoming and outgoing messages
- * @param event
- * the message occurrence specification
- * @return the absolute location or null
- */
- public static Point findLocationOfMessageOccurrence(GraphicalEditPart nodeEditPart, MessageOccurrenceSpecification event) {
- // messages to the node
- List<?> targetConnections = nodeEditPart.getTargetConnections();
- for(Object conn : targetConnections) {
- if(conn instanceof ConnectionNodeEditPart) {
- EObject element = ((ConnectionNodeEditPart)conn).resolveSemanticElement();
- if(element instanceof Message && event.equals(((Message)element).getReceiveEvent())) {
- // finish event of the message
- IFigure figure = ((ConnectionNodeEditPart)conn).getFigure();
- if(figure instanceof AbstractPointListShape) {
- return getAbsoluteEdgeExtremity((ConnectionNodeEditPart)conn, false);
- }
- }
- }
- }
- // messages from the node
- List<?> sourceConnections = nodeEditPart.getSourceConnections();
- for(Object conn : sourceConnections) {
- if(conn instanceof ConnectionNodeEditPart) {
- EObject element = ((ConnectionNodeEditPart)conn).resolveSemanticElement();
- if(element instanceof Message && event.equals(((Message)element).getSendEvent())) {
- // start event of the message
- IFigure figure = ((ConnectionNodeEditPart)conn).getFigure();
- if(figure instanceof AbstractPointListShape) {
- return getAbsoluteEdgeExtremity((ConnectionNodeEditPart)conn, true);
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Find the location on a node of a execution occurrence specification
- *
- * @param nodeEditPart
- * the node edit part which to check incoming and outgoing messages
- * @param event
- * the execution occurrence specification
- * @return the absolute location or null
- */
- public static Point findLocationOfExecutionOccurrence(GraphicalEditPart nodeEditPart, ExecutionOccurrenceSpecification event) {
- // child to the node
- List<?> children = nodeEditPart.getChildren();
- for(Object child : children) {
- if(child instanceof ActionExecutionSpecificationEditPart) {
- EObject element = ((ActionExecutionSpecificationEditPart)child).resolveSemanticElement();
- if(element != null && element instanceof ExecutionSpecification) {
- IFigure figure = ((ActionExecutionSpecificationEditPart)child).getFigure();
- Rectangle copy = figure.getBounds().getCopy();
- figure.translateToAbsolute(copy);
- if(event.equals(((ExecutionSpecification)element).getStart())){
- return copy.getTop();
- }else if(event.equals(((ExecutionSpecification)element).getFinish())){
- return copy.getBottom();
- }
- }
- }else if(child instanceof BehaviorExecutionSpecificationEditPart) {
- EObject element = ((BehaviorExecutionSpecificationEditPart)child).resolveSemanticElement();
- if(element != null && element instanceof ExecutionSpecification) {
- IFigure figure = ((BehaviorExecutionSpecificationEditPart)child).getFigure();
- Rectangle copy = figure.getBounds().getCopy();
- figure.translateToAbsolute(copy);
- if(event.equals(((ExecutionSpecification)element).getStart())){
- return copy.getTop();
- }else if(event.equals(((ExecutionSpecification)element).getFinish())){
- return copy.getBottom();
- }
- }
- }
- }
-
- return null;
- }
-
- /**
- * Find the occurrence specification covering the lifeline near the given location.
- * If none is close enough, null is returned.
- *
- * @param location
- * the location
- * @param lifelineEditPart
- * the Lifeline edit part
- * @return an entry with the nearest OccurrenceSpecification(s) and its corresponding location or null if none is close enough
- */
- public static Entry<Point, List<OccurrenceSpecification>> findNearestEvent(Point location, LifelineEditPart lifelineEditPart) {
- if(lifelineEditPart == null) {
- return null;
- }
- // Map referencing children occurrences by their location on the lifeline.
- Map<Point, List<OccurrenceSpecification>> occurrences = new HashMap<Point, List<OccurrenceSpecification>>();
- // graphical children of the lifeline
- List<?> children = lifelineEditPart.getChildren();
- for(Object child : children) {
- // children executions
- if(child instanceof ActionExecutionSpecificationEditPart || child instanceof BehaviorExecutionSpecificationEditPart) {
- EObject element = ((GraphicalEditPart)child).resolveSemanticElement();
- if(element instanceof ExecutionSpecification) {
- // find start and finish events of the execution
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)child);
- if(!occurrences.containsKey(bounds.getTop())) {
- // there should be at most 2 occurrences (with starting message)
- occurrences.put(bounds.getTop(), new ArrayList<OccurrenceSpecification>(2));
- }
- occurrences.get(bounds.getTop()).add(((ExecutionSpecification)element).getStart());
- if(!occurrences.containsKey(bounds.getBottom())) {
- occurrences.put(bounds.getBottom(), new ArrayList<OccurrenceSpecification>(1));
- }
- occurrences.get(bounds.getBottom()).add(((ExecutionSpecification)element).getFinish());
- // messages to and from the execution
- completeOccurrencesMapWithMessages((GraphicalEditPart)child, occurrences);
- }
- }
- // destruction event
- if(child instanceof DestructionOccurrenceSpecificationEditPart) {
- EObject destructionOccurence = ((GraphicalEditPart)child).resolveSemanticElement();
- EObject lifeline = lifelineEditPart.resolveSemanticElement();
- if(destructionOccurence instanceof DestructionOccurrenceSpecification && lifeline instanceof Lifeline) {
- for(InteractionFragment occurence : ((Lifeline)lifeline).getCoveredBys()) {
- if(occurence instanceof DestructionOccurrenceSpecification) {
- DestructionOccurrenceSpecification currentOccurence = ((DestructionOccurrenceSpecification)occurence);
- if(destructionOccurence.equals(currentOccurence)) {
- Rectangle bounds = getAbsoluteBounds((GraphicalEditPart)child);
- if(!occurrences.containsKey(bounds.getCenter())) {
- occurrences.put(bounds.getCenter(), new ArrayList<OccurrenceSpecification>(2));
- }
- occurrences.get(bounds.getCenter()).add((OccurrenceSpecification)occurence);
- break;
- }
- }
- }
- }
- }
- }
- // messages to and from the lifeline
- completeOccurrencesMapWithMessages(lifelineEditPart, occurrences);
-
- // Find the nearest object within acceptable distance
- double smallerDistance = MAXIMAL_DISTANCE_FROM_EVENT;
- Entry<Point, List<OccurrenceSpecification>> nearestObject = null;
- for(Entry<Point, List<OccurrenceSpecification>> entry : occurrences.entrySet()) {
- double distance = location.getDistance(entry.getKey());
- if(distance < smallerDistance) {
- smallerDistance = distance;
- nearestObject = entry;
- } else if(distance == smallerDistance && nearestObject != null) {
- // two events at the exact same distance.
- // Keep both so the best one can be used
- if(entry.getValue() instanceof MessageOccurrenceSpecification) {
- nearestObject.getValue().addAll(entry.getValue());
- }
- }
- }
-
- return nearestObject;
- }
-
- /**
- * Complete the map of occurrences and their location, by taking in account messages from and to the node edit part
- *
- * @param nodeEditPart
- * part to consider message around
- * @param occurrencesMap
- * the map to complete
- */
- private static void completeOccurrencesMapWithMessages(GraphicalEditPart nodeEditPart, Map<Point, List<OccurrenceSpecification>> occurrencesMap) {
- // messages to the node
- List<?> targetConnections = nodeEditPart.getTargetConnections();
- for(Object conn : targetConnections) {
- if(conn instanceof ConnectionNodeEditPart) {
- EObject element = ((ConnectionNodeEditPart)conn).resolveSemanticElement();
- if(element instanceof Message && ((Message)element).getReceiveEvent() instanceof MessageOccurrenceSpecification) {
- // finish events of the message
- IFigure figure = ((ConnectionNodeEditPart)conn).getFigure();
- if(figure instanceof AbstractPointListShape) {
- Point end = getAbsoluteEdgeExtremity((ConnectionNodeEditPart)conn, false);
- if(!occurrencesMap.containsKey(end)) {
- occurrencesMap.put(end, new ArrayList<OccurrenceSpecification>(1));
- }
- occurrencesMap.get(end).add((MessageOccurrenceSpecification)((Message)element).getReceiveEvent());
- }
- }
- }
- }
- // messages from the node
- List<?> sourceConnections = nodeEditPart.getSourceConnections();
- for(Object conn : sourceConnections) {
- if(conn instanceof ConnectionNodeEditPart) {
- EObject element = ((ConnectionNodeEditPart)conn).resolveSemanticElement();
- if(element instanceof Message && ((Message)element).getSendEvent() instanceof MessageOccurrenceSpecification) {
- // start events of the message
- IFigure figure = ((ConnectionNodeEditPart)conn).getFigure();
- if(figure instanceof AbstractPointListShape) {
- Point start = getAbsoluteEdgeExtremity((ConnectionNodeEditPart)conn, true);
- if(!occurrencesMap.containsKey(start)) {
- occurrencesMap.put(start, new ArrayList<OccurrenceSpecification>(1));
- }
- occurrencesMap.get(start).add((MessageOccurrenceSpecification)((Message)element).getSendEvent());
- }
- }
- }
- }
- }
-
- /**
- * The position of the part where the event is linked
- *
- * @param occSpec
- * the occurrence specification
- * @param timeElementPart
- * the part representing time element (duration/time constraint/observation)
- * @return one of {@link PositionConstants#TOP}, {@link PositionConstants#CENTER}, {@link PositionConstants#BOTTOM},
- * {@link PositionConstants#NONE}
- */
- public static int positionWhereEventIsLinkedToPart(OccurrenceSpecification occSpec, IBorderItemEditPart timeElementPart) {
- EObject timeElement = timeElementPart.resolveSemanticElement();
- if(timeElement instanceof TimeObservation) {
- if(occSpec.equals(((TimeObservation)timeElement).getEvent())) {
- return PositionConstants.CENTER;
- } else {
- return PositionConstants.NONE;
- }
- } else if(timeElement instanceof TimeConstraint) {
- if(((TimeConstraint)timeElement).getConstrainedElements().contains(occSpec)) {
- return PositionConstants.CENTER;
- } else {
- return PositionConstants.NONE;
- }
- } else if(timeElement instanceof DurationConstraint) {
- if(((DurationConstraint)timeElement).getConstrainedElements().contains(occSpec)) {
- List<Element> events = ((DurationConstraint)timeElement).getConstrainedElements();
- LifelineEditPart lifelinePart = getParentLifelinePart(timeElementPart);
- if(lifelinePart != null && events.size() >= 2) {
- OccurrenceSpecification otherEvent = null;
- if(!occSpec.equals(events.get(0)) && events.get(0) instanceof OccurrenceSpecification) {
- otherEvent = (OccurrenceSpecification)events.get(0);
- } else if(!occSpec.equals(events.get(1)) && events.get(1) instanceof OccurrenceSpecification) {
- otherEvent = (OccurrenceSpecification)events.get(1);
- }
- if(otherEvent != null) {
- Point otherLoc = findLocationOfEvent(lifelinePart, otherEvent);
- Point thisLoc = findLocationOfEvent(lifelinePart, occSpec);
- if(otherLoc != null && thisLoc != null) {
- if(otherLoc.y > thisLoc.y) {
- return PositionConstants.TOP;
- } else {
- return PositionConstants.BOTTOM;
- }
- }
- }
- }
- } else {
- return PositionConstants.NONE;
- }
- }
- return PositionConstants.NONE;
- }
-
- /**
- * Return the lifeline edit part containing this part (directly or indirectly)
- *
- * @param nodeEditPart
- * the contained edit part or itself
- * @return lifeline edit part or null
- */
- public static LifelineEditPart getParentLifelinePart(EditPart nodeEditPart) {
- EditPart parent = nodeEditPart;
- while(parent != null) {
- if(parent instanceof LifelineEditPart) {
- return (LifelineEditPart)parent;
- } else {
- parent = parent.getParent();
- }
- }
- return null;
- }
-
- /**
- * Get the edit part (message, execution, or destruction event) which starts or finishes with the event on the given lifeline part
- *
- * @param lifelinePart
- * the lifeline edit part on which the event is located
- * @param event
- * the event
- * @return the edit part of which an end is defined by event on the lifelinePart edit part
- */
- public static EditPart getLinkedEditPart(EditPart lifelinePart, OccurrenceSpecification event) {
- if(event instanceof MessageOccurrenceSpecification) {
- // get parts representing the message linked with the event
- Message message = ((MessageOccurrenceSpecification)event).getMessage();
- if(message == null) {
- return null;
- }
- Collection<Setting> settings = CacheAdapter.INSTANCE.getNonNavigableInverseReferences(message);
- for(Setting ref : settings) {
- if(NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View)ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the message part must start or finish on the lifeline (with the event)
- if(part instanceof ConnectionEditPart) {
- EditPart lifelineChild = null;
- if(event.equals(message.getSendEvent())) {
- lifelineChild = ((ConnectionEditPart)part).getSource();
- } else if(event.equals(message.getReceiveEvent())) {
- lifelineChild = ((ConnectionEditPart)part).getTarget();
- }
- LifelineEditPart parentLifeline = getParentLifelinePart(lifelineChild);
- if(lifelinePart.equals(parentLifeline)) {
- return part;
- }
- }
- }
- }
- } else if(event instanceof ExecutionOccurrenceSpecification) {
- // get parts representing the execution linked with the event
- ExecutionSpecification execution = ((ExecutionOccurrenceSpecification)event).getExecution();
- if(execution == null) {
- return null;
- }
- Collection<Setting> settings = CacheAdapter.INSTANCE.getNonNavigableInverseReferences(execution);
- for(Setting ref : settings) {
- if(NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View)ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the execution part must be on the lifeline
- EditPart lifelineChild = part;
- LifelineEditPart parentLifeline = getParentLifelinePart(lifelineChild);
- if(lifelinePart.equals(parentLifeline)) {
- return part;
- }
- }
- }
- } else {
- // get parts representing the destruction event linked with the event
- for(Object lifelineChild : lifelinePart.getChildren()) {
- if(lifelineChild instanceof DestructionOccurrenceSpecificationEditPart) {
- EObject destr = ((DestructionOccurrenceSpecificationEditPart)lifelineChild).resolveSemanticElement();
- if(destr instanceof DestructionOccurrenceSpecification && destr.equals(event)) {
- return (EditPart)lifelineChild;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Get the object safely casted as a list of OccurrenceSpecification
- *
- * @param occurrenceSpecificationList
- * the object which is supposed to be a list of OccurrenceSpecification
- */
- public static List<OccurrenceSpecification> getAsOccSpecList(Object occurrenceSpecificationList) {
- if(occurrenceSpecificationList instanceof List<?>) {
- List<?> list = (List<?>)occurrenceSpecificationList;
- if(!list.isEmpty()) {
- List<OccurrenceSpecification> newList = new ArrayList<OccurrenceSpecification>(list.size());
- for(Object elt : list) {
- if(elt instanceof OccurrenceSpecification) {
- newList.add((OccurrenceSpecification)elt);
- }
- }
- return newList;
- }
- }
- return Collections.emptyList();
- }
-
- /**
- * Get the pair of OccurrenceSpecification which a duration constraint or observation should be created between
- *
- * @param occ1List
- * the list of occurrences at the same time, among which the first one must be chosen
- * @param occ2List
- * the list of occurrences at the same time, among which the second one must be chosen
- * @return size two array of OccurrenceSpecification which can be linked or null
- */
- public static OccurrenceSpecification[] getPairOfCorrespondingOccSpec(List<OccurrenceSpecification> occ1List, List<OccurrenceSpecification> occ2List) {
- // check for occurrences linked by a message
- for(OccurrenceSpecification occ1 : occ1List) {
- for(OccurrenceSpecification occ2 : occ2List) {
- if(DurationConstraintHelper.endsOfSameMessage(occ1, occ2)) {
- // we must link occurrences of a message
- return new OccurrenceSpecification[]{ occ1, occ2 };
- }
- }
- }
- // check for occurrences on a same lifeline
- for(OccurrenceSpecification occ1 : occ1List) {
- if(occ1 instanceof MessageOccurrenceSpecification) {
- Message mess = ((MessageOccurrenceSpecification)occ1).getMessage();
- if(mess.getReceiveEvent().equals(occ1) && MessageSort.SYNCH_CALL_LITERAL.equals(mess.getMessageSort())) {
- // filter receive event, we prefer the corresponding start event at the same location
- continue;
- }
- }
- for(OccurrenceSpecification occ2 : occ2List) {
- if(occ2 instanceof MessageOccurrenceSpecification) {
- Message mess = ((MessageOccurrenceSpecification)occ2).getMessage();
- if(mess.getReceiveEvent().equals(occ2) && MessageSort.SYNCH_CALL_LITERAL.equals(mess.getMessageSort())) {
- // filter receive event, we prefer the corresponding start event at the same location
- continue;
- }
- }
- if(DurationConstraintHelper.coversSameLifeline(occ1, occ2)) {
- // we must link occurrences on a same lifeline
- return new OccurrenceSpecification[]{ occ1, occ2 };
- }
- }
- }
- return null;
- }
-
- public static List<Element> getCombinedFragmentAssociatedElement(CombinedFragment cf) {
- List<Element> elements = new LinkedList<Element>();
-
- for(InteractionOperand operand : cf.getOperands()) {
- // Add all elements related to this operand
- elements.addAll(getInteractionOperandAssociatedElement(operand));
- // Add this operand
- elements.add(operand);
- }
- return elements;
-
- }
-
- public static List<Element> getInteractionOperandAssociatedElement(InteractionOperand interactionOperand) {
- List<Element> elements = new LinkedList<Element>();
- for(InteractionFragment itf : interactionOperand.getFragments()) {
- if(itf instanceof CombinedFragment) {
- // add the combinedFragment
- elements.addAll(getCombinedFragmentAssociatedElement((CombinedFragment)itf));
- }
- elements.add(itf);
- if(itf instanceof MessageOccurrenceSpecification) {
- MessageOccurrenceSpecification mos = (MessageOccurrenceSpecification)itf;
- if(mos.getMessage() != null) {
- elements.add(mos.getMessage());
- }
- }
- }
- return elements;
- }
-
- public static void handleMessageSortChange(EditingDomain editingDomain, Notification notification, Message message, MessageSort expectedMessageSort) {
- //This restriction isn't needed anymore, as the Property View offers a refactoring
- //facility for the MessageSort. The refactoring is only available for AsynchCall to
- //AsynchSignal and vice-versa.
- //However, the modification of the MessageSort from the "Advanced" property view should still be forbidden.
-
- Object feature = notification.getFeature();
-
- if(UMLPackage.eINSTANCE.getMessage_MessageSort().equals(feature) && !expectedMessageSort.equals(notification.getNewValue())) {
- Object oldValue = notification.getOldValue();
- Object newValue = notification.getNewValue();
- if(oldValue instanceof MessageSort) {
- if(!((oldValue == MessageSort.ASYNCH_CALL_LITERAL && newValue == MessageSort.ASYNCH_SIGNAL_LITERAL) || (oldValue == MessageSort.ASYNCH_SIGNAL_LITERAL && newValue == MessageSort.ASYNCH_CALL_LITERAL))) {
- MessageDialog.openWarning(Display.getCurrent().getActiveShell(), BLOCK_SORT_MODIFICATION_TITLE, BLOCK_SORT_MODIFICATION_MSG);
- CommandHelper.executeCommandWithoutHistory(editingDomain, SetCommand.create(editingDomain, message, feature, notification.getOldValue()), true);
- return;
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public static Set<Lifeline> getCoveredLifelines(Rectangle selectionRect, EditPart hostEditPart) {
- Set<Lifeline> coveredLifelines = new HashSet<Lifeline>();
-
- // retrieve all the edit parts in the registry
- Set<Entry<Object, EditPart>> allEditPartEntries = hostEditPart.getViewer().getEditPartRegistry().entrySet();
- for(Entry<Object, EditPart> epEntry : allEditPartEntries) {
- EditPart ep = epEntry.getValue();
-
- if(ep instanceof ShapeEditPart) {
- ShapeEditPart sep = (ShapeEditPart)ep;
- EObject elem = sep.getNotationView().getElement();
-
- if(elem instanceof Lifeline) {
- Rectangle figureBounds = getAbsoluteBounds(sep);
-
- if(selectionRect.intersects(figureBounds)) {
- coveredLifelines.add((Lifeline)elem);
- }
- }
- }
- }
- return coveredLifelines;
- }
-
- /**
- * retrieve all the interaction fragments and their related ift at least partially covered by the rectangle, including sub ift like
- * interaction operands in combined fragment.
- *
- * @param selectionRect
- * the rectangle where to look for ift.
- * @param hostEditPart
- * the host edit part used to retrieve all the edit parts in the registry.
- * @param ignoreSet
- * a set of ift to ignore.
- * @return
- * a set containing the covered ift or null if an ift not ignored is not fully covered.
- */
- @SuppressWarnings("unchecked")
- public static Set<InteractionFragment> getCoveredInteractionFragments(Rectangle selectionRect, EditPart hostEditPart, Set<InteractionFragment> ignoreSet) {
- Set<InteractionFragment> coveredInteractionFragments = new HashSet<InteractionFragment>();
-
- if(ignoreSet == null) {
- ignoreSet = new HashSet<InteractionFragment>();
- }
-
- // retrieve all the edit parts in the registry
- Set<Entry<Object, EditPart>> allEditPartEntries = hostEditPart.getViewer().getEditPartRegistry().entrySet();
- for(Entry<Object, EditPart> epEntry : allEditPartEntries) {
- EditPart ep = epEntry.getValue();
-
- if(ep instanceof ShapeEditPart) {
- ShapeEditPart sep = (ShapeEditPart)ep;
- EObject elem = sep.getNotationView().getElement();
-
- if(elem instanceof InteractionFragment && !ignoreSet.contains(elem)) {
- Rectangle figureBounds = getAbsoluteBounds(sep);
-
- // keep the fragment if its figure is completely in the selection
- // if it is inside but not completely this method return null
- if(selectionRect.contains(figureBounds)) {
- coveredInteractionFragments.add((InteractionFragment)elem);
- if(elem instanceof ExecutionSpecification) {
- ExecutionSpecification es = (ExecutionSpecification)elem;
- coveredInteractionFragments.add(es.getStart());
- coveredInteractionFragments.add(es.getFinish());
- }
- } else {
- Rectangle intersection = selectionRect.getIntersection(figureBounds);
- if(!intersection.equals(new Rectangle()) && !intersection.equals(selectionRect)) {
- return null;
- }
- }
- }
-
- } else if(ep instanceof ConnectionEditPart) {
- ConnectionEditPart cep = (ConnectionEditPart)ep;
- EObject elem = cep.getNotationView().getElement();
-
- // for connections, messages have ends that are ift but don't have theirs own edit parts
- // => use anchors to determine if they should be included in the set
- if(elem instanceof Message) {
- Message msg = (Message)elem;
- Connection msgFigure = cep.getConnectionFigure();
-
- Point sourcePoint = msgFigure.getSourceAnchor().getReferencePoint();
- Point targetPoint = msgFigure.getTargetAnchor().getReferencePoint();
-
- if(selectionRect.contains(sourcePoint)) {
- MessageEnd msgSendEnd = msg.getSendEvent();
- if(msgSendEnd instanceof InteractionFragment) {
- coveredInteractionFragments.add((InteractionFragment)msgSendEnd);
- }
- }
- if(selectionRect.contains(targetPoint)) {
- MessageEnd msgReceiveEnd = msg.getReceiveEvent();
- if(msgReceiveEnd instanceof InteractionFragment) {
- coveredInteractionFragments.add((InteractionFragment)msgReceiveEnd);
- }
- }
- }
- }
- }
- return coveredInteractionFragments;
- }
-
- /**
- * return a command to set the enclosing interaction or interaction operand of an interaction fragment.
- *
- * @param ed
- * The transactional editing domain.
- * @param ift
- * The interaction fragment.
- * @param io
- * the new enclosing interaction.
- * @return The command.
- */
- public static ICommand getSetEnclosingInteractionCommand(final TransactionalEditingDomain ed, final InteractionFragment ift, final EObject interaction) {
- return new AbstractTransactionalCommand(ed, "Set enclosing interaction command", null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- setEnclosingInteraction(ift, interaction, false);
-
- return CommandResult.newOKCommandResult();
- }
- };
- }
-
- /**
- * Set the interaction or interaction operand which contains a fragment
- *
- * @param ift
- * fragment to update container
- * @param interaction
- * new containing interaction or interaction operand
- * @param forceIfCoregion
- * force the set even if fragment belong to a coregion. Use true only when you are sure the fragment no longer belongs to a coregion's
- * operand.
- */
- public static void setEnclosingInteraction(InteractionFragment ift, EObject interaction, boolean forceIfCoregion) {
- if(ift != null) {
- if(interaction instanceof Interaction) {
- if(!interaction.equals(ift.getEnclosingInteraction())) {
- // check case when mos looks outside but is in a coregion.
- if(!forceIfCoregion && ift instanceof MessageOccurrenceSpecification) {
- InteractionOperand operand = ift.getEnclosingOperand();
- if(operand != null) {
- Element cf = operand.getOwner();
- if(cf instanceof CombinedFragment && InteractionOperatorKind.PAR_LITERAL.equals(((CombinedFragment)cf).getInteractionOperator())) {
- // was in a coregion. Check whether other mos is still in the coregion
- Message mess = ((MessageOccurrenceSpecification)ift).getMessage();
- // find other mos
- MessageOccurrenceSpecification otherMos = null;
- if(ift.equals(mess.getSendEvent()) && mess.getReceiveEvent() instanceof MessageOccurrenceSpecification) {
- otherMos = (MessageOccurrenceSpecification)mess.getReceiveEvent();
- } else if(ift.equals(mess.getReceiveEvent()) && mess.getSendEvent() instanceof MessageOccurrenceSpecification) {
- otherMos = (MessageOccurrenceSpecification)mess.getSendEvent();
- }
- if(otherMos != null) {
- // check that it is in a coregion (specific code is in charge of taking it out in ReconnectMessageHelper)
- if(operand.equals(otherMos.getEnclosingOperand())) {
- return;
- }
- }
- }
- }
- }
- ift.setEnclosingOperand(null);
- ift.setEnclosingInteraction((Interaction)interaction);
- }
- } else if(interaction instanceof InteractionOperand) {
- if(!interaction.equals(ift.getEnclosingOperand())) {
- ift.setEnclosingInteraction(null);
- ift.setEnclosingOperand((InteractionOperand)interaction);
- }
- }
- }
- }
-
- /**
- * return a command to add a covered lifeline to an interaction fragment.
- *
- * @param ed
- * The transactional editing domain.
- * @param ift
- * The interaction fragment.
- * @param lifeline
- * the lifeline.
- * @return The command.
- */
- public static ICommand getAddCoveredLifelineCommand(final TransactionalEditingDomain ed, final InteractionFragment ift, final Lifeline lifeline) {
- return new AbstractTransactionalCommand(ed, "Add covered lifeline command", null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ift.getCovereds().add(lifeline);
- return CommandResult.newOKCommandResult();
- }
- };
- }
-
- /**
- * return a command to remove a previously covered lifeline of an interaction fragment.
- *
- * @param ed
- * The transactional editing domain.
- * @param ift
- * The interaction fragment.
- * @param lifeline
- * the lifeline.
- * @return The command.
- */
- public static ICommand getRemoveCoveredLifelineCommand(final TransactionalEditingDomain ed, final InteractionFragment ift, final Lifeline lifeline) {
- return new AbstractTransactionalCommand(ed, "Add covered lifeline command", null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- ift.getCovereds().remove(lifeline);
- return CommandResult.newOKCommandResult();
- }
- };
- }
-
- /**
- * Create a command to update the enclosing interaction of a message end according to its new location.
- *
- * @param movedMos
- * the moved Message Occurrence Specification
- * @param newLocation
- * the new absolute location
- * @param editPart
- * any adit part of the corresponding diagram
- * @return the command or null if nothing changes
- */
- //@SuppressWarnings("unchecked")
- public static Command createUpdateEnclosingInteractionCommand(MessageOccurrenceSpecification movedMos, Point newLocation, GraphicalEditPart editPart) {
-
- // // calculate new bounds for the execution specification
- // Rectangle absoluteNewBounds = executionSpecificationEP.getFigure().getBounds().getCopy();
- //
- // executionSpecificationEP.getFigure().getParent().translateToAbsolute(absoluteNewBounds);
- //
- // absoluteNewBounds.translate(moveDelta);
- // absoluteNewBounds.resize(sizeDelta);
- //
- // int xCenter = absoluteNewBounds.getCenter().x;
- //
- // Rectangle top = new Rectangle(xCenter, absoluteNewBounds.y, 0, 0);
- // Rectangle bottom = new Rectangle(xCenter, absoluteNewBounds.bottom(), 0, 0);
- //
- // // associate es with its bounds, and start and finish event with the top and bottom of the bounds
- HashMap<InteractionFragment, Rectangle> iftToCheckForUpdate = new HashMap<InteractionFragment, Rectangle>();
- //
- // ExecutionSpecification es = (ExecutionSpecification)executionSpecificationEP.resolveSemanticElement();
-
- iftToCheckForUpdate.put(movedMos, new Rectangle(newLocation, new Dimension()));
-
- // iftToCheckForUpdate.put(es.getStart(), top);
- //
- // iftToCheckForUpdate.put(es.getFinish(), bottom);
- //
- // List<ConnectionEditPart> sourceConnectionEPs = executionSpecificationEP.getSourceConnections();
- //
- // // find possible ifts associated with messages connected to the moved es
- // for(ConnectionEditPart sourceConnectionEP : sourceConnectionEPs) {
- // EObject elem = sourceConnectionEP.getNotationView().getElement();
- //
- // // for connections, messages have ends that can be ift but don't have theirs own edit parts
- // // => use anchors to determine position
- // if(elem instanceof Message) {
- // Message msg = (Message)elem;
- // MessageEnd sendEvent = msg.getSendEvent();
- // if(sendEvent instanceof InteractionFragment) {
- // Connection msgFigure = sourceConnectionEP.getConnectionFigure();
- //
- // Point sourcePoint = msgFigure.getSourceAnchor().getLocation(msgFigure.getTargetAnchor().getReferencePoint());
- //
- // iftToCheckForUpdate.put((InteractionFragment)sendEvent, new Rectangle(sourcePoint.x + moveDelta.x, sourcePoint.y + moveDelta.y, 0, 0));
- // }
- // }
- // }
- //
- // List<ConnectionEditPart> targetConnectionEPs = executionSpecificationEP.getTargetConnections();
- //
- // for(ConnectionEditPart targetConnectionEP : targetConnectionEPs) {
- // EObject elem = targetConnectionEP.getNotationView().getElement();
- //
- // if(elem instanceof Message) {
- // Message msg = (Message)elem;
- // MessageEnd receiveEvent = msg.getReceiveEvent();
- // if(receiveEvent instanceof InteractionFragment) {
- // Connection msgFigure = targetConnectionEP.getConnectionFigure();
- //
- // Point targetPoint = msgFigure.getTargetAnchor().getLocation(msgFigure.getSourceAnchor().getReferencePoint());
- //
- // iftToCheckForUpdate.put((InteractionFragment)receiveEvent, new Rectangle(targetPoint.x + moveDelta.x, targetPoint.y + moveDelta.y, 0, 0));
- // }
- // }
- // }
-
- CompoundCommand cmd = new CompoundCommand();
-
- for(Map.Entry<InteractionFragment, Rectangle> entry : iftToCheckForUpdate.entrySet()) {
- InteractionFragment newEnclosingInteraction = findInteractionFragmentContainerAt(entry.getValue(), editPart);
- if(newEnclosingInteraction != null) {
- cmd.add(new ICommandProxy(getSetEnclosingInteractionCommand(editPart.getEditingDomain(), entry.getKey(), newEnclosingInteraction)));
- }
- }
-
- if(!cmd.isEmpty()) {
- return cmd;
- } else {
- return null;
- }
- }
-
- /**
- * Create a command to update the enclosing interaction of an execution specification according to its new bounds.
- *
- * @param executionSpecificationEP
- * the edit part of the execution specification
- * @param absoluteNewBounds
- * the new absolute bounds
- * @return the command or null if nothing changes
- */
- @SuppressWarnings("unchecked")
- public static Command createUpdateEnclosingInteractionCommand(ShapeNodeEditPart executionSpecificationEP, Point moveDelta, Dimension sizeDelta) {
-
- // calculate new bounds for the execution specification
- Rectangle absoluteNewBounds = executionSpecificationEP.getFigure().getBounds().getCopy();
-
- executionSpecificationEP.getFigure().getParent().translateToAbsolute(absoluteNewBounds);
-
- absoluteNewBounds.translate(moveDelta);
- absoluteNewBounds.resize(sizeDelta);
-
- int xCenter = absoluteNewBounds.getCenter().x;
-
- Rectangle top = new Rectangle(xCenter, absoluteNewBounds.y, 0, 0);
- Rectangle bottom = new Rectangle(xCenter, absoluteNewBounds.bottom(), 0, 0);
-
- // associate es with its bounds, and start and finish event with the top and bottom of the bounds
- HashMap<InteractionFragment, Rectangle> iftToCheckForUpdate = new HashMap<InteractionFragment, Rectangle>();
-
- ExecutionSpecification es = (ExecutionSpecification)executionSpecificationEP.resolveSemanticElement();
-
- iftToCheckForUpdate.put(es, absoluteNewBounds);
-
- iftToCheckForUpdate.put(es.getStart(), top);
-
- iftToCheckForUpdate.put(es.getFinish(), bottom);
-
- List<ConnectionEditPart> sourceConnectionEPs = executionSpecificationEP.getSourceConnections();
-
- // find possible ifts associated with messages connected to the moved es
- for(ConnectionEditPart sourceConnectionEP : sourceConnectionEPs) {
- EObject elem = sourceConnectionEP.getNotationView().getElement();
-
- // for connections, messages have ends that can be ift but don't have theirs own edit parts
- // => use anchors to determine position
- if(elem instanceof Message) {
- Message msg = (Message)elem;
- MessageEnd sendEvent = msg.getSendEvent();
- if(sendEvent instanceof InteractionFragment) {
- Connection msgFigure = sourceConnectionEP.getConnectionFigure();
-
- Point sourcePoint = msgFigure.getSourceAnchor().getLocation(msgFigure.getTargetAnchor().getReferencePoint());
-
- iftToCheckForUpdate.put((InteractionFragment)sendEvent, new Rectangle(sourcePoint.x + moveDelta.x, sourcePoint.y + moveDelta.y, 0, 0));
- }
- }
- }
-
- List<ConnectionEditPart> targetConnectionEPs = executionSpecificationEP.getTargetConnections();
-
- for(ConnectionEditPart targetConnectionEP : targetConnectionEPs) {
- EObject elem = targetConnectionEP.getNotationView().getElement();
-
- if(elem instanceof Message) {
- Message msg = (Message)elem;
- MessageEnd receiveEvent = msg.getReceiveEvent();
- if(receiveEvent instanceof InteractionFragment) {
- Connection msgFigure = targetConnectionEP.getConnectionFigure();
-
- Point targetPoint = msgFigure.getTargetAnchor().getLocation(msgFigure.getSourceAnchor().getReferencePoint());
-
- iftToCheckForUpdate.put((InteractionFragment)receiveEvent, new Rectangle(targetPoint.x + moveDelta.x, targetPoint.y + moveDelta.y, 0, 0));
- }
- }
- }
-
- CompoundCommand cmd = new CompoundCommand();
-
- for(Map.Entry<InteractionFragment, Rectangle> entry : iftToCheckForUpdate.entrySet()) {
- InteractionFragment newEnclosingInteraction = findInteractionFragmentContainerAt(entry.getValue(), executionSpecificationEP);
- if(newEnclosingInteraction != null) {
- cmd.add(new ICommandProxy(getSetEnclosingInteractionCommand(executionSpecificationEP.getEditingDomain(), entry.getKey(), newEnclosingInteraction)));
- }
- }
-
- if(!cmd.isEmpty()) {
- return cmd;
- } else {
- return null;
- }
- }
-
- /**
- * Find the edit part a connection should be reconnected to at a given reference point on a lifeline
- *
- * @param lifelinePart
- * lifeline part on which the reconnection must be performed
- * @param referencePoint
- * the reference point
- * @return lifeline or execution specification edit part to reconnect to (the most external in the lifeline)
- */
- public static GraphicalEditPart findPartToReconnectTo(LifelineEditPart lifelinePart, Point referencePoint) {
- Rectangle absoluteLifelineBounds = getAbsoluteBounds(lifelinePart);
- // inspect children nodes of lifeline
- List<?> children = lifelinePart.getChildren();
- GraphicalEditPart adequateExecutionPart = null;
- int maxDeltaWithMiddle = 0;
- for(Object child : children) {
- // children executions
- if(child instanceof ActionExecutionSpecificationEditPart || child instanceof BehaviorExecutionSpecificationEditPart || child instanceof CombinedFragment2EditPart) {
- GraphicalEditPart childPart = (GraphicalEditPart)child;
- Rectangle absoluteBounds = getAbsoluteBounds(childPart);
- // enlarge absolute bounds to contain also the right and bottom edges.
- absoluteBounds.expand(1, 1);
- if(absoluteBounds.contains(referencePoint)) {
- // this is an adequate execution part, take the most external one
- int deltaWithMiddle = Math.abs(absoluteBounds.getTop().x - absoluteLifelineBounds.getTop().x);
- if(deltaWithMiddle >= maxDeltaWithMiddle) {
- maxDeltaWithMiddle = deltaWithMiddle;
- adequateExecutionPart = childPart;
- }
- }
- }
- }
- if(adequateExecutionPart != null) {
- return adequateExecutionPart;
- }
- return lifelinePart;
- }
-
- /**
- * Find the range of possible locations an occurrence specification should be drawn in.
- *
- * @param lifelineEditPart
- * the lifeline on which the occurrence specification appears.
- * @param occSpec
- * the occurrence specification to find locations for.
- * @return rectangle within which the occurrence specification must be drawn (width is not significative)
- */
- public static Rectangle findPossibleLocationsForEvent(LifelineEditPart lifelineEditPart, OccurrenceSpecification occSpec) {
- // at least, we know the event is in the drawn lifeline
- Rectangle result = lifelineEditPart.getContentPane().getBounds().getCopy();
- lifelineEditPart.getFigure().translateToAbsolute(result);
-
-
- // find the containing pane
- IGraphicalEditPart containerPart = findDrawnContainerEditPart(lifelineEditPart, occSpec);
- IFigure drawnContentPane = getContentPaneThatCanContainFragments(containerPart);
- if(drawnContentPane != null) {
- // content pane is the smallest drawn owning rectangle
- Rectangle bounds = drawnContentPane.getBounds().getCopy();
- drawnContentPane.getParent().translateToAbsolute(bounds);
- // intersect with the lifeline's content
- result.intersect(bounds);
- }
-
- // we must search surrounding interaction fragments within uppestContainerToSearchInto
- EObject uppestContainerToSearchInto = containerPart.resolveSemanticElement();
-
- InteractionFragment after = InteractionFragmentHelper.findNextFragment(occSpec, uppestContainerToSearchInto);
- boolean foundNextFragment = false;
- while(!foundNextFragment && after != null) {
- Point bottom = findLocationOfEvent(lifelineEditPart, after);
- if(bottom != null && result.contains(bottom)) {
- int diff = bottom.y - result.bottom();
- result.resize(0, diff);
- foundNextFragment = true;
- } else {
- // fragment not represented on lifeline, search next fragment
- after = InteractionFragmentHelper.findNextFragment(after, uppestContainerToSearchInto);
- }
- }
- InteractionFragment before = InteractionFragmentHelper.findPreviousFragment(occSpec, uppestContainerToSearchInto);
- boolean foundPreviousFragment = false;
- while(!foundPreviousFragment && before != null) {
- Point top = findLocationOfEvent(lifelineEditPart, before);
- if(top != null && result.contains(top)) {
- int diff = top.y - result.y;
- result.translate(0, diff);
- result.resize(0, -diff);
- foundPreviousFragment = true;
- /*
- * In case before is contained in an interaction operand or
- * combined fragment which does not contain the searched event,
- * we must also take in account the bottom border of this node.
- */
- reduceByNodeContainingBefore(result, before, occSpec, lifelineEditPart);
- } else {
- // fragment not represented on lifeline, search next fragment
- before = InteractionFragmentHelper.findPreviousFragment(before, uppestContainerToSearchInto);
- }
- }
- return result;
- }
-
- /**
- * Reduce the possible bounds by removing the area of an eventual interaction operand or combined fragment which contains the fragment "before"
- * and not the occurrence specification for which we search a location.
- *
- * @param possibleBounds
- * bounds to reduce, in which the location will be possible
- * @param before
- * the fragment which happens before
- * @param occSpec
- * the occurrence specification for which we search a location
- * @param lifelineEditPart
- * the lifeline on which the occurrence specification appears.
- */
- private static void reduceByNodeContainingBefore(Rectangle possibleBounds, InteractionFragment before, OccurrenceSpecification occSpec, LifelineEditPart lifelineEditPart) {
- Element eventualNodeElement = before;
- // inspect each container of before, until it is common with occSpec
- while(!EcoreUtil.isAncestor(eventualNodeElement, occSpec)) {
- // test if eventualNodeElement has bounds excluding occSpec
- // search for the eventualNodeElement's edit part
- List<View> views = DiagramEditPartsUtil.findViews(eventualNodeElement, lifelineEditPart.getViewer());
- for(View view : views) {
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelineEditPart);
- // test if edit part is an adequate node
- if(part instanceof IGraphicalEditPart && getContentPaneThatCanContainFragments(part) != null) {
- Rectangle bounds = getAbsoluteBounds((IGraphicalEditPart)part);
- // reduce so that the bounds are excluded
- int newPossibleTop = bounds.bottom();
- if(possibleBounds.y < newPossibleTop) {
- int diff = newPossibleTop - possibleBounds.y;
- possibleBounds.translate(0, diff);
- possibleBounds.resize(0, -diff);
- }
- }
- }
- eventualNodeElement = eventualNodeElement.getOwner();
- }
- }
-
- /**
- * Get the content pane of an edit part that can directly or indirectly contain interaction fragments (this excludes lifeline, which references)
- *
- * @param containerPart
- * container edit part
- * @return its content pane if the container can contain fragments, null otherwise.
- */
- private static IFigure getContentPaneThatCanContainFragments(EditPart containerPart) {
- // test all owner edit parts which can contain an interaction fragment
- if(containerPart instanceof InteractionOperandEditPart) {
- return ((InteractionOperandEditPart)containerPart).getContentPane();
- } else if(containerPart instanceof CombinedFragmentEditPart) {
- return ((CombinedFragmentEditPart)containerPart).getContentPane();
- } else if(containerPart instanceof CombinedFragment2EditPart) {
- return ((CombinedFragment2EditPart)containerPart).getContentPane();
- } else if(containerPart instanceof ContinuationEditPart) {
- return ((ContinuationEditPart)containerPart).getContentPane();
- } else if(containerPart instanceof InteractionUseEditPart) {
- return ((InteractionUseEditPart)containerPart).getContentPane();
- } else if(containerPart instanceof InteractionEditPart) {
- return ((InteractionEditPart)containerPart).getContentPane();
- }
- return null;
- }
-
- /**
- * Find the smallest drawn edit part containing the occurrence specification.
- *
- * @param lifelineEditPart
- * support lifeline edit part
- * @param occSpec
- * occurrence specification to localize
- * @return a drawn edit part which element contains the occurrence specification or null
- */
- private static IGraphicalEditPart findDrawnContainerEditPart(LifelineEditPart lifelineEditPart, OccurrenceSpecification occSpec) {
- // find containing drawn edit parts
- Element owner = occSpec.getOwner();
- while(owner != null) {
- // search for the owner's edit part
- List<View> views = DiagramEditPartsUtil.findViews(owner, lifelineEditPart.getViewer());
- for(View view : views) {
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelineEditPart);
- // test if edit part can contain the occurrence specification
- if(part instanceof IGraphicalEditPart && getContentPaneThatCanContainFragments(part) != null) {
- return (IGraphicalEditPart)part;
- }
- }
- owner = owner.getOwner();
- }
- return null;
- }
-
- /**
- * Check whether the Lifeline is Create Message's target node
- * @param lifelineEP
- * @return boolean
- */
- public static boolean isCreateMessageEndLifeline(LifelineEditPart lifelineEP){
- List<Object> targetConnections = lifelineEP.getTargetConnections();
- if(targetConnections!=null && targetConnections.size()>0){
- for(int i = 0;i<targetConnections.size();i++){
- Object connection = targetConnections.get(i);
- if(connection instanceof Message4EditPart){
- return true;
- }
- }
- }
- return false;
- }
-
-
- /**
- * Find Time Observations editpart which are related to specific OccurenceSpecification
- * @param lifelinePart
- * @param oss
- * @return List<TimeObservationLabelEditPart>
- */
- public static List<TimeObservationLabelEditPart> findOccurenceSpecificationRelatedTimeObservationPart(LifelineEditPart lifelinePart,List<OccurrenceSpecification> oss){
- List<TimeObservationLabelEditPart> list = new ArrayList<TimeObservationLabelEditPart>();
- if(oss == null || oss.size() == 0){
- return list;
- }
- if(lifelinePart!=null&&lifelinePart.getTargetConnections().size()>0){
- for(Object targetConnection : lifelinePart.getTargetConnections()){
- if(targetConnection instanceof ObservationLinkEditPart){
- ObservationLinkEditPart observationLinkEditPart = (ObservationLinkEditPart)targetConnection;
- if(observationLinkEditPart.getSource() instanceof TimeObservationLabelEditPart){
- TimeObservationLabelEditPart source = (TimeObservationLabelEditPart)observationLinkEditPart.getSource();
- EObject timeElement = source.resolveSemanticElement();
- if(timeElement instanceof TimeObservation) {
- if(oss.contains(((TimeObservation)timeElement).getEvent())) {
- list.add(source);
- }
- }
- }
- }
- }
- }
- return list;
- }
-
- /**
- * Find Time Observations editpart which are related to specific OccurenceSpecification
- * @param lifelinePart
- * @param os
- * @return List<TimeObservationLabelEditPart>
- */
- public static List<TimeObservationLabelEditPart> findOccurenceSpecificationRelatedTimeObservationPart(LifelineEditPart lifelinePart,OccurrenceSpecification os){
- List<OccurrenceSpecification> oss = new ArrayList<OccurrenceSpecification>();
- oss.add(os);
- return findOccurenceSpecificationRelatedTimeObservationPart(lifelinePart, oss);
- }
-
- /**
- * Find specific editpart by semantic model
- * @param editPart
- * @param targetElement
- * @param targetClass
- * @return EditPart
- */
- public static EditPart getEditPart(EditPart editPart,
- EObject targetElement, Class targetClass) {
- if (editPart == null || targetElement == null || targetClass == null)
- return null;
- Map<?, ?> map = editPart.getViewer().getEditPartRegistry();
- for (Entry<?, ?> entry : map.entrySet()) {
- Object key = entry.getKey();
- if (!(key instanceof View)) {
- continue;
- }
- View view = (View) key;
- EObject tempElement = view.getElement();
- if (targetElement.equals(tempElement)) {
- Object value = entry.getValue();
- if (value.getClass() == targetClass) {
- return (EditPart) value;
- }
- }
- }
- return null;
- }
-
- /**
- * Intall observation link policy to specific editpart
- * @param editPart
- */
- public static void installObservationLinkPolicy(EditPart editPart) {
- String editPolicy = "observationlink";
- if (editPart instanceof LifelineEditPart
- || editPart instanceof TimeObservationLabelEditPart) {
- editPart.installEditPolicy(editPolicy,
- new ObservationLinkPolicy(editPart));
- }
- if (editPart instanceof DurationObservationEditPart) {
- editPart.installEditPolicy(editPolicy,
- new ObservationLinkPolicy(editPart));
- }
- if (editPart instanceof MessageEditPart
- || editPart instanceof Message2EditPart
- || editPart instanceof Message3EditPart
- || editPart instanceof Message4EditPart
- || editPart instanceof Message5EditPart
- || editPart instanceof Message6EditPart
- || editPart instanceof Message7EditPart) {
- editPart.installEditPolicy(editPolicy,
- new ObservationLinkPolicy(editPart));
- } else if (editPart instanceof MessageNameEditPart
- || editPart instanceof MessageName2EditPart
- || editPart instanceof MessageName3EditPart
- || editPart instanceof MessageName4EditPart
- || editPart instanceof MessageName5EditPart
- || editPart instanceof MessageName6EditPart
- || editPart instanceof MessageName7EditPart) {
- editPart.getParent().installEditPolicy(editPolicy,
- new ObservationLinkPolicy(editPart));
- } else if (editPart instanceof MessageSyncAppliedStereotypeEditPart
- || editPart instanceof MessageAsyncAppliedStereotypeEditPart
- || editPart instanceof MessageReplyAppliedStereotypeEditPart
- || editPart instanceof MessageCreateAppliedStereotypeEditPart
- || editPart instanceof MessageDeleteAppliedStereotypeEditPart
- || editPart instanceof MessageLostAppliedStereotypeEditPart
- || editPart instanceof MessageFoundAppliedStereotypeEditPart) {
- editPart.getParent().installEditPolicy(editPolicy,
- new ObservationLinkPolicy(editPart));
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/FragmentOrderingKeeper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/FragmentOrderingKeeper.java
deleted file mode 100644
index 559d6df2f31..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/FragmentOrderingKeeper.java
+++ /dev/null
@@ -1,823 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.validation;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.validation.IValidationContext;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.common.util.MDTUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.util.DestructionOccurrenceUtil;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.GeneralOrdering;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.MessageSort;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
-
-/**
- * This class is a validator which ensures that :<br/>
- * <li>
- * <ul>
- * In the order Interaction's fragment property, the order is kept as a valid trace,
- * </ul>
- * <ul>
- * Or at least, when there is no valid trace, that the order is kept for each lifeline (not to loose sequence information on a lifeline, which is
- * contained only graphically otherwise).
- * </ul>
- * </li> <br/>
- * Note that this class contains an algorithm which computes a valid trace. With little adaptation, it could easily provide all valid traces, hence,
- * compare two lifelines to know whether they are equivalent.
- *
- * @author vhemery
- */
-public class FragmentOrderingKeeper {
-
- /** A constant equals to half the smallest location delta */
- private static final float HALF_UNIT = (float)0.5;
-
- /** Format for displaying an element's name */
- private static final String NAME_FORMAT = "<{0}> {1}";
-
- /** map with, for a given index, the fragments which have been put with an optional order (may change) */
- private Map<Integer, List<InteractionFragment>> optionallyOrderedFragments;
-
- private EList<InteractionFragment> orderedFragments;
-
- private Set<Lifeline> constrainingNotRepresentedLifelines;
-
- private Set<LifelineEditPart> constrainingLifelineParts;
-
- private Set<Message> constrainingMessages;
-
- private Set<ExecutionSpecification> constrainingExecutions;
-
- private Set<GeneralOrdering> constrainingGeneralOrderings;
-
- /* private Set<CombinedFragment> constrainingCombinedFragments; */
-
- private List<List<InteractionFragment>> orderConstraints;
-
- private Set<InteractionFragment> conflictingFragments;
-
- /**
- * Validate modification and update the interaction's fragments order if necessary.
- *
- * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
- *
- * @param target
- * the target to validate
- * @param ctx
- * validation context
- * @return status
- */
- public IStatus validate(EObject target, IValidationContext ctx) {
- if(target instanceof Interaction) {
- Interaction interaction = (Interaction)target;
- boolean valid = validateOrder(interaction);
- if(!valid) {
- IStatus status = ctx.createFailureStatus(getConflictingFragmentsFormattedString());
- removeModelReferences();
- return status;
- }
- } else if(target instanceof InteractionOperand) {
- InteractionOperand interactionOp = (InteractionOperand)target;
- boolean valid = validateOrder(interactionOp);
- if(!valid) {
- IStatus status = ctx.createFailureStatus(getConflictingFragmentsFormattedString());
- removeModelReferences();
- return status;
- }
- } else if(target instanceof InteractionFragment) {
- InteractionFragment fragment = (InteractionFragment)target;
- boolean valid = validateOrder(fragment.getEnclosingInteraction());
- if(!valid) {
- IStatus status = ctx.createFailureStatus(getConflictingFragmentsFormattedString());
- removeModelReferences();
- return status;
- }
- }
- removeModelReferences();
- return ctx.createSuccessStatus();
- }
-
- /**
- * Get a formatted string with names of all conflicting fragments
- *
- * @return formatted string
- */
- private String getConflictingFragmentsFormattedString() {
- StringBuffer buff = new StringBuffer();
- for(InteractionFragment frag : conflictingFragments) {
- buff.append(System.getProperty("line.separator"));
- String name = NLS.bind(NAME_FORMAT, frag.eClass().getName(), frag.getQualifiedName());
- buff.append(name);
- }
- return buff.toString();
- }
-
- /**
- * Remove any reference to model elements to avoid memory loss
- */
- private void removeModelReferences() {
- // orderedFragments is an EList, hence, we must not empty it.
- orderedFragments = null;
- // other lists can be cleared.
- if(constrainingLifelineParts != null) {
- constrainingLifelineParts.clear();
- }
- if(constrainingMessages != null) {
- constrainingMessages.clear();
- }
- if(constrainingExecutions != null) {
- constrainingExecutions.clear();
- }
- if(constrainingGeneralOrderings != null) {
- constrainingGeneralOrderings.clear();
- }
- //constrainingCombinedFragments.clear();
- if(orderConstraints != null) {
- orderConstraints.clear();
- }
- if(conflictingFragments != null) {
- conflictingFragments.clear();
- }
- if(optionallyOrderedFragments != null) {
- optionallyOrderedFragments.clear();
- }
- }
-
- /**
- * Validate the order of interaction operand's fragments
- *
- * @param interactionOperand
- * the interaction operand
- * @return true if a valid trace has been computed, false if none exists
- */
- private boolean validateOrder(InteractionOperand interactionOperand) {
- orderedFragments = interactionOperand.getFragments();
- computeConstraints();
- return reorderFragmentsInAValidTrace();
- }
-
- /**
- * Validate the order of interaction's fragments
- *
- * @param interaction
- * the interaction
- * @return true if a valid trace has been computed, false if none exists
- */
- private boolean validateOrder(Interaction interaction) {
- orderedFragments = interaction.getFragments();
- computeConstraints();
- return reorderFragmentsInAValidTrace();
- }
-
- /**
- * Compute constraints defined on fragments.<br/>
- * These are given by (by priority order):<br/>
- * <li>
- * <ul>
- * Lifelines (graphical location and previous order of elements not drawn)
- * </ul>
- * <ul>
- * Combined Fragments (graphical order of InteractionOperands in case no Lifeline is covered)
- * </ul>
- * <ul>
- * Messages (send > receive)
- * </ul>
- * ExecutionSpecifications (start > execution > finish)
- * <ul>
- * <ul>
- * General Orderings (before > after)
- * </ul>
- * </li>
- */
- private void computeConstraints() {
- IEditorPart editor = MDTUtil.getActiveEditor();
- DiagramEditPart diagram = null;
- if(editor instanceof IDiagramWorkbenchPart) {
- diagram = ((IDiagramWorkbenchPart)editor).getDiagramEditPart();
- }
-
- // reset constraints
- constrainingNotRepresentedLifelines = new HashSet<Lifeline>();
- constrainingLifelineParts = new HashSet<LifelineEditPart>();
- /* constrainingCombinedFragments = new HashSet<CombinedFragment>(); */
- constrainingMessages = new HashSet<Message>();
- constrainingExecutions = new HashSet<ExecutionSpecification>();
- constrainingGeneralOrderings = new HashSet<GeneralOrdering>();
- // get new constraining objects
- for(InteractionFragment fragment : orderedFragments) {
- // get Lifelines
- for(Lifeline lifeline : fragment.getCovereds()) {
- boolean lifelineRepresented = false;
- List<?> lifelineViews = DiagramEditPartsUtil.getEObjectViews(lifeline);
- for(Object lifelineView : lifelineViews) {
- if(lifelineView instanceof View && diagram != null) {
- int visualID = UMLVisualIDRegistry.getVisualID((View)lifelineView);
- if(visualID == LifelineEditPart.VISUAL_ID) {
- EditPart part = DiagramEditPartsUtil.getEditPartFromView((View)lifelineView, diagram);
- if(part instanceof LifelineEditPart) {
- constrainingLifelineParts.add((LifelineEditPart)part);
- lifelineRepresented = true;
- }
- }
- }
- }
- if(!lifelineRepresented) {
- // rely on old order for the lifeline
- constrainingNotRepresentedLifelines.add(lifeline);
- }
- }
- // get usefull Combined Fragments. Removed, since Combined Fragments own themselves their operands
- /*
- * if(fragment.getCovereds().isEmpty()) {
- * if(fragment instanceof CombinedFragment) {
- * constrainingCombinedFragments.add((CombinedFragment)fragment);
- * } else if(fragment instanceof InteractionOperand) {
- * Element owningCF = fragment.getOwner();
- * if(owningCF instanceof CombinedFragment) {
- * constrainingCombinedFragments.add((CombinedFragment)owningCF);
- * }
- * }
- * }
- */
- // get Messages
- if(fragment instanceof MessageOccurrenceSpecification) {
- Message mess = ((MessageOccurrenceSpecification)fragment).getMessage();
- if(mess != null) {
- constrainingMessages.add(mess);
- }
- }
- // get ExecutionSpecifications
- if(fragment instanceof ExecutionSpecification) {
- constrainingExecutions.add((ExecutionSpecification)fragment);
- } else if(fragment instanceof ExecutionOccurrenceSpecification) {
- ExecutionSpecification exe = ((ExecutionOccurrenceSpecification)fragment).getExecution();
- if(exe != null) {
- constrainingExecutions.add(exe);
- }
- }
- // get General Orderings
- if(fragment instanceof OccurrenceSpecification) {
- EList<GeneralOrdering> orderings = ((OccurrenceSpecification)fragment).getToAfters();
- constrainingGeneralOrderings.addAll(orderings);
- orderings = ((OccurrenceSpecification)fragment).getToBefores();
- constrainingGeneralOrderings.addAll(orderings);
- }
- }
-
- // construct constrained partial orders
- constructPartialOrders();
- }
-
- /**
- * Compute partial orders given by constraining elements (ordered by priority).<br/>
- * <li>
- * <ul>
- * Lifelines (graphical location and previous order of elements not drawn)
- * </ul>
- * <ul>
- * Combined Fragments (graphical order of InteractionOperands in case no Lifeline is covered)
- * </ul>
- * <ul>
- * Messages (send > receive)
- * </ul>
- * ExecutionSpecifications (start > execution > finish)
- * <ul>
- * <ul>
- * General Orderings (before > after)
- * </ul>
- * </li>
- */
- private void constructPartialOrders() {
- optionallyOrderedFragments = new HashMap<Integer, List<InteractionFragment>>();
- int numberOfConstraints = constrainingNotRepresentedLifelines.size() + constrainingLifelineParts.size() + constrainingMessages.size() + constrainingExecutions.size() + constrainingGeneralOrderings.size();
- /*
- * + constrainingCombinedFragments.size();
- */
- orderConstraints = new ArrayList<List<InteractionFragment>>(numberOfConstraints);
- int indexConstraint = 0;
- // construct lifelines constraints (model only)
- for(Lifeline lifeline : constrainingNotRepresentedLifelines) {
- List<InteractionFragment> constraint = new ArrayList<InteractionFragment>();
- //fill constraint : previous order for elements of lifeline not drawn
- for(InteractionFragment fragment : orderedFragments) {
- if(lifeline.getCoveredBys().contains(fragment)) {
- constraint.add(fragment);
- }
- }
- DestructionOccurrenceUtil.reorderDestructionOccurrence(constraint);
- // store constraint
- orderConstraints.add(indexConstraint, constraint);
- indexConstraint++;
- }
- // construct lifelines constraints (graphical and model)
- for(LifelineEditPart part : constrainingLifelineParts) {
- TreeMap<Float, InteractionFragment> constraint = new TreeMap<Float, InteractionFragment>();
- //fill constraint : graphical location and previous order of elements not drawn
- fillConstraintWithLifelineEvents(constraint, part, indexConstraint);
- // store constraint
- ArrayList<InteractionFragment> list = new ArrayList<InteractionFragment>(constraint.values());
- DestructionOccurrenceUtil.reorderDestructionOccurrence(list);
- orderConstraints.add(indexConstraint, list);
- indexConstraint++;
- }
- // construct general orderings constraints. Removed, since Combined Fragments own themselves their operands
- /*
- * for(CombinedFragment combFrag : constrainingCombinedFragments) {
- * List<InteractionFragment> constraint = new ArrayList<InteractionFragment>();
- * //fill constraint : graphical order of InteractionOperands
- * // take model order of InteractionOperands, we ensure it is coherent with graphical order
- * constraint.addAll(combFrag.getOperands());
- * // store constraint
- * orderConstraints.add(indexConstraint, constraint);
- * indexConstraint++;
- * }
- */
- // construct messages constraints
- for(Message mess : constrainingMessages) {
- List<InteractionFragment> constraint = new ArrayList<InteractionFragment>(2);
- //fill constraint : send > receive
- MessageEnd frag = mess.getSendEvent();
- if(frag instanceof InteractionFragment && orderedFragments.contains(frag)) {
- constraint.add((InteractionFragment)frag);
- }
- frag = mess.getReceiveEvent();
- if(frag instanceof InteractionFragment && orderedFragments.contains(frag)) {
- constraint.add((InteractionFragment)frag);
- }
-
- DestructionOccurrenceUtil.constraintDestructionOccurrence(mess, constraint);
- // store constraint
- orderConstraints.add(indexConstraint, constraint);
- indexConstraint++;
- }
- // construct executions constraints
- for(ExecutionSpecification exe : constrainingExecutions) {
- List<InteractionFragment> constraint = new ArrayList<InteractionFragment>(3);
- //fill constraint : start > execution > finish
- InteractionFragment frag = exe.getStart();
- if(frag != null && orderedFragments.contains(frag)) {
- constraint.add(frag);
- }
- frag = exe;
- if(orderedFragments.contains(frag)) {
- constraint.add(frag);
- }
- frag = exe.getFinish();
- if(frag != null && orderedFragments.contains(frag)) {
- constraint.add(frag);
- }
- // store constraint
- orderConstraints.add(indexConstraint, constraint);
- indexConstraint++;
- }
- // construct general orderings constraints
- for(GeneralOrdering genOrd : constrainingGeneralOrderings) {
- List<InteractionFragment> constraint = new ArrayList<InteractionFragment>(2);
- //fill constraint : before > after
- InteractionFragment frag = genOrd.getBefore();
- if(frag != null && orderedFragments.contains(frag)) {
- constraint.add(frag);
- }
- frag = genOrd.getAfter();
- if(frag != null && orderedFragments.contains(frag)) {
- constraint.add(frag);
- }
- // store constraint
- orderConstraints.add(indexConstraint, constraint);
- indexConstraint++;
- }
- }
-
- /**
- * Fill the constraint imposed by a lifeline
- *
- * @param constraint
- * the tree map for hosting the constraint
- * @param lifelinePart
- * the lifeline edit part
- * @param indexConstraint
- * index of constraint
- */
- private void fillConstraintWithLifelineEvents(TreeMap<Float, InteractionFragment> constraint, LifelineEditPart lifelinePart, int indexConstraint) {
- EObject lifeline = lifelinePart.resolveSemanticElement();
- if(lifeline instanceof Lifeline) {
- List<InteractionFragment> nonLocalizedEvents = new ArrayList<InteractionFragment>();
- // sort fragments according to their location on the lifeline
- for(InteractionFragment event : ((Lifeline)lifeline).getCoveredBys()) {
- if(orderedFragments.contains(event)) {
- Point loc = SequenceUtil.findLocationOfEvent(lifelinePart, event);
- if(loc != null) {
- float index = findNonConflictingYIndexOnLifeline(loc.y, constraint, event);
- constraint.put(index, event);
- } else {
- nonLocalizedEvents.add(event);
- }
- }
- // else, it is not in the list, must be in a child element.
- }
- optionallyOrderedFragments.put(indexConstraint, nonLocalizedEvents);
- // add not drawn events according to their old order in the valid trace
- InteractionFragment lastMetSortedFragment = null;
- for(InteractionFragment fragment : orderedFragments) {
- if(((Lifeline)lifeline).getCoveredBys().contains(fragment)) {
- // this is a fragment of the lifeline.
- if(constraint.containsValue(fragment)) {
- lastMetSortedFragment = fragment;
- } else if(nonLocalizedEvents.contains(fragment) && lastMetSortedFragment == null) {
- // insert it at the very beginning
- constraint.put((float)0, fragment);
- lastMetSortedFragment = fragment;
- } else if(nonLocalizedEvents.contains(fragment)) {
- // insert it just after lastMetSortedFragment
- Iterator<Entry<Float, InteractionFragment>> entryIt = constraint.entrySet().iterator();
- // find float key of lastMetSortedFragment
- while(entryIt.hasNext()) {
- Entry<Float, InteractionFragment> entry = entryIt.next();
- if(entry.getValue().equals(lastMetSortedFragment)) {
- if(entryIt.hasNext()) {
- // insert between the two fragments
- float key = (entry.getKey() + entryIt.next().getKey()) / 2;
- constraint.put(key, fragment);
- lastMetSortedFragment = fragment;
- break;
- } else {
- // insert at the end
- float key = entry.getKey() + 1;
- constraint.put(key, fragment);
- lastMetSortedFragment = fragment;
- break;
- }
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * Find a float index corresponding approximatively to the location of event on the lifeline.
- *
- * @param y
- * real location of event on the lifeline
- * @param eventsMap
- * map containing other events of the lifeline
- * @param event
- * event to find a float index for
- * @return unused float index for the map
- */
- private float findNonConflictingYIndexOnLifeline(int y, TreeMap<Float, InteractionFragment> eventsMap, InteractionFragment event) {
- float index = Integer.valueOf(y).floatValue();
- float delta = HALF_UNIT;
- while(eventsMap.containsKey(index)) {
- InteractionFragment otherEvent = eventsMap.get(index);
- if(simulatenousEventsHappenInThisOrder(otherEvent, event)) {
- // other event must happen before the event
- index += delta;
- } else {
- // event must happen before the other event
- index -= delta;
- }
- delta = delta * HALF_UNIT;
- }
- return index;
- }
-
- /**
- * Gives the order between two fragments which virtually happen at the same time
- *
- * @param firstFragment
- * first InteractionFragment
- * @param secondFragment
- * second InteractionFragment
- * @return true if firstEvent should happen before secondEvent, false if the contrary.
- */
- private boolean simulatenousEventsHappenInThisOrder(InteractionFragment firstFragment, InteractionFragment secondFragment) {
- // DestructionEvent comes last
- if(firstFragment instanceof DestructionOccurrenceSpecification) {
- return false;
- } else if(secondFragment instanceof DestructionOccurrenceSpecification) {
- return true;
- }
- // a receiving message event should trigger any other event
- if(firstFragment instanceof MessageOccurrenceSpecification && EcoreUtil.equals(((MessageOccurrenceSpecification)firstFragment).getMessage().getReceiveEvent(), firstFragment)) {
- return true;
- }
- if(secondFragment instanceof MessageOccurrenceSpecification && EcoreUtil.equals(((MessageOccurrenceSpecification)secondFragment).getMessage().getReceiveEvent(), secondFragment)) {
- return false;
- }
- // a starting execution event should happen before subsequent execution's events (except creation message receive)
- if(firstFragment instanceof ExecutionOccurrenceSpecification && EcoreUtil.equals(((ExecutionOccurrenceSpecification)firstFragment).getExecution().getStart(), firstFragment)) {
- return true;
- }
- if(secondFragment instanceof ExecutionOccurrenceSpecification && EcoreUtil.equals(((ExecutionOccurrenceSpecification)secondFragment).getExecution().getStart(), secondFragment)) {
- return false;
- }
- // an execution event should happen before subsequent execution's events (except starting)
- if(firstFragment instanceof ExecutionSpecification) {
- return true;
- }
- if(secondFragment instanceof ExecutionSpecification) {
- return false;
- }
- // a finishing execution event should happen after terminated execution's events
- if(firstFragment instanceof ExecutionOccurrenceSpecification && EcoreUtil.equals(((ExecutionOccurrenceSpecification)firstFragment).getExecution().getFinish(), firstFragment)) {
- return false;
- }
- if(secondFragment instanceof ExecutionOccurrenceSpecification && EcoreUtil.equals(((ExecutionOccurrenceSpecification)secondFragment).getExecution().getFinish(), secondFragment)) {
- return true;
- }
- // a sending message event should happen preferably after an unspecified event
- if(firstFragment instanceof MessageOccurrenceSpecification && EcoreUtil.equals(((MessageOccurrenceSpecification)firstFragment).getMessage().getSendEvent(), firstFragment)) {
- return false;
- }
- if(secondFragment instanceof MessageOccurrenceSpecification && EcoreUtil.equals(((MessageOccurrenceSpecification)secondFragment).getMessage().getSendEvent(), secondFragment)) {
- return true;
- }
- // otherwise, no importance
- return true;
- }
-
- /**
- * Reorder the fragments according to constraints to make a valid trace.
- *
- * NOTE : this algorithm could easily be adapted to compute all valid traces.
- *
- * @return true if a valid trace has been computed, false if there is no valid trace
- */
- private boolean reorderFragmentsInAValidTrace() {
- List<InteractionFragment> initialFragmentsList = new ArrayList<InteractionFragment>(orderedFragments);
- List<InteractionFragment> reorderedFragments = new ArrayList<InteractionFragment>(orderedFragments.size());
- /*
- * This algorithm merges constraints to compute a valid trace.
- * With little adaptation, it could compute all valid traces.
- */
- // n : number of constraint lists
- int n = orderConstraints.size();
- // whether computed trace is valid (also whether a valid trace exists)
- boolean valid = true;
- // pointers to first elements to handle in each constraint list
- int[] pointers = new int[n];
- Arrays.fill(pointers, 0);
- while(getFragmentToInspect(-1, pointers) != null) {
- // inspect each constraint list to know whether fragment is mature enough, in such a case, store it with constraint index
- Map<Integer, InteractionFragment> matureFragments = new HashMap<Integer, InteractionFragment>(n);
- for(int i = 0; i < n; i++) {
-
- InteractionFragment fragmentToInspect = getFragmentToInspect(i, pointers);
- // if no more fragment in this constraint (fragmentToInspect == null), nothing to do
- if(fragmentToInspect != null) {
- /*
- * Check whether fragment is mature enough :
- * Fragment can happen only if other constraints do not impose it to happen after their current fragment.
- */
- boolean wait = false;
- for(int j = 0; j < n; j++) {
- if(i != j) {
- // check that current fragment of constraint j must not occur before
- if(pointers[j] < orderConstraints.get(j).size()) {
- List<InteractionFragment> waitingList = orderConstraints.get(j).subList(pointers[j] + 1, orderConstraints.get(j).size());
- if(waitingList.contains(fragmentToInspect)) {
- wait = true;
- break;
- }
- }
- }
- }
- if(!wait) {
- //Fragment is ready to happen.
- matureFragments.put(i, fragmentToInspect);
- }
- }
- }
- if(matureFragments.isEmpty()) {
- //FIXME duplicated code : try again, without optional order
- // inspect each constraint list to know whether fragment is mature enough, in such a case, store it with constraint index
- matureFragments = new HashMap<Integer, InteractionFragment>(n);
- for(int i = 0; i < n; i++) {
-
- InteractionFragment fragmentToInspect = getFragmentToInspect(i, pointers);
- // if no more fragment in this constraint (fragmentToInspect == null), nothing to do
- if(fragmentToInspect != null) {
- /*
- * Check whether fragment is mature enough :
- * Fragment can happen only if other constraints do not impose it to happen after their current fragment.
- */
- boolean wait = false;
- for(int j = 0; j < n; j++) {
- if(i != j) {
- // check that current fragment of constraint j must not occur before
- if(pointers[j] < orderConstraints.get(j).size()) {
- // only difference : ignore order for fragments in optionallyOrderedFragments
- int updatedPointer = pointers[j];
- if(optionallyOrderedFragments.containsKey(j)) {
- List<InteractionFragment> ignore = optionallyOrderedFragments.get(j);
- /*
- * // hack for coregion
- * while(ignore.contains(orderConstraints.get(j).get(updatedPointer)) ||
- * (orderConstraints.get(j).get(updatedPointer) instanceof CombinedFragment &&
- * InteractionOperatorKind.PAR_LITERAL
- * .equals(((CombinedFragment)orderConstraints.get(j).get(updatedPointer)).getInteractionOperator()))) {
- * updatedPointer++;
- * }
- */
- while(ignore.contains(orderConstraints.get(j).get(updatedPointer))) {
- updatedPointer++;
- }
- }
- List<InteractionFragment> waitingList = orderConstraints.get(j).subList(updatedPointer + 1, orderConstraints.get(j).size());
-
- if(waitingList.contains(fragmentToInspect)) {
- wait = true;
- break;
- }
- }
- }
- }
- if(!wait) {
- //Fragment is ready to happen.
- matureFragments.put(i, fragmentToInspect);
- }
- }
- }
- if(matureFragments.isEmpty()) {
- // no valid trace.
- if(valid) {
- // store first conflicting fragments for user explanation
- conflictingFragments = new HashSet<InteractionFragment>(n);
- for(int k = 0; k < n; k++) {
- InteractionFragment frag = getFragmentToInspect(k, pointers);
- if(frag != null) {
- conflictingFragments.add(frag);
- }
- }
- }
- valid = false;
- /*
- * We must at least keep order of constraints with higher priority.
- * Take the next event in the first available constraint.
- */
- InteractionFragment addedFragment = getFragmentToInspect(-1, pointers);
- reorderedFragments.add(addedFragment);
- // increment pointers of constraints whose fragment has been added.
- for(int k = 0; k < n; k++) {
- InteractionFragment frag = getFragmentToInspect(k, pointers);
- while(reorderedFragments.contains(frag)) {
- // either frag == addedFragment and has just been added, or it has been added earlier after a conflict
- pointers[k]++;
- frag = getFragmentToInspect(k, pointers);
- }
- }
- } else {
- /*
- * NOTE : to compute every traces, fork here by making fragmentsSet.size() branches, adding only one mature fragment for each
- * branch and continuing the algorithm.
- */
- // All matureFragments can happen in any order. Add them all (without doubles).
- Set<InteractionFragment> fragmentsSet = new HashSet<InteractionFragment>(matureFragments.values());
- reorderedFragments.addAll(fragmentsSet);
- // increment pointers of constraints whose fragment has been added.
- for(int incrementingPointerIndex : matureFragments.keySet()) {
- InteractionFragment frag = getFragmentToInspect(incrementingPointerIndex, pointers);
- while(reorderedFragments.contains(frag)) {
- // either frag == addedFragment and has just been added, or it has been added earlier after a conflict
- pointers[incrementingPointerIndex]++;
- frag = getFragmentToInspect(incrementingPointerIndex, pointers);
- }
- }
- }
-
- // // no valid trace.
- // if(valid) {
- // // store first conflicting fragments for user explanation
- // conflictingFragments = new HashSet<InteractionFragment>(n);
- // for(int k = 0; k < n; k++) {
- // InteractionFragment frag = getFragmentToInspect(k, pointers);
- // if(frag != null) {
- // conflictingFragments.add(frag);
- // }
- // }
- // }
- // valid = false;
- // /*
- // * We must at least keep order of constraints with higher priority.
- // * Take the next event in the first available constraint.
- // */
- // InteractionFragment addedFragment = getFragmentToInspect(-1, pointers);
- // reorderedFragments.add(addedFragment);
- // // increment pointers of constraints whose fragment has been added.
- // for(int k = 0; k < n; k++) {
- // InteractionFragment frag = getFragmentToInspect(k, pointers);
- // while(reorderedFragments.contains(frag)) {
- // // either frag == addedFragment and has just been added, or it has been added earlier after a conflict
- // pointers[k]++;
- // frag = getFragmentToInspect(k, pointers);
- // }
- // }
- } else {
- /*
- * NOTE : to compute every traces, fork here by making fragmentsSet.size() branches, adding only one mature fragment for each
- * branch and continuing the algorithm.
- */
- // All matureFragments can happen in any order. Add them all (without doubles).
- Set<InteractionFragment> fragmentsSet = new HashSet<InteractionFragment>(matureFragments.values());
- reorderedFragments.addAll(fragmentsSet);
- // increment pointers of constraints whose fragment has been added.
- for(int incrementingPointerIndex : matureFragments.keySet()) {
- InteractionFragment frag = getFragmentToInspect(incrementingPointerIndex, pointers);
- while(reorderedFragments.contains(frag)) {
- // either frag == addedFragment and has just been added, or it has been added earlier after a conflict
- pointers[incrementingPointerIndex]++;
- frag = getFragmentToInspect(incrementingPointerIndex, pointers);
- }
- }
- }
- }
- // Add fragments which were not in any constraint
- /*
- * NOTE : to compute every traces, these can be added wherever in the list.
- */
- initialFragmentsList.removeAll(reorderedFragments);
- reorderedFragments.addAll(initialFragmentsList);
-
- DestructionOccurrenceUtil.reorderDestructionOccurrence(reorderedFragments);
-
- /*
- * Now that we have a valid trace, apply it on orderedFragments.
- * Only move operations must be performed on the EList, since others strongly affect the model.
- */
- int size = reorderedFragments.size();
- for(int i = 0; i < size; i++) {
- orderedFragments.move(i, reorderedFragments.get(i));
- }
- return valid;
- }
-
- /**
- * Get the fragment to inspect for the trace computing algorithm.
- *
- * @param i
- * index of constraint to take in account, or -1 for taking the first available one with the highest priority
- * @param pointers
- * pointers indicating fragments to inspect in each constraint
- * @return fragment which must be inspected or null if none left
- */
- private InteractionFragment getFragmentToInspect(int i, int[] pointers) {
- if(orderConstraints.size() != pointers.length) {
- // should not happen, incorrect pointers argument
- return null;
- }
- if(i < 0 || i >= orderConstraints.size()) {
- i = -1;
- // compute best i with highest priority
- int j = 0;
- while(j < orderConstraints.size() && i == -1) {
- if(pointers[j] < orderConstraints.get(j).size()) {
- // elements left in constraint j. Best constraint index found.
- i = j;
- }
- j++;
- }
- }
- if(0 <= i && i < orderConstraints.size() && pointers[i] < orderConstraints.get(i).size()) {
- // return next fragment in constraint
- return orderConstraints.get(i).get(pointers[i]);
- } else {
- // no fragment left to inspect
- return null;
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/UMLValidationHelper.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/UMLValidationHelper.java
deleted file mode 100644
index d70a88a4bfd..00000000000
--- a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/validation/UMLValidationHelper.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.papyrus.uml.diagram.sequence.validation;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.validation.IValidationContext;
-import org.eclipse.gmf.runtime.notation.Bounds;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.sequence.part.Messages;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.uml2.uml.Interaction;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.InteractionOperand;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-
-/**
- * This helper performs non generated validation tasks.
- *
- * @author vhemery
- */
-public class UMLValidationHelper {
-
- /**
- * Validate modification and update the interaction operand's or interaction's fragments order if necessary.
- *
- * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
- *
- * @param context
- * object on which update is performed
- * @param ctx
- * validation context
- * @return status
- */
- public static IStatus validateFragmentsOrder(EObject context, IValidationContext ctx) {
- if(context instanceof View) {
- return validateFragmentsOrder(((View)context).getElement(), ctx);
- } else if(context instanceof Bounds) {
- return validateFragmentsOrder(((Bounds)context).eContainer(), ctx);
- } else if(context instanceof Interaction) {
- return validateFragmentsOrder((Interaction)context, ctx);
- } else if(context instanceof InteractionOperand) {
- return validateFragmentsOrder((InteractionOperand)context, ctx);
- } else if(context instanceof InteractionFragment) {
- return validateFragmentsOrder(((InteractionFragment)context).getOwner(), ctx);
- } else if(context instanceof Message) {
- // both events are in the same container, but they may not exist
- EObject sendFragmentContainer = ((Message)context).getSendEvent().eContainer();
- EObject receiveFragmentContainer = ((Message)context).getReceiveEvent().eContainer();
- if(sendFragmentContainer != null) {
- return validateFragmentsOrder(sendFragmentContainer, ctx);
- } else if(receiveFragmentContainer != null) {
- return validateFragmentsOrder(receiveFragmentContainer, ctx);
- }
- } else if(context instanceof Lifeline) {
- // events may have changed of container while lifeline was moving
- return validateFragmentsOrder(((Lifeline)context).getInteraction(), ctx);
- }
- // no implementation for this element
- return ctx.createSuccessStatus();
- }
-
- /**
- * Validate modification and update the interaction's fragments order if necessary.
- *
- * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
- *
- * @param context
- * element on which update is performed
- * @param ctx
- * validation context
- * @return status
- */
- public static IStatus validateFragmentsOrder(Interaction context, IValidationContext ctx) {
- try {
- FragmentOrderingKeeper keeper = new FragmentOrderingKeeper();
- return keeper.validate(context, ctx);
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError(Messages.FragmentOrderingKeeper_error, e);
- // avoid returning the exception, or the constraint will never be called again.
- return ctx.createSuccessStatus();
- }
- }
-
- /**
- * Validate modification and update the interaction operand's fragments order if necessary.
- *
- * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
- *
- * @param context
- * element on which update is performed
- * @param ctx
- * validation context
- * @return status
- */
- public static IStatus validateFragmentsOrder(InteractionOperand context, IValidationContext ctx) {
- try {
- FragmentOrderingKeeper keeper = new FragmentOrderingKeeper();
- return keeper.validate(context, ctx);
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError(Messages.FragmentOrderingKeeper_error, e);
- // avoid returning the exception, or the constraint will never be called again.
- return ctx.createSuccessStatus();
- }
- }
-
-}

Back to the top