Source Code Cross Referenced for ConverterItems.java in  » IDE-Netbeans » vmd.analyzer » org » netbeans » modules » vmd » midp » converter » wizard » 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.converter.wizard 
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:         */package org.netbeans.modules.vmd.midp.converter.wizard;
041:
042:        import org.netbeans.modules.vmd.api.model.Debug;
043:        import org.netbeans.modules.vmd.api.model.DesignComponent;
044:        import org.netbeans.modules.vmd.api.model.DesignDocument;
045:        import org.netbeans.modules.vmd.api.model.PropertyValue;
046:        import org.netbeans.modules.vmd.api.model.common.DocumentSupport;
047:        import org.netbeans.modules.vmd.api.model.support.ArraySupport;
048:        import org.netbeans.modules.vmd.midp.components.MidpDocumentSupport;
049:        import org.netbeans.modules.vmd.midp.components.MidpTypes;
050:        import org.netbeans.modules.vmd.midp.components.items.*;
051:        import org.netbeans.modules.vmd.midp.components.sources.ItemCommandEventSourceCD;
052:
053:        import java.util.ArrayList;
054:        import java.util.HashMap;
055:        import java.util.List;
056:
057:        /**
058:         * @author David Kaspar
059:         */
060:        public class ConverterItems {
061:
062:            // Created: NO, Adds: NO
063:            static void convertItem(HashMap<String, ConverterItem> id2item,
064:                    ConverterItem itemItem, DesignComponent itemComponent) {
065:                Converter.convertClass(itemItem, itemComponent);
066:                DesignDocument document = itemComponent.getDocument();
067:
068:                ConverterUtil.convertStringWithUserCode(itemComponent,
069:                        ItemCD.PROP_LABEL, itemItem.getPropertyValue("label")); // NOI18N
070:                ConverterUtil.convertInteger(itemComponent,
071:                        ItemCD.PROP_PREFERRED_WIDTH, itemItem
072:                                .getPropertyValue("preferredSizeX")); // NOI18N
073:                ConverterUtil.convertInteger(itemComponent,
074:                        ItemCD.PROP_PREFERRED_HEIGHT, itemItem
075:                                .getPropertyValue("preferredSizeY")); // NOI18N
076:                ConverterUtil.convertInteger(itemComponent, ItemCD.PROP_LAYOUT,
077:                        itemItem.getPropertyValue("layout")); // NOI18N
078:
079:                ArrayList<String> commandsList = itemItem
080:                        .getContainerPropertyValue("commands"); // NOI18N
081:                if (commandsList != null)
082:                    for (String commandValue : commandsList) {
083:                        ConverterItem commandActionItem = id2item
084:                                .get(commandValue);
085:                        if (commandActionItem == null)
086:                            continue;
087:                        ConverterActions.convertCommandAction(id2item,
088:                                commandActionItem, document);
089:                        DesignComponent eventSource = commandActionItem
090:                                .getRelatedComponent();
091:                        if (eventSource != null) {
092:                            MidpDocumentSupport.addEventSource(itemComponent,
093:                                    ItemCD.PROP_COMMANDS, eventSource);
094:                            eventSource
095:                                    .writeProperty(
096:                                            ItemCommandEventSourceCD.PROP_ITEM,
097:                                            PropertyValue
098:                                                    .createComponentReference(itemComponent));
099:                        } else
100:                            Debug.warning("Unrecognized command", itemItem,
101:                                    commandValue); // NOI18N
102:                    }
103:
104:                if (itemItem.isPropertyValueSet("defaultCommand")) { // NOI18N
105:                    DesignComponent defaultCommand = Converter
106:                            .convertConverterItemComponent(id2item, itemItem
107:                                    .getPropertyValue("defaultCommand"),
108:                                    document); // NOI18N
109:                    if (defaultCommand != null) {
110:                        List<DesignComponent> commandEventSources = DocumentSupport
111:                                .gatherSubComponentsOfType(itemComponent,
112:                                        ItemCommandEventSourceCD.TYPEID);
113:                        for (DesignComponent commandEventSource : commandEventSources) {
114:                            DesignComponent foundCommand = commandEventSource
115:                                    .readProperty(
116:                                            ItemCommandEventSourceCD.PROP_COMMAND)
117:                                    .getComponent();
118:                            if (defaultCommand == foundCommand) {
119:                                itemComponent
120:                                        .writeProperty(
121:                                                ItemCD.PROP_DEFAULT_COMMAND,
122:                                                PropertyValue
123:                                                        .createComponentReference(commandEventSource));
124:                                break;
125:                            }
126:                        }
127:                        Debug.warning("defaultCommand not found for", itemItem,
128:                                itemItem.getPropertyValue("defaultCommand")); // NOI18N
129:                    }
130:                }
131:            }
132:
133:            // Created: YES, Adds: NO
134:            static void convertGauge(HashMap<String, ConverterItem> id2item,
135:                    ConverterItem item, DesignDocument document) {
136:                convertGaugeCore(id2item, item, document
137:                        .createComponent(GaugeCD.TYPEID));
138:            }
139:
140:            // Created: NO, Adds: NO
141:            static void convertGaugeCore(
142:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
143:                    DesignComponent gauge) {
144:                convertItem(id2item, item, gauge);
145:
146:                ConverterUtil.convertBoolean(gauge, GaugeCD.PROP_INTERACTIVE,
147:                        item.getPropertyValue("interactive")); // NOI18N
148:                ConverterUtil.convertInteger(gauge, GaugeCD.PROP_VALUE, item
149:                        .getPropertyValue("value")); // NOI18N
150:                ConverterUtil.convertInteger(gauge, GaugeCD.PROP_MAX_VALUE,
151:                        item.getPropertyValue("maxValue")); // NOI18N
152:            }
153:
154:            // Created: YES, Adds: NO
155:            static void convertAlertIndicator(
156:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
157:                    DesignDocument document) {
158:                convertGauge(id2item, item, document);
159:
160:                DesignComponent gauge = item.getRelatedComponent();
161:                gauge.writeProperty(GaugeCD.PROP_USED_BY_ALERT, MidpTypes
162:                        .createBooleanValue(true));
163:            }
164:
165:            // Created: YES, Adds: NO
166:            static void convertSpacer(HashMap<String, ConverterItem> id2item,
167:                    ConverterItem item, DesignDocument document) {
168:                convertSpacerCore(id2item, item, document
169:                        .createComponent(SpacerCD.TYPEID));
170:            }
171:
172:            // Created: NO, Adds: NO
173:            static void convertSpacerCore(
174:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
175:                    DesignComponent spacer) {
176:                convertItem(id2item, item, spacer);
177:
178:                ConverterUtil.convertInteger(spacer, SpacerCD.PROP_MIN_WIDTH,
179:                        item.getPropertyValue("minWidth")); // NOI18N
180:                ConverterUtil.convertInteger(spacer, SpacerCD.PROP_MIN_HEIGHT,
181:                        item.getPropertyValue("minHeight")); // NOI18N
182:            }
183:
184:            // Created: YES, Adds: NO
185:            static void convertStringItem(
186:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
187:                    DesignDocument document) {
188:                convertStringItemCore(id2item, item, document
189:                        .createComponent(StringItemCD.TYPEID));
190:            }
191:
192:            // Created: NO, Adds: NO
193:            static void convertStringItemCore(
194:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
195:                    DesignComponent stringComponent) {
196:                convertItem(id2item, item, stringComponent);
197:
198:                ConverterUtil.convertStringWithUserCode(stringComponent,
199:                        StringItemCD.PROP_TEXT, item.getPropertyValue("text")); // NOI18N
200:
201:                ConverterUtil.convertConverterItemComponent(stringComponent,
202:                        StringItemCD.PROP_FONT, id2item, item
203:                                .getPropertyValue("font"));// NOI18N
204:
205:                String apperanceMode = item.getPropertyValue("appearanceMode");// NOI18N
206:                if ("PLAIN".equals(apperanceMode)) // NOI18N
207:                    stringComponent.writeProperty(ItemCD.PROP_APPEARANCE_MODE,
208:                            MidpTypes.createIntegerValue(ItemCD.VALUE_PLAIN));
209:                else if ("BUTTON".equals(apperanceMode)) // NOI18N
210:                    stringComponent.writeProperty(ItemCD.PROP_APPEARANCE_MODE,
211:                            MidpTypes.createIntegerValue(ItemCD.VALUE_BUTTON));
212:                else if ("HYPERLINK".equals(apperanceMode)) // NOI18N
213:                    stringComponent
214:                            .writeProperty(
215:                                    ItemCD.PROP_APPEARANCE_MODE,
216:                                    MidpTypes
217:                                            .createIntegerValue(ItemCD.VALUE_HYPERLINK));
218:            }
219:
220:            // Created: YES, Adds: NO
221:            static void convertImageItem(
222:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
223:                    DesignDocument document) {
224:                convertImageItemCore(id2item, item, document
225:                        .createComponent(ImageItemCD.TYPEID));
226:            }
227:
228:            // Created: NO, Adds: NO
229:            static void convertImageItemCore(
230:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
231:                    DesignComponent imageComponent) {
232:                convertItem(id2item, item, imageComponent);
233:
234:                ConverterUtil.convertStringWithUserCode(imageComponent,
235:                        ImageItemCD.PROP_ALT_TEXT, item
236:                                .getPropertyValue("altText")); // NOI18N
237:
238:                ConverterUtil.convertConverterItemComponent(imageComponent,
239:                        ImageItemCD.PROP_IMAGE, id2item, item
240:                                .getPropertyValue("image"));// NOI18N
241:
242:                String apperanceMode = item.getPropertyValue("appearanceMode");// NOI18N
243:                if ("PLAIN".equals(apperanceMode)) // NOI18N
244:                    imageComponent.writeProperty(ItemCD.PROP_APPEARANCE_MODE,
245:                            MidpTypes.createIntegerValue(ItemCD.VALUE_PLAIN));
246:                else if ("BUTTON".equals(apperanceMode)) // NOI18N
247:                    imageComponent.writeProperty(ItemCD.PROP_APPEARANCE_MODE,
248:                            MidpTypes.createIntegerValue(ItemCD.VALUE_BUTTON));
249:                else if ("HYPERLINK".equals(apperanceMode)) // NOI18N
250:                    imageComponent
251:                            .writeProperty(
252:                                    ItemCD.PROP_APPEARANCE_MODE,
253:                                    MidpTypes
254:                                            .createIntegerValue(ItemCD.VALUE_HYPERLINK));
255:            }
256:
257:            // Created: YES, Adds: NO
258:            static void convertTextField(
259:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
260:                    DesignDocument document) {
261:                convertTextFieldCore(id2item, item, document
262:                        .createComponent(TextFieldCD.TYPEID));
263:            }
264:
265:            // Created: NO, Adds: NO
266:            static void convertTextFieldCore(
267:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
268:                    DesignComponent textField) {
269:                convertItem(id2item, item, textField);
270:
271:                ConverterUtil.convertInteger(textField,
272:                        TextFieldCD.PROP_CONSTRAINTS, item
273:                                .getPropertyValue("constraints")); // NOI18N
274:                ConverterUtil.convertString(textField,
275:                        TextFieldCD.PROP_INITIAL_INPUT_MODE, item
276:                                .getPropertyValue("initialInputMode")); // NOI18N
277:                ConverterUtil.convertInteger(textField,
278:                        TextFieldCD.PROP_CONSTRAINTS, item
279:                                .getPropertyValue("maxSize")); // NOI18N
280:                ConverterUtil.convertStringWithUserCode(textField,
281:                        TextFieldCD.PROP_INITIAL_INPUT_MODE, item
282:                                .getPropertyValue("string")); // NOI18N
283:            }
284:
285:            // Created: YES, Adds: NO
286:            static void convertDateField(
287:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
288:                    DesignDocument document) {
289:                convertDateFieldCore(id2item, item, document
290:                        .createComponent(DateFieldCD.TYPEID));
291:            }
292:
293:            // Created: NO, Adds: NO
294:            static void convertDateFieldCore(
295:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
296:                    DesignComponent dateField) {
297:                convertItem(id2item, item, dateField);
298:
299:                String inputMode = item.getPropertyValue("inputMode");// NOI18N
300:                if ("DATE".equals(inputMode)) // NOI18N
301:                    dateField
302:                            .writeProperty(
303:                                    DateFieldCD.PROP_INPUT_MODE,
304:                                    MidpTypes
305:                                            .createIntegerValue(DateFieldCD.VALUE_DATE));
306:                else if ("DATE_TIME".equals(inputMode)) // NOI18N
307:                    dateField
308:                            .writeProperty(
309:                                    DateFieldCD.PROP_INPUT_MODE,
310:                                    MidpTypes
311:                                            .createIntegerValue(DateFieldCD.VALUE_DATE_TIME));
312:                else if ("TIME".equals(inputMode)) // NOI18N
313:                    dateField
314:                            .writeProperty(
315:                                    DateFieldCD.PROP_INPUT_MODE,
316:                                    MidpTypes
317:                                            .createIntegerValue(DateFieldCD.VALUE_TIME));
318:            }
319:
320:            // Created: YES, Adds: NO
321:            static void convertChoiceGroup(
322:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
323:                    DesignDocument document) {
324:                convertChoiceGroupCore(id2item, item, document
325:                        .createComponent(ChoiceGroupCD.TYPEID));
326:            }
327:
328:            // Created: NO, Adds: NO
329:            static void convertChoiceGroupCore(
330:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
331:                    DesignComponent choiceGroup) {
332:                convertItem(id2item, item, choiceGroup);
333:
334:                String choiceTypeValue = item.getPropertyValue("choiceType"); // NOI18N
335:                if ("EXCLUSIVE".equals(choiceTypeValue)) // NOI18N
336:                    choiceGroup
337:                            .writeProperty(
338:                                    ChoiceGroupCD.PROP_CHOICE_TYPE,
339:                                    MidpTypes
340:                                            .createIntegerValue(ChoiceSupport.VALUE_EXCLUSIVE));
341:                else if ("IMPLICIT".equals(choiceTypeValue)) // NOI18N
342:                    choiceGroup
343:                            .writeProperty(
344:                                    ChoiceGroupCD.PROP_CHOICE_TYPE,
345:                                    MidpTypes
346:                                            .createIntegerValue(ChoiceSupport.VALUE_IMPLICIT));
347:                else if ("MULTIPLE".equals(choiceTypeValue)) // NOI18N
348:                    choiceGroup
349:                            .writeProperty(
350:                                    ChoiceGroupCD.PROP_CHOICE_TYPE,
351:                                    MidpTypes
352:                                            .createIntegerValue(ChoiceSupport.VALUE_MULTIPLE));
353:                else if ("POPUP".equals(choiceTypeValue)) // NOI18N
354:                    choiceGroup
355:                            .writeProperty(
356:                                    ChoiceGroupCD.PROP_CHOICE_TYPE,
357:                                    MidpTypes
358:                                            .createIntegerValue(ChoiceSupport.VALUE_POPUP));
359:
360:                String fitPolicyValue = item.getPropertyValue("fitPolicy"); // NOI18N
361:                if ("TEXT_WRAP_DEFAULT".equals(fitPolicyValue)) // NOI18N
362:                    choiceGroup
363:                            .writeProperty(
364:                                    ChoiceGroupCD.PROP_FIT_POLICY,
365:                                    MidpTypes
366:                                            .createIntegerValue(ChoiceSupport.VALUE_TEXT_WRAP_DEFAULT));
367:                else if ("TEXT_WRAP_OFF".equals(fitPolicyValue)) // NOI18N
368:                    choiceGroup
369:                            .writeProperty(
370:                                    ChoiceGroupCD.PROP_FIT_POLICY,
371:                                    MidpTypes
372:                                            .createIntegerValue(ChoiceSupport.VALUE_TEXT_WRAP_OFF));
373:                else if ("TEXT_WRAP_ON".equals(fitPolicyValue)) // NOI18N
374:                    choiceGroup
375:                            .writeProperty(
376:                                    ChoiceGroupCD.PROP_FIT_POLICY,
377:                                    MidpTypes
378:                                            .createIntegerValue(ChoiceSupport.VALUE_TEXT_WRAP_ON));
379:
380:                ArrayList<String> elementsList = item
381:                        .getContainerPropertyValue("elements"); // NOI18N
382:                if (elementsList != null)
383:                    for (String elementValue : elementsList) {
384:                        DesignComponent choiceElement = Converter
385:                                .convertConverterItemComponent(id2item,
386:                                        elementValue, choiceGroup.getDocument());
387:                        if (choiceElement == null) {
388:                            Debug.warning("ChoiceElement not found",
389:                                    elementValue); // NOI18N
390:                            continue;
391:                        }
392:                        choiceGroup.addComponent(choiceElement);
393:                        ArraySupport.append(choiceGroup,
394:                                ChoiceGroupCD.PROP_ELEMENTS, choiceElement);
395:                    }
396:            }
397:
398:            // Created: NO, Adds: NO
399:            static void convertCustomItem(
400:                    HashMap<String, ConverterItem> id2item, ConverterItem item,
401:                    DesignComponent custom) {
402:                convertItem(id2item, item, custom);
403:            }
404:
405:        }
w__w__w__.___j__a___v__a_2s.___c__o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.