01: package fr.aliacom.form.swt.ui;
02:
03: import org.eclipse.swt.SWT;
04: import org.eclipse.swt.layout.GridData;
05: import org.eclipse.swt.layout.GridLayout;
06: import org.eclipse.swt.widgets.Composite;
07: import org.eclipse.swt.widgets.ProgressBar;
08:
09: import fr.aliacom.common.ui.IProgressHandler;
10:
11: /**
12: * @author tom
13: *
14: * (C) 2001, 2003 Thomas Cataldo
15: */
16: public final class SWTProgressHandler implements IProgressHandler {
17:
18: private int steps;
19: private int cur;
20: private ProgressBar bar;
21:
22: public SWTProgressHandler(Composite parent) {
23: this .steps = 0;
24: this .cur = 0;
25: this .bar = new ProgressBar(parent, SWT.SMOOTH | SWT.HORIZONTAL);
26: bar.setMinimum(0);
27:
28: /* bandaid fix */
29: if (parent.getLayout() instanceof GridLayout) {
30: GridData data = new GridData(GridData.FILL_HORIZONTAL);
31: bar.setLayoutData(data);
32: }
33: }
34:
35: /**
36: * @see fr.aliacom.common.ui.IProgressHandler#addSteps(int)
37: */
38: public void addSteps(int as) {
39: bar.setMaximum(steps + as);
40: }
41:
42: /**
43: * @see fr.aliacom.common.ui.IProgressHandler#incr()
44: */
45: public void incr() {
46: if (cur + 1 <= steps) {
47: bar.setSelection(cur + 1);
48: }
49: }
50:
51: /**
52: * @see fr.aliacom.common.ui.IProgressHandler#incr(java.lang.String)
53: */
54: public void incr(String label) {
55: incr();
56: }
57:
58: /**
59: * @see fr.aliacom.form.common.IFormComponent#reset()
60: */
61: public void reset() {
62: }
63:
64: /**
65: * @see fr.aliacom.form.common.IFormComponent#setValueBean(java.lang.Object)
66: */
67: public void setValueBean(Object bean) {
68: }
69:
70: /**
71: * @see fr.aliacom.form.common.IFormComponent#getNativeWidget()
72: */
73: public Object getNativeWidget() {
74: return bar;
75: }
76:
77: }
|