Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java (renamed from plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java)31
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java4
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java150
4 files changed, 66 insertions, 125 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java
index 9e69b4bfded..89de0b2ef90 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java
@@ -26,15 +26,17 @@ 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.Message;
import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* <p>
- * Abstract advice for Durations ({@link DurationConstraint} or {@link DurationObservation})
+ * Abstract advice for links connecting {@link OccurrenceSpecification}
+ * ({@link DurationConstraint}, {@link DurationObservation}, {@link GeneralOrdering})
* </p>
*/
-public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelperAdvice {
+public abstract class AbstractOccurrenceLinkEditHelperAdvice extends AbstractEditHelperAdvice {
/**
* <p>
@@ -44,7 +46,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <p>
* The source element may correspond to the element on which the relationship is created,
- * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -68,7 +70,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <p>
* The target element may correspond to the element on which the relationship is created,
- * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -91,7 +93,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <p>
* The source element may correspond to the element on which the relationship is created,
- * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -111,7 +113,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <p>
* The target element may correspond to the element on which the relationship is created,
- * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -126,27 +128,27 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
/**
* <p>
- * For Duration Links, the {@link CreateRelationshipRequest} will typically contain two distinct parameters
+ * For Links connecting {@link OccurrenceSpecification}s, the {@link CreateRelationshipRequest} will typically contain two distinct parameters
* for their source, and two for their target. The first one will represent the source/target visual element,
* and the second will represent the real event ({@link OccurrenceSpecification}); typically the start/finish
* {@link OccurrenceSpecification} of the graphical element.
* </p>
* <p>
* This method will take these two values (Which may or may not be valid {@link Element} or {@link OccurrenceSpecification},
- * thus the {@link Object} type), and will return the one that should be used as the source/target of the new Duration Link
+ * thus the {@link Object} type), and will return the one that should be used as the source/target of the new Link
* </p>
*
* @param rawElement
* The element that is the source or target of a {@link CreateRelationshipRequest}. (Typically the UML Element
* represented in a Diagram, i.e. an {@link ExecutionSpecification} or a {@link Message}. It may also be
- * an {@link OccurrenceSpecification}, e.g. if the Duration Link is created directly from the Model Explorer).
+ * an {@link OccurrenceSpecification}, e.g. if the Link is created directly from the Model Explorer).
* @param occurrenceParam
* The specific {@link OccurrenceSpecification} referenced by the {@link CreateRelationshipRequest}. Typical values
* may be <code>null</code> (The request doesn't specify which event should be used), an {@link OccurrenceSpecification}
* referenced by the <code>rawElement</code> (Start/Finish occurrence, or Send/Receive event), or the same object as
* <code>rawElement</code>.
* @return
- * The source or target semantic element for a DurationLink (Which may be different from
+ * The source or target semantic element for a Link (Which may be different from
* the graphical element, since {@link OccurrenceSpecification} are not displayed on diagrams)
*
* @see CreateRelationshipRequest#getSource()
@@ -206,13 +208,12 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
return UnexecutableCommand.INSTANCE;
}
if (source != null && target != null) {
- // Always create DurationConstraints in the Interaction
Object editContext = request.getEditContext();
if (editContext instanceof Element) {
- Element durationCreationContainer = getDurationCreationContainer((Element) editContext);
- if (durationCreationContainer != null) {
+ Element creationContainer = getCreationContainer((Element) editContext);
+ if (creationContainer != null) {
GetEditContextCommand command = new GetEditContextCommand(request);
- command.setEditContext(durationCreationContainer);
+ command.setEditContext(creationContainer);
return command;
}
}
@@ -225,6 +226,6 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
return sourceOrTarget instanceof OccurrenceSpecification;
}
- protected abstract Element getDurationCreationContainer(Element targetElement);
+ protected abstract Element getCreationContainer(Element targetElement);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java
index ab66612e12f..b952f34faed 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java
@@ -34,7 +34,7 @@ import org.eclipse.uml2.uml.UMLFactory;
* @since 3.0
*
*/
-public class DurationConstraintEditHelperAdvice extends AbstractDurationEditHelperAdvice {
+public class DurationConstraintEditHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice {
/**
@@ -124,13 +124,13 @@ public class DurationConstraintEditHelperAdvice extends AbstractDurationEditHelp
}
/**
- * @see org.eclipse.papyrus.uml.service.types.helper.advice.AbstractDurationEditHelperAdvice#getDurationCreationContainer(org.eclipse.uml2.uml.Element)
+ * @see org.eclipse.papyrus.uml.service.types.helper.advice.AbstractDurationEditHelperAdvice#getCreationContainer(org.eclipse.uml2.uml.Element)
*
* @param targetElement
* @return
*/
@Override
- protected Element getDurationCreationContainer(Element targetElement) {
+ protected Element getCreationContainer(Element targetElement) {
return findInteraction(targetElement);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java
index 03f293c0d1c..1a7c94bba4e 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java
@@ -25,7 +25,7 @@ import org.eclipse.uml2.uml.DurationObservation;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
-public class DurationObservationEditHelperAdvice extends AbstractDurationEditHelperAdvice {
+public class DurationObservationEditHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice {
@Override
protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
@@ -78,7 +78,7 @@ public class DurationObservationEditHelperAdvice extends AbstractDurationEditHel
}
@Override
- protected Element getDurationCreationContainer(Element targetElement) {
+ protected Element getCreationContainer(Element targetElement) {
return targetElement.getNearestPackage();
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
index 361122073a9..6b0ae9211a9 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
@@ -1,15 +1,14 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2018 CEA LIST, EclipseSource and others.
*
- *
* 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
+ * EclipseSource - Bug 537562
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
@@ -18,132 +17,73 @@ package org.eclipse.papyrus.uml.service.types.helper.advice;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
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.UnexecutableCommand;
-import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.GeneralOrdering;
+import org.eclipse.uml2.uml.Interaction;
import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.UMLPackage;
/**
- * This advice add automatically the constrained element (occurrence specification) for a time constraint
* @since 3.0
*/
-public class GeneralOrderingHelperAdvice extends AbstractEditHelperAdvice {
+public class GeneralOrderingHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice {
- /**
- * {@inheritDoc}
- */
@Override
- protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
- return new ConfigureElementCommand(request) {
+ protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
+ ICommand composite = new CompositeCommand("After Configure Command of GeneralOrdering");// $NON-NLS-0$
+ ICommand afterConfigureCommand = super.getAfterConfigureCommand(request);
+ if (null != afterConfigureCommand && afterConfigureCommand.canExecute()) {
+ composite.compose(afterConfigureCommand);
+ }
+
+ EObject toConfigure = request.getElementToConfigure();
+ if (false == toConfigure instanceof GeneralOrdering) {
+ return composite;
+ }
- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ GeneralOrdering generalOrdering = (GeneralOrdering) toConfigure;
+ // Create the command to initialize the Before and After values
+ Element source = getSourceElement(request);
+ Element target = getTargetElement(request);
- final GeneralOrdering generalOrdering = (GeneralOrdering) request.getElementToConfigure();
- {//set Before
- Object paramObject = this.getRequest().getParameter(CreateRelationshipRequest.SOURCE);
- if (paramObject instanceof OccurrenceSpecification) {
- generalOrdering.setBefore((OccurrenceSpecification)paramObject);
- }
- }
- {//set After
+ if (source instanceof OccurrenceSpecification && target instanceof OccurrenceSpecification) {
+ final ICommand initOrderedElements = new AbstractTransactionalCommand(request.getEditingDomain(), "Init GeneralOrdering ordered elements", null) {
- Object paramObject = this.getRequest().getParameter(CreateRelationshipRequest.TARGET);
- if (paramObject instanceof OccurrenceSpecification) {
- generalOrdering.setAfter((OccurrenceSpecification)paramObject);
- }
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ generalOrdering.setBefore((OccurrenceSpecification) source);
+ generalOrdering.setAfter((OccurrenceSpecification) target);
+ return CommandResult.newOKCommandResult();
}
+ };
- return CommandResult.newOKCommandResult(generalOrdering);
- }
- };
+ composite.compose(initOrderedElements);
+ }
+
+ return composite;
}
- /**
- * <pre>
- * {@inheritDoc}
- *
- * Add a command to related association end during re-orient.
- *
- * </pre>
- */
@Override
- protected ICommand getBeforeReorientRelationshipCommand(ReorientRelationshipRequest request) {
-
- ICommand gmfCommand = super.getBeforeReorientRelationshipCommand(request);
- final GeneralOrdering generalOrdering = (GeneralOrdering) request.getRelationship();
-
- SetRequest setTypeRequest = null;
+ protected Element getCreationContainer(Element targetElement) {
+ return findInteraction(targetElement);
+ }
- if (request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) {
- Object paramObject =request.getNewRelationshipEnd();
- System.out.println(paramObject);
- if (paramObject instanceof OccurrenceSpecification) {
- setTypeRequest = new SetRequest((OccurrenceSpecification)paramObject, UMLPackage.eINSTANCE.getGeneralOrdering_Before(), generalOrdering);
- }
- else{
- return UnexecutableCommand.INSTANCE;
+ protected Interaction findInteraction(Element source) {
+ Element element = source;
+ while (element != null) {
+ if (element instanceof Interaction) {
+ return (Interaction) element;
}
+ element = element.getOwner();
}
- else{
- Object paramObject =request.getNewRelationshipEnd();
- if (paramObject instanceof OccurrenceSpecification) {
- setTypeRequest = new SetRequest((OccurrenceSpecification)paramObject, UMLPackage.eINSTANCE.getGeneralOrdering_After(), generalOrdering);
- }
- else{
- return UnexecutableCommand.INSTANCE;
- }
+ return null;
+ }
- if (setTypeRequest != null) {
- // Propagate parameters to the set request
- //setTypeRequest.addParameters(request.getParameters());
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(generalOrdering);
- if (provider != null) {
- ICommand setTypeCommand = provider.getEditCommand(setTypeRequest);
- gmfCommand = CompositeCommand.compose(gmfCommand, setTypeCommand);
- }
- }
- }
- return gmfCommand;
- }
- /**
- * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
- *
- * @param request
- * @return
- */
- @Override
- public boolean approveRequest(IEditCommandRequest request) {
- if (request instanceof GetEditContextRequest){
- GetEditContextRequest contextRequest= (GetEditContextRequest)request;
- IEditCommandRequest editCommandRequest=contextRequest.getEditCommandRequest();
- if(editCommandRequest instanceof CreateRelationshipRequest){
- CreateRelationshipRequest relationshipRequest= (CreateRelationshipRequest)editCommandRequest;
- if (relationshipRequest.getSource() == null && relationshipRequest.getTarget() == null) {
- return false;
- }
- if (relationshipRequest.getSource() != null && false == relationshipRequest.getSource() instanceof OccurrenceSpecification) {
- return false;
- }
- if (relationshipRequest.getTarget() != null && false == relationshipRequest.getTarget() instanceof OccurrenceSpecification) {
- return false;
- }
- }
- }
- return super.approveRequest(request);
- }
}

Back to the top