01: package net.ar.webonswing.petstore;
02:
03: import javax.swing.*;
04:
05: import net.ar.webonswing.petstore.actions.*;
06: import net.ar.webonswing.petstore.model.*;
07:
08: public class Checkout extends ApplicationFrame {
09: public Checkout() {
10: init();
11: }
12:
13: protected JComponent getBody() {
14: Customer customer = getCurrentCustomer();
15: JPanel panel = new JPanel();
16:
17: if (customer != null) {
18: AddressView addressView = new AddressView(customer
19: .getAddress(), false);
20: CreditCardView creditCardView = new CreditCardView(customer
21: .getCreditCard(), false);
22: CartView cartView = new CartView(getCart());
23: JButton submitButton = new JButton("submit");
24: submitButton.addActionListener(new CheckOutAction(this ));
25:
26: panel.add(addressView).setName("address");
27: panel.add(creditCardView).setName("creditCard");
28: panel.add(cartView).setName("cart");
29: panel.add(submitButton).setName("submitButton");
30:
31: addressView.setLayout(ApplicationFrame.getCurrentSkin()
32: .getCurrentPropagateTemplateFor(
33: "CustomerView.address"));
34: creditCardView.setLayout(ApplicationFrame.getCurrentSkin()
35: .getCurrentPropagateTemplateFor(
36: "CustomerView.creditCard"));
37:
38: panel.setLayout(ApplicationFrame.getCurrentSkin()
39: .getCurrentPropagateTemplateFor("Checkout.main"));
40: } else {
41: panel.add(new JLabel("Error")).setName("title");
42: panel
43: .add(
44: new JLabel(
45: "Cannot make the checkout, you have to sign in first!"))
46: .setName("message");
47: panel.setLayout(ApplicationFrame.getCurrentSkin()
48: .getCurrentPropagateTemplateFor("Message.main"));
49: }
50:
51: return panel;
52: }
53: }
|