001 package videoautomat.contentcreator;
002
003 import javax.swing.BoxLayout;
004 import javax.swing.JComponent;
005 import javax.swing.JLabel;
006 import javax.swing.JPanel;
007
008 import sale.FormSheet;
009 import sale.FormSheetContentCreator;
010 import sale.UIGate;
011 import videoautomat.SaleProcessRent;
012 import videoautomat.contentcreator.stdactions.CommitAction;
013 import data.MoneyBag;
014 import data.stdforms.SingleTableFormSheet;
015
016 /**
017 * <code>ContentCreator</code> which changes the existing <code>FormSheet</code>
018 * to an addidtional table with the change money and some additional labels
019 * @author Tobias Ruch
020 */
021 public class RentConfirmFSContentCreator extends FormSheetContentCreator {
022
023 /** Sales Proecess in which the content creator is used */
024 private SaleProcessRent processRent;
025 /** <code>UIGate</code> of the FormSheet for the secound FormSheet */
026 private UIGate gate;
027
028 /**
029 * Constructs a new <code>RentConfirmFSContentCreator</code>.
030 * @param process - <code>SaleProcessRent</code> in which the content creator is used.
031 * @param gate - <code>UIGate</code> for the additional <code>SingleTableFormSheet</code>
032 */
033 public RentConfirmFSContentCreator(SaleProcessRent process, UIGate gate){
034 this.processRent = process;
035 this.gate = gate;
036 }
037 /**
038 * Creates additional content to the given FormSheet.
039 * Creates another table, some labels and the commit action to the ok button.
040 * @param fs - FormSheet which should be changed
041 */
042 protected void createFormSheetContent(FormSheet fs) {
043 SingleTableFormSheet stfs_money =
044 SingleTableFormSheet.create("", (MoneyBag)processRent.getContext().getProcessData(SaleProcessRent.MB_TEMP_KEY), gate, processRent.getBasket());
045
046 JComponent jc = new JPanel();
047 jc.setLayout(new BoxLayout(jc, BoxLayout.Y_AXIS));
048 jc.add(new JLabel("All your rented videos:"));
049 jc.add(fs.getComponent());
050 jc.add(new JLabel("The money you`ll get back:"));
051 jc.add(stfs_money.getComponent());
052 jc.add(new JLabel("Please, click Ok to confirm the transaction!"));
053 fs.setComponent(jc);
054 fs.removeButton(FormSheet.BTNID_CANCEL);
055
056 fs.getButton(FormSheet.BTNID_OK).setAction(new CommitAction());
057
058 }
059
060 }