Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Now the _end_ keyword is not displayed anymore in the label of these graphical n
- https://github.com/eclipse-syson/syson/issues/2059[#2059] [diagrams] Fix an issue where the _Add existing elements_ tool was not working correctly on the _action flow_ compartment of `ActionUsage` graphical nodes.
- https://github.com/eclipse-syson/syson/issues/2043[#2043] [explorer] Prevent user libraries from being moved to the root of the project when a child is created in it.
- https://github.com/eclipse-syson/syson/issues/2056[#2056] [diagams] Fix the user feedback when dropping an `Element` which is already exposed on a diagram.
- https://github.com/eclipse-syson/syson/issues/2048[#2048] [diagrams] Fix an issue where the non-empty compartments of graphical nodes were being displayed when executing the _Add existing elements_ tool.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ private Flux<DiagramRefreshedEventPayload> givenSubscriptionToDiagram() {
return this.givenDiagramSubscription.subscribe(diagramEventInput);
}


@BeforeEach
public void setUp() {
this.givenInitialServerState.initialize();
Expand All @@ -123,10 +122,9 @@ public void addExistingElementsOnDiagram() {

Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set);

String creationToolId = diagramDescriptionIdProvider.getDiagramCreationToolId("Add existing elements");
assertThat(creationToolId).as("The tool 'Add existing elements' should exist on the diagram").isNotNull();
String addExistingElementsToolId = diagramDescriptionIdProvider.getDiagramCreationToolId("Add existing elements");

Runnable nodeCreationRunner = () -> this.nodeCreationTester.invokeTool(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, diagram, creationToolId);
Runnable nodeCreationRunner = () -> this.nodeCreationTester.invokeTool(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, diagram, addExistingElementsToolId);

Consumer<Object> updatedDiagramConsumer = assertRefreshedDiagramThat(newDiagram -> {
assertThat(newDiagram.getNodes()).as("3 nodes should be visible on the diagram").hasSize(4);
Expand All @@ -147,7 +145,6 @@ public void addExistingElementsOnDiagram() {
.consumeNextWith(updatedDiagramConsumer)
.thenCancel()
.verify(Duration.ofSeconds(10));

}

@GivenSysONServer({ GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH })
Expand All @@ -164,15 +161,13 @@ public void addExistingElementsRecursiveOnDiagram() {
Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set);

String addExistingElementToolId = diagramDescriptionIdProvider.getDiagramCreationToolId("Add existing elements (recursive)");
assertThat(addExistingElementToolId).as("The tool 'Add existing elements (recursive)' should exist on the diagram").isNotNull();

Runnable addExistingElementTool = () -> this.nodeCreationTester.invokeTool(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, diagram, addExistingElementToolId);

Consumer<Object> updatedDiagramConsumer = assertRefreshedDiagramThat(newDiagram -> {
assertThat(newDiagram.getNodes()).as("6 nodes should be visible on the diagram").hasSize(7);
assertThat(newDiagram.getNodes()).as("7 root nodes should be visible on the diagram").hasSize(7);
assertThat(newDiagram.getEdges().stream().filter(e -> ViewModifier.Normal.equals(e.getState())).toList())
.as("3 edges should be visible on the diagram")
.hasSize(3)
.as("3 edges should be visible on the diagram").hasSize(3)
.as("The diagram should contain a composite edge between part2 and part1")
.anyMatch(edge -> edge.getTargetObjectLabel().equals(PART1))
.as("The diagram should contain a composite edge between action1 and action2")
Expand Down Expand Up @@ -340,16 +335,8 @@ private void checkRequirementUsage(Diagram newDiagram) {

assertThat(optRequirementNode).isPresent();
assertThat(optRequirementNode.get().getChildNodes())
.as("Node RequirementUsage should contain 6 children")
.hasSize(8);

var requirementDocCompartment = this.getCompartment(optRequirementNode.get(), "doc");
assertThat(requirementDocCompartment).isPresent();
assertThat(requirementDocCompartment.get())
.as("The doc compartment should be visible")
.matches(node -> !node.getModifiers().contains(ViewModifier.Hidden))
.as("The doc compartment should contain a document item")
.matches(node -> node.getChildNodes().size() == 1);
.as("Node RequirementUsage should contain 8 hidden compartment children").hasSize(8)
.allMatch(node -> node.getModifiers().contains(ViewModifier.Hidden));
}

private Optional<Node> getCompartment(Node node, String compartmentName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void dropPartFromTheExplorer() {
diagramTargetId.set(diagram.getTargetObjectId());
diagramId.set(diagram.getId());
var partNode = new DiagramNavigator(diagram).nodeWithLabel(LabelConstants.OPEN_QUOTE + "part" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "p1").getNode();
assertThat(partNode.getChildNodes().stream().filter(node -> node.getModifiers().contains(ViewModifier.Hidden))).hasSize(9);
assertThat(partNode.getChildNodes().stream().filter(node -> node.getModifiers().contains(ViewModifier.Hidden))).hasSize(10);
partNodeSemanticId.set(partNode.getTargetObjectId());
partNodeId.set(partNode.getId());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,17 @@ public Object infoMessage(Object self, String message) {
}

/**
* Checks if the given node represents the given feature. This especially handle can of feature chain that target inherited member. In such case, the two last segments of the chain should be used
* to find the suitable node.
* Checks if the given node represents the given feature. This especially handle can of feature chain that target
* inherited member. In such case, the two last segments of the chain should be used to find the suitable node.
*
* @param endFeature
* the end feature of a {@link org.eclipse.syson.sysml.ConnectorAsUsage}
* the end feature of a {@link org.eclipse.syson.sysml.ConnectorAsUsage}
* @param nodeToTest
* the node to test
* the node to test
* @param cacheRendering
* the current cache rendering
* the current cache rendering
* @param editingContext
* the editing context
* the editing context
* @return true if the given node is valid source/target for the given node
*/
private boolean isValidConnectionEnd(Feature endFeature, org.eclipse.sirius.components.representations.Element nodeToTest, DiagramRenderingCache cacheRendering,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy;
import org.eclipse.sirius.components.view.diagram.UserResizableDirection;
import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter;
import org.eclipse.syson.diagram.common.view.services.ViewNodeService;
import org.eclipse.syson.diagram.common.view.services.description.ToolDescriptionService;
import org.eclipse.syson.diagram.common.view.tools.CompartmentNodeToolProvider;
import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService;
Expand Down Expand Up @@ -100,6 +101,10 @@ public void link(DiagramDescription diagramDescription, IViewDiagramElementFinde
});
}

protected IDescriptionNameGenerator getDescriptionNameGenerator() {
return this.descriptionNameGenerator;
}

/**
* Implementers should provide the list of {@link NodeDescription} that can be dropped inside this compartment
* {@link NodeDescription}.
Expand Down Expand Up @@ -140,7 +145,9 @@ protected List<INodeToolProvider> getItemCreationToolProviders() {
* <code>false</code> otherwise.
*/
protected String isHiddenByDefaultExpression() {
return AQLUtils.getSelfServiceCallExpression("isHiddenByDefault", "'" + this.eReference.getName() + "'");
return ServiceMethod.of4(ViewNodeService::isHiddenByDefault).aqlSelf(AQLUtils.aqlString(this.getCompartmentName()),
org.eclipse.sirius.components.diagrams.description.NodeDescription.ANCESTORS,
IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT);
}

/**
Expand Down Expand Up @@ -239,10 +246,6 @@ protected DropNodeTool createCompartmentDropFromDiagramTool(IViewDiagramElementF
.build();
}

protected IDescriptionNameGenerator getDescriptionNameGenerator() {
return this.descriptionNameGenerator;
}

protected String getCompartmentLabel() {
String customLabel = this.getCustomCompartmentLabel();
if (customLabel != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public NodeDescription create() {
.defaultWidthExpression(ViewConstants.DEFAULT_NODE_WIDTH)
.domainType(SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getElement()))
.insideLabel(this.createInsideLabelDescription())
.isHiddenByDefaultExpression("aql:true")
.isHiddenByDefaultExpression(this.isHiddenByDefaultExpression())
.name(this.name)
.semanticCandidatesExpression(AQLConstants.AQL_SELF)
.style(this.createCompartmentNodeStyle())
Expand Down Expand Up @@ -162,7 +162,7 @@ protected InsideLabelStyle createInsideLabelStyle() {
.fontSize(12)
.italic(true)
.labelColor(this.colorProvider.getColor(ViewConstants.DEFAULT_LABEL_COLOR))
.showIconExpression("aql:false")
.showIconExpression(AQLConstants.AQL_FALSE)
.withHeader(true)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
import org.eclipse.sirius.components.view.diagram.NodeToolSection;
import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy;
import org.eclipse.sirius.components.view.diagram.UserResizableDirection;
import org.eclipse.syson.diagram.common.view.services.ViewNodeService;
import org.eclipse.syson.diagram.common.view.services.description.ToolConstants;
import org.eclipse.syson.diagram.common.view.tools.ActionFlowCompartmentNodeToolProvider;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.util.AQLConstants;
import org.eclipse.syson.util.AQLUtils;
import org.eclipse.syson.util.IDescriptionNameGenerator;
import org.eclipse.syson.util.ServiceMethod;
import org.eclipse.syson.util.StandardDiagramsConstants;
import org.eclipse.syson.util.SysMLMetamodelHelper;
import org.eclipse.syson.util.ViewConstants;
Expand Down Expand Up @@ -66,6 +68,7 @@ public NodeDescription create() {
.defaultWidthExpression(ViewConstants.DEFAULT_NODE_WIDTH)
.domainType(SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getElement()))
.insideLabel(this.createInsideLabelDescription())
.isHiddenByDefaultExpression(this.isHiddenByDefaultExpression())
.name(this.compartmentName)
.preconditionExpression(
AQLUtils.getSelfServiceCallExpression("isView",
Expand Down Expand Up @@ -162,4 +165,10 @@ protected NodeStyleDescription createCompartmentNodeStyle() {
.childrenLayoutStrategy(this.diagramBuilderHelper.newFreeFormLayoutStrategyDescription().build())
.build();
}

@Override
protected String isHiddenByDefaultExpression() {
return ServiceMethod.of4(ViewNodeService::isHiddenByDefault).aqlSelf(AQLUtils.aqlString(this.compartmentName), org.eclipse.sirius.components.diagrams.description.NodeDescription.ANCESTORS,
IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024, 2025 Obeo.
* Copyright (c) 2024, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -106,7 +106,7 @@ protected InsideLabelStyle createInsideLabelStyle() {
.fontSize(12)
.italic(true)
.labelColor(this.colorProvider.getColor(ViewConstants.DEFAULT_LABEL_COLOR))
.showIconExpression("aql:false")
.showIconExpression(AQLConstants.AQL_FALSE)
.withHeader(true)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext;
import org.eclipse.sirius.components.collaborative.diagrams.DiagramService;
import org.eclipse.sirius.components.collaborative.diagrams.DiagramServices;
Expand Down Expand Up @@ -315,41 +314,38 @@ public Node revealCompartment(Node node, Element targetElement, DiagramContext d
}

/**
* Check if the compartment associated to the given {@link Element} and reference should be hidden by default.
* Check if the compartment associated to the given {@link Element} should be hidden by default.
*
* @param self
* the {@link Element} associated to the compartment node.
* @param referenceName
* the name of the reference associated to the compartment node.
* @param compartmentName
* the name of the compartment to display/hide by default
* @param ancestors
* the list of ancestors of the element (semantic elements corresponding to graphical ancestors). It
* corresponds to a variable accessible from the variable manager.
* @param editingContext
* the {@link IEditingContext} of the element. It corresponds to a variable accessible from the variable
* manager.
* @param diagramContext
* the {@link DiagramContext} of the element. It corresponds to a variable accessible from the variable
* manager.
* @return <code>true</code> if the compartment should be hidden by default, <code>false</code> otherwise
*/
public boolean isHiddenByDefault(Element self, String referenceName) {
public boolean isHiddenByDefault(Element self, String compartmentName, List<Object> ancestors, IEditingContext editingContext, DiagramContext diagramContext) {
boolean isHiddenByDefault = true;
EStructuralFeature eStructuralFeature = self.eClass().getEStructuralFeature(referenceName);
if (eStructuralFeature != null && eStructuralFeature != SysmlPackage.eINSTANCE.getDefinition_OwnedPort()) {
Object referenceValue = self.eGet(eStructuralFeature);
if (referenceValue instanceof List<?> referenceListValue) {
isHiddenByDefault = referenceListValue.isEmpty();
} else {
isHiddenByDefault = referenceValue == null;
// @technical-debt we should find a way to compute this compartment name here and in
// InterconnectionCompartmentNodeDescriptionProvider only once.
if ("GV Compartment interconnection FreeForm".equals(compartmentName)) {
var exposedParts = this.getExposedElements(self, SysmlPackage.eINSTANCE.getPartUsage(), ancestors, editingContext, diagramContext);
var exposedActions = this.getExposedElements(self, SysmlPackage.eINSTANCE.getActionUsage(), ancestors, editingContext, diagramContext);
var exposedSatisfyRequirements = this.getExposedElements(self, SysmlPackage.eINSTANCE.getSatisfyRequirementUsage(), ancestors, editingContext, diagramContext);
if (!exposedParts.isEmpty() || !exposedActions.isEmpty() || !exposedSatisfyRequirements.isEmpty()) {
isHiddenByDefault = false;
}
}
return isHiddenByDefault;
}

/**
* Check if the compartment associated to the given {@link Element} and references should be hidden by default.
*
* @param self
* the {@link Element} associated to the compartment node.
* @param referenceNames
* the name of the references associated to the compartment node.
* @return <code>true</code> if the compartment should be hidden by default, <code>false</code> otherwise
*/
public boolean isHiddenByDefault(Element self, List<String> referenceNames) {
return referenceNames.stream().allMatch(referenceName -> this.isHiddenByDefault(self, referenceName));
}

/**
* Returns {@code true} if {@code parentNodeElement} is an ancestor of {@code childNodeElement}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.syson.diagram.common.view.nodes.AbstractCompartmentNodeDescriptionProvider;
import org.eclipse.syson.diagram.common.view.tools.ConnectionDefinitionEndCompartmentNodeToolProvider;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.util.AQLConstants;
import org.eclipse.syson.util.IDescriptionNameGenerator;

/**
Expand Down Expand Up @@ -51,4 +52,9 @@ protected List<INodeToolProvider> getItemCreationToolProviders() {
creationToolProviders.add(new ConnectionDefinitionEndCompartmentNodeToolProvider());
return creationToolProviders;
}

@Override
protected String isHiddenByDefaultExpression() {
return AQLConstants.AQL_FALSE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.syson.diagram.common.view.nodes.AbstractCompartmentNodeDescriptionProvider;
import org.eclipse.syson.diagram.common.view.tools.ConnectionDefinitionEndCompartmentNodeToolProvider;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.util.AQLConstants;
import org.eclipse.syson.util.IDescriptionNameGenerator;

/**
Expand Down Expand Up @@ -51,4 +52,9 @@ protected List<INodeToolProvider> getItemCreationToolProviders() {
creationToolProviders.add(new ConnectionDefinitionEndCompartmentNodeToolProvider());
return creationToolProviders;
}

@Override
protected String isHiddenByDefaultExpression() {
return AQLConstants.AQL_FALSE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.syson.diagram.common.view.nodes.AbstractCompartmentNodeDescriptionProvider;
import org.eclipse.syson.diagram.common.view.tools.InterfaceDefinitionEndCompartmentNodeToolProvider;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.util.AQLConstants;
import org.eclipse.syson.util.IDescriptionNameGenerator;

/**
Expand Down Expand Up @@ -52,9 +51,4 @@ protected List<INodeToolProvider> getItemCreationToolProviders() {
creationToolProviders.add(new InterfaceDefinitionEndCompartmentNodeToolProvider());
return creationToolProviders;
}

@Override
protected String isHiddenByDefaultExpression() {
return AQLConstants.AQL_TRUE;
}
}
Loading
Loading