Skip to content

Commit 5cb5373

Browse files
committed
[1363] Add a menu action that will hide children that don't have children and will reveal the others.
Bug: #1363 Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
1 parent 8e59846 commit 5cb5373

File tree

5 files changed

+116
-1
lines changed

5 files changed

+116
-1
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ All existing SysON _DiagramDescriptions_ (i.g. _General View_, _Interconnection
9494
- https://github.com/eclipse-syson/syson/issues/1346[#1346] [general-view] Improve _direct edit_ tool on `ConstraintUsage` to be able to edit basic expressions.
9595
- https://github.com/eclipse-syson/syson/issues/1310[#1310] [metamodel] Revert remove derived flag for `ViewUsage#exposedElement` feature.
9696
- https://github.com/eclipse-syson/syson/issues/1359[#1359] [export] Implement textual export of `ViewUsage`.
97+
- https://github.com/eclipse-syson/syson/issues/1363[#1363] [general-view] Add a reveal only valued content action on the manage visibility node action modal that will hide children that don't have children and will reveal the others.
9798

9899
=== New features
99100

backend/views/syson-diagram-general-view/src/main/java/org/eclipse/syson/diagram/general/view/services/GeneralViewManageVisibilityNodeActionProvider.java renamed to backend/views/syson-diagram-general-view/src/main/java/org/eclipse/syson/diagram/general/view/services/nodeactions/managevisibility/GeneralViewManageVisibilityNodeActionProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Contributors:
1111
* Obeo - initial API and implementation
1212
*******************************************************************************/
13-
package org.eclipse.syson.diagram.general.view.services;
13+
package org.eclipse.syson.diagram.general.view.services.nodeactions.managevisibility;
1414

1515
import org.eclipse.emf.ecore.EClass;
1616
import org.eclipse.emf.ecore.EObject;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.syson.diagram.general.view.services.nodeactions.managevisibility;
14+
15+
import org.eclipse.sirius.components.collaborative.diagrams.api.nodeactions.IManageVisibilityMenuActionProvider;
16+
import org.eclipse.sirius.components.collaborative.diagrams.dto.managevisibility.ManageVisibilityAction;
17+
import org.eclipse.sirius.components.core.api.IEditingContext;
18+
import org.eclipse.sirius.components.diagrams.IDiagramElement;
19+
import org.eclipse.sirius.components.diagrams.Node;
20+
import org.eclipse.sirius.components.diagrams.description.DiagramDescription;
21+
import org.springframework.stereotype.Service;
22+
23+
import java.util.List;
24+
25+
/**
26+
* Menu action on the manage visibility modal that will reveal children that also have children.
27+
*
28+
* @author mcharfadi
29+
*/
30+
@Service
31+
public class GeneralViewManageVisibilityRevealValuedContentAction implements IManageVisibilityMenuActionProvider {
32+
33+
public static final String ACTION_ID = "manage_visibility_menu_reveal_valued_content_action";
34+
35+
@Override
36+
public boolean canHandle(IEditingContext editingContext, DiagramDescription diagramDescription, IDiagramElement diagramElement) {
37+
return diagramElement instanceof Node node && !node.getChildNodes().isEmpty();
38+
}
39+
40+
@Override
41+
public List<ManageVisibilityAction> handle(IEditingContext editingContext, DiagramDescription diagramDescription, IDiagramElement diagramElement) {
42+
return List.of(new ManageVisibilityAction(ACTION_ID, "Reveal valued content only"));
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.syson.diagram.general.view.services.nodeactions.managevisibility;
14+
15+
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext;
16+
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramQueryService;
17+
import org.eclipse.sirius.components.collaborative.diagrams.api.nodeactions.IManageVisibilityMenuActionHandler;
18+
import org.eclipse.sirius.components.core.api.IEditingContext;
19+
import org.eclipse.sirius.components.diagrams.IDiagramElement;
20+
import org.eclipse.sirius.components.diagrams.Node;
21+
import org.eclipse.sirius.components.diagrams.events.HideDiagramElementEvent;
22+
import org.eclipse.sirius.components.representations.IStatus;
23+
import org.eclipse.sirius.components.representations.Success;
24+
import org.springframework.stereotype.Service;
25+
26+
import java.util.HashSet;
27+
import java.util.Objects;
28+
import java.util.Optional;
29+
import java.util.Set;
30+
31+
/**
32+
* Handler for the menu action on the manage visibility modal that will reveal children that also have children.
33+
*
34+
* @author mcharfadi
35+
*/
36+
@Service
37+
public class GeneralViewManageVisibilityRevealValuedContentHandler implements IManageVisibilityMenuActionHandler {
38+
39+
private final IDiagramQueryService diagramQueryService;
40+
41+
public GeneralViewManageVisibilityRevealValuedContentHandler(IDiagramQueryService diagramQueryService) {
42+
this.diagramQueryService = Objects.requireNonNull(diagramQueryService);
43+
}
44+
45+
@Override
46+
public boolean canHandle(IEditingContext editingContext, IDiagramContext diagramContext, IDiagramElement diagramElement, String actionId) {
47+
return actionId.equals(GeneralViewManageVisibilityRevealValuedContentAction.ACTION_ID);
48+
}
49+
50+
@Override
51+
public IStatus handle(IEditingContext editingContext, IDiagramContext diagramContext, IDiagramElement diagramElement, String actionId) {
52+
Optional<Node> optionalNode = this.diagramQueryService.findNodeById(diagramContext.getDiagram(), diagramElement.getId());
53+
Set<String> nodesToReveal = new HashSet<>();
54+
Set<String> nodesToHide = new HashSet<>();
55+
if (optionalNode.isPresent()) {
56+
optionalNode.get().getChildNodes().forEach(node -> {
57+
if (node.getChildNodes().isEmpty()) {
58+
nodesToHide.add(node.getId());
59+
} else {
60+
nodesToReveal.add(node.getId());
61+
}
62+
});
63+
diagramContext.getDiagramEvents().add(new HideDiagramElementEvent(nodesToReveal, false));
64+
diagramContext.getDiagramEvents().add(new HideDiagramElementEvent(nodesToHide, true));
65+
}
66+
return new Success();
67+
}
68+
69+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ image::view-usage-graphical-contents.png[ViewUsage graphical contents, width=65%
6161

6262
- `ManageVisibility` node action may now be displayed from the _General View_ on `Definition` and `Usage` graphical nodes.
6363
This node action open a modal that can be used to reveal or hide the graphical node children's.
64+
Menu actions can be used to `reveal all content`, `reveal valued content only` or `hide all content`.
6465

6566
image::release-notes-manage-visibility.png[Manage Visibility modal, width=65%,height=65%]
6667

0 commit comments

Comments
 (0)