001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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(String 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 setShowCurrentGroup(boolean showCurrentGroup) {
049                    _showCurrentGroup = showCurrentGroup;
050            }
051    
052            public void setShowCurrentPortlet(boolean showCurrentPortlet) {
053                    _showCurrentPortlet = showCurrentPortlet;
054            }
055    
056            public void setShowGuestGroup(boolean showGuestGroup) {
057                    _showGuestGroup = showGuestGroup;
058            }
059    
060            public void setShowLayout(boolean showLayout) {
061                    _showLayout = showLayout;
062            }
063    
064            public void setShowParentGroups(boolean showParentGroups) {
065                    _showParentGroups = showParentGroups;
066            }
067    
068            public void setShowPortletBreadcrumb(boolean showPortletBreadcrumb) {
069                    _showPortletBreadcrumb = showPortletBreadcrumb;
070            }
071    
072            @Override
073            protected void cleanUp() {
074                    _displayStyle = _DISPLAY_STYLE;
075                    _portletURL = null;
076                    _selLayout = null;
077                    _selLayoutParam = null;
078                    _showCurrentGroup = true;
079                    _showCurrentPortlet = true;
080                    _showGuestGroup = _SHOW_GUEST_GROUP;
081                    _showLayout = true;
082                    _showParentGroups = _SHOW_PARENT_GROUPS;
083                    _showPortletBreadcrumb = true;
084            }
085    
086            @Override
087            protected String getPage() {
088                    return _PAGE;
089            }
090    
091            @Override
092            protected void setAttributes(HttpServletRequest request) {
093                    request.setAttribute(
094                            "liferay-ui:breadcrumb:displayStyle", _displayStyle);
095                    request.setAttribute("liferay-ui:breadcrumb:portletURL", _portletURL);
096                    request.setAttribute("liferay-ui:breadcrumb:selLayout", _selLayout);
097                    request.setAttribute(
098                            "liferay-ui:breadcrumb:selLayoutParam", _selLayoutParam);
099                    request.setAttribute(
100                            "liferay-ui:breadcrumb:showCurrentGroup",
101                            String.valueOf(_showCurrentGroup));
102                    request.setAttribute(
103                            "liferay-ui:breadcrumb:showCurrentPortlet",
104                            String.valueOf(_showCurrentPortlet));
105                    request.setAttribute(
106                            "liferay-ui:breadcrumb:showGuestGroup",
107                            String.valueOf(_showGuestGroup));
108                    request.setAttribute(
109                            "liferay-ui:breadcrumb:showLayout", String.valueOf(_showLayout));
110                    request.setAttribute(
111                            "liferay-ui:breadcrumb:showParentGroups",
112                            String.valueOf(_showParentGroups));
113                    request.setAttribute(
114                            "liferay-ui:breadcrumb:showPortletBreadcrumb",
115                            String.valueOf(_showPortletBreadcrumb));
116            }
117    
118            private static final String _DISPLAY_STYLE = "0";
119    
120            private static final String _PAGE = "/html/taglib/ui/breadcrumb/page.jsp";
121    
122            private static final boolean _SHOW_GUEST_GROUP = GetterUtil.getBoolean(
123                    PropsUtil.get(PropsKeys.BREADCRUMB_SHOW_GUEST_GROUP));
124    
125            private static final boolean _SHOW_PARENT_GROUPS = GetterUtil.getBoolean(
126                    PropsUtil.get(PropsKeys.BREADCRUMB_SHOW_PARENT_GROUPS));
127    
128            private String _displayStyle = _DISPLAY_STYLE;
129            private PortletURL _portletURL;
130            private Layout _selLayout;
131            private String _selLayoutParam;
132            private boolean _showCurrentGroup = true;
133            private boolean _showCurrentPortlet = true;
134            private boolean _showGuestGroup = _SHOW_GUEST_GROUP;
135            private boolean _showLayout = true;
136            private boolean _showParentGroups = _SHOW_PARENT_GROUPS;
137            private boolean _showPortletBreadcrumb = true;
138    
139    }