use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class SortFolderAction method run.
@Override
public void run() {
Object selected = getSelection().getFirstElement();
if (selected instanceof IFolder) {
IFolder folder = (IFolder) selected;
Command cmd = new SortFolderCommand(folder);
CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
commandStack.execute(cmd);
}
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewActionFactory method getNewObjectActions.
/**
* @param selected
* @return A List (perhaps empty) of Actions for a given selected object
*/
public List<IAction> getNewObjectActions(Object selected) {
List<IAction> list = new ArrayList<IAction>();
// If we have selected a leaf object, go up to parent
if (selected instanceof IArchimateElement || selected instanceof IDiagramModel) {
selected = ((EObject) selected).eContainer();
}
// We want a folder
if (!(selected instanceof IFolder)) {
return list;
}
IFolder folder = (IFolder) selected;
// Find topmost folder type
IFolder f = folder;
while (f.eContainer() instanceof IFolder) {
f = (IFolder) f.eContainer();
}
switch(f.getType()) {
case STRATEGY:
for (EClass eClass : ArchimateModelUtils.getStrategyClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case BUSINESS:
for (EClass eClass : ArchimateModelUtils.getBusinessClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case APPLICATION:
for (EClass eClass : ArchimateModelUtils.getApplicationClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case MOTIVATION:
for (EClass eClass : ArchimateModelUtils.getMotivationClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case IMPLEMENTATION_MIGRATION:
for (EClass eClass : ArchimateModelUtils.getImplementationMigrationClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case TECHNOLOGY:
// Technology
for (EClass eClass : ArchimateModelUtils.getTechnologyClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
list.add(null);
// Physical
for (EClass eClass : ArchimateModelUtils.getPhysicalClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case OTHER:
// Grouping and Location
for (EClass eClass : ArchimateModelUtils.getOtherClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
list.add(null);
// Connectors
for (EClass eClass : ArchimateModelUtils.getConnectorClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case DIAGRAMS:
list.add(createNewArchimateDiagramAction(folder));
list.add(createNewSketchAction(folder));
break;
default:
break;
}
return list;
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class ArchimateModelTests method testGetDefaultFolderForObject.
@Test
public void testGetDefaultFolderForObject() {
EObject element = IArchimateFactory.eINSTANCE.createResource();
IFolder folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.STRATEGY, folder.getType());
element = IArchimateFactory.eINSTANCE.createBusinessEvent();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.BUSINESS, folder.getType());
element = IArchimateFactory.eINSTANCE.createApplicationComponent();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.APPLICATION, folder.getType());
element = IArchimateFactory.eINSTANCE.createNode();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.TECHNOLOGY, folder.getType());
element = IArchimateFactory.eINSTANCE.createEquipment();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.TECHNOLOGY, folder.getType());
element = IArchimateFactory.eINSTANCE.createJunction();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.OTHER, folder.getType());
element = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.RELATIONS, folder.getType());
element = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.DIAGRAMS, folder.getType());
element = IArchimateFactory.eINSTANCE.createSketchModel();
folder = model.getDefaultFolderForObject(element);
assertNotNull(folder);
assertEquals(FolderType.DIAGRAMS, folder.getType());
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class DiagramModelArchimateConnectionTests method testAddArchimateRelationshipToModel_AlreadyHasParent.
@Test(expected = IllegalArgumentException.class)
public void testAddArchimateRelationshipToModel_AlreadyHasParent() {
IFolder parent = IArchimateFactory.eINSTANCE.createFolder();
parent.getElements().add(connection.getArchimateRelationship());
connection.addArchimateConceptToModel(null);
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class DiagramModelArchimateObjectTests method testAddArchimateElementToModel_AlreadyHasParent.
@Test(expected = IllegalArgumentException.class)
public void testAddArchimateElementToModel_AlreadyHasParent() {
IFolder parent = IArchimateFactory.eINSTANCE.createFolder();
parent.getElements().add(object.getArchimateElement());
object.addArchimateConceptToModel(null);
}
Aggregations