use of com.archimatetool.model.IDiagramModelComponent in project archi by archimatetool.
the class MyImporter method createAndAddConnectionsToView.
protected void createAndAddConnectionsToView(IDiagramModel diagramModel, IArchimateRelationship relationship) {
List<IDiagramModelArchimateComponent> sources = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship.getSource());
List<IDiagramModelArchimateComponent> targets = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship.getTarget());
for (IDiagramModelComponent dmcSource : sources) {
for (IDiagramModelComponent dmcTarget : targets) {
IDiagramModelArchimateConnection dmc = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
dmc.setArchimateRelationship(relationship);
dmc.connect((IDiagramModelObject) dmcSource, (IDiagramModelObject) dmcTarget);
idLookup.put(dmc.getId(), dmc);
}
}
}
use of com.archimatetool.model.IDiagramModelComponent in project archi by archimatetool.
the class CopySnapshotTests method testNestedConnectionIsCopied.
@Test
public void testNestedConnectionIsCopied() throws IOException {
loadTestModel1();
// Create parent object
IDiagramModelArchimateObject dmoParent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
dmoParent.setBounds(0, 0, 200, 200);
sourceDiagramModel.getChildren().add(dmoParent);
// Create child object
IDiagramModelArchimateObject dmoChild = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessRole());
dmoChild.setBounds(0, 0, 100, 100);
dmoParent.getChildren().add(dmoChild);
// Create relationship
IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relationship.setSource(dmoParent.getArchimateElement());
relationship.setTarget(dmoChild.getArchimateElement());
// Test that an explicit connection is copied
// Create connection
IDiagramModelArchimateConnection connection = ArchimateTestModel.createDiagramModelArchimateConnection(relationship);
connection.connect(dmoParent, dmoChild);
List<IDiagramModelComponent> selected = new ArrayList<IDiagramModelComponent>();
selected.add(dmoParent);
CopySnapshot snapshot = new CopySnapshot(selected);
Command cmd = snapshot.getPasteCommand(targetDiagramModel, null, null, false);
assertNotNull(cmd);
cmd.execute();
assertEquals(1, countAllConnections(targetDiagramModel));
}
use of com.archimatetool.model.IDiagramModelComponent in project archi by archimatetool.
the class CopySnapshotTests method testDiagramCopyContainsAllConnectionsAndObjects.
@Test
public void testDiagramCopyContainsAllConnectionsAndObjects() throws IOException {
loadTestModel2();
List<IDiagramModelComponent> selected = new ArrayList<IDiagramModelComponent>();
// Select all
selected.addAll(getAllDiagramComponents(sourceDiagramModel));
CopySnapshot snapshot = new CopySnapshot(selected);
assertTrue(snapshot.canPasteToDiagram(targetDiagramModel));
Command cmd = snapshot.getPasteCommand(targetDiagramModel, mock(GraphicalViewer.class), null, false);
assertTrue(cmd.canExecute());
cmd.execute();
// Same number of objects pasted
assertEquals(8, countAllObjects(sourceDiagramModel));
assertEquals(countAllObjects(sourceDiagramModel), countAllObjects(targetDiagramModel));
// Same number of connections pasted
assertEquals(11, countAllConnections(sourceDiagramModel));
assertEquals(countAllConnections(sourceDiagramModel), countAllConnections(targetDiagramModel));
}
use of com.archimatetool.model.IDiagramModelComponent in project archi by archimatetool.
the class ArchimateDiagramEditor method selectArchimateConcepts.
@Override
public void selectArchimateConcepts(IArchimateConcept[] archimateConcepts) {
List<Object> objects = new ArrayList<Object>();
for (IArchimateConcept archimateConcept : archimateConcepts) {
// Find Diagram Concepts
for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(getModel(), archimateConcept)) {
if (!objects.contains(dc)) {
objects.add(dc);
}
}
}
selectObjects(objects.toArray());
}
use of com.archimatetool.model.IDiagramModelComponent in project archi by archimatetool.
the class CopyAction method run.
@Override
public void run() {
List<IDiagramModelComponent> selected = new ArrayList<IDiagramModelComponent>();
for (Object object : getSelectedObjects()) {
if (object instanceof EditPart) {
Object model = ((EditPart) object).getModel();
if (model instanceof ILockable && ((ILockable) model).isLocked()) {
continue;
}
if (model instanceof IDiagramModelComponent) {
selected.add((IDiagramModelComponent) model);
}
}
}
CopySnapshot clipBoardCopy = new CopySnapshot(selected);
Clipboard.getDefault().setContents(clipBoardCopy);
// Reset Paste Action
fPasteAction.reset();
}
Aggregations