01: package fr.aliacom.form.swt.ui;
02:
03: import java.util.ArrayList;
04:
05: import org.eclipse.swt.custom.StackLayout;
06: import org.eclipse.swt.widgets.Composite;
07: import org.eclipse.swt.widgets.Control;
08:
09: import fr.aliacom.common.ui.ICard;
10: import fr.aliacom.common.ui.ICardPanel;
11:
12: /**
13: * @author tom
14: *
15: * (C) 2001, 2003 Thomas Cataldo
16: */
17: public abstract class AbstractCardPanel implements ICardPanel {
18:
19: protected Composite cardPanelWidget;
20: protected StackLayout layout;
21: protected ArrayList controls;
22: protected ArrayList names;
23:
24: public AbstractCardPanel() {
25: layout = new StackLayout();
26: controls = new ArrayList();
27: names = new ArrayList();
28: }
29:
30: public void displayFirst() {
31: setCard(names.get(0).toString());
32: }
33:
34: /**
35: * @see fr.aliacom.common.ui.ICardPanel#setCard(java.lang.String)
36: */
37: public void setCard(String card) {
38: ICard ic = (ICard) controls.get(names.indexOf(card));
39: if (!ic.isLoaded()) {
40: System.out.println("Loading card (" + card + ")...");
41: ic.load();
42: }
43: Control c = (Control) ic.getComponent().getNativeWidget();
44: layout.topControl = c;
45: cardPanelWidget.layout();
46: }
47:
48: /**
49: * @see fr.aliacom.form.common.IFormComponent#reset()
50: */
51: public void reset() {
52: }
53:
54: /**
55: * @see fr.aliacom.form.common.IFormComponent#setValueBean(java.lang.Object)
56: */
57: public void setValueBean(Object bean) {
58: }
59:
60: /**
61: * @see fr.aliacom.form.common.IFormComponent#getNativeWidget()
62: */
63: public Object getNativeWidget() {
64: return cardPanelWidget;
65: }
66:
67: public void addCard(String name, ICard card) {
68: controls.add(card);
69: names.add(name);
70: }
71:
72: /**
73: * @see fr.aliacom.common.ui.ICardPanel#getLastCard()
74: */
75: public ICard getLastCard() {
76: return (ICard) controls.get(controls.size() - 1);
77: }
78:
79: /**
80: * @see fr.aliacom.form.common.events.IGroupListener#buttonSelected(java.lang.String)
81: */
82: public void buttonSelected(String action) {
83: setCard(action);
84: }
85:
86: }
|