Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-06-26 11:06:09 -0400
committerPatrick Tessier2019-08-20 04:48:49 -0400
commit265cc388b08e80b595f497e43fa628ef39dfc724 (patch)
tree5dc9418dfa209f760b6ae4d98f3658b030850e86 /plugins
parent3e505a4bd3d6012de51a7d9ee005f5344a2c0eee (diff)
downloadorg.eclipse.papyrus-265cc388b08e80b595f497e43fa628ef39dfc724.tar.gz
org.eclipse.papyrus-265cc388b08e80b595f497e43fa628ef39dfc724.tar.xz
org.eclipse.papyrus-265cc388b08e80b595f497e43fa628ef39dfc724.zip
Minor enhancements for helper advices
Change-Id: I498eea155e2dd6db6d6be147bc7f8f473eb4e32e Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/helper/advice/ConstraintHelperAdvice.java6
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionEditHelperAdvice.java21
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionUseEditHelperAdvice.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/ConstraintHelperAdvice.java6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types.ui/src/org/eclipse/papyrus/uml/service/types/internal/ui/advice/RoleBindingHelperAdvice.java37
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/CommunicationPathEditHelper.java17
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ElementOwnedElementEditHelperAdvice.java16
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java32
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PropertyHelperAdvice.java59
12 files changed, 89 insertions, 138 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/helper/advice/ConstraintHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/helper/advice/ConstraintHelperAdvice.java
index a1ee02f0126..b1f601a9156 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/helper/advice/ConstraintHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/helper/advice/ConstraintHelperAdvice.java
@@ -51,9 +51,9 @@ public class ConstraintHelperAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getAfterSetCommand(SetRequest request) {
EObject element = request.getElementToEdit();
- View view = findView(element);
- if (view != null) {
- if (element instanceof Constraint) {
+ if (element instanceof Constraint) {
+ View view = findView(element);
+ if (view != null) {
EStructuralFeature feature = request.getFeature();
final Object value = request.getValue();
Edge edgeToDestroy = null;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionEditHelperAdvice.java
index 4961ee99852..abaa9dc0e69 100755
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionEditHelperAdvice.java
@@ -35,20 +35,21 @@ import org.eclipse.uml2.uml.UMLPackage;
public class CallBehaviorActionAsInteractionEditHelperAdvice extends AbstractEditHelperAdvice {
- public static String CALL_BEHAVIOR_ACTION_AS_INTERACTION = "CallBehaviorActionAsInteraction";
+ public static String CALL_BEHAVIOR_ACTION_AS_INTERACTION = "CallBehaviorActionAsInteraction"; //$NON-NLS-1$
@Override
protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
- // get the activity containing the new element
- Activity parentActivity = null;
- EObject parent = request.getElementToConfigure();
- while (parent != null && parentActivity == null) {
- if (parent instanceof Activity) {
- parentActivity = (Activity) parent;
- }
- parent = parent.eContainer();
- }
if (CALL_BEHAVIOR_ACTION_AS_INTERACTION.equals(request.getParameter(CallBehaviorActionEditHelperAdvice.POPUP_TYPE))) {
+ // get the activity containing the new element
+ Activity parentActivity = null;
+ EObject parent = request.getElementToConfigure();
+ while (parent != null && parentActivity == null) {
+ if (parent instanceof Activity) {
+ parentActivity = (Activity) parent;
+ }
+ parent = parent.eContainer();
+ }
+
final CreateInteractionWithSnapshotDialog dialog = new CreateInteractionWithSnapshotDialog(Display.getDefault().getActiveShell(), parentActivity, (InvocationAction) request.getElementToConfigure());
if (IDialogConstants.OK_ID == dialog.open()) {
// initialize the invoked element (no need to use a command, since action is being created)
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionUseEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionUseEditHelperAdvice.java
index f0879a58949..a70a29d5321 100755
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionUseEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/advices/CallBehaviorActionAsInteractionUseEditHelperAdvice.java
@@ -36,20 +36,21 @@ import org.eclipse.uml2.uml.UMLPackage;
public class CallBehaviorActionAsInteractionUseEditHelperAdvice extends AbstractEditHelperAdvice {
- public static String CALL_BEHAVIOR_ACTION_AS_INTERACTION_USE = "CallBehaviorActionAsInteractionUse";
+ public static String CALL_BEHAVIOR_ACTION_AS_INTERACTION_USE = "CallBehaviorActionAsInteractionUse"; //$NON-NLS-1$
@Override
protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
- // get the activity containing the new element
- Activity parentActivity = null;
- EObject parent = request.getElementToConfigure();
- while (parent != null && parentActivity == null) {
- if (parent instanceof Activity) {
- parentActivity = (Activity) parent;
- }
- parent = parent.eContainer();
- }
if (CALL_BEHAVIOR_ACTION_AS_INTERACTION_USE.equals(request.getParameter(CallBehaviorActionEditHelperAdvice.POPUP_TYPE))) {
+ // get the activity containing the new element
+ Activity parentActivity = null;
+ EObject parent = request.getElementToConfigure();
+ while (parent != null && parentActivity == null) {
+ if (parent instanceof Activity) {
+ parentActivity = (Activity) parent;
+ }
+ parent = parent.eContainer();
+ }
+
final CreateInteractionUseDialog dialog = new CreateInteractionUseDialog(Display.getDefault().getActiveShell(), parentActivity, (InvocationAction) request.getElementToConfigure());
if (IDialogConstants.OK_ID == dialog.open()) {
// initialize the invoked element (no need to use a command, since action is being created)
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java
index 3ef40ed5aa0..ea9ff734df8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java
@@ -55,8 +55,6 @@ public abstract class AbstractDurationLinkAdvice extends AbstractEditHelperAdvic
@Override
protected ICommand getAfterSetCommand(SetRequest request) {
if (request.getFeature() == eventsReference && durationElementType.isInstance(request.getElementToEdit())) {
- Collection<Setting> usages = EMFHelper.getUsages(request.getElementToEdit());
-
// We need to delegate to the command provider; otherwise the view is not correctly destroyed,
// and the diagram may still display a ghost connection (referencing a view that is no longer
// attached to the notation model)
@@ -65,7 +63,9 @@ public abstract class AbstractDurationLinkAdvice extends AbstractEditHelperAdvic
return null;
}
- CompositeCommand deletions = new CompositeCommand("Delete inconsistent DurationLink views");
+ Collection<Setting> usages = EMFHelper.getUsages(request.getElementToEdit());
+
+ CompositeCommand deletions = new CompositeCommand("Delete inconsistent DurationLink views"); //$NON-NLS-1$
for (Setting usage : usages) {
if (usage.getEObject() instanceof Connector && usage.getEStructuralFeature() == NotationPackage.Literals.VIEW__ELEMENT) {
Connector connector = (Connector) usage.getEObject();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/ConstraintHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/ConstraintHelperAdvice.java
index 8002c45a36d..77d929c6081 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/ConstraintHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/ConstraintHelperAdvice.java
@@ -54,9 +54,9 @@ public class ConstraintHelperAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getAfterSetCommand(SetRequest request) {
EObject element = request.getElementToEdit();
- View view = findView(element);
- if (view != null) {
- if (element instanceof Constraint) {
+ if (element instanceof Constraint) {
+ View view = findView(element);
+ if (view != null) {
EStructuralFeature feature = request.getFeature();
final Object value = request.getValue();
Vector<Edge> edgesToDestroy = new Vector<>();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types.ui/src/org/eclipse/papyrus/uml/service/types/internal/ui/advice/RoleBindingHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types.ui/src/org/eclipse/papyrus/uml/service/types/internal/ui/advice/RoleBindingHelperAdvice.java
index 9da77e64c8d..c21561ea2ac 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types.ui/src/org/eclipse/papyrus/uml/service/types/internal/ui/advice/RoleBindingHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types.ui/src/org/eclipse/papyrus/uml/service/types/internal/ui/advice/RoleBindingHelperAdvice.java
@@ -1,7 +1,7 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2019 CEA LIST.
+ *
*
- *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Implement approveRequest
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.internal.ui.advice;
@@ -23,11 +24,11 @@ import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.CreateRelationshipCommand;
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.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.uml.service.types.internal.ui.dialogs.CollaborationRoleTreeContentProvider;
import org.eclipse.swt.SWT;
@@ -42,6 +43,21 @@ import org.eclipse.uml2.uml.NamedElement;
public class RoleBindingHelperAdvice extends AbstractEditHelperAdvice {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ */
+ @Override
+ public boolean approveRequest(final IEditCommandRequest request) {
+ if (request instanceof CreateRelationshipRequest) {
+ if (((CreateRelationshipRequest) request).getSource() instanceof CollaborationUse && null == ((CreateRelationshipRequest) request).getTarget()) {
+ return false;
+ }
+ }
+ return super.approveRequest(request);
+ }
+
@Override
protected ICommand getAfterCreateRelationshipCommand(CreateRelationshipRequest request) {
@@ -51,17 +67,13 @@ public class RoleBindingHelperAdvice extends AbstractEditHelperAdvice {
final CollaborationUse source = (CollaborationUse) reqSource;
final Dependency dependency = (Dependency) request.getNewElement();
final NamedElement target = (NamedElement) request.getTarget();
- if ((target == null)) {
- return UnexecutableCommand.INSTANCE;
- }
-
return new CreateRelationshipCommand(request) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
if (!canExecute()) {
- throw new ExecutionException("Invalid arguments in create link command");
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
}
@@ -72,8 +84,8 @@ public class RoleBindingHelperAdvice extends AbstractEditHelperAdvice {
try {
// Set dialog parameters
- dialog.setTitle("Collaboration role binding");
- dialog.setMessage("Select the role to bind:");
+ dialog.setTitle("Collaboration role binding"); //$NON-NLS-1$
+ dialog.setMessage("Select the role to bind:"); //$NON-NLS-1$
dialog.setAllowMultiple(false);
dialog.setHelpAvailable(false);
// The source CollaborationUse is set as input for the selection dialog,
@@ -94,7 +106,7 @@ public class RoleBindingHelperAdvice extends AbstractEditHelperAdvice {
ConnectableElement roleToBind = (ConnectableElement) dialog.getFirstResult();
// Create a Dependency (the binding) between selected role and a ConnectableElement
// (the target)
- dependency.setName("binding_" + roleToBind.getName() + "_" + target.getName());
+ dependency.setName("binding_" + roleToBind.getName() + "_" + target.getName()); //$NON-NLS-1$ //$NON-NLS-2$
source.getRoleBindings().add(dependency);
@@ -110,9 +122,6 @@ public class RoleBindingHelperAdvice extends AbstractEditHelperAdvice {
}
return null;
-
}
-
-
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/CommunicationPathEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/CommunicationPathEditHelper.java
index 4f8fe6b0a6e..10583771282 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/CommunicationPathEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/CommunicationPathEditHelper.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper;
@@ -27,6 +27,7 @@ import org.eclipse.uml2.uml.UMLPackage;
public class CommunicationPathEditHelper extends AssociationBaseEditHelper {
+ @Override
protected boolean canCreate(EObject source, EObject target) {
if (isInvalidEnd(source)) {
return false;
@@ -42,22 +43,16 @@ public class CommunicationPathEditHelper extends AssociationBaseEditHelper {
@Override
protected ICommand getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- return new AssociationReorientCommand(req){
+ return new AssociationReorientCommand(req) {
@Override
protected boolean canReorientSource() {
- if (isInvalidEnd(getNewSource())) {
- return false;
- }
- return true;
+ return !isInvalidEnd(getNewSource());
}
@Override
protected boolean canReorientTarget() {
- if (isInvalidEnd(getNewTarget())) {
- return false;
- }
- return true;
+ return !isInvalidEnd(getNewTarget());
}
};
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java
index 1a95c8fc85e..7d1c8440618 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java
@@ -36,7 +36,6 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipReques
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.service.types.command.ControlFlowReorientCommand;
-import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils;
import org.eclipse.papyrus.uml.tools.utils.ActivityEdgeUtil;
import org.eclipse.papyrus.uml.tools.utils.ControlFlowUtil;
import org.eclipse.uml2.uml.ActivityNode;
@@ -106,7 +105,7 @@ public class ControlFlowEditHelper extends ElementEditHelper {
boolean noSourceOrTarget = (source == null || target == null);
boolean noSourceAndTarget = (source == null && target == null);
- if (!noSourceAndTarget && !canCreate(source, target, RequestParameterUtils.getSourceView(req), RequestParameterUtils.getTargetView(req))) {
+ if (!noSourceAndTarget && !canCreate(source, target)) {
// Abort creation.
return UnexecutableCommand.INSTANCE;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java
index a1a92d62df0..0fdfa41201a 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java
@@ -36,7 +36,6 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipReques
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.service.types.command.ObjectFlowReorientCommand;
-import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils;
import org.eclipse.papyrus.uml.tools.utils.ActivityEdgeUtil;
import org.eclipse.papyrus.uml.tools.utils.ObjectFlowUtil;
import org.eclipse.uml2.uml.ActivityNode;
@@ -104,7 +103,7 @@ public class ObjectFlowEditHelper extends ElementEditHelper {
EObject target = req.getTarget();
boolean noSourceOrTarget = (source == null || target == null);
boolean noSourceAndTarget = (source == null && target == null);
- if (!noSourceAndTarget && !canCreate(source, target, RequestParameterUtils.getSourceView(req), RequestParameterUtils.getTargetView(req))) {
+ if (!noSourceAndTarget && !canCreate(source, target)) {
// Abort creation.
return UnexecutableCommand.INSTANCE;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ElementOwnedElementEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ElementOwnedElementEditHelperAdvice.java
index 87f44c61a18..0ca9337481c 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ElementOwnedElementEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ElementOwnedElementEditHelperAdvice.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * 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 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * CEA LIST - Initial implementation
+ *****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
import java.util.Arrays;
@@ -45,8 +58,7 @@ public class ElementOwnedElementEditHelperAdvice extends AbstractEditHelperAdvic
protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
// Be careful, This advice is binded to Element elementtype directly
List<ISpecializationType> subs = Arrays.asList(ElementTypeRegistry.getInstance().getSpecializationsOf(UMLElementTypes.ELEMENT_OWNEDELEMENT.getId()));
- if (!subs.contains(request.getElementType()))
- {
+ if (!subs.contains(request.getElementType())) {
return IdentityCommand.INSTANCE;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
index 3c405b583e1..a6c08b4f857 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
@@ -19,9 +19,7 @@ package org.eclipse.papyrus.uml.service.types.helper.advice;
import static org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils.getCoveredLifelines;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
@@ -189,36 +187,6 @@ public class ExecutionSpecificationHelperAdvice extends InteractionFragmentEditH
dependentsToDestroy.add(osFinish);
}
- Set<Lifeline> coveredLifelines = new HashSet<>(es.getCovereds());
-
- // find initiating MOS of a synch message
- // InteractionFragment previousIft = InteractionFragmentHelper.findPreviousFragment(osStart, es.getOwner());
- // while (previousIft != null) {
- // // keep the first ift with the same lifelines, and check it
- // if (coveredLifelines.equals(new HashSet<Lifeline>(previousIft.getCovereds()))) {
- // if (previousIft instanceof MessageOccurrenceSpecification) {
- // Message msg = ((MessageOccurrenceSpecification) previousIft).getMessage();
- // if (msg != null && MessageSort.SYNCH_CALL_LITERAL.equals(msg.getMessageSort())) {
- // dependentsToDestroy.add(previousIft);
- // }
- // }
- // break;
- // }
- // previousIft = InteractionFragmentHelper.findPreviousFragment(previousIft, es.getOwner());
- // }
- //
- // // find MOS between the start and finish
- // InteractionFragment fragment = osStart;
- // while (fragment != null && !fragment.equals(osFinish)) {
- // // remove MOS if it have the same covered lifelines as the ES
- // if (fragment instanceof MessageOccurrenceSpecification && coveredLifelines.equals(new HashSet<Lifeline>(fragment.getCovereds()))) {
- // dependentsToDestroy.add(fragment);
- // }
- //
- // fragment = InteractionFragmentHelper.findNextFragment(fragment, es.getOwner());
- // }
- //
- // return command to destroy dependents
if (!dependentsToDestroy.isEmpty()) {
return request.getDestroyDependentsCommand(dependentsToDestroy);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PropertyHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PropertyHelperAdvice.java
index d00705260d2..5f0c0dffd91 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PropertyHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/PropertyHelperAdvice.java
@@ -32,10 +32,8 @@ 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.DestroyDependentsRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
@@ -78,10 +76,11 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
- List<EObject> dependents = new ArrayList<EObject>();
- EReference[] refs = null;
-
if (request.getElementToDestroy() instanceof Property) {
+
+ List<EObject> dependents = new ArrayList<>();
+ EReference[] refs = null;
+
Property propertyToDelete = (Property) request.getElementToDestroy();
// Get related ConnectorEnd to be destroyed with the property
@@ -99,7 +98,7 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
for (Association association : associationRefs) {
// Test the number of remaining ends considering the dependents elements deletion in progress
- List<Property> remainingMembers = new ArrayList<Property>();
+ List<Property> remainingMembers = new ArrayList<>();
remainingMembers.addAll(association.getMemberEnds());
remainingMembers.removeAll(request.getDependentElementsToDestroy());
@@ -107,11 +106,11 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
dependents.add(association);
}
}
- }
- // Return the command to destroy all these dependents
- if (!dependents.isEmpty()) {
- return request.getDestroyDependentsCommand(dependents);
+ // Return the command to destroy all these dependents
+ if (!dependents.isEmpty()) {
+ return request.getDestroyDependentsCommand(dependents);
+ }
}
return null;
@@ -141,7 +140,7 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
// Only apply if the property is an association end.
Association relatedAssociation = propertyToEdit.getAssociation();
if (relatedAssociation != null) {
- Set<Property> members = new HashSet<Property>();
+ Set<Property> members = new HashSet<>();
members.addAll(relatedAssociation.getMemberEnds());
members.remove(propertyToEdit);
@@ -165,7 +164,7 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(relatedAssociation);
if (provider != null) {
DestroyElementRequest destroyRequest = new DestroyElementRequest(relatedAssociation, false);
- List<EObject> ps = new ArrayList<EObject>();
+ List<EObject> ps = new ArrayList<>();
ps.add(propertyToEdit);
destroyRequest.setParameter(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.DEPENDENTS_TO_KEEP, ps);
ICommand destroyCommand = provider.getEditCommand(destroyRequest);
@@ -224,7 +223,7 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
// the request comes from re-orient association? so do not remove the edge
if (request.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) == null) {
// Destroy inconsistent views of the association
- Set<View> viewsToDestroy = new HashSet<View>();
+ Set<View> viewsToDestroy = new HashSet<>();
viewsToDestroy.addAll(getViewsToDestroy(relatedAssociation));
@@ -249,38 +248,6 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
return gmfCommand;
}
- /**
- * Create a re-factoring command related to a Property move.
- *
- * @param setProperty
- * the property which type is set
- * @param associationToRefactor
- * the association to re-factor (re-orient action)
- * @param request
- * the original set request
- * @return the re-factoring command
- */
- private ICommand getAssociationRefactoringCommand(Property setProperty, Association associationToRefactor, SetRequest request) {
-
- Association relatedAssociation = setProperty.getAssociation(); // Should not be null, test before calling method.
-
- // Re-orient the related association (do not use edit service to avoid infinite loop here)
- int direction = ReorientRelationshipRequest.REORIENT_TARGET;
- if (setProperty == associationToRefactor.getMemberEnds().get(1)) {
- direction = ReorientRelationshipRequest.REORIENT_SOURCE;
- }
-
- ReorientRelationshipRequest reorientRequest = new ReorientRelationshipRequest(relatedAssociation, (Type) request.getValue(), setProperty.eContainer(), direction);
- reorientRequest.addParameters(request.getParameters());
-
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(relatedAssociation);
- if (provider != null) {
- return provider.getEditCommand(reorientRequest);
- }
-
- return null;
- }
-
@Override
public void configureRequest(IEditCommandRequest request) {
if (request instanceof CreateElementRequest) {
@@ -307,7 +274,7 @@ public class PropertyHelperAdvice extends AbstractEditHelperAdvice {
* @return the list of views to be destroy
*/
private HashSet<View> getViewsToDestroy(Association association) {
- HashSet<View> viewsToDestroy = new HashSet<View>();
+ HashSet<View> viewsToDestroy = new HashSet<>();
// Find all views representing the Associations
EReference[] refs = new EReference[] { NotationPackage.eINSTANCE.getView_Element() };

Back to the top