Skip to content

Instantly share code, notes, and snippets.

@projetnumero9
Created December 9, 2020 20:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save projetnumero9/3301cfb99d8747c79a8bd6e0edcec32e to your computer and use it in GitHub Desktop.
Save projetnumero9/3301cfb99d8747c79a8bd6e0edcec32e to your computer and use it in GitHub Desktop.
#jArchi Create createViewReference between concept and view, back and forth, to ease navigation
//
// Link concept to View
//
// 2020 David GERARD
//
// For selected concept in view, search the model for a view with the same name.
// If found,
// - create a .createViewReference() positioned in the upperleft corner of the concept, pointing to the view with the same name
// - create a .createViewReference() positioned in the upperleft corner of the view with the same name, point to the view holding the selected concept
// Quite useful to describe process and subprocesses, and especially with the HTML export
//
// No nesting for the time being; follow [Extend .createViewReference with 'autoNest' optional boolean parameter · Issue #81 · archimatetool/archi-scripting-plugin](https://github.com/archimatetool/archi-scripting-plugin/issues/81)
//
// Roadmap:
// - currently the script should not be run multiple times for the same concept: it will create multiple .createViewReference(), stacked
//
// # Functions
// # Variables
var list = $(selection);
all_views = $("archimate-diagram-model");
// # Main
console.show();
console.clear();
console.log("> Link concept to View:");
list.each(function(theConcept) {
currentConceptView = $("."+theConcept.view.name).filter("archimate-diagram-model").first() ;
if ($("."+theConcept.name).filter("archimate-diagram-model").first()!= null) {
var targetView = $("."+theConcept.name).filter("archimate-diagram-model").first() ;
viewRef = currentConceptView.createViewReference(targetView, theConcept.bounds.x, theConcept.bounds.y, 30, 30);
viewRef = targetView.createViewReference(currentConceptView, 10, 10, 30, 30);
};
});
console.log("> Ending properly");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment