Source Code Cross Referenced for XStateBinding.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.xui.XProjectManager;
006:        import net.xoetrope.xui.XListHolder;
007:        import net.xoetrope.xui.XStateHolder;
008:        import net.xoetrope.xml.XmlElement;
009:
010:        /**
011:         * <p>Bind a component's state to a data model value/node. The binding allows a
012:         * model node to linked to a UI component so that it can be refreshed when new
013:         * data is written to the model or conversely when the UI component needs to
014:         * write data to the model.
015:         * <br>This binding is designed to be used by components such
016:         * as RadioButtons or Checkboxes.</p> This state change does not affect the
017:         * content displayed by the component.
018:         * <p>Copyright (c) Xoetrope Ltd., 1998-2003<br>
019:         * License:      see license.txt
020:         * @version $Revision: 1.11 $
021:         */
022:        public class XStateBinding implements  XDataBinding {
023:            protected Component comp;
024:            protected XModel sourceModel;
025:            protected XModel outputModel;
026:            protected String srcPath;
027:            protected String outputPath;
028:            protected boolean isLeafNode;
029:
030:            /**
031:             * Construct a new data binding
032:             * @param c the component to be bound
033:             * @param dataElement the name of the data in the model
034:             */
035:            public XStateBinding(Component c, String dataElement) {
036:                srcPath = dataElement;
037:                outputPath = XModel.prefixOutputPath(srcPath);
038:                if (dataElement != null)
039:                    sourceModel = (XModel) XProjectManager.getModel().get(
040:                            dataElement);
041:                comp = c;
042:                isLeafNode = true;
043:            }
044:
045:            /**
046:             * Construct a new data binding
047:             * @param c the component to be bound
048:             * @param dataElement the name of the data in the model
049:             * @param srcModel the model node that acts as the data source for this node
050:             * @param leafAttrib null or true for a leaf node where the value controls the state,
051:             * or false to use the child values to control not only the state but also the enabled/disabled state
052:             */
053:            public XStateBinding(Component c, String dataElement,
054:                    XModel srcModel, String leafAttrib) {
055:                srcPath = dataElement;
056:                outputPath = XModel.prefixOutputPath(srcPath);
057:                sourceModel = srcModel;
058:                comp = c;
059:                if ((leafAttrib != null) && leafAttrib.equals("false"))
060:                    isLeafNode = false;
061:                else
062:                    isLeafNode = true;
063:            }
064:
065:            /**
066:             * Updates the component state with the value obtained from the data model.
067:             */
068:            public void get() {
069:                if ((outputModel != null) || (sourceModel != null)) {
070:                    if (isLeafNode) {
071:                        if ((outputModel != null))
072:                            ((XStateHolder) comp).setComponentState(outputModel
073:                                    .get());
074:                        else
075:                            ((XStateHolder) comp).setComponentState(sourceModel
076:                                    .get());
077:                    } else {
078:                        XModel srcNode = sourceModel.get(0);
079:                        boolean multipleChildren = (sourceModel
080:                                .getNumChildren() > 1);
081:                        comp.setEnabled(multipleChildren);
082:                        if (!multipleChildren)
083:                            ((XStateHolder) comp).setComponentState(srcNode
084:                                    .get());
085:                        else
086:                            ((XStateHolder) comp).setComponentState(outputModel
087:                                    .get());
088:                    }
089:                }
090:            }
091:
092:            /**
093:             * Updates the data model with the value retrieved from the component.
094:             */
095:            public void set() {
096:                Object state = ((XStateHolder) comp).getComponentState();
097:                if (state instanceof  Boolean)
098:                    outputModel.set(((Boolean) state).booleanValue() ? "1"
099:                            : "0");
100:                else
101:                    outputModel.set(state);
102:            }
103:
104:            /**
105:             * Get the component to which this object binds
106:             * @return
107:             */
108:            public Component getComponent() {
109:                return comp;
110:            }
111:
112:            /**
113:             * Get the model component to which this object binds
114:             * @return
115:             */
116:            public String getSourcePath() {
117:                return srcPath;
118:            }
119:
120:            /**
121:             * Get the model component to which this object binds ins output/state
122:             * @return
123:             */
124:            public String getOutputPath() {
125:                return outputPath;
126:            }
127:
128:            /**
129:             * Set the source node for data in the model
130:             * @param newNode the path of the data in the model
131:             */
132:            public void setSource(XModel newNode) {
133:                sourceModel = newNode;
134:                if (outputModel.get() == null)
135:                    outputModel.set(sourceModel.get());
136:            }
137:
138:            /**
139:             * Set the path to the output/state node
140:             * @param newPath the name of the path in the model
141:             */
142:            public void setOutput(XModel newNode) {
143:                outputModel = newNode;
144:            }
145:
146:            /**
147:             * Set the model path for the source data
148:             */
149:            public void setSourcePath(String newPath) {
150:                srcPath = newPath;
151:            }
152:
153:            /**
154:             * Set the model path for the output/state data
155:             */
156:            public void setOutputPath(String newPath) {
157:                outputPath = XModel.prefixOutputPath(newPath);
158:            }
159:
160:            /**
161:             * Gets the name of the model node
162:             * @return the name
163:             */
164:            public String getName() {
165:                return sourceModel
166:                        .getAttribValueAsString(XBaseModel.ID_ATTRIBUTE);
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.