Search in sources :

Example 1 with CreateViewOperationHandler

use of org.eclipse.sirius.components.emf.compatibility.modeloperations.CreateViewOperationHandler in project sirius-components by eclipse-sirius.

the class CreateViewOperationHandlerTests method initialize.

@BeforeEach
public void initialize() {
    this.operationTestContext = new OperationTestContext();
    // @formatter:off
    DiagramDescription diagramDescription = DiagramDescription.newDiagramDescription(UUID.randomUUID()).label(// $NON-NLS-1$
    "DiagramDescriptionTest").targetObjectIdProvider(// $NON-NLS-1$
    variableManager -> "diagramTargetObjectId").canCreatePredicate(variableManager -> true).labelProvider(// $NON-NLS-1$
    variableManager -> "Diagram").toolSections(List.of()).nodeDescriptions(List.of(this.getNodeDescription(UUID.randomUUID()))).edgeDescriptions(List.of()).dropHandler(// $NON-NLS-1$
    variableManager -> new Failure("")).build();
    Diagram diagram = Diagram.newDiagram(UUID.randomUUID().toString()).descriptionId(diagramDescription.getId()).targetObjectId(UUID.randomUUID().toString()).label(// $NON-NLS-1$
    "DiagramTest").position(Position.at(0, 0)).size(Size.of(100, 100)).nodes(new ArrayList<>()).edges(List.of()).build();
    IDiagramContext diagramContext = new IDiagramContext.NoOp() {

        @Override
        public List<ViewCreationRequest> getViewCreationRequests() {
            return new ArrayList<>();
        }
    };
    this.operationTestContext.getVariables().put(IDiagramContext.DIAGRAM_CONTEXT, diagramContext);
    // @formatter:on
    AdapterFactoryEditingDomain editingDomain = new EditingDomainFactory().create();
    EditingContext editingContext = new EditingContext(UUID.randomUUID().toString(), editingDomain);
    this.operationTestContext.getVariables().put(IEditingContext.EDITING_CONTEXT, editingContext);
    this.operationTestContext.getVariables().put(CONTAINER_VIEW, diagram);
    this.createViewOperation = org.eclipse.sirius.diagram.description.tool.ToolFactory.eINSTANCE.createCreateView();
    this.createViewOperationHandler = new CreateViewOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.createViewOperation);
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) BeforeEach(org.junit.jupiter.api.BeforeEach) Size(org.eclipse.sirius.components.diagrams.Size) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ToolFactory(org.eclipse.sirius.viewpoint.description.tool.ToolFactory) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Position(org.eclipse.sirius.components.diagrams.Position) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) CreateViewOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.CreateViewOperationHandler) RectangularNodeStyle(org.eclipse.sirius.components.diagrams.RectangularNodeStyle) EditingDomainFactory(org.eclipse.sirius.components.emf.services.EditingDomainFactory) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) Diagram(org.eclipse.sirius.components.diagrams.Diagram) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) IStatus(org.eclipse.sirius.components.representations.IStatus) LineStyle(org.eclipse.sirius.components.diagrams.LineStyle) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Failure(org.eclipse.sirius.components.representations.Failure) Success(org.eclipse.sirius.components.representations.Success) ENamedElement(org.eclipse.emf.ecore.ENamedElement) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CreateView(org.eclipse.sirius.diagram.description.tool.CreateView) VariableManager(org.eclipse.sirius.components.representations.VariableManager) ViewCreationRequest(org.eclipse.sirius.components.diagrams.ViewCreationRequest) ChangeContext(org.eclipse.sirius.viewpoint.description.tool.ChangeContext) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) ViewCreationRequest(org.eclipse.sirius.components.diagrams.ViewCreationRequest) ArrayList(java.util.ArrayList) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) CreateViewOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.CreateViewOperationHandler) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) EditingDomainFactory(org.eclipse.sirius.components.emf.services.EditingDomainFactory) Failure(org.eclipse.sirius.components.representations.Failure) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 ENamedElement (org.eclipse.emf.ecore.ENamedElement)1 AdapterFactoryEditingDomain (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain)1 IDiagramContext (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext)1 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)1 Diagram (org.eclipse.sirius.components.diagrams.Diagram)1 INodeStyle (org.eclipse.sirius.components.diagrams.INodeStyle)1 LineStyle (org.eclipse.sirius.components.diagrams.LineStyle)1 Position (org.eclipse.sirius.components.diagrams.Position)1 RectangularNodeStyle (org.eclipse.sirius.components.diagrams.RectangularNodeStyle)1 Size (org.eclipse.sirius.components.diagrams.Size)1 ViewCreationRequest (org.eclipse.sirius.components.diagrams.ViewCreationRequest)1 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)1 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)1 LabelStyleDescription (org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)1 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)1