Search in sources :

Example 36 with IDiagramModelObject

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

the class BasicConnectionPolicy method getConnectionCreateCommand.

@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
    CreateDiagramConnectionCommand cmd = null;
    EClass classType = (EClass) request.getNewObjectType();
    IDiagramModelObject source = (IDiagramModelObject) getHost().getModel();
    if (isValidConnectionSource(source, classType)) {
        cmd = new CreateDiagramConnectionCommand(request);
        cmd.setSource(source);
        request.setStartCommand(cmd);
    }
    return cmd;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) CreateDiagramConnectionCommand(com.archimatetool.editor.diagram.commands.CreateDiagramConnectionCommand)

Example 37 with IDiagramModelObject

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

the class BasicContainerEditPolicy method getOrphanChildrenCommand.

/*
     * This allows us to drag parts from a parent container to another.
     * This is the "remove" counterpart to the "add" Command created in DiagramLayoutPolicy.createAddCommand(EditPart, Object);
     * 
     * If you don't want a part to be removed, return null here.
     */
@Override
public Command getOrphanChildrenCommand(GroupRequest request) {
    CompoundCommand result = new CompoundCommand(Messages.BasicContainerEditPolicy_0);
    IDiagramModelContainer parent = (IDiagramModelContainer) getHost().getModel();
    for (Object o : request.getEditParts()) {
        EditPart editPart = (EditPart) o;
        IDiagramModelObject child = (IDiagramModelObject) editPart.getModel();
        result.add(new RemoveObjectCommand(parent, child));
    }
    return result;
}
Also used : EditPart(org.eclipse.gef.EditPart) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 38 with IDiagramModelObject

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

the class DiagramLayoutPolicy method createAddCommand.

/*
     * This allows us to drag parts from a parent container to another.
     * This is the "add" counterpart to the "remove" Command created in BasicContainerEditPolicy.getOrphanChildrenCommand(GroupRequest);
     * 
     * If you don't want a part to be added, return null here.
     */
@Override
protected AddObjectCommand createAddCommand(ChangeBoundsRequest request, EditPart childEditPart, Object constraint) {
    IDiagramModelContainer parent = (IDiagramModelContainer) getHost().getModel();
    IDiagramModelObject child = (IDiagramModelObject) childEditPart.getModel();
    // Keep within box
    Rectangle bounds = (Rectangle) constraint;
    if (bounds.x < 0) {
        bounds.x = 0;
    }
    if (bounds.y < 0) {
        bounds.y = 0;
    }
    return new AddObjectCommand(parent, child, bounds);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Example 39 with IDiagramModelObject

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

the class PartComponentEditPolicy method createDeleteCommand.

@Override
protected Command createDeleteCommand(GroupRequest request) {
    IDiagramModelObject object = (IDiagramModelObject) getHost().getModel();
    boolean isLocked = object instanceof ILockable && ((ILockable) object).isLocked();
    return isLocked ? null : DiagramCommandFactory.createDeleteDiagramObjectCommand(object);
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) ILockable(com.archimatetool.model.ILockable)

Example 40 with IDiagramModelObject

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

the class NestedElementsChecker method findWrongNestedElements.

// Nested diagram elements without correct relationships
List<IIssue> findWrongNestedElements() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateDiagramModel dm : fViews) {
        for (Iterator<EObject> iter = dm.eAllContents(); iter.hasNext(); ) {
            EObject eObject = iter.next();
            if (eObject instanceof IDiagramModelArchimateObject) {
                IDiagramModelArchimateObject parent = (IDiagramModelArchimateObject) eObject;
                for (IDiagramModelObject dmoChild : parent.getChildren()) {
                    if (dmoChild instanceof IDiagramModelArchimateObject) {
                        IDiagramModelArchimateObject child = (IDiagramModelArchimateObject) dmoChild;
                        if (isNestedWithoutValidRelation(parent, child)) {
                            String description = NLS.bind(fDescription, new Object[] { child.getName(), parent.getName() });
                            IIssue issue = new AdviceType(fName, description, fExplanation, child);
                            issues.add(issue);
                        }
                    }
                }
            }
        }
    }
    return issues;
}
Also used : AdviceType(com.archimatetool.hammer.validation.issues.AdviceType) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Aggregations

IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)51 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)12 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)12 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)10 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 Test (org.junit.Test)10 IArchimateElement (com.archimatetool.model.IArchimateElement)9 Dimension (org.eclipse.draw2d.geometry.Dimension)9 IDiagramModel (com.archimatetool.model.IDiagramModel)8 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)7 IBounds (com.archimatetool.model.IBounds)6 Command (org.eclipse.gef.commands.Command)6 ILockable (com.archimatetool.model.ILockable)5 ArrayList (java.util.ArrayList)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 EObject (org.eclipse.emf.ecore.EObject)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)4 IArchimateModel (com.archimatetool.model.IArchimateModel)3 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 ILineObject (com.archimatetool.model.ILineObject)3