Skip to content

Commit

Permalink
[606] Prevent nested part to be rendered as border nodes
Browse files Browse the repository at this point in the history
Bug: eclipse-syson#606
Signed-off-by: Gwendal Daniel <gwendal.daniel@obeosoft.com>
  • Loading branch information
gdaniel authored and AxelRICHARD committed Jul 25, 2024
1 parent efb044a commit f05c631
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The changes are:
- [releng] Add a dependency to CycloneDX to compute the backend software bill of materials during the build

=== Bug fixes
- https://github.com/eclipse-syson/syson/issues/606[#606] [interconnection-view] Prevent nested part to be rendered as border nodes

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.sirius.components.view.diagram.NodeToolSection;
import org.eclipse.syson.sysml.Feature;
import org.eclipse.syson.sysml.FeatureDirectionKind;
import org.eclipse.syson.sysml.FeatureMembership;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.util.AQLUtils;
import org.eclipse.syson.util.IDescriptionNameGenerator;
Expand Down Expand Up @@ -252,32 +253,82 @@ public NodeTool createNodeTool(NodeDescription nodeDescription, EClass eClass) {
/**
* Returns the creation node tool description for the given Node Description to build a new node for the given
* EClass.
* <p>
* This method creates a {@link FeatureMembership}, use
* {@link #createNodeTool(NodeDescription, EClass, EClass, NodeContainmentKind)} to specify the membership type to
* create.
* </p>
*
* @param nodeDescription
* the Node Description where the returned tool is added
* @param eClass
* the EClass that the returned tool is in charge of
* @param nodeKind
* the kind of the node associated to the EClass that is built by the returned tool
* @return the created node tool
*/
public NodeTool createNodeTool(NodeDescription nodeDescription, EClass eClass, NodeContainmentKind nodeKind) {
return this.createNodeToolWithDirection(nodeDescription, eClass, nodeKind, null);
}

/**
* Returns the creation node tool description for the given Node Description to build a new node for the given
* EClass (which must be a {@link Feature}.
* EClass.
*
* @param nodeDescription
* the Node Description where the returned tool is added
* @param eClass
* the EClass that the returned tool is in charge of
* @param membershipEClass
* the EClass of the membership to create
* @param nodeKind
* the kind of the node associated to the EClass that is built by the returned tool
* @return the created node tool
*/
public NodeTool createNodeTool(NodeDescription nodeDescription, EClass eClass, EClass membershipEClass, NodeContainmentKind nodeKind) {
return this.createNodeToolWithDirection(nodeDescription, eClass, membershipEClass, nodeKind, null);
}

/**
* Returns the creation node tool description for the given Node Description to build a new node for the given
* EClass (which must be a {@link Feature}).
* <p>
* This method creates a {@link FeatureMembership}, use
* {@link #createNodeToolWithDirection(NodeDescription, EClass, EClass, NodeContainmentKind, FeatureDirectionKind)}
* to specify the membership type to create.
* </p>
*
* @param nodeDescription
* the Node Description where the returned tool is added
* @param eClass
* the EClass that the returned tool is in charge of
* @param nodeKind
* the kind of the node associated to the EClass that is build by the returned tool
* @param direction
* the feature direction
* @return the created node tool
*/
public NodeTool createNodeToolWithDirection(NodeDescription nodeDescription, EClass eClass, NodeContainmentKind nodeKind, FeatureDirectionKind direction) {
return this.createNodeToolWithDirection(nodeDescription, eClass, SysmlPackage.eINSTANCE.getFeatureMembership(), nodeKind, direction);
}

/**
* Returns the creation node tool description for the given Node Description to build a new node for the given
* EClass (which must be a {@link Feature}).
*
* @param nodeDescription
* the Node Description where the returned tool is added
* @param eClass
* the EClass that the returned tool is in charge of
* @param membershipEClass
* the EClass of the membership to create
* @param nodeKind
* the kind of the node associated to the EClass that is built by the returned tool
* @param direction
* the feature direction
* @return the created node tool
*/
public NodeTool createNodeToolWithDirection(NodeDescription nodeDescription, EClass eClass, EClass membershipEClass, NodeContainmentKind nodeKind, FeatureDirectionKind direction) {
// make sure that the given element is a feature to avoid error at runtime.
if (!SysmlPackage.eINSTANCE.getFeature().isSuperTypeOf(eClass) && direction != null) {
return this.createNodeTool(nodeDescription, eClass, nodeKind);
Expand Down Expand Up @@ -322,7 +373,7 @@ public NodeTool createNodeToolWithDirection(NodeDescription nodeDescription, ECl
.children(createEClassInstance.build(), createView.build());

var createMembership = this.viewBuilderHelper.newCreateInstance()
.typeName(SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getFeatureMembership()))
.typeName(SysMLMetamodelHelper.buildQualifiedName(membershipEClass))
.referenceName(SysmlPackage.eINSTANCE.getElement_OwnedRelationship().getName())
.variableName("newFeatureMembership")
.children(changeContexMembership.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.sirius.components.view.diagram.UserResizableDirection;
import org.eclipse.syson.diagram.common.view.nodes.AbstractNodeDescriptionProvider;
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.SysMLMetamodelHelper;
Expand Down Expand Up @@ -60,7 +59,7 @@ public NodeDescription create() {
.domainType(domainType)
.outsideLabels(this.createOutsideLabelDescription())
.name(this.getName())
.semanticCandidatesExpression(AQLConstants.AQL_SELF + "." + SysmlPackage.eINSTANCE.getUsage_NestedItem().getName())
.semanticCandidatesExpression(AQLUtils.getSelfServiceCallExpression("getParameters"))
.style(this.createItemUnsetNodeStyle())
.conditionalStyles(this.createItemUsageConditionalNodeStyles().toArray(ConditionalNodeStyle[]::new))
.userResizable(UserResizableDirection.NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.syson.diagram.interconnection.view.services;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.sirius.components.core.api.IObjectService;
Expand Down Expand Up @@ -98,6 +99,21 @@ public List<ActionUsage> getActionUsages(Element element) {
return actionUsages;
}

/**
* Returns the parameters of the provided element.
*
* @param element
* the element
* @return the features that are parameters of the provided {@code element}
*/
public List<Feature> getParameters(Element element) {
List<Feature> parameters = new ArrayList<>();
if (element instanceof ActionUsage actionUsage) {
parameters = actionUsage.getParameter();
}
return parameters;
}

public boolean isInFeature(Feature feature) {
return FeatureDirectionKind.IN.equals(feature.getDirection());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ public List<NodeToolSection> caseActionUsage(ActionUsage object) {

NodeDescription itemNodeDescription = this.cache.getNodeDescription(this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getItemUsage())).get();
createSection.getNodeTools().addAll(List.of(
this.toolDescriptionService.createNodeTool(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), NodeContainmentKind.BORDER_NODE),
this.toolDescriptionService.createNodeToolWithDirection(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.IN),
this.toolDescriptionService.createNodeToolWithDirection(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.INOUT),
this.toolDescriptionService.createNodeToolWithDirection(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.OUT)));
this.toolDescriptionService.createNodeTool(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getParameterMembership(),
NodeContainmentKind.BORDER_NODE),
this.toolDescriptionService.createNodeToolWithDirection(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getParameterMembership(),
NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.IN),
this.toolDescriptionService.createNodeToolWithDirection(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getParameterMembership(),
NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.INOUT),
this.toolDescriptionService.createNodeToolWithDirection(itemNodeDescription, SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getParameterMembership(),
NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.OUT)));

createSection.getNodeTools().addAll(this.createToolsForCompartmentItems(object));
createSection.getNodeTools().add(new ActionFlowCompartmentNodeToolProvider().create(null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The changes are:
- Add a dependency to CycloneDX to compute the backend software bill of materials during the build

== Bug fixes
- Prevent nested part to be rendered as border nodes in the Interconnection View diagram


== Improvements

Expand Down

0 comments on commit f05c631

Please sign in to comment.