A simple promptSelection function

Started by Thomas Rohde, November 16, 2022, 03:56:31 AM

Previous topic - Next topic

Thomas Rohde

I sometimes need a prompt to select from a list. As it turns out this is simple:

window.promptSelection = function (title, choices) {
    var ElementListSelectionDialog = Java.type('org.eclipse.ui.dialogs.ElementListSelectionDialog');
    var LabelProvider = Java.type('org.eclipse.jface.viewers.LabelProvider');
    var dialog = new ElementListSelectionDialog(shell, new LabelProvider());

    return dialog.getResult();

// Test it
let answer = window.promptSelection("Is everything OK?", ["Yes", "Maybe", "No"]);

Maybe this could be added to init.js?

Thomas Rohde

Change the return statement to return a proper Javascript string:

return new String(dialog.getResult());

Jean-Baptiste Sarrodie


Quote from: Thomas Rohde on November 16, 2022, 03:56:31 AMMaybe this could be added to init.js?

Yes, makes sense.

Could you share the code as a Gist and open an issue on GitHub.


If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.