Skip to content

Commit

Permalink
eclipse-capella#2884 Improve DnD on DeploymentLinks
Browse files Browse the repository at this point in the history
When multiple DeploymentsLinks are enabled, the drag and drop of a
Component or a Part with several DeploymentLinks doesn't remove existing
DeploymentsLinks that are not affected by the reference update.

Signed-off-by: Glenn Plouhinec <[email protected]>
  • Loading branch information
GlennPlou committed Jul 9, 2024
1 parent 75652cb commit e9cf53e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2024 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -727,6 +727,11 @@ public boolean isValidDndABComponent(Part semanticObjectToDrop, EObject targetCo
}

context = CsServices.getService().getABTarget((DSemanticDecorator) targetContainerView);
final EObject semanticTarget = context;
boolean isSourceAlreadyReployed = semanticObjectToDrop.getDeployingLinks().stream().anyMatch(link -> link.eContainer().equals(semanticTarget));
if (isSourceAlreadyReployed) {
return false;
}
if (context instanceof BlockArchitecture) {
return false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2024 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -2988,7 +2988,10 @@ public EObject dndABDeployment(NamedElement pcMoved, NamedElement oldContainer,
}

// move all deploying links
for (AbstractDeploymentLink link : new ArrayList<AbstractDeploymentLink>(component.getDeployingLinks())) {
List<AbstractDeploymentLink> deployingLinksToUpdate = component.getDeployingLinks().stream()
.filter(link -> link.eContainer().equals(oldContainer))
.collect(Collectors.toList());
for (AbstractDeploymentLink link : deployingLinksToUpdate) {
link.setLocation(newComponent);
newComponent.getOwnedDeploymentLinks().add(link);
}
Expand All @@ -3009,7 +3012,10 @@ public EObject dndABDeployment(NamedElement pcMoved, NamedElement oldContainer,
}

// move all deploying links
for (AbstractDeploymentLink link : new ArrayList<AbstractDeploymentLink>(currentPart.getDeployingLinks())) {
List<AbstractDeploymentLink> deployingLinksToUpdate = currentPart.getDeployingLinks().stream()
.filter(link -> link.eContainer().equals(oldContainer))
.collect(Collectors.toList());
for (AbstractDeploymentLink link : deployingLinksToUpdate) {
link.setLocation(newPart);
newPart.getOwnedDeploymentLinks().add(link);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2019, 2024 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -124,6 +124,8 @@ public void testDnDComponentsBehaviorAndNodeDeployedOrNot(Session session, Sessi
expectedNotPossible.add(new Pair<>(NOT_DEPLOYED_BEHAVIOR_DRAGGED, NOT_DEPLOYED_NODE_CONTAINER));
expectedNotPossible.add(new Pair<>(NOT_DEPLOYED_BEHAVIOR_DRAGGED, DEPLOYED_NODE_CONTAINER));
expectedNotPossible.add(new Pair<>(NOT_DEPLOYED_BEHAVIOR_DRAGGED, ACTOR_CONTAINER));
// Moving PC 8 from PC 1 to PC 1 is not a drag and drop.
expectedNotPossible.add(new Pair<>(DEPLOYED_NODE_DRAGGED, NOT_DEPLOYED_NODE_CONTAINER));

// Now testing all combinations of dragged elements and containers
for (String draggedElement : draggedElements) {
Expand Down

0 comments on commit e9cf53e

Please sign in to comment.