01: /*
02: #IFNDEF ALT_LICENSE
03: ThinWire(R) RIA Ajax Framework
04: Copyright (C) 2003-2007 Custom Credit Systems
05:
06: This library is free software; you can redistribute it and/or modify it under
07: the terms of the GNU Lesser General Public License as published by the Free
08: Software Foundation; either version 2.1 of the License, or (at your option) any
09: later version.
10:
11: This library is distributed in the hope that it will be useful, but WITHOUT ANY
12: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13: PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14:
15: You should have received a copy of the GNU Lesser General Public License along
16: with this library; if not, write to the Free Software Foundation, Inc., 59
17: Temple Place, Suite 330, Boston, MA 02111-1307 USA
18:
19: Users who would rather have a commercial license, warranty or support should
20: contact the following company who invented, built and supports the technology:
21:
22: Custom Credit Systems, Richardson, TX 75081, USA.
23: email: info@thinwire.com ph: +1 (888) 644-6405
24: http://www.thinwire.com
25: #ENDIF
26: [ v1.2_RC2 ]
27: */
28: package thinwire.render.web;
29:
30: import thinwire.ui.Component;
31: import thinwire.ui.RangeComponent;
32: import thinwire.ui.event.PropertyChangeEvent;
33: import thinwire.ui.style.FX;
34:
35: abstract class RangeComponentRenderer extends ComponentRenderer {
36:
37: public void render(WindowRenderer wr, Component c,
38: ComponentRenderer container) {
39: RangeComponent rc = (RangeComponent) c;
40: if (rc.getLength() == 1) {
41: addInitProperty(RangeComponent.PROPERTY_LENGTH, 2);
42: addInitProperty(RangeComponent.PROPERTY_CURRENT_INDEX, rc
43: .getCurrentIndex() + 1);
44: } else {
45: addInitProperty(RangeComponent.PROPERTY_LENGTH, rc
46: .getLength());
47: addInitProperty(RangeComponent.PROPERTY_CURRENT_INDEX, rc
48: .getCurrentIndex());
49: }
50:
51: super .render(wr, comp, container);
52: }
53:
54: public void propertyChange(PropertyChangeEvent pce) {
55: String name = pce.getPropertyName();
56: if (isPropertyChangeIgnored(name))
57: return;
58: Object newValue = pce.getNewValue();
59: RangeComponent rc = (RangeComponent) comp;
60:
61: if (name.equals(RangeComponent.PROPERTY_LENGTH)) {
62: if (rc.getLength() == 1) {
63: postClientEvent("setLength", 2);
64: postClientEvent("setCurrentIndex",
65: rc.getCurrentIndex() + 1);
66: } else {
67: postClientEvent("setLength", (Integer) newValue);
68: postClientEvent("setCurrentIndex", rc.getCurrentIndex());
69: }
70: } else if (name.equals(RangeComponent.PROPERTY_CURRENT_INDEX)) {
71: if (rc.getLength() == 1) {
72: setPropertyWithEffect(name, ((Integer) newValue + 1),
73: ((Integer) pce.getOldValue() + 1),
74: "setCurrentIndex",
75: FX.PROPERTY_FX_POSITION_CHANGE);
76: } else {
77: setPropertyWithEffect(name, (Integer) newValue,
78: (Integer) pce.getOldValue(), "setCurrentIndex",
79: FX.PROPERTY_FX_POSITION_CHANGE);
80: }
81: } else {
82: super.propertyChange(pce);
83: }
84: }
85:
86: }
|