Search in sources :

Example 1 with LabelStyleDescription

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

the class AbstractNodeMappingConverter method convert.

public NodeDescription convert(AbstractNodeMapping abstractNodeMapping, AQLInterpreter interpreter, Map<UUID, NodeDescription> id2NodeDescriptions) {
    LabelStyleDescriptionConverter labelStyleDescriptionConverter = new LabelStyleDescriptionConverter(interpreter, this.objectService);
    Function<VariableManager, org.eclipse.sirius.viewpoint.description.style.LabelStyleDescription> abstractNodeMappingDescriptionProvider = new LabelStyleDescriptionProvider(interpreter, abstractNodeMapping);
    Function<VariableManager, String> labelIdProvider = this.getLabelIdProvider();
    Function<VariableManager, String> labelExpressionProvider = this.getLabelExpressionProvider(interpreter, abstractNodeMappingDescriptionProvider);
    Function<VariableManager, LabelStyleDescription> labelStyleDescriptionProvider = this.getLabelStyleDescriptionProvider(labelStyleDescriptionConverter, abstractNodeMappingDescriptionProvider);
    // @formatter:off
    LabelDescription labelDescription = LabelDescription.newLabelDescription(this.identifierProvider.getIdentifier(abstractNodeMapping) + LabelDescription.LABEL_SUFFIX).idProvider(labelIdProvider).textProvider(labelExpressionProvider).styleDescriptionProvider(labelStyleDescriptionProvider).build();
    // @formatter:on
    Function<VariableManager, String> semanticTargetIdProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getId).orElse(null);
    };
    Function<VariableManager, String> semanticTargetKindProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getKind).orElse(null);
    };
    Function<VariableManager, String> semanticTargetLabelProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getLabel).orElse(null);
    };
    Function<VariableManager, INodeStyle> styleProvider = new AbstractNodeMappingStyleProvider(interpreter, abstractNodeMapping);
    Function<VariableManager, String> typeProvider = variableManager -> {
        var result = NodeType.NODE_RECTANGLE;
        INodeStyle style = styleProvider.apply(variableManager);
        if (style instanceof ImageNodeStyle) {
            result = NodeType.NODE_IMAGE;
        } else if (style instanceof ListItemNodeStyle) {
            result = NodeType.NODE_LIST_ITEM;
        } else if (style instanceof ListNodeStyle) {
            result = NodeType.NODE_LIST;
        }
        return result;
    };
    AbstractNodeMappingSizeProvider sizeProvider = new AbstractNodeMappingSizeProvider(interpreter, abstractNodeMapping);
    String domainClass = abstractNodeMapping.getDomainClass();
    String semanticCandidatesExpression = abstractNodeMapping.getSemanticCandidatesExpression();
    String preconditionExpression = abstractNodeMapping.getPreconditionExpression();
    Function<VariableManager, List<?>> semanticElementsProvider = this.semanticCandidatesProviderFactory.getSemanticCandidatesProvider(interpreter, domainClass, semanticCandidatesExpression, preconditionExpression);
    List<NodeDescription> childNodeDescriptions = this.getChildNodeDescriptions(abstractNodeMapping, interpreter, id2NodeDescriptions);
    // @formatter:off
    List<NodeDescription> borderNodeDescriptions = abstractNodeMapping.getBorderedNodeMappings().stream().map(borderNodeMapping -> this.convert(borderNodeMapping, interpreter, id2NodeDescriptions)).collect(Collectors.toList());
    // @formatter:on
    ToolConverter toolConverter = new ToolConverter(interpreter, this.editService, this.modelOperationHandlerSwitchProvider);
    var deleteHandler = toolConverter.createDeleteToolHandler(abstractNodeMapping.getDeletionDescription());
    var labelEditHandler = toolConverter.createDirectEditToolHandler(abstractNodeMapping.getLabelDirectEdit());
    SynchronizationPolicy synchronizationPolicy = SynchronizationPolicy.SYNCHRONIZED;
    if (!abstractNodeMapping.isCreateElements()) {
        synchronizationPolicy = SynchronizationPolicy.UNSYNCHRONIZED;
    }
    // @formatter:off
    NodeDescription description = NodeDescription.newNodeDescription(UUID.fromString(this.identifierProvider.getIdentifier(abstractNodeMapping))).typeProvider(typeProvider).targetObjectIdProvider(semanticTargetIdProvider).targetObjectKindProvider(semanticTargetKindProvider).targetObjectLabelProvider(semanticTargetLabelProvider).semanticElementsProvider(semanticElementsProvider).synchronizationPolicy(synchronizationPolicy).labelDescription(labelDescription).styleProvider(styleProvider).sizeProvider(sizeProvider).borderNodeDescriptions(borderNodeDescriptions).childNodeDescriptions(childNodeDescriptions).labelEditHandler(labelEditHandler).deleteHandler(deleteHandler).build();
    // @formatter:on
    id2NodeDescriptions.put(description.getId(), description);
    return description;
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) ListNodeStyle(org.eclipse.sirius.components.diagrams.ListNodeStyle) StringValueProvider(org.eclipse.sirius.components.compatibility.utils.StringValueProvider) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) IEditService(org.eclipse.sirius.components.core.api.IEditService) StyleFactory(org.eclipse.sirius.viewpoint.description.style.StyleFactory) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) ListItemNodeStyle(org.eclipse.sirius.components.diagrams.ListItemNodeStyle) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Objects(java.util.Objects) List(java.util.List) NodeType(org.eclipse.sirius.components.diagrams.NodeType) Optional(java.util.Optional) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) List(java.util.List) ListNodeStyle(org.eclipse.sirius.components.diagrams.ListNodeStyle) ListItemNodeStyle(org.eclipse.sirius.components.diagrams.ListItemNodeStyle) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle)

Example 2 with LabelStyleDescription

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

the class EdgeMappingConverter method createLabelDescription.

private LabelDescription createLabelDescription(AQLInterpreter interpreter, LabelStyleDescriptionConverter labelStyleDescriptionConverter, BasicLabelStyleDescription siriusBasicLabelStyleDescription, String idSuffix, EdgeMapping edgeMapping) {
    String labelExpression = siriusBasicLabelStyleDescription.getLabelExpression();
    Function<VariableManager, LabelStyleDescription> labelStyleDescriptionProvider = variableManager -> {
        return labelStyleDescriptionConverter.convert(siriusBasicLabelStyleDescription);
    };
    Function<VariableManager, String> labelIdProvider = variableManager -> {
        Object parentId = variableManager.getVariables().get(LabelDescription.OWNER_ID);
        return String.valueOf(parentId) + idSuffix;
    };
    String id = this.identifierProvider.getIdentifier(edgeMapping) + idSuffix;
    StringValueProvider textProvider = new StringValueProvider(interpreter, labelExpression);
    // @formatter:off
    return LabelDescription.newLabelDescription(id).idProvider(labelIdProvider).textProvider(textProvider).styleDescriptionProvider(labelStyleDescriptionProvider).build();
// @formatter:on
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) EdgeStyleDescription(org.eclipse.sirius.diagram.description.style.EdgeStyleDescription) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) StringValueProvider(org.eclipse.sirius.components.compatibility.utils.StringValueProvider) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) Builder(org.eclipse.sirius.components.diagrams.description.EdgeDescription.Builder) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) IEditService(org.eclipse.sirius.components.core.api.IEditService) EdgeStyle(org.eclipse.sirius.components.diagrams.EdgeStyle) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Element(org.eclipse.sirius.components.representations.Element) Objects(java.util.Objects) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) DiagramElementMapping(org.eclipse.sirius.diagram.description.DiagramElementMapping) Optional(java.util.Optional) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) StringValueProvider(org.eclipse.sirius.components.compatibility.utils.StringValueProvider) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)

Example 3 with LabelStyleDescription

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

the class DiagramRendererEdgeTests method getNodeDescription.

private NodeDescription getNodeDescription(UUID nodeDescriptionId) {
    // @formatter:off
    LabelStyleDescription labelStyleDescription = LabelStyleDescription.newLabelStyleDescription().colorProvider(// $NON-NLS-1$
    variableManager -> "#000000").fontSizeProvider(variableManager -> 16).boldProvider(variableManager -> false).italicProvider(variableManager -> false).underlineProvider(variableManager -> false).strikeThroughProvider(variableManager -> false).iconURLProvider(// $NON-NLS-1$
    variableManager -> "").build();
    LabelDescription labelDescription = // $NON-NLS-1$
    LabelDescription.newLabelDescription("labelDescriptionId").idProvider(// $NON-NLS-1$
    variableManager -> "labelId").textProvider(// $NON-NLS-1$
    variableManager -> "Node").styleDescriptionProvider(variableManager -> labelStyleDescription).build();
    Function<VariableManager, INodeStyle> nodeStyleProvider = variableManager -> {
        return RectangularNodeStyle.newRectangularNodeStyle().color(// $NON-NLS-1$
        "").borderColor(// $NON-NLS-1$
        "").borderSize(0).borderStyle(LineStyle.Solid).build();
    };
    Function<VariableManager, String> targetObjectIdProvider = variableManager -> {
        Object object = variableManager.getVariables().get(VariableManager.SELF);
        if (object instanceof String) {
            // $NON-NLS-1$
            return nodeDescriptionId + "__" + object;
        }
        return null;
    };
    return NodeDescription.newNodeDescription(nodeDescriptionId).typeProvider(// $NON-NLS-1$
    variableManager -> "").semanticElementsProvider(variableManager -> List.of(FIRST_OBJECT_ID, SECOND_OBJECT_ID)).targetObjectIdProvider(targetObjectIdProvider).targetObjectKindProvider(// $NON-NLS-1$
    variableManager -> "").targetObjectLabelProvider(// $NON-NLS-1$
    variableManager -> "").labelDescription(labelDescription).styleProvider(nodeStyleProvider).sizeProvider(variableManager -> Size.UNDEFINED).borderNodeDescriptions(new ArrayList<>()).childNodeDescriptions(new ArrayList<>()).labelEditHandler((variableManager, newLabel) -> new Success()).deleteHandler(variableManager -> new Success()).build();
// @formatter:on
}
Also used : Edge(org.eclipse.sirius.components.diagrams.Edge) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Node(org.eclipse.sirius.components.diagrams.Node) Size(org.eclipse.sirius.components.diagrams.Size) ArrowStyle(org.eclipse.sirius.components.diagrams.ArrowStyle) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) HashMap(java.util.HashMap) 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) Diagram(org.eclipse.sirius.components.diagrams.Diagram) Map(java.util.Map) LineStyle(org.eclipse.sirius.components.diagrams.LineStyle) EdgeStyle(org.eclipse.sirius.components.diagrams.EdgeStyle) Failure(org.eclipse.sirius.components.representations.Failure) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Element(org.eclipse.sirius.components.representations.Element) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) DiagramComponentProps(org.eclipse.sirius.components.diagrams.components.DiagramComponentProps) NodeElementProps(org.eclipse.sirius.components.diagrams.elements.NodeElementProps) Optional(java.util.Optional) DiagramComponent(org.eclipse.sirius.components.diagrams.components.DiagramComponent) VariableManager(org.eclipse.sirius.components.representations.VariableManager) VariableManager(org.eclipse.sirius.components.representations.VariableManager) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) ArrayList(java.util.ArrayList) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) Success(org.eclipse.sirius.components.representations.Success)

Example 4 with LabelStyleDescription

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

the class DiagramRendererNodeTests method createDiagram.

/**
 * Create a diagram with one element that match with the given styleProvider/typeProvider.
 */
private Diagram createDiagram(Function<VariableManager, INodeStyle> styleProvider, Function<VariableManager, String> typeProvider, Function<VariableManager, Size> sizeProvider, Optional<Diagram> previousDiagram) {
    // @formatter:off
    LabelStyleDescription labelStyleDescription = LabelStyleDescription.newLabelStyleDescription().italicProvider(VariableManager -> true).boldProvider(VariableManager -> true).underlineProvider(VariableManager -> true).strikeThroughProvider(VariableManager -> true).colorProvider(VariableManager -> LABEL_COLOR).fontSizeProvider(variableManager -> LABEL_FONT_SIZE).iconURLProvider(// $NON-NLS-1$
    VariableManager -> "").build();
    LabelDescription labelDescription = // $NON-NLS-1$
    LabelDescription.newLabelDescription("labelDescriptionId").idProvider(variableManager -> LABEL_ID).textProvider(variableManager -> LABEL_TEXT).styleDescriptionProvider(variableManager -> labelStyleDescription).build();
    NodeDescription nodeDescription = NodeDescription.newNodeDescription(NODE_DESCRIPTION_ID).typeProvider(typeProvider).semanticElementsProvider(variableManager -> List.of(new Object())).targetObjectIdProvider(// $NON-NLS-1$
    variableManager -> "targetObjectId").targetObjectKindProvider(// $NON-NLS-1$
    variableManager -> "").targetObjectLabelProvider(// $NON-NLS-1$
    variableManager -> "").labelDescription(labelDescription).styleProvider(styleProvider).sizeProvider(sizeProvider).borderNodeDescriptions(new ArrayList<>()).childNodeDescriptions(new ArrayList<>()).labelEditHandler((variableManager, newLabel) -> new Success()).deleteHandler(variableManager -> new Success()).build();
    DiagramDescription diagramDescription = DiagramDescription.newDiagramDescription(UUID.randomUUID()).label(// $NON-NLS-1$
    "").canCreatePredicate(variableManager -> true).targetObjectIdProvider(// $NON-NLS-1$
    variableManager -> "diagramTargetObjectId").labelProvider(variableManager -> DIAGRAM_LABEL).nodeDescriptions(List.of(nodeDescription)).edgeDescriptions(new ArrayList<>()).toolSections(List.of()).dropHandler(// $NON-NLS-1$
    variableManager -> new Failure("")).build();
    // @formatter:on
    VariableManager variableManager = new VariableManager();
    // @formatter:off
    DiagramComponentProps props = DiagramComponentProps.newDiagramComponentProps().variableManager(variableManager).diagramDescription(diagramDescription).viewCreationRequests(List.of()).viewDeletionRequests(List.of()).previousDiagram(previousDiagram).build();
    // @formatter:on
    Element element = new Element(DiagramComponent.class, props);
    return new DiagramRenderer().render(element);
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Node(org.eclipse.sirius.components.diagrams.Node) Size(org.eclipse.sirius.components.diagrams.Size) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) 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) Diagram(org.eclipse.sirius.components.diagrams.Diagram) LineStyle(org.eclipse.sirius.components.diagrams.LineStyle) Label(org.eclipse.sirius.components.diagrams.Label) LabelStyle(org.eclipse.sirius.components.diagrams.LabelStyle) Failure(org.eclipse.sirius.components.representations.Failure) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) Success(org.eclipse.sirius.components.representations.Success) Set(java.util.Set) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) CustomizableProperties(org.eclipse.sirius.components.diagrams.CustomizableProperties) Element(org.eclipse.sirius.components.representations.Element) Test(org.junit.jupiter.api.Test) List(java.util.List) DiagramComponentProps(org.eclipse.sirius.components.diagrams.components.DiagramComponentProps) Optional(java.util.Optional) DiagramComponent(org.eclipse.sirius.components.diagrams.components.DiagramComponent) VariableManager(org.eclipse.sirius.components.representations.VariableManager) VariableManager(org.eclipse.sirius.components.representations.VariableManager) Element(org.eclipse.sirius.components.representations.Element) ArrayList(java.util.ArrayList) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) Success(org.eclipse.sirius.components.representations.Success) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) Failure(org.eclipse.sirius.components.representations.Failure) DiagramComponentProps(org.eclipse.sirius.components.diagrams.components.DiagramComponentProps)

Example 5 with LabelStyleDescription

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

the class UnsynchronizedDiagramTests method getDiagramDescription.

private DiagramDescription getDiagramDescription() {
    // @formatter:off
    LabelStyleDescription labelStyleDescription = LabelStyleDescription.newLabelStyleDescription().italicProvider(VariableManager -> true).boldProvider(VariableManager -> true).underlineProvider(VariableManager -> true).strikeThroughProvider(VariableManager -> true).colorProvider(// $NON-NLS-1$
    VariableManager -> "#FFFFFF").fontSizeProvider(variableManager -> 10).iconURLProvider(// $NON-NLS-1$
    VariableManager -> "").build();
    LabelDescription labelDescription = // $NON-NLS-1$
    LabelDescription.newLabelDescription("labelDescriptionId").idProvider(// $NON-NLS-1$
    variableManager -> "labelid").textProvider(// $NON-NLS-1$
    variableManager -> "label").styleDescriptionProvider(variableManager -> labelStyleDescription).build();
    Function<VariableManager, INodeStyle> styleProvider = variableManager -> {
        return RectangularNodeStyle.newRectangularNodeStyle().color(// $NON-NLS-1$
        "").borderColor(// $NON-NLS-1$
        "").borderSize(0).borderStyle(LineStyle.Solid).build();
    };
    NodeDescription subUnsynchronizedNodeDescription = // $NON-NLS-1$
    NodeDescription.newNodeDescription(UUID.nameUUIDFromBytes("subUnsynchronized".getBytes())).synchronizationPolicy(SynchronizationPolicy.UNSYNCHRONIZED).typeProvider(variableManager -> NODE_TYPE).semanticElementsProvider(variableManager -> List.of(new Object())).targetObjectIdProvider(variableManager -> TARGET_OBJECT_ID).targetObjectKindProvider(// $NON-NLS-1$
    variableManager -> "").targetObjectLabelProvider(// $NON-NLS-1$
    variableManager -> "").labelDescription(labelDescription).styleProvider(styleProvider).sizeProvider(variableManager -> Size.UNDEFINED).borderNodeDescriptions(new ArrayList<>()).childNodeDescriptions(new ArrayList<>()).labelEditHandler((variableManager, newLabel) -> new Success()).deleteHandler(variableManager -> new Success()).build();
    NodeDescription unsynchronizedNodeDescription = // $NON-NLS-1$
    NodeDescription.newNodeDescription(UUID.nameUUIDFromBytes("unsynchronized".getBytes())).synchronizationPolicy(SynchronizationPolicy.UNSYNCHRONIZED).typeProvider(variableManager -> NODE_TYPE).semanticElementsProvider(variableManager -> List.of(new Object())).targetObjectIdProvider(variableManager -> TARGET_OBJECT_ID).targetObjectKindProvider(// $NON-NLS-1$
    variableManager -> "").targetObjectLabelProvider(// $NON-NLS-1$
    variableManager -> "").labelDescription(labelDescription).styleProvider(styleProvider).sizeProvider(variableManager -> Size.UNDEFINED).borderNodeDescriptions(new ArrayList<>()).childNodeDescriptions(List.of(subUnsynchronizedNodeDescription)).labelEditHandler((variableManager, newLabel) -> new Success()).deleteHandler(variableManager -> new Success()).build();
    NodeDescription synchronizedNodeDescription = // $NON-NLS-1$
    NodeDescription.newNodeDescription(UUID.nameUUIDFromBytes("synchronized".getBytes())).synchronizationPolicy(SynchronizationPolicy.SYNCHRONIZED).typeProvider(variableManager -> NODE_TYPE).semanticElementsProvider(variableManager -> List.of(new Object())).targetObjectIdProvider(variableManager -> TARGET_OBJECT_ID).targetObjectKindProvider(// $NON-NLS-1$
    variableManager -> "").targetObjectLabelProvider(// $NON-NLS-1$
    variableManager -> "").labelDescription(labelDescription).styleProvider(styleProvider).sizeProvider(variableManager -> Size.UNDEFINED).borderNodeDescriptions(new ArrayList<>()).childNodeDescriptions(new ArrayList<>()).labelEditHandler((variableManager, newLabel) -> new Success()).deleteHandler(variableManager -> new Success()).build();
    DiagramDescription diagramDescription = // $NON-NLS-1$
    DiagramDescription.newDiagramDescription(UUID.nameUUIDFromBytes("diagram".getBytes())).label(// $NON-NLS-1$
    "").canCreatePredicate(variableManager -> true).targetObjectIdProvider(// $NON-NLS-1$
    variableManager -> "diagramTargetObjectId").labelProvider(// $NON-NLS-1$
    variableManager -> "label").nodeDescriptions(List.of(unsynchronizedNodeDescription, synchronizedNodeDescription)).edgeDescriptions(List.of()).toolSections(List.of()).dropHandler(// $NON-NLS-1$
    variableManager -> new Failure("")).build();
    return diagramDescription;
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Node(org.eclipse.sirius.components.diagrams.Node) Size(org.eclipse.sirius.components.diagrams.Size) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ViewDeletionRequest(org.eclipse.sirius.components.diagrams.ViewDeletionRequest) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) 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) Diagram(org.eclipse.sirius.components.diagrams.Diagram) LineStyle(org.eclipse.sirius.components.diagrams.LineStyle) Failure(org.eclipse.sirius.components.representations.Failure) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Element(org.eclipse.sirius.components.representations.Element) Test(org.junit.jupiter.api.Test) List(java.util.List) DiagramComponentProps(org.eclipse.sirius.components.diagrams.components.DiagramComponentProps) Optional(java.util.Optional) DiagramComponent(org.eclipse.sirius.components.diagrams.components.DiagramComponent) VariableManager(org.eclipse.sirius.components.representations.VariableManager) ViewCreationRequest(org.eclipse.sirius.components.diagrams.ViewCreationRequest) VariableManager(org.eclipse.sirius.components.representations.VariableManager) ArrayList(java.util.ArrayList) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) Success(org.eclipse.sirius.components.representations.Success) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) Failure(org.eclipse.sirius.components.representations.Failure)

Aggregations

LabelStyleDescription (org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)13 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)12 VariableManager (org.eclipse.sirius.components.representations.VariableManager)12 List (java.util.List)11 UUID (java.util.UUID)11 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)11 Test (org.junit.jupiter.api.Test)9 Optional (java.util.Optional)8 Function (java.util.function.Function)8 Size (org.eclipse.sirius.components.diagrams.Size)8 ArrayList (java.util.ArrayList)7 INodeStyle (org.eclipse.sirius.components.diagrams.INodeStyle)7 Success (org.eclipse.sirius.components.representations.Success)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 IObjectService (org.eclipse.sirius.components.core.api.IObjectService)6 LineStyle (org.eclipse.sirius.components.diagrams.LineStyle)6 RectangularNodeStyle (org.eclipse.sirius.components.diagrams.RectangularNodeStyle)6 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)6 AQLInterpreter (org.eclipse.sirius.components.interpreter.AQLInterpreter)6 IIdentifierProvider (org.eclipse.sirius.components.compatibility.api.IIdentifierProvider)5