use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class DeleteNestedConnectionsCommand method createDeleteCommands.
/**
* Child Objects that have connections
*/
void createDeleteCommands() {
for (IDiagramModelArchimateObject child : fChildObjects) {
for (IDiagramModelConnection connection : child.getTargetConnections()) {
if (connection instanceof IDiagramModelArchimateConnection && DiagramModelUtils.shouldBeHiddenConnection((IDiagramModelArchimateConnection) connection)) {
for (IDiagramModelConnection subconnection : connection.getTargetConnections()) {
Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand(subconnection);
add(cmd);
}
for (IDiagramModelConnection subconnection : connection.getSourceConnections()) {
Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand(subconnection);
add(cmd);
}
}
}
}
}
use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class DiagramModelObjectTests method testAddConnection.
@Test
public void testAddConnection() {
IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
// Should not be added if connection source or target not set
object.addConnection(conn);
assertTrue(object.getSourceConnections().isEmpty());
assertTrue(object.getTargetConnections().isEmpty());
// Now should be OK
conn.connect(object, object);
object.addConnection(conn);
assertTrue(object.getSourceConnections().contains(conn));
assertTrue(object.getTargetConnections().contains(conn));
}
use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class DiagramModelObjectTests method testGetCopy.
@Override
@Test
public void testGetCopy() {
super.testGetCopy();
IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
conn.connect(object, object);
object.addConnection(conn);
assertTrue(object.getSourceConnections().contains(conn));
assertTrue(object.getTargetConnections().contains(conn));
IBounds bounds = IArchimateFactory.eINSTANCE.createBounds(2, 4, 6, 8);
object.setBounds(bounds);
IDiagramModelObject copy = (IDiagramModelObject) object.getCopy();
assertNotSame(object, copy);
assertTrue(copy.getSourceConnections().isEmpty());
assertTrue(copy.getTargetConnections().isEmpty());
assertNotSame(bounds, copy.getBounds());
assertEquals(bounds.getX(), copy.getBounds().getX());
assertEquals(bounds.getY(), copy.getBounds().getY());
assertEquals(bounds.getWidth(), copy.getBounds().getWidth());
assertEquals(bounds.getHeight(), copy.getBounds().getHeight());
}
use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class DeleteCommandHandler method createCommands.
/**
* Create the Delete Commands
*/
private void createCommands() {
/*
* We need to ensure that the Delete Diagram Model Commands are called first in order to close
* any open diagram editors before removing their models from parent folders.
*/
for (Object object : fElementsToDelete) {
if (object instanceof IDiagramModel) {
CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
if (compoundCommand != null) {
Command cmd = new DeleteDiagramModelCommand((IDiagramModel) object);
compoundCommand.add(cmd);
} else {
// $NON-NLS-1$
System.err.println("Could not get CompoundCommand in " + getClass());
}
}
}
/*
* Then the other types
*/
for (Object object : fElementsToDelete) {
if (object instanceof IDiagramModel) {
// already done
continue;
}
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 IFolder) {
Command cmd = new DeleteFolderCommand((IFolder) object);
compoundCommand.add(cmd);
} else if (object instanceof IArchimateElement) {
Command cmd = new DeleteArchimateElementCommand((IArchimateElement) object);
compoundCommand.add(cmd);
} else if (object instanceof IArchimateRelationship) {
Command cmd = new DeleteArchimateRelationshipCommand((IArchimateRelationship) object);
compoundCommand.add(cmd);
} else if (object instanceof IDiagramModelObject) {
Command cmd = DiagramCommandFactory.createDeleteDiagramObjectCommand((IDiagramModelObject) object);
compoundCommand.add(cmd);
} else if (object instanceof IDiagramModelConnection) {
Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand((IDiagramModelConnection) object);
compoundCommand.add(cmd);
}
}
}
Aggregations