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.stdforms.SingleTableFormSheet; 014 015 /** 016 * <code>ContentCreator</code> which changes the existing <code>FormSheet</code> 017 * to an addidtional table with the change money and some additional labels 018 * @author Tobias Ruch 019 */ 020 public class RentConfirmFSContentCreator extends FormSheetContentCreator { 021 022 /** 023 * ID for Serialization. 024 */ 025 private static final long serialVersionUID = 928189229586346904L; 026 027 /** Sales Proecess in which the content creator is used */ 028 private SaleProcessRent processRent; 029 /** <code>UIGate</code> of the FormSheet for the secound FormSheet */ 030 private UIGate gate; 031 032 /** 033 * Constructs a new <code>RentConfirmFSContentCreator</code>. 034 * @param process - <code>SaleProcessRent</code> in which the content creator is used. 035 * @param gate - <code>UIGate</code> for the additional <code>SingleTableFormSheet</code> 036 */ 037 public RentConfirmFSContentCreator(SaleProcessRent process, UIGate gate){ 038 this.processRent = process; 039 this.gate = gate; 040 } 041 /** 042 * Creates additional content to the given FormSheet. 043 * Creates another table, some labels and the commit action to the ok button. 044 * @param fs - FormSheet which should be changed 045 */ 046 protected void createFormSheetContent(FormSheet fs) { 047 SingleTableFormSheet stfs_money = 048 SingleTableFormSheet.create("", processRent.getTemporaryMoneyBag(), gate, processRent.getBasket()); 049 050 JComponent jc = new JPanel(); 051 jc.setLayout(new BoxLayout(jc, BoxLayout.Y_AXIS)); 052 jc.add(new JLabel("All your rented videos:")); 053 jc.add(fs.getComponent()); 054 jc.add(new JLabel("The money you`ll get back:")); 055 jc.add(stfs_money.getComponent()); 056 jc.add(new JLabel("Please, click Ok to confirm the transaction!")); 057 fs.setComponent(jc); 058 fs.removeButton(FormSheet.BTNID_CANCEL); 059 060 fs.getButton(FormSheet.BTNID_OK).setAction(new CommitAction()); 061 062 } 063 064 }