Source Code Cross Referenced for XuiProComponentFactory.java in  » XML-UI » xui32 » com » xoetrope » awt » 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 » xui32 » com.xoetrope.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.awt;
002:
003:        import com.xoetrope.awt.survey.XKioskQuestion;
004:        import com.xoetrope.awt.survey.XQuestion;
005:        import com.xoetrope.awt.survey.XWrapQuestion;
006:        import java.util.Hashtable;
007:
008:        import java.awt.Component;
009:
010:        import net.xoetrope.xui.XComponentConstructor;
011:        import net.xoetrope.xui.XComponentFactory;
012:        import net.xoetrope.xui.XImageHolder;
013:        import net.xoetrope.xui.XProjectManager;
014:        import net.xoetrope.xui.XTextHolder;
015:        import net.xoetrope.registry.ComponentAdapter;
016:        import net.xoetrope.xui.XProject;
017:
018:        /**
019:         * @todo get rid of this class, all components should be added through the registry
020:         * A factory class used to add the components available as part of the XForms
021:         * package. These are: Question, WrapQuestion, KioskQuestion, ProgressBar, Date,
022:         * DateChooser, Keypad, Money and EasterEgg.
023:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
024:         * the GNU Public License (GPL), please see license.txt for more details. If
025:         * you make commercial use of this software you must purchase a commercial
026:         * license from Xoetrope.</p>
027:         * <p>$Revision: 1.6 $</p>
028:         */
029:        public class XuiProComponentFactory implements  XComponentConstructor {
030:            private XQuestion lastQuestion;
031:            private int nextValue = 0;
032:            private String defaultQuestionFormat;
033:            private String packageName = "net.xoetrope.awt";
034:
035:            /**
036:             * The owner project and the context in which this object operates.
037:             */
038:            protected XProject currentProject;
039:
040:            /**
041:             * @param proj The project to which the factory belongs
042:             */
043:            public XuiProComponentFactory(XProject project) {
044:                currentProject = project;
045:                update();
046:            }
047:
048:            public void update() {
049:                try {
050:                    defaultQuestionFormat = currentProject
051:                            .getStartupParam("DefaultQuestionFormat");
052:                } catch (Exception ex) {
053:                }
054:                if (defaultQuestionFormat == null)
055:                    defaultQuestionFormat = "Question";
056:            }
057:
058:            /**
059:             * Set the package name for the factory's widgets.
060:             * @param defPackage the package in which the widgets are defined
061:             */
062:            public void setPackageName(String defPackage) {
063:                packageName = defPackage;
064:            }
065:
066:            /**
067:             * Constructs XForms components on behalf of the component factory. At present
068:             * the following types are supported
069:             * @param cf the calling component factory
070:             * @param type
071:             * @param content
072:             * @return The new Component
073:             */
074:            public Component constructComponent(XComponentFactory cf, int type,
075:                    String content) {
076:                return null;
077:            }
078:
079:            /**
080:             * Constructs XForms components on behalf of the component factory. At present
081:             * the following types are supported
082:             * <UL>
083:             * <LI>ProgressBar</LI>
084:             * </UL>
085:             * @param cf the calling component factory
086:             * @param type the component type name
087:             * @param content the contents if applicable
088:             * @return the new component
089:             */
090:            public Object constructComponent(XComponentFactory cf, String type,
091:                    String content) {
092:                Component comp = null;
093:                if (type.compareToIgnoreCase("Question") == 0) {
094:                    if (defaultQuestionFormat.compareTo("WrapQuestion") == 0)
095:                        comp = lastQuestion = new XWrapQuestion();
096:                    else if (defaultQuestionFormat.compareTo("KioskQuestion") == 0)
097:                        comp = lastQuestion = new XKioskQuestion();
098:                    if (comp == null)
099:                        comp = lastQuestion = new XQuestion();
100:                    ((XTextHolder) comp).setText(content);
101:                    nextValue = 0;
102:                }
103:                //    else if ( type.compareToIgnoreCase( "ProgressBar" ) == 0 )
104:                //      comp = new XProgressBar();
105:                //    else if ( type.compareToIgnoreCase( "Date" ) == 0 )
106:                //      comp = new XDateEdit();
107:                //    else if ( type.compareToIgnoreCase( "DateChooser" ) == 0 )
108:                //      comp = new XDateChooser();
109:                //    else if ( type.compareToIgnoreCase( "Keypad" ) == 0 )
110:                //      comp = new XKeypad();
111:                //    else if ( type.compareToIgnoreCase( "Money" ) == 0 )
112:                //      comp = new XMoneyEdit();
113:                //    else if ( type.compareToIgnoreCase( "ImageButton" ) == 0 )
114:                //      comp = new XImageButton();
115:                //    else if ( type.compareToIgnoreCase( "Shape" ) == 0 )
116:                //      comp = new XShape();
117:                //    else if ( type.compareToIgnoreCase( "AWTSpinner" ) == 0 )
118:                //      comp = new XSpinner();
119:                else if (type.compareToIgnoreCase("EasterEgg") == 0) {
120:                    comp = new XEasterEgg();
121:                    ((XImageHolder) comp).setImage(currentProject
122:                            .getImage(content));
123:                }
124:                return comp;
125:            }
126:
127:            /**
128:             * A factory method for adding non component elements. This includes question
129:             * response elements
130:             * @param cf the calling component factory
131:             * @param type the object type
132:             * @param name  a name identifying the element to be created
133:             * @param content the component text/content
134:             * @param attribs the element attributes if any
135:             */
136:            public Object addElement(XComponentFactory cf, String type,
137:                    String name, String content, Hashtable attribs) {
138:                if (type.compareToIgnoreCase("Response") == 0)
139:                    lastQuestion.addResponse(new Integer((String) attribs
140:                            .get("id")).intValue(), content);
141:                else if (type.compareToIgnoreCase("QuestionManager") == 0) {
142:                    int slots = new Integer((String) attribs.get("slots"))
143:                            .intValue();
144:                    int width = new Integer((String) attribs.get("w"))
145:                            .intValue();
146:                    int height = new Integer((String) attribs.get("h"))
147:                            .intValue();
148:                    for (int i = 0; i < slots; i++) {
149:                        Component comp = lastQuestion = (XQuestion) cf
150:                                .addComponent("Question", 0, 0, width, height,
151:                                        "");
152:                        comp.setName(name);
153:                        ((XTextHolder) comp).setText(content);
154:                        lastQuestion.setAttribute("ref", "next");
155:                    }
156:                    lastQuestion.setLastQuestion(true);
157:                    nextValue = 0;
158:                }
159:
160:                return lastQuestion;
161:            }
162:
163:            /**
164:             * Get the component adapter for this type
165:             * @param type the name identifying the type
166:             */
167:            public ComponentAdapter getComponentAdapter(String type) {
168:                return null;
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.