Search in sources :

Example 26 with IDiagramModelConnection

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

the class ArchimateDiagramModelFactory method getNewObject.

public Object getNewObject() {
    if (fTemplate == null) {
        return null;
    }
    Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
    // Connection created from Relationship Template
    if (object instanceof IArchimateRelationship) {
        return createDiagramModelArchimateConnection((IArchimateRelationship) object);
    } else // Archimate Diagram Object created from Archimate Element Template
    if (object instanceof IArchimateElement) {
        IArchimateElement element = (IArchimateElement) object;
        element.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        return createDiagramModelArchimateObject(element);
    } else // Group
    if (object instanceof IDiagramModelGroup) {
        IDiagramModelGroup group = (IDiagramModelGroup) object;
        group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        ColorFactory.setDefaultColors(group);
        ((IDiagramModelGroup) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Note
    if (object instanceof IDiagramModelNote) {
        ColorFactory.setDefaultColors((IDiagramModelObject) object);
        ((IDiagramModelNote) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Connection
    if (object instanceof IDiagramModelConnection) {
        ColorFactory.setDefaultColors((IDiagramModelConnection) object);
    }
    return object;
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote)

Example 27 with IDiagramModelConnection

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

the class ManualBendpointEditPolicy method getCreateBendpointCommand.

@Override
protected Command getCreateBendpointCommand(BendpointRequest request) {
    CreateBendpointCommand command = new CreateBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();
    conn.translateToRelative(p);
    command.setLocation(p);
    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
    conn.translateToRelative(ref1);
    conn.translateToRelative(ref2);
    command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    command.setDiagramModelConnection((IDiagramModelConnection) request.getSource().getModel());
    command.setIndex(request.getIndex());
    return command;
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) Connection(org.eclipse.draw2d.Connection) CreateBendpointCommand(com.archimatetool.editor.diagram.commands.CreateBendpointCommand) Point(org.eclipse.draw2d.geometry.Point)

Example 28 with IDiagramModelConnection

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

the class ManualBendpointEditPolicy method getMoveBendpointCommand.

@Override
protected Command getMoveBendpointCommand(BendpointRequest request) {
    MoveBendpointCommand command = new MoveBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();
    conn.translateToRelative(p);
    command.setLocation(p);
    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
    conn.translateToRelative(ref1);
    conn.translateToRelative(ref2);
    command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    command.setDiagramModelConnection((IDiagramModelConnection) request.getSource().getModel());
    command.setIndex(request.getIndex());
    return command;
}
Also used : MoveBendpointCommand(com.archimatetool.editor.diagram.commands.MoveBendpointCommand) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) Connection(org.eclipse.draw2d.Connection) Point(org.eclipse.draw2d.geometry.Point)

Example 29 with IDiagramModelConnection

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

the class DiagramModelUtilsTests method hasCycle.

@Test
public void hasCycle() {
    IDiagramModelObject source = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    IDiagramModelObject target = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    ;
    IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
    conn.connect(source, target);
    assertFalse(DiagramModelUtils.hasCycle(source, target));
    conn.connect(target, source);
    assertTrue(DiagramModelUtils.hasCycle(source, target));
    conn.disconnect();
    assertFalse(DiagramModelUtils.hasCycle(source, target));
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Test(org.junit.Test)

Example 30 with IDiagramModelConnection

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

the class ArchimateRelationshipEditPart method getFilteredConnections.

/**
 * See if any connections are filtered out
 * @param originalList
 * @return A list of filtered connections
 */
private List<IDiagramModelConnection> getFilteredConnections(List<IDiagramModelConnection> originalList) {
    IEditPartFilterProvider filterProvider = getRootEditPartFilterProvider();
    if (filterProvider == null) {
        return originalList;
    }
    IConnectionEditPartFilter[] filters = getRootEditPartFilterProvider().getEditPartFilters(IConnectionEditPartFilter.class);
    if (filters != null) {
        List<IDiagramModelConnection> filteredList = new ArrayList<IDiagramModelConnection>();
        for (IDiagramModelConnection connection : originalList) {
            boolean add = true;
            for (IConnectionEditPartFilter filter : filters) {
                add = filter.isConnectionVisible(this, connection);
                if (!add) {
                    // no point in trying the next filter
                    break;
                }
            }
            if (add) {
                filteredList.add(connection);
            }
        }
        return filteredList;
    }
    return originalList;
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) ArrayList(java.util.ArrayList)

Aggregations

IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)34 Test (org.junit.Test)15 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)10 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)7 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)5 Command (org.eclipse.gef.commands.Command)5 IArchimateElement (com.archimatetool.model.IArchimateElement)4 IConnectable (com.archimatetool.model.IConnectable)4 IDiagramModel (com.archimatetool.model.IDiagramModel)4 EditPart (org.eclipse.gef.EditPart)4 ReconnectDiagramConnectionCommand (com.archimatetool.editor.diagram.commands.ReconnectDiagramConnectionCommand)3 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)3 ArrayList (java.util.ArrayList)3 ConnectionTextPositionCommand (com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)2 LineWidthCommand (com.archimatetool.editor.diagram.commands.LineWidthCommand)2 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)2 DeleteArchimateElementCommand (com.archimatetool.editor.model.commands.DeleteArchimateElementCommand)2 DeleteArchimateRelationshipCommand (com.archimatetool.editor.model.commands.DeleteArchimateRelationshipCommand)2