Search in sources :

Example 1 with ToolDescription

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();
}
Also used : IObjectService(org.eclipse.sirius.components.core.api.IObjectService) ToolDescription(org.eclipse.sirius.viewpoint.description.tool.ToolDescription) EPackage(org.eclipse.emf.ecore.EPackage) Test(org.junit.jupiter.api.Test)

Example 2 with ToolDescription

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;
}
Also used : DeleteElementDescription(org.eclipse.sirius.diagram.description.tool.DeleteElementDescription) NodeCreationDescription(org.eclipse.sirius.diagram.description.tool.NodeCreationDescription) ToolDescription(org.eclipse.sirius.viewpoint.description.tool.ToolDescription) ITool(org.eclipse.sirius.components.diagrams.tools.ITool) OperationAction(org.eclipse.sirius.viewpoint.description.tool.OperationAction) ToolDescription(org.eclipse.sirius.viewpoint.description.tool.ToolDescription) AbstractToolDescription(org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription) ContainerCreationDescription(org.eclipse.sirius.diagram.description.tool.ContainerCreationDescription) EdgeCreationDescription(org.eclipse.sirius.diagram.description.tool.EdgeCreationDescription)

Example 3 with ToolDescription

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;
}
Also used : InitialOperation(org.eclipse.sirius.viewpoint.description.tool.InitialOperation) LayerSpec(org.eclipse.sirius.diagram.business.internal.metamodel.description.spec.LayerSpec) ToolDescription(org.eclipse.sirius.viewpoint.description.tool.ToolDescription) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) Layer(org.eclipse.sirius.diagram.description.Layer) OperationAction(org.eclipse.sirius.viewpoint.description.tool.OperationAction) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) InitialNodeCreationOperation(org.eclipse.sirius.viewpoint.description.tool.InitialNodeCreationOperation) IToolImageProviderFactory(org.eclipse.sirius.components.compatibility.api.IToolImageProviderFactory) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IStatus(org.eclipse.sirius.components.representations.IStatus) ITool(org.eclipse.sirius.components.diagrams.tools.ITool) Map(java.util.Map) AbstractToolDescription(org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) AdditionalLayer(org.eclipse.sirius.diagram.description.AdditionalLayer) DiagramDescription(org.eclipse.sirius.diagram.description.DiagramDescription) NodeCreationDescription(org.eclipse.sirius.diagram.description.tool.NodeCreationDescription) ToolGroup(org.eclipse.sirius.diagram.description.tool.ToolGroup) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) Collection(java.util.Collection) UUID(java.util.UUID) SelectModelElementVariableProvider(org.eclipse.sirius.components.compatibility.services.SelectModelElementVariableProvider) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) IdentifiedElementQuery(org.eclipse.sirius.business.api.query.IdentifiedElementQuery) Objects(java.util.Objects) DeleteElementDescription(org.eclipse.sirius.diagram.description.tool.DeleteElementDescription) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) SingleClickOnTwoDiagramElementsCandidate(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsCandidate) Stream(java.util.stream.Stream) Optional(java.util.Optional) ContainerCreationDescription(org.eclipse.sirius.diagram.description.tool.ContainerCreationDescription) Node(org.eclipse.sirius.components.diagrams.Node) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) Function(java.util.function.Function) InitEdgeCreationOperation(org.eclipse.sirius.viewpoint.description.tool.InitEdgeCreationOperation) ArrayList(java.util.ArrayList) SingleClickOnDiagramElementTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool) Service(org.springframework.stereotype.Service) SingleClickOnTwoDiagramElementsTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool) EdgeCreationDescription(org.eclipse.sirius.diagram.description.tool.EdgeCreationDescription) IAQLInterpreterFactory(org.eclipse.sirius.components.compatibility.api.IAQLInterpreterFactory) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Failure(org.eclipse.sirius.components.representations.Failure) Success(org.eclipse.sirius.components.representations.Success) DiagramElementMapping(org.eclipse.sirius.diagram.description.DiagramElementMapping) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) ArrayList(java.util.ArrayList) ITool(org.eclipse.sirius.components.diagrams.tools.ITool) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection)

Aggregations

ToolDescription (org.eclipse.sirius.viewpoint.description.tool.ToolDescription)3 ITool (org.eclipse.sirius.components.diagrams.tools.ITool)2 ContainerCreationDescription (org.eclipse.sirius.diagram.description.tool.ContainerCreationDescription)2 DeleteElementDescription (org.eclipse.sirius.diagram.description.tool.DeleteElementDescription)2 EdgeCreationDescription (org.eclipse.sirius.diagram.description.tool.EdgeCreationDescription)2 NodeCreationDescription (org.eclipse.sirius.diagram.description.tool.NodeCreationDescription)2 AbstractToolDescription (org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription)2 OperationAction (org.eclipse.sirius.viewpoint.description.tool.OperationAction)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 EPackage (org.eclipse.emf.ecore.EPackage)1 IdentifiedElementQuery (org.eclipse.sirius.business.api.query.IdentifiedElementQuery)1