Source Code Cross Referenced for ItemCode.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.MultiGuardedSection;
044:        import org.netbeans.modules.vmd.api.codegen.Parameter;
045:        import org.netbeans.modules.vmd.api.model.Debug;
046:        import org.netbeans.modules.vmd.api.model.DesignComponent;
047:        import org.netbeans.modules.vmd.api.model.PropertyValue;
048:        import org.netbeans.modules.vmd.midp.codegen.MidpCodeSupport;
049:        import org.netbeans.modules.vmd.midp.codegen.MidpParameter;
050:        import org.netbeans.modules.vmd.midp.components.MidpTypes;
051:        import org.netbeans.modules.vmd.midp.components.sources.CommandEventSourceCD;
052:        import org.netbeans.modules.vmd.midp.components.sources.ItemCommandEventSourceCD;
053:
054:        import java.util.List;
055:
056:        /**
057:         * @author David Kaspar
058:         */
059:        public class ItemCode {
060:
061:            static final String PARAM_COMMAND = "itemCommand"; // NOI18N
062:            static final String PARAM_ITEM_COMMAND_LISTENER = "itemCommandListener"; // NOI18N
063:            static final String PARAM_LAYOUT = "layout"; // NOI18N
064:            static final String PARAM_APPEARANCE_MODE = "appearanceMode"; // NOI18N
065:            static final String PARAM_DEFAULT_COMMAND = "defaultCommand"; // NOI18N
066:
067:            public static Parameter createCommandParameter() {
068:                return new CommandParameter();
069:            }
070:
071:            public static Parameter createItemCommandListenerParameter() {
072:                return new ItemCommandListenerParameter();
073:            }
074:
075:            public static Parameter createItemLayoutParameter() {
076:                return new ItemLayoutParameter();
077:            }
078:
079:            public static Parameter createAppearanceModeParameter() {
080:                return new AppearanceModeParameter();
081:            }
082:
083:            public static Parameter createDefaultCommandParameter() {
084:                return new DefaultCommandParameter();
085:            }
086:
087:            private static class CommandParameter implements  Parameter {
088:
089:                public String getParameterName() {
090:                    return PARAM_COMMAND;
091:                }
092:
093:                public int getParameterPriority() {
094:                    return 0;
095:                }
096:
097:                public void generateParameterCode(DesignComponent component,
098:                        MultiGuardedSection section, int index) {
099:                    PropertyValue propertyValue = component
100:                            .readProperty(ItemCD.PROP_COMMANDS);
101:                    List<PropertyValue> array = propertyValue.getArray();
102:                    DesignComponent commandEventSource = array.get(index)
103:                            .getComponent();
104:                    MidpCodeSupport.generateCodeForPropertyValue(section
105:                            .getWriter(), commandEventSource
106:                            .readProperty(CommandEventSourceCD.PROP_COMMAND));
107:                }
108:
109:                public boolean isRequiredToBeSet(DesignComponent component) {
110:                    return !component.isDefaultValue(ItemCD.PROP_COMMANDS);
111:                }
112:
113:                public int getCount(DesignComponent component) {
114:                    PropertyValue propertyValue = component
115:                            .readProperty(ItemCD.PROP_COMMANDS);
116:                    List<PropertyValue> array = propertyValue.getArray();
117:                    return array.size();
118:                }
119:
120:                public boolean isRequiredToBeSet(DesignComponent component,
121:                        int index) {
122:                    return true;
123:                }
124:
125:            }
126:
127:            private static class ItemCommandListenerParameter extends
128:                    MidpParameter {
129:
130:                private ItemCommandListenerParameter() {
131:                    super (PARAM_ITEM_COMMAND_LISTENER);
132:                }
133:
134:                @Override
135:                public void generateParameterCode(DesignComponent component,
136:                        MultiGuardedSection section, int index) {
137:                    MidpCodeSupport.generateCodeForPropertyValue(section
138:                            .getWriter(), component
139:                            .readProperty(ItemCD.PROP_ITEM_COMMAND_LISTENER));
140:                }
141:
142:                @Override
143:                public boolean isRequiredToBeSet(DesignComponent component) {
144:                    return !component.isDefaultValue(ItemCD.PROP_COMMANDS);
145:                }
146:
147:            }
148:
149:            private static class ItemLayoutParameter extends MidpParameter {
150:
151:                protected ItemLayoutParameter() {
152:                    super (PARAM_LAYOUT);
153:                }
154:
155:                @Override
156:                public void generateParameterCode(DesignComponent component,
157:                        MultiGuardedSection section, int index) {
158:                    PropertyValue propertyValue = component
159:                            .readProperty(ItemCD.PROP_LAYOUT);
160:                    if (propertyValue.getKind() == PropertyValue.Kind.VALUE) {
161:                        int value = MidpTypes.getInteger(propertyValue);
162:                        switch (value & 3) {
163:                        case ItemCD.VALUE_LAYOUT_DEFAULT:
164:                            section.getWriter().write(
165:                                    "ImageItem.LAYOUT_DEFAULT"); // NOI18N
166:                            break;
167:                        case ItemCD.VALUE_LAYOUT_LEFT:
168:                            section.getWriter().write("ImageItem.LAYOUT_LEFT"); // NOI18N
169:                            break;
170:                        case ItemCD.VALUE_LAYOUT_RIGHT:
171:                            section.getWriter().write("ImageItem.LAYOUT_RIGHT"); // NOI18N
172:                            break;
173:                        case ItemCD.VALUE_LAYOUT_CENTER:
174:                            section.getWriter()
175:                                    .write("ImageItem.LAYOUT_CENTER"); // NOI18N
176:                            break;
177:                        default:
178:                            throw Debug.illegalState();
179:                        }
180:                        if ((value & ItemCD.VALUE_LAYOUT_TOP) != 0)
181:                            section.getWriter().write(" | Item.LAYOUT_TOP"); // NOI18N
182:                        if ((value & ItemCD.VALUE_LAYOUT_BOTTOM) != 0)
183:                            section.getWriter().write(" | Item.LAYOUT_BOTTOM"); // NOI18N
184:                        if ((value & ItemCD.VALUE_LAYOUT_VCENTER) != 0)
185:                            section.getWriter().write(" | Item.LAYOUT_VCENTER"); // NOI18N
186:                        if ((value & ItemCD.VALUE_LAYOUT_NEWLINE_BEFORE) != 0)
187:                            section.getWriter().write(
188:                                    " | ImageItem.LAYOUT_NEWLINE_BEFORE"); // NOI18N
189:                        if ((value & ItemCD.VALUE_LAYOUT_NEWLINE_AFTER) != 0)
190:                            section.getWriter().write(
191:                                    " | ImageItem.LAYOUT_NEWLINE_AFTER"); // NOI18N
192:                        if ((value & ItemCD.VALUE_LAYOUT_SHRINK) != 0)
193:                            section.getWriter().write(" | Item.LAYOUT_SHRINK"); // NOI18N
194:                        if ((value & ItemCD.VALUE_LAYOUT_VSHRINK) != 0)
195:                            section.getWriter().write(" | Item.LAYOUT_VSHRINK"); // NOI18N
196:                        if ((value & ItemCD.VALUE_LAYOUT_EXPAND) != 0)
197:                            section.getWriter().write(" | Item.LAYOUT_EXPAND"); // NOI18N
198:                        if ((value & ItemCD.VALUE_LAYOUT_VEXPAND) != 0)
199:                            section.getWriter().write(" | Item.LAYOUT_VEXPAND"); // NOI18N
200:                        if ((value & ItemCD.VALUE_LAYOUT_2) != 0)
201:                            section.getWriter().write(" | Item.LAYOUT_2"); // NOI18N
202:                        return;
203:                    }
204:                    super .generateParameterCode(component, section, index);
205:                }
206:
207:            }
208:
209:            private static class AppearanceModeParameter extends MidpParameter {
210:
211:                protected AppearanceModeParameter() {
212:                    super (PARAM_APPEARANCE_MODE);
213:                }
214:
215:                @Override
216:                public void generateParameterCode(DesignComponent component,
217:                        MultiGuardedSection section, int index) {
218:                    PropertyValue propertyValue = component
219:                            .readProperty(ItemCD.PROP_APPEARANCE_MODE);
220:                    if (propertyValue.getKind() == PropertyValue.Kind.VALUE) {
221:                        int value = MidpTypes.getInteger(propertyValue);
222:                        switch (value) {
223:                        case ItemCD.VALUE_PLAIN:
224:                            section.getWriter().write("Item.PLAIN"); // NOI18N
225:                            return;
226:                        case ItemCD.VALUE_BUTTON:
227:                            section.getWriter().write("Item.BUTTON"); // NOI18N
228:                            return;
229:                        case ItemCD.VALUE_HYPERLINK:
230:                            section.getWriter().write("Item.HYPERLINK"); // NOI18N
231:                            return;
232:                        default:
233:                            throw Debug.illegalState();
234:                        }
235:                    }
236:                    super .generateParameterCode(component, section, index);
237:                }
238:            }
239:
240:            private static class DefaultCommandParameter implements  Parameter {
241:
242:                public String getParameterName() {
243:                    return PARAM_DEFAULT_COMMAND;
244:                }
245:
246:                public int getParameterPriority() {
247:                    return 0;
248:                }
249:
250:                public void generateParameterCode(DesignComponent component,
251:                        MultiGuardedSection section, int index) {
252:                    MidpCodeSupport.generateCodeForPropertyValue(section
253:                            .getWriter(), getDefaultCommand(component));
254:                }
255:
256:                public boolean isRequiredToBeSet(DesignComponent component) {
257:                    return getDefaultCommand(component).getKind() != PropertyValue.Kind.NULL;
258:                }
259:
260:                public int getCount(DesignComponent component) {
261:                    return -1;
262:                }
263:
264:                public boolean isRequiredToBeSet(DesignComponent component,
265:                        int index) {
266:                    throw Debug.illegalState();
267:                }
268:
269:                private PropertyValue getDefaultCommand(
270:                        DesignComponent component) {
271:                    DesignComponent source = component.readProperty(
272:                            ItemCD.PROP_DEFAULT_COMMAND).getComponent();
273:                    return source != null ? source
274:                            .readProperty(ItemCommandEventSourceCD.PROP_COMMAND)
275:                            : PropertyValue.createNull();
276:                }
277:
278:            }
279:
280:        }
w_ww.___ja___v___a_2___s_.co_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.