Source Code Cross Referenced for Command.java in  » Ajax » zk » org » zkoss » mil » 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 » Ajax » zk » org.zkoss.mil 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Command.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Jun 1, 2007 11:09:09 AM, Created by henrichen
010:        }}IS_NOTE
011:
012:        Copyright (C) 2007 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:
020:        package org.zkoss.mil;
021:
022:        import org.zkoss.lang.Objects;
023:        import org.zkoss.xml.HTMLs;
024:        import org.zkoss.zk.ui.Component;
025:        import org.zkoss.zk.ui.UiException;
026:
027:        /**
028:         * A command on the Mobile. Whenever a Command is "clicked" on the Mobile, it will fire onCommand to  
029:         * its parent component.
030:         * 
031:         * @author henrichen
032:         */
033:        public class Command extends MilComponent {
034:            private final static int BACK = 2;
035:            private final static int CANCEL = 3;
036:            private final static int EXIT = 7;
037:            private final static int HELP = 5;
038:            private final static int ITEM = 8;
039:            private final static int OK = 4;
040:            private final static int SCREEN = 1;
041:            private final static int STOP = 6;
042:
043:            private final static int SELECT = 0x100; //special command for JavaME List.setSelectCommand() only
044:
045:            private static final long serialVersionUID = 200706011201L;
046:            private String _label = "OK";
047:            private String _llabel;
048:            private String _type = "ok";
049:            private int _priority = 1;
050:
051:            public Command() {
052:            }
053:
054:            /**
055:             * A Command on the Mobile (the command priority is default to 1).
056:             * 
057:             * @param label label appear on the command
058:             * @param type The command type on the Mobile (back, cancel, exit, help, item, ok, screen, stop).
059:             */
060:            public Command(String label, String type) {
061:                this (label, null/*longLabel*/, type, 1);
062:            }
063:
064:            /**
065:             * A Command on the Mobile.
066:             * 
067:             * @param label label appear on the command
068:             * @param type The command type on the Mobile (back, cancel, exit, help, item, ok, screen, stop).
069:             */
070:            public Command(String label, String type, int priority) {
071:                this (label, null/*longLabel*/, type, priority);
072:            }
073:
074:            /**
075:             * A Command on the Mobile.
076:             * 
077:             * @param label label appear on the command
078:             * @param longLabel long label apper on the command
079:             * @param type The command type on the Mobile (back, cancel, exit, help, item, ok, screen, stop).
080:             */
081:            public Command(String label, String longLabel, String type,
082:                    int priority) {
083:                setLabel(label);
084:                setLongLabel(longLabel);
085:                setType(type);
086:                setPriority(priority);
087:            }
088:
089:            public String getLabel() {
090:                return _label;
091:            }
092:
093:            public void setLabel(String label) {
094:                if (label != null && label.length() == 0) {
095:                    label = null;
096:                }
097:                if (label == null) {
098:                    throw new NullPointerException(
099:                            "Label cannot be empty or null");
100:                }
101:                if (!Objects.equals(_label, label)) {
102:                    _label = label;
103:                    smartUpdate("lb", label);
104:                }
105:            }
106:
107:            public String getLongLabel() {
108:                return _llabel;
109:            }
110:
111:            public void setLongLabel(String label) {
112:                if (label != null && label.length() == 0) {
113:                    label = null;
114:                }
115:                if (!Objects.equals(_llabel, label)) {
116:                    _llabel = label;
117:                    smartUpdate("ll", label);
118:                }
119:            }
120:
121:            public String getType() {
122:                return _type;
123:            }
124:
125:            public void setType(String type) {
126:                if (type != null && type.length() == 0) {
127:                    type = null;
128:                }
129:                if (!Objects.equals(_type, type)) {
130:                    _type = type;
131:                    smartUpdate("tp", getCommandType(type));
132:                }
133:            }
134:
135:            public int getPriority() {
136:                return _priority;
137:            }
138:
139:            public void setPriority(int priority) {
140:                if (_priority != priority) {
141:                    _priority = priority;
142:                    smartUpdate("pr", priority);
143:                }
144:            }
145:
146:            //--Component--//
147:            public void setParent(Component parent) {
148:                if ((parent != null && !(parent instanceof  MilComponent))
149:                        || parent instanceof  Listitem) {
150:                    throw new UiException("Unsupported parent for command: "
151:                            + parent);
152:                }
153:                super .setParent(parent);
154:            }
155:
156:            /** Not childable. */
157:            public boolean isChildable() {
158:                return false;
159:            }
160:
161:            public String getInnerAttrs() {
162:                final StringBuffer sb = new StringBuffer(64);
163:                HTMLs.appendAttribute(sb, "tp", getCommandType(_type));
164:                HTMLs.appendAttribute(sb, "lb", encodeString(getLabel()));
165:                HTMLs.appendAttribute(sb, "ll", encodeString(getLongLabel()));
166:                HTMLs.appendAttribute(sb, "pr", getPriority());
167:                return sb.toString();
168:            }
169:
170:            private int getCommandType(String type) {
171:                if ("back".equals(type)) {
172:                    return BACK;
173:                } else if ("cancel".equalsIgnoreCase(type)) {
174:                    return CANCEL;
175:                } else if ("exit".equalsIgnoreCase(type)) {
176:                    return EXIT;
177:                } else if ("help".equalsIgnoreCase(type)) {
178:                    return HELP;
179:                } else if ("item".equalsIgnoreCase(type)) {
180:                    return ITEM;
181:                } else if ("ok".equalsIgnoreCase(type)) {
182:                    return OK;
183:                } else if ("screen".equalsIgnoreCase(type)) {
184:                    return SCREEN;
185:                } else if ("stop".equalsIgnoreCase(type)) {
186:                    return STOP;
187:                } else if ("select".equalsIgnoreCase(type)) {
188:                    return SELECT;
189:                } else {
190:                    throw new IllegalArgumentException(
191:                            "Unsupport Command type: " + type);
192:                }
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.