use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class MyImporter method createAndAddView.
protected IDiagramModel createAndAddView(IArchimateModel model, String name, String id) {
IDiagramModel diagramModel = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
diagramModel.setName(name);
diagramModel.setId(id);
IFolder folder = model.getDefaultFolderForObject(diagramModel);
folder.getElements().add(diagramModel);
idLookup.put(diagramModel.getId(), diagramModel);
return diagramModel;
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class ArchimateModel method getDiagramModels.
/**
* <!-- begin-user-doc -->
* Return the Diagram Models - could be empty list
* <!-- end-user-doc -->
* @generated NOT
*/
public EList<IDiagramModel> getDiagramModels() {
EList<IDiagramModel> list = new BasicEList<IDiagramModel>();
IFolder folder = getFolder(FolderType.DIAGRAMS);
if (folder != null) {
for (Iterator<EObject> iter = folder.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModel) {
list.add((IDiagramModel) eObject);
}
}
}
return list;
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method moveTreeObjects_DropChildFolderOntoDifferentParent.
/**
* Drag and dropping a folder onto a different parent
*/
@Test
public void moveTreeObjects_DropChildFolderOntoDifferentParent() {
// Add a child folder to a parent folder
IFolder sourceParentFolder = model.getFolder(FolderType.BUSINESS);
IFolder childFolder = IArchimateFactory.eINSTANCE.createFolder();
sourceParentFolder.getFolders().add(childFolder);
// Check all is well
assertEquals(1, sourceParentFolder.getFolders().size());
assertTrue(sourceParentFolder.getFolders().contains(childFolder));
// New target parent folder
IFolder targetParentFolder = model.getFolder(FolderType.APPLICATION);
assertTrue(targetParentFolder.getFolders().isEmpty());
assertTrue(targetParentFolder.getElements().isEmpty());
// Move child folder to the different target parent folder
dragHandler.moveTreeObjects(targetParentFolder, new Object[] { childFolder });
// Source should be empty
assertTrue(sourceParentFolder.getFolders().isEmpty());
// Target should be populated
assertEquals(1, targetParentFolder.getFolders().size());
assertEquals(childFolder, targetParentFolder.getFolders().get(0));
// Elements should not be affected
assertTrue(targetParentFolder.getElements().isEmpty());
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method __doTestHasCommonAncestorFolderWithTheseFolders.
private void __doTestHasCommonAncestorFolderWithTheseFolders(IFolder parentFolder1, IFolder parentFolder2) {
/*
businessFolder
|-- f2
|-- e1
|-- f3
|-- e2
appFolder
|-- f4
|-- e3
|-- f5
|-- e4
*/
IFolder f2 = IArchimateFactory.eINSTANCE.createFolder();
IFolder f3 = IArchimateFactory.eINSTANCE.createFolder();
parentFolder1.getFolders().add(f2);
parentFolder1.getFolders().add(f3);
IArchimateElement e1 = IArchimateFactory.eINSTANCE.createBusinessActor();
f2.getElements().add(e1);
IArchimateElement e2 = IArchimateFactory.eINSTANCE.createBusinessActor();
f3.getElements().add(e2);
IFolder f4 = IArchimateFactory.eINSTANCE.createFolder();
IFolder f5 = IArchimateFactory.eINSTANCE.createFolder();
parentFolder2.getFolders().add(f4);
parentFolder2.getFolders().add(f5);
IArchimateElement e3 = IArchimateFactory.eINSTANCE.createApplicationComponent();
f4.getElements().add(e3);
IArchimateElement e4 = IArchimateFactory.eINSTANCE.createApplicationComponent();
f5.getElements().add(e4);
// Same common ancestor
assertTrue(dragHandler.hasCommonAncestorFolder(f2, f3));
assertTrue(dragHandler.hasCommonAncestorFolder(f2, e1));
assertTrue(dragHandler.hasCommonAncestorFolder(f3, e1));
assertTrue(dragHandler.hasCommonAncestorFolder(e1, e2));
// Different common ancestors
assertFalse(dragHandler.hasCommonAncestorFolder(f2, f4));
assertFalse(dragHandler.hasCommonAncestorFolder(f3, f5));
assertFalse(dragHandler.hasCommonAncestorFolder(f3, e3));
assertFalse(dragHandler.hasCommonAncestorFolder(e1, e4));
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method testIsValidTreeSelection.
@Test
public void testIsValidTreeSelection() {
// Null selection is not valid
StructuredSelection selection = null;
assertFalse(dragHandler.isValidTreeSelection(selection));
// Set up some data
IFolder userFolder = IArchimateFactory.eINSTANCE.createFolder();
model.getFolder(FolderType.DIAGRAMS).getFolders().add(userFolder);
IFolder businessFolder = model.getFolder(FolderType.BUSINESS);
IArchimateElement e1 = IArchimateFactory.eINSTANCE.createBusinessActor();
businessFolder.getElements().add(e1);
IArchimateElement e2 = IArchimateFactory.eINSTANCE.createBusinessActor();
businessFolder.getElements().add(e2);
// Elements from the same root parent are OK
selection = new StructuredSelection(new Object[] { e1, e2 });
assertTrue(dragHandler.isValidTreeSelection(selection));
// Can't DnD a model
selection = new StructuredSelection(new Object[] { model });
assertFalse(dragHandler.isValidTreeSelection(selection));
// Can DnD a user folder
selection = new StructuredSelection(new Object[] { userFolder });
assertTrue(dragHandler.isValidTreeSelection(selection));
// Can't DnD a system folder
selection = new StructuredSelection(new Object[] { businessFolder });
assertFalse(dragHandler.isValidTreeSelection(selection));
// Can't DnD Mixed parent models
IArchimateModel model2 = IArchimateFactory.eINSTANCE.createArchimateModel();
model2.setDefaults();
IArchimateElement e3 = IArchimateFactory.eINSTANCE.createBusinessActor();
model2.getFolder(FolderType.BUSINESS).getElements().add(e3);
selection = new StructuredSelection(new Object[] { e1, e3 });
assertFalse(dragHandler.isValidTreeSelection(selection));
}
Aggregations