Source Code Cross Referenced for MenuBar.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.context.effects.JavascriptContext;
039:        import com.icesoft.faces.util.CoreUtils;
040:
041:        import javax.faces.component.NamingContainer;
042:        import javax.faces.component.UICommand;
043:        import javax.faces.component.UIComponent;
044:        import javax.faces.context.FacesContext;
045:        import javax.faces.el.ValueBinding;
046:        import javax.faces.event.AbortProcessingException;
047:        import javax.faces.event.FacesEvent;
048:        import javax.faces.event.ActionEvent;
049:
050:        /**
051:         * MenuBar is a JSF component class representing the ICEfaces menu bar. <p>The
052:         * menuBar component provides a robust menu system that supports:
053:         * <p/>
054:         * 1. Nested child menuItem and menuItemSeparator components. Support for
055:         * menuItemCheckbox and menuItemRadio components are planned for a future
056:         * release.<br/> 2. Horizontal (default) and Vertical menu orientations. Defines
057:         * whether the submenus of the top-level menu items appear beside or below the
058:         * top-level menu items.<br/> 3. Definition of the heirarchy of menu items and
059:         * their submenus in one of two ways:<br/> - by using a binding to a bean method
060:         * that returns a (potentially) dynamic heirarchy of menu items.<br/> - by
061:         * statically defining the heirarchy in the JSPX page.<br/> 4. The action
062:         * attribute of the contained menuItem tags or instances can be defined to
063:         * indicate a string or a backing bean method that can be used in application
064:         * navigation.<br/> 5. The actionListener attribute of the contained menuItem
065:         * tags or instances can be defined to indicate an actionListener that resides
066:         * in a backing bean.<br/>
067:         * <p/>
068:         * This component extends the JSF UICommand component and implements the
069:         * NamingContainer interface.
070:         * <p/>
071:         * By default the MenuBar is rendered by the "com.icesoft.faces.View" renderer
072:         * type.
073:         *
074:         * @author Chris Brown
075:         * @author gmccleary
076:         * @version 1.1
077:         */
078:        public class MenuBar extends UICommand implements  NamingContainer {
079:
080:            // default style classes
081:            private static final String DEFAULT_IMAGEDIR = "/xmlhttp/css/xp/css-images/";
082:            /**
083:             * String constant vertical orientation
084:             */
085:            public static final String ORIENTATION_VERTICAL = "vertical";
086:            /**
087:             * String contant horizontal orientation
088:             */
089:            public static final String ORIENTATION_HORIZONTAL = "horizontal";
090:            /**
091:             * String contant default orientation
092:             */
093:            public static final String DEFAULT_ORIENTATION = ORIENTATION_HORIZONTAL;
094:            /**
095:             * String constant menu id prefix
096:             */
097:            public static final String ID_PREFIX = "menu-";
098:
099:            private String imageDir;
100:            private String orientation; // horizontal | vertical ; default = horizontal
101:            private String style;
102:            private String renderedOnUserRole = null;
103:            private Boolean noIcons;
104:
105:            /**
106:             * default no args constructor
107:             */
108:            public MenuBar() {
109:                JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
110:                        FacesContext.getCurrentInstance());
111:            }
112:
113:            /**
114:             * <p>Return the value of the <code>COMPONENT_FAMILY</code> of this
115:             * component.</p>
116:             *
117:             * @return String component family
118:             */
119:            public String getFamily() {
120:                return "com.icesoft.faces.Menu";
121:            }
122:
123:            /**
124:             * @return String component type
125:             */
126:            public String getComponentType() {
127:                return "com.icesoft.faces.Menu";
128:            }
129:
130:            /* (non-Javadoc)
131:             * @see javax.faces.component.UIComponentBase#getRendererType()
132:             */
133:            public String getRendererType() {
134:                return "com.icesoft.faces.View";
135:            }
136:
137:            /**
138:             * Return the value of the noIcons property. A return value of "true"
139:             * indicates that noIcons should be rendered on all of the MenuBar
140:             * subMenus.
141:             *
142:             * @return String value of Boolean noIcons
143:             */
144:            public String getNoIcons() {
145:
146:                if (noIcons != null) {
147:                    return noIcons.toString();
148:                }
149:                ValueBinding vb = getValueBinding("noIcons");
150:                if (vb != null) {
151:                    return vb.getValue(getFacesContext()).toString();
152:                }
153:                return String.valueOf(false);
154:            }
155:
156:            /**
157:             * Set the value of the noIcons property. Setting this value to "true" will
158:             * cause all subMenus of this MenuBar to be rendered without icons and
159:             * spacers.
160:             *
161:             * @param b
162:             */
163:            public void setNoIcons(String b) {
164:                noIcons = new Boolean(b);
165:            }
166:
167:            /**
168:             * <p>Set the value of the <code>style</code> property.</p>
169:             *
170:             * @param style
171:             */
172:            public void setStyle(String style) {
173:                this .style = style;
174:            }
175:
176:            /**
177:             * <p>Return the value of the <code>style</code> property.</p>
178:             *
179:             * @return String style
180:             */
181:            public String getStyle() {
182:                if (style != null) {
183:                    return style;
184:                }
185:                ValueBinding vb = getValueBinding("style");
186:                return vb != null ? (String) vb.getValue(getFacesContext())
187:                        : null;
188:            }
189:
190:            // GETTERS AND SETTERS
191:
192:            /**
193:             * <p>Return the value of the <code>imageDir</code> property.</p>
194:             *
195:             * @return String imageDir
196:             */
197:            public String getImageDir() {
198:                if (imageDir != null) {
199:                    return imageDir;
200:                }
201:                ValueBinding vb = getValueBinding("imageDir");
202:                if (vb != null) {
203:                    return (String) vb.getValue(getFacesContext());
204:                }
205:                return DEFAULT_IMAGEDIR;
206:            }
207:
208:            /**
209:             * <p>Set the value of the <code>imageDir</code> property.</p>
210:             *
211:             * @param imageDir
212:             */
213:            public void setImageDir(String imageDir) {
214:                this .imageDir = imageDir;
215:            }
216:
217:            /**
218:             * <p>Return the value of the <code>orientation</code> property.</p>
219:             *
220:             * @return String orientation
221:             */
222:            public String getOrientation() {
223:                if (orientation != null) {
224:                    return orientation;
225:                }
226:                ValueBinding vb = getValueBinding("orientation");
227:                if (vb != null) {
228:                    return (String) vb.getValue(getFacesContext());
229:                }
230:                return DEFAULT_ORIENTATION;
231:            }
232:
233:            /**
234:             * <p>Set the value of the <code>orientation</code> property.</p>
235:             *
236:             * @param orient
237:             */
238:            public void setOrientation(String orient) {
239:                orientation = orient;
240:            }
241:
242:            /* (non-Javadoc)
243:             * @see javax.faces.component.UIComponent#processDecodes(javax.faces.context.FacesContext)
244:             */
245:            public void processDecodes(FacesContext context) {
246:                if (context == null) {
247:                    throw new NullPointerException("context");
248:                }
249:                if (!isRendered()) {
250:                    return;
251:                }
252:
253:                decodeRecursive(this , context);
254:                try {
255:                    decode(context);
256:                } catch (RuntimeException e) {
257:                    context.renderResponse();
258:                    throw e;
259:                }
260:            }
261:
262:            /**
263:             * @param component
264:             * @param context
265:             */
266:            private void decodeRecursive(UIComponent component,
267:                    FacesContext context) {
268:                for (int i = 0; i < component.getChildCount(); i++) {
269:                    UIComponent next = (UIComponent) component.getChildren()
270:                            .get(i);
271:                    next.processDecodes(context);
272:                    decodeRecursive(next, context);
273:                }
274:            }
275:
276:            /* (non-Javadoc)
277:             * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
278:             */
279:            public void queueEvent(FacesEvent e) {
280:                // ICE-1956 UICommand subclasses shouldn't call super.queueEvent
281:                //  on ActionEvents or else the immediate flag is ignored
282:                if ((e instanceof  ActionEvent)
283:                        && !this .equals(e.getComponent())
284:                        && getParent() != null) {
285:                    getParent().queueEvent(e);
286:                } else {
287:                    super .queueEvent(e);
288:                }
289:            }
290:
291:            /* (non-Javadoc)
292:             * @see javax.faces.component.UIComponent#broadcast(javax.faces.event.FacesEvent)
293:             */
294:            public void broadcast(FacesEvent event)
295:                    throws AbortProcessingException {
296:                super .broadcast(event);
297:                return;
298:
299:            }
300:
301:            /**
302:             * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
303:             *
304:             * @param renderedOnUserRole
305:             */
306:            public void setRenderedOnUserRole(String renderedOnUserRole) {
307:                this .renderedOnUserRole = renderedOnUserRole;
308:            }
309:
310:            /**
311:             * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
312:             *
313:             * @return String renderedOnUserRole
314:             */
315:            public String getRenderedOnUserRole() {
316:                if (renderedOnUserRole != null) {
317:                    return renderedOnUserRole;
318:                }
319:                ValueBinding vb = getValueBinding("renderedOnUserRole");
320:                return vb != null ? (String) vb.getValue(getFacesContext())
321:                        : null;
322:            }
323:
324:            /**
325:             * <p>Return the value of the <code>rendered</code> property.</p>
326:             *
327:             * @return boolean rendered
328:             */
329:            public boolean isRendered() {
330:                if (!Util.isRenderedOnUserRole(this )) {
331:                    return false;
332:                }
333:                return super .isRendered();
334:            }
335:
336:            private String styleClass;
337:
338:            /**
339:             * <p>Set the value of the <code>styleClass</code> property.</p>
340:             *
341:             * @param styleClass
342:             */
343:            public void setStyleClass(String styleClass) {
344:                this .styleClass = styleClass;
345:            }
346:
347:            /**
348:             * <p>Return the value of the <code>styleClass</code> property.</p>
349:             *
350:             * @return String styleClass
351:             */
352:            public String getStyleClass() {
353:                String defaultStyle = CSS_DEFAULT.MENU_BAR_STYLE;
354:                String userDefinedClass = styleClass;
355:                if (MenuBar.ORIENTATION_VERTICAL
356:                        .equalsIgnoreCase(getOrientation())) {
357:                    defaultStyle += CSS_DEFAULT.MENU_BAR_VERTICAL_SUFFIX_STYLE;
358:                    if (userDefinedClass != null) {
359:                        userDefinedClass += CSS_DEFAULT.MENU_BAR_VERTICAL_SUFFIX_STYLE;
360:                    }
361:                }
362:                return Util.getQualifiedStyleClass(this , userDefinedClass,
363:                        defaultStyle, "styleClass");
364:            }
365:
366:            public String getItemStyleClass() {
367:                return Util.getQualifiedStyleClass(this ,
368:                        CSS_DEFAULT.MENU_BAR_ITEM_STYLE);
369:            }
370:
371:            public String getItemLabelStyleClass() {
372:                return Util.getQualifiedStyleClass(this ,
373:                        CSS_DEFAULT.MENU_BAR_ITEM_LABEL_STYLE);
374:            }
375:
376:            public String getItemImageStyleClass() {
377:                return Util.getQualifiedStyleClass(this ,
378:                        CSS_DEFAULT.MENU_BAR_ITEM_STYLE
379:                                + CSS_DEFAULT.MENU_ITEM_IMAGE_STYLE);
380:            }
381:
382:            public String getSubMenuStyleClass() {
383:                return Util.getQualifiedStyleClass(this ,
384:                        CSS_DEFAULT.MENU_BAR_SUB_MENU_STYLE);
385:            }
386:
387:            public String getSubMenuIndicatorStyleClass() {
388:                return Util.getQualifiedStyleClass(this,
389:                        CSS_DEFAULT.MENU_BAR_SUB_MENU_INDICATOR_STYLE);
390:            }
391:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.