Skip to content

Commit

Permalink
[3677] Remove CustomizableProperties from legacy layout engine
Browse files Browse the repository at this point in the history
Bug: #3677
Signed-off-by: Guillaume Coutable <[email protected]>
  • Loading branch information
gcoutable authored and sbegaudeau committed Sep 23, 2024
1 parent d70c426 commit 4be44b4
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Set;

import org.eclipse.sirius.components.diagrams.CollapsingState;
import org.eclipse.sirius.components.diagrams.CustomizableProperties;
import org.eclipse.sirius.components.diagrams.Node;
import org.eclipse.sirius.components.diagrams.ViewModifier;

Expand Down Expand Up @@ -77,11 +76,6 @@ public NodeAssert hasCollapsingState(CollapsingState collapsingState) {
return this;
}

public NodeAssert hasCustomizedProperties(Set<CustomizableProperties> customizedProperties) {
assertThat(this.actual.getCustomizedProperties()).hasSameElementsAs(customizedProperties);
return this;
}

public NodeAssert hasDefaultWidth(int defaultWidth) {
assertThat(this.actual.getDefaultWidth()).isEqualTo(defaultWidth);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.UUID;

import org.eclipse.sirius.components.diagrams.CollapsingState;
import org.eclipse.sirius.components.diagrams.CustomizableProperties;
import org.eclipse.sirius.components.diagrams.INodeStyle;
import org.eclipse.sirius.components.diagrams.IconLabelNodeStyle;
import org.eclipse.sirius.components.diagrams.InsideLabel;
Expand Down Expand Up @@ -52,8 +51,6 @@ public class IconlabelNodeBuilder<T> implements NodeBuilder<T> {

private NodesBuilder<IconlabelNodeBuilder<T>> childNodesBuilder;

private Set<CustomizableProperties> customizedProperties = Set.of();

public IconlabelNodeBuilder(NodesBuilder<T> nodesBuilder, String nodeLabel, boolean isBorderNode) {
this.insideLabel = new LabelBuilder().basicInsideLabel(nodeLabel, LabelType.INSIDE_CENTER, false);
this.isBorderNode = isBorderNode;
Expand All @@ -70,11 +67,6 @@ public NodesBuilder<IconlabelNodeBuilder<T>> childNodes() {
return this.childNodesBuilder;
}

public IconlabelNodeBuilder<T> customizedProperties(Set<CustomizableProperties> customizedProperties) {
this.customizedProperties = Objects.requireNonNull(customizedProperties);
return this;
}

public NodesBuilder<T> and() {
return this.nodesBuilder;
}
Expand Down Expand Up @@ -103,7 +95,6 @@ public Node build(Map<String, String> targetObjectIdToNodeId) {
.borderNode(this.isBorderNode)
.borderNodes(borderNodes)
.childNodes(childNodes)
.customizedProperties(this.customizedProperties)
.descriptionId(descriptionId)
.targetObjectId(labelText)
.targetObjectKind("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.UUID;

import org.eclipse.sirius.components.diagrams.CollapsingState;
import org.eclipse.sirius.components.diagrams.CustomizableProperties;
import org.eclipse.sirius.components.diagrams.INodeStyle;
import org.eclipse.sirius.components.diagrams.ImageNodeStyle;
import org.eclipse.sirius.components.diagrams.InsideLabel;
Expand Down Expand Up @@ -51,8 +50,6 @@ public final class ImageNodeBuilder<T> implements NodeBuilder<T> {

private NodesBuilder<ImageNodeBuilder<T>> childNodesBuilder;

private Set<CustomizableProperties> customizedProperties = Set.of();

public ImageNodeBuilder(NodesBuilder<T> nodesBuilder, String nodeLabel, boolean isBorderNode) {
this.insideLabel = new LabelBuilder().basicInsideLabel(nodeLabel, LabelType.OUTSIDE_CENTER, false);
this.isBorderNode = isBorderNode;
Expand All @@ -69,11 +66,6 @@ public NodesBuilder<ImageNodeBuilder<T>> childNodes() {
return this.childNodesBuilder;
}

public ImageNodeBuilder<T> customizedProperties(Set<CustomizableProperties> customizedProperties) {
this.customizedProperties = Objects.requireNonNull(customizedProperties);
return this;
}

public NodesBuilder<T> and() {
return this.nodesBuilder;
}
Expand Down Expand Up @@ -103,7 +95,6 @@ public Node build(Map<String, String> targetObjectIdToNodeId) {
.borderNode(this.isBorderNode)
.borderNodes(borderNodes)
.childNodes(childNodes)
.customizedProperties(this.customizedProperties)
.descriptionId(descriptionId)
.targetObjectId(labelText)
.targetObjectKind("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.UUID;

import org.eclipse.sirius.components.diagrams.CollapsingState;
import org.eclipse.sirius.components.diagrams.CustomizableProperties;
import org.eclipse.sirius.components.diagrams.ILayoutStrategy;
import org.eclipse.sirius.components.diagrams.INodeStyle;
import org.eclipse.sirius.components.diagrams.InsideLabel;
Expand Down Expand Up @@ -58,8 +57,6 @@ public final class RectangleNodeBuilder<T> implements NodeBuilder<T> {

private NodesBuilder<RectangleNodeBuilder<T>> childNodesBuilder;

private Set<CustomizableProperties> customizedProperties = Set.of();

public RectangleNodeBuilder(NodesBuilder<T> nodesBuilder, String nodeLabel, boolean isBorderNode) {
this(nodesBuilder, nodeLabel, isBorderNode, false);
}
Expand All @@ -86,11 +83,6 @@ public NodesBuilder<RectangleNodeBuilder<T>> childNodes(ILayoutStrategy layoutSt
return this.childNodesBuilder;
}

public RectangleNodeBuilder<T> customizedProperties(Set<CustomizableProperties> customizedProperties) {
this.customizedProperties = Objects.requireNonNull(customizedProperties);
return this;
}

public NodesBuilder<T> and() {
return this.nodesBuilder;
}
Expand Down Expand Up @@ -123,7 +115,6 @@ public Node build(Map<String, String> targetObjectIdToNodeId) {
.borderNode(this.isBorderNode)
.borderNodes(borderNodes)
.childNodes(childNodes)
.customizedProperties(this.customizedProperties)
.descriptionId(descriptionId)
.targetObjectId(labeltext)
.targetObjectKind("")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public final class Node implements IDiagramElement {

private List<Node> childNodes;

private Set<CustomizableProperties> customizedProperties;

private Integer defaultWidth;

private Integer defaultHeight;
Expand Down Expand Up @@ -150,10 +148,6 @@ public List<Node> getChildNodes() {
return this.childNodes;
}

public Set<CustomizableProperties> getCustomizedProperties() {
return this.customizedProperties;
}

public Integer getDefaultWidth() {
return this.defaultWidth;
}
Expand Down Expand Up @@ -221,8 +215,6 @@ public static final class Builder {

private List<Node> childNodes;

private Set<CustomizableProperties> customizedProperties = Set.of();

private Integer defaultWidth;

private Integer defaultHeight;
Expand Down Expand Up @@ -252,7 +244,6 @@ private Builder(Node node) {
this.childrenLayoutStrategy = node.getChildrenLayoutStrategy();
this.borderNodes = node.getBorderNodes();
this.childNodes = node.getChildNodes();
this.customizedProperties = node.getCustomizedProperties();
this.defaultWidth = node.getDefaultWidth();
this.defaultHeight = node.getDefaultHeight();
this.labelEditable = node.isLabelEditable();
Expand Down Expand Up @@ -334,11 +325,6 @@ public Builder childNodes(List<Node> childNodes) {
return this;
}

public Builder customizedProperties(Set<CustomizableProperties> customizedProperties) {
this.customizedProperties = Objects.requireNonNull(customizedProperties);
return this;
}

public Builder defaultWidth(Integer defaultWidth) {
this.defaultWidth = Objects.requireNonNull(defaultWidth);
return this;
Expand Down Expand Up @@ -377,7 +363,6 @@ public Node build() {
node.childrenLayoutStrategy = this.childrenLayoutStrategy;
node.borderNodes = Objects.requireNonNull(this.borderNodes);
node.childNodes = Objects.requireNonNull(this.childNodes);
node.customizedProperties = this.customizedProperties;
node.defaultWidth = this.defaultWidth; // Optional on purpose
node.defaultHeight = this.defaultHeight; // Optional on purpose
node.labelEditable = this.labelEditable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Set;

import org.eclipse.sirius.components.diagrams.CollapsingState;
import org.eclipse.sirius.components.diagrams.CustomizableProperties;
import org.eclipse.sirius.components.diagrams.ILayoutStrategy;
import org.eclipse.sirius.components.diagrams.INodeStyle;
import org.eclipse.sirius.components.diagrams.Node;
Expand Down Expand Up @@ -184,11 +183,6 @@ private Element doRender(VariableManager nodeVariableManager, String targetObjec
.build();
Element nodeChildren = new Element(NodeChildrenComponent.class, nodeChildrenComponentProps);

Set<CustomizableProperties> customizableProperties = Set.of();

if (CollapsingState.EXPANDED.equals(collapsingState)) {
customizableProperties = optionalPreviousNode.map(Node::getCustomizedProperties).orElse(Set.of());
}
Integer defaultWidth = nodeDescription.getDefaultWidthProvider().apply(nodeVariableManager);
Integer defaultHeight = nodeDescription.getDefaultHeightProvider().apply(nodeVariableManager);

Expand All @@ -201,7 +195,6 @@ private Element doRender(VariableManager nodeVariableManager, String targetObjec
.borderNode(isBorderNode)
.style(style)
.children(List.of(nodeChildren))
.customizableProperties(customizableProperties)
.modifiers(modifiers)
.state(state)
.pinned(isPinned)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.eclipse.sirius.components.annotations.Immutable;
import org.eclipse.sirius.components.diagrams.CollapsingState;
import org.eclipse.sirius.components.diagrams.CustomizableProperties;
import org.eclipse.sirius.components.diagrams.ILayoutStrategy;
import org.eclipse.sirius.components.diagrams.INodeStyle;
import org.eclipse.sirius.components.diagrams.ViewModifier;
Expand Down Expand Up @@ -64,8 +63,6 @@ public final class NodeElementProps implements IProps {

private Integer defaultHeight;

private Set<CustomizableProperties> customizableProperties;

private List<Element> children;

private boolean labelEditable;
Expand Down Expand Up @@ -136,10 +133,6 @@ public Integer getDefaultHeight() {
return this.defaultHeight;
}

public Set<CustomizableProperties> getCustomizableProperties() {
return this.customizableProperties;
}

@Override
public List<Element> getChildren() {
return this.children;
Expand Down Expand Up @@ -195,8 +188,6 @@ public static final class Builder {

private Integer defaultHeight;

private Set<CustomizableProperties> customizableProperties = Set.of();

private List<Element> children;

private boolean labelEditable;
Expand Down Expand Up @@ -272,11 +263,6 @@ public Builder defaultHeight(Integer defaultHeight) {
return this;
}

public Builder customizableProperties(Set<CustomizableProperties> customizableProperties) {
this.customizableProperties = Objects.requireNonNull(customizableProperties);
return this;
}

public Builder children(List<Element> children) {
this.children = Objects.requireNonNull(children);
return this;
Expand Down Expand Up @@ -308,7 +294,6 @@ public NodeElementProps build() {
nodeElementProps.childrenLayoutStrategy = this.childrenLayoutStrategy;
nodeElementProps.children = Objects.requireNonNull(this.children);
nodeElementProps.labelEditable = this.labelEditable;
nodeElementProps.customizableProperties = Objects.requireNonNull(this.customizableProperties);
nodeElementProps.defaultWidth = this.defaultWidth; // Optional on purpose
nodeElementProps.defaultHeight = this.defaultHeight; // Optional on purpose
nodeElementProps.pinned = this.pinned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ private Node instantiateNode(IProps props, List<Object> children) {
.style(nodeElementProps.getStyle())
.borderNodes(borderNodes)
.childNodes(childNodes)
.customizedProperties(nodeElementProps.getCustomizableProperties())
.state(nodeElementProps.getState())
.pinned(nodeElementProps.isPinned())
.modifiers(nodeElementProps.getModifiers())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* 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.sirius.web.application.editingcontext.migration.participants.representation;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import org.eclipse.sirius.components.collaborative.representations.migration.IRepresentationMigrationParticipant;
import org.springframework.stereotype.Service;

/**
* Remove the customizedProperties from node.
*
* @author gcoutable
*/
@Service
public class DiagramCustomizedPropertiesAttributeMigrationParticipant implements IRepresentationMigrationParticipant {

public static final String CUSTOMIZED_PROPERTIES = "customizedProperties";

@Override
public String getVersion() {
return "2024.11.0-202409231055";
}

@Override
public String getKind() {
return "siriusComponents://representation?type=Diagram";
}

@Override
public void replaceJsonNode(ObjectNode root, String currentAttribute, JsonNode currentValue) {
if (currentAttribute.equals(CUSTOMIZED_PROPERTIES)) {
root.remove(CUSTOMIZED_PROPERTIES);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void testRemoveSizeFromDiagramPresentOnDiagramAndNodesAndEdges() {
}

@ParameterizedTest
@ValueSource(strings = {"alignment", "routingPoints", "sourceAnchorRelativePosition", "targetAnchorRelativePosition", "userResizable"})
@ValueSource(strings = {"alignment", "routingPoints", "sourceAnchorRelativePosition", "targetAnchorRelativePosition", "userResizable", "customizedProperties"})
@DisplayName("Given a project with an old diagram representation, when the representation is loaded, then the position and size of diagram and nodes have been removed, but not from layout data")
@Sql(scripts = {"/scripts/migration.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = {"/scripts/cleanup.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ private Node createView(Optional<Node> optionalParentNode, NodeDescription nodeD
.childrenLayoutStrategy(new FreeFormLayoutStrategy())
.borderNodes(List.of())
.childNodes(List.of())
.customizedProperties(Set.of())
.build();
}

Expand Down

0 comments on commit 4be44b4

Please sign in to comment.