1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.tapfx.components.machobar;
17
18 import org.apache.hivemind.ApplicationRuntimeException;
19 import org.apache.tapestry.IRequestCycle;
20 import org.apache.tapestry.IAsset;
21
22 import net.sf.tapfx.components.TapFXBaseComponent;
23
24 /***
25 * @author Andreas Andreou
26 * @version $Id: MachoItem.java,v 1.3 2005/11/07 03:27:15 andyhot Exp $
27 */
28 public abstract class MachoItem extends TapFXBaseComponent
29 {
30 private int index;
31 private int size;
32 private String prefix;
33
34 public int getIndex()
35 {
36 return index;
37 }
38
39 public String getPrefix()
40 {
41 return prefix;
42 }
43
44 public int getSize()
45 {
46 return size;
47 }
48
49 public abstract IAsset getIcon();
50 public abstract IAsset getLargeIcon();
51
52 protected void setupComponent(IRequestCycle cycle)
53 {
54 MachoBar bar = MachoBar.getMachoBar(cycle);
55 if (null == bar)
56 {
57 throw new ApplicationRuntimeException("You need to provide a @MachoBar around this component!");
58 }
59 prefix = bar.getIdPrefix();
60 size = bar.getSize();
61
62 String imageURL = getIcon().buildURL(cycle);
63 bar.addAssetUrl(imageURL);
64
65
66 if (getLargeIcon() != null)
67 {
68 imageURL = getLargeIcon().buildURL(cycle);
69 }
70 bar.addLargeAssetUrl(imageURL);
71
72 index = bar.getItemsCount();
73 }
74 }