001 package market.stdform;
002
003 import market.SMarket;
004 import sale.GateChangeTransition;
005 import sale.MenuSheet;
006 import sale.MenuSheetItem;
007 import sale.SaleProcess;
008 import sale.SalesPoint;
009 import sale.Transition;
010 import sale.UIGate;
011
012 /**
013 * This MenuSheet class provides a simple log-off MenuSheet.
014 */
015 public class MSLogOff extends MenuSheet{
016
017 /**
018 * ID for serialization.
019 */
020 private static final long serialVersionUID = 2099559124315233565L;
021
022 /**
023 * Creates a MenuSheet with one MenuSheetItem, which`s action closes the SalesPoint related to the MenuSheet.
024 *
025 * @param trans Transition that gets set in the MenuSheetItem`s action to the current Gate of a SaleProcess,
026 * if someone runs on the SalesPoint related to this MenuSheet.
027 */
028 public MSLogOff(final Transition trans) {
029 super("System", null, 'S');
030 this.add(new MenuSheetItem("Abmelden", "exit", new sale.Action() {
031 private static final long serialVersionUID = 708299138129393449L;
032 public void doAction(SaleProcess p, SalesPoint sp) throws Throwable {
033 if(p!=null){
034 ((UIGate)p.getCurrentGate()).setNextTransition(trans);
035 }
036 if (sp != null) {//sp is only null if a JDDShowMessage is active
037 if(sp.getCurrentProcess()!=null) sp.processFinished(p);
038 SMarket.getTheMarket().removeSalesPoint(sp);
039 sp.quit();
040 }
041 }
042 }, 'A'));
043 }
044
045 /**
046 * Overloads constructor with GateChangeTransition.CHANGE_TO_STOP_GATE as argument.
047 */
048 public MSLogOff() {
049 this(GateChangeTransition.CHANGE_TO_STOP_GATE);
050 }
051 }