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
}
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
}
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
}
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
}
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
}
Aggregations