Skip to content

Commit 0e45b1c

Browse files
committed
[1747] Automatically select more newly created elements
Bug: #1747 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
1 parent a297d07 commit 0e45b1c

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This fix ensure that imported models containing, for example, a top-level `Libra
4646
- https://github.com/eclipse-syson/syson/issues/1565[#1565] Provide a way to duplicate semantic element in the _Explorer_ view.
4747
- https://github.com/eclipse-syson/syson/issues/1737[#1737] [diagrams] Add creation tools to InterconnectionCompartmentNode
4848
- https://github.com/eclipse-syson/syson/issues/1395[#1395] Provide a way to duplicate a semantic element ans its representation node in the _General View_ diagram.
49+
- https://github.com/eclipse-syson/syson/issues/1747[#1747] [diagrams] Most new elements created by invoking a tool on a diagram are now automatically selected
4950

5051
== v2025.12.0
5152

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AbstractCompartmentNodeToolProvider.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*******************************************************************************/
1313
package org.eclipse.syson.diagram.common.view.tools;
1414

15-
import java.util.List;
16-
1715
import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext;
1816
import org.eclipse.sirius.components.core.api.IEditingContext;
1917
import org.eclipse.sirius.components.diagrams.Node;
@@ -25,9 +23,9 @@
2523
import org.eclipse.sirius.components.view.diagram.NodeTool;
2624
import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription;
2725
import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter;
26+
import org.eclipse.syson.diagram.common.view.services.ViewNodeService;
2827
import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService;
2928
import org.eclipse.syson.util.AQLConstants;
30-
import org.eclipse.syson.util.AQLUtils;
3129
import org.eclipse.syson.util.ServiceMethod;
3230

3331
/**
@@ -37,6 +35,8 @@
3735
*/
3836
public abstract class AbstractCompartmentNodeToolProvider implements INodeToolProvider {
3937

38+
private static final String NEW_INSTANCE = "newInstance";
39+
4040
protected final DiagramBuilders diagramBuilderHelper = new DiagramBuilders();
4141

4242
protected final ViewBuilders viewBuilderHelper = new ViewBuilders();
@@ -77,8 +77,8 @@ public NodeTool create(IViewDiagramElementFinder cache) {
7777
ChangeContextBuilder revealOperation;
7878
if (this.revealOnCreate()) {
7979
revealOperation = this.viewBuilderHelper.newChangeContext()
80-
.expression(AQLUtils.getServiceCallExpression(Node.SELECTED_NODE, "revealCompartment",
81-
List.of("self", DiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE)));
80+
.expression(ServiceMethod.of4(ViewNodeService::revealCompartment).aql(Node.SELECTED_NODE, AQLConstants.SELF, DiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT,
81+
ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE));
8282
} else {
8383
revealOperation = this.viewBuilderHelper.newChangeContext().expression(AQLConstants.AQL_SELF);
8484
}
@@ -87,19 +87,25 @@ public NodeTool create(IViewDiagramElementFinder cache) {
8787
.expression(ServiceMethod.of4(DiagramMutationAQLService::expose).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, Node.SELECTED_NODE,
8888
ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE));
8989

90-
var creationCompartmentItemServiceCall = this.viewBuilderHelper.newChangeContext()
91-
.expression(this.getServiceCallExpression())
90+
var exposeAndRevealNewInstance = this.viewBuilderHelper.newChangeContext()
91+
.expression(AQLConstants.AQL + NEW_INSTANCE)
9292
.children(addToExposedElements.build(), revealOperation.build());
9393

94+
var letNewInstance = this.viewBuilderHelper.newLet()
95+
.variableName(NEW_INSTANCE)
96+
.valueExpression(this.getServiceCallExpression())
97+
.children(exposeAndRevealNewInstance.build());
98+
9499
var rootChangContext = this.viewBuilderHelper.newChangeContext()
95100
.expression(AQLConstants.AQL_SELF)
96-
.children(creationCompartmentItemServiceCall.build())
101+
.children(letNewInstance.build())
97102
.build();
98103

99104
return builder.name(this.getNodeToolName())
100105
.iconURLsExpression(this.getNodeToolIconURLsExpression())
101106
.body(rootChangContext)
102107
.preconditionExpression(this.getPreconditionExpression())
108+
.elementsToSelectExpression(AQLConstants.AQL + NEW_INSTANCE)
103109
.build();
104110
}
105111

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ActionFlowCompartmentNodeToolProvider.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*******************************************************************************/
1313
package org.eclipse.syson.diagram.common.view.tools;
1414

15-
import java.util.List;
16-
1715
import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext;
1816
import org.eclipse.sirius.components.core.api.IEditingContext;
1917
import org.eclipse.sirius.components.diagrams.Node;
@@ -23,8 +21,10 @@
2321
import org.eclipse.sirius.components.view.builder.providers.INodeToolProvider;
2422
import org.eclipse.sirius.components.view.diagram.NodeTool;
2523
import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter;
24+
import org.eclipse.syson.diagram.common.view.services.ViewCreateService;
25+
import org.eclipse.syson.diagram.common.view.services.ViewNodeService;
2626
import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService;
27-
import org.eclipse.syson.util.AQLUtils;
27+
import org.eclipse.syson.util.AQLConstants;
2828
import org.eclipse.syson.util.ServiceMethod;
2929

3030
/**
@@ -34,6 +34,8 @@
3434
*/
3535
public class ActionFlowCompartmentNodeToolProvider implements INodeToolProvider {
3636

37+
private static final String NEW_INSTANCE = "newInstance";
38+
3739
private final DiagramBuilders diagramBuilderHelper = new DiagramBuilders();
3840

3941
private final ViewBuilders viewBuilderHelper = new ViewBuilders();
@@ -47,18 +49,19 @@ public NodeTool create(IViewDiagramElementFinder cache) {
4749
ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE));
4850

4951
var revealOperation = this.viewBuilderHelper.newChangeContext()
50-
.expression(
51-
AQLUtils.getServiceCallExpression(Node.SELECTED_NODE, "revealCompartment",
52-
List.of("self", DiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE)));
52+
.expression(ServiceMethod.of4(ViewNodeService::revealCompartment).aql(Node.SELECTED_NODE, AQLConstants.SELF, DiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT,
53+
ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE));
5354

54-
var creationServiceCall = this.viewBuilderHelper.newChangeContext()
55-
.expression(AQLUtils.getSelfServiceCallExpression("createSubActionUsage"))
55+
var letNewInstance = this.viewBuilderHelper.newLet()
56+
.variableName(NEW_INSTANCE)
57+
.valueExpression(ServiceMethod.of0(ViewCreateService::createSubActionUsage).aqlSelf())
5658
.children(addToExposedElements.build(), revealOperation.build())
5759
.build();
5860

5961
return builder.name("New Action")
6062
.iconURLsExpression("/icons/full/obj16/ActionUsage.svg")
61-
.body(creationServiceCall)
63+
.body(letNewInstance)
64+
.elementsToSelectExpression(AQLConstants.AQL + NEW_INSTANCE)
6265
.build();
6366
}
6467
}

doc/content/modules/user-manual/pages/release-notes/2026.1.0.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ This applies to: `FeatureTyping`, `Subsetting`, `Redefinition` and `Subclassific
6262
image::release-notes-redundant-feature-typing-message.png[Message displayed when attempting to create a redundant feature typing]
6363

6464
- In diagrams, it is now possible to create a `SatisfyRequirement` from a `PartDefinition` or `PartUsage` graphical node.
65+
- In diagrams, many new tools now automatically select the `Elements` they create or expose on a diagram.
66+
This makes it easy to start editing newly created elements to give them proper names by starting to type directly when the new element appears.
6567

6668
== Technical details
6769

0 commit comments

Comments
 (0)