Skip to content

Commit

Permalink
[571] Add ActionUsage node in Interconnection View
Browse files Browse the repository at this point in the history
Bug: eclipse-syson#571
Signed-off-by: Gwendal Daniel <gwendal.daniel@obeosoft.com>
  • Loading branch information
gdaniel committed Jul 19, 2024
1 parent d62125a commit d5a0976
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The changes are:
- https://github.com/eclipse-syson/syson/issues/557[#557] [state-transition-view] Allow the creation of a StateTransitionView diagram on a _PartUsage_/_PartDefinition_
- https://github.com/eclipse-syson/syson/issues/558[#558] [state-transition-view] Allow the creation of a StateTransitionView diagram on a _StateUsage_/_StateDefinition_
- https://github.com/eclipse-syson/syson/issues/568[#568] [interconnection-view] Simplify Interconnection View implementation and remove duplicated code
- https://github.com/eclipse-syson/syson/issues/571[#571] [interconnection-view] Add ActionUsage node in Interconnection View

=== New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public RepresentationDescription create(IColorProvider colorProvider) {
new FakeNodeDescriptionProvider(colorProvider, this.getDescriptionNameGenerator()),
new RootNodeDescriptionProvider(colorProvider, this.getDescriptionNameGenerator()),
new FirstLevelChildUsageNodeDescriptionProvider(SysmlPackage.eINSTANCE.getPartUsage(), "getPartUsages", colorProvider, this.getDescriptionNameGenerator()),
new FirstLevelChildUsageNodeDescriptionProvider(SysmlPackage.eINSTANCE.getActionUsage(), "getActionUsages", colorProvider, this.getDescriptionNameGenerator()),
new ChildUsageNodeDescriptionProvider(SysmlPackage.eINSTANCE.getPartUsage(), SysmlPackage.eINSTANCE.getUsage_NestedPart(), colorProvider, this.getDescriptionNameGenerator()),
new RootPortUsageBorderNodeDescriptionProvider("getPortUsages", colorProvider, this.getDescriptionNameGenerator()),
new PortUsageBorderNodeDescriptionProvider(colorProvider, this.getDescriptionNameGenerator()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ public NodeDescription create() {
public void link(DiagramDescription diagramDescription, IViewDiagramElementFinder cache) {
var optRootDefinitionNodeDescription = cache.getNodeDescription(this.getName());
var optFirstLevelChildPartUsageNodeDescription = cache.getNodeDescription(this.descriptionNameGenerator.getFirstLevelNodeName(SysmlPackage.eINSTANCE.getPartUsage()));
var optFirstLevelChildActionUsageNodeDescription = cache.getNodeDescription(this.descriptionNameGenerator.getFirstLevelNodeName(SysmlPackage.eINSTANCE.getActionUsage()));
var optRootPortUsageBorderNodeDescription = cache.getNodeDescription(RootPortUsageBorderNodeDescriptionProvider.NAME);

NodeDescription nodeDescription = optRootDefinitionNodeDescription.get();
diagramDescription.getNodeDescriptions().add(nodeDescription);
nodeDescription.getChildrenDescriptions().add(optFirstLevelChildPartUsageNodeDescription.get());
nodeDescription.getChildrenDescriptions().add(optFirstLevelChildActionUsageNodeDescription.get());
nodeDescription.getBorderNodesDescriptions().add(optRootPortUsageBorderNodeDescription.get());
nodeDescription.setPalette(this.createNodePalette(cache));
}
Expand Down Expand Up @@ -156,6 +158,9 @@ private NodeToolSection createNodeToolSection(IViewDiagramElementFinder cache) {
this.toolDescriptionService.createNodeTool(cache.getNodeDescription(this.descriptionNameGenerator.getFirstLevelNodeName(SysmlPackage.eINSTANCE.getPartUsage())).get(),
SysmlPackage.eINSTANCE.getPartUsage(),
NodeContainmentKind.CHILD_NODE),
this.toolDescriptionService.createNodeTool(cache.getNodeDescription(this.descriptionNameGenerator.getFirstLevelNodeName(SysmlPackage.eINSTANCE.getActionUsage())).get(),
SysmlPackage.eINSTANCE.getActionUsage(),
NodeContainmentKind.CHILD_NODE),
this.toolDescriptionService.createNodeTool(portNodeDescription, SysmlPackage.eINSTANCE.getPortUsage(), NodeContainmentKind.BORDER_NODE),
this.toolDescriptionService.createNodeToolWithDirection(portNodeDescription, SysmlPackage.eINSTANCE.getPortUsage(), NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.IN),
this.toolDescriptionService.createNodeToolWithDirection(portNodeDescription, SysmlPackage.eINSTANCE.getPortUsage(), NodeContainmentKind.BORDER_NODE, FeatureDirectionKind.INOUT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.sirius.components.core.api.IObjectService;
import org.eclipse.syson.diagram.common.view.services.ViewNodeService;
import org.eclipse.syson.diagram.interconnection.view.InterconnectionViewDiagramDescriptionProvider;
import org.eclipse.syson.sysml.ActionUsage;
import org.eclipse.syson.sysml.Definition;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.FeatureDirectionKind;
Expand Down Expand Up @@ -77,6 +78,25 @@ public List<PortUsage> getPortUsages(Element element) {
return portUsages;
}

/**
* Returns the {@link ActionUsage} instances contained in the provided {@code element}.
*
* @param element
* the parent element
* @return the {@link ActionUsage} instances contained in the provided {@code element}
*/
public List<ActionUsage> getActionUsages(Element element) {
List<ActionUsage> actionUsages = List.of();
if (element instanceof Usage usage) {
actionUsages = usage.getNestedAction();
} else if (element instanceof Definition definition) {
actionUsages = definition.getOwnedAction();
} else {
this.logger.warn("Cannot get {} from the provided element {}", ActionUsage.class.getSimpleName(), element);
}
return actionUsages;
}

public boolean isInPort(PortUsage portUsage) {
return FeatureDirectionKind.IN.equals(portUsage.getDirection());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ The changes are:
- Allow the creation of a StateTransitionView diagram on a _StateUsage_/_StateDefinition_
- The _InterfaceUsage_ created by the New Interface edge tool in the Interconnection View diagram are now created under closest containing _Definition_/_Package_.
- Simplify the implementation of the Interconnection View diagram and remove duplicated code
- Add action node in Interconnection View diagram

== New features

0 comments on commit d5a0976

Please sign in to comment.