Package overit.geocall.ui
Class Alert
java.lang.Object
overit.geocall.ui.Alert
- All Implemented Interfaces:
SingleUseComponent
The class implements the user interface element that should be used to display on-screen messages that appear in popups
and blocks the user interaction; they can be informational messages, question, warnings or error messages. The user must interact with
the alert, even just by closing it, in order to proceed with the operation.
In addition to the message, the alert can contain buttons and radio params that allows the user to make a choice from a list of possibilities.
The class implements the
In addition to the message, the alert can contain buttons and radio params that allows the user to make a choice from a list of possibilities.
The class implements the
SingleUseComponent interface.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe class implements a clickable button that can be added to the alertstatic classThe class implements one choice that can be added to the alert to create a multiple choice -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayList<Alert.Button> protected intprotected intprotected Stringprotected Object[]protected Mapprotected ArrayList<Alert.RadioParam> protected static AtomicLongprotected Stringprotected Stringstatic final intDefines an alert that contains an error message; in the body of the alert will appears an error icon.static final intDefines an alert that contains an informational message; in the body of the alert will appears a info icon.static final intDefines a generic alert; no icons will appears in the body of the alert.static final intDefines an alert that contains a question message; in the body of the alert will appears a question icon.static final intDefines an alert that contains a warning message; in the body of the alert will appears a warning icon. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an alert of the type passed as parameter with the specific title and messageCreates an alert of the type passed as parameter with empty title and messagesCreates an error alert starting from an exceptionAlert(String title, DAValidateException e, Teacher teacher) Creates a warning alert strating from aDAValidateExceptionCreates an error alert with empty title and message -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Alert.Button button) Adds aAlert.Buttonto the bottom of the alertvoidadd(Alert.RadioParam radio) Adds aAlert.RadioParamto the body of the alertvoidAdds a clickable button (Alert.Button) to the bottom of the alertvoidaddButton(String label, String icon, String event, String id, String param, String msg, String prompt) Adds a clickable button (Alert.Button) to the bottom of the alertvoidaddRadioParam(String label, String param, boolean def) Adds a radio param (Alert.RadioParam) to the body of the alert.voidEvery component can add a script to the StringBuilder, script executed when the component is created The method add the script that manage the creation and showing of the alertintReturns the alert's typeReturns the list ofAlert.Buttonof the alertprotected org.apache.ecs.Elementorg.apache.ecs.ElementReturns the html code of the alertstatic IconHDgetIcon(int type) Returns the theme-dependent icon associated to the alert typeReturns the alert's messageReturns theTeacher, the object that manages the translationsgetTitle()Returns the alert's titleprotected org.apache.ecs.ElementgetTitleBar(String title, Window w) voidsetAlertType(int type) Sets the type of the alertprotected voidsetAltAttribute(Icon icon, int type) voidsetCloseEvent(String eventId) Sets an event to be triggered if the popup is closedvoidsetCloseEventParam(String param) Sets additional parameters for the event triggered when the popup is closedvoidsetDefaultButton(int def) Sets wich one must be the default button for the alertvoidsetMessage(String message) Sets the message of the alert, the string that appears in the alert's bodyvoidsetMessage(String message, Object... oo) Sets the message (seeTextFormat) of the alert and the objects that will be used to fill in the messagevoidsetMessage(String message, Map params) Sets the message (seeMapFormat) of the alert and the map that will be used to fill in the messagevoidSets the title of the alert, the string that appears in the alert's header
-
Field Details
-
_sequence
-
_id
-
NONE
public static final int NONEDefines a generic alert; no icons will appears in the body of the alert.- See Also:
-
ERROR
public static final int ERRORDefines an alert that contains an error message; in the body of the alert will appears an error icon.- See Also:
-
WARNING
public static final int WARNINGDefines an alert that contains a warning message; in the body of the alert will appears a warning icon.- See Also:
-
MESSAGE
public static final int MESSAGEDefines an alert that contains an informational message; in the body of the alert will appears a info icon.- See Also:
-
QUESTION
public static final int QUESTIONDefines an alert that contains a question message; in the body of the alert will appears a question icon.- See Also:
-
_iAlertType
protected int _iAlertType -
_sTitle
-
_sMessage
-
_objects
-
_params
-
_buttons
-
_defaultButton
protected int _defaultButton -
_radios
-
-
Constructor Details
-
Alert
Creates an error alert with empty title and message- Parameters:
teacher- The component that manage the translations (seeTeacher)
-
Alert
Creates an alert of the type passed as parameter with empty title and messages -
Alert
Creates an alert of the type passed as parameter with the specific title and message -
Alert
Creates an error alert starting from an exception- Parameters:
title- The string that appears in the header of the alerte- The exception of which we want to show the messageteacher- The component that manage the translations (seeTeacher)
-
Alert
Creates a warning alert strating from aDAValidateException- Parameters:
title- The string that appears in the header of the alerte- TheDAValidateExceptionof which we want to show the messageteacher- The component that manage the translations (seeTeacher)
-
-
Method Details
-
getTeacher
Returns theTeacher, the object that manages the translations- Returns:
- The
Teacherthat manages the translations
-
setAlertType
public void setAlertType(int type) Sets the type of the alert -
setTitle
Sets the title of the alert, the string that appears in the alert's header- Parameters:
message- The title that appears in the header
-
setMessage
Sets the message of the alert, the string that appears in the alert's body- Parameters:
message- The message that appears in the body
-
setMessage
Sets the message (seeTextFormat) of the alert and the objects that will be used to fill in the message- Parameters:
message- The message that appears in the bodyoo- The objects that will be used to fill in the message
-
setMessage
Sets the message (seeMapFormat) of the alert and the map that will be used to fill in the message- Parameters:
message- The message that appears in the bodyparams- The map that will be used to fill in the message
-
setCloseEvent
Sets an event to be triggered if the popup is closed- Parameters:
eventId- The event triggered when the user clicks on the button
-
setCloseEventParam
Sets additional parameters for the event triggered when the popup is closed- Parameters:
param- The parameter passed to the event triggered when the user clicks the button
-
getAlertType
public int getAlertType()Returns the alert's type -
getTitle
Returns the alert's title- Returns:
- The string that represents the alert title
-
getMessage
Returns the alert's message- Returns:
- The string that represents the alert message
-
setDefaultButton
public void setDefaultButton(int def) Sets wich one must be the default button for the alert- Parameters:
def- The integer that defines the position (from left to right) of the button that must be the default one
-
addButton
Adds a clickable button (Alert.Button) to the bottom of the alert- Parameters:
label- The label that appears on the buttonicon- The icon that appears on the buttonevent- The event triggered when the user clicks on the buttonid- The target for the event
-
addButton
public void addButton(String label, String icon, String event, String id, String param, String msg, String prompt) Adds a clickable button (Alert.Button) to the bottom of the alert- Parameters:
label- The label that appears on the buttonicon- The icon that appears on the buttonevent- The event triggered when the user clicks on the buttonid- The target for the eventparam- The parameter passed to the event triggered when the user clicks the buttonmsg- The string that appears as a message when the user clicks the buttonprompt- The string that appears as a prompt when the user clicks the button
-
addRadioParam
Adds a radio param (Alert.RadioParam) to the body of the alert. Use this method to add multiple choices selectable with a single button, and prevent a large number of buttons.- Parameters:
label- The label string associated to the chioceparam- The parameter associated to the chioce, passed to the event of the button of the alertdef- true if this one must be the default selected choice when the alert appears, false otherwise
-
add
Adds aAlert.Buttonto the bottom of the alert- Parameters:
button- The button to add to the alert
-
add
Adds aAlert.RadioParamto the body of the alert- Parameters:
radio- The radio param to add to the alert
-
getButtons
Returns the list ofAlert.Buttonof the alert- Returns:
- The list of buttons
-
getHtml
Returns the html code of the alert- Specified by:
getHtmlin interfaceSingleUseComponent- Parameters:
es- the page entity setw- the window onto expose the alert- Returns:
- The html code of the alert
-
getIcon
Returns the theme-dependent icon associated to the alert type -
setAltAttribute
-
getTitleBar
-
buildSetupScript
Every component can add a script to the StringBuilder, script executed when the component is created The method add the script that manage the creation and showing of the alert- Specified by:
buildSetupScriptin interfaceSingleUseComponent- Parameters:
sb- The StringBuilder on which we want to add the script
-