Proof-of-concept: Bi-directional integration of a browser editor/window

Started by Thomas Rohde, November 29, 2022, 13:36:18 PM

Previous topic - Next topic

Thomas Rohde

I created a quick proof-of-concept for how to integrate a browser application into Archi. The gist 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

Jean-Baptiste Sarrodie

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
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

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.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Thomas Rohde


Jean-Baptiste Sarrodie

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
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Thomas Rohde


Thomas Rohde

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

Jean-Baptiste Sarrodie

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
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

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.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

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
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

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...  ;)
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

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... ;-)
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.