archimatetool / archi-scripting-plugin

jArchi - Scripting for Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
122 stars 33 forks source link

Idea - Make it possible to call jArchi's API from a browser window #52

Open jbsarrodie opened 5 years ago

jbsarrodie commented 5 years ago

This is a note to self for my future experimentations

ATM it is possible to open a browser window (in fact a "Tab" in the UI) which either load an HTTP(S) resource or a local content (potentially a simple string created "on the fly" by a jArchi script).

This is very powerful but is "read only": even if the loaded HTML page can be interactive, it is impossible to return some information to the calling script, and also impossible to call some script functions from withing the browser. Changing this would allow to create even more powerful script that could leverage the best of both world: great UI created with HTML/JS/CSS, and ability to work (query/edit) the model.

It seems that this could be made possible by binding some Java objects to JS object inside the browser. This post explains how to do it with code samples.

This involves extending BrowserFunction.

Of course this is not as simple: this is limited in the number of types supported and this binds a Java function, not a jArchi one. Experimentation is needed...

jbsarrodie commented 5 years ago

Comment to self

A first step could be to expose the (SWT) Browser object or proxify its .evaluate() method. This would allow a jArchi script to execute code inside the browser and get the result.

jbsarrodie commented 5 years ago

For later reference

Found this other example of a nice implementation: http://ramkulkarni.com/blog/webapprunner-run-your-web-applications-standalone/