use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class HTMLReportExporter method addNewBounds.
/**
* Add new bounds for each diagram object in relation to its parent offset x,y
*/
private void addNewBounds(IDiagramModelObject dmo, int offsetX, int offsetY) {
// Add new bounds caled to device zoom
BoundsWithAbsolutePosition newBounds = new BoundsWithAbsolutePosition(dmo.getBounds(), ImageFactory.getDeviceZoom() / 100);
// Add offset
newBounds.setOffset(offsetX, offsetY);
childBoundsMap.put(dmo.getId(), newBounds);
// Children
if (dmo instanceof IDiagramModelArchimateObject || dmo instanceof IDiagramModelGroup) {
for (IDiagramModelObject child : ((IDiagramModelContainer) dmo).getChildren()) {
addNewBounds(child, newBounds.getX1(), newBounds.getY1());
}
}
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class DiagramModelArchimateObject method getCopy.
@Override
public EObject getCopy() {
IDiagramModelArchimateObject newObject = (IDiagramModelArchimateObject) super.getCopy();
IArchimateElement element = (IArchimateElement) getArchimateElement().getCopy();
newObject.setArchimateElement(element);
// Clear children
newObject.getChildren().clear();
return newObject;
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ArchimateContainerLayoutPolicy method getAddCommand.
// Over-ride this method to add a sub-command for nested connections
@Override
protected Command getAddCommand(Request generic) {
Object parent = getHost().getModel();
ChangeBoundsRequest request = (ChangeBoundsRequest) generic;
CompoundCommand command = new CompoundCommand();
// Add relations/connections between parent and child if Prefs set and if parent is an Archimate object
boolean doAddNestedConnections = ConnectionPreferences.createRelationWhenMovingElement() && parent instanceof IDiagramModelArchimateObject;
List<IDiagramModelArchimateObject> childObjectsForNewConnections = new ArrayList<IDiagramModelArchimateObject>();
// Delete connections between parent and child if Prefs set and if parent is an Archimate object
boolean doDeleteNestedConnections = ConnectionPreferences.useNestedConnections();
List<IDiagramModelArchimateObject> childObjectsForDeletedConnections = new ArrayList<IDiagramModelArchimateObject>();
for (Object editPart : request.getEditParts()) {
GraphicalEditPart child = (GraphicalEditPart) editPart;
AddObjectCommand addCommand = createAddCommand(request, child, translateToModelConstraint(getConstraintFor(request, child)));
command.add(addCommand);
// If we use nested connections, and child is an Archimate diagram object add it to the list
if (doAddNestedConnections && addCommand.child instanceof IDiagramModelArchimateObject) {
childObjectsForNewConnections.add((IDiagramModelArchimateObject) addCommand.child);
}
// If we need to delete some nested connections
if (doDeleteNestedConnections && addCommand.child instanceof IDiagramModelArchimateObject) {
childObjectsForDeletedConnections.add((IDiagramModelArchimateObject) addCommand.child);
}
}
// We have some child objects for deletion connections
if (!childObjectsForDeletedConnections.isEmpty()) {
Command cmd = new DeleteNestedConnectionsCommand((IDiagramModelArchimateObject) parent, childObjectsForDeletedConnections);
command.add(cmd);
}
// We have some child objects so add the sub command
if (!childObjectsForNewConnections.isEmpty()) {
Command cmd = new CreateNestedArchimateConnectionsWithDialogCommand((IDiagramModelArchimateObject) parent, childObjectsForNewConnections);
command.add(cmd);
}
return command.unwrap();
}
use of com.archimatetool.model.IDiagramModelArchimateObject 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;
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class DuplicateCommandHandlerTests method testDuplicateDiagramModel_AddsConnectionsToConnections.
@Test
public void testDuplicateDiagramModel_AddsConnectionsToConnections() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
IDiagramModel dm = model.getDefaultDiagramModel();
IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(element1);
dm.getChildren().add(dmo1);
IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(element2);
dm.getChildren().add(dmo2);
IArchimateElement element3 = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo3 = tm.createDiagramModelArchimateObjectAndAddToModel(element3);
dm.getChildren().add(dmo3);
IArchimateRelationship relation1 = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation1.setSource(element1);
relation1.setTarget(element2);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation1);
dmc1.connect(dmo1, dmo2);
IArchimateRelationship relation2 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
relation2.setSource(element3);
relation2.setTarget(relation1);
IDiagramModelArchimateConnection dmc2 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation2);
dmc2.connect(dmo3, dmc1);
DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
handler.duplicate();
IDiagramModel dmCopy = model.getDiagramModels().get(1);
EList<IDiagramModelObject> children = dmCopy.getChildren();
assertEquals(3, children.size());
IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0);
IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1);
IDiagramModelArchimateObject dmo3Copy = (IDiagramModelArchimateObject) children.get(2);
assertSame(element1, dmo1Copy.getArchimateConcept());
assertSame(element2, dmo2Copy.getArchimateConcept());
assertSame(element3, dmo3Copy.getArchimateConcept());
IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) dmo1Copy.getSourceConnections().get(0);
assertSame(relation1, dmc1Copy.getArchimateConcept());
assertSame(dmo2Copy, dmc1Copy.getTarget());
// Connection to Connection
assertSame(dmc1Copy, dmo3Copy.getSourceConnections().get(0).getTarget());
}
Aggregations