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());
dialog.setElements(choices);
dialog.setTitle(title);
dialog.open();
return dialog.getResult();
}
// Test it
let answer = window.promptSelection("Is everything OK?", ["Yes", "Maybe", "No"]);
console.log(answer);
Maybe this could be added to init.js?
Change the return statement to return a proper Javascript string:
return new String(dialog.getResult());
Hi,
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 (https://github.com/archimatetool/archi-scripting-plugin/issues).
Regards,
JB