This repository was archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
UsingDialogs
Minkyu Lee edited this page Jan 19, 2015
·
12 revisions
In this chapter, we're going to learn how to use dialogs. StarUML provides the following Dialogs:
File Dialogs
- Open Dialog
- Save Dialog
Message Dialogs
- Error Dialog
- Alert Dialog
- Info Dialog
Input Dialogs
- Confirm Dialog
- Text Dialog
- Select Radio Dialog
- Select Dropdown Dialog
- Color Dialog
- Font Dialog
Element Dialogs
- Element Picker Dialog
- Element List Picker Dialog
- Element List Editor Dialog
Toast
- info
- warning
- error
You can use Open Dialog and Save Dialog to allow users to choose files or directories. File-related Dialogs are defined in FileSystem module. Please refer to API Docs for full specification of API.
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
}
});
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
}
});
To show message Dialogs, use Dialogs module.
var Dialogs = app.getModule('dialogs/Dialogs');
There are three types of message Dialogs to show error, alert, and info.
// Error Dialog
Dialogs.showErrorDialog("This is error message.");
// Alert Dialog
Dialogs.showAlertDialog("This is alert message.");
// Info Dialog
Dialogs.showInfoDialog("This is info message.");