Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2735] Contribute the first version of the Gantt representation
This version contains: Backend: * GanttDescription as view model * GanttDescription as POJO * Gantt representation rendering * Gantt representation subscription wiring * Task meta-model with concept that will represented by Gantt * An instance of the GanttRepresentation view model based on Task MM that is usable as a stereotype (no GanttRepresentation is deployed at server start) Front: * Gantt representation creation and display * Toolbar with display options Bug: #2735 Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
- Loading branch information
Showing
21 changed files
with
374 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...in/java/org/eclipse/sirius/components/collaborative/gantt/dto/input/RenameGanttInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.collaborative.gantt.dto.input; | ||
|
||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttInput; | ||
|
||
/** | ||
* The input of the rename gantt mutation. | ||
* | ||
* @author lfasani | ||
*/ | ||
public record RenameGanttInput(UUID id, String editingContextId, String representationId, String newLabel) implements IGanttInput { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...a/org/eclipse/sirius/components/collaborative/gantt/handlers/RenameGanttEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.collaborative.gantt.handlers; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.ChangeDescription; | ||
import org.eclipse.sirius.components.collaborative.api.ChangeKind; | ||
import org.eclipse.sirius.components.collaborative.api.IRepresentationPersistenceService; | ||
import org.eclipse.sirius.components.collaborative.api.IRepresentationSearchService; | ||
import org.eclipse.sirius.components.collaborative.api.Monitoring; | ||
import org.eclipse.sirius.components.collaborative.dto.RenameRepresentationSuccessPayload; | ||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttEventHandler; | ||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttInput; | ||
import org.eclipse.sirius.components.collaborative.gantt.dto.input.RenameGanttInput; | ||
import org.eclipse.sirius.components.collaborative.gantt.message.ICollaborativeGanttMessageService; | ||
import org.eclipse.sirius.components.core.api.ErrorPayload; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.gantt.Gantt; | ||
import org.springframework.stereotype.Service; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import reactor.core.publisher.Sinks.Many; | ||
import reactor.core.publisher.Sinks.One; | ||
|
||
/** | ||
* Handler used to rename a gantt. | ||
* | ||
* @author lfasani | ||
*/ | ||
@Service | ||
public class RenameGanttEventHandler implements IGanttEventHandler { | ||
|
||
private final IRepresentationSearchService representationSearchService; | ||
|
||
private final IRepresentationPersistenceService representationPersistenceService; | ||
|
||
private final ICollaborativeGanttMessageService messageService; | ||
|
||
private final Counter counter; | ||
|
||
public RenameGanttEventHandler(IRepresentationSearchService representationSearchService, IRepresentationPersistenceService representationPersistenceService, | ||
ICollaborativeGanttMessageService messageService, MeterRegistry meterRegistry) { | ||
this.representationSearchService = Objects.requireNonNull(representationSearchService); | ||
this.representationPersistenceService = Objects.requireNonNull(representationPersistenceService); | ||
this.messageService = Objects.requireNonNull(messageService); | ||
|
||
this.counter = Counter.builder(Monitoring.EVENT_HANDLER) | ||
.tag(Monitoring.NAME, this.getClass().getSimpleName()) | ||
.register(meterRegistry); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(IGanttInput ganttInput) { | ||
return ganttInput instanceof RenameGanttInput; | ||
} | ||
|
||
@Override | ||
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, Gantt gantt, IGanttInput ganttInput) { | ||
this.counter.increment(); | ||
|
||
String message = this.messageService.invalidInput(ganttInput.getClass().getSimpleName(), RenameGanttInput.class.getSimpleName()); | ||
IPayload payload = new ErrorPayload(ganttInput.id(), message); | ||
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, ganttInput.representationId(), ganttInput); | ||
|
||
if (ganttInput instanceof RenameGanttInput) { | ||
RenameGanttInput renameRepresentationInput = (RenameGanttInput) ganttInput; | ||
String representationId = renameRepresentationInput.representationId(); | ||
String newLabel = renameRepresentationInput.newLabel(); | ||
Optional<Gantt> optionalDiagram = this.representationSearchService.findById(editingContext, representationId, Gantt.class); | ||
if (optionalDiagram.isPresent()) { | ||
Gantt currentGantt = optionalDiagram.get(); | ||
|
||
Gantt renamedGantt = Gantt.newGantt(currentGantt).label(newLabel).build(); | ||
this.representationPersistenceService.save(editingContext, renamedGantt); | ||
|
||
payload = new RenameRepresentationSuccessPayload(ganttInput.id(), renamedGantt); | ||
changeDescription = new ChangeDescription(ChangeKind.REPRESENTATION_RENAMING, renameRepresentationInput.representationId(), ganttInput); | ||
} | ||
} | ||
|
||
payloadSink.tryEmitValue(payload); | ||
changeDescriptionSink.tryEmitNext(changeDescription); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...lipse/sirius/components/collaborative/gantt/message/CollaborativeGanttMessageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.collaborative.gantt.message; | ||
|
||
import java.util.Objects; | ||
|
||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.support.MessageSourceAccessor; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Implementation of the collaborative gantt message service. | ||
* | ||
* @author lfasani | ||
*/ | ||
@Service | ||
public class CollaborativeGanttMessageService implements ICollaborativeGanttMessageService { | ||
private final MessageSourceAccessor messageSourceAccessor; | ||
|
||
public CollaborativeGanttMessageService(@Qualifier("collaborativeGanttMessageSourceAccessor") MessageSourceAccessor messageSourceAccessor) { | ||
this.messageSourceAccessor = Objects.requireNonNull(messageSourceAccessor); | ||
} | ||
|
||
@Override | ||
public String invalidInput(String expectedInputTypeName, String receivedInputTypeName) { | ||
return this.messageSourceAccessor.getMessage(MessageConstants.INVALID_INPUT, new Object[] { expectedInputTypeName, receivedInputTypeName }); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...components/collaborative/gantt/message/CollaborativeGanttMessageServiceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.collaborative.gantt.message; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.support.MessageSourceAccessor; | ||
import org.springframework.context.support.ResourceBundleMessageSource; | ||
|
||
/** | ||
* Configuration used to retrieve the message source accessor for the project. | ||
* | ||
* @author lfasani | ||
*/ | ||
@Configuration | ||
public class CollaborativeGanttMessageServiceConfiguration { | ||
private static final String PATH = "messages/sirius-web-collaborative-gantt"; | ||
|
||
@Bean | ||
public MessageSourceAccessor collaborativeGanttMessageSourceAccessor() { | ||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); | ||
messageSource.addBasenames(PATH); | ||
return new MessageSourceAccessor(messageSource); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ipse/sirius/components/collaborative/gantt/message/ICollaborativeGanttMessageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.collaborative.gantt.message; | ||
|
||
/** | ||
* Interface of the collaborative gantt message service. | ||
* | ||
* @author lfasani | ||
*/ | ||
public interface ICollaborativeGanttMessageService { | ||
|
||
String invalidInput(String expectedInputTypeName, String receivedInputTypeName); | ||
|
||
/** | ||
* Implementation which does nothing, used for mocks in unit tests. | ||
* | ||
* @author lfasani | ||
*/ | ||
class NoOp implements ICollaborativeGanttMessageService { | ||
|
||
@Override | ||
public String invalidInput(String expectedInputTypeName, String receivedInputTypeName) { | ||
return ""; | ||
} | ||
} | ||
} |
Oops, something went wrong.