001    package sale;
002    
003    import java.io.Serializable;
004    
005    /**
006     * An action that can be associated with a {@link MenuSheetItem MenuSheetItem} or
007     * {@link FormSheet.FormButton FormSheet button}.
008     *
009     * <p>Actions are triggered when there associated control is clicked. They can run in
010     * the context of a {@link Shop}, possibly a {@link SalesPoint}, and also maybe a {@link SaleProcess}.</p>
011     *
012     * @author Steffen Zschaler
013     * @version 2.0 21/05/1999
014     * @since v2.0
015     */
016    public interface Action extends Serializable {
017    
018        /**
019         * Perform the actual action.
020         *
021         * <p>The parameters define the context in which the action is performed:</p>
022         *
023         * <ol>
024         *   <li>It will always be performed in the context of the Shop. The Shop can be
025         *       retrieved via {@link sale.Shop#getTheShop Shop.getTheShop()}.</li>
026         *   <li>If <code>sp != null</code>, <code>sp</code> will define the SalesPoint
027         *       that is the context of this action.</li>
028         *   <li>If <code>p != null</code>, <code>p</code> will define the SaleProcess
029         *       that is the context of this action.</li>
030         * </ol>
031         *
032         * <p>Note, that virtually any combination of the parameters makes sense.</p>
033         *
034         * @override Always
035         *
036         * @param p the SaleProcess context of the action.
037         * @param sp the SalesPoint context of the action.
038         *
039         * @exception Throwable on any error that shall be reported and lead to cancellation of
040         * the action.
041         */
042        public void doAction(SaleProcess p, SalesPoint sp) throws Throwable;
043    
044    }