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.portletext;
016    
017    import com.liferay.portal.kernel.servlet.taglib.FileAvailabilityUtil;
018    import com.liferay.portal.theme.PortletDisplay;
019    import com.liferay.taglib.ui.IconTag;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     * @author Shuyang Zhou
024     */
025    public class IconPortletCssTag extends IconTag {
026    
027            @Override
028            protected String getPage() {
029                    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
030                            return _PAGE;
031                    }
032    
033                    PortletDisplay portletDisplay =
034                            (PortletDisplay)pageContext.getAttribute("portletDisplay");
035    
036                    if (!portletDisplay.isShowPortletCssIcon()) {
037                            return null;
038                    }
039    
040                    setCssClass("portlet-css portlet-css-icon lfr-js-required");
041                    setImage("../aui/picture");
042                    setMessage("look-and-feel");
043    
044                    String onClick =
045                            "Liferay.Portlet.loadCSSEditor('".concat(
046                                    portletDisplay.getId()).concat("'); return false;");
047    
048                    setOnClick(onClick);
049    
050                    setToolTip(false);
051                    setUrl(portletDisplay.getURLPortletCss());
052    
053                    return super.getPage();
054            }
055    
056            private static final String _PAGE =
057                    "/html/taglib/portlet/icon_portlet_css/page.jsp";
058    
059    }