Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Disabling the _Hide expression internals_ filter in the _Explorer_ view allows t
- https://github.com/eclipse-syson/syson/issues/2231[#2231] [diagrams] Add a new tool to create a _frame_ `ConcernUsage` from `RequirementUsage` and `RequirementDefinition` graphical nodes.
- https://github.com/eclipse-syson/syson/issues/2231[#2231] [diagrams] Add the support for the _frames_ compartment graphical node in `RequirementUsage` and `RequirementDefinition` graphical nodes.
- https://github.com/eclipse-syson/syson/issues/2235[#2235] [diagrams] Leverage the selection dialog to improve the graphical node tool creating a _frame_ `ConcernUsage` from `RequirementUsage` and `RequirementDefinition` graphical nodes.
- https://github.com/eclipse-syson/syson/issues/2247[#2247] [diagrams] Add the support for creating _timeslices/snapshots_ from the different kind of `OccurrenceDefiniton` graphical nodes.
It leverages the selection dialog to either create an _occurrence timeslice/snapshot_, or the _usage timeslice/snapshot_ matching the `OccurrenceDefinition` on which the tool is applied.

== v2026.5.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,15 @@ private static Stream<Arguments> portionKingNodeParameters() {

private static Stream<Arguments> portionKindSelectionDialogTreeParameters() {
return Stream.of(
Arguments.of(SysmlPackage.eINSTANCE.getAllocationUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.ALLOCATION_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.ALLOCATION_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getInterfaceUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.INTERFACE_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.INTERFACE_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getItemUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.ITEM_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.ITEM_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getOccurrenceUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.OCCURRENCE_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.OCCURRENCE_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getPartUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.PART_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.PART_USAGE_ID)
Arguments.of(SysmlPackage.eINSTANCE.getAllocationDefinition(), SysmlPackage.eINSTANCE.getAllocationUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.ALLOCATION_DEFINITION_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.ALLOCATION_DEFINITION_ID),
Arguments.of(SysmlPackage.eINSTANCE.getAllocationUsage(), SysmlPackage.eINSTANCE.getAllocationUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.ALLOCATION_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.ALLOCATION_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getInterfaceUsage(), SysmlPackage.eINSTANCE.getInterfaceUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.INTERFACE_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.INTERFACE_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getItemDefinition(), SysmlPackage.eINSTANCE.getItemUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.ITEM_DEFINITION_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.ITEM_DEFINITION_ID),
Arguments.of(SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getItemUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.ITEM_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.ITEM_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getOccurrenceDefinition(), SysmlPackage.eINSTANCE.getOccurrenceUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.OCCURRENCE_DEFINITION_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.OCCURRENCE_DEFINITION_ID),
Arguments.of(SysmlPackage.eINSTANCE.getOccurrenceUsage(), SysmlPackage.eINSTANCE.getOccurrenceUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.OCCURRENCE_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.OCCURRENCE_USAGE_ID),
Arguments.of(SysmlPackage.eINSTANCE.getPartDefinition(), SysmlPackage.eINSTANCE.getPartUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.PART_DEFINITION_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.PART_DEFINITION_ID),
Arguments.of(SysmlPackage.eINSTANCE.getPartUsage(), SysmlPackage.eINSTANCE.getPartUsage(), GeneralViewWithTopNodesTestProjectData.GraphicalIds.PART_USAGE_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.PART_USAGE_ID)
).map(TestNameGenerator::namedArguments);
};

Expand Down Expand Up @@ -251,7 +255,7 @@ public void createSnapshotNodeOn(EClass parentEClass, String parentTargetObjectI

@ParameterizedTest
@MethodSource("portionKindSelectionDialogTreeParameters")
public void testCheckAvailableElementsInTimesliceSelectionDialog(EClass elementClass, String graphicalId, String semanticId) {
public void testCheckAvailableElementsInTimesliceSelectionDialog(EClass elementClass, EClass expectedTimesliceEClass, String graphicalId, String semanticId) {
var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID,
SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID);
var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider);
Expand All @@ -264,7 +268,7 @@ public void testCheckAvailableElementsInTimesliceSelectionDialog(EClass elementC
Consumer<Object> initialTreeContentConsumer = assertRefreshedTreeThat(tree -> {
assertThat(tree).isNotNull();
assertThat(tree.getChildren()).size().isEqualTo(1);
assertThat(tree.getChildren().getFirst().getId()).isEqualTo(identityService.getId(elementClass));
assertThat(tree.getChildren().getFirst().getId()).isEqualTo(identityService.getId(expectedTimesliceEClass));
});

StepVerifier.create(flux)
Expand All @@ -275,7 +279,7 @@ public void testCheckAvailableElementsInTimesliceSelectionDialog(EClass elementC

@ParameterizedTest
@MethodSource("portionKindSelectionDialogTreeParameters")
public void testCheckAvailableElementsInSnapshotSelectionDialog(EClass elementClass, String graphicalId, String semanticId) {
public void testCheckAvailableElementsInSnapshotSelectionDialog(EClass elementClass, EClass expectedSnapshotEClass, String graphicalId, String semanticId) {
var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID,
SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID);
var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider);
Expand All @@ -288,7 +292,7 @@ public void testCheckAvailableElementsInSnapshotSelectionDialog(EClass elementCl
Consumer<Object> initialTreeContentConsumer = assertRefreshedTreeThat(tree -> {
assertThat(tree).isNotNull();
assertThat(tree.getChildren()).size().isEqualTo(1);
assertThat(tree.getChildren().getFirst().getId()).isEqualTo(identityService.getId(elementClass));
assertThat(tree.getChildren().getFirst().getId()).isEqualTo(identityService.getId(expectedSnapshotEClass));
});

StepVerifier.create(flux)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public static class GraphicalIds {

public static final String ACTION_USAGE_ID = "61aaf64a-4fbc-356e-ba73-4bd47b386989";

public static final String ALLOCATION_DEFINITION_ID = "304ed5e0-b3e2-3399-b110-8836d4b27127";

public static final String ALLOCATION_USAGE_ID = "361506fb-2a1d-3edc-be2d-8cd60a235f53";

public static final String ATTRIBUTE_USAGE_ID = "7b8e6835-c563-35cd-8991-e2f894fc2139";
Expand All @@ -50,6 +52,8 @@ public static class GraphicalIds {

public static final String PART_USAGE_ID = "4c4fe0d5-4974-377e-9113-9ab022c75f8c";

public static final String OCCURRENCE_DEFINITION_ID = "af3a9437-85c6-3bce-a62e-20aa80f277f4";

public static final String OCCURRENCE_USAGE_ID = "47653014-87d1-3dc6-856b-72454aa93154";

public static final String REQUIREMENT_DEFINITION_ID = "b83f2b54-1602-382d-beb1-c500e08a8684";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.syson.sysml.Documentation;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.Membership;
import org.eclipse.syson.sysml.OccurrenceUsage;
import org.eclipse.syson.sysml.PartUsage;
import org.eclipse.syson.sysml.RequirementUsage;
import org.eclipse.syson.sysml.Type;
Expand Down Expand Up @@ -95,9 +94,9 @@ public Element createSatisfyRequirement(Element self, Element selectedObject) {
}

/**
* {@link MetamodelMutationElementService#createOccurrenceInOccurrence(OccurrenceUsage, EClass)}.
* {@link MetamodelMutationElementService#createOccurrenceInOccurrence(Type, EClass)}.
*/
public EObject createOccurrenceInOccurrence(OccurrenceUsage container, EClass eClass) {
public EObject createOccurrenceInOccurrence(Type container, EClass eClass) {
return this.metamodelElementMutationService.createOccurrenceInOccurrence(container, eClass);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.syson.sysml.InterfaceUsage;
import org.eclipse.syson.sysml.Membership;
import org.eclipse.syson.sysml.Namespace;
import org.eclipse.syson.sysml.OccurrenceDefinition;
import org.eclipse.syson.sysml.OccurrenceUsage;
import org.eclipse.syson.sysml.Package;
import org.eclipse.syson.sysml.PortUsage;
Expand Down Expand Up @@ -212,17 +213,17 @@ public InterfaceUsage createInterfaceUsage(PortUsage source, PortUsage target, E
}

/**
* Creates an instance of {@code eClass} in the given {@link OccurrenceUsage} container.
* <p>It returns {@code null} if the {@code eClass} is not assignable to {@link OccurrenceUsage}</p>
* Creates an instance of {@code eClass} in the given {@link Type} container if it is an {@link OccurrenceUsage} or an {@link OccurrenceDefinition}.
* <p>It returns {@code null} if the {@code eClass} is not assignable to {@link OccurrenceUsage} or the {@code container} is not assignable to either @link OccurrenceUsage} or {@link OccurrenceDefinition}</p>
*
* @param container
* the {@link OccurrenceUsage} container
* the {@link Type} container
* @param eClass
* the {@link EClass} assignable to {@link OccurrenceUsage} to instantiate
* @return a new {@link EClass} instantiated {@link EObject}, {@code null} if the {@code eClass} is not assignable to {@link OccurrenceUsage}
* @return a new {@link EClass} instantiated {@link EObject}, {@code null} if the {@code eClass} is not assignable to {@link OccurrenceUsage} and the {@code container} is not assignable to either {@link OccurrenceUsage} or {@link OccurrenceDefinition}
*/
public EObject createOccurrenceInOccurrence(OccurrenceUsage container, EClass eClass) {
if (SysmlPackage.eINSTANCE.getOccurrenceUsage().isSuperTypeOf(eClass)) {
public EObject createOccurrenceInOccurrence(Type container, EClass eClass) {
if ((container instanceof OccurrenceUsage || container instanceof OccurrenceDefinition) && SysmlPackage.eINSTANCE.getOccurrenceUsage().isSuperTypeOf(eClass)) {
var membership = SysmlFactory.eINSTANCE.createFeatureMembership();
var timeSlice = (OccurrenceUsage) SysmlFactory.eINSTANCE.create(eClass);
membership.getOwnedRelatedElement().add(timeSlice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
import org.eclipse.syson.sysml.ActionDefinition;
import org.eclipse.syson.sysml.ActionUsage;
import org.eclipse.syson.sysml.ActorMembership;
import org.eclipse.syson.sysml.AllocationDefinition;
import org.eclipse.syson.sysml.CaseDefinition;
import org.eclipse.syson.sysml.CaseUsage;
import org.eclipse.syson.sysml.Comment;
import org.eclipse.syson.sysml.ConnectionDefinition;
import org.eclipse.syson.sysml.ConstraintDefinition;
import org.eclipse.syson.sysml.Definition;
import org.eclipse.syson.sysml.Documentation;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.FeatureMembership;
import org.eclipse.syson.sysml.ItemDefinition;
import org.eclipse.syson.sysml.Membership;
import org.eclipse.syson.sysml.ObjectiveMembership;
import org.eclipse.syson.sysml.OwningMembership;
Expand Down Expand Up @@ -425,19 +429,6 @@ public List<Object> getNamespaceImportSelectionDialogElements(IEditingContext ed
* {@link Package}.
*/
public List<? extends Object> getNamespaceImportSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List<String> expandedIds) {
// List<Package> result = new ArrayList<>();
// if (self instanceof Resource resource) {
// resource.getContents().stream()
// .filter(Element.class::isInstance)
// .map(Element.class::cast)
// .forEach(element -> result.addAll(this.findClosestPackageInChildren(element)));
// } else if (self instanceof Package packageElement) {
// packageElement.getOwnedRelationship().stream()
// .filter(Membership.class::isInstance)
// .map(Membership.class::cast)
// .forEach(membership -> result.addAll(this.findClosestPackageInChildren(membership)));
// }
// return result;
return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getPackage()));

}
Expand Down Expand Up @@ -667,6 +658,25 @@ public List<? extends Object> getSelectionDialogChildren(Object selectionDialogT
return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, candidates);
}

/**
* Return the {@code Usage} {@link EClass} corresponding to the given {@link Type}.
*
* @param type
* the type we want the {@code Usage} {@link EClass}
* @return the {@code Usage} {@link EClass} corresponding to the given {@link Type}
*/
public EClass getPortionKindSelectionDialogElement(Type type) {
return switch (type) {
case AllocationDefinition a -> SysmlPackage.eINSTANCE.getAllocationUsage();
case ConnectionDefinition c -> SysmlPackage.eINSTANCE.getConnectionUsage();
case PartDefinition p -> SysmlPackage.eINSTANCE.getPartUsage();
case ConstraintDefinition c -> SysmlPackage.eINSTANCE.getConstraintUsage();
case ItemDefinition i -> SysmlPackage.eINSTANCE.getItemUsage();
case Usage u -> u.eClass();
default -> SysmlPackage.eINSTANCE.getOccurrenceUsage();
};
}

protected List<Object> getAllResourcesWithInstancesOf(IEditingContext editingContext, List<EClassifier> eClassifiers) {
var elementsContainingClassifiers = new ArrayList<>();
List<Object> elements = this.sysONExplorerService.getElements(editingContext, List.of());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription;
import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter;
import org.eclipse.syson.diagram.common.view.services.ViewCreateService;
import org.eclipse.syson.diagram.common.view.services.ViewToolService;
import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService;
import org.eclipse.syson.sysml.PortionKind;
import org.eclipse.syson.sysml.SysmlPackage;
Expand Down Expand Up @@ -104,7 +105,7 @@ private DialogDescription getDescriptionDialog() {

private SelectionDialogTreeDescription getDialogTreeDescriptionDialog() {
return this.diagramBuilderHelper.newSelectionDialogTreeDescription()
.elementsExpression(AQLConstants.AQL_SELF + ".eClass()")
.elementsExpression(ServiceMethod.of0(ViewToolService::getPortionKindSelectionDialogElement).aqlSelf())
.isSelectableExpression(AQLConstants.AQL_TRUE)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription;
import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter;
import org.eclipse.syson.diagram.common.view.services.ViewCreateService;
import org.eclipse.syson.diagram.common.view.services.ViewToolService;
import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService;
import org.eclipse.syson.model.services.aql.ModelMutationAQLService;
import org.eclipse.syson.sysml.PortionKind;
Expand Down Expand Up @@ -105,7 +106,7 @@ private DialogDescription getDescriptionDialog() {

private SelectionDialogTreeDescription getDialogTreeDescriptionDialog() {
return this.diagramBuilderHelper.newSelectionDialogTreeDescription()
.elementsExpression(AQLConstants.AQL_SELF + ".eClass()")
.elementsExpression(ServiceMethod.of0(ViewToolService::getPortionKindSelectionDialogElement).aqlSelf())
.isSelectableExpression(AQLConstants.AQL_TRUE)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ public List<NodeToolSection> caseInterfaceDefinition(InterfaceDefinition object)
@Override
public List<NodeToolSection> caseItemDefinition(ItemDefinition object) {
var sections = this.toolDescriptionService.createDefaultNodeToolSections();
this.toolDescriptionService.addNodeTool(sections, ToolConstants.BEHAVIOR, new OccurrenceUsageTimesliceNodeToolProvider().create(cache));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.BEHAVIOR, new OccurrenceUsageSnapshotNodeToolProvider().create(cache));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.STRUCTURE,
this.toolDescriptionService.createNodeTool(this.getNodeDescription(SysmlPackage.eINSTANCE.getItemUsage()), SysmlPackage.eINSTANCE.getItemUsage()));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.STRUCTURE, this.toolDescriptionService
Expand Down Expand Up @@ -456,6 +458,8 @@ public List<NodeToolSection> caseOccurrenceDefinition(OccurrenceDefinition objec
var sections = this.toolDescriptionService.createDefaultNodeToolSections();
this.toolDescriptionService.addNodeTool(sections, ToolConstants.STRUCTURE,
this.toolDescriptionService.createNodeTool(this.getNodeDescription(SysmlPackage.eINSTANCE.getPartUsage()), SysmlPackage.eINSTANCE.getPartUsage()));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.BEHAVIOR, new OccurrenceUsageTimesliceNodeToolProvider().create(cache));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.BEHAVIOR, new OccurrenceUsageSnapshotNodeToolProvider().create(cache));

this.toolDescriptionService.addNodeTool(sections, ToolConstants.VIEW_AS,
new ViewNodeAsToolProvider(AQLUtils.aqlString(StandardDiagramsConstants.GV_QN), StandardDiagramsConstants.GV).create(this.cache));
Expand Down Expand Up @@ -528,6 +532,8 @@ public List<NodeToolSection> casePartDefinition(PartDefinition object) {
new ExhibitStateNodeToolProvider(false).create(this.cache));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.BEHAVIOR,
new ExhibitStateNodeToolProvider(true).create(this.cache));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.BEHAVIOR, new OccurrenceUsageTimesliceNodeToolProvider().create(cache));
this.toolDescriptionService.addNodeTool(sections, ToolConstants.BEHAVIOR, new OccurrenceUsageSnapshotNodeToolProvider().create(cache));

this.createToolsForCompartmentItems(object, sections, this.cache);

Expand Down
Loading
Loading