Skip to content

Commit

Permalink
[3834] Add more variables for DeckDescription
Browse files Browse the repository at this point in the history
Bug: #3834
Signed-off-by: Laurent Fasani <[email protected]>
  • Loading branch information
lfasani authored and sbegaudeau committed Aug 27, 2024
1 parent f2c4a0e commit 962e19f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ A migration participant has been added to automatically keep compatible all diag
- https://github.com/eclipse-sirius/sirius-web/issues/3763[#3763] [diagram] Split the SelectionDialogDescription to prepare the Tree support
- https://github.com/eclipse-sirius/sirius-web/issues/3793[#3793] [sirius-web] Add mechanism to retrieve the parent object of an element in the tree representation
- https://github.com/eclipse-sirius/sirius-web/issues/3880[#3880] [sirius-web] Make some tests methods more generic
- https://github.com/eclipse-sirius/sirius-web/issues/3834[#3834] [deck] Add more variables for DeckDescription

== v2024.7.0

Expand Down
9 changes: 9 additions & 0 deletions doc/specifier/representation-deck.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ image::images/deck-description-overview.png[Deck description overview]
* `Precondition Expression`: An expression that determine if it is possible to create the representation
* `Title Expression`: The initial name of the representation once created
### Variables

The variable `deckTarget` is the semantic element associated with the deck representation.
It is available for

* lane descriptions
* card descriptions
* all style descriptions
### Deck style

It is possible to define the *background color* of the `Deck` representation by adding a `StyleDescription` in the `DeckDescription`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public IPayload createCard(CreateDeckCardInput createDeckCardInput, IEditingCont
String currentLaneId = createDeckCardInput.currentLaneId();
Optional<Lane> optionalParentLane = this.findLane(lane -> Objects.equals(lane.id(), currentLaneId), deck);
Optional<LaneDescription> optionalLaneDescription = optionalParentLane.flatMap(lane -> this.findLaneDescription(lane.descriptionId(), deck, editingContext));
Optional<Object> optionalDeckTarget = this.objectService.getObject(editingContext, deck.getTargetObjectId());

if (optionalLaneDescription.isPresent()) {
if (optionalLaneDescription.isPresent() && optionalDeckTarget.isPresent()) {
VariableManager variableManager = new VariableManager();
Optional<Object> optionalTargetObject;
if (currentLaneId != null) {
Expand All @@ -84,6 +85,7 @@ public IPayload createCard(CreateDeckCardInput createDeckCardInput, IEditingCont
}
if (optionalTargetObject.isPresent()) {
variableManager.put(VariableManager.SELF, optionalTargetObject.get());
variableManager.put(DeckDescription.DECK_TARGET, optionalDeckTarget.get());
variableManager.put(DeckDescription.TITLE, createDeckCardInput.title());
variableManager.put(DeckDescription.DESCRIPTION, createDeckCardInput.description());
variableManager.put(DeckDescription.LABEL, createDeckCardInput.label());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public class DeckCreationService implements IDeckCreationService {
public DeckCreationService(IRepresentationDescriptionSearchService representationDescriptionSearchService, IObjectService objectService, MeterRegistry meterRegistry) {
this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService);
this.objectService = Objects.requireNonNull(objectService);
this.timer = Timer.builder(Monitoring.REPRESENTATION_EVENT_PROCESSOR_REFRESH).tag(Monitoring.NAME, "deck").register(meterRegistry);
this.timer = Timer.builder(Monitoring.REPRESENTATION_EVENT_PROCESSOR_REFRESH)
.tag(Monitoring.NAME, "deck")
.register(meterRegistry);
}

@Override
Expand Down Expand Up @@ -83,6 +85,7 @@ private Deck doRender(String label, Object targetObject, IEditingContext editing
VariableManager variableManager = new VariableManager();
variableManager.put(DeckDescription.LABEL, label);
variableManager.put(VariableManager.SELF, targetObject);
variableManager.put(DeckDescription.DECK_TARGET, targetObject);
variableManager.put(IEditingContext.EDITING_CONTEXT, editingContext);
Optional<Deck> optionalPreviousDeck = optionalDeckContext.map(IDeckContext::getDeck);
Optional<IDeckEvent> optionalDeckEvent = optionalDeckContext.map(IDeckContext::getDeckEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public record DeckDescription(String id, String label, Function<VariableManager,

public static final String LABEL = "label";

public static final String DECK_TARGET = "deckTarget";

public static final String NEW_TITLE = "newTitle";

public static final String NEW_DESCRIPTION = "newDescription";
Expand Down

0 comments on commit 962e19f

Please sign in to comment.