01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.impl.comp.ui;
15:
16: import org.itsnat.comp.ItsNatLabel;
17: import org.itsnat.comp.ItsNatLabelRenderer;
18: import org.itsnat.comp.ui.ItsNatLabelUI;
19: import org.itsnat.impl.comp.ItsNatLabelImpl;
20: import org.itsnat.impl.core.domutil.ElementLabelImpl;
21: import org.w3c.dom.Element;
22:
23: /**
24: *
25: * @author jmarranz
26: */
27: public class ItsNatLabelUIImpl extends ItsNatElementComponentUIImpl
28: implements ItsNatLabelUI {
29: protected boolean enabled = true;
30: protected ElementLabelImpl label;
31:
32: /** Creates a new instance of ItsNatLabelUIImpl */
33: public ItsNatLabelUIImpl(ItsNatLabelImpl parentComp) {
34: super (parentComp);
35:
36: this .label = getItsNatDocumentImpl()
37: .createElementLabelInternal(getElement(), true, null);
38: }
39:
40: public ItsNatLabel getItsNatLabel() {
41: return (ItsNatLabel) parentComp;
42: }
43:
44: public ItsNatLabelRenderer getItsNatLabelRenderer() {
45: return getItsNatLabel().getItsNatLabelRenderer();
46: }
47:
48: public void addLabelMarkup(Object value) {
49: label.addLabelMarkup();
50: setLabelValue(value, true);
51: }
52:
53: public void removeLabelMarkup() {
54: ItsNatLabelRenderer renderer = getItsNatLabelRenderer();
55: if (renderer != null) {
56: Element parent = label.getParentElement();
57: renderer.unrenderLabel(getItsNatLabel(), parent);
58: }
59:
60: label.removeLabelMarkup();
61: }
62:
63: public void setLabelValue(Object value) {
64: setLabelValue(value, false);
65: }
66:
67: public void setLabelValue(Object value, boolean isNew) {
68: label.prepareRendering(isNew);
69:
70: ItsNatLabelRenderer renderer = getItsNatLabelRenderer();
71: if (renderer != null) {
72: Element parent = label.getParentElement();
73: renderer
74: .renderLabel(getItsNatLabel(), value, parent, isNew);
75: }
76: }
77:
78: public boolean hasLabelMarkup() {
79: return label.hasLabelMarkup();
80: }
81:
82: public boolean isUsePatternMarkupToRender() {
83: return label.isUsePatternMarkupToRender();
84: }
85:
86: public void setUsePatternMarkupToRender(boolean value) {
87: label.setUsePatternMarkupToRender(value);
88: }
89:
90: public void setEnabled(boolean b) {
91: this .enabled = b;
92: }
93:
94: public boolean isEnabled() {
95: return enabled;
96: }
97: }
|