archimatetool / archi-scripting-plugin

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

Feature request: Add window.promptSelection to Init.js #112

Closed ThomasRohde closed 1 year ago

ThomasRohde commented 1 year ago

I suggest to add a selection prompt to Init.js, prompting the user to select from a list of given string options. Suggested implementation in Init.js:

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();
    result = dialog.getResult();
    if (result) return new String(result);
    else return null;
}
Phillipus commented 1 year ago

Sure I could add it, or you could submit a Pull Request if you prefer?

ThomasRohde commented 1 year ago

Please do. I'm not familiar with the process :-)

Phillipus commented 1 year ago

OK, I added it with a small modification to return the first element.