001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.impl.comp.html;
015:
016: import org.itsnat.comp.html.ItsNatHTMLAnchor;
017: import org.itsnat.comp.ui.ItsNatButtonUI;
018: import org.itsnat.comp.ui.ItsNatComponentUI;
019: import org.itsnat.impl.comp.ItsNatButtonBasedSharedImpl;
020: import org.itsnat.impl.comp.html.ui.ItsNatHTMLAnchorUIImpl;
021: import javax.swing.ButtonModel;
022: import javax.swing.DefaultButtonModel;
023: import javax.swing.event.ChangeEvent;
024: import org.itsnat.core.event.ParamTransport;
025: import org.itsnat.core.NameValue;
026: import org.itsnat.impl.comp.ItsNatButtonInternal;
027: import org.itsnat.impl.core.html.ItsNatHTMLDocumentImpl;
028: import org.w3c.dom.Node;
029: import org.w3c.dom.events.Event;
030: import org.w3c.dom.html.HTMLAnchorElement;
031:
032: /**
033: *
034: * @author jmarranz
035: */
036: public abstract class ItsNatHTMLAnchorImpl extends
037: ItsNatHTMLElementComponentImpl implements ItsNatHTMLAnchor,
038: ItsNatButtonInternal {
039:
040: /** Creates a new instance of ItsNatHTMLAnchorImpl */
041: public ItsNatHTMLAnchorImpl(HTMLAnchorElement element,
042: NameValue[] artifacts,
043: ItsNatHTMLComponentManagerImpl componentMgr) {
044: super (element, artifacts, componentMgr);
045: }
046:
047: public void enableEventListeners() {
048: enableEventListener("click"); // Por defecto se procesa, pues es lo importante
049: }
050:
051: public HTMLAnchorElement getHTMLAnchorElement() {
052: return (HTMLAnchorElement) getHTMLElement();
053: }
054:
055: public ItsNatButtonUI createDefaultItsNatHTMLAnchorUI() {
056: return new ItsNatHTMLAnchorUIImpl(this );
057: }
058:
059: public ItsNatComponentUI createDefaultItsNatComponentUI() {
060: return createDefaultItsNatHTMLAnchorUI();
061: }
062:
063: public void bindDataModel() {
064: ItsNatButtonBasedSharedImpl.bindDataModel(this );
065: }
066:
067: public void unbindDataModel() {
068: ItsNatButtonBasedSharedImpl.unbindDataModel(this );
069: }
070:
071: public void syncUIWithDataModel() {
072: ItsNatButtonBasedSharedImpl.syncUIWithDataModel(this );
073: }
074:
075: public void stateChanged(ChangeEvent e) {
076: ItsNatButtonBasedSharedImpl.stateChanged(this , e);
077: }
078:
079: public ButtonModel getButtonModel() {
080: return (ButtonModel) dataModel;
081: }
082:
083: public void setButtonModel(ButtonModel dataModel) {
084: setDataModel(dataModel);
085: }
086:
087: public boolean isEnabled() {
088: // Está propiedad está en el modelo no sólo en el DOM
089: // el modelo modifica el DOM via listeners pues es el modelo el que manda
090: return getButtonModel().isEnabled();
091: }
092:
093: public void setEnabled(boolean b) {
094: // Está propiedad está en el modelo no sólo en el DOM
095: // el modelo modificará el DOM via listeners pues es el modelo el que manda
096: getButtonModel().setEnabled(b);
097: }
098:
099: public void processDOMEvent(Event evt) {
100: if (!ItsNatButtonBasedSharedImpl.handleEvent(getButtonModel(),
101: evt))
102: return;
103:
104: super .processDOMEvent(evt);
105: }
106:
107: public void blur() {
108: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
109: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
110: getHTMLElement(), "blur", new Object[0], true);
111: }
112:
113: public void focus() {
114: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
115: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
116: getHTMLElement(), "focus", new Object[0], true);
117: }
118:
119: public Object createDefaultModelInternal() {
120: return createDefaultButtonModel();
121: }
122:
123: public ButtonModel createDefaultButtonModel() {
124: return new DefaultButtonModel();
125: }
126:
127: public ItsNatButtonUI getItsNatButtonUI() {
128: return (ItsNatButtonUI) compUI;
129: }
130:
131: protected ParamTransport[] getParamTransports(String type) {
132: return null;
133: }
134:
135: public Node createDefaultNode() {
136: return (HTMLAnchorElement) getItsNatDocument().getDocument()
137: .createElement("a");
138: }
139:
140: }
|