use of com.archimatetool.model.IConnectable in project archi by archimatetool.
the class CopySnapshot method getMinimumPoint.
// Find leftmost and topmost origin of top level objects
private Point getMinimumPoint(Set<IConnectable> selectedObjects) {
// flag values
int xOrigin = 99999, yOrigin = 99999;
for (IConnectable object : selectedObjects) {
if (object instanceof IDiagramModelObject) {
IDiagramModelObject dmo = (IDiagramModelObject) object;
Point pt = new Point(dmo.getBounds().getX(), dmo.getBounds().getY());
translateToAbsolute(dmo, pt);
// If this object has a parent that is also selected, ignore it
if (dmo.eContainer() instanceof IDiagramModelObject && selectedObjects.contains(dmo.eContainer())) {
continue;
}
if (pt.x < xOrigin) {
xOrigin = pt.x;
}
if (pt.y < yOrigin) {
yOrigin = pt.y;
}
}
}
return (xOrigin == 99999 || yOrigin == 99999) ? null : new Point(xOrigin, yOrigin);
}
use of com.archimatetool.model.IConnectable in project archi by archimatetool.
the class CopySnapshot method createSnapshotConnectionsForSelectedComponents.
/*
* Create copies of connections that have been selected (if source and target also have been selected/mapped)
*/
private void createSnapshotConnectionsForSelectedComponents(List<IDiagramModelComponent> selected) {
// Create new connection copies for all selected connections, but don't connect them yet
for (IDiagramModelComponent component : selected) {
if (component instanceof IDiagramModelConnection) {
IDiagramModelConnection connection = (IDiagramModelConnection) component;
// The source and the target object must also be selected
if (isSelectedConnectionCopyable(connection, selected)) {
IDiagramModelConnection newConnection = (IDiagramModelConnection) connection.getCopy();
fOriginalToSnapshotComponentsMapping.put(connection, newConnection);
}
}
}
// Now connect both ends if both ends are also in the selection/mapping
for (Entry<IConnectable, IConnectable> entry : fOriginalToSnapshotComponentsMapping.entrySet()) {
if (entry.getKey() instanceof IDiagramModelConnection) {
IDiagramModelConnection originalConnection = (IDiagramModelConnection) entry.getKey();
IConnectable newSource = fOriginalToSnapshotComponentsMapping.get(originalConnection.getSource());
IConnectable newTarget = fOriginalToSnapshotComponentsMapping.get(originalConnection.getTarget());
if (newSource != null && newTarget != null) {
IDiagramModelConnection newConnection = (IDiagramModelConnection) entry.getValue();
newConnection.connect(newSource, newTarget);
}
}
}
}
use of com.archimatetool.model.IConnectable in project archi by archimatetool.
the class CopySnapshot method createPasteConnections.
private List<IDiagramModelConnection> createPasteConnections() {
List<IDiagramModelConnection> connections = new ArrayList<IDiagramModelConnection>();
// Create new connections from basis of snapshot
for (IConnectable connectable : fOriginalToSnapshotComponentsMapping.values()) {
if (connectable instanceof IDiagramModelConnection) {
IDiagramModelConnection snapshotConnection = (IDiagramModelConnection) connectable;
IDiagramModelConnection newConnection = (IDiagramModelConnection) snapshotConnection.getCopy();
createID(newConnection);
connections.add(newConnection);
// Mapping
fSnapshotToNewComponentMapping.put(snapshotConnection, newConnection);
// Re-use original Archimate relationship if required
if (!fDoCreateNewArchimateComponents && snapshotConnection instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateConnection originalDiagramConnection = (IDiagramModelArchimateConnection) fOriginalToSnapshotComponentsMapping.getKey(snapshotConnection);
IArchimateRelationship relationship = originalDiagramConnection.getArchimateRelationship();
((IDiagramModelArchimateConnection) newConnection).setArchimateRelationship(relationship);
}
}
}
// Connect them
for (Entry<IConnectable, IConnectable> entry : fSnapshotToNewComponentMapping.entrySet()) {
if (entry.getKey() instanceof IDiagramModelConnection) {
IDiagramModelConnection snapshotConnection = (IDiagramModelConnection) entry.getKey();
IConnectable newSource = fSnapshotToNewComponentMapping.get(snapshotConnection.getSource());
IConnectable newTarget = fSnapshotToNewComponentMapping.get(snapshotConnection.getTarget());
if (newSource != null && newTarget != null) {
IDiagramModelConnection newConnection = (IDiagramModelConnection) entry.getValue();
newConnection.connect(newSource, newTarget);
}
}
}
return connections;
}
use of com.archimatetool.model.IConnectable in project archi by archimatetool.
the class CopySnapshot method createAutomaticSnapshotConnections.
/*
* Create automatic copies of connections (if source and target also have been selected/mapped)
*/
private void createAutomaticSnapshotConnections() {
List<IDiagramModelConnection> allConnections = new ArrayList<IDiagramModelConnection>();
// Get all connections from objects
for (IConnectable connectable : fOriginalToSnapshotComponentsMapping.keySet()) {
for (IDiagramModelConnection connection : connectable.getSourceConnections()) {
if (!allConnections.contains(connection)) {
allConnections.add(connection);
}
}
for (IDiagramModelConnection connection : connectable.getTargetConnections()) {
if (!allConnections.contains(connection)) {
allConnections.add(connection);
}
}
}
// Create copies of ones that have both ends
for (IDiagramModelConnection connection : allConnections) {
if (isSelectedConnectionCopyable(connection, allConnections)) {
IDiagramModelConnection newConnection = (IDiagramModelConnection) connection.getCopy();
fOriginalToSnapshotComponentsMapping.put(connection, newConnection);
}
}
// Now connect both ends if both ends are also in the mapping
for (Entry<IConnectable, IConnectable> entry : fOriginalToSnapshotComponentsMapping.entrySet()) {
if (entry.getKey() instanceof IDiagramModelConnection) {
IDiagramModelConnection originalConnection = (IDiagramModelConnection) entry.getKey();
IConnectable newSource = fOriginalToSnapshotComponentsMapping.get(originalConnection.getSource());
IConnectable newTarget = fOriginalToSnapshotComponentsMapping.get(originalConnection.getTarget());
if (newSource != null && newTarget != null) {
IDiagramModelConnection newConnection = (IDiagramModelConnection) entry.getValue();
newConnection.connect(newSource, newTarget);
} else {
// $NON-NLS-1$
System.err.println("No source or target in CopySnapshot!");
}
}
}
}
use of com.archimatetool.model.IConnectable in project archi by archimatetool.
the class DiagramModelConnection method setSource.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSource(IConnectable newSource) {
IConnectable oldSource = source;
source = newSource;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, IArchimatePackage.DIAGRAM_MODEL_CONNECTION__SOURCE, oldSource, source));
}
Aggregations