diff options
Diffstat (limited to 'extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice')
14 files changed, 0 insertions, 1439 deletions
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/BehavioredClassifierEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/BehavioredClassifierEditHelperAdvice.java deleted file mode 100644 index 4c30c5acbca..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/BehavioredClassifierEditHelperAdvice.java +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; -import org.eclipse.papyrus.umlrt.internals.Activator; - -/** - * Edit helper advice to forbid the creation of OperationAsMessages in Any behaviored classifier except the MessageSet kinds - */ -public class BehavioredClassifierEditHelperAdvice extends AbstractEditHelperAdvice { - - /** - * {@inheritDoc} - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - // do not allow to create a children to MessageSets other than operations (Messages) - if (request instanceof CreateElementRequest) { - CreateElementRequest createElementRequest = ((CreateElementRequest) request); - // retrieve element type from this request and check if this is a kind of UMLRT::Message - IElementType type = createElementRequest.getElementType(); - - // type should only be compatible with UMLRT::OperationAsMessages - IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.PROTOCOL_MESSAGE_ID); - // should not be null, otherwise, element type model is not loaded correctly. abort. - if (umlRTMessageType == null) { - Activator.log.debug("RTMessage element type is not accessible"); - return super.approveRequest(request); - } - - // check type is compatible with UMLRT::OperationAsMessages - List<IElementType> types = Arrays.asList(type.getAllSuperTypes()); - // element to create is not a rt message, no need to do something on that part... - if (!types.contains(umlRTMessageType)) { - return super.approveRequest(request); - } - // element to create is a RT message. The behaviored classifier should be a MessageSet... - IElementType messageSetType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); - if (!(messageSetType instanceof ISpecializationType)) { - return super.approveRequest(request); - } else { - if(!((ISpecializationType)messageSetType).getMatcher().matches(createElementRequest.getContainer())) { - return false; - } - } - return super.approveRequest(request); - } - - return super.approveRequest(request); - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/CapsuleEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/CapsuleEditHelperAdvice.java deleted file mode 100644 index bcc1ef0b9bc..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/CapsuleEditHelperAdvice.java +++ /dev/null @@ -1,69 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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: Onder Gurcan <onder.gurcan@cea.fr> - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -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.commands.ConfigureElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; -import org.eclipse.uml2.uml.Class; - - -/** - * The helperadvice class used for UMLRealTime::Protocol. - * - * @author Onder Gurcan <onder.gurcan@cea.fr> - * - */ -public class CapsuleEditHelperAdvice extends AbstractEditHelperAdvice { - - private enum Relation { - CHILD, SIBLING, PARENT; - } - - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) - * - * @param request - * @return - */ - @Override - protected ICommand getBeforeConfigureCommand(ConfigureRequest request) { - final Class capsule = (Class) request.getElementToConfigure(); - final String name = NamedElementUtil.getDefaultNameWithIncrementFromBase("Capsule", capsule.eContainer().eContents()); - - return new ConfigureElementCommand(request) { - private IProgressMonitor progressMonitor; - private IAdaptable info; - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - this.progressMonitor = progressMonitor; - this.info = info; - - capsule.setIsActive(true); - capsule.setName(name); - - return CommandResult.newOKCommandResult(capsule); - } - - }; - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/MessageSetEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/MessageSetEditHelperAdvice.java deleted file mode 100644 index 3d48488cc99..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/MessageSetEditHelperAdvice.java +++ /dev/null @@ -1,128 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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: Onder Gurcan <onder.gurcan@cea.fr> - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -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.MoveRequest; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; -import org.eclipse.papyrus.umlrt.custom.utils.MessageUtils; -import org.eclipse.papyrus.umlrt.internals.Activator; -import org.eclipse.uml2.uml.CallEvent; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Operation; - - -/** - * The helper advice class used for UMLRealTime::MessageSets. - */ -public class MessageSetEditHelperAdvice extends AbstractEditHelperAdvice { - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterEditContextCommand(GetEditContextRequest request) { - return super.getAfterEditContextCommand(request); - } - - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterMoveCommand(final MoveRequest request) { - ICommand result = null; - - CompositeCommand compositeMoveCommand = new CompositeCommand("Composite Move Command"); - - Map<?, ?> elementsToMove = request.getElementsToMove(); - if (!elementsToMove.isEmpty()) { - for (Object elementToMove : elementsToMove.keySet()) { - if (elementToMove instanceof Operation) { - final Operation operation = (Operation) elementToMove; - final CallEvent callEvent = MessageUtils.getCallEvent(operation); - if (callEvent != null) { - MoveElementsCommand command = MessageUtils.createMoveCallEventCommand(request, callEvent); - compositeMoveCommand.add(command); - } - } - } - } - - if (compositeMoveCommand.isEmpty()) { - result = super.getAfterMoveCommand(request); - } else { - result = compositeMoveCommand; - } - - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - - // do not allow to create a children to MessageSets other than operations (Messages) - if (request instanceof CreateElementRequest) { - CreateElementRequest createElementRequest = ((CreateElementRequest) request); - // retrieve element type from this request and check if this is a kind of UMLRT::Message - IElementType type = createElementRequest.getElementType(); - - // type should only be compatible with UMLRT::OperationAsMessages - IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.PROTOCOL_MESSAGE_ID); - // should not be null, otherwise, element type model is not loaded correctly. abort. - if (umlRTMessageType == null) { - Activator.log.debug("RTMessage element type is not accessible"); - return super.approveRequest(request); - } - - // check type is compatible with UMLRT::OperationAsMessages - List<IElementType> types = Arrays.asList(type.getAllSuperTypes()); - if (!types.contains(umlRTMessageType)) { - return false; - } - return super.approveRequest(request); - } - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterCreateCommand(CreateElementRequest request) { - if (request.getElementType().getId().equals(IUMLRTElementTypes.PROTOCOL_MESSAGE_IN_ID)) { - EObject container = request.getContainer(); - Element element = (Element)container; - org.eclipse.uml2.uml.Package pack = element.getNearestPackage(); - CreateElementRequest req = new CreateElementRequest(request.getEditingDomain(), pack, ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.CallEvent")); - } - return super.getAfterCreateCommand(request); - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageEditHelperAdvice.java deleted file mode 100644 index 8a426bd509a..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageEditHelperAdvice.java +++ /dev/null @@ -1,126 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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: Onder Gurcan <onder.gurcan@cea.fr> - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import static org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.CALL_EVENT; - -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.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; -import org.eclipse.uml2.uml.CallEvent; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Operation; -import org.eclipse.uml2.uml.Package; - - -/** - * The helperadvice class used for UMLRealTime::Operation. - * - * @author Onder Gurcan <onder.gurcan@cea.fr> - * - */ -public class OperationAsMessageEditHelperAdvice extends AbstractEditHelperAdvice { - - private CallEvent callEvent; - - private enum Relation { - CHILD, SIBLING, PARENT; - } - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) - * - * @param request - * @return - */ - @Override - protected ICommand getBeforeConfigureCommand(ConfigureRequest request) { - final Operation operation = (Operation) request.getElementToConfigure(); - final String name = NamedElementUtil.getDefaultNameWithIncrementFromBase("CallEvent", operation.eContainer().eContainer().eContents()); - - return new ConfigureElementCommand(request) { - private IProgressMonitor progressMonitor; - private IAdaptable info; - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - this.progressMonitor = progressMonitor; - this.info = info; - - // Create the UML::CallEvent element - createCallEvent(operation, name); - - return CommandResult.newOKCommandResult(operation); - } - - /** - * Creates a UML::Usage relation between protocol and rtMessageSet with given name. - * - * @param protocol - * @param name - * @param rtMessageSet - * @throws ExecutionException - */ - private void createCallEvent(final Operation operation, final String name) throws ExecutionException { - // find the corresponding protocol container - Package protocolContainer = operation.getNearestPackage(); - // then create the call event - callEvent = (CallEvent) createElement(protocolContainer, name, CALL_EVENT, Relation.CHILD); - // finally associate the operation with this call event - callEvent.setOperation(operation); - } - - /** - * - * @param referenceElement - * @param name - * @param elementType - * @param relation - * @return created element as EObject - * @throws ExecutionException - */ - private EObject createElement(Element referenceElement, String name, IElementType elementType, Relation relation) throws ExecutionException { - if ((referenceElement == null) || (name == null)) { - throw new ExecutionException("Either the referenceElement or the name parameter is null. "); - } - - EObject newElement = null; - - CreateElementRequest createElementRequest = new CreateElementRequest(referenceElement.getNearestPackage(), elementType); - CreateElementCommand command = new CreateElementCommand(createElementRequest); - command.execute(progressMonitor, info); - newElement = command.getNewElement(); - - if (newElement == null) { - throw new ExecutionException("Element creation problem for " + elementType.getDisplayName() + "."); - } - - ((NamedElement)newElement).setName(name); - - return newElement; - } - }; - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInEditHelperAdvice.java deleted file mode 100644 index 4f25c453e78..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInEditHelperAdvice.java +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.emf.ecore.EObject; -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.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; -import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; -import org.eclipse.uml2.uml.Interface; - -/** - * Specialization of the Operation as message in message sets, but specific to message sets with kind=IN - */ -public class OperationAsMessageInEditHelperAdvice extends OperationAsMessageEditHelperAdvice { - - /** - * @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 CreateElementRequest) { - // check container. - EObject container = ((CreateElementRequest) request).getContainer(); - if (!(container instanceof Interface)) { - return false; - } - - IElementType messageSetType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); - if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded - if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { - return false; - } - - // this is really a message set. Should go for the kind - if (RTMessageKind.IN == MessageSetUtils.getMessageKind(container)) { - return true; - } - } - - // should not be possible to create except RT interface - return false; - } - - - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeCreateCommand(CreateElementRequest request) { - // check container. - EObject container = request.getContainer(); - if (!(container instanceof Interface)) { - return UnexecutableCommand.INSTANCE; - } - - IElementType messageSetType= ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); - if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded - if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { - return UnexecutableCommand.INSTANCE; - } - - // this is really a message set. Should go for the kind - if (RTMessageKind.IN == MessageSetUtils.getMessageKind(container)) { - return super.getBeforeCreateCommand(request); - } - } - - // should not be possible to create except RT interface - return UnexecutableCommand.INSTANCE; - } - -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInOutEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInOutEditHelperAdvice.java deleted file mode 100644 index 7b3f4ef2a81..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInOutEditHelperAdvice.java +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.emf.ecore.EObject; -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.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; -import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; -import org.eclipse.uml2.uml.Interface; - -/** - * Specialization of the Operation as message in message sets, but specific to message sets with kind=IN - */ -public class OperationAsMessageInOutEditHelperAdvice extends OperationAsMessageEditHelperAdvice { - - /** - * @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 CreateElementRequest) { - // check container. - EObject container = ((CreateElementRequest) request).getContainer(); - if (!(container instanceof Interface)) { - return false; - } - - IElementType messageSetType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); - if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded - if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { - return false; - } - - // this is really a message set. Should go for the kind - if (RTMessageKind.IN_OUT == MessageSetUtils.getMessageKind(container)) { - return true; - } - } - - // should not be possible to create except RT interface - return false; - } - - - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeCreateCommand(CreateElementRequest request) { - // check container. - EObject container = request.getContainer(); - if (!(container instanceof Interface)) { - return UnexecutableCommand.INSTANCE; - } - - IElementType messageSetType= ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); - if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded - if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { - return UnexecutableCommand.INSTANCE; - } - - // this is really a message set. Should go for the kind - if (RTMessageKind.IN_OUT == MessageSetUtils.getMessageKind(container)) { - return super.getBeforeCreateCommand(request); - } - } - - // should not be possible to create except RT interface - return UnexecutableCommand.INSTANCE; - } - -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageOutEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageOutEditHelperAdvice.java deleted file mode 100644 index 0056b5ab707..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageOutEditHelperAdvice.java +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.emf.ecore.EObject; -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.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; -import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; -import org.eclipse.uml2.uml.Interface; - -/** - * Specialization of the Operation as message in message sets, but specific to message sets with kind=IN - */ -public class OperationAsMessageOutEditHelperAdvice extends OperationAsMessageEditHelperAdvice { - - /** - * @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 CreateElementRequest) { - // check container. - EObject container = ((CreateElementRequest) request).getContainer(); - if (!(container instanceof Interface)) { - return false; - } - - IElementType messageSetType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); - if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded - if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { - return false; - } - - // this is really a message set. Should go for the kind - if (RTMessageKind.OUT == MessageSetUtils.getMessageKind(container)) { - return true; - } - } - - // should not be possible to create except RT interface - return false; - } - - - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeCreateCommand(CreateElementRequest request) { - // check container. - EObject container = request.getContainer(); - if (!(container instanceof Interface)) { - return UnexecutableCommand.INSTANCE; - } - - IElementType messageSetType= ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); - if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded - if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { - return UnexecutableCommand.INSTANCE; - } - - // this is really a message set. Should go for the kind - if (RTMessageKind.OUT == MessageSetUtils.getMessageKind(container)) { - return super.getBeforeCreateCommand(request); - } - } - - // should not be possible to create except RT interface - return UnexecutableCommand.INSTANCE; - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationEditHelperAdvice.java deleted file mode 100644 index af440e958e4..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationEditHelperAdvice.java +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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: Onder Gurcan <onder.gurcan@cea.fr> - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -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.commands.ConfigureElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.papyrus.umlrt.custom.utils.CapsuleUtils; -import org.eclipse.uml2.uml.CallConcurrencyKind; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.Operation; - - -/** - * The helperadvice class used for UMLRealTime::Operation. - * - * @author Onder Gurcan <onder.gurcan@cea.fr> - * - */ -public class OperationEditHelperAdvice extends AbstractEditHelperAdvice { - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) - * - * @param request - * @return - */ - @Override - protected ICommand getBeforeConfigureCommand(ConfigureRequest request) { - final Operation operation = (Operation) request.getElementToConfigure(); - - if (matches(operation)) { - return new ConfigureElementCommand(request) { - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - // All operations of a capsule are guarded. - operation.setConcurrency(CallConcurrencyKind.GUARDED_LITERAL); - return CommandResult.newOKCommandResult(operation); - } - - }; - } else { - return null; - } - } - - /** - * The owner of the operation should be a capsule. - * @param operation - * @return - */ - public boolean matches(Operation operation) { - return CapsuleUtils.isCapsule((Classifier) operation.getOwner()); - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolContainerEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolContainerEditHelperAdvice.java deleted file mode 100644 index f6fa07ce85c..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolContainerEditHelperAdvice.java +++ /dev/null @@ -1,162 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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: CEA LIST - * - *****************************************************************************/ -package org.eclipse.papyrus.umlrt.custom.advice; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.commands.GetEditContextCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -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.SetRequest; -import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; -import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; -import org.eclipse.papyrus.umlrt.custom.utils.ProtocolContainerUtils; -import org.eclipse.papyrus.umlrt.internals.Activator; -import org.eclipse.uml2.uml.Collaboration; -import org.eclipse.uml2.uml.Interface; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * The helper advice class used for UMLRealTime::ProtocolContainer. - */ -public class ProtocolContainerEditHelperAdvice extends AbstractEditHelperAdvice { - - /** - * {@inheritDoc} - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - if (request instanceof CreateElementRequest) { - CreateElementRequest createElementRequest = ((CreateElementRequest) request); - // retrieve element type from this request and check if this is a kind of UMLRT::Message - IElementType type = createElementRequest.getElementType(); - - // type should only be compatible with UMLRT::OperationAsMessages - IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.PROTOCOL_MESSAGE_ID); - // should not be null, otherwise, element type model is not loaded correctly. abort. - if (umlRTMessageType == null) { - Activator.log.debug("RTMessage element type is not accessible"); - return super.approveRequest(request); - } - - // check type is compatible with UMLRT::OperationAsMessages. If yes, allow creation - List<IElementType> types = Arrays.asList(type.getAllSuperTypes()); - if (types.contains(umlRTMessageType)) { - return true; - } else { - // return false; - return super.approveRequest(createElementRequest); - } - } - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeEditContextCommand(GetEditContextRequest request) { - IEditCommandRequest editCommandRequest = request.getEditCommandRequest(); - if(editCommandRequest instanceof CreateElementRequest) { - // check the element to create is a sub kind of RTMessage - CreateElementRequest createElementRequest = ((CreateElementRequest) editCommandRequest); - // retrieve element type from this request and check if this is a kind of UMLRT::Message - IElementType type = createElementRequest.getElementType(); - - // type should only be compatible with UMLRT::OperationAsMessages - IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.PROTOCOL_MESSAGE_ID); - // should not be null, otherwise, element type model is not loaded correctly. abort. - if (umlRTMessageType == null) { - Activator.log.debug("RTMessage element type is not accessible"); - return super.getBeforeEditContextCommand(request); - } - - // check type is compatible with UMLRT::OperationAsMessages. If yes, allow creation - List<IElementType> types = Arrays.asList(type.getAllSuperTypes()); - if (types.contains(umlRTMessageType)) { - // return the right message set here rather than the protocol container - - GetEditContextCommand command = new GetEditContextCommand(request); - if (request.getEditContext() instanceof Package) { - command.setEditContext(ProtocolContainerUtils.getMessageSetIn((Package) request.getEditContext())); - } - return command; - } - - } - - return super.getBeforeEditContextCommand(request); - } - - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterSetCommand(SetRequest request) { - // for change name request, changes the name of the protocol and its interfaces - if (UMLPackage.eINSTANCE.getNamedElement_Name().equals(request.getFeature())) { - - final EObject elementToEdit = request.getElementToEdit(); - if (!(elementToEdit instanceof Package)) { - return super.getBeforeSetCommand(request); - } - - final String newName = (request.getValue() != null) ? request.getValue().toString() : "Protocol"; - - final Package protocolContainer = (Package) elementToEdit; - RecordingCommand command = new RecordingCommand(request.getEditingDomain(), "Change Dependents", "Change the names of the dependents of the ProtocolContainer") { - - @Override - protected void doExecute() { - // rename protocol, avoid dependency to avoid circular dependencies towards advices - Interface interfaceIn = ProtocolContainerUtils.getMessageSetIn(protocolContainer); - if (interfaceIn != null) { - interfaceIn.setName(MessageSetUtils.computeInterfaceInName(newName)); - } - - Interface interfaceOut = ProtocolContainerUtils.getMessageSetOut(protocolContainer); - if (interfaceOut != null) { - interfaceOut.setName(MessageSetUtils.computeInterfaceOutName(newName)); - } - - Interface interfaceInOut = ProtocolContainerUtils.getMessageSetInOut(protocolContainer); - if (interfaceInOut != null) { - interfaceInOut.setName(MessageSetUtils.computeInterfaceInOutName(newName)); - } - - Collaboration collaboration = ProtocolContainerUtils.getCollaboration(protocolContainer); - if (collaboration != null) { - collaboration.setName(newName); - } - } - }; - // check the super in case of more commands - ICommand superCommand = super.getAfterSetCommand(request); - if (superCommand != null) { - return superCommand.compose(new EMFtoGMFCommandWrapper(command)); - } - return new EMFtoGMFCommandWrapper(command); - } - return super.getAfterSetCommand(request); - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolEditHelperAdvice.java deleted file mode 100644 index ccda68535dd..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolEditHelperAdvice.java +++ /dev/null @@ -1,389 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 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: Onder Gurcan <onder.gurcan@cea.fr> - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import static org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.ANY_RECEIVE_EVENT; -import static org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.INTERFACE_REALIZATION; -import static org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.USAGE; -import static org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator.PROTOCOL_CONTAINER; -import static org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator.RT_MESSAGE_SET; - -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.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -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.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.commands.GetEditContextCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -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.emf.type.core.requests.DestroyElementRequest; -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.SetRequest; -import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper; -import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageSet; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; -import org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator; -import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; -import org.eclipse.papyrus.umlrt.custom.utils.ProtocolContainerUtils; -import org.eclipse.papyrus.umlrt.custom.utils.ProtocolUtils; -import org.eclipse.papyrus.umlrt.internals.Activator; -import org.eclipse.uml2.uml.Collaboration; -import org.eclipse.uml2.uml.Interface; -import org.eclipse.uml2.uml.InterfaceRealization; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.PackageableElement; -import org.eclipse.uml2.uml.Type; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.Usage; -import org.eclipse.uml2.uml.util.UMLUtil; - - -/** - * The helperadvice class used for UMLRealTime::Protocol. - * - * @author Onder Gurcan <onder.gurcan@cea.fr> - * - */ -public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { - - private enum Relation { - CHILD, SIBLING, PARENT; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - if (request instanceof CreateElementRequest) { - CreateElementRequest createElementRequest = ((CreateElementRequest) request); - // retrieve element type from this request and check if this is a kind of UMLRT::Message - IElementType type = createElementRequest.getElementType(); - - // type should only be compatible with UMLRT::OperationAsMessages - IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.PROTOCOL_MESSAGE_ID); - // should not be null, otherwise, element type model is not loaded correctly. abort. - if (umlRTMessageType == null) { - Activator.log.debug("RTMessage element type is not accessible"); - return super.approveRequest(request); - } - - // check type is compatible with UMLRT::OperationAsMessages. If yes, allow creation - List<IElementType> types = new ArrayList<IElementType>(Arrays.asList(type.getAllSuperTypes())); - types.add(type); - if (types.contains(umlRTMessageType)) { - return true; - } else { - if (types.contains(ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Generalization"))) { - return true; - } else { - return false; - } - - // return super.approveRequest(createElementRequest); - } - } - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeEditContextCommand(GetEditContextRequest request) { - IEditCommandRequest editCommandRequest = request.getEditCommandRequest(); - if (editCommandRequest instanceof CreateElementRequest) { - // check the element to create is a sub kind of RTMessage - CreateElementRequest createElementRequest = ((CreateElementRequest) editCommandRequest); - // retrieve element type from this request and check if this is a kind of UMLRT::Message - IElementType type = createElementRequest.getElementType(); - - // type should only be compatible with UMLRT::OperationAsMessages - IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.PROTOCOL_MESSAGE_ID); - // should not be null, otherwise, element type model is not loaded correctly. abort. - if (umlRTMessageType == null || type == null) { - Activator.log.debug("RTMessage element type is not accessible"); - return super.getBeforeEditContextCommand(request); - } - - // check type is compatible with UMLRT::OperationAsMessages. If yes, allow creation - List<IElementType> types = new ArrayList<IElementType>(Arrays.asList(type.getAllSuperTypes())); - types.add(type); - if (types.contains(umlRTMessageType)) { - // return the right message set here rather than the protocol container - - GetEditContextCommand command = new GetEditContextCommand(request); - if (request.getEditContext() instanceof Collaboration) { - // retrieve all needed element types - IElementType rTMessageTypeIn = UMLRTElementTypesEnumerator.PROTOCOL_MESSAGE_IN; - IElementType rTMessageTypeOut = UMLRTElementTypesEnumerator.PROTOCOL_MESSAGE_OUT; - IElementType rTMessageTypeInOut = UMLRTElementTypesEnumerator.PROTOCOL_MESSAGE_INOUT; - if (types.contains(rTMessageTypeIn)) { - command.setEditContext(ProtocolUtils.getMessageSetIn((Collaboration) request.getEditContext())); - } else if (types.contains(rTMessageTypeOut)) { - command.setEditContext(ProtocolUtils.getMessageSetOut((Collaboration) request.getEditContext())); - } else if (types.contains(rTMessageTypeInOut)) { - command.setEditContext(ProtocolUtils.getMessageSetInOut((Collaboration) request.getEditContext())); - } else { - return super.getBeforeEditContextCommand(request); - } - } - return command; - } - - } - - return super.getBeforeEditContextCommand(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterSetCommand(SetRequest request) { - if(UMLPackage.eINSTANCE.getNamedElement_Name().equals(request.getFeature() ) ){ - - final EObject elementToEdit = request.getElementToEdit(); - if (!(elementToEdit instanceof Collaboration)) { - return super.getAfterSetCommand(request); - } - final Collaboration protocol = (Collaboration) elementToEdit; - - final String newName = (request.getValue() != null) ? request.getValue().toString() : "Protocol"; - - RecordingCommand command = new RecordingCommand(request.getEditingDomain(), "Change Dependents", "Change the names of the dependents of the Protocol") { - - @Override - protected void doExecute() { - Package protocolContainer = ProtocolUtils.getProtocolContainer(protocol); - if(protocolContainer ==null) { - return; - } - - protocolContainer.setName(newName); - protocol.setName(newName); - - // rename protocol, avoid dependency to avoid circular dependencies towards advices - Interface interfaceIn = ProtocolContainerUtils.getMessageSetIn(protocolContainer); - if (interfaceIn != null) { - interfaceIn.setName(MessageSetUtils.computeInterfaceInName(newName)); - } - - Interface interfaceOut = ProtocolContainerUtils.getMessageSetOut(protocolContainer); - if (interfaceOut != null) { - interfaceOut.setName(MessageSetUtils.computeInterfaceOutName(newName)); - } - - Interface interfaceInOut = ProtocolContainerUtils.getMessageSetInOut(protocolContainer); - if (interfaceInOut != null) { - interfaceInOut.setName(MessageSetUtils.computeInterfaceInOutName(newName)); - } - - } - }; - // check the super in case of more commands - ICommand superCommand = super.getAfterSetCommand(request); - if (superCommand != null) { - return superCommand.compose(new EMFtoGMFCommandWrapper(command)); - } - return new EMFtoGMFCommandWrapper(command); - } - return super.getAfterSetCommand(request); - } - - - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) - * - * @param request - * @return - */ - @Override - protected ICommand getBeforeConfigureCommand(ConfigureRequest request) { - final Collaboration protocol = (Collaboration) request.getElementToConfigure(); - final String name = NamedElementUtil.getDefaultNameWithIncrementFromBase("Protocol", protocol.eContainer().eContents()); - - return new ConfigureElementCommand(request) { - private IProgressMonitor progressMonitor; - private IAdaptable info; - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - this.progressMonitor = progressMonitor; - this.info = info; - - // Create the UMLRealTime::ProtocolContainer package - createElement(protocol, name, PROTOCOL_CONTAINER, Relation.PARENT); - - // Create the incoming UMLRealTime::RTMessageSet interface - String nameIn = MessageSetUtils.computeInterfaceInName(name); - Interface rtMessageSetInt = (Interface) createElement(protocol, nameIn, RT_MESSAGE_SET, Relation.SIBLING); - setRtMsgKind(rtMessageSetInt, RTMessageKind.IN); - createInterfaceRealization(protocol, nameIn, rtMessageSetInt); - - // Create the outgoing UMLRealTime::RTMessageSet interface - String nameOut = MessageSetUtils.computeInterfaceOutName(name); - Interface rtMessageSetOutInt = (Interface) createElement(protocol, nameOut, RT_MESSAGE_SET, Relation.SIBLING); - setRtMsgKind(rtMessageSetOutInt, RTMessageKind.OUT); - createUsage(protocol, nameOut, rtMessageSetOutInt); - - createElement(protocol, "*", ANY_RECEIVE_EVENT, Relation.SIBLING); //$NON-NLS-1$ - - // Create the in-out UMLRealTime::RTMessageSet interface - String nameInOut = MessageSetUtils.computeInterfaceInOutName(name); - Interface rtMessageSetInOutInt = (Interface) createElement(protocol, nameInOut, RT_MESSAGE_SET, Relation.SIBLING); - setRtMsgKind(rtMessageSetInOutInt, RTMessageKind.IN_OUT); - createInterfaceRealization(protocol, nameInOut, rtMessageSetInOutInt); - createUsage(protocol, nameInOut, rtMessageSetInOutInt); - - protocol.setName(name); - - return CommandResult.newOKCommandResult(protocol); - } - - /** - * Creates a UML::Usage relation between protocol and rtMessageSet with given name. - * - * @param protocol - * @param name - * @param rtMessageSet - * @throws ExecutionException - */ - private void createUsage(final Collaboration protocol, final String name, Interface rtMessageSet) throws ExecutionException { - Usage usageOut = (Usage) createElement(protocol, name, USAGE, Relation.SIBLING); - usageOut.getClients().add(protocol); - usageOut.getSuppliers().add(rtMessageSet); - } - - /** - * Creates an UML::InterfaceRealization relation between protocol and rtMessageSet with given name. - * - * @param protocol - * @param name - * @param rtMessageSet - * @throws ExecutionException - */ - private void createInterfaceRealization(final Collaboration protocol, final String name, Interface rtMessageSetInt) throws ExecutionException { - InterfaceRealization realization = (InterfaceRealization) createElement(protocol, name, INTERFACE_REALIZATION, Relation.CHILD); - realization.setContract(rtMessageSetInt); - realization.setImplementingClassifier(protocol); - } - - /** - * - * @param referenceElement - * @param name - * @param elementType - * @param relation - * @return created element as EObject - * @throws ExecutionException - */ - private EObject createElement(Collaboration referenceElement, String name, IElementType elementType, Relation relation) throws ExecutionException { - if ((referenceElement == null) || (name == null)) { - throw new ExecutionException("Either the referenceElement or the name parameter is null. "); - } - - EObject newElement = null; - - CreateElementRequest createElementRequest = new CreateElementRequest(referenceElement.getNearestPackage(), elementType); - CreateElementCommand command = new CreateElementCommand(createElementRequest); - command.execute(progressMonitor, info); - newElement = command.getNewElement(); - - if (newElement == null) { - throw new ExecutionException("Element creation problem for " + elementType.getDisplayName() + "."); - } - - ((NamedElement)newElement).setName(name); - - if (relation == Relation.CHILD) { // if newElement is an owned element of protocol - if (elementType == INTERFACE_REALIZATION) { - referenceElement.getInterfaceRealizations().add((InterfaceRealization) newElement); - } else { - referenceElement.createOwnedAttribute(name, (Type) newElement); - } - } else if (relation == Relation.SIBLING) { // if newElement is a sibling of protocol - Package nearestPackage = referenceElement.getNearestPackage(); - nearestPackage.getPackagedElements().add((PackageableElement) newElement); - } else if (relation == Relation.PARENT) { // otherwise newElement is a container element of protocol - Package container = (Package) newElement; - EList<PackageableElement> packagedElements = container.getPackagedElements(); - packagedElements.add(referenceElement); - } - - return newElement; - } - - private void setRtMsgKind(Interface rtMessageSetInt, RTMessageKind kind){ - RTMessageSet rtMessageSet = UMLUtil.getStereotypeApplication(rtMessageSetInt, RTMessageSet.class); - rtMessageSet.setRtMsgKind(kind); - } - }; - } - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) - * - * @param request - * @return - */ - @Override - protected ICommand getAfterConfigureCommand(ConfigureRequest request) { - final Collaboration protocol = (Collaboration) request.getElementToConfigure(); - final String name = protocol.getPackage().getName(); - - return new ConfigureElementCommand(request) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - protocol.setName(name); - return CommandResult.newOKCommandResult(); - } - }; - } - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) - * - * @param request - * @return - */ - @Override - protected ICommand getAfterDestroyElementCommand(DestroyElementRequest request) { - PackageableElement protocolToDestroy = (PackageableElement) request.getElementToDestroy(); - Package protocolContainerToDestroy = protocolToDestroy.getNearestPackage(); - - request = new DestroyElementRequest(protocolContainerToDestroy, false); - - return new DestroyElementCommand(request); - } -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInMatcher.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInMatcher.java deleted file mode 100644 index c2d9b4e098a..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInMatcher.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.custom.utils.RTMessageUtils; - -/** - * - */ -public class RTMessageInMatcher implements IElementMatcher { - - /** - * {@inheritDoc} - */ - @Override - public boolean matches(EObject eObject) { - return RTMessageUtils.isRTMessage(eObject, RTMessageKind.IN); - } - -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInOutMatcher.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInOutMatcher.java deleted file mode 100644 index 9cf74560f6f..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInOutMatcher.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.custom.utils.RTMessageUtils; - -/** - * - */ -public class RTMessageInOutMatcher implements IElementMatcher { - - /** - * {@inheritDoc} - */ - @Override - public boolean matches(EObject eObject) { - return RTMessageUtils.isRTMessage(eObject, RTMessageKind.IN_OUT); - } - -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageMatcher.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageMatcher.java deleted file mode 100644 index 1a0b5515ff7..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageMatcher.java +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; -import org.eclipse.papyrus.umlrt.custom.utils.RTMessageUtils; - -/** - * - */ -public class RTMessageMatcher implements IElementMatcher { - - /** - * {@inheritDoc} - */ - @Override - public boolean matches(EObject eObject) { - return RTMessageUtils.isRTMessage(eObject); - } - -} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageOutMatcher.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageOutMatcher.java deleted file mode 100644 index 5e0a5a9188f..00000000000 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageOutMatcher.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.umlrt.custom.advice; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.custom.utils.RTMessageUtils; - -/** - * - */ -public class RTMessageOutMatcher implements IElementMatcher { - - /** - * {@inheritDoc} - */ - @Override - public boolean matches(EObject eObject) { - return RTMessageUtils.isRTMessage(eObject, RTMessageKind.OUT); - } - -} |