Skip to content

Commit 9c82a0a

Browse files
flatombeAxelRICHARD
authored andcommitted
[960] Display possible 'actor' PartUsages in a tree
In the General View diagram, the creation tool for ActorParameter now shows possible candidate PartUsages in a tree instead of a flat list. Bug: #960 Signed-off-by: Florent Latombe <florent.latombe@obeo.fr>
1 parent 80781d4 commit 9c82a0a

File tree

6 files changed

+49
-29
lines changed

6 files changed

+49
-29
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The changes are:
4747
- https://github.com/eclipse-syson/syson/issues/946[#946] [libraries] All standard libraries have been updated to comply with the SysML Beta 2.3 specification.
4848
- https://github.com/eclipse-syson/syson/issues/982[#982] [metamodel] `Membership#isDistinguishableFrom` derived attribute has been implemented.
4949
- https://github.com/eclipse-syson/syson/issues/992[#992] [export] Implement SysML export of `ConcernDefinition`, `ConcernUsage` and `StakeholderMembership`
50-
- https://github.com/eclipse-syson/syson/issues/960[#960] [general-view] In the selection dialog of the creation tool for 'StakeholderParameter', display possible PartUsage candidates in a tree instead of a list.
50+
- https://github.com/eclipse-syson/syson/issues/960[#960] [general-view] In the selection dialog of the creation tools for `Stakeholders` and `Actors`, display possible `Part Usage` candidates in a tree instead of a list.
5151

5252
=== New features
5353

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewNodeService.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2024, 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -246,15 +246,6 @@ public List<Element> getAllReachableRequirements(EObject eObject) {
246246
.toList();
247247
}
248248

249-
public List<Element> getAllReachableItems(EObject eObject) {
250-
List<EObject> allItemUsage = this.utilService.getAllReachable(eObject, SysmlPackage.eINSTANCE.getItemUsage(), false);
251-
List<EObject> allItemDefinition = this.utilService.getAllReachable(eObject, SysmlPackage.eINSTANCE.getItemDefinition(), false);
252-
return Stream.concat(allItemUsage.stream(), allItemDefinition.stream())
253-
.filter(Element.class::isInstance)
254-
.map(Element.class::cast)
255-
.toList();
256-
}
257-
258249
/**
259250
* Returns {@code true} if the provided {@code element} is an actor, {@code false} otherwise.
260251
* <p>
@@ -302,7 +293,7 @@ private boolean isReferencingPerformActionUsage(PerformActionUsage pau) {
302293
// the given PerformActionUsage is a referencing PerformActionUsage if it contains a reference subsetting
303294
// pointing to an action.
304295
ReferenceSubsetting referenceSubSetting = pau.getOwnedReferenceSubsetting();
305-
return referenceSubSetting != null && referenceSubSetting.getReferencedFeature() instanceof ActionUsage perfomedAction;
296+
return referenceSubSetting != null && referenceSubSetting.getReferencedFeature() instanceof ActionUsage;
306297
}
307298

308299
private Node getOneMatchingAnnotatedNodes(Node node, EList<Element> annotatedElements, IDiagramContext diagramContext, IEditingContext editingContext) {

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,10 @@ public List<Resource> getNamespaceImportSelectionDialogElements(IEditingContext
11321132
.map(IEMFEditingContext::getDomain)
11331133
.map(EditingDomain::getResourceSet);
11341134
var resources = optionalResourceSet.map(resourceSet -> resourceSet.getResources().stream()
1135-
.filter(resource -> containsDirectlyOrIndirectlyInstancesOf(resource, SysmlPackage.eINSTANCE.getPackage()))
1135+
.filter(resource -> this.containsDirectlyOrIndirectlyInstancesOf(resource, SysmlPackage.eINSTANCE.getPackage()))
11361136
.toList())
11371137
.orElseGet(ArrayList::new);
1138-
return resources.stream().sorted((r1, r2) -> getResourceName(r1).compareTo(getResourceName(r2))).toList();
1138+
return resources.stream().sorted((r1, r2) -> this.getResourceName(r1).compareTo(this.getResourceName(r2))).toList();
11391139
}
11401140

11411141
/**
@@ -1161,7 +1161,7 @@ public List<Package> getNamespaceImportSelectionDialogChildren(Object self) {
11611161
return result;
11621162
}
11631163

1164-
private static boolean containsDirectlyOrIndirectlyInstancesOf(Resource resource, EClassifier eClassifier) {
1164+
private boolean containsDirectlyOrIndirectlyInstancesOf(Resource resource, EClassifier eClassifier) {
11651165
boolean found = false;
11661166
final Iterator<EObject> allContents = resource.getAllContents();
11671167
while (!found && allContents.hasNext()) {
@@ -1170,7 +1170,7 @@ private static boolean containsDirectlyOrIndirectlyInstancesOf(Resource resource
11701170
return found;
11711171
}
11721172

1173-
private static boolean containsDirectlyOrIndirectlyInstancesOf(EObject eObject, EClassifier eClassifier) {
1173+
private boolean containsDirectlyOrIndirectlyInstancesOf(EObject eObject, EClassifier eClassifier) {
11741174
boolean found = false;
11751175
final Iterator<EObject> allContents = eObject.eAllContents();
11761176
while (!found && allContents.hasNext()) {
@@ -1179,7 +1179,7 @@ private static boolean containsDirectlyOrIndirectlyInstancesOf(EObject eObject,
11791179
return found;
11801180
}
11811181

1182-
private static String getResourceName(Resource resource) {
1182+
private String getResourceName(Resource resource) {
11831183
return resource.eAdapters().stream()
11841184
.filter(ResourceMetadataAdapter.class::isInstance)
11851185
.map(ResourceMetadataAdapter.class::cast)
@@ -1212,7 +1212,7 @@ private List<Package> findClosestPackageInChildren(Element element) {
12121212
* @return the (non-{@code null}) {@link List} of all {@link Resource} that contain at least one {@link PartUsage}.
12131213
*/
12141214
public List<Resource> getStakeholderSelectionDialogElements(IEditingContext editingContext) {
1215-
return getAllResourcesWithInstancesOf(editingContext, SysmlPackage.eINSTANCE.getPartUsage());
1215+
return this.getAllResourcesWithInstancesOf(editingContext, SysmlPackage.eINSTANCE.getPartUsage());
12161216
}
12171217

12181218
/**
@@ -1224,10 +1224,33 @@ public List<Resource> getStakeholderSelectionDialogElements(IEditingContext edit
12241224
* {@link PartUsage}.
12251225
*/
12261226
public List<? extends Object> getStakeholderSelectionDialogChildren(Object selectionDialogTreeElement) {
1227-
return getChildrenWithInstancesOf(selectionDialogTreeElement, SysmlPackage.eINSTANCE.getPartUsage());
1227+
return this.getChildrenWithInstancesOf(selectionDialogTreeElement, SysmlPackage.eINSTANCE.getPartUsage());
12281228
}
12291229

1230-
private static List<Resource> getAllResourcesWithInstancesOf(IEditingContext editingContext, EClassifier eClassifier) {
1230+
/**
1231+
* Provides the root elements in the tree of the selection dialog for the ActorParameter creation tool.
1232+
*
1233+
* @param editingContext
1234+
* the (non-{@code null}) {@link IEditingContext}.
1235+
* @return the (non-{@code null}) {@link List} of all {@link Resource} that contain at least one {@link PartUsage}.
1236+
*/
1237+
public List<Resource> getActorSelectionDialogElements(IEditingContext editingContext) {
1238+
return this.getAllResourcesWithInstancesOf(editingContext, SysmlPackage.eINSTANCE.getPartUsage());
1239+
}
1240+
1241+
/**
1242+
* Provides the children of element in the tree of the selection dialog for the ActorParameter creation tool.
1243+
*
1244+
* @param selectionDialogTreeElement
1245+
* a (non-{@code null}) selection dialog tree element.
1246+
* @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) or are
1247+
* {@link PartUsage}.
1248+
*/
1249+
public List<? extends Object> getActorSelectionDialogChildren(Object selectionDialogTreeElement) {
1250+
return this.getChildrenWithInstancesOf(selectionDialogTreeElement, SysmlPackage.eINSTANCE.getPartUsage());
1251+
}
1252+
1253+
private List<Resource> getAllResourcesWithInstancesOf(IEditingContext editingContext, EClassifier eClassifier) {
12311254
Objects.requireNonNull(editingContext);
12321255

12331256
var maybeResourceSet = Optional.of(editingContext)
@@ -1236,26 +1259,26 @@ private static List<Resource> getAllResourcesWithInstancesOf(IEditingContext edi
12361259
.map(IEMFEditingContext::getDomain)
12371260
.map(EditingDomain::getResourceSet);
12381261
var resourcesContainingPartUsage = maybeResourceSet.map(resourceSet -> resourceSet.getResources().stream()
1239-
.filter(resource -> containsDirectlyOrIndirectlyInstancesOf(resource, eClassifier))
1262+
.filter(resource -> this.containsDirectlyOrIndirectlyInstancesOf(resource, eClassifier))
12401263
.toList())
12411264
.orElseGet(ArrayList::new);
1242-
return resourcesContainingPartUsage.stream().sorted(Comparator.comparing(ViewToolService::getResourceName)).toList();
1265+
return resourcesContainingPartUsage.stream().sorted(Comparator.comparing(r -> this.getResourceName(r))).toList();
12431266
}
12441267

1245-
private static List<? extends Object> getChildrenWithInstancesOf(Object selectionDialogTreeElement, EClassifier eClassifier) {
1268+
private List<? extends Object> getChildrenWithInstancesOf(Object selectionDialogTreeElement, EClassifier eClassifier) {
12461269
Objects.requireNonNull(selectionDialogTreeElement);
12471270

12481271
final List<? extends Object> result;
12491272

12501273
if (selectionDialogTreeElement instanceof Resource resource) {
12511274
result = resource.getContents().stream()
1252-
.filter(content -> eClassifier.isInstance(content) || containsDirectlyOrIndirectlyInstancesOf(content, eClassifier)).toList();
1275+
.filter(content -> eClassifier.isInstance(content) || this.containsDirectlyOrIndirectlyInstancesOf(content, eClassifier)).toList();
12531276
} else if (selectionDialogTreeElement instanceof Element sysmlElement) {
12541277
return sysmlElement.getOwnedRelationship().stream()
12551278
.filter(Membership.class::isInstance)
12561279
.map(Membership.class::cast)
12571280
.map(Membership::getOwnedRelatedElement).flatMap(List::stream)
1258-
.filter(content -> eClassifier.isInstance(content) || containsDirectlyOrIndirectlyInstancesOf(content, eClassifier)).toList();
1281+
.filter(content -> eClassifier.isInstance(content) || this.containsDirectlyOrIndirectlyInstancesOf(content, eClassifier)).toList();
12591282
} else {
12601283
result = new ArrayList<>();
12611284
}

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ActorCompartmentNodeToolProvider.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -30,11 +30,13 @@ protected String getServiceCallExpression() {
3030
@Override
3131
protected SelectionDialogDescription getSelectionDialogDescription() {
3232
var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription()
33-
.elementsExpression(AQLUtils.getSelfServiceCallExpression("getAllReachableItems"))
33+
.elementsExpression(AQLUtils.getServiceCallExpression("editingContext", "getActorSelectionDialogElements"))
34+
.childrenExpression(AQLUtils.getSelfServiceCallExpression("getActorSelectionDialogChildren"))
35+
.isSelectableExpression("aql:self.oclIsKindOf(sysml::PartUsage)")
3436
.build();
3537
return this.diagramBuilderHelper.newSelectionDialogDescription()
3638
.selectionDialogTreeDescription(selectionDialogTree)
37-
.selectionMessage("Select an existing Item as actor:")
39+
.selectionMessage("Select an existing Part as actor:")
3840
.build();
3941
}
4042

39.2 KB
Loading

doc/content/modules/user-manual/pages/release-notes/2025.2.0.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ image::release-notes-gv-concern-usage.png[Concern Usage node creation tool, widt
8989

9090
image::release-notes-gv-stakeholders.png['stakeholders' compartment, width=50%, height=50%]
9191

92-
- In the `General View` diagram, the stakeholder creation tool displays available `Part Usage` in a tree instead of a list.
92+
- In the `General View` diagram, the stakeholder creation tool displays available `Part Usages` in a tree instead of a list.
9393

9494
image::release-notes-gv-stakeholder-creation-selection-dialog-tree.png['stakeholder creation tool selection dialog tree' compartment, width=50%, height=50%]
9595

96+
- In the `General View` diagram, the actor creation tool displays available `Part Usages` in a tree instead of a list.
97+
98+
image::release-notes-gv-actor-creation-selection-dialog-tree.png['actor creation tool selection dialog tree' compartment, width=50%, height=50%]
99+
96100
- Prevent the edition of imported user libraries from the details view.
97101
- Align metamodel to SysMLv2 and KerML Beta 2.3 specifications.
98102
The changes are:

0 commit comments

Comments
 (0)