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.AlignTextComponent.AlignX;
31: import thinwire.ui.Component;
32: import thinwire.ui.Label;
33: import thinwire.ui.event.PropertyChangeEvent;
34:
35: /**
36: * @author Joshua J. Gertzen
37: */
38: final class LabelRenderer extends TextComponentRenderer {
39: private static final String LABEL_CLASS = "tw_Label";
40: private static final String SET_WRAP_TEXT = "setWrapText";
41:
42: void render(WindowRenderer wr, Component c,
43: ComponentRenderer container) {
44: init(LABEL_CLASS, wr, c, container);
45: Label l = (Label) c;
46: addInitProperty(Label.PROPERTY_ALIGN_X, l.getAlignX().name()
47: .toLowerCase());
48: addInitProperty(Label.PROPERTY_WRAP_TEXT, l.isWrapText());
49: super .render(wr, c, container);
50: }
51:
52: public void propertyChange(PropertyChangeEvent pce) {
53: String name = pce.getPropertyName();
54: if (isPropertyChangeIgnored(name))
55: return;
56: Object newValue = pce.getNewValue();
57:
58: if (name.equals(Label.PROPERTY_ALIGN_X)) {
59: postClientEvent(SET_ALIGN_X, ((AlignX) newValue).name()
60: .toLowerCase());
61: } else if (name.equals(Label.PROPERTY_WRAP_TEXT)) {
62: postClientEvent(SET_WRAP_TEXT, newValue);
63: } else {
64: super.propertyChange(pce);
65: }
66: }
67: }
|