01: package net.ar.webonswing.petstore.actions;
02:
03: import java.awt.event.*;
04: import java.util.*;
05:
06: import javax.swing.*;
07:
08: import net.ar.webonswing.*;
09: import net.ar.webonswing.petstore.*;
10: import net.ar.webonswing.petstore.model.*;
11: import net.sf.hibernate.*;
12:
13: public final class CheckOutAction implements ActionListener {
14: private ApplicationFrame frame;
15:
16: public CheckOutAction(ApplicationFrame aFrame) {
17: frame = aFrame;
18: }
19:
20: public void actionPerformed(ActionEvent aE) {
21: Transaction transaction = null;
22:
23: final Order order = new Order(frame.getCurrentCustomer());
24: Cart cart = frame.getCart();
25:
26: for (Iterator i = cart.getCartItems().iterator(); i.hasNext();) {
27: CartItem cartItem = (CartItem) i.next();
28: order.add(cartItem.getItem(), cartItem.getQuantity());
29: }
30:
31: frame.getDao().saveOrUpdate(order);
32:
33: cart.clear();
34:
35: JDialog confirmation = new Confirmation(order);
36: WosFramework.showChildWindow(frame, confirmation);
37: }
38: }
|