If you are looking for Jitsi Meet, the WebRTC compatible video conferencing product click here.

previous | TOC | next

UI Service Documentation

Show warning, error and other simple dialogs

Throught the UI Service any bundle is able to show simple error or warning messages, confirmation or prompt dialogs. This possibility was created in a first place to liberate developers of other bundles from writing user interface widgets for simple interactions with the user and in the second place to create a unified messaging system.

If you want to implement the UIService: 1.Implement the PopupDialog interface 2. Return an instance of it by using getPopupDialog method in the UI Service. Example: You could see the Swing UIService implementation of the PopupDialog.

How to show a simple dialog:

  1. Invoke getPopupDialog() method to obtain the PopupDialog provided by the current UI Service implementation.
  2. Invoke one of the showXXX methods of the obtained PopupDialog, depending on your needs.

There are three main types of dialogs that could be shown: Input, Message and Confirm. Each of them has several show methods corresponging, allowing additional specific configurations, like specifying the title, the initial value, button names, etc.

  • Message dialog - a dialog that shows a simple message.
    • showMessagePopupDialog(Object message)
    • showMessagePopupDialog(Object message, String title, int messageType)
  • Confirm dialog - a simple dialog that prompts the user for confirmation.
    • showConfirmPopupDialog(Object message)
    • showConfirmPopupDialog(Object message, String title, int optionType)
    • showConfirmPopupDialog(Object message, String title, int optionType, int messageType)
  • Input dialog - a simple dialog that prompts the user for input.
    • showInputPopupDialog(Object message)
    • showInputPopupDialog(Object message, String initialSelectionValue)
    • showInputPopupDialog(Object message, String title, int messageType)
    • showInputPopupDialog(Object message, String title, int messageType, Object[] electionValues, Object initialSelectionValue)

For all dialogs you are able to specify the message that would be shown to the user. In addition you could set the title ot the dialog or the message type. From the message type the ui determines what icon to use when showing the dialog. The message type could be one of the following: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, PLAIN_MESSAGE.

When showing an Input dialog you’re able to specify additional paramaters like a list of selection values and an initial value. This means you could have a dialog with a selector box. The content of the selector box will be the list of selection values you specified and the initialy selected value will be the one you passed as a parameter. The Input dialog “show” methods are the only ones that return an object. The object returned is mostly a String and represents the input of the user. In the case of a field widget this would be the text entered in the field and in case of a selector box widget it will be the value selected by the user.

The Confirm dialog allows to specify different button combinations. You could choose between three options: YES_NO_OPTION, YES_NO_CANCEL_OPTION, OK_CANCEL_OPTION. If you use for example the YES_NO_OPTION this means that your dialog will have two buttons, one of them will be labeled “Yes” and the other one “No”. The return value of all confirm dialog “show” methods is indicating what was the choice of the user. It could be one of the following: YES_OPTION, NO_OPTION, CANCEL_OPTION, OK_OPTION or CLOSED_OPTION. The last one is returned when user closes the window without choosing anything.

Example:

//Obtain the UI Service
ServiceReference uiServiceRef
    = context.getServiceReference(UIService.class.getName());
UIService uiService =
    (UIService)context.getService(uiServiceRef);

//Obtain the current UI implementation PopupDialog
PopupDialog popupDialog = uiService.getPopupDialog();

//Show an Error dialog with a title and a message.
popupDialog.showMessagePopupDialog( "This is an error message", //Message
                                    "Error", //Title
                                    PopupDialog.ERROR_MESSAGE); //Message type

...

//Show a Confirm dialog with a title, a message and an
//"OK" and "Candel" buttons.
int userChoice = popupDialog.showConfirmPopupDialog(
                                    "Your confirmation is requested.", //Message
                                    "Confirm", //Title
                                    PopupDialog.OK_CANCEL_OPTION); //Option type

if(userChoice == PopupDialog.OK_OPTION) {
    //your code when user has pressed the "OK" button
}
else {
    //your code when user has pressed "Cancel"
}

...

//Show an Input dialog that has a title, a message and a selector
//box with the specified values.
Object userInput = popupDialog.showInputPopupDialog(
                                    "Please choose from the list below.", //Message
                                    "Input dialog", //Title
                                    PopupDialog.PLAIN_MESSAGE, //Message type
                                    new Object[]{"Choice1", "Choice2", "Choice3"}, //Selector box
                                    "Choice1"); //Initial selection

previous | TOC | next