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 IconEditDefaultsTag 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.isShowEditDefaultsIcon()) {
037                            return null;
038                    }
039    
040                    setImage("../aui/edit-sign");
041                    setMessage("default-preferences");
042                    setToolTip(false);
043                    setUrl(portletDisplay.getURLEditDefaults());
044    
045                    return super.getPage();
046            }
047    
048            private static final String _PAGE =
049                    "/html/taglib/portlet/icon_edit_defaults/page.jsp";
050    
051    }