Skip to content

Commit d256cc4

Browse files
pcdavidAxelRICHARD
authored andcommitted
[2119] Display expressions values in the Details view
Bug: #2119 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
1 parent 1fbc6a1 commit d256cc4

12 files changed

Lines changed: 343 additions & 8 deletions

File tree

CHANGELOG.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
- https://github.com/eclipse-syson/syson/issues/2198[#2198] [diagrams] Improve diagram-to-diagram drag and drop to support dropping multiple graphical nodes at once, leveraging Sirius Web's `droppedNodes` and `droppedElements` variables.
2828
- https://github.com/eclipse-syson/syson/issues/2194[#2194] [diagrams] Properly report feedback messages to user when using _ISysMLMoveElementService_.
29-
- https://github.com/eclipse-syson/syson/issues/2182[#2182] [services] Provide a way for downstream applications to extend _ISysMLMoveElementService_;
29+
- https://github.com/eclipse-syson/syson/issues/2182[#2182] [services] Provide a way for downstream applications to extend _ISysMLMoveElementService_.
3030
- https://github.com/eclipse-syson/syson/issues/2240[#2240] [diagrams] Update the choice of _timeslice_ and _snapshot_ elements that can be created in the selection dialog of tools creating _timeslice_ and _snapshot_ elements.
3131
Before, the selection dialog option with selection allowed choosing between all _timeslice/snapshot_ types.
3232
Now, the choice is restricted to the _timeslice/snapshot_ type that match the graphical node type on which the tool is applied.
33-
33+
- https://github.com/eclipse-syson/syson/issues/2119[#2119] [details] Display expressions values in the _Details_ view and allow to edit them from there.
3434

3535
=== New features
3636

backend/application/syson-application-configuration/src/main/java/org/eclipse/syson/application/configuration/SysMLv2PropertiesConfigurer.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
@Configuration
8080
public class SysMLv2PropertiesConfigurer implements IPropertiesDescriptionRegistryConfigurer {
8181

82+
private static final String CUSTOM_EXPRESSION_WIDGET_KEY = "syson:expression-value-widget";
83+
8284
private static final String CORE_PROPERTIES = "Core Properties";
8385

8486
private static final String ADVANCED_PROPERTIES = "Advanced Properties";
@@ -189,6 +191,7 @@ private FormDescription createDetailsViewForElement() {
189191
pageCore.getGroups().add(this.createExtraAcceptActionUsagePropertiesGroup());
190192
pageCore.getGroups().add(this.createExtraTransitionSourceTargetPropertiesGroup());
191193
pageCore.getGroups().add(this.createFeatureValuePropertiesGroup());
194+
pageCore.getGroups().add(this.createExpressionPropertiesGroup());
192195

193196
PageDescription pageAdvanced = FormFactory.eINSTANCE.createPageDescription();
194197
pageAdvanced.setName("SysON-DetailsView-Advanced");
@@ -203,6 +206,28 @@ private FormDescription createDetailsViewForElement() {
203206
return form;
204207
}
205208

209+
/**
210+
* Creates a group to display the value of an Expression.
211+
*
212+
* @return a {@link GroupDescription}
213+
*/
214+
private GroupDescription createExpressionPropertiesGroup() {
215+
GroupDescription group = FormFactory.eINSTANCE.createGroupDescription();
216+
group.setDisplayMode(GroupDisplayMode.LIST);
217+
group.setName("Expression Value");
218+
group.setLabelExpression("");
219+
group.setSemanticCandidatesExpression(ServiceMethod.of0(DetailsViewService::getExpression).aqlSelf());
220+
221+
TextAreaDescription expressionWidget = FormFactory.eINSTANCE.createTextAreaDescription();
222+
expressionWidget.setName("Expression");
223+
expressionWidget.setLabelExpression(CUSTOM_EXPRESSION_WIDGET_KEY);
224+
expressionWidget.setValueExpression(ServiceMethod.of0(DetailsViewService::getExpressionTextualRepresentation).aqlSelf());
225+
expressionWidget.setIsEnabledExpression(AQLConstants.AQL_FALSE);
226+
227+
group.getChildren().add(expressionWidget);
228+
229+
return group;
230+
}
206231

207232
/**
208233
* Creates a group to display the value of a Feature or FeatureValue.

backend/application/syson-application-configuration/src/main/java/org/eclipse/syson/application/services/DetailsViewService.java

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.eclipse.syson.sysml.Annotation;
4545
import org.eclipse.syson.sysml.Comment;
4646
import org.eclipse.syson.sysml.ConjugatedPortDefinition;
47+
import org.eclipse.syson.sysml.Definition;
4748
import org.eclipse.syson.sysml.Documentation;
4849
import org.eclipse.syson.sysml.Element;
4950
import org.eclipse.syson.sysml.EndFeatureMembership;
@@ -55,6 +56,7 @@
5556
import org.eclipse.syson.sysml.FeatureValue;
5657
import org.eclipse.syson.sysml.Import;
5758
import org.eclipse.syson.sysml.Membership;
59+
import org.eclipse.syson.sysml.Namespace;
5860
import org.eclipse.syson.sysml.ParameterMembership;
5961
import org.eclipse.syson.sysml.ReferenceSubsetting;
6062
import org.eclipse.syson.sysml.ReferenceUsage;
@@ -68,6 +70,7 @@
6870
import org.eclipse.syson.sysml.SysmlPackage;
6971
import org.eclipse.syson.sysml.TransitionUsage;
7072
import org.eclipse.syson.sysml.Type;
73+
import org.eclipse.syson.sysml.Usage;
7174
import org.eclipse.syson.sysml.ViewUsage;
7275
import org.eclipse.syson.sysml.metamodel.services.ElementInitializerSwitch;
7376
import org.eclipse.syson.sysml.metamodel.services.MetamodelQueryElementService;
@@ -570,12 +573,16 @@ public Element setNewDocumentationValue(Element self, String newValue) {
570573
* a {@link FeatureValue} or {@link Feature}
571574
* @return a {@link FeatureValue} or <code>null</code>
572575
*/
573-
public Element getFeatureValue(Element self) {
574-
Element result = null;
576+
public FeatureValue getFeatureValue(Element self) {
577+
FeatureValue result = null;
575578
if (self instanceof FeatureValue featureValue && featureValue.getValue() != null) {
576579
result = featureValue;
577580
} else if (self instanceof Feature feature) {
578-
result = this.metamodelQueryElementService.getValueExpression(feature).orElse(null);
581+
result = feature.getOwnedRelationship().stream()
582+
.filter(FeatureValue.class::isInstance)
583+
.map(FeatureValue.class::cast)
584+
.findFirst()
585+
.orElse(null);
579586
}
580587
return result;
581588
}
@@ -626,6 +633,39 @@ private String getExpressionAsText(Expression expression) {
626633
return this.metamodelQueryElementService.getExpressionTextualRepresentation(expression);
627634
}
628635

636+
/**
637+
* Gets the {@link ResultExpressionMembership} from a {@link Namespace} or a {@link ResultExpressionMembership}.
638+
*
639+
* @param self
640+
* a {@link Namespace} or a {@link ResultExpressionMembership}.
641+
* @return a {@link ResultExpressionMembership} or <code>null</code>
642+
*/
643+
public Element getResultExpression(Element self) {
644+
Element result = null;
645+
if (self instanceof ResultExpressionMembership expressionMembership && expressionMembership.getOwnedResultExpression() != null) {
646+
result = expressionMembership;
647+
} else if (self instanceof Namespace namespace && this.metamodelQueryElementService.getResultExpressionMembership(namespace) != null
648+
&& this.metamodelQueryElementService.getResultExpressionMembership(namespace).getOwnedResultExpression() != null) {
649+
result = this.metamodelQueryElementService.getResultExpressionMembership(namespace);
650+
}
651+
return result;
652+
}
653+
654+
/**
655+
* Gets the {@link ResultExpressionMembership} from a {@link Namespace} or a {@link ResultExpressionMembership}.
656+
*
657+
* @param self
658+
* a {@link Namespace} or a {@link ResultExpressionMembership}.
659+
* @return a {@link ResultExpressionMembership} or <code>null</code>
660+
*/
661+
public Element getExpression(Element self) {
662+
if (self instanceof Expression && !(self instanceof Usage) && !(self instanceof Definition)) {
663+
return self;
664+
} else {
665+
return null;
666+
}
667+
}
668+
629669
/**
630670
* Returns the element that owns the visibility feature of the given element.
631671
*

backend/services/syson-sysml-metamodel-services/src/main/java/org/eclipse/syson/sysml/metamodel/services/MetamodelQueryElementService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
import org.eclipse.syson.sysml.Feature;
2828
import org.eclipse.syson.sysml.FeatureValue;
2929
import org.eclipse.syson.sysml.FramedConcernMembership;
30+
import org.eclipse.syson.sysml.Namespace;
3031
import org.eclipse.syson.sysml.OwningMembership;
3132
import org.eclipse.syson.sysml.PartUsage;
3233
import org.eclipse.syson.sysml.ReferenceUsage;
34+
import org.eclipse.syson.sysml.ResultExpressionMembership;
3335
import org.eclipse.syson.sysml.StakeholderMembership;
3436
import org.eclipse.syson.sysml.SubjectMembership;
3537
import org.eclipse.syson.sysml.SysmlFactory;
@@ -306,4 +308,20 @@ public ConcernUsage getFramedConcernTarget(FramedConcernMembership framedConcern
306308
}
307309
return null;
308310
}
311+
312+
/**
313+
* Get the {@link ResultExpressionMembership} contained inside a given {@link Namespace}.
314+
*
315+
* @param namespace
316+
* a given {@link Namespace}.
317+
* @return a {@link ResultExpressionMembership}, or <code>null</code> if not found.
318+
*/
319+
public ResultExpressionMembership getResultExpressionMembership(Namespace namespace) {
320+
return namespace.getOwnedMembership().stream()
321+
.filter(ResultExpressionMembership.class::isInstance)
322+
.map(ResultExpressionMembership.class::cast)
323+
.findFirst()
324+
.orElse(null);
325+
}
326+
309327
}
114 KB
Loading

doc/content/modules/user-manual/pages/features/expressions.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ a|image::explorer-expression-internals-hidden.png[Internals hidden (default)]
1919
a|image::explorer-expression-internals-visible.png[Internals visible]
2020
|===
2121

22+
When an `Expression` element is selected(for example from the {explorer} view), the {details}} view displays its textual representation, with a button to open the expression edition modal (see below) directly on it:
23+
+
24+
image::expression-details.png[Expression value displayed in the _Details_ veiw, width=80%]
25+
2226
== Creation
2327

2428
To _create_ an expression, invoke the _New expression_ context menu action on a compatible element (supported elements are `Attributes`, `Constraints` and `Transitions`).

doc/content/modules/user-manual/pages/release-notes/2026.7.0.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ To _edit_ an existing expression, simply invoke the _Edit expression_ context me
6666
+
6767
To _delete_ an existing expression, you can simply invoke the normal _Delete_ menu item action on the expression itself or the new _Delete expression_ on its parent element.
6868

69+
* In the _Details_ view:
70+
71+
** When an `Expression` element is selected (for example from the _Explorer_ view), the _Details_ view displays its textual representation, with a button to open the expression edition modal (see above) directly on it:
72+
+
73+
image::expression-details.png[Expression value displayed in the _Details_ veiw, width=80%]
6974

7075
== Bug fixes
7176

frontend/syson-components/src/extensions/SysONExtensionRegistryMergeStrategy.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024, 2025 Obeo.
2+
* Copyright (c) 2024, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@
1212
*******************************************************************************/
1313

1414
import { DataExtension, ExtensionRegistryMergeStrategy } from '@eclipse-sirius/sirius-components-core';
15+
import { widgetContributionExtensionPoint } from '@eclipse-sirius/sirius-components-forms';
1516
import { omniboxCommandOverrideContributionExtensionPoint } from '@eclipse-sirius/sirius-components-omnibox';
1617
import { treeItemContextMenuEntryOverrideExtensionPoint } from '@eclipse-sirius/sirius-components-trees';
1718
import {
@@ -37,6 +38,9 @@ export class SysONExtensionRegistryMergeStrategy
3738
if (identifier === treeItemContextMenuEntryOverrideExtensionPoint.identifier) {
3839
return this.mergeTreeItemContributions(existingValues, newValues);
3940
}
41+
if (identifier === widgetContributionExtensionPoint.identifier) {
42+
return this.mergeWidgetContributions(existingValues, newValues);
43+
}
4044
return newValues;
4145
}
4246

@@ -69,4 +73,14 @@ export class SysONExtensionRegistryMergeStrategy
6973
data: [...existingContributions.data, ...newContributions.data],
7074
};
7175
}
76+
77+
private mergeWidgetContributions(
78+
existingContributions: DataExtension<any>,
79+
newContributions: DataExtension<any>
80+
): DataExtension<any> {
81+
return {
82+
identifier: `syson_${widgetContributionExtensionPoint.identifier}`,
83+
data: [...existingContributions.data, ...newContributions.data],
84+
};
85+
}
7286
}

0 commit comments

Comments
 (0)