Source Code Cross Referenced for TKOptionField.java in  » Content-Management-System » webman » com » teamkonzept » field » 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 » Content Management System » webman » com.teamkonzept.field 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.teamkonzept.field;
002:
003:        import java.util.Enumeration;
004:        import com.teamkonzept.lib.*;
005:        import com.teamkonzept.web.*;
006:        import com.teamkonzept.field.db.*;
007:        import com.teamkonzept.international.LanguageManager;
008:
009:        /**
010:         * The option field control.
011:         *
012:         * @author $Author: uli $
013:         * @version $Revision: 1.19 $
014:         */
015:        public abstract class TKOptionField extends TKAtomField {
016:            // $Id: TKOptionField.java,v 1.19 2002/02/27 11:07:04 uli Exp $
017:
018:            public static final String MULTIPLE_KEY = "MULTIPLE";
019:            public static final String OPTIONS_KEY = "OPTIONS";
020:
021:            protected boolean multiple = false;
022:
023:            protected TKVector optionList = null;
024:
025:            public TKOptionField() {
026:            };
027:
028:            protected TKOptionField(String classId, String name,
029:                    String showName, TKVector optionList, boolean multiple) {
030:                initOptionField(classId, name, showName, optionList, multiple);
031:            }
032:
033:            public final void initOptionField(String type, String name,
034:                    String showName, TKVector optionList, boolean multiple) {
035:                initAtomField(type, name, showName);
036:                this .optionList = optionList;
037:                this .multiple = multiple;
038:            }
039:
040:            public void init(String fieldClass, Object data)
041:                    throws TKUnregisteredClassException,
042:                    ClassNotFoundException, InstantiationException,
043:                    IllegalAccessException {
044:                TKHashtable checkData = (TKHashtable) data;
045:                super .init(fieldClass, data);
046:
047:                this .multiple = ((String) checkData.get(MULTIPLE_KEY))
048:                        .equals("YES");
049:                optionList = getListOfOptions((TKVector) checkData
050:                        .get(OPTIONS_KEY));
051:            }
052:
053:            /**
054:             * Methode zur Definition eines Optionseldes
055:             */
056:            public TKFieldGroup getDefGroup(TKFieldSwitch allSwitch,
057:                    TKFieldSwitchList allSwitchList) {
058:
059:                TKVector multipleOptions = new TKVector(2);
060:                multipleOptions
061:                        .addElement(new TKOptionFieldEntry(LanguageManager
062:                                .getText(LanguageManager.GENERAL, "YES"), "YES"));
063:                multipleOptions.addElement(new TKOptionFieldEntry(
064:                        LanguageManager.getText(LanguageManager.GENERAL, "NO"),
065:                        "NO"));
066:
067:                TKBaseField[] optionArray = {
068:                        new TKInputField("NAME",
069:                                TKInputField.SMALL_DEFAULT_SIZE,
070:                                TKInputField.SMALL_DEFAULT_LENGTH,
071:                                LanguageManager.getText(LANGUAGE_CONTEXT,
072:                                        "OPTIONFIELD_NAME"),
073:                                TKInputField.CHECK_STRING),
074:                        new TKInputField("SHOWNAME",
075:                                TKInputField.LARGE_DEFAULT_SIZE,
076:                                TKInputField.LARGE_DEFAULT_LENGTH,
077:                                LanguageManager.getText(LANGUAGE_CONTEXT,
078:                                        "OPTIONFIELD_SHOWNAME"),
079:                                TKInputField.CHECK_STRING) };
080:
081:                TKFieldGroup optionGroup = new TKFieldGroup("OPTION",
082:                        new TKVector(optionArray), LanguageManager.getText(
083:                                LANGUAGE_CONTEXT, "OPTION"));
084:
085:                return optionGroup;
086:            }
087:
088:            /**
089:             * Returns the internal representation of this field.
090:             *
091:             * @return the internal representation of this field.
092:             */
093:            public Object toData() {
094:                TKHashtable result = (TKHashtable) super .toData();
095:                result.put(MULTIPLE_KEY, (multiple ? "YES" : "NO"));
096:                result.put(OPTIONS_KEY, getDataOfOptions(optionList));
097:                return result;
098:            }
099:
100:            public void fillIntoTemplate(TKHTMLTemplate t, Object value,
101:                    String prefix) {
102:                super .fillIntoTemplate(t, value, prefix);
103:
104:                t.setListIterator(new TKOptionFieldIterator(optionList,
105:                        fieldName, t.getListIterator(), "OPTION_LIST"));
106:                t.set(prefix + fieldName, value);
107:
108:                if (multiple)
109:                    t.set(prefix + fieldName + ".MULTIPLE", Boolean.TRUE);
110:            }
111:
112:            public int realInsertIntoDB(TKFormDBData db, int formId) {
113:                if (super .realInsertIntoDB(db, formId) == -1)
114:                    return -1;
115:
116:                insertNewFieldAttribute(db, formId, MULTIPLE_KEY, 0, String
117:                        .valueOf(multiple));
118:                int osize = optionList.size();
119:                insertNewFieldAttribute(db, formId, OPTIONS_KEY, 0, String
120:                        .valueOf(osize));
121:                for (int i = 0; i < osize; i++) {
122:                    TKOptionFieldEntry entry = (TKOptionFieldEntry) optionList
123:                            .get(i);
124:                    insertNewFieldAttribute(db, formId,
125:                            TKOptionFieldEntry.OPTION_KEY, i, entry.option);
126:                    insertNewFieldAttribute(db, formId,
127:                            TKOptionFieldEntry.VALUE_KEY, i, entry.value);
128:                }
129:                return fieldId;
130:            }
131:
132:            public void initFromDB(String classId, TKFormDBData db,
133:                    TKVector otherFields) throws TKUnregisteredClassException,
134:                    ClassNotFoundException, InstantiationException,
135:                    IllegalAccessException {
136:                super .initFromDB(classId, db, otherFields);
137:
138:                multiple = (new Boolean(getFieldAttribute(db, MULTIPLE_KEY, 0)))
139:                        .booleanValue();
140:                int size = Integer.parseInt(getFieldAttribute(db, OPTIONS_KEY,
141:                        0));
142:                if (size == 0) {
143:                    optionList = new TKVector();
144:                } else {
145:                    optionList = new TKVector(size);
146:                    for (int i = 0; i < size; i++) {
147:                        String option = getFieldAttribute(db,
148:                                TKOptionFieldEntry.OPTION_KEY, i);
149:                        String value = getFieldAttribute(db,
150:                                TKOptionFieldEntry.VALUE_KEY, i);
151:                        optionList.addElement(new TKOptionFieldEntry(option,
152:                                value));
153:                    }
154:                }
155:            }
156:
157:            public static final TKVector getListOfOptions(TKVector options) {
158:                TKVector optionList = new TKVector(options.size());
159:                Enumeration e = options.elements();
160:                while (e.hasMoreElements()) {
161:                    TKHashtable option = (TKHashtable) e.nextElement();
162:                    optionList.addElement(new TKOptionFieldEntry(
163:                            (String) option.get(SHOW_NAME_KEY), (String) option
164:                                    .get(NAME_KEY)));
165:                }
166:                return optionList;
167:            }
168:
169:            public static final TKVector getDataOfOptions(TKVector optionList) {
170:                TKVector options = new TKVector(optionList.size());
171:                Enumeration e = optionList.elements();
172:                while (e.hasMoreElements()) {
173:                    TKOptionFieldEntry entry = (TKOptionFieldEntry) e
174:                            .nextElement();
175:                    TKHashtable option = new TKHashtable();
176:                    option.put(SHOW_NAME_KEY, entry.option);
177:                    option.put(NAME_KEY, entry.value);
178:                    options.addElement(option);
179:                }
180:                return options;
181:            }
182:
183:            /**
184:             * Checks wether this object and the specified object
185:             * may be treated as equal.
186:             *
187:             * @param object the object to checked for equality.
188:             * @return <CODE>true</CODE> if this object and the
189:             * specified object may be treated as equal, otherwise
190:             * <CODE>false</CODE>.
191:             */
192:            public boolean equals(Object object) {
193:                if (!super .equals(object)) {
194:                    return false;
195:                }
196:
197:                TKOptionField field = (TKOptionField) object;
198:
199:                return (this .multiple == field.multiple)
200:                        && (this .optionList == null ? field.optionList == null
201:                                : this .optionList.equals(field.optionList));
202:            }
203:
204:            /**
205:             * Returns the hash code for this object.
206:             *
207:             * @return the hash code for this object.
208:             */
209:            public int hashCode() {
210:                // Implementation for JTest only ;-(
211:                return super.hashCode();
212:            }
213:
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.