Source Code Cross Referenced for DataSample.java in  » XML-UI » XUI » net » xoetrope » samples » controls » 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.samples.controls 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.samples.controls;
002:
003:        import java.io.BufferedWriter;
004:        import java.io.File;
005:        import java.io.FileOutputStream;
006:        import java.io.OutputStreamWriter;
007:
008:        import java.awt.Frame;
009:
010:        import net.xoetrope.awt.XButton;
011:        import net.xoetrope.awt.XComboBox;
012:        import net.xoetrope.awt.XEdit;
013:        import net.xoetrope.data.XDataSource;
014:        import net.xoetrope.xui.XPage;
015:        import net.xoetrope.xui.XResourceManager;
016:        import net.xoetrope.xui.data.XDataBinding;
017:        import net.xoetrope.xui.data.XListBinding;
018:        import net.xoetrope.xui.data.XTextBinding;
019:        import net.xoetrope.xui.helper.BuddyHelper;
020:        import net.xoetrope.xui.style.XStyleFactory;
021:
022:        /**
023:         * <p>Title: Xui</p>
024:         * <p>Description: </p>
025:         * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
026:         * <p>Company: Xoetrope Ltd.</p>
027:         * @author not attributable
028:         * @version 1.0
029:         */
030:
031:        public class DataSample extends XPage {
032:            XButton closeButton, saveButton;
033:            Frame frame;
034:            BuddyHelper buddy;
035:            XEdit txtFirstname, txtSurname, txtAge;
036:            XComboBox cmbOccupations;
037:            private boolean pageValidation = false;
038:            private String validationText = "";
039:            private XDataSource modelDataSource;
040:
041:            public DataSample() {
042:                buddy = new BuddyHelper((XStyleFactory) componentFactory);
043:
044:                frame = new Frame("Data Sample");
045:                frame.setLayout(null);
046:                frame.setSize(640, 580);
047:                String desc = "This example shows how data can be bound to input controls. First create the components and then";
048:                desc += " bind them to the controls you wish to populate. Load the data using the modelDataSource and call the";
049:                desc += " updateBoundComponentValues function in order to do the population. To save the data the saveBoundComponentValues";
050:                desc += " must first be called. and then the save will output the data in the format it was read.";
051:                desc += " In the more complete examples the transfer of data between the controls and the model is automated";
052:                desc += " making the data handling more transparent";
053:
054:                componentFactory.addComponent(XPage.LABEL, 10, 50, 530, 120,
055:                        desc);
056:
057:                txtFirstname = (XEdit) buddy.addComponent(XPage.EDIT, 20, 250,
058:                        150, 25, "Firstname", "", null);
059:                txtSurname = (XEdit) buddy.addComponent(XPage.EDIT, 20, 280,
060:                        150, 25, "Surname", "", null);
061:                txtAge = (XEdit) buddy.addComponent(XPage.EDIT, 20, 95, 130,
062:                        310, 355, 25, "Age", "", "Years", null);
063:                cmbOccupations = (XComboBox) buddy.addComponent(XPage.COMBO,
064:                        20, 340, 150, 25, "Profession", "", null);
065:
066:                saveButton = (XButton) componentFactory.addComponent(
067:                        XPage.BUTTON, 10, 440, 130, 25, "Save");
068:                closeButton = (XButton) componentFactory.addComponent(
069:                        XPage.BUTTON, 10, 540, 130, 25, "Close");
070:                setSize(frame.getSize());
071:                mapEvents();
072:                loadData();
073:                populateComponents();
074:                updateBoundComponentValues();
075:
076:                frame.add(this );
077:                frame.setVisible(true);
078:                frame.show();
079:            }
080:
081:            public void populateComponents() {
082:                addBinding(new XTextBinding(txtFirstname,
083:                        "personaldata/firstname"));
084:                addBinding(new XTextBinding(txtSurname, "personaldata/surname"));
085:                addBinding(new XTextBinding(txtAge, "personaldata/age"));
086:                addBinding(new XListBinding(cmbOccupations,
087:                        "personaldata/professions"));
088:            }
089:
090:            public void updateBoundComponentValues() {
091:                // iterate over components and update their values
092:                int numBindings = modelBindings.size();
093:                for (int i = 0; i < numBindings; i++)
094:                    ((XDataBinding) modelBindings.elementAt(i)).get();
095:            }
096:
097:            public void saveBoundComponentValues() {
098:                // iterate over components and save their values
099:                int numBindings = modelBindings.size();
100:                for (int i = 0; i < numBindings; i++)
101:                    ((XDataBinding) modelBindings.elementAt(i)).set();
102:            }
103:
104:            private void mapEvents() {
105:                addMouseHandler(closeButton, "Close");
106:                addMouseHandler(saveButton, "save");
107:            }
108:
109:            public static void main(String args[]) {
110:                ValidationSample compSample = new ValidationSample();
111:            }
112:
113:            public void Close() {
114:                if (wasMouseClicked()) {
115:                    frame.setVisible(false);
116:                }
117:            }
118:
119:            private void loadData() {
120:                modelDataSource = new XDataSource();
121:                try {
122:                    String fileName = "sampledatasets.xml";
123:                    File source = new File(fileName);
124:                    if (source.exists())
125:                        modelDataSource.read(XResourceManager
126:                                .getBufferedReader(source, null));
127:                    else
128:                        modelDataSource.read(XResourceManager
129:                                .getBufferedReader(fileName, null));
130:                } catch (Exception ex) {
131:                    ex.printStackTrace();
132:                }
133:            }
134:
135:            public void save() {
136:                if (wasMouseClicked()) {
137:                    saveBoundComponentValues();
138:                    try {
139:                        String fileName = "SampleData.xml";
140:                        FileOutputStream fos = new FileOutputStream(fileName);
141:                        OutputStreamWriter osw = new OutputStreamWriter(fos,
142:                                "ISO-8859-1");
143:                        BufferedWriter bw = new BufferedWriter(osw);
144:                        modelDataSource.write(bw);
145:                    } catch (Exception ex) {
146:                        ex.printStackTrace();
147:                    }
148:                }
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.