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.ItsNatHTMLInputTextBased;
017: import org.itsnat.comp.ui.ItsNatComponentUI;
018: import org.itsnat.comp.ui.ItsNatTextComponentUI;
019: import org.itsnat.comp.ui.ItsNatTextFieldUI;
020: import org.itsnat.impl.comp.ItsNatTextBasedSharedImpl;
021: import org.itsnat.impl.comp.html.ui.ItsNatHTMLInputTextBasedUIImpl;
022: import javax.swing.event.DocumentEvent;
023: import javax.swing.text.Document;
024: import javax.swing.text.PlainDocument;
025: import org.itsnat.core.NameValue;
026: import org.itsnat.impl.comp.ItsNatTextComponentInternal;
027: import org.w3c.dom.events.Event;
028: import org.w3c.dom.html.HTMLInputElement;
029:
030: /**
031: *
032: * @author jmarranz
033: */
034: public abstract class ItsNatHTMLInputTextBasedImpl extends
035: ItsNatHTMLInputImpl implements ItsNatHTMLInputTextBased,
036: ItsNatTextComponentInternal {
037:
038: /**
039: * Creates a new instance of ItsNatHTMLInputTextBasedImpl
040: */
041: public ItsNatHTMLInputTextBasedImpl(HTMLInputElement element,
042: NameValue[] artifacts,
043: ItsNatHTMLComponentManagerImpl componentMgr) {
044: super (element, artifacts, componentMgr);
045: }
046:
047: public boolean hasDefaultBehaviorChangeEvent() {
048: return true;
049: }
050:
051: public ItsNatTextFieldUI getItsNatTextFieldUI() {
052: return (ItsNatTextFieldUI) compUI;
053: }
054:
055: public String getText() {
056: return ItsNatTextBasedSharedImpl.getText(this );
057: }
058:
059: public void setText(String t) {
060: ItsNatTextBasedSharedImpl.setText(this , t);
061: }
062:
063: public Document getDocument() {
064: // Ojo Document es javax.swing.text.Document
065: return (Document) dataModel;
066: }
067:
068: public void setDocument(Document dataModel) {
069: setDataModel(dataModel);
070: }
071:
072: public ItsNatTextComponentUI getItsNatTextComponentUI() {
073: return (ItsNatTextComponentUI) compUI;
074: }
075:
076: public ItsNatComponentUI createDefaultItsNatComponentUI() {
077: return createDefaultItsNatHTMLInputTextBasedUI();
078: }
079:
080: public ItsNatTextComponentUI createDefaultItsNatHTMLInputTextBasedUI() {
081: return new ItsNatHTMLInputTextBasedUIImpl(this );
082: }
083:
084: public void bindDataModel() {
085: ItsNatTextBasedSharedImpl.bindDataModel(this );
086: }
087:
088: public void unbindDataModel() {
089: ItsNatTextBasedSharedImpl.unbindDataModel(this );
090: }
091:
092: public void syncUIWithDataModel() {
093: ItsNatTextBasedSharedImpl.syncUIWithDataModel(this );
094: }
095:
096: public void insertUpdate(DocumentEvent e) {
097: ItsNatTextBasedSharedImpl.insertUpdate(this , e);
098: }
099:
100: public void removeUpdate(DocumentEvent e) {
101: ItsNatTextBasedSharedImpl.removeUpdate(this , e);
102: }
103:
104: public void changedUpdate(DocumentEvent e) {
105: ItsNatTextBasedSharedImpl.changedUpdate(this , e);
106: }
107:
108: public void setNewValueOnChange(String newValue, Event evt) {
109: // Al final se hará un setValue al HTMLInputElement pero a través del modelo de datos
110: ItsNatTextBasedSharedImpl.incrementalChange(this , newValue);
111: }
112:
113: public void setNewValueOnKeyUp(String newValue, Event evt) {
114: ItsNatTextBasedSharedImpl.incrementalChange(this , newValue);
115: }
116:
117: public Object createDefaultModelInternal() {
118: return createDefaultDocument();
119: }
120:
121: public Document createDefaultDocument() {
122: return new PlainDocument();
123: }
124:
125: public String getText(int offs, int len) {
126: return ItsNatTextBasedSharedImpl.getText(this , offs, len);
127: }
128:
129: public void appendString(String str) {
130: ItsNatTextBasedSharedImpl.appendString(this , str);
131: }
132:
133: public void replaceString(String str, int start, int end) {
134: ItsNatTextBasedSharedImpl.replaceString(this , str, start, end);
135: }
136:
137: public void insertString(String str, int pos) {
138: ItsNatTextBasedSharedImpl.insertString(this, str, pos);
139: }
140: }
|