use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class ArchimateDiagramModelFactory method getNewObject.
public Object getNewObject() {
if (fTemplate == null) {
return null;
}
Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
// Connection created from Relationship Template
if (object instanceof IArchimateRelationship) {
return createDiagramModelArchimateConnection((IArchimateRelationship) object);
} else // Archimate Diagram Object created from Archimate Element Template
if (object instanceof IArchimateElement) {
IArchimateElement element = (IArchimateElement) object;
element.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
return createDiagramModelArchimateObject(element);
} else // Group
if (object instanceof IDiagramModelGroup) {
IDiagramModelGroup group = (IDiagramModelGroup) object;
group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
ColorFactory.setDefaultColors(group);
((IDiagramModelGroup) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
} else // Note
if (object instanceof IDiagramModelNote) {
ColorFactory.setDefaultColors((IDiagramModelObject) object);
((IDiagramModelNote) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
} else // Connection
if (object instanceof IDiagramModelConnection) {
ColorFactory.setDefaultColors((IDiagramModelConnection) object);
}
return object;
}
use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class ManualBendpointEditPolicy method getCreateBendpointCommand.
@Override
protected Command getCreateBendpointCommand(BendpointRequest request) {
CreateBendpointCommand command = new CreateBendpointCommand();
Point p = request.getLocation();
Connection conn = getConnection();
conn.translateToRelative(p);
command.setLocation(p);
Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
conn.translateToRelative(ref1);
conn.translateToRelative(ref2);
command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
command.setDiagramModelConnection((IDiagramModelConnection) request.getSource().getModel());
command.setIndex(request.getIndex());
return command;
}
use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class ManualBendpointEditPolicy method getMoveBendpointCommand.
@Override
protected Command getMoveBendpointCommand(BendpointRequest request) {
MoveBendpointCommand command = new MoveBendpointCommand();
Point p = request.getLocation();
Connection conn = getConnection();
conn.translateToRelative(p);
command.setLocation(p);
Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
conn.translateToRelative(ref1);
conn.translateToRelative(ref2);
command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
command.setDiagramModelConnection((IDiagramModelConnection) request.getSource().getModel());
command.setIndex(request.getIndex());
return command;
}
use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class DiagramModelUtilsTests method hasCycle.
@Test
public void hasCycle() {
IDiagramModelObject source = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelObject target = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
;
IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
conn.connect(source, target);
assertFalse(DiagramModelUtils.hasCycle(source, target));
conn.connect(target, source);
assertTrue(DiagramModelUtils.hasCycle(source, target));
conn.disconnect();
assertFalse(DiagramModelUtils.hasCycle(source, target));
}
use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.
the class ArchimateRelationshipEditPart method getFilteredConnections.
/**
* See if any connections are filtered out
* @param originalList
* @return A list of filtered connections
*/
private List<IDiagramModelConnection> getFilteredConnections(List<IDiagramModelConnection> originalList) {
IEditPartFilterProvider filterProvider = getRootEditPartFilterProvider();
if (filterProvider == null) {
return originalList;
}
IConnectionEditPartFilter[] filters = getRootEditPartFilterProvider().getEditPartFilters(IConnectionEditPartFilter.class);
if (filters != null) {
List<IDiagramModelConnection> filteredList = new ArrayList<IDiagramModelConnection>();
for (IDiagramModelConnection connection : originalList) {
boolean add = true;
for (IConnectionEditPartFilter filter : filters) {
add = filter.isConnectionVisible(this, connection);
if (!add) {
// no point in trying the next filter
break;
}
}
if (add) {
filteredList.add(connection);
}
}
return filteredList;
}
return originalList;
}
Aggregations