001    /**
002     * Copyright (c) 2000-present 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.diff.DiffVersionsInfo;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import java.util.Locale;
021    import java.util.Set;
022    
023    import javax.portlet.PortletURL;
024    
025    import javax.servlet.http.HttpServletRequest;
026    
027    /**
028     * @author Eudaldo Alonso
029     */
030    public class DiffVersionComparatorTag extends IncludeTag {
031    
032            @Override
033            public int doStartTag() {
034                    return EVAL_BODY_INCLUDE;
035            }
036    
037            public void setAvailableLocales(Set<Locale> availableLocales) {
038                    _availableLocales = availableLocales;
039            }
040    
041            public void setDiffHtmlResults(String diffHtmlResults) {
042                    _diffHtmlResults = diffHtmlResults;
043            }
044    
045            public void setDiffVersionsInfo(DiffVersionsInfo diffVersionsInfo) {
046                    _diffVersionsInfo = diffVersionsInfo;
047            }
048    
049            public void setLanguageId(String languageId) {
050                    _languageId = languageId;
051            }
052    
053            public void setPortletURL(PortletURL portletURL) {
054                    _portletURL = portletURL;
055            }
056    
057            public void setResourceURL(PortletURL resourceURL) {
058                    _resourceURL = resourceURL;
059            }
060    
061            public void setSourceVersion(double sourceVersion) {
062                    _sourceVersion = sourceVersion;
063            }
064    
065            public void setTargetVersion(double targetVersion) {
066                    _targetVersion = targetVersion;
067            }
068    
069            @Override
070            protected void cleanUp() {
071                    _availableLocales = null;
072                    _diffHtmlResults = null;
073                    _diffVersionsInfo = null;
074                    _languageId = null;
075                    _portletURL = null;
076                    _resourceURL = null;
077                    _sourceVersion = 0;
078                    _targetVersion = 0;
079            }
080    
081            @Override
082            protected String getPage() {
083                    return _PAGE;
084            }
085    
086            @Override
087            protected boolean isCleanUpSetAttributes() {
088                    return _CLEAN_UP_SET_ATTRIBUTES;
089            }
090    
091            @Override
092            protected void setAttributes(HttpServletRequest request) {
093                    request.setAttribute(
094                            "liferay-ui:diff-version-comparator:availableLocales",
095                            _availableLocales);
096                    request.setAttribute(
097                            "liferay-ui:diff-version-comparator:diffHtmlResults",
098                            _diffHtmlResults);
099                    request.setAttribute(
100                            "liferay-ui:diff-version-comparator:diffVersionsInfo",
101                            _diffVersionsInfo);
102                    request.setAttribute(
103                            "liferay-ui:diff-version-comparator:languageId", _languageId);
104                    request.setAttribute(
105                            "liferay-ui:diff-version-comparator:portletURL", _portletURL);
106                    request.setAttribute(
107                            "liferay-ui:diff-version-comparator:resourceURL", _resourceURL);
108                    request.setAttribute(
109                            "liferay-ui:diff-version-comparator:sourceVersion", _sourceVersion);
110                    request.setAttribute(
111                            "liferay-ui:diff-version-comparator:targetVersion", _targetVersion);
112            }
113    
114            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
115    
116            private static final String _PAGE =
117                    "/html/taglib/ui/diff_version_comparator/page.jsp";
118    
119            private Set<Locale> _availableLocales;
120            private String _diffHtmlResults;
121            private DiffVersionsInfo _diffVersionsInfo;
122            private String _languageId;
123            private PortletURL _portletURL;
124            private PortletURL _resourceURL;
125            private double _sourceVersion;
126            private double _targetVersion;
127    
128    }