|
28 | 28 |
|
29 | 29 | import org.eclipse.emf.ecore.EObject; |
30 | 30 | import org.eclipse.emf.ecore.resource.Resource; |
| 31 | +import org.eclipse.emf.ecore.resource.ResourceSet; |
31 | 32 | import org.eclipse.sirius.components.collaborative.dto.CreateChildInput; |
32 | 33 | import org.eclipse.sirius.components.collaborative.dto.CreateChildSuccessPayload; |
33 | 34 | import org.eclipse.sirius.components.core.api.IEditingContextSearchService; |
|
50 | 51 | import org.eclipse.syson.application.data.GeneralViewEmptyTestProjectData; |
51 | 52 | import org.eclipse.syson.application.data.ProjectWithLibraryDependencyContainingLibraryPackageTestProjectData; |
52 | 53 | import org.eclipse.syson.application.data.WithUserLibrariesTestProjectData; |
| 54 | +import org.eclipse.syson.sysml.Element; |
| 55 | +import org.eclipse.syson.sysml.LibraryPackage; |
| 56 | +import org.eclipse.syson.sysml.Namespace; |
| 57 | +import org.eclipse.syson.sysml.SysmlPackage; |
53 | 58 | import org.eclipse.syson.tree.explorer.filters.SysONTreeFilterConstants; |
54 | 59 | import org.eclipse.syson.tree.explorer.fragments.LibrariesDirectory; |
55 | 60 | import org.eclipse.syson.tree.explorer.fragments.UserLibrariesDirectory; |
@@ -405,14 +410,38 @@ private List<String> getAllTreeItemIds(String editingContextId) { |
405 | 410 |
|
406 | 411 | var editingContext = optionalEditingContext.get(); |
407 | 412 | var expandedIds = new ArrayList<String>(); |
408 | | - editingContext.getDomain().getResourceSet().getAllContents().forEachRemaining(notifier -> { |
409 | | - if (notifier instanceof Resource || notifier instanceof EObject) { |
410 | | - expandedIds.add(this.identityService.getId(notifier)); |
411 | | - } |
412 | | - }); |
| 413 | + ResourceSet resourceSet = editingContext.getDomain().getResourceSet(); |
| 414 | + List<Resource> resources = resourceSet.getResources().stream().filter(r -> !this.isStandardLibrary(r)).toList(); |
| 415 | + for (Resource resource : resources) { |
| 416 | + expandedIds.add(this.identityService.getId(resource)); |
| 417 | + resource.getAllContents().forEachRemaining(notifier -> { |
| 418 | + if (notifier instanceof EObject) { |
| 419 | + expandedIds.add(this.identityService.getId(notifier)); |
| 420 | + } |
| 421 | + }); |
| 422 | + } |
413 | 423 | return expandedIds; |
414 | 424 | } |
415 | 425 |
|
| 426 | + private boolean isStandardLibrary(Resource resource) { |
| 427 | + var standardLib = resource.getContents().stream() |
| 428 | + .filter(Namespace.class::isInstance) |
| 429 | + .map(Namespace.class::cast) |
| 430 | + .filter(this::isRootNamespace) |
| 431 | + .flatMap(namespace -> namespace.getOwnedElement().stream()) |
| 432 | + .filter(LibraryPackage.class::isInstance) |
| 433 | + .map(LibraryPackage.class::cast) |
| 434 | + .filter(libraryPackage -> libraryPackage.isIsStandard()) |
| 435 | + .findFirst(); |
| 436 | + return standardLib.isPresent(); |
| 437 | + } |
| 438 | + |
| 439 | + private boolean isRootNamespace(Element element) { |
| 440 | + return element.eClass() == SysmlPackage.eINSTANCE.getNamespace() |
| 441 | + && element.getOwner() == null |
| 442 | + && element.getName() == null; |
| 443 | + } |
| 444 | + |
416 | 445 | private Consumer<Object> getTreeRefreshedEventPayloadMatcher(List<TreeItemMatcher> treeItemMatchers) { |
417 | 446 | return assertRefreshedTreeThat(tree -> { |
418 | 447 | assertThat(treeItemMatchers).allMatch(treeItemMatcher -> { |
|
0 commit comments