5.4 Browsing for Elements Function (formula.gui)

The following methods are used to browse and select elements from the Elements hierarchy. These are entry points to the BrowseForElementDialog class that enable bringing up the element dname browser.

  • formula.gui.browseForDNames(Component parent, String multiSelect)

  • formula.gui.browseForDNames(Component parent, String rootDName, String multiSelect)

  • formula.gui.browseForDNames(Component parent, String rootDName, String title, String label, String multiSelect)

Each version returns a java.util.Vector of java.lang.String for each DName selected in the browser.

Create a client operation that uses a script containing this function, such as the example shown below. Fire the operation. If you select one or more elements in the browser, the operation shows a pop-up listing the selected elements’ dnames.

The operation allows supplying a title and label prompt for the element browser. Otherwise, click OK in this initial pop‑up dialog box to use the browser defaults.

var promptDialog = formula.gui.PromptDialog(appFrame, "Test Prompt Dialog Driver", [ "Title", "Label" ], [ false, false ])

var title = null
var label = null

if ( promptDialog.process() == true )
{
  title = promptDialog.getInputText(0);

  label = promptDialog.getInputText(1);
}
var dnamesVector

if ( title != null && label != null && title.length() > 0 && label.length() > 0 )
    dnamesVector = formula.gui.browseForDNames(appFrame, "root=Elements", title, label, true)
else
    dnamesVector = formula.gui.browseForDNames(appFrame, "root=Elements", true)
if ( dnamesVector.size() > 0 )
{
   var dnames = "";
   for (var i = 0; i < dnamesVector.size(); i++)
  dnames = dnames + dnamesVector.elementAt(i) + "\n"
   info(dnames)
}