diff options
author | Fanch BONNABESSE | 2017-07-07 13:49:05 +0000 |
---|---|---|
committer | Patrick Tessier | 2017-08-28 15:01:32 +0000 |
commit | 2ec48c3981d04d83fecdb92d71c4911dc552c84f (patch) | |
tree | f0f249ae0bd1c0f7c382dff10962085c790a2ccc /plugins/uml/org.eclipse.papyrus.uml.service.types | |
parent | 7e9a5940c0c9132a4bf493f863abbeaed1fcf3f6 (diff) | |
download | org.eclipse.papyrus-2ec48c3981d04d83fecdb92d71c4911dc552c84f.tar.gz org.eclipse.papyrus-2ec48c3981d04d83fecdb92d71c4911dc552c84f.tar.xz org.eclipse.papyrus-2ec48c3981d04d83fecdb92d71c4911dc552c84f.zip |
Bug 515122: [Component Diagram] Contact lost when reroute Realization
https://bugs.eclipse.org/bugs/show_bug.cgi?id=515122
Override "reorientTarget()" and "reorientSource()" to change "Contract"
and "RealizingClassifier".
Change-Id: If9f922cdc3b32b91c6e476e8de2d0c91fea0b7e9
Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.service.types')
3 files changed, 286 insertions, 240 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ComponentRealizationReorientCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ComponentRealizationReorientCommand.java index 6b893473097..9eb9d210465 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ComponentRealizationReorientCommand.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ComponentRealizationReorientCommand.java @@ -1,83 +1,99 @@ -/*****************************************************************************
- * 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:
- *
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.service.types.command;
-
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Component;
-import org.eclipse.uml2.uml.ComponentRealization;
-
-/**
- * <pre>
- * Re-orient command for {@link ComponentRealization} elements.
- * </pre>
- */
-public class ComponentRealizationReorientCommand extends DependencyReorientCommand {
-
- /**
- * <pre>
- * Constructor.
- *
- * @param request the re-orient relationship request.
- * </pre>
- */
- public ComponentRealizationReorientCommand(ReorientRelationshipRequest request) {
- super(request);
- }
-
- /**
- * <pre>
- * @see org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand#canExecute()
- *
- * @return true if the command is executable.
- * </pre>
- */
- public boolean canExecute() {
- if(! (getElementToEdit() instanceof ComponentRealization)) {
- return false;
- }
-
- return super.canExecute();
- }
-
- protected boolean canReorientSource() {
- if(!(newEnd instanceof Classifier)) {
- return false;
- }
-
- if (newEnd == getLink().getAbstraction()) {
- return false;
- }
-
- return true;
- }
-
- protected boolean canReorientTarget() {
- if(!(newEnd instanceof Component)) {
- return false;
- }
-
- if (getLink().getRealizingClassifiers().contains(newEnd)) {
- return false;
- }
-
- return true;
- }
-
- protected ComponentRealization getLink() {
- return (ComponentRealization)getElementToEdit();
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2011, 2017 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 + * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 515122 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.service.types.command; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Component; +import org.eclipse.uml2.uml.ComponentRealization; + +/** + * <pre> + * Re-orient command for {@link ComponentRealization} elements. + * </pre> + */ +public class ComponentRealizationReorientCommand extends DependencyReorientCommand { + + /** + * Constructor. + * + * @param request + * the re-orient relationship request. + */ + public ComponentRealizationReorientCommand(ReorientRelationshipRequest request) { + super(request); + } + + /** + * @see org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand#canExecute() + * + * @return true if the command is executable. + */ + @Override + public boolean canExecute() { + if (!(getElementToEdit() instanceof ComponentRealization)) { + return false; + } + + return super.canExecute(); + } + + @Override + protected boolean canReorientSource() { + if (!(newEnd instanceof Classifier)) { + return false; + } + + if (newEnd == getLink().getAbstraction()) { + return false; + } + + return true; + } + + @Override + protected boolean canReorientTarget() { + if (!(newEnd instanceof Component)) { + return false; + } + + if (getLink().getRealizingClassifiers().contains(newEnd)) { + return false; + } + + return true; + } + + @Override + protected ComponentRealization getLink() { + return (ComponentRealization) getElementToEdit(); + } + + /** + * {@inheritDoc} + */ + @Override + protected CommandResult reorientSource() throws ExecutionException { + getLink().getRealizingClassifiers().remove(getOldSource()); + if (getNewSource() instanceof Classifier) { + getLink().getRealizingClassifiers().add((Classifier) getNewSource()); + } + return super.reorientSource(); + } + +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/InterfaceRealizationReorientCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/InterfaceRealizationReorientCommand.java index 7c95278eb08..2061d8a9bd2 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/InterfaceRealizationReorientCommand.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/InterfaceRealizationReorientCommand.java @@ -1,75 +1,90 @@ -/*****************************************************************************
- * 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:
- *
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.service.types.command;
-
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.uml2.uml.BehavioredClassifier;
-import org.eclipse.uml2.uml.Interface;
-import org.eclipse.uml2.uml.InterfaceRealization;
-
-/**
- * <pre>
- * Re-orient command for {@link InterfaceRealization} elements.
- * </pre>
- */
-public class InterfaceRealizationReorientCommand extends DependencyReorientCommand {
-
- /**
- * <pre>
- * Constructor.
- *
- * @param request the re-orient relationship request.
- * </pre>
- */
- public InterfaceRealizationReorientCommand(ReorientRelationshipRequest request) {
- super(request);
- }
-
- /**
- * <pre>
- * @see org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand#canExecute()
- *
- * @return true if the command is executable.
- * </pre>
- */
- public boolean canExecute() {
- if(! (getElementToEdit() instanceof InterfaceRealization)) {
- return false;
- }
-
- return super.canExecute();
- }
-
- protected boolean canReorientSource() {
- if(!(newEnd instanceof BehavioredClassifier)) {
- return false;
- }
-
- return true;
- }
-
- protected boolean canReorientTarget() {
- if(!(newEnd instanceof Interface)) {
- return false;
- }
-
- return true;
- }
-
- protected InterfaceRealization getLink() {
- return (InterfaceRealization)getElementToEdit();
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2011, 2017 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 + * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 515122 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.service.types.command; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; +import org.eclipse.uml2.uml.BehavioredClassifier; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.InterfaceRealization; + +/** + * <pre> + * Re-orient command for {@link InterfaceRealization} elements. + * </pre> + */ +public class InterfaceRealizationReorientCommand extends DependencyReorientCommand { + + /** + * Constructor. + * + * @param request + * the re-orient relationship request. + */ + public InterfaceRealizationReorientCommand(ReorientRelationshipRequest request) { + super(request); + } + + /** + * @see org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand#canExecute() + * + * @return true if the command is executable. + */ + @Override + public boolean canExecute() { + if (!(getElementToEdit() instanceof InterfaceRealization)) { + return false; + } + + return super.canExecute(); + } + + @Override + protected boolean canReorientSource() { + if (!(newEnd instanceof BehavioredClassifier)) { + return false; + } + + return true; + } + + @Override + protected boolean canReorientTarget() { + if (!(newEnd instanceof Interface)) { + return false; + } + + return true; + } + + @Override + protected InterfaceRealization getLink() { + return (InterfaceRealization) getElementToEdit(); + } + + /** + * {@inheritDoc} + */ + @Override + protected CommandResult reorientTarget() throws ExecutionException { + if (getNewTarget() instanceof Interface) { + getLink().setContract((Interface) getNewTarget()); + } + return super.reorientTarget(); + } + +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/SubstitutionReorientCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/SubstitutionReorientCommand.java index 604edf2e2d2..3726c3332b8 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/SubstitutionReorientCommand.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/SubstitutionReorientCommand.java @@ -1,82 +1,97 @@ -/*****************************************************************************
- * 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:
- *
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.service.types.command;
-
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Substitution;
-
-/**
- * <pre>
- * Re-orient command for {@link Substitution} elements.
- * </pre>
- */
-public class SubstitutionReorientCommand extends DependencyReorientCommand {
-
- /**
- * <pre>
- * Constructor.
- *
- * @param request the re-orient relationship request.
- * </pre>
- */
- public SubstitutionReorientCommand(ReorientRelationshipRequest request) {
- super(request);
- }
-
- /**
- * <pre>
- * @see org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand#canExecute()
- *
- * @return true if the command is executable.
- * </pre>
- */
- public boolean canExecute() {
- if(! (getElementToEdit() instanceof Substitution)) {
- return false;
- }
-
- return super.canExecute();
- }
-
- protected boolean canReorientSource() {
- if(!(newEnd instanceof Classifier)) {
- return false;
- }
-
- if (newEnd == getLink().getContract()) {
- return false;
- }
-
- return true;
- }
-
- protected boolean canReorientTarget() {
- if(!(newEnd instanceof Classifier)) {
- return false;
- }
-
- if (newEnd == getLink().getSubstitutingClassifier()) {
- return false;
- }
-
- return true;
- }
-
- protected Substitution getLink() {
- return (Substitution)getElementToEdit();
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2011, 2017 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 + * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 515122 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.service.types.command; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Substitution; + +/** + * <pre> + * Re-orient command for {@link Substitution} elements. + * </pre> + */ +public class SubstitutionReorientCommand extends DependencyReorientCommand { + + /** + * Constructor. + * + * @param request + * the re-orient relationship request. + */ + public SubstitutionReorientCommand(ReorientRelationshipRequest request) { + super(request); + } + + /** + * @see org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand#canExecute() + * + * @return true if the command is executable. + */ + @Override + public boolean canExecute() { + if (!(getElementToEdit() instanceof Substitution)) { + return false; + } + + return super.canExecute(); + } + + @Override + protected boolean canReorientSource() { + if (!(newEnd instanceof Classifier)) { + return false; + } + + if (newEnd == getLink().getContract()) { + return false; + } + + return true; + } + + @Override + protected boolean canReorientTarget() { + if (!(newEnd instanceof Classifier)) { + return false; + } + + if (newEnd == getLink().getSubstitutingClassifier()) { + return false; + } + + return true; + } + + @Override + protected Substitution getLink() { + return (Substitution) getElementToEdit(); + } + + /** + * {@inheritDoc} + */ + @Override + protected CommandResult reorientTarget() throws ExecutionException { + if (getNewTarget() instanceof Classifier) { + getLink().setContract((Classifier) getNewTarget()); + } + return super.reorientTarget(); + } + +} |