Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DependencyBranchDeletion.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DependencyBranchDeletion.java41
1 files changed, 23 insertions, 18 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DependencyBranchDeletion.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DependencyBranchDeletion.java
index 95363764e46..d83926c70f0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DependencyBranchDeletion.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DependencyBranchDeletion.java
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.uml.diagram.profile.custom.commands;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -65,25 +66,22 @@ public class DependencyBranchDeletion implements IObjectActionDelegate {
Dependency dependency = null;
TransactionalEditingDomain domain = selectedElement.getEditingDomain();
GraphicalEditPart dependencyNodeEditPart = null;
-
// 1. Semanctic deletion of the client or supplier
- GraphicalEditPart branchSource = (GraphicalEditPart)selectedElement.getSource();
- GraphicalEditPart branchtarget = (GraphicalEditPart)selectedElement.getTarget();
+ GraphicalEditPart branchSource = (GraphicalEditPart) selectedElement.getSource();
+ GraphicalEditPart branchtarget = (GraphicalEditPart) selectedElement.getTarget();
EStructuralFeature feature = null;
ArrayList<NamedElement> newValue = new ArrayList<NamedElement>();
-
- if(branchSource.resolveSemanticElement() instanceof Dependency) {
+ if (branchSource.resolveSemanticElement() instanceof Dependency) {
// target is the supplier of the dependency
- dependency = (Dependency)branchSource.resolveSemanticElement();
+ dependency = (Dependency) branchSource.resolveSemanticElement();
dependencyNodeEditPart = branchSource;
newValue.addAll(dependency.getSuppliers());
newValue.remove(branchtarget.resolveSemanticElement());
feature = UMLPackage.eINSTANCE.getDependency_Supplier();
-
} else {
// source is the client of the dependency to remove
feature = UMLPackage.eINSTANCE.getDependency_Client();
- dependency = (Dependency)branchtarget.resolveSemanticElement();
+ dependency = (Dependency) branchtarget.resolveSemanticElement();
dependencyNodeEditPart = branchtarget;
newValue.addAll(dependency.getClients());
newValue.remove(branchSource.resolveSemanticElement());
@@ -91,14 +89,12 @@ public class DependencyBranchDeletion implements IObjectActionDelegate {
SetRequest setRequest = new SetRequest(dependency, feature, newValue);
SetValueCommand setValueCommand = new SetValueCommand(setRequest);
command.add(new ICommandProxy(setValueCommand));
-
// 2. graphical deletion of the branch
View branchDependencyView = selectedElement.getNotationView();
command.add(new ICommandProxy(new DeleteCommand(domain, branchDependencyView)));
-
// 3. test if it exists more than 2 branches
int branchNumber = dependencyNodeEditPart.getSourceConnections().size() + dependencyNodeEditPart.getTargetConnections().size();
- if(branchNumber == 3) {
+ if (branchNumber == 3) {
// 4. Graphical deletion of the node
command.add(new ICommandProxy(new DeleteCommand(domain, dependencyNodeEditPart.getNotationView())));
// 5. Graphical creation of the binary dependency
@@ -106,15 +102,24 @@ public class DependencyBranchDeletion implements IObjectActionDelegate {
// dependency
ArrayList<EditPart> sourceList = new ArrayList<EditPart>();
ArrayList<EditPart> targetList = new ArrayList<EditPart>();
-
- sourceList.addAll(dependencyNodeEditPart.getSourceConnections());
- targetList.addAll(dependencyNodeEditPart.getTargetConnections());
+ List<?> sourceConnections = dependencyNodeEditPart.getSourceConnections();
+ for (Object object : sourceConnections) {
+ if (object instanceof EditPart) {
+ sourceList.add((EditPart) object);
+ }
+ }
+ List<?> targetConnections = dependencyNodeEditPart.getTargetConnections();
+ for (Object object : targetConnections) {
+ if (object instanceof EditPart) {
+ targetList.add((EditPart) object);
+ }
+ }
sourceList.remove(selectedElement);
targetList.remove(selectedElement);
- PreferencesHint preferencesHint = ((GraphicalEditPart)((ConnectionEditPart)(sourceList.get(0))).getTarget()).getDiagramPreferencesHint();
- ConnectionViewDescriptor viewDescriptor = new ConnectionViewDescriptor(UMLElementTypes.Dependency_4008, ((IHintedType)UMLElementTypes.Dependency_4008).getSemanticHint(), preferencesHint);
-
- CustomDeferredCreateConnectionViewCommand binaryCommand = new CustomDeferredCreateConnectionViewCommand(domain, ((IHintedType)UMLElementTypes.Dependency_4008).getSemanticHint(), new SemanticAdapter(null, (((ConnectionEditPart)(targetList.get(0))).getSource()).getModel()), new SemanticAdapter(null, (((ConnectionEditPart)(sourceList.get(0))).getTarget()).getModel()), sourceList.get(0).getViewer(), preferencesHint, viewDescriptor, null);
+ PreferencesHint preferencesHint = ((GraphicalEditPart) ((ConnectionEditPart) (sourceList.get(0))).getTarget()).getDiagramPreferencesHint();
+ ConnectionViewDescriptor viewDescriptor = new ConnectionViewDescriptor(UMLElementTypes.Dependency_4008, ((IHintedType) UMLElementTypes.Dependency_4008).getSemanticHint(), preferencesHint);
+ CustomDeferredCreateConnectionViewCommand binaryCommand = new CustomDeferredCreateConnectionViewCommand(domain, ((IHintedType) UMLElementTypes.Dependency_4008).getSemanticHint(), new SemanticAdapter(null,
+ (((ConnectionEditPart) (targetList.get(0))).getSource()).getModel()), new SemanticAdapter(null, (((ConnectionEditPart) (sourceList.get(0))).getTarget()).getModel()), sourceList.get(0).getViewer(), preferencesHint, viewDescriptor, null);
binaryCommand.setElement(dependency);
command.add(new ICommandProxy(binaryCommand));
}

Back to the top