Skip to content

Commit

Permalink
[519] Add creation tools for Item on an ActionDefinition in GV/AFV
Browse files Browse the repository at this point in the history
Bug: #519
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
  • Loading branch information
AxelRICHARD committed Jul 11, 2024
1 parent 3d9c6d4 commit 88bf436
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ The tool now works correctly on packages, and doesn't render sibling elements wh
- https://github.com/eclipse-syson/syson/issues/492[#492] [diagrams] Add tools for creation Items with direction
- https://github.com/eclipse-syson/syson/issues/494[#494] [diagrams] Change the default name of the transition element
- [syson] Provide new icons for State, Conjugation, Port (in,in/out,out) and Item (in,in/out,out).
- https://github.com/eclipse-syson/syson/issues/519[#519] [diagrams] Add tools for creating _Items_ on _ActionDefinition_ in GeneralView and ActionFlowView.

=== New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ private static Stream<Arguments> actionUsageListAndFreeFormNodeParameters() {
.map(TestNameGenerator::namedArguments);
}

private static Stream<Arguments> actionDefinitionSiblingNodeParameters() {
return Stream.of(
Arguments.of(SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getDefinition_OwnedItem(), 3))
.map(TestNameGenerator::namedArguments);
}

private static Stream<Arguments> actionDefinitionListAndFreeFormNodeParameters() {
return Stream.of(
Arguments.of(SysmlPackage.eINSTANCE.getAcceptActionUsage(), ACTIONS_COMPARTMENT, SysmlPackage.eINSTANCE.getDefinition_OwnedAction(), 1),
Expand Down Expand Up @@ -1054,6 +1060,36 @@ public void createPerformActionUsageInActionUsage() {
this.checkEditingContext(this.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass));
}

@Sql(scripts = { "/scripts/syson-test-database.sql" }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@ParameterizedTest
@MethodSource("actionDefinitionSiblingNodeParameters")
public void createActionDefinitionSiblingNodes(EClass childEClass, EReference containmentReference, int compartmentCount) {
EClass parentEClass = SysmlPackage.eINSTANCE.getActionDefinition();
String parentLabel = "ActionDefinition";
this.createNode(parentEClass, parentLabel, childEClass);
final IDiagramChecker diagramChecker;
if (SysmlPackage.eINSTANCE.getItemUsage().equals(childEClass)) {
diagramChecker = (initialDiagram, newDiagram) -> {
int createdNodesExpectedCount = 2 + compartmentCount;
new CheckDiagramElementCount(this.diagramComparator)
.hasNewNodeCount(createdNodesExpectedCount)
.hasNewEdgeCount(1)
.check(initialDiagram, newDiagram);

String newNodeDescriptionName = this.descriptionNameGenerator.getNodeName(childEClass);
new CheckNodeOnDiagram(this.diagramDescriptionIdProvider, this.diagramComparator)
.hasNodeDescriptionName(newNodeDescriptionName)
.hasCompartmentCount(compartmentCount)
.check(initialDiagram, newDiagram);
};
} else {
diagramChecker = this.getSiblingNodeGraphicalChecker(childEClass, compartmentCount);
}
this.checkDiagram(diagramChecker);
this.checkEditingContext(this.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass));
}

@Sql(scripts = { "/scripts/syson-test-database.sql" }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ public class ActionFlowViewDiagramDescriptionProvider implements IRepresentation
);

public static final Map<EClass, List<EReference>> COMPARTMENTS_WITH_LIST_ITEMS = Map.ofEntries(
Map.entry(SysmlPackage.eINSTANCE.getAcceptActionUsage(), List.of(SysmlPackage.eINSTANCE.getElement_Documentation())),
Map.entry(SysmlPackage.eINSTANCE.getActionDefinition(), List.of(SysmlPackage.eINSTANCE.getElement_Documentation(), SysmlPackage.eINSTANCE.getDefinition_OwnedAction())),
Map.entry(SysmlPackage.eINSTANCE.getActionUsage(), List.of(SysmlPackage.eINSTANCE.getElement_Documentation(), SysmlPackage.eINSTANCE.getUsage_NestedItem(), SysmlPackage.eINSTANCE.getUsage_NestedAction())),
Map.entry(SysmlPackage.eINSTANCE.getPerformActionUsage(),
List.of(SysmlPackage.eINSTANCE.getElement_Documentation(), SysmlPackage.eINSTANCE.getUsage_NestedItem(), SysmlPackage.eINSTANCE.getUsage_NestedAction()))
Map.entry(SysmlPackage.eINSTANCE.getAcceptActionUsage(), List.of(SysmlPackage.eINSTANCE.getElement_Documentation())),
Map.entry(SysmlPackage.eINSTANCE.getActionDefinition(), List.of(SysmlPackage.eINSTANCE.getElement_Documentation(), SysmlPackage.eINSTANCE.getDefinition_OwnedItem(), SysmlPackage.eINSTANCE.getDefinition_OwnedAction())),
Map.entry(SysmlPackage.eINSTANCE.getActionUsage(), List.of(SysmlPackage.eINSTANCE.getElement_Documentation(), SysmlPackage.eINSTANCE.getUsage_NestedItem(), SysmlPackage.eINSTANCE.getUsage_NestedAction())),
Map.entry(SysmlPackage.eINSTANCE.getPerformActionUsage(), List.of(SysmlPackage.eINSTANCE.getElement_Documentation(), SysmlPackage.eINSTANCE.getUsage_NestedItem(), SysmlPackage.eINSTANCE.getUsage_NestedAction()))
);

public static final List<ToolSectionDescription> TOOL_SECTIONS = List.of(
Expand Down Expand Up @@ -164,8 +163,7 @@ public RepresentationDescription create(IColorProvider colorProvider) {
});
});

diagramElementDescriptionProviders.stream().map(IDiagramElementDescriptionProvider::create)
.forEach(cache::put);
diagramElementDescriptionProviders.stream().map(IDiagramElementDescriptionProvider::create).forEach(cache::put);
diagramElementDescriptionProviders.forEach(diagramElementDescriptionProvider -> diagramElementDescriptionProvider.link(diagramDescription, cache));

diagramDescription.setPalette(this.createDiagramPalette(cache));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public List<NodeToolSection> caseActionDefinition(ActionDefinition object) {
new AssignmentActionNodeToolProvider(SysmlPackage.eINSTANCE.getActionDefinition(), this.descriptionNameGenerator).create(this.cache),
new ReferencingPerformActionNodeToolProvider(SysmlPackage.eINSTANCE.getActionDefinition(), this.descriptionNameGenerator).create(this.cache),
new PerformActionNodeToolProvider(SysmlPackage.eINSTANCE.getActionDefinition(), this.descriptionNameGenerator).create(this.cache));
createSection.getNodeTools().addAll(this.createToolsForCompartmentItem(SysmlPackage.eINSTANCE.getDefinition_OwnedItem()));
return List.of(createSection, this.toolDescriptionService.addElementsNodeToolSection(true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,17 @@ public List<NodeToolSection> caseActionDefinition(ActionDefinition object) {
// StateDefinition has its own "action" creation tools
createSection.getNodeTools().add(new ActionFlowCompartmentNodeToolProvider(SysmlPackage.eINSTANCE.getActionDefinition(), this.descriptionNameGenerator).create(null));
}

createSection.getNodeTools().add(new CompartmentNodeToolProvider(SysmlPackage.eINSTANCE.getElement_Documentation(), this.descriptionNameGenerator).create(null));

createSection.getNodeTools().add(this.toolDescriptionService.createNodeTool(this.getNodeDescription(SysmlPackage.eINSTANCE.getItemUsage()), SysmlPackage.eINSTANCE.getItemUsage()));
createSection.getNodeTools().add(this.toolDescriptionService.createNodeToolWithDirection(this.getNodeDescription(SysmlPackage.eINSTANCE.getItemUsage()), SysmlPackage.eINSTANCE.getItemUsage(),
NodeContainmentKind.CHILD_NODE, FeatureDirectionKind.IN));
createSection.getNodeTools().add(this.toolDescriptionService.createNodeToolWithDirection(this.getNodeDescription(SysmlPackage.eINSTANCE.getItemUsage()), SysmlPackage.eINSTANCE.getItemUsage(),
NodeContainmentKind.CHILD_NODE, FeatureDirectionKind.INOUT));
createSection.getNodeTools().add(this.toolDescriptionService.createNodeToolWithDirection(this.getNodeDescription(SysmlPackage.eINSTANCE.getItemUsage()), SysmlPackage.eINSTANCE.getItemUsage(),
NodeContainmentKind.CHILD_NODE, FeatureDirectionKind.OUT));

return List.of(createSection, this.toolDescriptionService.addElementsNodeToolSection(true));
}

Expand Down

0 comments on commit 88bf436

Please sign in to comment.