Search in sources :

Example 1 with SynchronizationPolicy

use of org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy 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 SynchronizationPolicy

use of org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy 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)

Example 3 with SynchronizationPolicy

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

the class EdgeComponent method render.

@Override
public Element render() {
    VariableManager variableManager = this.props.getVariableManager();
    EdgeDescription edgeDescription = this.props.getEdgeDescription();
    IEdgesRequestor edgesRequestor = this.props.getEdgesRequestor();
    DiagramRenderingCache cache = this.props.getCache();
    List<Element> children = new ArrayList<>();
    // @formatter:off
    boolean hasCandidates = this.hasNodeCandidates(edgeDescription.getSourceNodeDescriptions(), cache) && this.hasNodeCandidates(edgeDescription.getTargetNodeDescriptions(), cache);
    if (hasCandidates) {
        VariableManager semanticElementsVariableManager = new VariableManager();
        variableManager.getVariables().forEach(semanticElementsVariableManager::put);
        semanticElementsVariableManager.put(DiagramDescription.CACHE, cache);
        List<?> semanticElements = edgeDescription.getSemanticElementsProvider().apply(semanticElementsVariableManager);
        int count = 0;
        for (Object semanticElement : semanticElements) {
            VariableManager edgeVariableManager = variableManager.createChild();
            edgeVariableManager.put(VariableManager.SELF, semanticElement);
            edgeVariableManager.put(DiagramDescription.CACHE, cache);
            String targetObjectId = edgeDescription.getTargetObjectIdProvider().apply(edgeVariableManager);
            String targetObjectKind = edgeDescription.getTargetObjectKindProvider().apply(edgeVariableManager);
            String targetObjectLabel = edgeDescription.getTargetObjectLabelProvider().apply(edgeVariableManager);
            List<Element> sourceNodes = edgeDescription.getSourceNodesProvider().apply(edgeVariableManager);
            if (!sourceNodes.isEmpty()) {
                List<Element> targetNodes = edgeDescription.getTargetNodesProvider().apply(edgeVariableManager);
                for (Element sourceNode : sourceNodes) {
                    for (Element targetNode : targetNodes) {
                        String id = this.computeEdgeId(edgeDescription, sourceNode, targetNode, count);
                        var optionalPreviousEdge = edgesRequestor.getById(id);
                        var edgeInstanceVariableManager = edgeVariableManager.createChild();
                        edgeInstanceVariableManager.put(EdgeDescription.SEMANTIC_EDGE_SOURCE, cache.getNodeToObject().get(sourceNode));
                        edgeInstanceVariableManager.put(EdgeDescription.SEMANTIC_EDGE_TARGET, cache.getNodeToObject().get(targetNode));
                        SynchronizationPolicy synchronizationPolicy = edgeDescription.getSynchronizationPolicy();
                        boolean shouldRender = synchronizationPolicy == SynchronizationPolicy.SYNCHRONIZED || (synchronizationPolicy == SynchronizationPolicy.UNSYNCHRONIZED && optionalPreviousEdge.isPresent());
                        if (shouldRender) {
                            EdgeStyle style = edgeDescription.getStyleProvider().apply(edgeInstanceVariableManager);
                            String sourceId = this.getId(sourceNode);
                            String targetId = this.getId(targetNode);
                            // @formatter:off
                            String edgeType = optionalPreviousEdge.map(Edge::getType).orElse(// $NON-NLS-1$
                            "edge:straight");
                            List<Position> routingPoints = optionalPreviousEdge.map(Edge::getRoutingPoints).orElse(List.of());
                            Ratio sourceAnchorRelativePosition = optionalPreviousEdge.map(Edge::getSourceAnchorRelativePosition).orElse(Ratio.UNDEFINED);
                            Ratio targetAnchorRelativePosition = optionalPreviousEdge.map(Edge::getTargetAnchorRelativePosition).orElse(Ratio.UNDEFINED);
                            List<Element> labelChildren = this.getLabelsChildren(edgeDescription, edgeInstanceVariableManager, optionalPreviousEdge, id, routingPoints);
                            EdgeElementProps edgeElementProps = EdgeElementProps.newEdgeElementProps(id).type(edgeType).descriptionId(edgeDescription.getId()).targetObjectId(targetObjectId).targetObjectKind(targetObjectKind).targetObjectLabel(targetObjectLabel).sourceId(sourceId).targetId(targetId).style(style).routingPoints(routingPoints).sourceAnchorRelativePosition(sourceAnchorRelativePosition).targetAnchorRelativePosition(targetAnchorRelativePosition).children(labelChildren).build();
                            // @formatter:on
                            Element edgeElement = new Element(EdgeElementProps.TYPE, edgeElementProps);
                            children.add(edgeElement);
                            count++;
                        }
                    }
                }
            }
        }
    }
    FragmentProps fragmentProps = new FragmentProps(children);
    return new Fragment(fragmentProps);
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) Position(org.eclipse.sirius.components.diagrams.Position) Element(org.eclipse.sirius.components.representations.Element) ArrayList(java.util.ArrayList) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Fragment(org.eclipse.sirius.components.representations.Fragment) EdgeElementProps(org.eclipse.sirius.components.diagrams.elements.EdgeElementProps) DiagramRenderingCache(org.eclipse.sirius.components.diagrams.renderer.DiagramRenderingCache) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Ratio(org.eclipse.sirius.components.diagrams.Ratio) FragmentProps(org.eclipse.sirius.components.representations.FragmentProps) EdgeStyle(org.eclipse.sirius.components.diagrams.EdgeStyle)

Example 4 with SynchronizationPolicy

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

the class DiagramDescriptionConverter method convert.

private EdgeDescription convert(org.eclipse.sirius.components.view.EdgeDescription viewEdgeDescription, AQLInterpreter interpreter) {
    Function<VariableManager, List<?>> semanticElementsProvider;
    if (viewEdgeDescription.isIsDomainBasedEdge()) {
        // Same logic as for nodes.
        semanticElementsProvider = this.getSemanticElementsProvider(viewEdgeDescription, interpreter);
    } else {
        // 
        var sourceNodeDescriptions = viewEdgeDescription.getSourceNodeDescriptions().stream().map(this.convertedNodes::get);
        semanticElementsProvider = new RelationBasedSemanticElementsProvider(sourceNodeDescriptions.map(NodeDescription::getId).collect(Collectors.toList()));
    }
    Function<VariableManager, List<Element>> sourceNodesProvider = null;
    if (viewEdgeDescription.isIsDomainBasedEdge()) {
        sourceNodesProvider = variableManager -> {
            var optionalCache = variableManager.get(DiagramDescription.CACHE, DiagramRenderingCache.class);
            if (optionalCache.isEmpty()) {
                return List.of();
            }
            DiagramRenderingCache cache = optionalCache.get();
            String sourceFinderExpression = viewEdgeDescription.getSourceNodesExpression();
            Result result = interpreter.evaluateExpression(variableManager.getVariables(), sourceFinderExpression);
            List<Object> semanticCandidates = result.asObjects().orElse(List.of());
            var nodeCandidates = semanticCandidates.stream().flatMap(semanticObject -> cache.getElementsRepresenting(semanticObject).stream());
            // @formatter:off
            return nodeCandidates.filter(nodeElement -> viewEdgeDescription.getSourceNodeDescriptions().stream().anyMatch(nodeDescription -> this.isFromDescription(nodeElement, nodeDescription))).filter(Objects::nonNull).collect(Collectors.toList());
        // @formatter:on
        };
    } else {
        sourceNodesProvider = variableManager -> {
            var optionalObject = variableManager.get(VariableManager.SELF, Object.class);
            var optionalCache = variableManager.get(DiagramDescription.CACHE, DiagramRenderingCache.class);
            if (optionalObject.isEmpty() || optionalCache.isEmpty()) {
                return List.of();
            }
            DiagramRenderingCache cache = optionalCache.get();
            Object object = optionalObject.get();
            // @formatter:off
            return cache.getElementsRepresenting(object).stream().filter(this.isFromCompatibleSourceMapping(viewEdgeDescription)).filter(Objects::nonNull).collect(Collectors.toList());
        // @formatter:on
        };
    }
    Function<VariableManager, List<Element>> targetNodesProvider = new TargetNodesProvider(this.idProvider, viewEdgeDescription, interpreter);
    Function<VariableManager, EdgeStyle> styleProvider = variableManager -> {
        // @formatter:off
        var effectiveStyle = viewEdgeDescription.getConditionalStyles().stream().filter(style -> this.matches(interpreter, style.getCondition(), variableManager)).map(org.eclipse.sirius.components.view.EdgeStyle.class::cast).findFirst().orElseGet(viewEdgeDescription::getStyle);
        // @formatter:on
        return this.stylesFactory.createEdgeStyle(effectiveStyle);
    };
    SynchronizationPolicy synchronizationPolicy = SynchronizationPolicy.valueOf(viewEdgeDescription.getSynchronizationPolicy().getName());
    // @formatter:off
    var builder = EdgeDescription.newEdgeDescription(this.idProvider.apply(viewEdgeDescription)).targetObjectIdProvider(this.semanticTargetIdProvider).targetObjectKindProvider(this.semanticTargetKindProvider).targetObjectLabelProvider(this.semanticTargetLabelProvider).sourceNodeDescriptions(viewEdgeDescription.getSourceNodeDescriptions().stream().map(this.convertedNodes::get).collect(Collectors.toList())).targetNodeDescriptions(viewEdgeDescription.getTargetNodeDescriptions().stream().map(this.convertedNodes::get).collect(Collectors.toList())).semanticElementsProvider(semanticElementsProvider).synchronizationPolicy(synchronizationPolicy).sourceNodesProvider(sourceNodesProvider).targetNodesProvider(targetNodesProvider).styleProvider(styleProvider).deleteHandler(this.createDeleteHandler(viewEdgeDescription, interpreter)).labelEditHandler(this.createLabelEditHandler(viewEdgeDescription, interpreter));
    // $NON-NLS-1$
    this.getSpecificEdgeLabelDescription(viewEdgeDescription, viewEdgeDescription.getBeginLabelExpression(), "_beginlabel", interpreter).ifPresent(builder::beginLabelDescription);
    // $NON-NLS-1$
    this.getSpecificEdgeLabelDescription(viewEdgeDescription, viewEdgeDescription.getLabelExpression(), "_centerlabel", interpreter).ifPresent(builder::centerLabelDescription);
    // $NON-NLS-1$
    this.getSpecificEdgeLabelDescription(viewEdgeDescription, viewEdgeDescription.getEndLabelExpression(), "_endlabel", interpreter).ifPresent(builder::endLabelDescription);
    EdgeDescription result = builder.build();
    this.convertedEdges.put(viewEdgeDescription, result);
    return result;
// @formatter:on
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) BiFunction(java.util.function.BiFunction) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection) IStatus(org.eclipse.sirius.components.representations.IStatus) ITool(org.eclipse.sirius.components.diagrams.tools.ITool) Map(java.util.Map) DomainClassPredicate(org.eclipse.sirius.components.emf.compatibility.DomainClassPredicate) NodeStyle(org.eclipse.sirius.components.view.NodeStyle) Predicate(java.util.function.Predicate) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) Result(org.eclipse.sirius.components.interpreter.Result) EObject(org.eclipse.emf.ecore.EObject) 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) SingleClickOnTwoDiagramElementsCandidate(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsCandidate) Optional(java.util.Optional) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Size(org.eclipse.sirius.components.diagrams.Size) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Status(org.eclipse.sirius.components.interpreter.Status) EClass(org.eclipse.emf.ecore.EClass) SingleClickOnDiagramElementTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool) CanonicalBehaviors(org.eclipse.sirius.components.emf.view.CanonicalBehaviors) SingleClickOnTwoDiagramElementsTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool) IEditService(org.eclipse.sirius.components.core.api.IEditService) EdgeStyle(org.eclipse.sirius.components.diagrams.EdgeStyle) DiagramRenderingCache(org.eclipse.sirius.components.diagrams.renderer.DiagramRenderingCache) ToolInterpreter(org.eclipse.sirius.components.emf.view.ToolInterpreter) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Failure(org.eclipse.sirius.components.representations.Failure) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) DiagramElementDescription(org.eclipse.sirius.components.view.DiagramElementDescription) EdgeTool(org.eclipse.sirius.components.view.EdgeTool) LabelEditTool(org.eclipse.sirius.components.view.LabelEditTool) ViewPackage(org.eclipse.sirius.components.view.ViewPackage) NodeElementProps(org.eclipse.sirius.components.diagrams.elements.NodeElementProps) VariableManager(org.eclipse.sirius.components.representations.VariableManager) DeleteTool(org.eclipse.sirius.components.view.DeleteTool) NodeTool(org.eclipse.sirius.components.view.NodeTool) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Result(org.eclipse.sirius.components.interpreter.Result) DiagramRenderingCache(org.eclipse.sirius.components.diagrams.renderer.DiagramRenderingCache) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) List(java.util.List) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) EdgeStyle(org.eclipse.sirius.components.diagrams.EdgeStyle)

Example 5 with SynchronizationPolicy

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

the class NodeComponent method shouldRender.

private boolean shouldRender(String targetObjectId, Optional<Node> optionalPreviousNode) {
    boolean shouldRender = false;
    NodeDescription nodeDescription = this.props.getNodeDescription();
    SynchronizationPolicy synchronizationPolicy = nodeDescription.getSynchronizationPolicy();
    if (synchronizationPolicy == SynchronizationPolicy.SYNCHRONIZED) {
        shouldRender = true;
    } else if (synchronizationPolicy == SynchronizationPolicy.UNSYNCHRONIZED) {
        if (optionalPreviousNode.isPresent()) {
            Node previousNode = optionalPreviousNode.get();
            shouldRender = !this.existsViewDeletionRequested(previousNode.getId());
        } else {
            shouldRender = this.existsViewCreationRequested(targetObjectId);
        }
    }
    return shouldRender;
}
Also used : NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Node(org.eclipse.sirius.components.diagrams.Node)

Aggregations

SynchronizationPolicy (org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy)8 ArrayList (java.util.ArrayList)7 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)7 VariableManager (org.eclipse.sirius.components.representations.VariableManager)7 List (java.util.List)6 UUID (java.util.UUID)6 Function (java.util.function.Function)6 INodeStyle (org.eclipse.sirius.components.diagrams.INodeStyle)6 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)6 LabelStyleDescription (org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)6 Size (org.eclipse.sirius.components.diagrams.Size)5 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)5 Failure (org.eclipse.sirius.components.representations.Failure)5 Optional (java.util.Optional)4 IDiagramContext (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext)4 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)4 Map (java.util.Map)3 Objects (java.util.Objects)3 Collectors (java.util.stream.Collectors)3 Diagram (org.eclipse.sirius.components.diagrams.Diagram)3