Skip to content

Commit

Permalink
[3342] Update Deck views
Browse files Browse the repository at this point in the history
Update deck view examples
Add domain type feature in gantt and deck xxDescription

Bug: #3342
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
  • Loading branch information
lfasani authored and frouene committed Apr 9, 2024
1 parent 6d3f678 commit 38612f5
Show file tree
Hide file tree
Showing 44 changed files with 821 additions and 226 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ image:doc/screenshots/inside_outside_labels.png[Isinde outside label example, 70
- https://github.com/eclipse-sirius/sirius-web/issues/3279[#3279] [gantt] The expressions `TaskDescription#startTimeExpression` and `TaskDescription#endTimeExpression` can now both accept `String` values as a result if those values can be parsed by `java.timeInstant#parse`.
They still support returning an `java.time.Instant` object directly.
- https://github.com/eclipse-sirius/sirius-web/issues/3309[#3309] [diagram] Hide header border-bottom when the node is collapsed
- https://github.com/eclipse-sirius/sirius-web/issues/3285[#3285] Make the icons in the diagram palette use the default color of Sirius Web theme
- https://github.com/eclipse-sirius/sirius-web/issues/3312[#3312] Make the details view more compact
- https://github.com/eclipse-sirius/sirius-web/issues/3349[#3349] Add a default label when creating a NodeDescription
- https://github.com/eclipse-sirius/sirius-web/issues/3285[#3285] [diagram] Make the icons in the diagram palette use the default color of Sirius Web theme
- https://github.com/eclipse-sirius/sirius-web/issues/3312[#3312] [form] Make the details view more compact
- https://github.com/eclipse-sirius/sirius-web/issues/3349[#3349] [diagram] Add a default label when creating a NodeDescription
- https://github.com/eclipse-sirius/sirius-web/issues/3342[#3342] [deck] Update deck and gantt view metamodel and deck view examples


== v2024.3.0
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/cypress/e2e/project/deck/deck-lane.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ describe('Verify the Deck Representation lanes selection and editing', () => {
deck.getLane('Monday').should('have.css', 'border-width', '0px');
explorer.select('daily::Monday');
deck.getLane('Monday').should('have.css', 'border', '2px solid rgb(190, 26, 120)');
deck.getLane('Wednesday').click();
deck.getLane('Saturday').click();

// We verify that when selecting a card, the task is selected too in the model explorer.
explorer.getSelectedTreeItems();
explorer.getSelectedTreeItems().should('have.length', 1);
explorer.getSelectedTreeItems().contains('daily::Wednesday').should('exist');
explorer.getSelectedTreeItems().contains('daily::Saturday').should('exist');
});

it('We verify the lane direct edit.', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
@PublicApi
public record CardDescription(String id, Function<VariableManager, String> targetObjectKindProvider, Function<VariableManager, String> targetObjectLabelProvider,
Function<VariableManager, String> targetObjectIdProvider, Function<VariableManager, List<Object>> semanticElementsProvider, Function<VariableManager, String> titleProvider,
Function<VariableManager, String> targetObjectIdProvider, Function<VariableManager, List<?>> semanticElementsProvider, Function<VariableManager, String> titleProvider,
Function<VariableManager, String> labelProvider, Function<VariableManager, String> descriptionProvider, Consumer<VariableManager> editCardProvider,
Consumer<VariableManager> deleteCardProvider, Function<VariableManager, DeckElementStyle> styleProvider) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
@PublicApi
public record LaneDescription(String id, Function<VariableManager, String> targetObjectKindProvider, Function<VariableManager, String> targetObjectLabelProvider,
Function<VariableManager, String> targetObjectIdProvider, Function<VariableManager, List<Object>> semanticElementsProvider, Function<VariableManager, String> titleProvider,
Function<VariableManager, String> targetObjectIdProvider, Function<VariableManager, List<?>> semanticElementsProvider, Function<VariableManager, String> titleProvider,
Function<VariableManager, String> labelProvider, List<CardDescription> cardDescriptions, Consumer<VariableManager> editLaneProvider, Consumer<VariableManager> createCardProvider,
Consumer<VariableManager> dropCardProvider, Function<VariableManager, Boolean> collapsibleProvider, Function<VariableManager, DeckElementStyle> styleProvider) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Element render() {

List<Element> children = new ArrayList<>();

List<Object> semanticElements = cardDescription.semanticElementsProvider().apply(variableManager);
List<?> semanticElements = cardDescription.semanticElementsProvider().apply(variableManager);
for (Object semanticElement : semanticElements) {
VariableManager childVariableManager = variableManager.createChild();
childVariableManager.put(VariableManager.SELF, semanticElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Element render() {

List<Element> children = new ArrayList<>();

List<Object> semanticElements = laneDescription.semanticElementsProvider().apply(variableManager);
List<?> semanticElements = laneDescription.semanticElementsProvider().apply(variableManager);
for (Object semanticElement : semanticElements) {
VariableManager childVariableManager = variableManager.createChild();
childVariableManager.put(VariableManager.SELF, semanticElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
@PublicApi
public record TaskDescription(String id, Function<VariableManager, String> targetObjectIdProvider, Function<VariableManager, String> targetObjectKindProvider,
Function<VariableManager, String> targetObjectLabelProvider, Function<VariableManager, List<Object>> semanticElementsProvider, Function<VariableManager, String> nameProvider,
Function<VariableManager, String> targetObjectLabelProvider, Function<VariableManager, List<?>> semanticElementsProvider, Function<VariableManager, String> nameProvider,
Function<VariableManager, String> descriptionProvider, Function<VariableManager, Instant> startTimeProvider, Function<VariableManager, Instant> endTimeProvider,
Function<VariableManager, Integer> progressProvider, Function<VariableManager, Boolean> computeDatesDynamicallyProvider, Function<VariableManager, List<Object>> taskDependenciesProvider,
List<String> reusedTaskDescriptionIds, List<TaskDescription> subTaskDescriptions) {
Expand Down Expand Up @@ -76,7 +76,7 @@ public static final class Builder {

private Function<VariableManager, String> targetObjectLabelProvider;

private Function<VariableManager, List<Object>> semanticElementsProvider;
private Function<VariableManager, List<?>> semanticElementsProvider;

private Function<VariableManager, String> nameProvider;

Expand Down Expand Up @@ -115,7 +115,7 @@ public Builder targetObjectLabelProvider(Function<VariableManager, String> targe
return this;
}

public Builder semanticElementsProvider(Function<VariableManager, List<Object>> semanticElementsProvider) {
public Builder semanticElementsProvider(Function<VariableManager, List<?>> semanticElementsProvider) {
this.semanticElementsProvider = Objects.requireNonNull(semanticElementsProvider);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Element render() {

List<Element> children = new ArrayList<>();

List<Object> semanticElements = taskDescription.semanticElementsProvider().apply(variableManager);
List<?> semanticElements = taskDescription.semanticElementsProvider().apply(variableManager);
for (Object semanticElement : semanticElements) {
VariableManager childVariableManager = variableManager.createChild();
childVariableManager.put(VariableManager.SELF, semanticElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.List;
import java.util.Locale;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.components.task.Company;
import org.eclipse.sirius.components.task.KeyResult;
import org.eclipse.sirius.components.task.Objective;
Expand All @@ -37,7 +36,7 @@
*/
public class TaskExampleBuilder {

private static final String KANBAN = "Kanban";
private static final String KANBAN = "kanban";
private static final String REVIEW = "Review";
private static final String DEVELOPMENT = "Development";
private static final String CODE_DEVELOPMENT = "Code Development";
Expand All @@ -54,7 +53,7 @@ public class TaskExampleBuilder {
private static final String DATE_2023_12_16T17_30_00Z = "2023-12-16T17:30:00Z";
private static final String DATE_2023_12_18T08_30_00Z = "2023-12-18T08:30:00Z";

public EObject getContent() {
public Company getContent() {
Company company = TaskFactory.eINSTANCE.createCompany();

Person paul = TaskFactory.eINSTANCE.createPerson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.StreamSupport;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.components.core.api.IFeedbackMessageService;
import org.eclipse.sirius.components.gantt.TaskDetail;
import org.eclipse.sirius.components.representations.Message;
import org.eclipse.sirius.components.representations.MessageLevel;
import org.eclipse.sirius.components.task.AbstractTask;
import org.eclipse.sirius.components.task.KeyResult;
import org.eclipse.sirius.components.task.Objective;
import org.eclipse.sirius.components.task.Project;
import org.eclipse.sirius.components.task.Task;
import org.eclipse.sirius.components.task.TaskFactory;
Expand All @@ -45,18 +47,6 @@ public TaskJavaService(IFeedbackMessageService feedbackMessageService) {
this.feedbackMessageService = Objects.requireNonNull(feedbackMessageService);
}

public TaskDetail getTaskDetail(Task task) {

String name = Optional.ofNullable(task.getName()).orElse("");
String description = Optional.ofNullable(task.getDescription()).orElse("");
Instant startTime = task.getStartTime();
Instant endTime = task.getEndTime();
int progress = task.getProgress();
boolean computeStartEndDynamically = task.isComputeStartEndDynamically();

return new TaskDetail(name, description, startTime, endTime, progress, computeStartEndDynamically);
}

public void editTask(EObject eObject, String name, String description, Instant startTime, Instant endTime, Integer progress) {
if (eObject instanceof AbstractTask task) {
if (name != null) {
Expand Down Expand Up @@ -106,11 +96,14 @@ public List<Task> getTasksWithTag(TaskTag tag) {
return Optional.ofNullable(tag.eContainer())
.filter(Project.class::isInstance)
.map(Project.class::cast).stream()
.map(Project::getOwnedTasks)
.flatMap(List::stream)
.flatMap(project -> {
Iterable<EObject> content = () -> project.eAllContents();
return StreamSupport.stream(content.spliterator(), false);
})
.filter(Task.class::isInstance)
.map(Task.class::cast)
.filter(task -> task.getTags().contains(tag))
.toList();

}

public String computeTaskDurationDays(Task task) {
Expand Down Expand Up @@ -185,6 +178,16 @@ public void moveTaskIntoTarget(Task sourceTask, EObject target, int indexInTarge
}
}

public void moveKeyResultIntoObjective(KeyResult sourceKeyResult, Objective targetObjective, int indexInTarget) {
EList<KeyResult> ownedKeyResults = targetObjective.getOwnedKeyResults();
if (sourceKeyResult.eContainer().equals(targetObjective)) {
ownedKeyResults.move(indexInTarget, sourceKeyResult);
} else {
ownedKeyResults.add(sourceKeyResult);
ownedKeyResults.move(indexInTarget, sourceKeyResult);
}
}

private void moveTaskInSubTasks(Task sourceTask, int indexInTarget, Task targetTask) {
List<Task> subTasks = targetTask.getSubTasks();
if (subTasks.contains(sourceTask)) {
Expand All @@ -207,55 +210,51 @@ private void moveTaskInSubTasks(Task sourceTask, int indexInTarget, Task targetT
}
}

public Task moveCardAtIndex(Task task, int index, TaskTag targetTag) {
public Task moveTaskInTag(Task moveTask, int index, TaskTag targetTag) {
// We retrieve all tasks with the same tag (in the same lane).
List<Task> targetLaneTaskList = this.getTasksWithTag(targetTag);
if (!targetLaneTaskList.isEmpty()) {
EObject eContainer = task.eContainer();
List<Task> allTaskInTheLane = this.getTasksWithTag(targetTag);
Optional<Task> firstTaskAfterTheDroppedTaskWithSameParent = allTaskInTheLane.subList(index, allTaskInTheLane.size()).stream()
.filter(task -> task.eContainer().equals(moveTask.eContainer()))
.findFirst();

List<Task> tasksBeforeTheDroppedTaskWithSameParent = allTaskInTheLane.subList(0, index).stream()
.filter(task -> task.eContainer().equals(moveTask.eContainer()))
.toList();
Optional<Task> lastTaskBeforeTheDroppedTaskWithSameParent = Optional.empty();
if (!tasksBeforeTheDroppedTaskWithSameParent.isEmpty()) {
lastTaskBeforeTheDroppedTaskWithSameParent = Optional.of(tasksBeforeTheDroppedTaskWithSameParent.get(tasksBeforeTheDroppedTaskWithSameParent.size() - 1));
}

if (lastTaskBeforeTheDroppedTaskWithSameParent.isPresent() || firstTaskAfterTheDroppedTaskWithSameParent.isPresent()) {
EObject eContainer = moveTask.eContainer();
if (eContainer instanceof Project project) {
int newIndex = this.computeIndexOfTaskToReplace(task, index, targetLaneTaskList, project);
// We move the current task before the taskToReplace in the project ownTasks list.
int oldIndex = project.getOwnedTasks().indexOf(task);
// If the moved task was located before the new location, the index after having remove the task is
// decremented.
if (oldIndex < newIndex) {
newIndex--;
int indexInParent = 0;
if (lastTaskBeforeTheDroppedTaskWithSameParent.isPresent()) {
indexInParent = project.getOwnedTasks().indexOf(lastTaskBeforeTheDroppedTaskWithSameParent.get()) + 1;
} else {
indexInParent = project.getOwnedTasks().indexOf(firstTaskAfterTheDroppedTaskWithSameParent.get());
}
project.getOwnedTasks().move(newIndex, task);
project.getOwnedTasks().move(indexInParent , moveTask);
} else if (eContainer instanceof AbstractTask parentTask) {
int indexInParent = 0;
if (lastTaskBeforeTheDroppedTaskWithSameParent.isPresent()) {
indexInParent = parentTask.getSubTasks().indexOf(lastTaskBeforeTheDroppedTaskWithSameParent.get()) + 1;
} else {
indexInParent = parentTask.getSubTasks().indexOf(firstTaskAfterTheDroppedTaskWithSameParent.get());
}
parentTask.getSubTasks().move(indexInParent , moveTask);
}
}
return task;
return moveTask;
}

/**
* When a card is moved, we change the underlying task ordering.
*
* @param task
* the task to move.
* @param index
* the new index in the lane task list.
* @param targetLaneTaskList
* the current lane task list.
* @param project
* the project owning the tasks.
* @return the index on which the task should be moved in the project task list to match the new index in the lane.
*/
private int computeIndexOfTaskToReplace(Task task, int index, List<Task> targetLaneTaskList, Project project) {
int newIndex;
List<Task> unmovedLaneTasks = targetLaneTaskList.stream().filter(currentTask -> currentTask != task).toList();
if (index < unmovedLaneTasks.size()) {
// We retrieve the Task that will be located after the moved one.
Task taskToMoveAround = unmovedLaneTasks.get(index);
newIndex = project.getOwnedTasks().indexOf(taskToMoveAround);
} else {
// We need to locate the task after the last one in the lane
Task lastTask = unmovedLaneTasks.get(unmovedLaneTasks.size() - 1);
newIndex = project.getOwnedTasks().indexOf(lastTask) + 1;
public void moveObjectiveAtIndex(Objective objective, int index) {
if (objective.eContainer() instanceof Project project) {
project.getOwnedObjectives().move(index, objective);
}
return newIndex;
}

public void moveLaneAtIndex(TaskTag movedTag, int index) {
public void moveTagAtIndex(TaskTag movedTag, int index) {
EObject eContainer = movedTag.eContainer();
if (eContainer instanceof Project project) {
String prefix = movedTag.getPrefix();
Expand Down
Loading

0 comments on commit 38612f5

Please sign in to comment.