Source Code Cross Referenced for CommandCD.java in  » IDE-Netbeans » vmd.analyzer » org » netbeans » modules » vmd » midp » components » commands » 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.commands 
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.commands;
042:
043:        import org.netbeans.modules.vmd.api.codegen.CodeSetterPresenter;
044:        import org.netbeans.modules.vmd.api.codegen.MultiGuardedSection;
045:        import org.netbeans.modules.vmd.api.inspector.InspectorFolderComponentPresenter;
046:        import org.netbeans.modules.vmd.api.inspector.InspectorPositionPresenter;
047:        import org.netbeans.modules.vmd.api.inspector.common.FolderPositionControllerFactory;
048:        import org.netbeans.modules.vmd.api.model.*;
049:        import org.netbeans.modules.vmd.api.properties.DefaultPropertiesPresenter;
050:        import org.netbeans.modules.vmd.api.screen.actions.EditDependencyPresenter;
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.components.general.ClassCD;
057:        import org.netbeans.modules.vmd.midp.propertyeditors.MidpPropertiesCategories;
058:        import org.netbeans.modules.vmd.midp.propertyeditors.PropertyEditorComboBox;
059:        import org.netbeans.modules.vmd.midp.propertyeditors.PropertyEditorNumber;
060:        import org.netbeans.modules.vmd.midp.propertyeditors.PropertyEditorString;
061:        import org.openide.util.NbBundle;
062:
063:        import java.util.Arrays;
064:        import java.util.List;
065:        import java.util.Map;
066:        import java.util.TreeMap;
067:
068:        /**
069:         * @author David Kaspar
070:         */
071:
072:        public final class CommandCD extends ComponentDescriptor {
073:
074:            public static final TypeID TYPEID = new TypeID(
075:                    TypeID.Kind.COMPONENT, "javax.microedition.lcdui.Command"); // NOI18N
076:
077:            public static final String ICON_PATH = "org/netbeans/modules/vmd/midp/resources/components/command_16.png"; // NOI18N
078:            public static final String LARGE_ICON_PATH = "org/netbeans/modules/vmd/midp/resources/components/command_32.png"; // NOI18N
079:
080:            public static final int VALUE_SCREEN = 1;
081:            public static final int VALUE_BACK = 2;
082:            public static final int VALUE_CANCEL = 3;
083:            public static final int VALUE_OK = 4;
084:            public static final int VALUE_HELP = 5;
085:            public static final int VALUE_STOP = 6;
086:            public static final int VALUE_EXIT = 7;
087:            public static final int VALUE_ITEM = 8;
088:
089:            public static final String PROP_LABEL = "label"; // NOI18N
090:            public static final String PROP_LONG_LABEL = "longLabel"; // NOI18N
091:            public static final String PROP_TYPE = "type"; // NOI18N
092:            public static final String PROP_PRIORITY = "priority"; // NOI18N
093:            public static final String PROP_ORDINARY = "ordinary"; // NOI18N
094:
095:            private static Map<String, PropertyValue> typeValues;
096:
097:            static {
098:                MidpTypes.registerIconResource(TYPEID, ICON_PATH);
099:            }
100:
101:            public TypeDescriptor getTypeDescriptor() {
102:                return new TypeDescriptor(ClassCD.TYPEID, TYPEID, true, true);
103:            }
104:
105:            public VersionDescriptor getVersionDescriptor() {
106:                return MidpVersionDescriptor.MIDP;
107:            }
108:
109:            public List<PropertyDescriptor> getDeclaredPropertyDescriptors() {
110:                return Arrays.asList(new PropertyDescriptor(PROP_LABEL,
111:                        MidpTypes.TYPEID_JAVA_LANG_STRING, PropertyValue
112:                                .createNull(), false, true,
113:                        MidpVersionable.MIDP), new PropertyDescriptor(
114:                        PROP_LONG_LABEL, MidpTypes.TYPEID_JAVA_LANG_STRING,
115:                        PropertyValue.createNull(), true, true,
116:                        MidpVersionable.MIDP_2), new PropertyDescriptor(
117:                        PROP_TYPE, MidpTypes.TYPEID_INT, PropertyValue
118:                                .createNull(), false, true,
119:                        MidpVersionable.MIDP), new PropertyDescriptor(
120:                        PROP_PRIORITY, MidpTypes.TYPEID_INT, MidpTypes
121:                                .createIntegerValue(0), false, true,
122:                        MidpVersionable.MIDP), new PropertyDescriptor(
123:                        PROP_ORDINARY, MidpTypes.TYPEID_BOOLEAN, MidpTypes
124:                                .createBooleanValue(true), false, false,
125:                        Versionable.FOREVER));
126:            }
127:
128:            private static DefaultPropertiesPresenter createPropertiesPresenter() {
129:                return new DefaultPropertiesPresenter().addPropertiesCategory(
130:                        MidpPropertiesCategories.CATEGORY_PROPERTIES)
131:                        .addProperty(
132:                                NbBundle.getMessage(CommandCD.class,
133:                                        "DISP_Command_Label"), // NOI18N
134:                                PropertyEditorString
135:                                        .createTextFieldInstance(NbBundle
136:                                                .getMessage(CommandCD.class,
137:                                                        "LBL_Command_Label")),
138:                                PROP_LABEL) // NOI18N
139:                        .addProperty(
140:                                NbBundle.getMessage(CommandCD.class,
141:                                        "DISP_Command_Long_Label"), // NOI18N
142:                                PropertyEditorString.createInstance(NbBundle
143:                                        .getMessage(CommandCD.class,
144:                                                "LBL_Command_Long_Label")),
145:                                PROP_LONG_LABEL) // NOI18N
146:                        .addProperty(
147:                                NbBundle.getMessage(CommandCD.class,
148:                                        "DISP_Command_Type"), // NOI18N
149:                                PropertyEditorComboBox.createInstance(
150:                                        getTypes(), TYPEID,
151:                                        NbBundle.getMessage(CommandCD.class,
152:                                                "DISP_Command_Type_RB_LABEL"), // NOI18N
153:                                        NbBundle.getMessage(CommandCD.class,
154:                                                "DISP_Command_Type_UCLABEL")),
155:                                PROP_TYPE) // NOI18N
156:                        .addProperty(
157:                                NbBundle.getMessage(CommandCD.class,
158:                                        "DISP_Command_Priority"), // NOI18N
159:                                PropertyEditorNumber.createIntegerInstance(
160:                                        false, NbBundle.getMessage(
161:                                                CommandCD.class,
162:                                                "LBL_Command_Priority")),
163:                                PROP_PRIORITY); // NOI18N
164:            }
165:
166:            public static Map<String, PropertyValue> getTypes() {
167:                if (typeValues == null) {
168:                    typeValues = new TreeMap<String, PropertyValue>();
169:                    typeValues.put("SCREEN", MidpTypes
170:                            .createIntegerValue(VALUE_SCREEN)); // NOI18N
171:                    typeValues.put("BACK", MidpTypes
172:                            .createIntegerValue(VALUE_BACK)); // NOI18N
173:                    typeValues.put("CANCEL", MidpTypes
174:                            .createIntegerValue(VALUE_CANCEL)); // NOI18N
175:                    typeValues
176:                            .put("OK", MidpTypes.createIntegerValue(VALUE_OK)); // NOI18N
177:                    typeValues.put("HELP", MidpTypes
178:                            .createIntegerValue(VALUE_HELP)); // NOI18N
179:                    typeValues.put("STOP", MidpTypes
180:                            .createIntegerValue(VALUE_STOP)); // NOI18N
181:                    typeValues.put("EXIT", MidpTypes
182:                            .createIntegerValue(VALUE_EXIT)); // NOI18N
183:                    typeValues.put("ITEM", MidpTypes
184:                            .createIntegerValue(VALUE_ITEM)); // NOI18N
185:                }
186:
187:                return typeValues;
188:            }
189:
190:            private static Presenter createSetterPresenter() {
191:                return new CodeSetterPresenter().addParameters(
192:                        MidpParameter.create(PROP_LABEL, PROP_LONG_LABEL,
193:                                PROP_PRIORITY)).addParameters(
194:                        new CodeCommandTypeParameter()).addSetters(
195:                        MidpSetter.createConstructor(TYPEID,
196:                                MidpVersionable.MIDP).addParameters(PROP_LABEL,
197:                                PROP_TYPE, PROP_PRIORITY)).addSetters(
198:                        MidpSetter.createConstructor(TYPEID,
199:                                MidpVersionable.MIDP_2).addParameters(
200:                                PROP_LABEL, PROP_LONG_LABEL, PROP_TYPE,
201:                                PROP_PRIORITY));
202:            }
203:
204:            protected List<? extends Presenter> createPresenters() {
205:                return Arrays.asList(
206:                        // properties
207:                        createPropertiesPresenter(),
208:                        // action
209:                        EditDependencyPresenter.createEditablePresenter(),
210:                        // inspector
211:                        new InspectorFolderComponentPresenter(true),
212:                        InspectorPositionPresenter
213:                                .create(FolderPositionControllerFactory
214:                                        .createHierarchical()),
215:                        // code
216:                        createSetterPresenter());
217:            }
218:
219:            private static class CodeCommandTypeParameter extends MidpParameter {
220:
221:                public static final String PARAM = "type"; // NOI18N
222:
223:                protected CodeCommandTypeParameter() {
224:                    super (PARAM);
225:                }
226:
227:                @Override
228:                public void generateParameterCode(DesignComponent component,
229:                        MultiGuardedSection section, int index) {
230:                    PropertyValue propertyValue = component
231:                            .readProperty(PROP_TYPE);
232:                    if (propertyValue.getKind() == PropertyValue.Kind.VALUE) {
233:                        int i = MidpTypes.getInteger(propertyValue);
234:                        switch (i) {
235:                        case VALUE_SCREEN:
236:                            section.getWriter().write("Command.SCREEN");
237:                            return; // NOI18N
238:                        case VALUE_BACK:
239:                            section.getWriter().write("Command.BACK");
240:                            return; // NOI18N
241:                        case VALUE_CANCEL:
242:                            section.getWriter().write("Command.CANCEL");
243:                            return; // NOI18N
244:                        case VALUE_OK:
245:                            section.getWriter().write("Command.OK");
246:                            return; // NOI18N
247:                        case VALUE_HELP:
248:                            section.getWriter().write("Command.HELP");
249:                            return; // NOI18N
250:                        case VALUE_STOP:
251:                            section.getWriter().write("Command.STOP");
252:                            return; // NOI18N
253:                        case VALUE_EXIT:
254:                            section.getWriter().write("Command.EXIT");
255:                            return; // NOI18N
256:                        case VALUE_ITEM:
257:                            section.getWriter().write("Command.ITEM");
258:                            return; // NOI18N
259:                        }
260:                    }
261:                    super .generateParameterCode(component, section, index);
262:                }
263:
264:                @Override
265:                public boolean isRequiredToBeSet(DesignComponent component) {
266:                    return true;
267:                }
268:
269:            }
270:
271:        }
w_w__w._j__a___v___a2s.c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.