01: package net.ar.webonswing.petstore;
02:
03: import javax.swing.*;
04:
05: import net.ar.webonswing.*;
06: import net.ar.webonswing.petstore.actions.*;
07: import net.ar.webonswing.petstore.contributors.*;
08: import net.ar.webonswing.petstore.model.*;
09:
10: public class ItemView extends ApplicationFrame {
11: protected Item item;
12:
13: public ItemView() {
14: WosFramework.assignContributor(this ,
15: new HibernateObjectPersistenceContributor("item"));
16: }
17:
18: public ItemView(Item anItem) {
19: this ();
20:
21: setItem(anItem);
22: init();
23: }
24:
25: protected JComponent getBody() {
26: JLabel image = new JLabel(new ImageIcon(
27: "net/ar/webonswing/petstore/"
28: + getCurrentSkin().getImagesPath()
29: + item.getImagePath()
30: + getCurrentSkin().getDefaultImageExtension()));
31: JLabel itemId = new JLabel(item.getItemId());
32: JLabel description = new JLabel(item.getDescription());
33: JLabel listPrice = new JLabel(item.getListPrice() + "");
34: JLabel productDescription = new JLabel(item.getProduct()
35: .getDescription());
36:
37: JButton addToCartButton = new JButton("Add to cart");
38: addToCartButton.addActionListener(new AddItemToCartAction(item,
39: getCart()));
40:
41: JPanel panel = new JPanel();
42: panel.add(image).setName("image");
43: panel.add(itemId).setName("itemId");
44: panel.add(description).setName("description");
45: panel.add(productDescription).setName("productDescription");
46: panel.add(listPrice).setName("listPrice");
47: panel.add(addToCartButton).setName("addToCartButton");
48: panel.setLayout(ApplicationFrame.getCurrentSkin()
49: .getCurrentPropagateTemplateFor("ItemView.main"));
50:
51: return panel;
52: }
53:
54: public Item getItem() {
55: return item;
56: }
57:
58: public void setItem(Item anItem) {
59: this.item = anItem;
60: }
61: }
|