Get user input with macro

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Get user input with macro

Postby RSB » Fri Jan 20, 2023 6:04 pm

Is there a way to request user input in a macro? Like if the macro is creating something it can ask the user what package it should be placed in or what to name it?
RSB
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Fri Jan 20, 2023 1:18 pm

Re: Get user input with macro

Postby buddy.robbins@linquest.com » Wed Jan 25, 2023 4:33 pm

Depending on what input you want, there's different solutions.
For, say, selecting a package where a new element will be created, you'd use the ElementSelectionDlgFactory.create.

Code: Select all
var dlg = ElementSelectionDlgFactory.create(MDDialogParentProvider.getProvider().getDialogOwner());
var selectable = new ArrayList();
selectable.add(Package); //Only allowing selection of packages
var  types = new SelectElementTypes(null, selectable);
ElementSelectionDlgFactory.initSingle(dlg, types, new SelectElementInfo(false, false), null);
if( null != dlg){
    dlg.setVisible(true);
    if (dlg.isOkClicked()){
        result = dlg.getSelectedElement();               
    }         
}
buddy.robbins@linquest.com
Forum Newbie
Forum Newbie
 
Posts: 7
Posts Rating:0
Joined: Fri Jul 23, 2021 11:14 am

Re: Get user input with macro

Postby RSB » Fri Jan 27, 2023 5:44 pm

Perfect! Thank you, that solves one of my problems and I have some leads to try for other things now.

I haven't gotten the filter to only allow selection of Packages to work correctly, but I haven't spent much time trying to debug that. I probably am simply missing an include and will get that sorted out once I get a chance to dive into it again.
RSB
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Fri Jan 20, 2023 1:18 pm


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest