Hi all,
Based on the work of Hervé, but using SWT/Jface instead of Swing to have the same look and feel as Archi, I've developed a configuration dialog box script which can serve as example if you need something similar. Caveat: you need to understand swt widgets and layout.
You can find the code here: https://gist.github.com/rchevallier/d155527dcc3e956848a90e51bf21d7e1 (https://gist.github.com/rchevallier/d155527dcc3e956848a90e51bf21d7e1)
NB: Using VsCode for coding in Javascript, I added some type annotation for type checking functionality of this IDE
Hi,
Great! Thank you!
I was missing such example.
Regards,
JB
Yes, thank-you very much for sharing. That's what this forum is all about, users helping each other and sharing. Nice. :-)
Phil
And if anyone has remarks for improvement, please don't hesitate (my 1st code in js, I'm more of a java, scala, python guy) :)
I came across this post and the script looked interesting, but on trying it out I get an exception. Is this meant to work straight out of the zip file or am I missing a step?
Script Error: javax.script.ScriptException: SyntaxError: file:/C:/Users/Manjit/AppData/Roaming/Archi4/scripts/JFaceConfigDialog.ajs:22:23 Expected an operand but found const
/** @type JavaClass */ const SWT = Java.type('org.eclipse.swt.SWT')
^ in <eval> at line number 1
Appreciate any help to get this working as it would be great to use for same look and feel of Archi.
Some of the code in the script is not supported by JS ES5.
In Archi Preferences, Scripting, choose "Nashorn ES6" or "GraalVM".
Thanks Phil - Nashorn ES6 sorted it
Thanks Phil
It was not clear indeed it requires ES6 or above
Added a comment in the gist
Apologies for replying to such an old thread. I've been searching to find an example of adding a SWT.Selection listener to buttons using rchevallier's script as the base. I have made changes to the script and it is working for my use case but now need to add a selection listener to a specific button to update something on the dialog. All the examples available are Java examples but I can't seem to find a Javascript / Graalvm / JArchi example. The Java examples are typically as follows:
button.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
// do something
}
} );
How would I do it if I added a listener to rchevaillier's script?
A similar question was asked in this thread but I don't know what the eventual resolution was: https://forum.archimatetool.com/index.php?topic=1088.msg5809#msg5809
Thanks in advance for any possible assistance
Try this:
button.addListener(SWT.Selection, event => {
console.log(event);
});
Thank you so much, that works!!
@fanievh Since then, I've developped more extensive use of SWT by jArchi.
In case this can be helpful, you'll find the code there: https://github.com/rchevallier/jarchi-lib/blob/main/doc/Colormap%20wizard.md (and https://github.com/rchevallier/jarchi-lib/blob/main/scripts/lib/colormap/UI.js)
Thank you
@rchevallier, I just had a brief look at your example and it looks very good!