use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class DiagramFigureTypeSection method update.
@Override
protected void update() {
IDiagramModelArchimateObject diagramObject = (IDiagramModelArchimateObject) getFirstSelectedObject();
IArchimateElement element = diagramObject.getArchimateElement();
Image image1 = FigureImagePreviewFactory.getFigurePreviewImageForClass(element.eClass());
Image image2 = FigureImagePreviewFactory.getAlternateFigurePreviewImageForClass(element.eClass());
figure1.setImage(image1);
figure2.setImage(image2);
figure1.getParent().layout();
int type = diagramObject.getType();
figure1.setSelected(type == 0);
figure2.setSelected(type == 1);
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class DiagramModelUtils method shouldBeHiddenConnection.
/**
* @param connection The connection to check
* @return true if a connection should be hidden when its source (parent) element contains its target (child) element
*/
public static boolean shouldBeHiddenConnection(IDiagramModelArchimateConnection connection) {
if (!ConnectionPreferences.useNestedConnections()) {
return false;
}
// Only if the connection's source and target are both ArchiMate concepts
if (!(connection.getSource() instanceof IDiagramModelArchimateComponent) && !(connection.getTarget() instanceof IDiagramModelArchimateComponent)) {
return false;
}
IDiagramModelArchimateComponent source = (IDiagramModelArchimateComponent) connection.getSource();
IDiagramModelArchimateComponent target = (IDiagramModelArchimateComponent) connection.getTarget();
// If the connection's source element contains the target element, or the connection's target element contains the source element
if (source instanceof IDiagramModelArchimateObject && target instanceof IDiagramModelArchimateObject) {
if (((IDiagramModelContainer) source).getChildren().contains((IDiagramModelArchimateObject) target) || ((IDiagramModelContainer) target).getChildren().contains((IDiagramModelArchimateObject) source)) {
// And it's a relationship type we have chosen to hide
for (EClass eClass : ConnectionPreferences.getRelationsClassesForHiding()) {
if (connection.getArchimateRelationship().eClass() == eClass) {
return true;
}
}
}
}
// If connection's source is an element and target is a connection
if (source instanceof IDiagramModelArchimateObject && target instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateObject parent = (IDiagramModelArchimateObject) source;
IConnectable connectionSource = ((IDiagramModelArchimateConnection) target).getSource();
IConnectable connectionTarget = ((IDiagramModelArchimateConnection) target).getTarget();
if (parent.getChildren().contains(connectionSource) && parent.getChildren().contains(connectionTarget)) {
// And it's a relationship type we have chosen to hide
for (EClass eClass : ConnectionPreferences.getRelationsClassesForHiding()) {
if (connection.getArchimateRelationship().eClass() == eClass) {
return true;
}
}
}
}
// TODO: Not sure if this directionality should be allowed
if (target instanceof IDiagramModelArchimateObject && source instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateObject parent = (IDiagramModelArchimateObject) target;
IConnectable connectionSource = ((IDiagramModelArchimateConnection) source).getSource();
IConnectable connectionTarget = ((IDiagramModelArchimateConnection) source).getTarget();
if (parent.getChildren().contains(connectionSource) && parent.getChildren().contains(connectionTarget)) {
// And it's a relationship type we have chosen to hide
for (EClass eClass : ConnectionPreferences.getRelationsClassesForHiding()) {
if (connection.getArchimateRelationship().eClass() == eClass) {
return true;
}
}
}
}
return false;
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class JunctionFigureTests method createFigure.
@Override
protected JunctionFigure createFigure() {
// Add a DiagramModelObject
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setBounds(IArchimateFactory.eINSTANCE.createBounds());
dmo.setArchimateElement(IArchimateFactory.eINSTANCE.createJunction());
dm.getChildren().add(dmo);
// Layout
editor.layoutPendingUpdates();
return (JunctionFigure) editor.findFigure(dmo);
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ArchimateDiagramConnectionPolicyTests method testIsValidConnection_ArchimateDiagramModelConnection.
@Test
public void testIsValidConnection_ArchimateDiagramModelConnection() {
EClass relationshipType = IArchimatePackage.eINSTANCE.getAssociationRelationship();
IDiagramModelArchimateObject dmao1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmao1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
IDiagramModelArchimateObject dmao2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmao2.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
// OK
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, dmao2, relationshipType));
// OK if relationshipType is null (magic connector)
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, dmao2, null));
// Nope
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(IArchimateFactory.eINSTANCE.createDiagramModelGroup(), dmao2, relationshipType));
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(IArchimateFactory.eINSTANCE.createDiagramModelNote(), dmao2, relationshipType));
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class FormatPainterInfoTests method testUpdatePaintFormat.
@Test
public void testUpdatePaintFormat() {
// Set FormatPainterInfo to Source component
IDiagramModelArchimateObject sourceComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
info.updatePaintFormat(sourceComponent);
PaintFormat pf = info.getPaintFormat();
assertNotNull(pf);
assertEquals(sourceComponent, pf.getSourceComponent());
// Check cursor
assertEquals(new RGB(255, 255, 181), pf.getCursorColor());
}
Aggregations