Source Code Cross Referenced for MenuOptionImpl.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » portalsite » impl » 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 » Portal » jetspeed 2.1.3 » org.apache.jetspeed.portalsite.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.portalsite.impl;
018:
019:        import org.apache.jetspeed.om.folder.Folder;
020:        import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
021:        import org.apache.jetspeed.om.page.Link;
022:        import org.apache.jetspeed.om.page.Page;
023:        import org.apache.jetspeed.page.document.Node;
024:        import org.apache.jetspeed.page.document.NodeNotFoundException;
025:        import org.apache.jetspeed.portalsite.MenuOption;
026:        import org.apache.jetspeed.portalsite.PortalSiteRequestContext;
027:
028:        /**
029:         * This class implements the portal-site menu option
030:         * elements constructed and returned to decorators.
031:         * 
032:         * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
033:         * @version $Id: MenuOptionImpl.java 537314 2007-05-11 23:08:36Z taylor $
034:         */
035:        public class MenuOptionImpl extends MenuElementImpl implements 
036:                MenuOption, Cloneable {
037:            /**
038:             * definition - menu option definition
039:             */
040:            private MenuOptionsDefinition definition;
041:
042:            /**
043:             * MenuOptionImpl - constructor
044:             *
045:             * @param parent containing menu implementation
046:             * @param node menu option node proxy
047:             * @param definition menu option definition
048:             */
049:            public MenuOptionImpl(MenuImpl parent, Node node,
050:                    MenuOptionsDefinition definition) {
051:                super (parent, node);
052:                this .definition = definition;
053:            }
054:
055:            /**
056:             * getElementType - get type of menu element
057:             *
058:             * @return OPTION_ELEMENT_TYPE
059:             */
060:            public String getElementType() {
061:                return OPTION_ELEMENT_TYPE;
062:            }
063:
064:            /**
065:             * getType - get type of menu option
066:             *
067:             * @return FOLDER_OPTION_TYPE, PAGE_OPTION_TYPE, or
068:             *         LINK_OPTION_TYPE
069:             */
070:            public String getType() {
071:                // return type of menu option node proxy
072:                Node node = getNode();
073:                if (node instanceof  Page) {
074:                    return PAGE_OPTION_TYPE;
075:                } else if (node instanceof  Link) {
076:                    return LINK_OPTION_TYPE;
077:                } else if (node instanceof  Folder) {
078:                    return FOLDER_OPTION_TYPE;
079:                }
080:                return null;
081:            }
082:
083:            /**
084:             * getSkin - get skin name for menu element
085:             *
086:             * @return skin name
087:             */
088:            public String getSkin() {
089:                // get skin from definition, from menu option
090:                // node proxy, or inherit from parent menu
091:                String skin = definition.getSkin();
092:                if (skin == null) {
093:                    Node node = getNode();
094:                    if (node instanceof  Page) {
095:                        skin = ((Page) node).getSkin();
096:                    } else if (node instanceof  Link) {
097:                        skin = ((Link) node).getSkin();
098:                    } else if (node instanceof  Folder) {
099:                        skin = ((Folder) node).getSkin();
100:                    }
101:                }
102:                if (skin == null) {
103:                    skin = super .getSkin();
104:                }
105:                return skin;
106:            }
107:
108:            /**
109:             * getUrl - get url of menu option
110:             *
111:             * @return folder, page, or link url
112:             */
113:            public String getUrl() {
114:                return getNode().getUrl();
115:            }
116:
117:            /**
118:             * getTarget - get target for url of menu option
119:             *
120:             * @return url target
121:             */
122:            public String getTarget() {
123:                // only link nodes support target
124:                Node node = getNode();
125:                if (node instanceof  Link) {
126:                    return ((Link) node).getTarget();
127:                }
128:                return null;
129:            }
130:
131:            /**
132:             * getDefaultPage - get default page for a folder (if folder) of menu option
133:             *
134:             * @return url target
135:             */
136:            public String getDefaultPage() {
137:                // only link nodes support target
138:                Node node = getNode();
139:                if (node instanceof  Folder) {
140:                    return ((Folder) node).getDefaultPage();
141:                }
142:                return null;
143:            }
144:
145:            /**
146:             * isHidden - get hidden state of menu option
147:             *
148:             * @return hidden state
149:             */
150:            public boolean isHidden() {
151:                return getNode().isHidden();
152:            }
153:
154:            /**
155:             * isSelected - return true if menu option is selected by
156:             *              the specified request context
157:             *
158:             * @param context request context
159:             * @return selected state
160:             */
161:            public boolean isSelected(PortalSiteRequestContext context) {
162:                // compare the site view url of the page or
163:                // folder menu option proxy with the url of
164:                // the context request profiled page proxy
165:                if (context != null) {
166:                    // get request page
167:                    Page requestPage = null;
168:                    try {
169:                        requestPage = context.getPage();
170:                    } catch (NodeNotFoundException nnfe) {
171:                    } catch (SecurityException se) {
172:                    }
173:                    if (requestPage != null) {
174:                        // get selected status based or request page url
175:                        Node node = getNode();
176:                        if (node instanceof  Page) {
177:                            // page urls must match the request page
178:                            // urls to be considered selected
179:                            return requestPage.getUrl().equals(node.getUrl());
180:                        } else if (node instanceof  Folder) {
181:                            // folder urls must be a prefix of the
182:                            // request page urls to be considered
183:                            // selected
184:                            return requestPage.getUrl().startsWith(
185:                                    node.getUrl());
186:                        }
187:                    }
188:                }
189:                return false;
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.