Search in sources :

Example 1 with Diagram

use of org.eclipse.sirius.components.diagrams.Diagram in project sirius-components by eclipse-sirius.

the class ViewToolSectionsProvider method createExtraToolSections.

private List<ToolSection> createExtraToolSections(Object diagramElementDescription) {
    List<ToolSection> extraToolSections = new ArrayList<>();
    List<NodeDescription> targetDescriptions = new ArrayList<>();
    boolean unsynchronizedMapping = false;
    // @formatter:off
    if (diagramElementDescription instanceof NodeDescription) {
        targetDescriptions.add((NodeDescription) diagramElementDescription);
        unsynchronizedMapping = SynchronizationPolicy.UNSYNCHRONIZED.equals(((NodeDescription) diagramElementDescription).getSynchronizationPolicy());
    } else if (diagramElementDescription instanceof EdgeDescription) {
        EdgeDescription edgeDescription = (EdgeDescription) diagramElementDescription;
        targetDescriptions.addAll(edgeDescription.getSourceNodeDescriptions());
        unsynchronizedMapping = SynchronizationPolicy.UNSYNCHRONIZED.equals(((EdgeDescription) diagramElementDescription).getSynchronizationPolicy());
    }
    Function<VariableManager, IStatus> fakeHandler = variableManager -> new Success();
    // Graphical Delete Tool for unsynchronized mapping only (the handler is never called)
    if (diagramElementDescription instanceof NodeDescription || diagramElementDescription instanceof EdgeDescription) {
        // Edit Tool (the handler is never called)
        SingleClickOnDiagramElementTool editTool = // $NON-NLS-1$
        SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool("edit").label(// $NON-NLS-1$
        "Edit").imageURL(DiagramImageConstants.EDIT_SVG).targetDescriptions(targetDescriptions).handler(fakeHandler).appliesToDiagramRoot(false).build();
        var editToolSection = // $NON-NLS-1$
        ToolSection.newToolSection("edit-section").label(// $NON-NLS-1$
        "").imageURL(// $NON-NLS-1$
        "").tools(List.of(editTool)).build();
        extraToolSections.add(editToolSection);
        if (unsynchronizedMapping) {
            SingleClickOnDiagramElementTool graphicalDeleteTool = // $NON-NLS-1$
            SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool("graphical-delete").label(// $NON-NLS-1$
            "Delete from diagram").imageURL(DiagramImageConstants.GRAPHICAL_DELETE_SVG).targetDescriptions(targetDescriptions).handler(fakeHandler).appliesToDiagramRoot(false).build();
            var graphicalDeleteToolSection = // $NON-NLS-1$
            ToolSection.newToolSection("graphical-delete-section").label(// $NON-NLS-1$
            "").imageURL(// $NON-NLS-1$
            "").tools(List.of(graphicalDeleteTool)).build();
            extraToolSections.add(graphicalDeleteToolSection);
        }
        // Semantic Delete Tool (the handler is never called)
        SingleClickOnDiagramElementTool semanticDeleteTool = // $NON-NLS-1$
        SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool("semantic-delete").label(// $NON-NLS-1$
        "Delete from model").imageURL(DiagramImageConstants.SEMANTIC_DELETE_SVG).targetDescriptions(targetDescriptions).handler(fakeHandler).appliesToDiagramRoot(false).build();
        var semanticDeleteToolSection = // $NON-NLS-1$
        ToolSection.newToolSection("semantic-delete-section").label(// $NON-NLS-1$
        "").imageURL(// $NON-NLS-1$
        "").tools(List.of(semanticDeleteTool)).build();
        extraToolSections.add(semanticDeleteToolSection);
    }
    return extraToolSections;
// @formatter:on
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) Node(org.eclipse.sirius.components.diagrams.Node) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Success(org.eclipse.sirius.components.representations.Success) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) IToolSectionsProvider(org.eclipse.sirius.components.collaborative.diagrams.api.IToolSectionsProvider) Objects(java.util.Objects) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IStatus(org.eclipse.sirius.components.representations.IStatus) ITool(org.eclipse.sirius.components.diagrams.tools.ITool) SingleClickOnDiagramElementTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool) Service(org.springframework.stereotype.Service) DiagramImageConstants(org.eclipse.sirius.components.collaborative.diagrams.api.DiagramImageConstants) VariableManager(org.eclipse.sirius.components.representations.VariableManager) SingleClickOnTwoDiagramElementsTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IStatus(org.eclipse.sirius.components.representations.IStatus) ArrayList(java.util.ArrayList) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Success(org.eclipse.sirius.components.representations.Success) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) SingleClickOnDiagramElementTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection)

Example 2 with Diagram

use of org.eclipse.sirius.components.diagrams.Diagram in project sirius-components by eclipse-sirius.

the class CreateViewOperationHandlerTests method initialize.

@BeforeEach
public void initialize() {
    this.operationTestContext = new OperationTestContext();
    // @formatter:off
    DiagramDescription diagramDescription = DiagramDescription.newDiagramDescription(UUID.randomUUID()).label(// $NON-NLS-1$
    "DiagramDescriptionTest").targetObjectIdProvider(// $NON-NLS-1$
    variableManager -> "diagramTargetObjectId").canCreatePredicate(variableManager -> true).labelProvider(// $NON-NLS-1$
    variableManager -> "Diagram").toolSections(List.of()).nodeDescriptions(List.of(this.getNodeDescription(UUID.randomUUID()))).edgeDescriptions(List.of()).dropHandler(// $NON-NLS-1$
    variableManager -> new Failure("")).build();
    Diagram diagram = Diagram.newDiagram(UUID.randomUUID().toString()).descriptionId(diagramDescription.getId()).targetObjectId(UUID.randomUUID().toString()).label(// $NON-NLS-1$
    "DiagramTest").position(Position.at(0, 0)).size(Size.of(100, 100)).nodes(new ArrayList<>()).edges(List.of()).build();
    IDiagramContext diagramContext = new IDiagramContext.NoOp() {

        @Override
        public List<ViewCreationRequest> getViewCreationRequests() {
            return new ArrayList<>();
        }
    };
    this.operationTestContext.getVariables().put(IDiagramContext.DIAGRAM_CONTEXT, diagramContext);
    // @formatter:on
    AdapterFactoryEditingDomain editingDomain = new EditingDomainFactory().create();
    EditingContext editingContext = new EditingContext(UUID.randomUUID().toString(), editingDomain);
    this.operationTestContext.getVariables().put(IEditingContext.EDITING_CONTEXT, editingContext);
    this.operationTestContext.getVariables().put(CONTAINER_VIEW, diagram);
    this.createViewOperation = org.eclipse.sirius.diagram.description.tool.ToolFactory.eINSTANCE.createCreateView();
    this.createViewOperationHandler = new CreateViewOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.createViewOperation);
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) BeforeEach(org.junit.jupiter.api.BeforeEach) Size(org.eclipse.sirius.components.diagrams.Size) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ToolFactory(org.eclipse.sirius.viewpoint.description.tool.ToolFactory) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Position(org.eclipse.sirius.components.diagrams.Position) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) CreateViewOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.CreateViewOperationHandler) RectangularNodeStyle(org.eclipse.sirius.components.diagrams.RectangularNodeStyle) EditingDomainFactory(org.eclipse.sirius.components.emf.services.EditingDomainFactory) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) Diagram(org.eclipse.sirius.components.diagrams.Diagram) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) IStatus(org.eclipse.sirius.components.representations.IStatus) LineStyle(org.eclipse.sirius.components.diagrams.LineStyle) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Failure(org.eclipse.sirius.components.representations.Failure) Success(org.eclipse.sirius.components.representations.Success) ENamedElement(org.eclipse.emf.ecore.ENamedElement) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CreateView(org.eclipse.sirius.diagram.description.tool.CreateView) VariableManager(org.eclipse.sirius.components.representations.VariableManager) ViewCreationRequest(org.eclipse.sirius.components.diagrams.ViewCreationRequest) ChangeContext(org.eclipse.sirius.viewpoint.description.tool.ChangeContext) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) ViewCreationRequest(org.eclipse.sirius.components.diagrams.ViewCreationRequest) ArrayList(java.util.ArrayList) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) CreateViewOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.CreateViewOperationHandler) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) EditingDomainFactory(org.eclipse.sirius.components.emf.services.EditingDomainFactory) Failure(org.eclipse.sirius.components.representations.Failure) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Diagram

use of org.eclipse.sirius.components.diagrams.Diagram in project sirius-components by eclipse-sirius.

the class DeleteViewOperationHandlerTests method initialize.

@BeforeEach
public void initialize() {
    this.operationTestContext = new OperationTestContext();
    // @formatter:off
    DiagramDescription diagramDescription = DiagramDescription.newDiagramDescription(UUID.randomUUID()).label(// $NON-NLS-1$
    "DiagramDescriptionTest").targetObjectIdProvider(// $NON-NLS-1$
    variableManager -> "diagramTargetObjectId").canCreatePredicate(variableManager -> true).labelProvider(// $NON-NLS-1$
    variableManager -> "Diagram").toolSections(List.of()).nodeDescriptions(List.of(this.getNodeDescription(UUID.randomUUID()))).edgeDescriptions(List.of()).dropHandler(// $NON-NLS-1$
    variableManager -> new Failure("")).build();
    Node node = Node.newNode(UUID.randomUUID().toString()).descriptionId(UUID.randomUUID()).type(// $NON-NLS-1$
    "Node").targetObjectId(UUID.randomUUID().toString()).targetObjectKind(// $NON-NLS-1$
    "ecore::EPackage").targetObjectLabel(OperationTestContext.ROOT_PACKAGE_NAME).label(Label.newLabel(UUID.randomUUID().toString()).type(// $NON-NLS-1$
    "Label").text(OperationTestContext.ROOT_PACKAGE_NAME).position(Position.at(0, 0)).size(Size.of(10, 10)).alignment(Position.at(0, 0)).style(// $NON-NLS-1$ //$NON-NLS-2$
    LabelStyle.newLabelStyle().color("").fontSize(0).iconURL("").build()).build()).style(// $NON-NLS-1$
    ImageNodeStyle.newImageNodeStyle().imageURL("").scalingFactor(0).build()).position(Position.at(0, 0)).size(Size.of(10, 10)).borderNodes(List.of()).childNodes(List.of()).build();
    Diagram diagram = Diagram.newDiagram(UUID.randomUUID().toString()).descriptionId(diagramDescription.getId()).targetObjectId(UUID.randomUUID().toString()).label(// $NON-NLS-1$
    "DiagramTest").position(Position.at(0, 0)).size(Size.of(100, 100)).nodes(List.of(node)).edges(List.of()).build();
    IDiagramContext diagramContext = new IDiagramContext.NoOp() {

        @Override
        public List<ViewDeletionRequest> getViewDeletionRequests() {
            return new ArrayList<>();
        }
    };
    this.operationTestContext.getVariables().put(IDiagramContext.DIAGRAM_CONTEXT, diagramContext);
    // @formatter:on
    AdapterFactoryEditingDomain editingDomain = new EditingDomainFactory().create();
    EditingContext editingContext = new EditingContext(UUID.randomUUID().toString(), editingDomain);
    this.operationTestContext.getVariables().put(IEditingContext.EDITING_CONTEXT, editingContext);
    this.operationTestContext.getVariables().put(CONTAINER_VIEW, diagram);
    this.operationTestContext.getVariables().put(VariableManager.SELF, diagram.getNodes().get(0));
    this.deleteViewOperation = ToolFactory.eINSTANCE.createDeleteView();
    this.deleteViewOperationHandler = new DeleteViewOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.deleteViewOperation);
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) BeforeEach(org.junit.jupiter.api.BeforeEach) Node(org.eclipse.sirius.components.diagrams.Node) Size(org.eclipse.sirius.components.diagrams.Size) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ToolFactory(org.eclipse.sirius.viewpoint.description.tool.ToolFactory) ViewDeletionRequest(org.eclipse.sirius.components.diagrams.ViewDeletionRequest) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Position(org.eclipse.sirius.components.diagrams.Position) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) RectangularNodeStyle(org.eclipse.sirius.components.diagrams.RectangularNodeStyle) EditingDomainFactory(org.eclipse.sirius.components.emf.services.EditingDomainFactory) DeleteView(org.eclipse.sirius.viewpoint.description.tool.DeleteView) Diagram(org.eclipse.sirius.components.diagrams.Diagram) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) IStatus(org.eclipse.sirius.components.representations.IStatus) LineStyle(org.eclipse.sirius.components.diagrams.LineStyle) Label(org.eclipse.sirius.components.diagrams.Label) LabelStyle(org.eclipse.sirius.components.diagrams.LabelStyle) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Failure(org.eclipse.sirius.components.representations.Failure) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test) List(java.util.List) DeleteViewOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.DeleteViewOperationHandler) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) VariableManager(org.eclipse.sirius.components.representations.VariableManager) ChangeContext(org.eclipse.sirius.viewpoint.description.tool.ChangeContext) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) Node(org.eclipse.sirius.components.diagrams.Node) DeleteViewOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.DeleteViewOperationHandler) ArrayList(java.util.ArrayList) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) ViewDeletionRequest(org.eclipse.sirius.components.diagrams.ViewDeletionRequest) EditingDomainFactory(org.eclipse.sirius.components.emf.services.EditingDomainFactory) Failure(org.eclipse.sirius.components.representations.Failure) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with Diagram

use of org.eclipse.sirius.components.diagrams.Diagram in project sirius-components by eclipse-sirius.

the class DynamicDiagramsTests method testRenderSynchronizedEcoreDiagram.

@Test
void testRenderSynchronizedEcoreDiagram() throws Exception {
    DiagramDescription diagramDescription = ViewFactory.eINSTANCE.createDiagramDescription();
    // $NON-NLS-1$
    diagramDescription.setName("Simple Ecore Diagram");
    diagramDescription.setTitleExpression(NAME_EXPRESSION);
    diagramDescription.setAutoLayout(false);
    // $NON-NLS-1$
    diagramDescription.setDomainType("ecore::EPackage");
    NodeDescription eClassNode = ViewFactory.eINSTANCE.createNodeDescription();
    // $NON-NLS-1$
    eClassNode.setName("EClass Node");
    // $NON-NLS-1$
    eClassNode.setDomainType("ecore::EClass");
    eClassNode.setLabelExpression(NAME_EXPRESSION);
    // $NON-NLS-1$
    eClassNode.setSemanticCandidatesExpression("aql:self.eClassifiers");
    eClassNode.setSynchronizationPolicy(SynchronizationPolicy.SYNCHRONIZED);
    // $NON-NLS-1$
    this.setBasicNodeStyle(eClassNode, "red");
    diagramDescription.getNodeDescriptions().add(eClassNode);
    Diagram result = this.render(diagramDescription, this.fixture);
    assertThat(result).isNotNull();
    assertThat(result.getEdges()).isEmpty();
    assertThat(result.getNodes()).hasSize(2);
    // $NON-NLS-1$ //$NON-NLS-2$
    assertThat(result.getNodes()).extracting(node -> node.getLabel().getText()).containsExactlyInAnyOrder("Class1", "Class2");
}
Also used : EcoreFactory(org.eclipse.emf.ecore.EcoreFactory) BeforeEach(org.junit.jupiter.api.BeforeEach) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EcorePackage(org.eclipse.emf.ecore.EcorePackage) IRepresentationPersistenceService(org.eclipse.sirius.components.collaborative.api.IRepresentationPersistenceService) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SynchronizationPolicy(org.eclipse.sirius.components.view.SynchronizationPolicy) Diagram(org.eclipse.sirius.components.diagrams.Diagram) EClass(org.eclipse.emf.ecore.EClass) ViewFactory(org.eclipse.sirius.components.view.ViewFactory) NodeDescription(org.eclipse.sirius.components.view.NodeDescription) IEditService(org.eclipse.sirius.components.core.api.IEditService) NodeStyle(org.eclipse.sirius.components.view.NodeStyle) DiagramDescription(org.eclipse.sirius.components.view.DiagramDescription) DiagramCreationService(org.eclipse.sirius.components.collaborative.diagrams.DiagramCreationService) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) UUID(java.util.UUID) EPackage(org.eclipse.emf.ecore.EPackage) Test(org.junit.jupiter.api.Test) List(java.util.List) ILayoutService(org.eclipse.sirius.components.diagrams.layout.api.ILayoutService) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) View(org.eclipse.sirius.components.view.View) Optional(java.util.Optional) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) NodeDescription(org.eclipse.sirius.components.view.NodeDescription) DiagramDescription(org.eclipse.sirius.components.view.DiagramDescription) Diagram(org.eclipse.sirius.components.diagrams.Diagram) Test(org.junit.jupiter.api.Test)

Example 5 with Diagram

use of org.eclipse.sirius.components.diagrams.Diagram in project sirius-components by eclipse-sirius.

the class DeleteFromDiagramEventHandler method handleDelete.

private void handleDelete(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IDiagramContext diagramContext, DeleteFromDiagramInput diagramInput) {
    List<String> errors = new ArrayList<>();
    boolean atLeastOneOk = false;
    Diagram diagram = diagramContext.getDiagram();
    for (String edgeId : diagramInput.getEdgeIds()) {
        var optionalElement = this.diagramQueryService.findEdgeById(diagram, edgeId);
        if (optionalElement.isPresent()) {
            IStatus status = this.invokeDeleteEdgeTool(optionalElement.get(), editingContext, diagramContext, diagramInput.getDeletionPolicy());
            if (status instanceof Success) {
                atLeastOneOk = true;
            } else {
                errors.add(((Failure) status).getMessage());
            }
        } else {
            String message = this.messageService.edgeNotFound(edgeId.toString());
            errors.add(message);
        }
    }
    for (String nodeId : diagramInput.getNodeIds()) {
        var optionalElement = this.diagramQueryService.findNodeById(diagram, nodeId);
        if (optionalElement.isPresent()) {
            IStatus status = this.invokeDeleteNodeTool(optionalElement.get(), editingContext, diagramContext, diagramInput.getDeletionPolicy());
            if (status instanceof Success) {
                atLeastOneOk = true;
            } else {
                errors.add(((Failure) status).getMessage());
            }
        } else {
            String message = this.messageService.nodeNotFound(nodeId.toString());
            errors.add(message);
        }
    }
    this.sendResponse(payloadSink, changeDescriptionSink, errors, atLeastOneOk, diagramContext, diagramInput);
}
Also used : IStatus(org.eclipse.sirius.components.representations.IStatus) ArrayList(java.util.ArrayList) Success(org.eclipse.sirius.components.representations.Success) Diagram(org.eclipse.sirius.components.diagrams.Diagram)

Aggregations

Diagram (org.eclipse.sirius.components.diagrams.Diagram)66 Test (org.junit.jupiter.api.Test)37 Node (org.eclipse.sirius.components.diagrams.Node)34 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)28 UUID (java.util.UUID)20 Failure (org.eclipse.sirius.components.representations.Failure)20 VariableManager (org.eclipse.sirius.components.representations.VariableManager)19 ArrayList (java.util.ArrayList)18 List (java.util.List)18 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)17 Success (org.eclipse.sirius.components.representations.Success)16 Position (org.eclipse.sirius.components.diagrams.Position)14 Optional (java.util.Optional)13 Function (java.util.function.Function)12 Size (org.eclipse.sirius.components.diagrams.Size)12 IStatus (org.eclipse.sirius.components.representations.IStatus)12 Path (java.nio.file.Path)11 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)10 IPayload (org.eclipse.sirius.components.core.api.IPayload)10