Skip to content

Commit

Permalink
[4101] Add loop tree item label element description
Browse files Browse the repository at this point in the history
Bug: eclipse-sirius#4101
Signed-off-by: Jerome Gout <[email protected]>
  • Loading branch information
jerome-obeo authored and pcdavid committed Jan 13, 2025
1 parent c5877d9 commit 6e424ea
Show file tree
Hide file tree
Showing 26 changed files with 1,105 additions and 46 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ Specifiers can contribute dedicated AQL services for this feature using implemen
- [charts] Make the npm package `sirius-components-charts` use the strict version of our TypeScript configuration
- [trees] Make the npm package `sirius-components-trees` use the strict version of our TypeScript configuration
- https://github.com/eclipse-sirius/sirius-web/issues/1047[#1047] [sirius-web] In the _Domain_ diagram, when using direct-edit on a relatin edge, the initial text now only includes the name of the relation (without the cardinality)
- https://github.com/eclipse-sirius/sirius-web/issues/4095[#4095] Add conditional tree item label element description
- https://github.com/eclipse-sirius/sirius-web/issues/4095[#4095] [tree] Add conditional tree item label element description
- https://github.com/eclipse-sirius/sirius-web/issues/4101[#4101] [tree] Add loop tree item label element description

== v2025.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ private TreeItemLabelDescription entityStyle(TextStylePalette textStylePalette)
.children(
this.getEntityKeyFragment(textStylePalette),
this.getEntityValueFragment(textStylePalette),
new TreeBuilders().newTreeItemLabelFragmentDescription()
.labelExpression(" {")
.style(this.getTextStyleByName(textStylePalette, NORMAL_TEXT_STYLE_NAME))
.build(),
this.getAttributesFragments(textStylePalette),
new TreeBuilders().newTreeItemLabelFragmentDescription()
.labelExpression("}")
.style(this.getTextStyleByName(textStylePalette, NORMAL_TEXT_STYLE_NAME))
.build(),
this.getAbstractEntityValueFragment(textStylePalette))
.build();
}
Expand All @@ -176,6 +185,13 @@ private TreeItemLabelDescription defaultStyle() {
.build();
}

private TreeItemLabelElementDescription getEntityKeyFragment(TextStylePalette textStylePalette) {
return new TreeBuilders().newTreeItemLabelFragmentDescription()
.labelExpression("aql:'[Entity] '")
.style(this.getTextStyleByName(textStylePalette, BROWN_BOLD_TEXT_STYLE_NAME))
.build();
}

private TreeItemLabelElementDescription getEntityValueFragment(TextStylePalette textStylePalette) {
return new TreeBuilders().newTreeItemLabelFragmentDescription()
.labelExpression(AQL_SELF_GET_TREE_ITEM_LABEL)
Expand All @@ -193,10 +209,23 @@ private TreeItemLabelElementDescription getAbstractEntityValueFragment(TextStyle
.build();
}

private TreeItemLabelElementDescription getEntityKeyFragment(TextStylePalette textStylePalette) {
return new TreeBuilders().newTreeItemLabelFragmentDescription()
.labelExpression("aql:'[Entity] '")
.style(this.getTextStyleByName(textStylePalette, BROWN_BOLD_TEXT_STYLE_NAME))
private TreeItemLabelElementDescription getAttributesFragments(TextStylePalette textStylePalette) {
return new TreeBuilders().newForTreeItemLabelElementDescription()
.iterator("attribute")
.iterableExpression("aql:self.attributes")
.children(
new TreeBuilders().newTreeItemLabelFragmentDescription()
.labelExpression("aql:attribute.name")
.style(this.getTextStyleByName(textStylePalette, NORMAL_TEXT_STYLE_NAME))
.build(),
new TreeBuilders().newIfTreeItemLabelElementDescription()
.predicateExpression("aql:self.attributes->indexOf(attribute) < (self.attributes->size())")
.children(new TreeBuilders().newTreeItemLabelFragmentDescription()
.labelExpression(", ")
.style(this.getTextStyleByName(textStylePalette, NORMAL_TEXT_STYLE_NAME))
.build())
.build()
)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void givenAnExplorerRepresentationWhenWeSubscribeToItsEventThenTheReprese
assertThat(tree.getChildren().get(0).getChildren()).hasSize(1);
assertThat(tree.getChildren().get(0).getChildren().get(0).getLabel().toString()).isEqualTo("buck");
assertThat(tree.getChildren().get(0).getChildren().get(0).getChildren()).hasSize(3);
assertThat(tree.getChildren().get(0).getChildren().get(0).getChildren().get(2).getLabel().toString()).isEqualTo("[Entity] Human");
assertThat(tree.getChildren().get(0).getChildren().get(0).getChildren().get(2).getLabel().toString()).contains("[Entity] Human");
assertThat(tree.getChildren().get(0).getChildren().get(0).getChildren().get(2).getChildren()).hasSize(4);
assertThat(tree.getChildren().get(0).getChildren().get(0).getChildren().get(2).getChildren().get(0).getLabel().toString()).isEqualTo("superTypes");
settingId.set(tree.getChildren().get(0).getChildren().get(0).getChildren().get(2).getChildren().get(0).getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.function.Consumer;

import org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload;
import org.eclipse.sirius.components.core.api.labels.StyledString;
import org.eclipse.sirius.components.trees.Tree;
import org.eclipse.sirius.components.trees.TreeItem;
import org.eclipse.sirius.web.AbstractIntegrationTests;
Expand Down Expand Up @@ -104,6 +103,7 @@ public void givenAStudioWhenTheTreeItemLabelsAreRequestedThenTheCorrectStylesAre
// 2- check that styles are properly applied
// - check that the ROOT entity has not the abstract style applied.
// - check that the NamedElement entity has the abstract style (if style)
// - check that the Human entity has 3 attributes (for style)
var inputStyle = new ExplorerEventInput(UUID.randomUUID(), StudioIdentifiers.SAMPLE_STUDIO_PROJECT.toString(), explorerRepresentationId);
var fluxStyle = this.explorerEventSubscriptionRunner.run(inputStyle);

Expand All @@ -114,11 +114,15 @@ public void givenAStudioWhenTheTreeItemLabelsAreRequestedThenTheCorrectStylesAre
.getChildren()
.get(0)
.getChildren();
StyledString rootLabel = domainChildren.get(0).getLabel();
StyledString namedElementLabel = domainChildren.get(1).getLabel();
assertThat(rootLabel.styledStringFragments()).hasSize(2);
assertThat(namedElementLabel.styledStringFragments()).hasSize(3);
assertThat(namedElementLabel.toString()).isEqualTo("[Entity] NamedElement [abstract]");
var rootLabels = domainChildren.get(0).getLabel().styledStringFragments();
var namedElementLabels = domainChildren.get(1).getLabel().styledStringFragments();
var humanLabels = domainChildren.get(2).getLabel().styledStringFragments();
assertThat(rootLabels.get(rootLabels.size() - 1).text()).doesNotContain("[abstract]");
assertThat(namedElementLabels.get(namedElementLabels.size() - 1).text()).contains("[abstract]");
assertThat(humanLabels).hasSize(9);
assertThat(humanLabels.get(3).text()).isEqualTo("description");
assertThat(humanLabels.get(5).text()).isEqualTo("promoted");
assertThat(humanLabels.get(7).text()).isEqualTo("birthDate");
});

StepVerifier.create(fluxStyle)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2023, 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.sirius.components.view.builder.generated.tree;

/**
* Builder for ForTreeItemLabelElementDescriptionBuilder.
*
* @author BuilderGenerator
* @generated
*/
public class ForTreeItemLabelElementDescriptionBuilder {

/**
* Create instance org.eclipse.sirius.components.view.tree.ForTreeItemLabelElementDescription.
* @generated
*/
private org.eclipse.sirius.components.view.tree.ForTreeItemLabelElementDescription forTreeItemLabelElementDescription = org.eclipse.sirius.components.view.tree.TreeFactory.eINSTANCE.createForTreeItemLabelElementDescription();

/**
* Return instance org.eclipse.sirius.components.view.tree.ForTreeItemLabelElementDescription.
* @generated
*/
protected org.eclipse.sirius.components.view.tree.ForTreeItemLabelElementDescription getForTreeItemLabelElementDescription() {
return this.forTreeItemLabelElementDescription;
}

/**
* Return instance org.eclipse.sirius.components.view.tree.ForTreeItemLabelElementDescription.
* @generated
*/
public org.eclipse.sirius.components.view.tree.ForTreeItemLabelElementDescription build() {
return this.getForTreeItemLabelElementDescription();
}

/**
* Setter for Iterator.
*
* @generated
*/
public ForTreeItemLabelElementDescriptionBuilder iterator(java.lang.String value) {
this.getForTreeItemLabelElementDescription().setIterator(value);
return this;
}
/**
* Setter for IterableExpression.
*
* @generated
*/
public ForTreeItemLabelElementDescriptionBuilder iterableExpression(java.lang.String value) {
this.getForTreeItemLabelElementDescription().setIterableExpression(value);
return this;
}
/**
* Setter for Children.
*
* @generated
*/
public ForTreeItemLabelElementDescriptionBuilder children(org.eclipse.sirius.components.view.tree.TreeItemLabelElementDescription ... values) {
for (org.eclipse.sirius.components.view.tree.TreeItemLabelElementDescription value : values) {
this.getForTreeItemLabelElementDescription().getChildren().add(value);
}
return this;
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public IfTreeItemLabelElementDescriptionBuilder newIfTreeItemLabelElementDescrip
return new IfTreeItemLabelElementDescriptionBuilder();
}

/**
* Instantiate a ForTreeItemLabelElementDescriptionBuilder .
*
* @author BuilderGenerator
* @generated
*/
public ForTreeItemLabelElementDescriptionBuilder newForTreeItemLabelElementDescription() {
return new ForTreeItemLabelElementDescriptionBuilder();
}

/**
* Instantiate a TreeItemLabelFragmentDescriptionBuilder .
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 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 @@ -147,7 +147,7 @@ private StringBuilder getFactoryClassBody(GenPackage pak) {
public #builderClassName new#className() {
return new #builderClassName();
}
""".replace(BUILDER_CLASSNAME, this.builderClasssName(clazz))
.replace("#className", clazz.getName()));
}
Expand All @@ -159,7 +159,7 @@ private StringBuilder getFactory(GenPackage pak, String builderFactoryName, Stri
StringBuilder factory = new StringBuilder();
factory.append("""
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 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 All @@ -171,7 +171,7 @@ private StringBuilder getFactory(GenPackage pak, String builderFactoryName, Stri
* Obeo - initial API and implementation
*******************************************************************************/
package #package;
/**
* Use to instantiate a new builder.
*
Expand All @@ -197,23 +197,23 @@ private StringBuilder getBody(GenClass clazz) {
* @generated
*/
private #eObjType #eObjNameLowerCase = #packageFactory.create#eObjName();
/**
* Return instance #eObjType.
* @generated
*/
protected #eObjType get#eObjName() {
return this.#eObjNameLowerCase;
}
/**
* Return instance #eObjType.
* @generated
*/
public #eObjType build() {
return this.get#eObjName();
}
""".replace("#packageFactory", clazz.getGenPackage().getQualifiedEFactoryInternalInstanceAccessor())
.replace("#eObjType", clazz.getQualifiedInterfaceName())
.replace("#eObjNameLowerCase", clazz.uncapPrefixedName(clazz.getSafeUncapName()))
Expand Down Expand Up @@ -253,7 +253,7 @@ private StringBuilder getBody(GenClass clazz) {
}
return this;
}
""".replace(BUILDER_CLASSNAME, this.builderClasssName(clazz))
.replace("#paramType", feat.getListItemType(clazz))
.replace("#accessor", feat.getAccessorName())
Expand All @@ -272,7 +272,7 @@ private StringBuilder getBuilder(GenPackage pak, GenClass clazz, StringBuilder b
if (clazz.isAbstract()) {
builder.append("""
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 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 All @@ -284,24 +284,24 @@ private StringBuilder getBuilder(GenPackage pak, GenClass clazz, StringBuilder b
* Obeo - initial API and implementation
*******************************************************************************/
package #package;
/**
* Builder for #qualifiedType.
*
* @author BuilderGenerator
* @generated
*/
public abstract class #builderClassName {
/**
* Builder for #qualifiedType.
* @generated
*/
protected abstract #qualifiedType get#eObjName();
#classbody
}
""".replace(BUILDER_CLASSNAME, this.builderClasssName(clazz))
.replace("#qualifiedType", this.qualifiedNameFromGenClass(clazz))
.replace(CLASSBODY, body)
Expand All @@ -310,7 +310,7 @@ public abstract class #builderClassName {
} else {
builder.append("""
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 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 All @@ -322,18 +322,18 @@ public abstract class #builderClassName {
* Obeo - initial API and implementation
*******************************************************************************/
package #package;
/**
* Builder for #builderClassName.
*
* @author BuilderGenerator
* @generated
*/
public class #builderClassName {
#classbody
}
""".replace(BUILDER_CLASSNAME, this.builderClasssName(clazz))
.replace("#qualifiedType", clazz.getQualifiedInterfaceName())
.replace(CLASSBODY, body)
Expand Down
Loading

0 comments on commit 6e424ea

Please sign in to comment.