use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class OpacityAction method run.
@Override
public void run() {
List<?> selection = getSelectedObjects();
IDiagramModelObject dmo = (IDiagramModelObject) getFirstValidSelectedModelObject(selection);
if (dmo == null) {
return;
}
// Set default alpha on first selected connection
int alpha = dmo.getAlpha();
OpacityDialog dialog = new OpacityDialog(getWorkbenchPart().getSite().getShell(), alpha);
if (dialog.open() == Window.OK) {
execute(createCommand(selection, dialog.getAlpha()));
}
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class DiagramModelUtilsTests method hasExistingConnectionType.
@Test
public void hasExistingConnectionType() {
IDiagramModelObject source = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createArtifact());
IDiagramModelObject target = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createArtifact());
IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
IDiagramModelConnection conn = ArchimateTestModel.createDiagramModelArchimateConnection(relation);
conn.connect(source, target);
assertTrue(DiagramModelUtils.hasExistingConnectionType(source, target, relation.eClass()));
assertFalse(DiagramModelUtils.hasExistingConnectionType(source, target, IArchimatePackage.eINSTANCE.getAccessRelationship()));
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class DiagramModelUtilsTests method getAncestorContainer.
// =================================================================================================
@Test
public void getAncestorContainer() {
IDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
IDiagramModelGroup group1 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelGroup group2 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelObject child = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
dm.getChildren().add(group1);
group1.getChildren().add(group2);
assertNull(DiagramModelUtils.getAncestorContainer(child));
group2.getChildren().add(child);
assertEquals(group1, DiagramModelUtils.getAncestorContainer(child));
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class DuplicateCommandHandlerTests method testDuplicateDiagramModel.
@Test
public void testDuplicateDiagramModel() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
IDiagramModel dm = model.getDefaultDiagramModel();
IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
dmo1.setName("dm");
dm.getChildren().add(dmo1);
IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
dm.getChildren().add(dmo2);
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(actor);
relation.setTarget(role);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
dmc1.connect(dmo1, dmo2);
DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
handler.duplicate();
assertEquals(2, model.getDiagramModels().size());
IDiagramModel dmCopy = model.getDiagramModels().get(1);
assertNotSame(dm, dmCopy);
assertEquals(dm.getName() + " (copy)", dmCopy.getName());
EList<IDiagramModelObject> children = dmCopy.getChildren();
assertEquals(2, children.size());
IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0);
IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1);
assertNotSame(dmo1, dmo1Copy);
assertNotSame(dmo2, dmo2Copy);
assertSame(actor, dmo1Copy.getArchimateConcept());
assertSame(role, dmo2Copy.getArchimateConcept());
EList<IDiagramModelConnection> connections = dmo1Copy.getSourceConnections();
assertEquals(1, connections.size());
IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) connections.get(0);
assertNotSame(dmc1, dmc1Copy);
assertSame(relation, dmc1Copy.getArchimateConcept());
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class ArchimateContainerEditPolicy method createNewConnectionCommands.
/**
* When Archimate child objects are dragged out of a parent Archimate object check to see if new connections should be created
*
* TODO A3: If O1--C1--O2 and in parent. C1 is also connected to parent (and hidden).
* O1 or O2 is removed from parent - should add connection from C1 to parent?
* Or should it be only when O1 AND O2 are removed from parent?
*/
void createNewConnectionCommands(IDiagramModelArchimateObject parentObject, List<?> childEditParts, CompoundCommand command) {
IArchimateElement parentElement = parentObject.getArchimateElement();
for (Object o : childEditParts) {
IDiagramModelObject child = (IDiagramModelObject) ((EditPart) o).getModel();
// If it's an Archimate type child object...
if (child instanceof IDiagramModelArchimateObject) {
IDiagramModelArchimateObject childObject = (IDiagramModelArchimateObject) child;
IArchimateElement childElement = childObject.getArchimateElement();
// See if there are any (nested type) relationships between parent element and child element...
for (IArchimateRelationship relation : parentElement.getSourceRelationships()) {
if (relation.getTarget() == childElement && DiagramModelUtils.isNestedConnectionTypeRelationship(relation)) {
// And there's not a connection already there then add one
if (!DiagramModelUtils.hasDiagramModelArchimateConnection(parentObject, childObject, relation)) {
command.add(new CreateDiagramArchimateConnectionCommand(parentObject, childObject, relation));
}
}
}
}
}
}
Aggregations