001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.portal.kernel.util.GetterUtil;
018    import com.liferay.portal.kernel.util.PropsKeys;
019    import com.liferay.portal.kernel.util.PropsUtil;
020    import com.liferay.portal.model.Layout;
021    import com.liferay.taglib.util.IncludeTag;
022    
023    import javax.portlet.PortletURL;
024    
025    import javax.servlet.http.HttpServletRequest;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class BreadcrumbTag extends IncludeTag {
031    
032            public void setDisplayStyle(int displayStyle) {
033                    _displayStyle = displayStyle;
034            }
035    
036            public void setPortletURL(PortletURL portletURL) {
037                    _portletURL = portletURL;
038            }
039    
040            public void setSelLayout(Layout selLayout) {
041                    _selLayout = selLayout;
042            }
043    
044            public void setSelLayoutParam(String selLayoutParam) {
045                    _selLayoutParam = selLayoutParam;
046            }
047    
048            public void setShowGuestGroup(boolean showGuestGroup) {
049                    _showGuestGroup = showGuestGroup;
050            }
051    
052            public void setShowLayout(boolean showLayout) {
053                    _showLayout = showLayout;
054            }
055    
056            public void setShowParentGroups(boolean showParentGroups) {
057                    _showParentGroups = showParentGroups;
058            }
059    
060            public void setShowPortletBreadcrumb(boolean showPortletBreadcrumb) {
061                    _showPortletBreadcrumb = showPortletBreadcrumb;
062            }
063    
064            protected void cleanUp() {
065                    _displayStyle = _DISPLAY_STYLE;
066                    _portletURL = null;
067                    _selLayout = null;
068                    _selLayoutParam = null;
069                    _showGuestGroup = _SHOW_GUEST_GROUP;
070                    _showLayout = true;
071                    _showParentGroups = _SHOW_PARENT_GROUPS;
072                    _showPortletBreadcrumb = true;
073            }
074    
075            protected String getPage() {
076                    return _PAGE;
077            }
078    
079            protected void setAttributes(HttpServletRequest request) {
080                    request.setAttribute(
081                            "liferay-ui:breadcrumb:displayStyle",
082                            String.valueOf(_displayStyle));
083                    request.setAttribute("liferay-ui:breadcrumb:portletURL", _portletURL);
084                    request.setAttribute("liferay-ui:breadcrumb:selLayout", _selLayout);
085                    request.setAttribute(
086                            "liferay-ui:breadcrumb:selLayoutParam", _selLayoutParam);
087                    request.setAttribute(
088                            "liferay-ui:breadcrumb:showGuestGroup",
089                            String.valueOf(_showGuestGroup));
090                    request.setAttribute(
091                            "liferay-ui:breadcrumb:showLayout", String.valueOf(_showLayout));
092                    request.setAttribute(
093                            "liferay-ui:breadcrumb:showParentGroups",
094                            String.valueOf(_showParentGroups));
095                    request.setAttribute(
096                            "liferay-ui:breadcrumb:showPortletBreadcrumb",
097                            String.valueOf(_showPortletBreadcrumb));
098            }
099    
100            private static final int _DISPLAY_STYLE = 0;
101    
102            private static final String _PAGE = "/html/taglib/ui/breadcrumb/page.jsp";
103    
104            private static final boolean _SHOW_GUEST_GROUP = GetterUtil.getBoolean(
105                    PropsUtil.get(PropsKeys.BREADCRUMB_SHOW_GUEST_GROUP));
106    
107            private static final boolean _SHOW_PARENT_GROUPS = GetterUtil.getBoolean(
108                    PropsUtil.get(PropsKeys.BREADCRUMB_SHOW_PARENT_GROUPS));
109    
110            private int _displayStyle = _DISPLAY_STYLE;
111            private PortletURL _portletURL;
112            private Layout _selLayout;
113            private String _selLayoutParam;
114            private boolean _showGuestGroup = _SHOW_GUEST_GROUP;
115            private boolean _showLayout = true;
116            private boolean _showParentGroups = _SHOW_PARENT_GROUPS;
117            private boolean _showPortletBreadcrumb = true;
118    
119    }