archimatetool/archi-scripting-plugin

Feature request: Add window.promptSelection to Init.js

ThomasRohde opened this issue · 3 comments

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;
}

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

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

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