Search in sources :

Example 1 with IFolder

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);
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) SortFolderCommand(com.archimatetool.editor.views.tree.commands.SortFolderCommand) Command(org.eclipse.gef.commands.Command) SortFolderCommand(com.archimatetool.editor.views.tree.commands.SortFolderCommand) IFolder(com.archimatetool.model.IFolder)

Example 2 with IFolder

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;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IAction(org.eclipse.jface.action.IAction) IDiagramModel(com.archimatetool.model.IDiagramModel) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IFolder(com.archimatetool.model.IFolder)

Example 3 with IFolder

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());
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IFolder(com.archimatetool.model.IFolder) Test(org.junit.Test)

Example 4 with IFolder

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);
}
Also used : IFolder(com.archimatetool.model.IFolder) Test(org.junit.Test)

Example 5 with IFolder

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);
}
Also used : IFolder(com.archimatetool.model.IFolder) Test(org.junit.Test)

Aggregations

IFolder (com.archimatetool.model.IFolder)41 Test (org.junit.Test)19 EObject (org.eclipse.emf.ecore.EObject)13 IArchimateElement (com.archimatetool.model.IArchimateElement)11 IArchimateModel (com.archimatetool.model.IArchimateModel)11 ArrayList (java.util.ArrayList)6 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)5 IDiagramModel (com.archimatetool.model.IDiagramModel)5 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)4 Command (org.eclipse.gef.commands.Command)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 File (java.io.File)3 ICanvasModel (com.archimatetool.canvas.model.ICanvasModel)2 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)2 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)2 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)2