Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
=== New features

- https://github.com/eclipse-syson/syson/issues/1581[#1581] [diagrams] Display inherited `PortUsages` as border nodes in diagrams
- https://github.com/eclipse-syson/syson/issues/1589[#1589] [explorer] Add a filter to hide expose elements in `ViewUsage`

== v2025.10.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@ public void testDirectEditOnViewUsage() {

}

@DisplayName("GIVEN the SysON Explorer View, WHEN hide expose element filter is active, THEN the expose element are not return as tree item")
@Sql(scripts = { ExplorerViewDirectEditTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Test
public void testHideExposeElementFilter() {
var expandedIds = this.getAllTreeItemIds();
var activatedFilters = List.of(SysONTreeFilterProvider.HIDE_ROOT_NAMESPACES_ID, SysONTreeFilterProvider.HIDE_MEMBERSHIPS_TREE_ITEM_FILTER_ID, SysONTreeFilterProvider.HIDE_EXPOSE_ELEMENTS_TREE_ITEM_FILTER_ID);
var treeRepresentationId = this.representationIdBuilder.buildExplorerRepresentationId(this.sysONTreeViewDescriptionProvider.getDescriptionId(), expandedIds, activatedFilters);

var treeEventInput = new ExplorerEventInput(UUID.randomUUID(), ExplorerViewDirectEditTestProjectData.EDITING_CONTEXT_ID, treeRepresentationId);
var treeFlux = this.treeEventSubscriptionRunner.run(treeEventInput);

var hasNoExposeElement = assertRefreshedTreeThat(tree -> assertThat(tree.getChildren()).allSatisfy(this::assertNoExposeChildren));

StepVerifier.create(treeFlux)
.consumeNextWith(hasNoExposeElement)
.thenCancel()
.verify(Duration.ofSeconds(100));

}

private List<String> getAllTreeItemIds() {
var optionalEditingContext = this.editingContextSearchService.findById(ExplorerViewDirectEditTestProjectData.EDITING_CONTEXT_ID)
.filter(IEMFEditingContext.class::isInstance)
Expand Down Expand Up @@ -179,4 +201,17 @@ private Runnable triggerDirectEditTreeItemLabel(String editingContextId, String
assertThat(initialDirectEditLabel).isEqualTo(expectedLabel);
};
}

private void assertNoExposeChildren(TreeItem item) {
if (item == null) {
return;
}
assertThat(item.getKind()).doesNotEndWith("entity=MembershipExpose");
List<TreeItem> children = item.getChildren();
if (children != null) {
for (TreeItem child : children) {
this.assertNoExposeChildren(child);
}
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.syson.tree.explorer.view.filters;

import java.util.List;
import java.util.Objects;

import org.eclipse.sirius.components.representations.VariableManager;
import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerTreeItemAlteredContentProvider;
import org.eclipse.syson.tree.explorer.view.services.api.ISysONExplorerFilterService;
import org.springframework.stereotype.Service;

/**
* An implementation of {@link IExplorerTreeItemAlteredContentProvider} allowing to hide exposed elements tree items from
* Explorer tree.
*
* @author frouene
*/
@Service
public class HideExposeElementsTreeItemAlteredContentProvider implements IExplorerTreeItemAlteredContentProvider {

private final ISysONExplorerFilterService filterService;

public HideExposeElementsTreeItemAlteredContentProvider(ISysONExplorerFilterService filterService) {
this.filterService = Objects.requireNonNull(filterService);
}

@Override
public boolean canHandle(Object object, List<String> activeFilterIds) {
return activeFilterIds.contains(SysONTreeFilterProvider.HIDE_EXPOSE_ELEMENTS_TREE_ITEM_FILTER_ID);
}

@Override
public List<Object> apply(List<Object> computedChildren, VariableManager variableManager) {
return this.filterService.hideExposeElements(computedChildren);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -39,6 +39,8 @@ public class SysONTreeFilterProvider implements ITreeFilterProvider {

public static final String HIDE_ROOT_NAMESPACES_ID = UUID.nameUUIDFromBytes("SysONTreeRootNamespacesFilter".getBytes()).toString();

public static final String HIDE_EXPOSE_ELEMENTS_TREE_ITEM_FILTER_ID = UUID.nameUUIDFromBytes("SysONTreeExposeElementsFilter".getBytes()).toString();

@Override
public List<TreeFilter> get(String editingContextId, TreeDescription treeDescription, String representationId) {
List<TreeFilter> filters = new ArrayList<>();
Expand All @@ -47,6 +49,7 @@ public List<TreeFilter> get(String editingContextId, TreeDescription treeDescrip
filters.add(new TreeFilter(HIDE_SYSML_STANDARD_LIBRARIES_TREE_FILTER_ID, "Hide SysML Standard Libraries", false));
filters.add(new TreeFilter(HIDE_USER_LIBRARIES_TREE_FILTER_ID, "Hide User Libraries", false));
filters.add(new TreeFilter(HIDE_ROOT_NAMESPACES_ID, "Hide Root Namespaces", true));
filters.add(new TreeFilter(HIDE_EXPOSE_ELEMENTS_TREE_ITEM_FILTER_ID, "Hide Expose Elements", true));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I enabled it by default.

return filters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.syson.services.UtilService;
import org.eclipse.syson.services.api.ISysONResourceService;
import org.eclipse.syson.sysml.Expose;
import org.eclipse.syson.sysml.Membership;
import org.eclipse.syson.sysml.Namespace;
import org.eclipse.syson.sysml.util.ElementUtil;
Expand Down Expand Up @@ -106,6 +107,13 @@ public List<Object> hideRootNamespace(List<Object> elements) {
return alteredElements;
}

@Override
public List<Object> hideExposeElements(List<Object> elements) {
return elements.stream()
.filter(element -> !(element instanceof Expose))
.toList();
}

@Override
public List<Object> applyFilters(List<?> elements, List<String> activeFilterIds) {
List<Object> alteredElements = new ArrayList<>(elements);
Expand All @@ -124,6 +132,9 @@ public List<Object> applyFilters(List<?> elements, List<String> activeFilterIds)
if (activeFilterIds.contains(SysONTreeFilterProvider.HIDE_ROOT_NAMESPACES_ID)) {
alteredElements = this.hideRootNamespace(alteredElements);
}
if (activeFilterIds.contains(SysONTreeFilterProvider.HIDE_EXPOSE_ELEMENTS_TREE_ITEM_FILTER_ID)) {
alteredElements = this.hideExposeElements(alteredElements);
}
return alteredElements;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.sirius.components.trees.Tree;
import org.eclipse.sirius.components.trees.description.TreeDescription;
import org.eclipse.syson.services.UtilService;
import org.eclipse.syson.sysml.Expose;
import org.eclipse.syson.sysml.Membership;
import org.eclipse.syson.sysml.Namespace;
import org.eclipse.syson.tree.explorer.view.SysONExplorerTreeDescriptionProvider;
Expand Down Expand Up @@ -150,6 +151,9 @@ private List<Object> applyFilters(List<Object> elements, List<String> activeFilt
if (activeFilterIds.contains(SysONTreeFilterProvider.HIDE_ROOT_NAMESPACES_ID)) {
alteredElements.removeIf(e -> e instanceof Namespace ns && this.utilService.isRootNamespace(ns));
}
if (activeFilterIds.contains(SysONTreeFilterProvider.HIDE_EXPOSE_ELEMENTS_TREE_ITEM_FILTER_ID)) {
alteredElements.removeIf(Expose.class::isInstance);
}
return alteredElements;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -37,5 +37,7 @@ public interface ISysONExplorerFilterService {

List<Object> hideRootNamespace(List<Object> elements);

List<Object> hideExposeElements(List<Object> elements);

List<Object> applyFilters(List<?> elements, List<String> activeFilterIds);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ Ensure the desired tree items are expanded to effectively use the filter and hig
[#filter-explorer]
=== Filter from kind

Three filters are available in the {explorer} to filter element by kind:
Six filters are available in the {explorer} to filter element by kind:

* Hide Memberships,
* Hide {kerml} Standard Libraries,
* Hide {sysml} Standard Libraries.
* Hide Root Namespaces
* Hide User Librairies
* Hide Root Namespaces

These filters allow to clear the {explorer} view.
By hiding the technical elements, only the data directly exploited by the user are displayed, which make the model more readable in the {explorer} view.
Expand All @@ -72,4 +75,4 @@ To filter elements in the {explorer} by their kind using the filter tool:
. Click filter button,
. Select filters to activate.

image::hands-on-filter-element.png[Filter kind]
image::hands-on-filter-element.png[Filter kind]
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

image::gv-inherited-port.png[Inherited port, width=65%,height=65%]

- Add a new filter in the explorer to hide expose elements in `ViewUsage`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update the documentation please?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the list of available filters and updated the image.


image::explorer-hide-expose-element-filter.png[Hide expose element filter, width=65%,height=65%]

== Bug fixes

== Improvements
Expand Down
Loading