Skip to content

[1237] Add support for ViewUsage in General View. #1239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 18 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
= Changelog

== v2025.4.0 (work in progress)
== v2025.6.0 (work in progress)

=== Shapes

=== Breaking changes

=== Dependency update

=== Bug fixes

=== Improvements

=== New features

- https://github.com/eclipse-syson/syson/issues/1237[#1237] [general-view] Add `ViewUsage` node in the General View.


== v2025.4.0

=== Shapes

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*******************************************************************************
* 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.application.nodes;

import java.text.MessageFormat;
import java.util.Objects;

import org.eclipse.sirius.components.annotations.Immutable;
import org.eclipse.sirius.components.diagrams.INodeStyle;
import org.eclipse.sirius.components.diagrams.LineStyle;

/**
* The SysML view frame node style.
*
* @author frouene
*/
@Immutable
public final class SysMLViewFrameNodeStyle implements INodeStyle {

private String background;

private String borderColor;

private int borderSize;

private LineStyle borderStyle;

private int borderRadius;

private SysMLViewFrameNodeStyle() {
// Prevent instantiation
}

public static Builder newSysMLViewFrameNodeStyle() {
return new Builder();
}

public String getBackground() {
return this.background;
}

public String getBorderColor() {
return this.borderColor;
}

public int getBorderSize() {
return this.borderSize;
}

public LineStyle getBorderStyle() {
return this.borderStyle;
}

public int getBorderRadius() {
return this.borderRadius;
}

@Override
public String toString() {
String pattern = "{0} '{'color: {1}, border: '{' background: {2}, size: {3}, style: {4} '}''}'";
return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.background, this.borderColor, this.borderSize, this.borderStyle);
}

/**
* The builder used to create the view frame node style.
*
* @author frouene
*/
@SuppressWarnings("checkstyle:HiddenField")
public static final class Builder {

private String background;

private String borderColor;

private int borderSize;

private LineStyle borderStyle;

private int borderRadius;

private Builder() {
// Prevent instantiation
}

public Builder background(String background) {
this.background = Objects.requireNonNull(background);
return this;
}

public Builder borderColor(String borderColor) {
this.borderColor = Objects.requireNonNull(borderColor);
return this;
}

public Builder borderSize(int borderSize) {
this.borderSize = borderSize;
return this;
}

public Builder borderStyle(LineStyle borderStyle) {
this.borderStyle = Objects.requireNonNull(borderStyle);
return this;
}

public Builder borderRadius(int borderRadius) {
this.borderRadius = borderRadius;
return this;
}

public SysMLViewFrameNodeStyle build() {
SysMLViewFrameNodeStyle nodeStyleDescription = new SysMLViewFrameNodeStyle();
nodeStyleDescription.background = Objects.requireNonNull(this.background);
nodeStyleDescription.borderColor = Objects.requireNonNull(this.borderColor);
nodeStyleDescription.borderSize = this.borderSize;
nodeStyleDescription.borderStyle = Objects.requireNonNull(this.borderStyle);
nodeStyleDescription.borderRadius = this.borderRadius;
return nodeStyleDescription;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*******************************************************************************
* 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.application.nodes;

import java.util.Optional;

import org.eclipse.sirius.components.diagrams.INodeStyle;
import org.eclipse.sirius.components.diagrams.LineStyle;
import org.eclipse.sirius.components.view.FixedColor;
import org.eclipse.sirius.components.view.diagram.NodeStyleDescription;
import org.eclipse.sirius.components.view.emf.diagram.INodeStyleProvider;
import org.eclipse.syson.sysmlcustomnodes.SysMLViewFrameNodeStyleDescription;
import org.springframework.stereotype.Service;

/**
* This class provides style information for the view frame custom node.
*
* @author frouene
*/
@Service
public class SysMLViewFrameNodeStyleProvider implements INodeStyleProvider {

public static final String NODE_SYSML_VIEW_FRAME = "customnode:sysmlviewframe";

@Override
public Optional<String> getNodeType(NodeStyleDescription nodeStyle) {
if (nodeStyle instanceof SysMLViewFrameNodeStyleDescription) {
return Optional.of(NODE_SYSML_VIEW_FRAME);
}
return Optional.empty();
}

@Override
public Optional<INodeStyle> createNodeStyle(NodeStyleDescription nodeStyle, Optional<String> optionalEditingContextId) {
Optional<INodeStyle> iNodeStyle = Optional.empty();
Optional<String> nodeType = this.getNodeType(nodeStyle);
if (nodeType.isPresent()) {
return Optional.of(SysMLViewFrameNodeStyle.newSysMLViewFrameNodeStyle()
.background(Optional.ofNullable(((SysMLViewFrameNodeStyleDescription) nodeStyle).getBackground())
.filter(FixedColor.class::isInstance)
.map(FixedColor.class::cast)
.map(FixedColor::getValue)
.orElse("transparent"))
.borderColor(Optional.ofNullable(nodeStyle.getBorderColor())
.filter(FixedColor.class::isInstance)
.map(FixedColor.class::cast)
.map(FixedColor::getValue)
.orElse("black"))
.borderSize(nodeStyle.getBorderSize())
.borderStyle(LineStyle.valueOf(nodeStyle.getBorderLineStyle().getLiteral()))
.borderRadius(nodeStyle.getBorderRadius())
.build());
}

return iNodeStyle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ type SysMLNoteNodeStyle {
borderColor: String!
borderSize: Int!
borderStyle: LineStyle!
}
}

extend union INodeStyle = SysMLViewFrameNodeStyle

type SysMLViewFrameNodeStyle {
background: String!
borderColor: String!
borderSize: Int!
borderStyle: LineStyle!
borderRadius: Int!
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import org.eclipse.syson.services.diagrams.api.IGivenDiagramSubscription;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.LibraryPackage;
import org.eclipse.syson.sysml.Membership;
import org.eclipse.syson.sysml.Namespace;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.util.IDescriptionNameGenerator;
Expand Down Expand Up @@ -96,55 +95,38 @@
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class GVTopNodeCreationTests extends AbstractIntegrationTests {

private final IDescriptionNameGenerator descriptionNameGenerator = new GVDescriptionNameGenerator();
@Autowired
private IGivenInitialServerState givenInitialServerState;

@Autowired
private IGivenDiagramReference givenDiagram;

@Autowired
private IGivenDiagramDescription givenDiagramDescription;

@Autowired
private IGivenDiagramSubscription givenDiagramSubscription;

@Autowired
private IDiagramIdProvider diagramIdProvider;

@Autowired
private IIdentityService identityService;

@Autowired
private IObjectSearchService objectSearchService;

@Autowired
private NodeCreationTester nodeCreationTester;

@Autowired
private SemanticRunnableFactory semanticRunnableFactory;

@Autowired
private DiagramComparator diagramComparator;

@Autowired
private SelectionDialogTreeEventSubscriptionRunner selectionDialogTreeEventSubscriptionRunner;

@Autowired
private RepresentationIdBuilder representationIdBuilder;

@Autowired
private IViewDiagramDescriptionSearchService viewDiagramDescriptionSearchService;

private DiagramDescriptionIdProvider diagramDescriptionIdProvider;

private Step<DiagramRefreshedEventPayload> verifier;

private AtomicReference<Diagram> diagram;

private DiagramDescription diagramDescription;

private final IDescriptionNameGenerator descriptionNameGenerator = new GVDescriptionNameGenerator();

private static Stream<Arguments> topNodeParameters() {
return Stream.of(
Arguments.of(SysmlPackage.eINSTANCE.getAttributeUsage(), 3),
Expand Down Expand Up @@ -180,7 +162,8 @@ private static Stream<Arguments> topNodeParameters() {
Arguments.of(SysmlPackage.eINSTANCE.getSatisfyRequirementUsage(), 7),
Arguments.of(SysmlPackage.eINSTANCE.getStateUsage(), 4),
Arguments.of(SysmlPackage.eINSTANCE.getStateDefinition(), 4),
Arguments.of(SysmlPackage.eINSTANCE.getExhibitStateUsage(), 4)
Arguments.of(SysmlPackage.eINSTANCE.getExhibitStateUsage(), 4),
Arguments.of(SysmlPackage.eINSTANCE.getViewUsage(), 0)
).map(TestNameGenerator::namedArguments);
}

Expand Down Expand Up @@ -222,9 +205,9 @@ public void createTopNode(EClass eClass, int compartmentCount) {
.ifPresentOrElse(newDiagram -> {
int createdNodesExpectedCount = 1 + compartmentCount;
new CheckDiagramElementCount(this.diagramComparator)
.hasNewEdgeCount(0)
.hasNewNodeCount(createdNodesExpectedCount)
.check(this.diagram.get(), newDiagram);
.hasNewEdgeCount(0)
.hasNewNodeCount(createdNodesExpectedCount)
.check(this.diagram.get(), newDiagram);

String newNodeDescriptionName = this.descriptionNameGenerator.getNodeName(eClass);

Expand Down Expand Up @@ -272,7 +255,7 @@ public void createTopNamespaceImportNode() {
this.diagram,
null,
creationToolId,
List.of(new ToolVariable("selectedObject", libId.get().get(), ToolVariableType.OBJECT_ID)));
List.of(new ToolVariable("selectedObject", libId.get().get(), ToolVariableType.OBJECT_ID)));
});

Consumer<DiagramRefreshedEventPayload> updatedDiagramConsumer = payload -> Optional.of(payload)
Expand Down Expand Up @@ -356,7 +339,7 @@ private Optional<LibraryPackage> getISQAcousticsLibraryPackageElement(Resource r
.filter(Namespace.class::isInstance)
.map(Namespace.class::cast)
.flatMap(namespace -> namespace.getOwnedMembership().stream())
.map(Membership.class::cast)
.map(t -> t)
.flatMap(membership -> membership.getRelatedElement().stream())
.filter(LibraryPackage.class::isInstance)
.filter(element -> "ISQAcoustics".equals(element.getDeclaredName()))
Expand Down
Loading
Loading