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.ui;
15:
16: import org.itsnat.comp.ItsNatTextComponent;
17: import org.itsnat.comp.html.ItsNatHTMLFormComponent;
18: import org.itsnat.comp.ui.ItsNatTextComponentUI;
19: import org.itsnat.impl.comp.html.ItsNatHTMLFormCompValueBasedImpl;
20: import org.itsnat.impl.comp.html.ItsNatHTMLFormComponentImpl;
21:
22: /**
23: *
24: * @author jmarranz
25: */
26: public abstract class ItsNatHTMLTextBasedUIImpl extends
27: ItsNatHTMLElementComponentUIImpl implements
28: ItsNatTextComponentUI {
29: /**
30: * Creates a new instance of ItsNatHTMLTextBasedUIImpl
31: */
32: public ItsNatHTMLTextBasedUIImpl(
33: ItsNatHTMLFormCompValueBasedImpl parentComp) {
34: super (parentComp);
35:
36: setEditable(true);
37: }
38:
39: public ItsNatHTMLFormComponent getItsNatHTMLFormComponent() {
40: return (ItsNatHTMLFormComponent) parentComp;
41: }
42:
43: public ItsNatHTMLFormComponentImpl getItsNatHTMLFormComponentImpl() {
44: return (ItsNatHTMLFormComponentImpl) parentComp;
45: }
46:
47: public ItsNatTextComponent getItsNatTextComponent() {
48: return (ItsNatTextComponent) parentComp;
49: }
50:
51: public String getText() {
52: // NO publicar, es interna
53: return getDOMValueProperty();
54: }
55:
56: public void setText(String str) {
57: setDOMValueProperty(str); // Sólo nos interesa modificar en el servidor no en ningún cliente porque la modificación en el cliente se hace después
58: }
59:
60: public void insertString(int where, String str) {
61: String text = getText();
62: text = text.substring(0, where) + str + text.substring(where);
63: setText(text);
64: }
65:
66: public void removeString(int where, int len) {
67: String text = getText();
68: text = text.substring(0, where) + text.substring(where + len);
69: setText(text);
70: }
71:
72: protected abstract String getDOMValueProperty();
73:
74: protected abstract void setDOMValueProperty(String str);
75: }
|