Archi Forum

Archi Plug-ins => jArchi => Topic started by: Thomas Rohde on November 29, 2022, 13:36:18 PM

Title: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Thomas Rohde on November 29, 2022, 13:36:18 PM
I created a quick proof-of-concept for how to integrate a browser application into Archi. The gist (https://gist.github.com/ThomasRohde/8daf0a5c5814b597953983d0a549b04c) is a demo application that prompts for a RegExp search term, and displays a table in the browser of all elements with matching names. The table allows the user to edit the documentation column, and pressing "Refresh" updates the model.

With this functionality, I guess the sky is the limit for what you can do with scripting, user interfaces, and tons of browser-based Javascript libraries. At least without going deep in Eclipse/Java  8)

Browser Interaction.png
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Jean-Baptiste Sarrodie on November 29, 2022, 16:02:23 PM
Hi,

Thank you for sharing !

I've worked on similar things in the past, but my issue is that everything done in a script is (should be) undoable, so each action is recorded and reversed when using the undo function. This means, that the changes done through this browser tab can't be undo until the script is finished, so undo basically don't work here because the script never really finish.

I've also noticed another issue which is that changes are no more applied when another script has been run.

I really would like to find solutions to these issues, as one of my very first goals when we created jArchi was to enable such jArchi based "plugins" with real UI (of of my use-cases was an excel-like view on the model to quickly update some elements, or a matrix view to show/edit relationships...).

Regards,

JB
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Phil Beauvoir on November 29, 2022, 16:41:36 PM
Further to what JB has said, be aware that you can corrupt a model if the model is modified and the action is not put on the Undo/Redo stack. The next time the user applies "Undo", or makes another change, the last modification is not taken into account and so the model could lose its integrity. The safest thing to do is to close and re-open the model.
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Thomas Rohde on November 29, 2022, 16:50:07 PM
Too bad - I was so exited to get it to "work" ;)
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Jean-Baptiste Sarrodie on November 29, 2022, 17:17:09 PM
Quote from: Thomas Rohde on November 29, 2022, 16:50:07 PMI was so exited to get it to "work" ;)

Mee too. This doesn't mean the idea should be thrown away, just that we all have to think more deeply about this use-case to make it work.

Before we find what to change in jArchi to support it, a simple workaround is to open such browser not in a tab but in a modal window.

Regards,

JB
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Thomas Rohde on November 29, 2022, 17:22:52 PM
I have put a warning sticker on the gist!
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Thomas Rohde on November 30, 2022, 05:36:54 AM
Just out of curiosity, does the problems I face with my little script have something todo with multithreading in GraalJS ?

https://github.com/oracle/graaljs/blob/master/docs/user/Multithreading.md (https://github.com/oracle/graaljs/blob/master/docs/user/Multithreading.md)
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Jean-Baptiste Sarrodie on November 30, 2022, 07:21:50 AM
Quote from: Thomas Rohde on November 30, 2022, 05:36:54 AMJust out of curiosity, does the problems I face with my little script have something todo with multithreading in GraalJS ?

No, issue would be the same with Nashorn.

JB
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Phil Beauvoir on November 30, 2022, 08:26:28 AM
Because a script can consist of hundreds (or thousands) of model commands we can't put all of these commands on the Undo/Redo command stack, otherwise the user would have to click "Undo" hundreds of times to undo the script. So, when the script has finished we put one compound command consisting of the sub-commands onto the stack and "execute" it. The execution does nothing because the commands have already happened but it allows the Command stack to see that one compound command has been executed, and thus Undo and Redo can occur.

In this use case it would seem that an alternate method would be required so that each script command is actually executed on the Command stack, but that would require some more thought.
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Jean-Baptiste Sarrodie on November 30, 2022, 10:05:07 AM
Quote from: Phil Beauvoir on November 30, 2022, 08:26:28 AMIn this use case it would seem that an alternate method would be required so that each script command is actually executed on the Command stack, but that would require some more thought.

Or, have a special API method/function to force jArchi to push its compound command onto the stack (and implicitely called when a script ends), and prepare a new one at this point. This would make it possible for an interactive script to still manage chunks of behavior that can subsequently been undone. In Thomas POC, the Refresh button could then update the model and push onto the stack.

JB
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Phil Beauvoir on November 30, 2022, 10:14:41 AM
Quote from: Jean-Baptiste Sarrodie on November 30, 2022, 10:05:07 AM
Quote from: Phil Beauvoir on November 30, 2022, 08:26:28 AMIn this use case it would seem that an alternate method would be required so that each script command is actually executed on the Command stack, but that would require some more thought.

Or, have a special API method/function to force jArchi to push its compound command onto the stack (and implicitely called when a script ends), and prepare a new one at this point. This would make it possible for an interactive script to still manage chunks of behavior that can subsequently been undone. In Thomas POC, the Refresh button could then update the model and push onto the stack.

JB

Don't give me ideas...  ;)
Title: Re: Proof-of-concept: Bi-directional integration of a browser editor/window
Post by: Jean-Baptiste Sarrodie on November 30, 2022, 11:46:36 AM
Quote from: Phil Beauvoir on November 30, 2022, 10:14:41 AMDon't give me ideas...  ;)

Never my intention...

Btw, being able to disable undo (both in jArchi and Archi itself) when Archi is run headless through ACLI could make it possible to run a neverending script which acts as an (Archi) API server... ;-)