Skip to content
This repository was archived by the owner on Jun 2, 2022. It is now read-only.

UsingDialogs

Minkyu Lee edited this page Jan 19, 2015 · 12 revisions

Using Dialogs

In this chapter, we're going to learn how to use dialogs. StarUML provides the following Dialogs:

File-related Dialogs

  • Open Dialog
  • Save Dialog

Message-related Dialogs

  • Error Dialog
  • Alert Dialog
  • Info Dialog
  • Simple Dialog
  • Toast

Input-related Dialogs

  • Text Dialog
  • Select Radio Dialog
  • Select Dropdown Dialog
  • Color Dialog
  • Font Dialog

Element-related Dialogs

  • Element Picker Dialog
  • Element List Picker Dialog
  • Element List Editor Dialog

File-related Dialogs

You can use Open Dialog and Save Dialog to allow users to choose files or directories. To show the Dialogs, use FileSystem module. Please refer to API Docs for full specification of API.

Open Dialog

Following is an example of Open Dialog for choosing a text *.txt file.

var FileSystem = require("filesystem/FileSystem");

FileSystem.showOpenDialog(false, false, "Select a text file...", null, ["txt"], function (err, files) {
    if (!err) {
        if (files.length > 0) {
            // User selected one or more files
        } else {
            // User canceled
        }
    } else {
        // Handle error
    }
});

Save Dialog

Following is an example of Save Dialog for getting a file name.

var FileSystem = require("filesystem/FileSystem");

FileSystem.showSaveDialog("Save text as...", null, "Untitled.txt", function (err, filename) {
    if (!err) {
        if (filename) {
            // User selected a file name
        } else {
            // User canceled
        }
    } else {
        // Handle error
    }
});
Clone this wiki locally