use of org.eclipse.sirius.components.view.EdgeTool in project sirius-components by eclipse-sirius.
the class EdgeDescriptionItemProvider method collectNewChildDescriptors.
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created
* under this object. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
EdgeTool newEdgeTool = ViewFactory.eINSTANCE.createEdgeTool();
// $NON-NLS-1$
newEdgeTool.setName("Create Edge");
ChangeContext initialOperation = ViewFactory.eINSTANCE.createChangeContext();
// $NON-NLS-1$
initialOperation.setExpression("aql:semanticEdgeSource");
newEdgeTool.getBody().add(initialOperation);
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.EDGE_DESCRIPTION__EDGE_TOOLS, newEdgeTool));
EdgeStyle newEdgeStyle = ViewFactory.eINSTANCE.createEdgeStyle();
// $NON-NLS-1$
newEdgeStyle.setColor("#002639");
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.EDGE_DESCRIPTION__STYLE, newEdgeStyle));
ConditionalEdgeStyle conditionalEdgeStyle = ViewFactory.eINSTANCE.createConditionalEdgeStyle();
// $NON-NLS-1$
conditionalEdgeStyle.setColor("#002639");
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.EDGE_DESCRIPTION__CONDITIONAL_STYLES, conditionalEdgeStyle));
}
use of org.eclipse.sirius.components.view.EdgeTool in project sirius-components by eclipse-sirius.
the class DiagramDescriptionConverter method createToolSections.
private List<ToolSection> createToolSections(AQLInterpreter interpreter) {
var capturedConvertedNodes = Map.copyOf(this.convertedNodes);
List<ITool> nodeCreationTools = new ArrayList<>();
for (var nodeDescription : this.convertedNodes.keySet()) {
// Add custom tools
int i = 0;
for (NodeTool nodeTool : nodeDescription.getNodeTools()) {
// @formatter:off
SingleClickOnDiagramElementTool customTool = // $NON-NLS-1$
SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(this.idProvider.apply(nodeDescription) + "_tool" + i++).label(nodeTool.getName()).imageURL(NODE_CREATION_TOOL_ICON).handler(variableManager -> new ToolInterpreter(interpreter, this.objectService, this.editService, this.getDiagramContext(variableManager), capturedConvertedNodes).executeTool(nodeTool, variableManager)).targetDescriptions(Optional.ofNullable(nodeDescription.eContainer()).map(this.convertedNodes::get).stream().collect(Collectors.toList())).appliesToDiagramRoot(nodeDescription.eContainer() instanceof org.eclipse.sirius.components.view.DiagramDescription).build();
// @formatter:on
nodeCreationTools.add(customTool);
}
// If there are no custom tools defined, add a canonical creation tool
if (i == 0) {
// @formatter:off
SingleClickOnDiagramElementTool tool = // $NON-NLS-1$
SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(this.idProvider.apply(nodeDescription) + "_creationTool").label(// $NON-NLS-1$
"New " + this.getSimpleTypeName(nodeDescription.getDomainType())).imageURL(NODE_CREATION_TOOL_ICON).handler(variableManager -> this.canonicalBehaviors.createNewNode(nodeDescription, variableManager)).targetDescriptions(Optional.ofNullable(nodeDescription.eContainer()).map(this.convertedNodes::get).stream().collect(Collectors.toList())).appliesToDiagramRoot(nodeDescription.eContainer() instanceof org.eclipse.sirius.components.view.DiagramDescription).build();
// @formatter:on
nodeCreationTools.add(tool);
}
}
List<ITool> edgeCreationTools = new ArrayList<>();
for (var edgeDescription : this.convertedEdges.keySet()) {
// Add custom tools
int i = 0;
for (EdgeTool edgeTool : edgeDescription.getEdgeTools()) {
// @formatter:off
SingleClickOnTwoDiagramElementsTool customTool = // $NON-NLS-1$
SingleClickOnTwoDiagramElementsTool.newSingleClickOnTwoDiagramElementsTool(this.idProvider.apply(edgeDescription) + "_tool" + i++).label(edgeTool.getName()).imageURL(EDGE_CREATION_TOOL_ICON).candidates(List.of(SingleClickOnTwoDiagramElementsCandidate.newSingleClickOnTwoDiagramElementsCandidate().sources(edgeDescription.getSourceNodeDescriptions().stream().map(this.convertedNodes::get).collect(Collectors.toList())).targets(edgeDescription.getTargetNodeDescriptions().stream().map(this.convertedNodes::get).collect(Collectors.toList())).build())).handler(variableManager -> new ToolInterpreter(interpreter, this.objectService, this.editService, this.getDiagramContext(variableManager), capturedConvertedNodes).executeTool(edgeTool, variableManager)).build();
// @formatter:on
edgeCreationTools.add(customTool);
}
// If there are no custom tools defined, add a canonical creation tool
if (i == 0) {
// @formatter:off
SingleClickOnTwoDiagramElementsTool tool = // $NON-NLS-1$
SingleClickOnTwoDiagramElementsTool.newSingleClickOnTwoDiagramElementsTool(this.idProvider.apply(edgeDescription) + "_creationTool").label(// $NON-NLS-1$
"New " + this.getSimpleTypeName(edgeDescription.getDomainType())).imageURL(EDGE_CREATION_TOOL_ICON).candidates(List.of(SingleClickOnTwoDiagramElementsCandidate.newSingleClickOnTwoDiagramElementsCandidate().sources(edgeDescription.getSourceNodeDescriptions().stream().map(this.convertedNodes::get).collect(Collectors.toList())).targets(edgeDescription.getTargetNodeDescriptions().stream().map(this.convertedNodes::get).collect(Collectors.toList())).build())).handler(variableManager -> this.canonicalBehaviors.createNewEdge(variableManager, edgeDescription)).build();
// @formatter:on
edgeCreationTools.add(tool);
}
}
// @formatter:off
return // $NON-NLS-1$
List.of(// $NON-NLS-1$
ToolSection.newToolSection(UUID.randomUUID().toString()).label(NODE_CREATION_TOOL_SECTION).tools(nodeCreationTools).imageURL("").build(), // $NON-NLS-1$
ToolSection.newToolSection(UUID.randomUUID().toString()).label(EDGE_CREATION_TOOL_SECTION).tools(edgeCreationTools).imageURL("").build());
// @formatter:on
}
Aggregations