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.factory;
15:
16: import org.itsnat.comp.ItsNatComponent;
17: import org.itsnat.comp.html.ItsNatHTMLElementComponent;
18: import org.itsnat.core.NameValue;
19: import org.itsnat.impl.comp.FactoryItsNatComponentImpl;
20: import org.itsnat.impl.comp.ItsNatComponentManagerImpl;
21: import org.itsnat.impl.comp.html.*;
22: import org.w3c.dom.Element;
23: import org.w3c.dom.html.HTMLElement;
24:
25: /**
26: *
27: * @author jmarranz
28: */
29: public abstract class FactoryItsNatHTMLComponentImpl extends
30: FactoryItsNatComponentImpl {
31: public FactoryItsNatHTMLComponentImpl() {
32: }
33:
34: public static String getKey(HTMLElement element) {
35: return "HTML:" + element.getTagName();
36: }
37:
38: public String getKey() {
39: return "HTML:" + getTag();
40: }
41:
42: public boolean declaredAsHTMLComponent(Element element) {
43: if (isFormControl())
44: return !ItsNatComponentManagerImpl
45: .explicitIsNotComponentAttribute(element);
46: else
47: return ItsNatComponentManagerImpl
48: .isComponentAttribute(element); // Hay que marcar porque no se aņade por defecto
49: }
50:
51: public boolean mustBeCreated(Element element,
52: boolean ignoreIsComponentAttr) {
53: if (ignoreIsComponentAttr)
54: return true; // Ignorar lo que diga el markup
55:
56: return declaredAsHTMLComponent(element);
57: }
58:
59: public ItsNatComponent createItsNatComponent(Element element,
60: String compType, NameValue[] artifacts,
61: boolean ignoreIsComponentAttr,
62: ItsNatComponentManagerImpl compMgr) {
63: if (!mustBeCreated(element, ignoreIsComponentAttr))
64: return null;
65:
66: ItsNatHTMLComponentManagerImpl htmlCompMgr = (ItsNatHTMLComponentManagerImpl) compMgr;
67: return createItsNatHTMLComponent((HTMLElement) element,
68: compType, artifacts, htmlCompMgr);
69: }
70:
71: protected abstract ItsNatHTMLElementComponent createItsNatHTMLComponent(
72: HTMLElement element, String compType,
73: NameValue[] artifacts,
74: ItsNatHTMLComponentManagerImpl compMgr);
75:
76: public abstract String getTag();
77:
78: public abstract boolean isFormControl();
79: }
|