Skip to content

Commit

Permalink
[680] Add "Show/Hide Diagrams Inherited Members from Standard Libraries"
Browse files Browse the repository at this point in the history
Add "Show/Hide Diagrams Inherited Members from Standard Libraries"
action in Diagram Panel

Bug: #680
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
  • Loading branch information
AxelRICHARD committed Aug 28, 2024
1 parent d16a615 commit b93c8f1
Show file tree
Hide file tree
Showing 22 changed files with 699 additions and 48 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ A new edge tool allows to create a flow between two ports.
- https://github.com/eclipse-syson/syson/issues/615[#615] [details] Add documentation property to Core tab of the Details view.
- https://github.com/eclipse-syson/syson/issues/626[#626] [explorer] Allow to insert textual SysMLv2 from existing model elements.
- https://github.com/eclipse-syson/syson/issues/466[#466] [syson] Handle implicit specializations from standard libraries for Usages/Definitions.
- https://github.com/eclipse-syson/syson/issues/667[#667] [diagrams] Add "Show/Hide Inherited Members in Diagrams" action in Diagram Panel, allowing to show/hide inherited members in diagrams.
- https://github.com/eclipse-syson/syson/issues/667[#667] [diagrams] Add "Show/Hide Inherited Members in Diagrams" action in Diagram Panel, allowing to show/hide inherited members from users models in diagrams.
- https://github.com/eclipse-syson/syson/issues/680[#680] [diagrams] Add "Show/Hide Inherited Members from Standard Libraries in Diagrams" action in Diagram Panel, allowing to show/hide inherited members from standard libraries in diagrams.

== v2024.7.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ org.eclipse.syson.show.diagrams.icons=true
# SYSON OPTION FOR DISPLAYING INHERITED MEMBERS ON DIAGRAMS
#
##################################################
org.eclipse.syson.show.diagrams.inherited.members=false
org.eclipse.syson.show.diagrams.inherited.members=true
org.eclipse.syson.show.diagrams.inherited.members.from.standard.libraries=false

##################################################
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,32 @@
import org.springframework.stereotype.Service;

/**
* Service class for ShowDiagramsInheritedMembers option.
* Service class for ShowDiagramsInheritedMembers options.
*
* @author arichard
*/
@Service
public class ShowDiagramsInheritedMembersService {

@Value("${org.eclipse.syson.show.diagrams.inherited.members:false}")
@Value("${org.eclipse.syson.show.diagrams.inherited.members:true}")
private boolean showInheritedMembers;

@Value("${org.eclipse.syson.show.diagrams.inherited.members.from.standard.libraries:false}")
private boolean showInheritedMembersFromStandardLibraries;

public boolean getShowInheritedMembers() {
return this.showInheritedMembers;
}

public void setShowInheritedMembers(boolean showInheritedMembers) {
this.showInheritedMembers = showInheritedMembers;
}

public boolean getShowInheritedMembers() {
return this.showInheritedMembers;
public boolean getShowInheritedMembersFromStandardLibraries() {
return this.showInheritedMembersFromStandardLibraries;
}

public void setShowInheritedMembersFromStandardLibraries(boolean showInheritedMembersFromStandardLibraries) {
this.showInheritedMembersFromStandardLibraries = showInheritedMembersFromStandardLibraries;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.eclipse.syson.sysml.Usage;
import org.eclipse.syson.sysml.UseCaseDefinition;
import org.eclipse.syson.sysml.UseCaseUsage;
import org.eclipse.syson.sysml.util.ElementUtil;

/**
* Creation-related Java shared services used by several diagrams.
Expand Down Expand Up @@ -471,7 +472,10 @@ private Element getSourceOwner(Node sourceNode, IEditingContext editingContext,
}

public List<Feature> getInheritedCompartmentItems(Type type, String eReferenceName) {
if (!this.showDiagramsInheritedMembersService.getShowInheritedMembers()) {
boolean showInheritedMembers = this.showDiagramsInheritedMembersService.getShowInheritedMembers();
boolean showInheritedMembersFromStandardLibraries = this.showDiagramsInheritedMembersService.getShowInheritedMembersFromStandardLibraries();

if (!showInheritedMembers && !showInheritedMembersFromStandardLibraries) {
return List.of();
}

Expand All @@ -494,6 +498,12 @@ public List<Feature> getInheritedCompartmentItems(Type type, String eReferenceNa
.forEach(alreadySpecializedFeatures::add);
inheritedElements.removeAll(alreadySpecializedFeatures);
inheritedElements.remove(type);

if (showInheritedMembers && !showInheritedMembersFromStandardLibraries) {
inheritedElements.removeIf(elt -> ElementUtil.isFromStandardLibrary(elt));
} else if (showInheritedMembersFromStandardLibraries && !showInheritedMembers) {
inheritedElements.removeIf(elt -> !ElementUtil.isFromStandardLibrary(elt));
}
return inheritedElements;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 2024 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.diagram.common.view.services.datafetchers;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Objects;
import java.util.concurrent.CompletableFuture;

import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher;
import org.eclipse.sirius.components.core.api.IPayload;
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates;
import org.eclipse.sirius.components.graphql.api.IEditingContextDispatcher;
import org.eclipse.sirius.components.graphql.api.IExceptionWrapper;
import org.eclipse.syson.diagram.common.view.services.dto.ShowDiagramsInheritedMembersFromStandardLibrariesInput;

import graphql.schema.DataFetchingEnvironment;

/**
* Data fetcher for the field Mutation#showDiagramsInheritedMembersFromStandardLibraries.
*
* @author arichard
*/
@QueryDataFetcher(type = "Mutation", field = "showDiagramsInheritedMembersFromStandardLibraries")
public class MutationShowDiagramsInheritedMembersFromStandardLibrariesDataFetcher implements IDataFetcherWithFieldCoordinates<CompletableFuture<IPayload>> {

private static final String INPUT_ARGUMENT = "input";

private final ObjectMapper objectMapper;

private final IExceptionWrapper exceptionWrapper;

private final IEditingContextDispatcher editingContextDispatcher;

public MutationShowDiagramsInheritedMembersFromStandardLibrariesDataFetcher(ObjectMapper objectMapper, IExceptionWrapper exceptionWrapper, IEditingContextDispatcher editingContextDispatcher) {
this.objectMapper = Objects.requireNonNull(objectMapper);
this.exceptionWrapper = Objects.requireNonNull(exceptionWrapper);
this.editingContextDispatcher = Objects.requireNonNull(editingContextDispatcher);
}

@Override
public CompletableFuture<IPayload> get(DataFetchingEnvironment environment) throws Exception {
Object argument = environment.getArgument(INPUT_ARGUMENT);
var input = this.objectMapper.convertValue(argument, ShowDiagramsInheritedMembersFromStandardLibrariesInput.class);

return this.exceptionWrapper.wrapMono(() -> this.editingContextDispatcher.dispatchMutation(input.editingContextId(), input), input).toFuture();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2024 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.diagram.common.view.services.datafetchers;

import java.util.Objects;

import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher;
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates;
import org.eclipse.syson.diagram.common.view.services.ShowDiagramsInheritedMembersService;

import graphql.schema.DataFetchingEnvironment;

/**
* Data fetcher for Viewer#showDiagramsInheritedMembers query.
*
* @author arichard
*/
@QueryDataFetcher(type = "Viewer", field = "showDiagramsInheritedMembersFromStandardLibrariesValue")
public class ShowDiagramsInheritedMembersFromStandardLibrariesDataFetcher implements IDataFetcherWithFieldCoordinates<Boolean> {

private final ShowDiagramsInheritedMembersService showDiagramsInheritedMembersService;

public ShowDiagramsInheritedMembersFromStandardLibrariesDataFetcher(ShowDiagramsInheritedMembersService showDiagramsInheritedMembersService) {
this.showDiagramsInheritedMembersService = Objects.requireNonNull(showDiagramsInheritedMembersService);
}

@Override
public Boolean get(DataFetchingEnvironment environment) throws Exception {
return Boolean.valueOf(this.showDiagramsInheritedMembersService.getShowInheritedMembersFromStandardLibraries());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2024 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.diagram.common.view.services.dto;

import java.util.UUID;

import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput;

/**
* The input object of the show diagrams inherited members from standard libraries mutation.
*
* @author arichard
*/
public record ShowDiagramsInheritedMembersFromStandardLibrariesInput(UUID id, String editingContextId, String representationId, boolean show) implements IDiagramInput {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2024 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.diagram.common.view.services.dto;

import java.util.Objects;
import java.util.UUID;

import org.eclipse.sirius.components.core.api.IPayload;

/**
* The payload of the show diagrams inherited members from standard libraries mutation.
*
* @author arichard
*/
public record ShowDiagramsInheritedMembersFromStandardLibrariesSuccessPayload(UUID id, boolean show) implements IPayload {

public ShowDiagramsInheritedMembersFromStandardLibrariesSuccessPayload {
Objects.requireNonNull(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import reactor.core.publisher.Sinks.One;

/**
* Handle show diagrams inherited members icons event.
* Handle show diagrams inherited members event.
*
* @author arichard
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*******************************************************************************
* Copyright (c) 2024 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.diagram.common.view.services.handlers;

import java.util.Objects;

import org.eclipse.sirius.components.collaborative.api.ChangeDescription;
import org.eclipse.sirius.components.collaborative.api.ChangeKind;
import org.eclipse.sirius.components.collaborative.diagrams.DiagramChangeKind;
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext;
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler;
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput;
import org.eclipse.sirius.components.collaborative.diagrams.messages.ICollaborativeDiagramMessageService;
import org.eclipse.sirius.components.core.api.ErrorPayload;
import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.components.core.api.IPayload;
import org.eclipse.syson.diagram.common.view.services.ShowDiagramsInheritedMembersService;
import org.eclipse.syson.diagram.common.view.services.dto.ShowDiagramsInheritedMembersFromStandardLibrariesInput;
import org.eclipse.syson.diagram.common.view.services.dto.ShowDiagramsInheritedMembersFromStandardLibrariesSuccessPayload;
import org.springframework.stereotype.Service;

import reactor.core.publisher.Sinks.Many;
import reactor.core.publisher.Sinks.One;

/**
* Handle show diagrams inherited members from standard libraries event.
*
* @author arichard
*/
@Service
public class ShowDiagramsInheritedMembersFromStandardLibrariesEventHandler implements IDiagramEventHandler {

private final ICollaborativeDiagramMessageService messageService;

private final ShowDiagramsInheritedMembersService showDiagramsInheritedMembersService;

public ShowDiagramsInheritedMembersFromStandardLibrariesEventHandler(ICollaborativeDiagramMessageService messageService, ShowDiagramsInheritedMembersService showDiagramsInheritedMembersService) {
this.messageService = Objects.requireNonNull(messageService);
this.showDiagramsInheritedMembersService = Objects.requireNonNull(showDiagramsInheritedMembersService);
}

@Override
public boolean canHandle(IDiagramInput diagramInput) {
return diagramInput instanceof ShowDiagramsInheritedMembersFromStandardLibrariesInput;
}

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IDiagramContext diagramContext, IDiagramInput diagramInput) {
if (diagramInput instanceof ShowDiagramsInheritedMembersFromStandardLibrariesInput showDiagramsInheritedMembersFromStandardLibrariesInput) {
this.showDiagramsInheritedMembersService.setShowInheritedMembersFromStandardLibraries(showDiagramsInheritedMembersFromStandardLibrariesInput.show());
IPayload payload = new ShowDiagramsInheritedMembersFromStandardLibrariesSuccessPayload(diagramInput.id(), showDiagramsInheritedMembersFromStandardLibrariesInput.show());
ChangeDescription changeDescription = new ChangeDescription(DiagramChangeKind.DIAGRAM_ELEMENT_VISIBILITY_CHANGE, diagramInput.representationId(), diagramInput);
payloadSink.tryEmitValue(payload);
changeDescriptionSink.tryEmitNext(changeDescription);
} else {
String message = this.messageService.invalidInput(diagramInput.getClass().getSimpleName(), ShowDiagramsInheritedMembersFromStandardLibrariesInput.class.getSimpleName());
IPayload payload = new ErrorPayload(diagramInput.id(), message);
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, diagramInput.representationId(), diagramInput);
payloadSink.tryEmitValue(payload);
changeDescriptionSink.tryEmitNext(changeDescription);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
extend type Viewer {
showDiagramsIconsValue: Boolean!
showDiagramsInheritedMembersValue: Boolean!
showDiagramsInheritedMembersFromStandardLibrariesValue: Boolean!
}

extend type Mutation {
showDiagramsIcons(input: ShowDiagramsIconsInput!): ShowDiagramsIconsPayload!
showDiagramsInheritedMembers(input: ShowDiagramsInheritedMembersInput!): ShowDiagramsInheritedMembersPayload!
showDiagramsInheritedMembersFromStandardLibraries(input: ShowDiagramsInheritedMembersFromStandardLibrariesInput!): ShowDiagramsInheritedMembersFromStandardLibrariesPayload!
}

input ShowDiagramsIconsInput {
Expand Down Expand Up @@ -34,4 +36,18 @@ union ShowDiagramsInheritedMembersPayload = ErrorPayload | ShowDiagramsInherited
type ShowDiagramsInheritedMembersSuccessPayload {
id: ID!
show: Boolean!
}
}

input ShowDiagramsInheritedMembersFromStandardLibrariesInput {
id: ID!
editingContextId: ID!
representationId: ID!
show: Boolean!
}

union ShowDiagramsInheritedMembersFromStandardLibrariesPayload = ErrorPayload | ShowDiagramsInheritedMembersFromStandardLibrariesSuccessPayload

type ShowDiagramsInheritedMembersFromStandardLibrariesSuccessPayload {
id: ID!
show: Boolean!
}
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.
12 changes: 10 additions & 2 deletions doc/content/modules/user-manual/pages/release-notes/2024.9.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ image::release-notes-insert-textual-sysmlv2-dialog.png[New objects from text dia

image::release-notes-show-hide-icons-in-diagram.png[Show/Hide Icons in Diagram]

- *New "Show/Hide Inherited Members in Diagrams" diagram panel entry*: from panel in _Diagrams_, allow to show or hide the inherited members of elements in diagrams.
- *New "Show/Hide Inherited Members in Diagrams" diagram panel entry*: from panel in _Diagrams_, allow to show or hide the inherited members from users models in diagrams.

image::release-notes-show-hide-inherited-members-in-diagram.png[Show/Hide Inherited Members in Diagram]

- *New "Show/Hide Inherited Members from Standard Libraries in Diagrams" diagram panel entry*: from panel in _Diagrams_, allow to show or hide the inherited members from standard libraries in diagrams.

image::release-notes-show-hide-inherited-members-from-standard-libraries-in-diagram.png[Show/Hide Inherited Members from Standard Libraries in Diagram]


== Breaking changes

Expand Down Expand Up @@ -185,7 +189,11 @@ image::release-notes-insert-textual-sysmlv2-dialog.png[New objects from text dia

- Improve the drag and drop of container elements to move their content.
- Handle implicit specializations from standard libraries for Usages/Definitions.
- Add "Show/Hide Inherited Members in Diagrams" action in Diagram Panel, allowing to show/hide inherited members in diagrams.
- Add "Show/Hide Inherited Members in Diagrams" action in Diagram Panel, allowing to show/hide inherited members from users models in diagrams.

image::release-notes-show-hide-inherited-members-in-diagram.png[Show/Hide Inherited Members in Diagram]

- Add "Show/Hide Inherited Members from Standard Libraries in Diagrams" action in Diagram Panel, allowing to show/hide inherited members from standard libraries in diagrams.

image::release-notes-show-hide-inherited-members-from-standard-libraries-in-diagram.png[Show/Hide Inherited Members from Standard Libraries in Diagram]

Loading

0 comments on commit b93c8f1

Please sign in to comment.