SOURCECODE |
How to... change SalesPoint´s quit behavior
Description:
A SalesPoint quit´s with a MsgForm, asking "Are you sure, you want to close this SalesPoint? YES/NO".
If you want to change this behavior, overwrite protected boolean onCanQuit()
method.
(See also: HowTo..incorporate a SalesPoint )
ToDo's:
- Select the SalesPoint, whose Quit Behavior is to be altered.
- Overwrite
protected boolean onCanQuit()
method to change Quit Behavior.
Uses:
SalesPoint
1
// Main Class
public class VideoCounter extends SalesPoint
{
2
// Method is called, when SalesPoint is to be closed
// Overwrite it, if you don´t like to be asked if you were sure to quit
protected boolean onCanQuit()
{
JDisplayDialog jddConfirmer = new JDisplayDialog();
final boolean[] abResult = {true};
final sale.stdforms.MsgForm mf = new sale.stdforms.MsgForm ("Closing \"" + getName() + "\"",
"Are you sure, you want to close this SalesPoint?");
mf.removeAllButtons();
mf.addButton ("Yes", 0,
new sale.Action() {
public void doAction (SaleProcess p, SalesPoint sp) {
mf.close();
}
});
mf.addButton ("No", 1,
new sale.Action() {
public void doAction (SaleProcess p, SalesPoint sp) {
abResult[0] = false;
mf.close();
}
});
jddConfirmer.setVisible (true);
try {
jddConfirmer.setFormSheet (mf);
}
catch (InterruptedException ie) {
return false;
}
return abResult[0];
}
}