Search in sources :

Example 1 with IdentifiedElementQuery

use of org.eclipse.sirius.business.api.query.IdentifiedElementQuery in project sirius-components by eclipse-sirius.

the class ToolProvider method convertEdgeCreationDescription.

private SingleClickOnTwoDiagramElementsTool convertEdgeCreationDescription(Map<UUID, NodeDescription> id2NodeDescriptions, AQLInterpreter interpreter, EdgeCreationDescription edgeCreationDescription) {
    String id = this.identifierProvider.getIdentifier(edgeCreationDescription);
    String label = new IdentifiedElementQuery(edgeCreationDescription).getLabel();
    String imagePath = this.toolImageProviderFactory.getToolImageProvider(edgeCreationDescription).get();
    // @formatter:off
    List<SingleClickOnTwoDiagramElementsCandidate> edgeCandidates = new ArrayList<>();
    for (EdgeMapping edgeMapping : edgeCreationDescription.getEdgeMappings()) {
        List<NodeDescription> sources = edgeMapping.getSourceMapping().stream().filter(AbstractNodeMapping.class::isInstance).map(this.identifierProvider::getIdentifier).map(UUID::fromString).map(id2NodeDescriptions::get).collect(Collectors.toList());
        List<NodeDescription> targets = edgeMapping.getTargetMapping().stream().filter(AbstractNodeMapping.class::isInstance).map(this.identifierProvider::getIdentifier).map(UUID::fromString).map(id2NodeDescriptions::get).collect(Collectors.toList());
        SingleClickOnTwoDiagramElementsCandidate edgeCandidate = SingleClickOnTwoDiagramElementsCandidate.newSingleClickOnTwoDiagramElementsCandidate().sources(sources).targets(targets).build();
        edgeCandidates.add(edgeCandidate);
    }
    return SingleClickOnTwoDiagramElementsTool.newSingleClickOnTwoDiagramElementsTool(id).label(label).imageURL(imagePath).handler(this.createEdgeCreationHandler(interpreter, edgeCreationDescription)).candidates(edgeCandidates).build();
// @formatter:on
}
Also used : NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) IdentifiedElementQuery(org.eclipse.sirius.business.api.query.IdentifiedElementQuery) ArrayList(java.util.ArrayList) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) UUID(java.util.UUID) SingleClickOnTwoDiagramElementsCandidate(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsCandidate)

Example 2 with IdentifiedElementQuery

use of org.eclipse.sirius.business.api.query.IdentifiedElementQuery in project sirius-components by eclipse-sirius.

the class ToolProvider method convertToolDescription.

private SingleClickOnDiagramElementTool convertToolDescription(Map<UUID, NodeDescription> id2NodeDescriptions, AQLInterpreter interpreter, DiagramDescription siriusDiagramDescription, ToolDescription toolDescription) {
    String id = this.identifierProvider.getIdentifier(toolDescription);
    String label = new IdentifiedElementQuery(toolDescription).getLabel();
    String imagePath = this.toolImageProviderFactory.getToolImageProvider(toolDescription).get();
    List<DiagramElementMapping> mappings = this.getAllDiagramElementMappings(siriusDiagramDescription);
    // @formatter:off
    List<String> targetDescriptionIds = mappings.stream().map(this.identifierProvider::getIdentifier).collect(Collectors.toList());
    List<NodeDescription> targetDescriptions = targetDescriptionIds.stream().map(UUID::fromString).map(id2NodeDescriptions::get).collect(Collectors.toList());
    return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id).label(label).imageURL(imagePath).handler(this.createGenericToolHandler(interpreter, toolDescription)).targetDescriptions(targetDescriptions).appliesToDiagramRoot(true).build();
// @formatter:on
}
Also used : NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IdentifiedElementQuery(org.eclipse.sirius.business.api.query.IdentifiedElementQuery) DiagramElementMapping(org.eclipse.sirius.diagram.description.DiagramElementMapping) UUID(java.util.UUID)

Example 3 with IdentifiedElementQuery

use of org.eclipse.sirius.business.api.query.IdentifiedElementQuery in project sirius-components by eclipse-sirius.

the class ToolProvider method convertDeleteElementDescription.

private SingleClickOnDiagramElementTool convertDeleteElementDescription(Map<UUID, NodeDescription> id2NodeDescriptions, AQLInterpreter interpreter, DeleteElementDescription deleteElementDescription) {
    String id = this.identifierProvider.getIdentifier(deleteElementDescription);
    String label = new IdentifiedElementQuery(deleteElementDescription).getLabel();
    String imagePath = this.toolImageProviderFactory.getToolImageProvider(deleteElementDescription).get();
    List<DiagramElementMapping> mappings = deleteElementDescription.getMappings();
    // @formatter:off
    List<String> targetDescriptionIds = mappings.stream().map(this.identifierProvider::getIdentifier).collect(Collectors.toList());
    List<NodeDescription> targetDescriptions = targetDescriptionIds.stream().map(UUID::fromString).map(id2NodeDescriptions::get).filter(Objects::nonNull).collect(Collectors.toList());
    return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id).label(label).imageURL(imagePath).handler(this.createDeleteToolHandler(interpreter, deleteElementDescription)).appliesToDiagramRoot(false).targetDescriptions(targetDescriptions).build();
// @formatter:on
}
Also used : NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IdentifiedElementQuery(org.eclipse.sirius.business.api.query.IdentifiedElementQuery) DiagramElementMapping(org.eclipse.sirius.diagram.description.DiagramElementMapping)

Example 4 with IdentifiedElementQuery

use of org.eclipse.sirius.business.api.query.IdentifiedElementQuery in project sirius-components by eclipse-sirius.

the class ToolProvider method convertOperationAction.

private SingleClickOnDiagramElementTool convertOperationAction(Map<UUID, NodeDescription> id2NodeDescriptions, AQLInterpreter interpreter, DiagramDescription siriusDiagramDescription, OperationAction operationAction) {
    String id = this.identifierProvider.getIdentifier(operationAction);
    String label = new IdentifiedElementQuery(operationAction).getLabel();
    String imagePath = this.toolImageProviderFactory.getToolImageProvider(operationAction).get();
    List<DiagramElementMapping> mappings = this.getAllDiagramElementMappings(siriusDiagramDescription);
    // @formatter:off
    List<String> targetDescriptionIds = mappings.stream().map(this.identifierProvider::getIdentifier).collect(Collectors.toList());
    List<NodeDescription> targetDescriptions = targetDescriptionIds.stream().map(UUID::fromString).map(id2NodeDescriptions::get).collect(Collectors.toList());
    return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id).label(label).imageURL(imagePath).handler(this.createOperationActionHandler(interpreter, operationAction)).targetDescriptions(targetDescriptions).appliesToDiagramRoot(true).build();
// @formatter:on
}
Also used : NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IdentifiedElementQuery(org.eclipse.sirius.business.api.query.IdentifiedElementQuery) DiagramElementMapping(org.eclipse.sirius.diagram.description.DiagramElementMapping) UUID(java.util.UUID)

Example 5 with IdentifiedElementQuery

use of org.eclipse.sirius.business.api.query.IdentifiedElementQuery in project sirius-components by eclipse-sirius.

the class ToolProvider method convertContainerCreationDescription.

private SingleClickOnDiagramElementTool convertContainerCreationDescription(Map<UUID, NodeDescription> id2NodeDescriptions, AQLInterpreter interpreter, ContainerCreationDescription containerCreationDescription) {
    String id = this.identifierProvider.getIdentifier(containerCreationDescription);
    String label = new IdentifiedElementQuery(containerCreationDescription).getLabel();
    String imagePath = this.toolImageProviderFactory.getToolImageProvider(containerCreationDescription).get();
    List<NodeDescription> targetDescriptions = this.getParentNodeDescriptions(containerCreationDescription.getContainerMappings(), id2NodeDescriptions);
    var selectModelElementVariableOpt = new SelectModelElementVariableProvider().getSelectModelElementVariable(containerCreationDescription.getVariable());
    String selectionDescriptionId = null;
    if (selectModelElementVariableOpt.isPresent()) {
        selectionDescriptionId = this.identifierProvider.getIdentifier(selectModelElementVariableOpt.get());
    }
    // @formatter:off
    return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id).label(label).imageURL(imagePath).handler(this.createContainerCreationHandler(interpreter, containerCreationDescription)).targetDescriptions(targetDescriptions).appliesToDiagramRoot(this.atLeastOneRootMapping(containerCreationDescription.getContainerMappings())).selectionDescriptionId(selectionDescriptionId).build();
// @formatter:on
}
Also used : NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IdentifiedElementQuery(org.eclipse.sirius.business.api.query.IdentifiedElementQuery) SelectModelElementVariableProvider(org.eclipse.sirius.components.compatibility.services.SelectModelElementVariableProvider)

Aggregations

IdentifiedElementQuery (org.eclipse.sirius.business.api.query.IdentifiedElementQuery)6 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)6 UUID (java.util.UUID)3 DiagramElementMapping (org.eclipse.sirius.diagram.description.DiagramElementMapping)3 SelectModelElementVariableProvider (org.eclipse.sirius.components.compatibility.services.SelectModelElementVariableProvider)2 ArrayList (java.util.ArrayList)1 SingleClickOnTwoDiagramElementsCandidate (org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsCandidate)1 AbstractNodeMapping (org.eclipse.sirius.diagram.description.AbstractNodeMapping)1 EdgeMapping (org.eclipse.sirius.diagram.description.EdgeMapping)1