swt dialog box example in jarchi

Started by rchevallier, April 07, 2020, 16:00:55 PM

Previous topic - Next topic

rchevallier

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

NB: Using VsCode for coding in Javascript, I added some type annotation for type checking functionality of this IDE


Jean-Baptiste Sarrodie

Hi,

Great! Thank you!

I was missing such example.

Regards,

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Phil Beauvoir

Yes, thank-you very much for sharing. That's what this forum is all about, users helping each other and sharing. Nice. :-)

Phil
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

rchevallier

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) :)

Manj75

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.

Phil Beauvoir

Some of the code in the script is not supported by JS ES5.

In Archi Preferences, Scripting, choose "Nashorn ES6" or "GraalVM".
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Manj75

Thanks Phil - Nashorn ES6 sorted it

rchevallier

Thanks Phil
It was not clear indeed it requires ES6 or above
Added a comment in the gist