Closed pgartlan-kd closed 3 years ago
Hi, this can be done through a script:
var response = window.confirm("This script will swap ends on selected relationships, and will update all views in which they appear. Continue?");
if (!response)
exit();
selection.filter('relationship').each(function(o) {swapRelationshipEnds(concept(o))});
function swapRelationshipEnds(r) {
// Check if allowed
if ($.model.isAllowedRelationship(r.type, r.target.type, r.source.type)) {
// Change type temporarily (some intermediate states are not valid otherwise)
var origType = r.type;
r.type = "association-relationship";
// Swap source and target
var origSource = r.source;
var origTarget = r.target;
r.source = origTarget;
r.target = origSource;
// Restore type
r.type = origType;
// Swap Bendpoints (if any)
$(r).objectRefs().each(function(o) {
bps = o.relativeBendpoints;
o.deleteAllBendpoints();
var i;
for (i = 0; i < bps.length; i++) {
bp = bps[bps.length-i-1];
new_bp = {};
new_bp.startX = bp.endX;
new_bp.startY = bp.endY;
new_bp.endX = bp.startX;
new_bp.endY = bp.startY;
o.addRelativeBendpoint(new_bp, i);
}
});
}
}
function concept(o) {
if(o.concept)
return o.concept;
else
return o;
}
I'll publish it on Gist soon
Thanks for that, JB.
A general point - we realised that there is no way that we can implement every feature request, and every particular requirement for every user ("make each assignment relationship coloured blue, but only on Mondays!").
So that's why we developed jArchi, the scripting plug-in. It should be possible, using jArchi, to implement a lot of individual features, such as this. Once created, a script can be re-used and become part of a scripting library. Perhaps the Archi community could even share their scripts with each other, and even help each other (rather than one or two people having to do everything.)
Awesome - thank you so much
Hi, would be handy to be able to reverse a relationship where allowed. For example: 1) right click on a relationship 2) select reverse direction
Merci