Source Code Cross Referenced for MenuItem.java in  » J2EE » ICEfaces-1.6.1 » com » icesoft » faces » component » menubar » 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 » J2EE » ICEfaces 1.6.1 » com.icesoft.faces.component.menubar 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003:         *
004:         * "The contents of this file are subject to the Mozilla Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License at
007:         * http://www.mozilla.org/MPL/
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011:         * License for the specific language governing rights and limitations under
012:         * the License.
013:         *
014:         * The Original Code is ICEfaces 1.5 open source software code, released
015:         * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016:         * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017:         * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018:         *
019:         * Contributor(s): _____________________.
020:         *
021:         * Alternatively, the contents of this file may be used under the terms of
022:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023:         * License), in which case the provisions of the LGPL License are
024:         * applicable instead of those above. If you wish to allow use of your
025:         * version of this file only under the terms of the LGPL License and not to
026:         * allow others to use your version of this file under the MPL, indicate
027:         * your decision by deleting the provisions above and replace them with
028:         * the notice and other provisions required by the LGPL License. If you do
029:         * not delete the provisions above, a recipient may use your version of
030:         * this file under either the MPL or the LGPL License."
031:         *
032:         */
033:
034:        package com.icesoft.faces.component.menubar;
035:
036:        import com.icesoft.faces.component.CSS_DEFAULT;
037:        import com.icesoft.faces.component.ext.taglib.Util;
038:        import com.icesoft.faces.util.CoreUtils;
039:
040:        import javax.faces.component.UIComponent;
041:        import javax.faces.component.UIParameter;
042:        import javax.faces.el.MethodBinding;
043:        import javax.faces.el.ValueBinding;
044:        import javax.faces.event.ActionListener;
045:        import javax.faces.event.FacesEvent;
046:        import javax.faces.event.ActionEvent;
047:        import java.util.Iterator;
048:        import java.util.List;
049:
050:        /**
051:         * MenuItem is a JSF component class that represent an ICEfaces menuItem.
052:         * <p>MenuItem components are the menu items contained by a menuBar. The action
053:         * and actionListener attributes operate in the same way as the standard
054:         * component attributes of the same name. The MenuItem component is only used in
055:         * the static approach to defining the heirarchy of menu items.
056:         * <p/>
057:         * This component extends the ICEfaces MenuItemBase component.
058:         * <p/>
059:         * By default the MenuItem is rendered by the "com.icesoft.faces.View" renderer
060:         * type.
061:         *
062:         * @author Chris Brown
063:         * @author gmccleary
064:         * @version 1.1
065:         */
066:        public class MenuItem extends MenuItemBase {
067:
068:            private String icon;
069:            private Object value;
070:            private String link;
071:            private String target;
072:            private MethodBinding action = null;
073:            private MethodBinding actionListener = null;
074:            private Boolean disabled = null;
075:            private String enabledOnUserRole = null;
076:            private String renderedOnUserRole = null;
077:
078:            /**
079:             * String constant defining default menu icon img
080:             */
081:            public static final String DEFAULT_ICON = "/xmlhttp/css/xp/css-images/menu_blank_icon.gif";
082:            private static final String DEFAULT_VALUE = "menu item default";
083:            private static final String DEFAULT_LINK = "#";
084:
085:            public MenuItem() {
086:            }
087:
088:            /* (non-Javadoc)
089:             * @see javax.faces.component.UIComponent#getRendererType()
090:             */
091:            public String getRendererType() {
092:                return "com.icesoft.faces.View";
093:            }
094:
095:            public String getComponentType() {
096:                return "com.icesoft.faces.MenuNode";
097:            }
098:
099:            /**
100:             * <p>Return the value of the <code>COMPONENT_FAMILY</code> of this
101:             * component.</p>
102:             */
103:            public String getFamily() {
104:                return "com.icesoft.faces.MenuNode";
105:            }
106:
107:            // convenience getters / setters
108:
109:            /**
110:             * <p>Return the value of the <code>icon</code> property.</p>
111:             */
112:            public String getIcon() {
113:                if (icon != null) {
114:                    return icon;
115:                }
116:                ValueBinding vb = getValueBinding("icon");
117:                if (vb != null) {
118:                    return (String) vb.getValue(getFacesContext());
119:                }
120:                return DEFAULT_ICON;
121:            }
122:
123:            /**
124:             * <p>Set the value of the <code>icon</code> property.</p>
125:             */
126:            public void setIcon(String iconValue) {
127:                icon = iconValue;
128:            }
129:
130:            /**
131:             * <p>Return the value of the <code>value</code> property.</p>
132:             */
133:            public Object getValue() {
134:                if (value != null) {
135:                    return value;
136:                }
137:                ValueBinding vb = getValueBinding("value");
138:                if (vb != null) {
139:                    return (String) vb.getValue(getFacesContext());
140:                }
141:                return DEFAULT_VALUE;
142:            }
143:
144:            /**
145:             * <p>Set the value of the <code>value</code> property.</p>
146:             */
147:            public void setValue(Object value) {
148:                this .value = value;
149:            }
150:
151:            /**
152:             * <p>Return the value of the <code>link</code> property.</p>
153:             */
154:            public String getLink() {
155:                if (link != null) {
156:                    return link;
157:                }
158:                ValueBinding vb = getValueBinding("link");
159:                if (vb != null) {
160:                    return (String) vb.getValue(getFacesContext());
161:                }
162:                return DEFAULT_LINK;
163:            }
164:
165:            /**
166:             * <p>Set the value of the <code>link</code> property.</p>
167:             */
168:            public void setLink(String linkValue) {
169:                this .link = linkValue;
170:            }
171:
172:            /**
173:             * <p>Return the value of the <code>target</code> property.</p>
174:             */
175:            public String getTarget() {
176:                if (target != null) {
177:                    return target;
178:                }
179:                ValueBinding vb = getValueBinding("target");
180:                if (vb != null) {
181:                    return (String) vb.getValue(getFacesContext());
182:                }
183:                return null;
184:            }
185:
186:            /**
187:             * <p>Set the value of the <code>target</code> property.</p>
188:             */
189:            public void setTarget(String target) {
190:                this .target = target;
191:            }
192:
193:            /**
194:             * <p>Return the value of the <code>action</code> property.</p>
195:             */
196:            public MethodBinding getAction() {
197:                // Superclass getAction() is smart enough to handle JSF 1.1 and 1.2,
198:                //  getting Action MethodBinding or MethodExpression
199:                MethodBinding actionMB = super .getAction();
200:                if (actionMB != null)
201:                    return actionMB;
202:                return action;
203:            }
204:
205:            /**
206:             * <p>Set the value of the <code>action</code> property.</p>
207:             */
208:            public void setAction(MethodBinding action) {
209:                this .action = action;
210:            }
211:
212:            /**
213:             * <p>Return the value of the <code>actionListener</code> property.</p>
214:             */
215:            public MethodBinding getActionListener() {
216:                return actionListener;
217:            }
218:
219:            /**
220:             * <p>Set the value of the <code>actionListener</code> property.</p>
221:             */
222:            public void setActionListener(MethodBinding actionListener) {
223:                this .actionListener = actionListener;
224:            }
225:
226:            public boolean hasActionOrActionListener() {
227:                if (getAction() != null)
228:                    return true;
229:                if (getActionListener() != null)
230:                    return true;
231:                ActionListener[] actionListeners = getActionListeners();
232:                if (actionListeners != null && actionListeners.length > 0)
233:                    return true;
234:                return false;
235:            }
236:
237:            public void queueEvent(FacesEvent e) {
238:                // ICE-1956 UICommand subclasses shouldn't call super.queueEvent
239:                //  on ActionEvents or else the immediate flag is ignored
240:                if ((e instanceof  ActionEvent)
241:                        && !this .equals(e.getComponent())
242:                        && getParent() != null) {
243:                    getParent().queueEvent(e);
244:                } else {
245:                    super .queueEvent(e);
246:                }
247:            }
248:
249:            /**
250:             * <p>Set the value of the <code>disabled</code> property.</p>
251:             */
252:            public void setDisabled(boolean disabled) {
253:                this .disabled = new Boolean(disabled);
254:                ValueBinding vb = getValueBinding("disabled");
255:                if (vb != null) {
256:                    vb.setValue(getFacesContext(), this .disabled);
257:                    this .disabled = null;
258:                }
259:            }
260:
261:            public boolean getDisabled() {
262:                return isDisabled();
263:            }
264:
265:            /**
266:             * <p>Return the value of the <code>disabled</code> property.</p>
267:             */
268:            public boolean isDisabled() {
269:                if (!Util.isEnabledOnUserRole(this )) {
270:                    return true;
271:                }
272:
273:                if (disabled != null) {
274:                    return disabled.booleanValue();
275:                }
276:                ValueBinding vb = getValueBinding("disabled");
277:                Boolean v = vb != null ? (Boolean) vb
278:                        .getValue(getFacesContext()) : null;
279:                return v != null ? v.booleanValue() : false;
280:            }
281:
282:            void addParameter(UIComponent link) {
283:                List children = getChildren();
284:
285:                for (int i = 0; i < children.size(); i++) {
286:                    UIComponent nextChild = (UIComponent) children.get(i);
287:                    if (nextChild instanceof  UIParameter) {
288:                        UIParameter param = new UIParameter();
289:                        param.setName(((UIParameter) nextChild).getName());
290:                        param.setValue(((UIParameter) nextChild).getValue());
291:                        link.getChildren().add(param);
292:                    }
293:                }
294:            }
295:
296:            boolean isChildrenMenuItem() {
297:                Iterator children = getChildren().iterator();
298:                while (children.hasNext()) {
299:                    UIComponent child = (UIComponent) children.next();
300:                    if (child instanceof  MenuItem) {
301:                        return true;
302:                    }
303:                }
304:                return false;
305:            }
306:
307:            /**
308:             * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
309:             *
310:             * @param enabledOnUserRole
311:             */
312:            public void setEnabledOnUserRole(String enabledOnUserRole) {
313:                this .enabledOnUserRole = enabledOnUserRole;
314:            }
315:
316:            /**
317:             * <p>Return the value of the <code>enabledOnUserRole</code> property.</p>
318:             *
319:             * @return String enabledOnUserRole
320:             */
321:            public String getEnabledOnUserRole() {
322:                if (enabledOnUserRole != null) {
323:                    return enabledOnUserRole;
324:                }
325:                ValueBinding vb = getValueBinding("enabledOnUserRole");
326:                return vb != null ? (String) vb.getValue(getFacesContext())
327:                        : null;
328:            }
329:
330:            /**
331:             * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
332:             *
333:             * @param renderedOnUserRole
334:             */
335:            public void setRenderedOnUserRole(String renderedOnUserRole) {
336:                this .renderedOnUserRole = renderedOnUserRole;
337:            }
338:
339:            /**
340:             * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
341:             *
342:             * @return String renderedOnUserRole
343:             */
344:            public String getRenderedOnUserRole() {
345:                if (renderedOnUserRole != null) {
346:                    return renderedOnUserRole;
347:                }
348:                ValueBinding vb = getValueBinding("renderedOnUserRole");
349:                return vb != null ? (String) vb.getValue(getFacesContext())
350:                        : null;
351:            }
352:
353:            /**
354:             * <p>Return the value of the <code>rendered</code> property.</p>
355:             *
356:             * @return boolean rendered
357:             */
358:            public boolean isRendered() {
359:                if (!Util.isRenderedOnUserRole(this )) {
360:                    return false;
361:                }
362:                return super .isRendered();
363:            }
364:
365:            private String styleClass;
366:
367:            /**
368:             * <p>Set the value of the <code>styleClass</code> property.</p>
369:             *
370:             * @param styleClass
371:             */
372:            public void setStyleClass(String styleClass) {
373:                this .styleClass = styleClass;
374:            }
375:
376:            /**
377:             * <p>Return the value of the <code>styleClass</code> property.</p>
378:             *
379:             * @return String styleClass
380:             */
381:            public String getStyleClass() {
382:                return Util
383:                        .getQualifiedStyleClass(this , styleClass,
384:                                CSS_DEFAULT.MENU_ITEM_STYLE, "styleClass",
385:                                isDisabled());
386:            }
387:
388:            public String getLabelStyleClass() {
389:                return Util.getQualifiedStyleClass(this ,
390:                        CSS_DEFAULT.MENU_ITEM_LABEL_STYLE, isDisabled());
391:            }
392:
393:            public String getImageStyleClass() {
394:                return Util.getQualifiedStyleClass(this ,
395:                        CSS_DEFAULT.MENU_ITEM_IMAGE_STYLE);
396:            }
397:
398:            String getUserDefinedStyleClass(String parentClass, String subClass) {
399:                String disSuffix = isDisabled() ? "-dis" : "";
400:
401:                if (styleClass != null) {
402:                    return parentClass + disSuffix + " " + styleClass
403:                            + subClass + disSuffix;
404:                }
405:
406:                ValueBinding vb = getValueBinding("styleClass");
407:                return vb != null ? parentClass + disSuffix + " "
408:                        + (String) vb.getValue(getFacesContext()) + subClass
409:                        + disSuffix : parentClass + disSuffix;
410:            }
411:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.