Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ It has long been unused by Sirius Web itself (since the transition to MUI).
- https://github.com/eclipse-syson/syson/issues/2232[#2232] [configuration] Fix a serialization problem of the View models of SysON representations.
- https://github.com/eclipse-syson/syson/issues/2237[#2237] [diagrams] Fix the item label inside `frames`, `require constraints`, and `assume constraints` compartments.
- https://github.com/eclipse-syson/syson/issues/2278[#2278] [diagrams] Display inherited behavior parameters in the _parameters_ compartment of `ActionDefinition` and `ActionUsage` graphical nodes.
- https://github.com/eclipse-syson/syson/issues/2291[#2291] [diagrams] Fix item label for constraint to show their name and expression value between braces (if present).

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,7 @@ public String getCompartmentItemLabel(Usage usage) {

private String getCompartmentItemStringRepresentation(Usage usage, boolean directEditInput) {
StringBuilder label = new StringBuilder();
if (usage instanceof ConstraintUsage constraintUsage
&& usage.getOwningMembership() instanceof RequirementConstraintMembership) {
// Use the constraint-specific rendering only if the element is a constraint owned by a requirement. Other
// constraints (including requirements) are rendered as regular elements.
if (usage instanceof ConstraintUsage constraintUsage) {
label.append(this.getCompartmentItemLabel(constraintUsage, directEditInput));
} else {
label.append(this.getUsageListItemPrefix(usage));
Expand Down Expand Up @@ -597,11 +594,7 @@ public String getSatisfyLabel(SatisfyRequirementUsage satisfyRequirementUsage) {
*/
private String getCompartmentItemLabel(ConstraintUsage constraintUsage, boolean directEditInput) {
StringBuilder label = new StringBuilder();
if (constraintUsage == null) {
label.append("");
} else if (!constraintUsage.getOwnedMember().isEmpty() && constraintUsage.getOwnedMember().get(0) instanceof Expression expression) {
label.append(this.getSysmlTextualRepresentation(expression, directEditInput));
} else {
if (constraintUsage != null) {
var identificationLabel = this.getIdentificationLabel(constraintUsage);
if (identificationLabel.isBlank()) {
// The constraint doesn't have an expression and does not have a name, we use the referenced feature name if the referenced feature exists
Expand All @@ -615,6 +608,14 @@ private String getCompartmentItemLabel(ConstraintUsage constraintUsage, boolean
label.append(this.getReferenceSubsettingLabel(constraintUsage));
}

if (!directEditInput && !constraintUsage.getOwnedMember().isEmpty() && constraintUsage.getOwnedMember().get(0) instanceof Expression expression) {
if (!label.isEmpty()) {
label.append(LabelConstants.SPACE);
}
label.append(LabelConstants.OPEN_BRACE).append(LabelConstants.SPACE);
label.append(this.getSysmlTextualRepresentation(expression, directEditInput));
label.append(LabelConstants.SPACE).append(LabelConstants.CLOSE_BRACE);
}
}
return label.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void testGetCompartmentItemLabelOfConstraintWithBooleanExpression() {
literalInteger.setValue(2);
yValue.getOwnedRelatedElement().add(literalInteger);

assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo("1 >= 2");
assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo(CONSTRAINT_USAGE_NAME + " { 1 >= 2 }");
}

@DisplayName("GIVEN a ConstraintUsage with an expression containing a subject reference, WHEN its label is computed, THEN the label represents the expression")
Expand All @@ -356,7 +356,7 @@ public void testGetCompartmentItemLabelOfConstraintWithSubjectReferenceExpressio
yFeatureReference.getOwnedRelationship().add(yFeatureReferenceMembership);
yFeatureReferenceMembership.setMemberElement(subjectReference);

assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo("1 >= mySubject");
assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo(CONSTRAINT_USAGE_NAME + " { 1 >= mySubject }");

}

Expand All @@ -381,7 +381,7 @@ public void testGetCompartmentItemLabelOfConstraintWithAttributeReferenceExpress
yFeatureReference.getOwnedRelationship().add(yFeatureReferenceMembership);
yFeatureReferenceMembership.setMemberElement(attributeUsage);

assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo("1 >= myAttribute");
assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo(CONSTRAINT_USAGE_NAME + " { 1 >= myAttribute }");
}

@DisplayName("GIVEN a ConstraintUsage with an expression containing a single feature chaining, WHEN its label is computed, THEN the label represents the expression")
Expand All @@ -406,7 +406,7 @@ public void testGetCompartmentItemLabelOfConstraintWithSingleFeatureChainingExpr
featureChainExpression.getOwnedRelationship().add(featureChainMembership);
featureChainMembership.setMemberElement(subAttributeUsage);

assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo("1 >= myAttribute.mySubAttribute");
assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo(CONSTRAINT_USAGE_NAME + " { 1 >= myAttribute.mySubAttribute }");
}

@DisplayName("GIVEN a ConstraintUsage with an expression containing multiple feature chainings, WHEN its label is computed, THEN the label represents the expression")
Expand Down Expand Up @@ -439,7 +439,7 @@ public void testGetCompartmentItemLabelOfConstraintWithMultipleFeatureChainingEx
featureChaining2.setChainingFeature(zAttributeUsage);
feature.getOwnedRelationship().addAll(List.of(featureChaining1, featureChaining2));

assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo("1 >= x.y.z");
assertThat(this.labelService.getCompartmentItemLabel(constraintUsage)).isEqualTo(CONSTRAINT_USAGE_NAME + " { 1 >= x.y.z }");
}

@DisplayName("GIVEN a Dependency with a name and short name, WHEN its edge label is computed, THEN the label contains the name and short name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class LabelConstants {

public static final String ASSUME = SysMLv2Keywords.ASSUME;

public static final String CLOSE_BRACE = SysMLv2Keywords.RIGHT_BRACE;

public static final String CLOSE_BRACKET = SysMLv2Keywords.RIGHT_BRACKET;

public static final String CLOSE_PARENTHESIS = SysMLv2Keywords.RIGHT_PAREN;
Expand Down Expand Up @@ -63,6 +65,8 @@ public class LabelConstants {

public static final String NON_UNIQUE = SysMLv2Keywords.NONUNIQUE;

public static final String OPEN_BRACE = SysMLv2Keywords.LEFT_BRACE;

public static final String OPEN_BRACKET = SysMLv2Keywords.LEFT_BRACKET;

public static final String OPEN_PARENTHESIS = SysMLv2Keywords.LEFT_PAREN;
Expand Down
Loading