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.html;
15:
16: import org.itsnat.comp.html.ItsNatHTMLComponentManager;
17: import org.itsnat.comp.html.ItsNatHTMLFormComponent;
18: import org.itsnat.comp.html.ItsNatHTMLLabel;
19: import org.itsnat.comp.html.ui.ItsNatHTMLElementComponentUI;
20: import org.itsnat.core.html.ItsNatHTMLDocument;
21: import org.itsnat.core.NameValue;
22: import org.itsnat.impl.comp.ItsNatLabelImpl;
23: import org.w3c.dom.Node;
24: import org.w3c.dom.html.HTMLElement;
25: import org.w3c.dom.html.HTMLLabelElement;
26:
27: /**
28: * Nota por si se aplican futuros usos: El accesskey se accede via ALT-letra
29: * en MSIE y Firefox <2, en el FireFox >= 2 ha cambiado a SHIFT-ALT-letra
30: * para que no interfiera con la funcionalidad normal de los menues del navegador.
31: * Cuando se usa un accesskey FireFox (v2 al menos) envía un evento click al label.
32: *
33: * http://juicystudio.com/article/numeric-accesskeys-fixed-firefox.php
34: *
35: * @author jmarranz
36: */
37: public class ItsNatHTMLLabelImpl extends ItsNatLabelImpl implements
38: ItsNatHTMLLabel {
39: /**
40: * Creates a new instance of ItsNatHTMLLabelImpl
41: */
42: public ItsNatHTMLLabelImpl(HTMLLabelElement element,
43: NameValue[] artifacts,
44: ItsNatHTMLComponentManagerImpl componentMgr) {
45: super (element, artifacts, componentMgr);
46:
47: setItsNatLabelEditor(null); // No hace falta, pero para que quede claro que no son editables por defecto porque suelen estar asociados a controles de formulario que son los que se "editan"
48:
49: init();
50: }
51:
52: public HTMLLabelElement getHTMLLabelElement() {
53: return (HTMLLabelElement) getNode();
54: }
55:
56: public ItsNatHTMLFormComponent getForComponent() {
57: HTMLLabelElement element = getHTMLLabelElement();
58: String compId = element.getHtmlFor();
59: return (ItsNatHTMLFormComponent) componentMgr
60: .findItsNatComponentById(compId);
61: }
62:
63: public HTMLElement getHTMLElement() {
64: return getHTMLLabelElement();
65: }
66:
67: public ItsNatHTMLDocument getItsNatHTMLDocument() {
68: return getItsNatHTMLComponentManager().getItsNatHTMLDocument();
69: }
70:
71: public ItsNatHTMLElementComponentUI getItsNatHTMLElementComponentUI() {
72: return (ItsNatHTMLElementComponentUI) compUI;
73: }
74:
75: public ItsNatHTMLComponentManager getItsNatHTMLComponentManager() {
76: return (ItsNatHTMLComponentManager) componentMgr;
77: }
78:
79: public Node createDefaultNode() {
80: return (HTMLLabelElement) getItsNatDocument().getDocument()
81: .createElement("label");
82: }
83: }
|