Skip to content

Instantly share code, notes, and snippets.

View romualdrichard's full-sized avatar

Romuald Richard romualdrichard

View GitHub Profile
@romualdrichard
romualdrichard / Excel XML 2003 Export Import.ajs
Last active April 28, 2026 10:08
#jArchi Export and Import model or views to Excel 2003 XML
/*
* Archi ↔ Excel XML (XML Spreadsheet 2003)
* Single script: choose Export or Import at startup
* Export: full model or selected views → .xml
* Import: .xml → model (UID optional, duplicate detection with custom dialog)
*/
console.show();
console.clear();
// ---------- Global SWT declarations ----------
@romualdrichard
romualdrichard / CreateOrUpdateCalculatedNotes.ajs
Created April 23, 2026 08:11
#jarchi Create/update note from label
/**
* CreateOrUpdateCalculatedNotes.ajs
* ---------------------------------------------------------------------------
* Creates a note for each selected object in the current view,
* or updates all notes that have the calculatedLabel property.
*
* Rules:
* - The "calculatedLabel" property on the note stores the ID of the
* visual object it refers to (enables reliable updates).
* - Note text = labelValue of the object if non-empty, otherwise name.
@romualdrichard
romualdrichard / DecreaseFontSize.ajs
Created April 9, 2026 12:06
#jarchi decrease fonts size of the selection
// This script decrease the font size of the selected element
// Requires jArchi - https://www.archimatetool.com
// Change -1 to 1 to have IncreaseFontSize script
// Assign a key to this script
try{
console.log("font decreasing");
$(selection).each(function(selectedElement) {
selectedElement.fontSize += -1;
} );
@romualdrichard
romualdrichard / CreateViewFromSelection.ajs
Last active April 3, 2026 09:03
#jarchi create view from selection
/**
* CreateViewFromSelection.ajs
*
* Creates a new ArchiMate view from the current selection,
* OR updates an existing generated view if one is selected.
*
* Identity: The view carries a user property "generated-by-script" = "CreateViewFromSelection"
* and a JSON property "generation-criteria" storing the full criteria.
*
* Update mode (view with that property selected):
@romualdrichard
romualdrichard / gist:6a33ed04757bfc2a54bb46299ab1b37e
Created March 31, 2026 08:10
#jarchi Merge Two Selected Archi Objects
/**
* Merge Two Selected Archi Objects
*
* Works with either:
* - Two elements of the same type
* - Two relationships of the same type, source and target
*
* An SWT dialog lets the user choose, for each field (name, documentation,
* each property), which value to keep — or to merge both documentation texts.
*
@romualdrichard
romualdrichard / align-and-spread.ajs
Last active March 31, 2026 08:08
#jarchi Align and Spread with dialogbox
// Author: Jean-Charles Perron, based on the work of Rob Kamp
// Requires: jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
// Purpose: SWT dialog to align (left, top, bottom, right) and spread (horizontal, vertical) selected elements
// Date: 2024-01
// Version: 2.2
// Changes:
// 1.0 - Initial version (Rob Kamp / Jean-Charles Perron): spread vertical/horizontal via prompt
// 2.0 - SWT dialog with align left/top/bottom/right + spread H/V, closeable with ESC
// 2.1 - Dual behaviour: children mode vs normal mode
// 2.2 - Children mode reworked:
@romualdrichard
romualdrichard / ModifyPropertyValue.ajs
Created January 30, 2026 08:46
#jarchi modifiy property value
/*
* JArchi Script - Modify User Property Value
*
* This script allows you to search and replace a property value
* on all model objects that have this property.
*
* Uses SWT dialog boxes for user interaction.
*/
// Import necessary SWT classes
/*
* Distribute relationships between multiple selected elements
* Enhanced version - supports multiple elements selection
* Based on: https://forum.archimatetool.com/index.php?topic=1174.0
*/
console.log("Distribute relations - Multi-element version");
var view = selection.parents().filter('archimate-diagram-model').first();
var elements = selection.filter('element');
@romualdrichard
romualdrichard / search_and_create_view.ajs
Created January 29, 2026 13:59
#jarchi create a view from a criteria
/*
* JArchi Script - Search and Create View
* Search for model elements by text and create a view with the results
*/
// Import necessary SWT classes
var SWT = Java.type('org.eclipse.swt.SWT');
var Shell = Java.type('org.eclipse.swt.widgets.Shell');
var Display = Java.type('org.eclipse.swt.widgets.Display');
var Dialog = Java.type('org.eclipse.swt.widgets.Dialog');
@romualdrichard
romualdrichard / duplicate_relation.ajs
Created January 29, 2026 13:08
#jarchi duplicate relationship
/**
* JArchi Script: Duplicate Relationships
*
* This script duplicates selected relationships by creating:
* - A new relationship with the same type, source, target and properties
* - Visual connections in all views where the original relationship appears (optional)
*
* Usage: Select one or more relationships and run the script
*/