Source Code Cross Referenced for XTextBinding.java in  » XML-UI » XUI » net » xoetrope » xui » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » XUI » net.xoetrope.xui.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.xui.data;
002:
003:        import java.awt.Component;
004:
005:        import net.xoetrope.xml.XmlElement;
006:        import net.xoetrope.xui.XProjectManager;
007:        import net.xoetrope.xui.XTextHolder;
008:
009:        /**
010:         * <p>Bind a TextComponent to a data model value/node. The binding allows a model node to
011:         * linked to a UI component so that it can be refreshed when new data is written
012:         * to the model or conversely when the UI component needs to write data to the
013:         * model.<br>This binding is designed to be used by components such
014:         * as TextComponents or TextFields.</p> For a text component the source and
015:         * destination area synonymous.
016:         * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003<br>
017:         * License:      see license.txt
018:         * @version $Revision: 1.25 $
019:         */
020:        public class XTextBinding implements  XDataBinding {
021:            protected Component comp;
022:            protected XModel sourceModel;
023:            protected XModel outputModel;
024:            protected String srcPath;
025:            protected String outputPath;
026:            protected String attribStr;
027:
028:            public XTextBinding() {
029:            }
030:
031:            /**
032:             * Construct a new data binding
033:             * @param c the component to be bound
034:             * @param dataElement the name of the data in the model
035:             */
036:            public XTextBinding(Component c, String dataElement) {
037:                this (c, dataElement, null, null);
038:            }
039:
040:            /**
041:             * Construct a new data binding
042:             * @param c the component to be bound
043:             * @param dataElement the name of the data in the model
044:             * @param srcModel the source model node
045:             */
046:            public XTextBinding(Component c, String dataElement, XModel srcModel) {
047:                this (c, dataElement, srcModel, null);
048:            }
049:
050:            /**
051:             * Construct a new data binding
052:             * @param c the component to be bound
053:             * @param dataElement the name of the data in the model
054:             * @param srcModel the source model node
055:             * @param attrib display an attribute of the source node if non null
056:             */
057:            public XTextBinding(Component c, String dataElement,
058:                    XModel srcModel, String attrib) {
059:                srcPath = dataElement;
060:                outputPath = XModel.prefixOutputPath(srcPath);
061:                if ((srcModel == null) && (srcPath != null))
062:                    sourceModel = (XModel) XProjectManager.getModel().get(
063:                            srcPath);
064:                else
065:                    sourceModel = srcModel;
066:                comp = c;
067:                attribStr = attrib;
068:            }
069:
070:            /**
071:             * Updates the TextComponent with the value obtained from the data model.
072:             */
073:            public void get() {
074:                if (sourceModel != null) {
075:                    Object objValue = null;
076:                    if ((attribStr != null) && (attribStr.length() > 0)) {
077:                        int attribPos = ((XModel) sourceModel)
078:                                .getAttribute(attribStr);
079:                        if (attribPos >= 0)
080:                            objValue = ((XModel) sourceModel)
081:                                    .getAttribValue(attribPos);
082:                    } else
083:                        objValue = sourceModel.get();
084:                    if (objValue != null)
085:                        ((XTextHolder) comp).setText(objValue.toString());
086:                    else
087:                        ((XTextHolder) comp).setText("");
088:                }
089:            }
090:
091:            /**
092:             * Updates the data model with the value retrieved from the TextComponent.
093:             */
094:            public void set() {
095:                if (attribStr == null) {
096:                    sourceModel.set(((XTextHolder) comp).getText());
097:                    if (outputModel != null)
098:                        outputModel.set(((XTextHolder) comp).getText());
099:                } else {
100:                    int attIdx = sourceModel.getAttribute(attribStr);
101:                    String compValue = ((XTextHolder) comp).getText();
102:                    sourceModel.setAttribValue(attIdx, compValue);
103:                    if (outputModel != null) {
104:                        int attribIdx = outputModel.getAttribute(attribStr);
105:                        if (attribIdx < 0) {
106:                            boolean appendState = XBaseModel
107:                                    .getAppendByDefault();
108:                            XBaseModel.setAppendByDefault(true);
109:                            attribIdx = outputModel.getAttribute(attribStr);
110:                            XBaseModel.setAppendByDefault(appendState);
111:                        }
112:                        outputModel.setAttribValue(attribIdx, compValue);
113:                    }
114:                }
115:            }
116:
117:            /**
118:             * Get the component to which this object binds
119:             * @return
120:             */
121:            public Component getComponent() {
122:                return comp;
123:            }
124:
125:            /**
126:             * Get the model component to which this object binds
127:             * @return
128:             */
129:            public String getSourcePath() {
130:                return srcPath;
131:            }
132:
133:            /**
134:             * Get the model component to which this object binds ins output/state
135:             * @return
136:             */
137:            public String getOutputPath() {
138:                return outputPath;
139:            }
140:
141:            /**
142:             * Set the source node for data in the model
143:             * @param newNode the path of the data in the model
144:             */
145:            public void setSource(XModel newNode) {
146:                sourceModel = newNode;
147:            }
148:
149:            /**
150:             * Set the path to the output/state node
151:             * @param newPath the name of the path in the model
152:             */
153:            public void setOutput(XModel newNode) {
154:                outputModel = newNode;
155:            }
156:
157:            /**
158:             * Set the model path for the source data
159:             */
160:            public void setSourcePath(String newPath) {
161:                srcPath = newPath;
162:            }
163:
164:            /**
165:             * Set the model path for the output/state data
166:             */
167:            public void setOutputPath(String newPath) {
168:                outputPath = XModel.prefixOutputPath(newPath);
169:            }
170:
171:            /**
172:             * Gets the name of the model node
173:             * @return the name
174:             */
175:            public String getName() {
176:                return sourceModel
177:                        .getAttribValueAsString(XBaseModel.ID_ATTRIBUTE);
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.