Search in sources :

Example 1 with DuplicateCommandHandler

use of com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler in project archi by archimatetool.

the class DiagramModelUtilsTests method testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram.

// =================================================================================================
@Test
public void testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram() {
    ArchimateTestModel tm = new ArchimateTestModel();
    IArchimateModel model = tm.createNewModel();
    IDiagramModel dm = model.getDefaultDiagramModel();
    IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
    dm.getChildren().add(dmo1);
    IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
    IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
    dm.getChildren().add(dmo2);
    IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relation.setSource(actor);
    relation.setTarget(role);
    IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
    dmc1.connect(dmo1, dmo2);
    List<?> list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
    assertEquals(1, list.size());
    list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
    assertEquals(1, list.size());
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
    assertEquals(1, list.size());
    // Duplicate
    DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
    handler.duplicate();
    list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
    assertEquals(2, list.size());
    list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
    assertEquals(2, list.size());
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
    assertEquals(2, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) DuplicateCommandHandler(com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler) Test(org.junit.Test)

Example 2 with DuplicateCommandHandler

use of com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler in project archi by archimatetool.

the class DuplicateAction method run.

@Override
public void run() {
    IStructuredSelection selection = getSelection();
    if (selection == null || selection.isEmpty()) {
        return;
    }
    DuplicateCommandHandler cmdHandler = new DuplicateCommandHandler(selection.toArray());
    cmdHandler.duplicate();
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DuplicateCommandHandler(com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler)

Aggregations

DuplicateCommandHandler (com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler)2 IArchimateElement (com.archimatetool.model.IArchimateElement)1 IArchimateModel (com.archimatetool.model.IArchimateModel)1 IAssignmentRelationship (com.archimatetool.model.IAssignmentRelationship)1 IDiagramModel (com.archimatetool.model.IDiagramModel)1 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)1 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)1 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Test (org.junit.Test)1