Source Code Cross Referenced for FormCmd.java in  » Scripting » hecl » org » hecl » midp20 » lcdui » 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 » Scripting » hecl » org.hecl.midp20.lcdui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007
003:         * Wolfgang S. Kechel, data2c GmbH (www.data2c.com)
004:         * 
005:         * Author: Wolfgang S. Kechel - wolfgang.kechel@data2c.com
006:         *
007:         * Licensed under the Apache License, Version 2.0 (the "License");
008:         * you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at
010:         * 
011:         * http://www.apache.org/licenses/LICENSE-2.0
012:         * 
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License.
018:         */
019:
020:        package org.hecl.midp20.lcdui;
021:
022:        import java.util.Vector;
023:        import javax.microedition.lcdui.Command;
024:        import javax.microedition.lcdui.Display;
025:        import javax.microedition.lcdui.Form;
026:        import javax.microedition.lcdui.Image;
027:        import javax.microedition.lcdui.Item;
028:        import javax.microedition.lcdui.ItemStateListener;
029:
030:        import org.hecl.HeclException;
031:        import org.hecl.Interp;
032:        import org.hecl.IntThing;
033:        import org.hecl.ListThing;
034:        import org.hecl.ObjectThing;
035:        import org.hecl.Properties;
036:        import org.hecl.RealThing;
037:        import org.hecl.StringThing;
038:        import org.hecl.Thing;
039:
040:        import org.hecl.midp20.MidletCmd;
041:        import org.hecl.misc.HeclUtils;
042:
043:        public class FormCmd extends ScreenCmd {
044:            public static void load(Interp ip) {
045:                ip.addCommand(CMDNAME, cmd);
046:                ip.addClassCmd(Form.class, cmd);
047:            }
048:
049:            public static void unload(Interp ip) {
050:                ip.removeCommand(CMDNAME);
051:                ip.removeClassCmd(Form.class);
052:            }
053:
054:            public Thing cmdCode(Interp interp, Thing[] argv)
055:                    throws HeclException {
056:                Properties p = WidgetInfo.defaultProps(Form.class);
057:                p.setProps(argv, 1);
058:                Form w = new Form(null);
059:                return ObjectThing.create(setInstanceProperties(interp, w, p));
060:            }
061:
062:            protected FormCmd() {
063:            }
064:
065:            public Thing cget(Interp ip, Object target, String optname)
066:                    throws HeclException {
067:                Form f = (Form) target;
068:
069:                return super .cget(ip, target, optname);
070:            }
071:
072:            public void cset(Interp ip, Object target, String optname,
073:                    Thing optval) throws HeclException {
074:                Form f = (Form) target;
075:
076:                if (optname.equals("-itemstatehandler")) {
077:                    ItemStateListener listener = null;
078:                    if (optval.toString().length() > 0)
079:                        listener = new WidgetListener(ip, optval, f);
080:                    f.setItemStateListener(listener);
081:                    return;
082:                }
083:                super .cset(ip, target, optname, optval);
084:            }
085:
086:            //#ifdef notdef
087:            public void itemcreate(Interp ip, String what, Thing[] argv,
088:                    int startat) throws HeclException {
089:                Form f = getForm();
090:                FormGadget g = null;
091:                Properties p = null;
092:
093:                if (what.equals("choice")) {
094:                    p = WidgetInfo.defaultProps(ChoiceGroup.class);
095:                    p.setProps(argv, startat);
096:                    g = new ChoiceGadget(p.getProp(WidgetInfo.NLABEL)
097:                            .toString(), WidgetInfo.toChoiceType(p
098:                            .getProp(WidgetInfo.NTYPE)), this );
099:                    p.delProp(WidgetInfo.NLABEL);
100:                    p.delProp(WidgetInfo.NTYPE);
101:                } else if (what.equals("date")) {
102:                    p = WidgetInfo.defaultProps(DateField.class);
103:                    p.setProps(argv, startat);
104:                    g = new DateGadget(p.getProp(WidgetInfo.NLABEL).toString(),
105:                            WidgetInfo.toDateFieldMode(p
106:                                    .getProp(WidgetInfo.NTYPE)), this );
107:                } else if (what.equals("gauge")) {
108:                    p = WidgetInfo.defaultProps(Gauge.class);
109:                    p.setProps(argv, startat);
110:                    //#ifdef notdef
111:                    System.err.println("GAUGE");
112:                    System.err
113:                            .println("gauge: "
114:                                    + p.getProp(WidgetInfo.NLABEL).toString()
115:                                    + ", "
116:                                    + p.getProp(WidgetInfo.NINTERACTIVE)
117:                                            .toString()
118:                                    + ", "
119:                                    + p.getProp(WidgetInfo.NVALUE).toString()
120:                                    + ", "
121:                                    + p.getProp(WidgetInfo.NMAXVALUE)
122:                                            .toString());
123:                    System.err.println("GAUGE2");
124:                    //#endif		
125:                    g = new GaugeGadget(
126:                            p.getProp(WidgetInfo.NLABEL).toString(), HeclUtils
127:                                    .thing2bool(p
128:                                            .getProp(WidgetInfo.NINTERACTIVE)),
129:                            WidgetInfo.toGaugeInitial(p
130:                                    .getProp(WidgetInfo.NVALUE)),
131:                            WidgetInfo.toGaugeMax(p
132:                                    .getProp(WidgetInfo.NMAXVALUE)), this );
133:                    p.delProp(WidgetInfo.NINTERACTIVE);
134:                } else if (what.equals("image")) {
135:                    p = WidgetInfo.defaultProps(ImageItem.class);
136:                    p.setProps(argv, startat);
137:                    g = new ImageGadget(
138:                            p.getProp(WidgetInfo.NLABEL).toString(), p.getProp(
139:                                    WidgetInfo.NTEXT).toString(), WidgetInfo
140:                                    .toItemAppearance(p
141:                                            .getProp(WidgetInfo.NAPPEARANCE)),
142:                            this );
143:                    p.delProp(WidgetInfo.NLABEL);
144:                    p.delProp(WidgetInfo.NTEXT);
145:                    p.delProp(WidgetInfo.NAPPEARANCE);
146:                } else if (what.equals("spacer")) {
147:                    p = WidgetInfo.defaultProps(Spacer.class);
148:                    p.setProps(argv, startat);
149:                    g = new SpacerGadget(IntThing.get(p
150:                            .getProp(WidgetInfo.NMINWIDTH)), IntThing.get(p
151:                            .getProp(WidgetInfo.NMINHEIGHT)), this );
152:                    p.delProp(WidgetInfo.NMINWIDTH);
153:                    p.delProp(WidgetInfo.NMINHEIGHT);
154:                } else if (what.equals("string")) {
155:                    p = WidgetInfo.defaultProps(StringItem.class);
156:                    p.setProps(argv, startat);
157:                    g = new StringGadget(p.getProp(WidgetInfo.NLABEL)
158:                            .toString(), WidgetInfo.toItemAppearance(p
159:                            .getProp(WidgetInfo.NAPPEARANCE)), this );
160:                    p.delProp(WidgetInfo.NLABEL);
161:                    p.delProp(WidgetInfo.NAPPEARANCE);
162:                } else if (what.equals("text")) {
163:                    p = WidgetInfo.defaultProps(TextField.class);
164:                    p.setProps(argv, startat);
165:                    g = new TextGadget(p.getProp(WidgetInfo.NLABEL).toString(),
166:                            HeclUtils.thing2len(p.getProp(WidgetInfo.NMAXLEN),
167:                                    1), WidgetInfo.toTextType(p
168:                                    .getProp(WidgetInfo.NTYPE)), this );
169:                    p.delProp(WidgetInfo.NTITLE);
170:                    p.delProp(WidgetInfo.NMAXLEN);
171:                    p.delProp(WidgetInfo.NTYPE);
172:                } else {
173:                    throw new HeclException("Unknown item type '" + what + "'.");
174:                }
175:
176:                if (g == null) {
177:                    throw new HeclException("Cannot create item '" + what
178:                            + "'.");
179:                }
180:                Thing optargs[] = p.getProps();
181:                g.configure(ip, optargs, 0, optargs.length);
182:                g.getItem().setItemCommandListener(myitemcmdlistener);
183:                ip.setResult(append(g));
184:            }
185:
186:            //#endif
187:
188:            public Thing handlecmd(Interp ip, Object target, String subcmd,
189:                    Thing[] argv, int startat) throws HeclException {
190:                Form f = (Form) target;
191:
192:                int n = startat + 1;
193:
194:                if (subcmd.equals(WidgetInfo.NSIZE))
195:                    return IntThing.create(f.size());
196:                if (subcmd.equals(WidgetInfo.NAPPEND)) {
197:                    if (argv.length < n) {
198:                        throw HeclException.createWrongNumArgsException(argv,
199:                                n, "append item|string|image");
200:                    }
201:                    // append <item|string|image>
202:                    Thing arg = argv[startat];
203:                    RealThing rt = arg.getVal();
204:                    try {
205:                        if (rt instanceof  ObjectThing) {
206:                            if (((ObjectThing) rt).get() != null) {
207:                                Item item = WidgetInfo
208:                                        .asItem(arg, false, false);
209:                                if (item != null) {
210:                                    f.append(item);
211:                                } else {
212:                                    Image im = WidgetInfo.asImage(arg, false,
213:                                            false);
214:                                    if (im != null)
215:                                        f.append(im);
216:                                }
217:                            } else {
218:                                throw new HeclException("cannot append null");
219:                            }
220:                        } else {
221:                            f.append(arg.toString());
222:                        }
223:                    } catch (Exception ex) {
224:                        throw new HeclException("unable to append: " + ex);
225:                    }
226:                    return null;
227:                }
228:                if (subcmd.equals(WidgetInfo.NITEM)) {
229:                    // item<something> requires an item as parameter
230:                    if (argv.length < n) {
231:                        throw HeclException.createWrongNumArgsException(argv,
232:                                n, "item itemnumber");
233:                    }
234:                    return ObjectThing.create(f
235:                            .get(IntThing.get(argv[startat])));
236:                }
237:                if (subcmd.equals(WidgetInfo.NDELETE)) {
238:                    if (argv.length != n) {
239:                        throw HeclException.createWrongNumArgsException(argv,
240:                                n, "delete itemnumber");
241:                    }
242:                    f.delete(IntThing.get(argv[startat]));
243:                    return null;
244:                }
245:                if (subcmd.equals("deleteall")) {
246:                    f.deleteAll();
247:                    return null;
248:                }
249:                if (subcmd.equals(WidgetInfo.NSETCURRENT)) {
250:                    // extension: setcurrent itemnumber
251:                    if (argv.length == n) {
252:                        // start j2mepolish break down
253:                        // to allow correct preprocessing
254:                        Display displ = MidletCmd.getDisplay();
255:                        Item item = f.get(IntThing.get(argv[startat]));
256:                        displ.setCurrentItem(item);
257:                        // end j2mepolish break down
258:                        return null;
259:                    }
260:                }
261:                return super .handlecmd(ip, target, subcmd, argv, startat);
262:            }
263:
264:            private static FormCmd cmd = new FormCmd();
265:            private static final String CMDNAME = "lcdui.form";
266:        }
267:
268:        // Variables:
269:        // mode:java
270:        // coding:utf-8
271:        // End:
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.