Source Code Cross Referenced for ChoiceGroupCode.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:        package org.netbeans.modules.vmd.midp.components.items;
042:
043:        import org.netbeans.modules.vmd.api.codegen.CodeWriter;
044:        import org.netbeans.modules.vmd.api.codegen.MultiGuardedSection;
045:        import org.netbeans.modules.vmd.api.codegen.Parameter;
046:        import org.netbeans.modules.vmd.api.model.Debug;
047:        import org.netbeans.modules.vmd.api.model.DesignComponent;
048:        import org.netbeans.modules.vmd.api.model.PropertyValue;
049:        import org.netbeans.modules.vmd.midp.codegen.MidpCodeSupport;
050:        import org.netbeans.modules.vmd.midp.codegen.MidpParameter;
051:        import org.netbeans.modules.vmd.midp.components.MidpTypes;
052:        import org.netbeans.modules.vmd.midp.components.elements.ChoiceElementCD;
053:
054:        import java.util.List;
055:
056:        /**
057:         * @author David Kaspar
058:         */
059:        public class ChoiceGroupCode {
060:
061:            public static final String PARAM_STRING = "elementString"; // NOI18N
062:            public static final String PARAM_IMAGE = "elementImage"; // NOI18N
063:            static final String PARAM_FONT = "elementFont"; // NOI18N
064:            static final String PARAM_SELECTED_ARRAY = "elementSelectedArray"; // NOI18N
065:            static final String PARAM_STRING_ARRAY = "elementStringArray"; // NOI18N
066:            static final String PARAM_IMAGE_ARRAY = "elementImageArray"; // NOI18N
067:            static final String PARAM_CHOICE_TYPE = "choiceType"; // NOI18N
068:            static final String PARAM_FIT_POLICY = "fitPolicy"; // NOI18N
069:
070:            public static Parameter createStringParameter() {
071:                return new StringParameter();
072:            }
073:
074:            public static Parameter createImageParameter() {
075:                return new ImageParameter();
076:            }
077:
078:            public static Parameter createFontParameter() {
079:                return new FontParameter();
080:            }
081:
082:            public static Parameter createSelectArrayParameter() {
083:                return new SelectedArrayParameter();
084:            }
085:
086:            public static Parameter createStringArrayParameter() {
087:                return new StringArrayParameter();
088:            }
089:
090:            public static Parameter createImageArrayParameter() {
091:                return new ImageArrayParameter();
092:            }
093:
094:            public static Parameter createChoiceTypeParameter() {
095:                return new ChoiceTypeParameter();
096:            }
097:
098:            public static Parameter createFitPolicyParameter() {
099:                return new FitPolicyParameter();
100:            }
101:
102:            private static class StringParameter implements  Parameter {
103:
104:                public String getParameterName() {
105:                    return PARAM_STRING;
106:                }
107:
108:                public int getParameterPriority() {
109:                    return 0;
110:                }
111:
112:                public void generateParameterCode(DesignComponent component,
113:                        MultiGuardedSection section, int index) {
114:                    PropertyValue propertyValue = component
115:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
116:                    List<PropertyValue> array = propertyValue.getArray();
117:                    DesignComponent listElement = array.get(index)
118:                            .getComponent();
119:                    PropertyValue string = listElement
120:                            .readProperty(ChoiceElementCD.PROP_STRING);
121:                    MidpCodeSupport.generateCodeForPropertyValue(section
122:                            .getWriter(), string);
123:                }
124:
125:                public boolean isRequiredToBeSet(DesignComponent component) {
126:                    return !component
127:                            .isDefaultValue(ChoiceGroupCD.PROP_ELEMENTS);
128:                }
129:
130:                public int getCount(DesignComponent component) {
131:                    PropertyValue propertyValue = component
132:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
133:                    List<PropertyValue> array = propertyValue.getArray();
134:                    return array.size();
135:                }
136:
137:                public boolean isRequiredToBeSet(DesignComponent component,
138:                        int index) {
139:                    return true;
140:                }
141:
142:            }
143:
144:            private static class ImageParameter implements  Parameter {
145:
146:                public String getParameterName() {
147:                    return PARAM_IMAGE;
148:                }
149:
150:                public int getParameterPriority() {
151:                    return 0;
152:                }
153:
154:                public void generateParameterCode(DesignComponent component,
155:                        MultiGuardedSection section, int index) {
156:                    PropertyValue propertyValue = component
157:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
158:                    List<PropertyValue> array = propertyValue.getArray();
159:                    DesignComponent choiceElement = array.get(index)
160:                            .getComponent();
161:                    PropertyValue string = choiceElement
162:                            .readProperty(ChoiceElementCD.PROP_IMAGE);
163:                    MidpCodeSupport.generateCodeForPropertyValue(section
164:                            .getWriter(), string);
165:                }
166:
167:                public boolean isRequiredToBeSet(DesignComponent component) {
168:                    return !component
169:                            .isDefaultValue(ChoiceGroupCD.PROP_ELEMENTS);
170:                }
171:
172:                public int getCount(DesignComponent component) {
173:                    PropertyValue propertyValue = component
174:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
175:                    List<PropertyValue> array = propertyValue.getArray();
176:                    return array.size();
177:                }
178:
179:                public boolean isRequiredToBeSet(DesignComponent component,
180:                        int index) {
181:                    return true;
182:                }
183:
184:            }
185:
186:            private static class FontParameter implements  Parameter {
187:
188:                public String getParameterName() {
189:                    return PARAM_FONT;
190:                }
191:
192:                public int getParameterPriority() {
193:                    return 0;
194:                }
195:
196:                public void generateParameterCode(DesignComponent component,
197:                        MultiGuardedSection section, int index) {
198:                    PropertyValue propertyValue = component
199:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
200:                    List<PropertyValue> array = propertyValue.getArray();
201:                    DesignComponent choiceElement = array.get(index)
202:                            .getComponent();
203:                    PropertyValue string = choiceElement
204:                            .readProperty(ChoiceElementCD.PROP_FONT);
205:                    MidpCodeSupport.generateCodeForPropertyValue(section
206:                            .getWriter(), string);
207:                }
208:
209:                public boolean isRequiredToBeSet(DesignComponent component) {
210:                    return !component
211:                            .isDefaultValue(ChoiceGroupCD.PROP_ELEMENTS);
212:                }
213:
214:                public int getCount(DesignComponent component) {
215:                    PropertyValue propertyValue = component
216:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
217:                    List<PropertyValue> array = propertyValue.getArray();
218:                    return array.size();
219:                }
220:
221:                public boolean isRequiredToBeSet(DesignComponent component,
222:                        int index) {
223:                    return true;
224:                }
225:
226:            }
227:
228:            private static class SelectedArrayParameter implements  Parameter {
229:
230:                public String getParameterName() {
231:                    return PARAM_SELECTED_ARRAY;
232:                }
233:
234:                public int getParameterPriority() {
235:                    return 0;
236:                }
237:
238:                public void generateParameterCode(DesignComponent component,
239:                        MultiGuardedSection section, int index) {
240:                    PropertyValue propertyValue = component
241:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
242:                    List<PropertyValue> elementsArray = propertyValue
243:                            .getArray();
244:                    CodeWriter writer = section.getWriter();
245:
246:                    writer.write("new boolean[] { "); // NOI18N
247:
248:                    for (int i = 0; i < elementsArray.size(); i++) {
249:                        if (i > 0) {
250:                            writer.write(", "); // NOI18N
251:                        }
252:                        PropertyValue choiceElementValue = elementsArray.get(i);
253:                        DesignComponent choiceElement = choiceElementValue
254:                                .getComponent();
255:                        PropertyValue string = choiceElement
256:                                .readProperty(ChoiceElementCD.PROP_SELECTED);
257:                        MidpCodeSupport.generateCodeForPropertyValue(writer,
258:                                string);
259:                    }
260:
261:                    writer.write(" }"); // NOI18N
262:                }
263:
264:                public boolean isRequiredToBeSet(DesignComponent component) {
265:                    return !component
266:                            .isDefaultValue(ChoiceGroupCD.PROP_ELEMENTS);
267:                }
268:
269:                public int getCount(DesignComponent component) {
270:                    return -1;
271:                }
272:
273:                public boolean isRequiredToBeSet(DesignComponent component,
274:                        int index) {
275:                    throw Debug.illegalState();
276:                }
277:
278:            }
279:
280:            private static class StringArrayParameter implements  Parameter {
281:
282:                public String getParameterName() {
283:                    return PARAM_STRING_ARRAY;
284:                }
285:
286:                public int getParameterPriority() {
287:                    return 0;
288:                }
289:
290:                public void generateParameterCode(DesignComponent component,
291:                        MultiGuardedSection section, int index) {
292:                    PropertyValue propertyValue = component
293:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
294:                    List<PropertyValue> elementsArray = propertyValue
295:                            .getArray();
296:                    CodeWriter writer = section.getWriter();
297:
298:                    writer.write("new String[] { "); // NOI18N
299:
300:                    for (int i = 0; i < elementsArray.size(); i++) {
301:                        if (i > 0) {
302:                            writer.write(", "); // NOI18N
303:                        }
304:                        PropertyValue choiceElementValue = elementsArray.get(i);
305:                        DesignComponent choiceElement = choiceElementValue
306:                                .getComponent();
307:                        PropertyValue string = choiceElement
308:                                .readProperty(ChoiceElementCD.PROP_STRING);
309:                        MidpCodeSupport.generateCodeForPropertyValue(writer,
310:                                string);
311:                    }
312:
313:                    writer.write(" }"); // NOI18N
314:                }
315:
316:                public boolean isRequiredToBeSet(DesignComponent component) {
317:                    return !component
318:                            .isDefaultValue(ChoiceGroupCD.PROP_ELEMENTS);
319:                }
320:
321:                public int getCount(DesignComponent component) {
322:                    return -1;
323:                }
324:
325:                public boolean isRequiredToBeSet(DesignComponent component,
326:                        int index) {
327:                    throw Debug.illegalState();
328:                }
329:
330:            }
331:
332:            private static class ImageArrayParameter implements  Parameter {
333:
334:                public String getParameterName() {
335:                    return PARAM_IMAGE_ARRAY;
336:                }
337:
338:                public int getParameterPriority() {
339:                    return 0;
340:                }
341:
342:                public void generateParameterCode(DesignComponent component,
343:                        MultiGuardedSection section, int index) {
344:                    PropertyValue propertyValue = component
345:                            .readProperty(ChoiceGroupCD.PROP_ELEMENTS);
346:                    List<PropertyValue> elementsArray = propertyValue
347:                            .getArray();
348:                    CodeWriter writer = section.getWriter();
349:
350:                    writer.write("new Image[] { "); // NOI18N
351:
352:                    for (int i = 0; i < elementsArray.size(); i++) {
353:                        if (i > 0) {
354:                            writer.write(", "); // NOI18N
355:                        }
356:                        PropertyValue choiceElementValue = elementsArray.get(i);
357:                        DesignComponent choiceElement = choiceElementValue
358:                                .getComponent();
359:                        PropertyValue image = choiceElement
360:                                .readProperty(ChoiceElementCD.PROP_IMAGE);
361:                        MidpCodeSupport.generateCodeForPropertyValue(writer,
362:                                image);
363:                    }
364:
365:                    writer.write(" }"); // NOI18N
366:                }
367:
368:                public boolean isRequiredToBeSet(DesignComponent component) {
369:                    return !component
370:                            .isDefaultValue(ChoiceGroupCD.PROP_ELEMENTS);
371:                }
372:
373:                public int getCount(DesignComponent component) {
374:                    return -1;
375:                }
376:
377:                public boolean isRequiredToBeSet(DesignComponent component,
378:                        int index) {
379:                    throw Debug.illegalState();
380:                }
381:
382:            }
383:
384:            private static class ChoiceTypeParameter extends MidpParameter {
385:
386:                protected ChoiceTypeParameter() {
387:                    super (PARAM_CHOICE_TYPE);
388:                }
389:
390:                @Override
391:                public void generateParameterCode(DesignComponent component,
392:                        MultiGuardedSection section, int index) {
393:                    PropertyValue propertyValue = component
394:                            .readProperty(ChoiceGroupCD.PROP_CHOICE_TYPE);
395:                    if (propertyValue.getKind() == PropertyValue.Kind.VALUE) {
396:                        int value = MidpTypes.getInteger(propertyValue);
397:                        switch (value) {
398:                        case ChoiceSupport.VALUE_EXCLUSIVE:
399:                            section.getWriter().write("Choice.EXCLUSIVE"); // NOI18N
400:                            break;
401:                        case ChoiceSupport.VALUE_MULTIPLE:
402:                            section.getWriter().write("Choice.MULTIPLE"); // NOI18N
403:                            break;
404:                        case ChoiceSupport.VALUE_POPUP:
405:                            section.getWriter().write("Choice.POPUP"); // NOI18N
406:                            break;
407:                        default:
408:                            throw Debug.illegalState();
409:                        }
410:                        return;
411:                    }
412:                    super .generateParameterCode(component, section, index);
413:                }
414:
415:            }
416:
417:            private static class FitPolicyParameter extends MidpParameter {
418:
419:                protected FitPolicyParameter() {
420:                    super (PARAM_FIT_POLICY);
421:                }
422:
423:                @Override
424:                public void generateParameterCode(DesignComponent component,
425:                        MultiGuardedSection section, int index) {
426:                    PropertyValue propertyValue = component
427:                            .readProperty(ChoiceGroupCD.PROP_FIT_POLICY);
428:                    if (propertyValue.getKind() == PropertyValue.Kind.VALUE) {
429:                        int value = MidpTypes.getInteger(propertyValue);
430:                        switch (value) {
431:                        case ChoiceSupport.VALUE_TEXT_WRAP_DEFAULT:
432:                            section.getWriter().write(
433:                                    "Choice.TEXT_WRAP_DEFAULT"); // NOI18N
434:                            break;
435:                        case ChoiceSupport.VALUE_TEXT_WRAP_ON:
436:                            section.getWriter().write("Choice.TEXT_WRAP_ON"); // NOI18N
437:                            break;
438:                        case ChoiceSupport.VALUE_TEXT_WRAP_OFF:
439:                            section.getWriter().write("Choice.TEXT_WRAP_OFF"); // NOI18N
440:                            break;
441:                        default:
442:                            throw Debug.illegalState();
443:                        }
444:                        return;
445:                    }
446:                    super.generateParameterCode(component, section, index);
447:                }
448:
449:            }
450:
451:        }
ww_w__.j__a_v___a_2___s._com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.