Source Code Cross Referenced for TextFieldCD.java in  » IDE-Netbeans » vmd.analyzer » org » netbeans » modules » vmd » midp » components » items » 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 » IDE Netbeans » vmd.analyzer » org.netbeans.modules.vmd.midp.components.items 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.vmd.midp.components.items;
043:
044:        import org.netbeans.modules.vmd.api.codegen.CodeSetterPresenter;
045:        import org.netbeans.modules.vmd.api.codegen.CodeWriter;
046:        import org.netbeans.modules.vmd.api.codegen.MultiGuardedSection;
047:        import org.netbeans.modules.vmd.api.model.*;
048:        import org.netbeans.modules.vmd.api.model.common.DocumentSupport;
049:        import org.netbeans.modules.vmd.api.properties.DefaultPropertiesPresenter;
050:        import org.netbeans.modules.vmd.api.screen.display.ScreenDisplayPresenter;
051:        import org.netbeans.modules.vmd.midp.codegen.MidpParameter;
052:        import org.netbeans.modules.vmd.midp.codegen.MidpSetter;
053:        import org.netbeans.modules.vmd.midp.components.MidpTypes;
054:        import org.netbeans.modules.vmd.midp.components.MidpVersionDescriptor;
055:        import org.netbeans.modules.vmd.midp.components.MidpVersionable;
056:        import org.netbeans.modules.vmd.midp.propertyeditors.*;
057:        import org.netbeans.modules.vmd.midp.screen.display.TextFieldDisplayPresenter;
058:        import org.openide.util.NbBundle;
059:
060:        import java.util.ArrayList;
061:        import java.util.Arrays;
062:        import java.util.List;
063:
064:        /**
065:         *
066:         * @author Karol Harezlak
067:         */
068:
069:        public class TextFieldCD extends ComponentDescriptor {
070:
071:            public static final TypeID TYPEID = new TypeID(
072:                    TypeID.Kind.COMPONENT, "javax.microedition.lcdui.TextField"); // NOI18N
073:
074:            public static final int VALUE_ANY = 0;
075:            public static final int VALUE_EMAILADDR = 1;
076:            public static final int VALUE_NUMERIC = 2;
077:            public static final int VALUE_PHONENUMBER = 3;
078:            public static final int VALUE_URL = 4;
079:            public static final int VALUE_DECIMAL = 5;
080:
081:            public static final int VALUE_CONSTRAINT_MASK = 0xFFFF;
082:            public static final int VALUE_PASSWORD = 0x10000;
083:            public static final int VALUE_UNEDITABLE = 0x20000;
084:            public static final int VALUE_SENSITIVE = 0x40000;
085:            public static final int VALUE_NON_PREDICTIVE = 0x80000;
086:            public static final int VALUE_INITIAL_CAPS_WORD = 0x100000;
087:            public static final int VALUE_INITIAL_CAPS_SENTENCE = 0x200000;
088:
089:            public static final String PROP_TEXT = "text"; // NOI18N
090:            public static final String PROP_MAX_SIZE = "maxSize"; // NOI18N
091:            public static final String PROP_CONSTRAINTS = "constraints"; // NOI18N
092:            public static final String PROP_INITIAL_INPUT_MODE = "initialInputMode"; // NOI18N
093:
094:            public TypeDescriptor getTypeDescriptor() {
095:                return new TypeDescriptor(ItemCD.TYPEID, TYPEID, true, true);
096:            }
097:
098:            public VersionDescriptor getVersionDescriptor() {
099:                return MidpVersionDescriptor.MIDP;
100:            }
101:
102:            @Override
103:            public void postInitialize(DesignComponent component) {
104:                component.writeProperty(PROP_MAX_SIZE, MidpTypes
105:                        .createIntegerValue(32));
106:                component.writeProperty(PROP_CONSTRAINTS, MidpTypes
107:                        .createIntegerValue(VALUE_ANY));
108:            }
109:
110:            public List<PropertyDescriptor> getDeclaredPropertyDescriptors() {
111:                return Arrays.asList(
112:                        new PropertyDescriptor(PROP_TEXT,
113:                                MidpTypes.TYPEID_JAVA_LANG_STRING,
114:                                PropertyValue.createNull(), true, true,
115:                                MidpVersionable.MIDP), new PropertyDescriptor(
116:                                PROP_MAX_SIZE, MidpTypes.TYPEID_INT,
117:                                PropertyValue.createNull(), false, true,
118:                                MidpVersionable.MIDP), new PropertyDescriptor(
119:                                PROP_CONSTRAINTS, MidpTypes.TYPEID_INT,
120:                                PropertyValue.createNull(), false, true,
121:                                MidpVersionable.MIDP), new PropertyDescriptor(
122:                                PROP_INITIAL_INPUT_MODE,
123:                                MidpTypes.TYPEID_JAVA_LANG_STRING,
124:                                PropertyValue.createNull(), true, true,
125:                                MidpVersionable.MIDP_2));
126:            }
127:
128:            @Override
129:            protected void gatherPresenters(ArrayList<Presenter> presenters) {
130:                DocumentSupport.removePresentersOfClass(presenters,
131:                        ScreenDisplayPresenter.class);
132:                super .gatherPresenters(presenters);
133:            }
134:
135:            private static DefaultPropertiesPresenter createPropertiesPresenter() {
136:                return new DefaultPropertiesPresenter()
137:                        .addPropertiesCategory(
138:                                MidpPropertiesCategories.CATEGORY_PROPERTIES)
139:                        .addProperty(
140:                                NbBundle.getMessage(TextFieldCD.class,
141:                                        "DISP_TextField_Maximum_Size"), // NOI18N
142:                                PropertyEditorNumber.createIntegerInstance(
143:                                        false, NbBundle.getMessage(
144:                                                TextFieldCD.class,
145:                                                "LBL_TextField_Maximum_Size")),
146:                                PROP_MAX_SIZE)
147:                        // NOI18N
148:                        .addProperty(
149:                                NbBundle.getMessage(TextFieldCD.class,
150:                                        "DISP_TextField_Text"), // NOI18N
151:                                PropertyEditorString
152:                                        .createInstance(
153:                                                PropertyEditorString.DEPENDENCE_TEXT_FIELD,
154:                                                NbBundle.getMessage(
155:                                                        TextFieldCD.class,
156:                                                        "LBL_TextField_Text")),
157:                                PROP_TEXT) // NOI18N
158:                        .addProperty(
159:                                NbBundle.getMessage(TextFieldCD.class,
160:                                        "DISP_TextField_Initial_Input_Mode"),
161:                                PropertyEditorInputMode.createInstance(),
162:                                PROP_INITIAL_INPUT_MODE) // NOI18N
163:                        .addProperty(
164:                                NbBundle.getMessage(TextFieldCD.class,
165:                                        "DISP_TextField_Input_Constraints"),
166:                                PropertyEditorConstraints.createInstance(),
167:                                PROP_CONSTRAINTS); // NOI18N
168:            }
169:
170:            private static Presenter createSetterPresenter() {
171:                return new CodeSetterPresenter()
172:                        .addParameters(
173:                                MidpParameter.create(PROP_TEXT, PROP_MAX_SIZE,
174:                                        PROP_INITIAL_INPUT_MODE))
175:                        .addParameters(new TextFieldConstraintsParameter())
176:                        .addSetters(
177:                                MidpSetter
178:                                        .createConstructor(TYPEID,
179:                                                MidpVersionable.MIDP)
180:                                        .addParameters(
181:                                                ItemCD.PROP_LABEL,
182:                                                PROP_TEXT,
183:                                                PROP_MAX_SIZE,
184:                                                TextFieldConstraintsParameter.PARAM_CONSTRAINTS))
185:                        .addSetters(
186:                                MidpSetter.createSetter("setString",
187:                                        MidpVersionable.MIDP).addParameters(
188:                                        PROP_TEXT)) // NOI18N
189:                        .addSetters(
190:                                MidpSetter
191:                                        .createSetter("setConstraints",
192:                                                MidpVersionable.MIDP)
193:                                        .addParameters(
194:                                                TextFieldConstraintsParameter.PARAM_CONSTRAINTS)) // NOI18N
195:                        .addSetters(
196:                                MidpSetter.createSetter("setInitialInputMode",
197:                                        MidpVersionable.MIDP_2).addParameters(
198:                                        PROP_INITIAL_INPUT_MODE)) // NOI18N
199:                        .addSetters(
200:                                MidpSetter.createSetter("setMaxSize",
201:                                        MidpVersionable.MIDP).addParameters(
202:                                        PROP_MAX_SIZE)); // NOI18N
203:            }
204:
205:            protected List<? extends Presenter> createPresenters() {
206:                return Arrays.asList(
207:                // properties
208:                        createPropertiesPresenter(),
209:                        // code
210:                        createSetterPresenter(),
211:                        // screen
212:                        new TextFieldDisplayPresenter());
213:            }
214:
215:            public static class TextFieldConstraintsParameter extends
216:                    MidpParameter {
217:
218:                public static final String PARAM_CONSTRAINTS = "constraints"; // NOI18N
219:
220:                public TextFieldConstraintsParameter() {
221:                    super (PARAM_CONSTRAINTS);
222:                }
223:
224:                @Override
225:                public void generateParameterCode(DesignComponent component,
226:                        MultiGuardedSection section, int index) {
227:                    PropertyValue value = component
228:                            .readProperty(PROP_CONSTRAINTS);
229:                    if (value.getKind() == PropertyValue.Kind.VALUE) {
230:                        int constraint = MidpTypes.getInteger(value);
231:                        int core = constraint
232:                                & TextFieldCD.VALUE_CONSTRAINT_MASK;
233:                        CodeWriter writer = section.getWriter();
234:                        switch (core) {
235:                        case TextFieldCD.VALUE_ANY:
236:                            writer.write("TextField.ANY"); // NOI18N
237:                            break;
238:                        case TextFieldCD.VALUE_EMAILADDR:
239:                            writer.write("TextField.EMAILADDR"); // NOI18N
240:                            break;
241:                        case TextFieldCD.VALUE_NUMERIC:
242:                            writer.write("TextField.NUMERIC"); // NOI18N
243:                            break;
244:                        case TextFieldCD.VALUE_PHONENUMBER:
245:                            writer.write("TextField.PHONENUMBER"); // NOI18N
246:                            break;
247:                        case TextFieldCD.VALUE_URL:
248:                            writer.write("TextField.URL"); // NOI18N
249:                            break;
250:                        case TextFieldCD.VALUE_DECIMAL:
251:                            writer.write("TextField.DECIMAL"); // NOI18N
252:                            break;
253:                        default:
254:                            writer.write(Integer.toString(core));
255:                        }
256:                        if ((constraint & TextFieldCD.VALUE_PASSWORD) != 0)
257:                            writer.write(" | TextField.PASSWORD"); // NOI18N
258:                        if ((constraint & TextFieldCD.VALUE_UNEDITABLE) != 0)
259:                            writer.write(" | TextField.UNEDITABLE"); // NOI18N
260:                        if ((constraint & TextFieldCD.VALUE_SENSITIVE) != 0)
261:                            writer.write(" | TextField.SENSITIVE"); // NOI18N
262:                        if ((constraint & TextFieldCD.VALUE_NON_PREDICTIVE) != 0)
263:                            writer.write(" | TextField.NON_PREDICTIVE"); // NOI18N
264:                        if ((constraint & TextFieldCD.VALUE_INITIAL_CAPS_WORD) != 0)
265:                            writer.write(" | TextField.INITIAL_CAPS_WORD"); // NOI18N
266:                        if ((constraint & TextFieldCD.VALUE_INITIAL_CAPS_SENTENCE) != 0)
267:                            writer.write(" | TextField.INITIAL_CAPS_SENTENCE"); // NOI18N
268:                        return;
269:                    }
270:                    super.generateParameterCode(component, section, index);
271:                }
272:
273:            }
274:
275:        }
w___ww_.__j_ava_2___s.__c__o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.