use of org.eclipse.sirius.viewpoint.description.tool.ToolDescription in project sirius-components by eclipse-sirius.
the class ToolImageProviderTests method testIconPathNormalization.
@Test
public void testIconPathNormalization() {
ToolDescription toolDescription = ToolFactory.eINSTANCE.createToolDescription();
toolDescription.setIconPath(ICON_PATH);
IObjectService objectService = new IObjectService.NoOp();
EPackage.Registry ePackageRegistry = EPackage.Registry.INSTANCE;
ToolImageProvider toolImageProvider = new ToolImageProvider(objectService, ePackageRegistry, toolDescription);
String convertedIconPath = toolImageProvider.get();
assertThat(convertedIconPath.equals(ICON_PATH.substring(ICON_PATH.indexOf('/', 1)))).isTrue();
}
use of org.eclipse.sirius.viewpoint.description.tool.ToolDescription in project sirius-components by eclipse-sirius.
the class ToolProvider method convertTool.
private Optional<ITool> convertTool(Map<UUID, NodeDescription> id2NodeDescriptions, org.eclipse.sirius.diagram.description.DiagramDescription siriusDiagramDescription, AbstractToolDescription siriusTool, AQLInterpreter interpreter) {
Optional<ITool> result = Optional.empty();
if (siriusTool instanceof NodeCreationDescription) {
NodeCreationDescription nodeCreationTool = (NodeCreationDescription) siriusTool;
result = Optional.of(this.convertNodeCreationDescription(id2NodeDescriptions, interpreter, nodeCreationTool));
} else if (siriusTool instanceof ContainerCreationDescription) {
ContainerCreationDescription containerCreationDescription = (ContainerCreationDescription) siriusTool;
result = Optional.of(this.convertContainerCreationDescription(id2NodeDescriptions, interpreter, containerCreationDescription));
} else if (siriusTool instanceof org.eclipse.sirius.viewpoint.description.tool.ToolDescription) {
org.eclipse.sirius.viewpoint.description.tool.ToolDescription toolDescription = (org.eclipse.sirius.viewpoint.description.tool.ToolDescription) siriusTool;
result = Optional.of(this.convertToolDescription(id2NodeDescriptions, interpreter, siriusDiagramDescription, toolDescription));
} else if (siriusTool instanceof EdgeCreationDescription) {
EdgeCreationDescription edgeCreationDescription = (EdgeCreationDescription) siriusTool;
result = Optional.of(this.convertEdgeCreationDescription(id2NodeDescriptions, interpreter, edgeCreationDescription));
} else if (siriusTool instanceof DeleteElementDescription) {
DeleteElementDescription deleteElementDescription = (DeleteElementDescription) siriusTool;
result = Optional.of(this.convertDeleteElementDescription(id2NodeDescriptions, interpreter, deleteElementDescription));
} else if (siriusTool instanceof OperationAction) {
OperationAction operationAction = (OperationAction) siriusTool;
result = Optional.of(this.convertOperationAction(id2NodeDescriptions, interpreter, siriusDiagramDescription, operationAction));
}
return result;
}
use of org.eclipse.sirius.viewpoint.description.tool.ToolDescription in project sirius-components by eclipse-sirius.
the class ToolProvider method getToolSections.
@Override
public List<ToolSection> getToolSections(Map<UUID, NodeDescription> id2NodeDescriptions, List<EdgeDescription> edgeDescriptions, DiagramDescription siriusDiagramDescription, List<Layer> layers) {
List<ToolSection> result = new ArrayList<>();
// @formatter:off
var siriusToolSections = layers.stream().flatMap(layer -> layer.getToolSections().stream()).filter(org.eclipse.sirius.diagram.description.tool.ToolSection.class::isInstance).map(org.eclipse.sirius.diagram.description.tool.ToolSection.class::cast).collect(Collectors.toList());
// @formatter:on
AQLInterpreter interpreter = this.interpreterFactory.create(siriusDiagramDescription);
for (var siriusToolSection : siriusToolSections) {
// @formatter:off
List<ITool> tools = this.getToolDescriptions(siriusToolSection).stream().filter(this::isSupported).map(toolDescription -> this.convertTool(id2NodeDescriptions, siriusDiagramDescription, toolDescription, interpreter)).flatMap(Optional::stream).collect(Collectors.toList());
// @formatter:on
if (!tools.isEmpty()) {
ToolSection toolSection = this.convertToolSection(siriusToolSection, tools);
result.add(toolSection);
}
}
return result;
}
Aggregations