use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method testIsValidDropTarget.
@Test
public void testIsValidDropTarget() {
IFolder folder = IArchimateFactory.eINSTANCE.createFolder();
IArchimateElement childElement = IArchimateFactory.eINSTANCE.createBusinessActor();
folder.getElements().add(childElement);
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(new Object[] { childElement }));
// Can only drop onto a folder
DropTargetEvent event = createMockDropTargetEvent(folder);
assertTrue(dragHandler.isValidDropTarget(event));
// And not something else
event = createMockDropTargetEvent(childElement);
assertFalse(dragHandler.isValidDropTarget(event));
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method testDoDropOperation.
@Test
public void testDoDropOperation() {
// Source
IFolder sourceParentFolder = model.getFolder(FolderType.BUSINESS);
IArchimateElement childElement = IArchimateFactory.eINSTANCE.createBusinessActor();
sourceParentFolder.getElements().add(childElement);
assertTrue(sourceParentFolder.getElements().contains(childElement));
// Target
IFolder targetParentFolder = model.getFolder(FolderType.APPLICATION);
assertTrue(targetParentFolder.getElements().isEmpty());
assertTrue(targetParentFolder.getFolders().isEmpty());
// Set up a mock DropTargetEvent for the DropOperation
DropTargetEvent event = createMockDropTargetEvent(targetParentFolder);
// Set the selection of elements we want to DnD
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(new Object[] { childElement }));
// And call the drop method
dragHandler.doDropOperation(event);
assertTrue(sourceParentFolder.getElements().isEmpty());
assertTrue(targetParentFolder.getElements().contains(childElement));
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method moveTreeObjects_DropChildElementsOntoSameParentIsSame.
/**
* Drag and dropping child elements onto same parent
*/
@Test
public void moveTreeObjects_DropChildElementsOntoSameParentIsSame() {
// Add child elements to a folder
IFolder parentFolder = model.getFolder(FolderType.BUSINESS);
IArchimateElement childElement1 = IArchimateFactory.eINSTANCE.createBusinessActor();
parentFolder.getElements().add(childElement1);
IArchimateElement childElement2 = IArchimateFactory.eINSTANCE.createBusinessActor();
parentFolder.getElements().add(childElement2);
// Check all is well
assertTrue(parentFolder.getFolders().isEmpty());
assertEquals(2, parentFolder.getElements().size());
assertEquals(childElement1, parentFolder.getElements().get(0));
assertEquals(childElement2, parentFolder.getElements().get(1));
// Move child elements to the same parent folder
dragHandler.moveTreeObjects(parentFolder, new Object[] { childElement1, childElement2 });
// Shouldn't affect folders
assertTrue(parentFolder.getFolders().isEmpty());
// Should be the same
assertEquals(2, parentFolder.getElements().size());
assertEquals(childElement1, parentFolder.getElements().get(0));
assertEquals(childElement2, parentFolder.getElements().get(1));
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method testHasCommonAncestorFolder.
@Test
public void testHasCommonAncestorFolder() {
// Test with folders and elements that have a root model
IFolder businessFolder = model.getFolder(FolderType.BUSINESS);
IFolder appFolder = model.getFolder(FolderType.APPLICATION);
__doTestHasCommonAncestorFolderWithTheseFolders(businessFolder, appFolder);
// Test with folders and elements that have no root model
IFolder parent1 = IArchimateFactory.eINSTANCE.createFolder();
IFolder parent2 = IArchimateFactory.eINSTANCE.createFolder();
__doTestHasCommonAncestorFolderWithTheseFolders(parent1, parent2);
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method moveTreeObjects_DropChildFolderOntoSameParentIsSame.
/**
* The famous DnD bug of drag and dropping a child folder onto its parent (fixed in Archi 2.4.1)
*/
@Test
public void moveTreeObjects_DropChildFolderOntoSameParentIsSame() {
// Add a child folder to a parent folder
IFolder parentFolder = model.getFolder(FolderType.BUSINESS);
IFolder childFolder = IArchimateFactory.eINSTANCE.createFolder();
parentFolder.getFolders().add(childFolder);
// Check all is well
assertEquals(1, parentFolder.getFolders().size());
assertTrue(parentFolder.getFolders().contains(childFolder));
assertTrue(parentFolder.getElements().isEmpty());
// Move child folder to the same target parent folder
dragHandler.moveTreeObjects(parentFolder, new Object[] { childFolder });
// Should be the same
assertEquals(1, parentFolder.getFolders().size());
assertTrue(parentFolder.getFolders().contains(childFolder));
// Elements should not be affected
assertTrue(parentFolder.getElements().isEmpty());
}
Aggregations