Skip to content

Commit 8e59846

Browse files
committed
[fix] Fix New Allocation edge tool
The container of the new Allocation was the ViewUsage instead of the parent of the semantic source. Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
1 parent 68980e4 commit 8e59846

File tree

2 files changed

+33
-55
lines changed

2 files changed

+33
-55
lines changed

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewCreateService.java

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public Element createPartUsageAsAllocationDefinitionEnd(AllocationDefinition sel
495495
}
496496

497497
public Element createAllocateEdge(Element source, Element target, Node sourceNode, IEditingContext editingContext, IDiagramService diagramService) {
498-
var owner = this.getSourceOwner(sourceNode, editingContext, diagramService);
498+
var owner = source.getOwner();
499499
var ownerMembership = SysmlFactory.eINSTANCE.createOwningMembership();
500500
owner.getOwnedRelationship().add(ownerMembership);
501501
var allocation = SysmlFactory.eINSTANCE.createAllocationUsage();
@@ -519,15 +519,17 @@ private void addEndToAllocateEdge(AllocationUsage edge, Element end) {
519519
}
520520

521521
/**
522-
* Retrieve the parent node semantic element of the given node
522+
* Retrieve the parent node's semantic element of the given node
523523
*
524524
* @param sourceNode
525-
* a {@link Node}
525+
* a {@link Node}
526526
* @param editingContext
527-
* the {@link IEditingContext} of the tool. It corresponds to a variable accessible from the variable manager.
527+
* the {@link IEditingContext} of the tool. It corresponds to a variable accessible from the variable
528+
* manager.
528529
* @param diagramService
529-
* the {@link IDiagramService} used to retrieve diagram
530-
* @return the semantic element of the parent graphical node of the given one or <code>null</code> if unable to find it.
530+
* the {@link IDiagramService} used to retrieve diagram
531+
* @return the semantic element of the parent graphical node of the given Node or <code>null</code> if unable to
532+
* find it.
531533
*/
532534
private Element getSourceOwner(Node sourceNode, IEditingContext editingContext, IDiagramService diagramService) {
533535
Diagram diagram = diagramService.getDiagramContext().getDiagram();
@@ -851,30 +853,6 @@ public ActionUsage createSubActionUsage(Element ownerElement) {
851853
return newActionUsage;
852854
}
853855

854-
/**
855-
* Removal service for Start action inside an action usage or definition.
856-
*
857-
* @param selectedNode
858-
* the node element that represents the start action in the diagram.
859-
* @param editingContext
860-
* the {@link IEditingContext} of the tool. It corresponds to a variable accessible from the variable manager.
861-
* @param diagramService
862-
* the {@link IDiagramService} used to retrieve diagram
863-
* @return the element that owned the start action.
864-
*/
865-
public Element removeStartAction(Node selectedNode, IEditingContext editingContext, IDiagramService diagramService) {
866-
Element owner = this.getSourceOwner(selectedNode, editingContext, diagramService);
867-
owner.getOwnedRelationship().stream()
868-
.filter(Membership.class::isInstance)
869-
.map(Membership.class::cast)
870-
.filter(m -> {
871-
return m.getMemberElement() instanceof ActionUsage au && this.utilService.isStandardStartAction(au);
872-
})
873-
.findFirst()
874-
.ifPresent(this.deleteService::deleteFromModel);
875-
return owner;
876-
}
877-
878856
/**
879857
* Creation of the semantic elements associated to a Join action.
880858
*

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitch.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ public List<EdgeTool> caseAcceptActionUsage(AcceptActionUsage object) {
9090
return edgeTools;
9191
}
9292

93-
private void addFeatureTypingEdgeToolForActionUsageSubType(List<EdgeTool> edgeTools) {
94-
Optional<NodeDescription> optActionDefinitionNodeDescription = this.edgeToolService.getNodeDescription(SysmlPackage.eINSTANCE.getActionDefinition());
95-
optActionDefinitionNodeDescription.ifPresent(nd -> edgeTools.add(this.edgeToolService.createFeatureTypingEdgeTool(List.of(nd))));
96-
}
97-
9893
@Override
9994
public List<EdgeTool> caseActionUsage(ActionUsage object) {
10095
var edgeTools = new ArrayList<EdgeTool>();
@@ -104,26 +99,6 @@ public List<EdgeTool> caseActionUsage(ActionUsage object) {
10499
return edgeTools;
105100
}
106101

107-
private List<NodeDescription> getSuccessionEdgeTargets() {
108-
return this.allNodeDescriptions.stream()
109-
.filter(this::isSuccessionTargetNodeDescription)
110-
.toList();
111-
}
112-
113-
private boolean isSuccessionTargetNodeDescription(NodeDescription nodeDesc) {
114-
boolean result = this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getActionUsage());
115-
result = result || this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getAcceptActionUsage());
116-
result = result || this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getAssignmentActionUsage());
117-
result = result || this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getPerformActionUsage());
118-
result = result || this.nameGenerator.getNodeName(DoneActionNodeDescriptionProvider.DONE_ACTION_NAME).equals(nodeDesc.getName());
119-
result = result || this.nameGenerator.getNodeName(JoinActionNodeDescriptionProvider.JOIN_ACTION_NAME).equals(nodeDesc.getName());
120-
result = result || this.nameGenerator.getNodeName(ForkActionNodeDescriptionProvider.FORK_ACTION_NAME).equals(nodeDesc.getName());
121-
result = result || this.nameGenerator.getNodeName(MergeActionNodeDescriptionProvider.MERGE_ACTION_NAME).equals(nodeDesc.getName());
122-
result = result || this.nameGenerator.getNodeName(DecisionActionNodeDescriptionProvider.DECISION_ACTION_NAME).equals(nodeDesc.getName());
123-
result = result || this.nameGenerator.getNodeName(ReferencingPerformActionUsageNodeDescriptionService.REFERENCING_PERFORM_ACTION_NAME).equals(nodeDesc.getName());
124-
return result;
125-
}
126-
127102
@Override
128103
public List<EdgeTool> caseAllocationUsage(AllocationUsage object) {
129104
var edgeTools = new ArrayList<EdgeTool>();
@@ -310,4 +285,29 @@ private boolean isRegularNodeDescription(NodeDescription nodeDesc) {
310285
isSpecial = isSpecial || this.nameGenerator.getNodeName(DecisionActionNodeDescriptionProvider.DECISION_ACTION_NAME).equals(nodeDesc.getName());
311286
return !isSpecial;
312287
}
288+
289+
private void addFeatureTypingEdgeToolForActionUsageSubType(List<EdgeTool> edgeTools) {
290+
Optional<NodeDescription> optActionDefinitionNodeDescription = this.edgeToolService.getNodeDescription(SysmlPackage.eINSTANCE.getActionDefinition());
291+
optActionDefinitionNodeDescription.ifPresent(nd -> edgeTools.add(this.edgeToolService.createFeatureTypingEdgeTool(List.of(nd))));
292+
}
293+
294+
private List<NodeDescription> getSuccessionEdgeTargets() {
295+
return this.allNodeDescriptions.stream()
296+
.filter(this::isSuccessionTargetNodeDescription)
297+
.toList();
298+
}
299+
300+
private boolean isSuccessionTargetNodeDescription(NodeDescription nodeDesc) {
301+
boolean result = this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getActionUsage());
302+
result = result || this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getAcceptActionUsage());
303+
result = result || this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getAssignmentActionUsage());
304+
result = result || this.edgeToolService.isTheNodeDescriptionFor(nodeDesc, SysmlPackage.eINSTANCE.getPerformActionUsage());
305+
result = result || this.nameGenerator.getNodeName(DoneActionNodeDescriptionProvider.DONE_ACTION_NAME).equals(nodeDesc.getName());
306+
result = result || this.nameGenerator.getNodeName(JoinActionNodeDescriptionProvider.JOIN_ACTION_NAME).equals(nodeDesc.getName());
307+
result = result || this.nameGenerator.getNodeName(ForkActionNodeDescriptionProvider.FORK_ACTION_NAME).equals(nodeDesc.getName());
308+
result = result || this.nameGenerator.getNodeName(MergeActionNodeDescriptionProvider.MERGE_ACTION_NAME).equals(nodeDesc.getName());
309+
result = result || this.nameGenerator.getNodeName(DecisionActionNodeDescriptionProvider.DECISION_ACTION_NAME).equals(nodeDesc.getName());
310+
result = result || this.nameGenerator.getNodeName(ReferencingPerformActionUsageNodeDescriptionService.REFERENCING_PERFORM_ACTION_NAME).equals(nodeDesc.getName());
311+
return result;
312+
}
313313
}

0 commit comments

Comments
 (0)