Search in sources :

Example 1 with IDiagramModel

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

the class DiagramModelReferenceEditPart method removeECoreAdapter.

@Override
protected void removeECoreAdapter() {
    super.removeECoreAdapter();
    // Unlisten to referenced model
    IDiagramModel ref = ((IDiagramModelReference) getModel()).getReferencedModel();
    if (ref != null) {
        ref.eAdapters().remove(getECoreAdapter());
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference)

Example 2 with IDiagramModel

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

the class DiagramModelReferenceFigure method drawIcon.

/**
 * Draw the icon
 */
protected void drawIcon(Graphics graphics) {
    // Draw the icon depending on the diagramModelObject
    IDiagramModel dm = ((IDiagramModelReference) getDiagramModelObject()).getReferencedModel();
    IGraphicsIcon graphicsIcon = ArchiLabelProvider.INSTANCE.getGraphicsIconForDiagramModel(dm);
    if (graphicsIcon != null) {
        graphicsIcon.drawIcon(graphics, getIconOrigin());
    }
}
Also used : IGraphicsIcon(com.archimatetool.editor.ui.IGraphicsIcon) IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference)

Example 3 with IDiagramModel

use of com.archimatetool.model.IDiagramModel 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 4 with IDiagramModel

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

the class DeleteCommandHandler method getElementsToDelete.

/**
 * Create the list of objects to delete and check
 * @return
 */
private void getElementsToDelete() {
    // Actual elements to delete
    fElementsToDelete = new ArrayList<Object>();
    // First, gather up the list of Archimate objects to be deleted...
    for (Object object : fSelectedObjects) {
        if (canDelete(object)) {
            addToList(object, fElementsToDelete);
            addFolderChildElements(object);
            addElementRelationships(object);
        }
    }
    // Gather referenced diagram objects to be deleted checking that the parent diagram model is not also selected to be deleted
    for (Object object : new ArrayList<>(fElementsToDelete)) {
        // Archimate Components
        if (object instanceof IArchimateConcept) {
            IArchimateConcept archimateConcept = (IArchimateConcept) object;
            for (IDiagramModel diagramModel : archimateConcept.getArchimateModel().getDiagramModels()) {
                // Check diagram model is not selected to be deleted - no point in deleting any of its children
                if (!fElementsToDelete.contains(diagramModel)) {
                    for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, archimateConcept)) {
                        addToList(dc, fElementsToDelete);
                    }
                }
            }
        }
        // Diagram Models and their references
        if (object instanceof IDiagramModel) {
            IDiagramModel diagramModelDeleted = (IDiagramModel) object;
            for (IDiagramModel diagramModel : diagramModelDeleted.getArchimateModel().getDiagramModels()) {
                // is there one?
                List<IDiagramModelReference> list = DiagramModelUtils.findDiagramModelReferences(diagramModel, diagramModelDeleted);
                fElementsToDelete.addAll(list);
            }
        }
    }
}
Also used : IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) ArrayList(java.util.ArrayList) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) EObject(org.eclipse.emf.ecore.EObject)

Example 5 with IDiagramModel

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

the class DuplicateCommandHandler method createCommands.

private void createCommands() {
    for (Object object : fElementsToDuplicate) {
        CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
        if (compoundCommand == null) {
            // sanity check
            // $NON-NLS-1$
            System.err.println("Could not get CompoundCommand in " + getClass());
            continue;
        }
        if (object instanceof IDiagramModel) {
            Command cmd = new DuplicateDiagramModelCommand((IDiagramModel) object);
            compoundCommand.add(cmd);
        } else if (object instanceof IArchimateElement) {
            Command cmd = new DuplicateElementCommand((IArchimateElement) object);
            compoundCommand.add(cmd);
        }
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) Command(org.eclipse.gef.commands.Command) IArchimateElement(com.archimatetool.model.IArchimateElement) EObject(org.eclipse.emf.ecore.EObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)

Aggregations

IDiagramModel (com.archimatetool.model.IDiagramModel)68 Test (org.junit.Test)28 IArchimateElement (com.archimatetool.model.IArchimateElement)16 IArchimateModel (com.archimatetool.model.IArchimateModel)12 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)12 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)11 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)10 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)9 File (java.io.File)8 EObject (org.eclipse.emf.ecore.EObject)8 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)8 Image (org.eclipse.swt.graphics.Image)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)7 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)7 ArrayList (java.util.ArrayList)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)6 Command (org.eclipse.gef.commands.Command)6 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)6 Shell (org.eclipse.swt.widgets.Shell)6