Search in sources :

Example 16 with IFolder

use of com.archimatetool.model.IFolder in project archi by archimatetool.

the class MyImporter method createAndAddArchimateComponent.

protected IArchimateConcept createAndAddArchimateComponent(IArchimateModel model, EClass type, String name, String id) {
    IArchimateConcept concept = (IArchimateConcept) IArchimateFactory.eINSTANCE.create(type);
    concept.setName(name);
    concept.setId(id);
    IFolder folder = model.getDefaultFolderForObject(concept);
    folder.getElements().add(concept);
    idLookup.put(concept.getId(), concept);
    return concept;
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IFolder(com.archimatetool.model.IFolder)

Example 17 with IFolder

use of com.archimatetool.model.IFolder in project archi by archimatetool.

the class TreeModelViewerDragDropHandler method isValidTreeSelection.

/**
 * Determine whether we have a valid selection of objects dragged from the Tree
 * Do it at the start of the drag operation for optimal speed.
 */
boolean isValidTreeSelection(IStructuredSelection selection) {
    if (selection == null || selection.isEmpty()) {
        return false;
    }
    IArchimateModel model = null;
    for (Object object : selection.toArray()) {
        // Can't drag Models
        if (object instanceof IArchimateModel) {
            return false;
        }
        // Can only drag user folders
        if (object instanceof IFolder && ((IFolder) object).getType() != FolderType.USER) {
            return false;
        }
        // Don't allow mixed parent models
        if (object instanceof IArchimateModelObject) {
            IArchimateModel m = ((IArchimateModelObject) object).getArchimateModel();
            if (model != null && m != model) {
                return false;
            }
            model = m;
        }
    }
    return true;
}
Also used : IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) EObject(org.eclipse.emf.ecore.EObject) IArchimateModel(com.archimatetool.model.IArchimateModel) IFolder(com.archimatetool.model.IFolder)

Example 18 with IFolder

use of com.archimatetool.model.IFolder in project archi by archimatetool.

the class TreeModelViewerDragDropHandler method isValidDropTarget.

/**
 * @return True if target is valid
 */
boolean isValidDropTarget(DropTargetEvent event) {
    // File from desktop onto blank area
    if (isFileDragOperation(event.currentDataType)) {
        return event.item == null;
    }
    // Local Tree Selection...
    // Dragging onto a Folder
    Object parent = getTargetParent(event);
    if (parent instanceof IFolder) {
        IFolder targetfolder = (IFolder) parent;
        IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
        for (Object object : selection.toList()) {
            // must have the same top folder type - a restriction which one day we should not enforce!
            if (!hasCommonAncestorFolder(targetfolder, (EObject) object)) {
                return false;
            }
            if (!canDropObject(object, (TreeItem) event.item)) {
                return false;
            }
        }
        return true;
    }
    return false;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) EObject(org.eclipse.emf.ecore.EObject) IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) EObject(org.eclipse.emf.ecore.EObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IFolder(com.archimatetool.model.IFolder)

Example 19 with IFolder

use of com.archimatetool.model.IFolder in project archi by archimatetool.

the class TreeModelViewerDragDropHandler method doDropOperation.

void doDropOperation(DropTargetEvent event) {
    // Local
    if (isLocalTreeDragOperation(event.currentDataType)) {
        Object parent = getTargetParent(event);
        if (parent instanceof IFolder) {
            IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
            moveTreeObjects((IFolder) parent, selection.toArray());
        }
    } else // File
    if (isFileDragOperation(event.currentDataType)) {
        addFileObjects((String[]) event.data);
    }
}
Also used : IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) EObject(org.eclipse.emf.ecore.EObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IFolder(com.archimatetool.model.IFolder)

Example 20 with IFolder

use of com.archimatetool.model.IFolder in project archi by archimatetool.

the class Archimate2To3Handler method convertConnectorsFolder.

private void convertConnectorsFolder(IArchimateModel model, IFolder connectorsFolder) {
    IFolder otherFolder = model.getFolder(FolderType.OTHER);
    if (otherFolder != null) {
        for (EObject eObject : new ArrayList<EObject>(connectorsFolder.eContents())) {
            otherFolder.getElements().add(eObject);
        }
    }
    model.getFolders().remove(connectorsFolder);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) IFolder(com.archimatetool.model.IFolder)

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