01: /* Progressmeter.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Mon Aug 14 16:38:24 2006, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zul;
20:
21: import org.zkoss.xml.HTMLs;
22:
23: import org.zkoss.zk.ui.UiException;
24: import org.zkoss.zul.impl.XulElement;
25:
26: /**
27: * A progress meter is a bar that indicates how much of a task has been completed.
28: *
29: * <p>Default {@link #getSclass}: progressmeter.
30: *
31: * @author tomyeh
32: */
33: public class Progressmeter extends XulElement {
34: private int _val;
35:
36: public Progressmeter() {
37: setSclass("progressmeter");
38: setWidth("100px");
39: }
40:
41: public Progressmeter(int value) {
42: this ();
43: setValue(value);
44: }
45:
46: /** Sets the current value of the progress meter.
47: * <p>Range: 0~100.
48: */
49: public void setValue(int value) {
50: if (value < 0 || value > 100)
51: throw new UiException("Illegal value: " + value
52: + ". Range: 0 ~ 100");
53: if (_val != value) {
54: _val = value;
55: smartUpdate("z.value", _val);
56: }
57: }
58:
59: /** Returns the current value of the progress meter.
60: */
61: public int getValue() {
62: return _val;
63: }
64:
65: /** Returns the style class of the SPAN tag that representing
66: * the progress status.
67: *
68: * <p>It is equivalent to "pmc-img", where pmc is assumed to be
69: * the return value of {@link #getSclass}.
70: * If {@link #getSclass} returns null, "progressmeter-img" is assumed.
71: *
72: * @since 3.0.1
73: */
74: public String getIconSclass() {
75: final String scls = getSclass();
76: return scls != null && scls.length() > 0 ? scls + "-img"
77: : "progressmeter-img";
78: }
79:
80: //-- super --//
81: public String getOuterAttrs() {
82: final StringBuffer sb = new StringBuffer(64).append(super
83: .getOuterAttrs());
84: HTMLs.appendAttribute(sb, "z.value", _val);
85: return sb.toString();
86: }
87:
88: //-- Component --//
89: public boolean isChildable() {
90: return false;
91: }
92: }
|