001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.workplace.comparison;
029
030import org.opencms.jsp.CmsJspActionElement;
031import org.opencms.util.CmsUUID;
032import org.opencms.workplace.CmsDialog;
033
034import javax.servlet.jsp.JspWriter;
035
036/**
037 * Provides a GUI for displaying two images.<p>
038 *
039 * @since 6.0.0
040 */
041public class CmsImageComparisonDialog extends CmsDialog {
042
043    /** Parameter value for the structure id of the first file. */
044    private String m_paramId1;
045
046    /** Parameter value for the structure id of the second file. */
047    private String m_paramId2;
048
049    /** Parameter value for the version of the first file. */
050    private String m_paramVersion1;
051
052    /** Parameter value for the version of the second file. */
053    private String m_paramVersion2;
054
055    /**
056     * Default constructor.<p>
057     *
058     * @param jsp an initialized JSP action element
059     */
060    public CmsImageComparisonDialog(CmsJspActionElement jsp) {
061
062        super(jsp);
063    }
064
065    /**
066     * Performs the dialog actions depending on the initialized action and displays the dialog form.<p>
067     *
068     * @throws Exception if writing to the JSP out fails
069     */
070    public void displayDialog() throws Exception {
071
072        if (getAction() == ACTION_CANCEL) {
073            actionCloseDialog();
074        }
075        String link1 = CmsHistoryListUtil.getHistoryLink(getCms(), new CmsUUID(m_paramId1), m_paramVersion1);
076        String link2 = CmsHistoryListUtil.getHistoryLink(getCms(), new CmsUUID(m_paramId2), m_paramVersion2);
077        JspWriter out = getJsp().getJspContext().getOut();
078        out.println(dialogBlockStart(key(Messages.GUI_COMPARE_CONTENT_0)));
079        out.println(dialogContentStart(null));
080        out.println("<table cellpadding='0' cellspacing='0' border='0' class='maxwidth'><tr align='center'><th>");
081        out.println(
082            key(
083                Messages.GUI_COMPARE_VERSION_1,
084                new String[] {CmsHistoryListUtil.getDisplayVersion(m_paramVersion1, getLocale())}));
085        out.println("</th><th>");
086        out.println(
087            key(
088                Messages.GUI_COMPARE_VERSION_1,
089                new String[] {CmsHistoryListUtil.getDisplayVersion(m_paramVersion2, getLocale())}));
090        out.println("</th></tr>");
091        out.println("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>");
092        out.println("\t<tr align='center'>\n");
093        out.println("\t\t<td width='50%'><img src='");
094        out.print(getJsp().link(link1));
095        out.print("' alt='");
096        out.print(
097            key(
098                Messages.GUI_COMPARE_VERSION_1,
099                new String[] {CmsHistoryListUtil.getDisplayVersion(m_paramVersion1, getLocale())}));
100        out.print("'/></td>\n");
101        out.println("\t\t<td width='50%'><img src='");
102        out.print(getJsp().link(link2));
103        out.print("' alt='");
104        out.print(
105            key(
106                Messages.GUI_COMPARE_VERSION_1,
107                new String[] {CmsHistoryListUtil.getDisplayVersion(m_paramVersion2, getLocale())}));
108        out.print("'/></td>\n");
109        out.println("\t</tr>");
110        out.println("</table>");
111        out.println(dialogBlockEnd());
112        out.println(dialogContentEnd());
113        out.println(dialogEnd());
114        out.println(bodyEnd());
115        out.println(htmlEnd());
116    }
117
118    /**
119     * Returns the paramId1.<p>
120     *
121     * @return the paramId1
122     */
123    public String getParamId1() {
124
125        return m_paramId1;
126    }
127
128    /**
129     * Returns the paramId2.<p>
130     *
131     * @return the paramId2
132     */
133    public String getParamId2() {
134
135        return m_paramId2;
136    }
137
138    /**
139     * Returns the paramVersion1.<p>
140     *
141     * @return the paramVersion1
142     */
143    public String getParamVersion1() {
144
145        return m_paramVersion1;
146    }
147
148    /**
149     * Returns the paramVersion2.<p>
150     *
151     * @return the paramVersion2
152     */
153    public String getParamVersion2() {
154
155        return m_paramVersion2;
156    }
157
158    /**
159     * Sets the paramId1.<p>
160     *
161     * @param paramId1 the paramId1 to set
162     */
163    public void setParamId1(String paramId1) {
164
165        m_paramId1 = paramId1;
166    }
167
168    /**
169     * Sets the paramId2.<p>
170     *
171     * @param paramId2 the paramId2 to set
172     */
173    public void setParamId2(String paramId2) {
174
175        m_paramId2 = paramId2;
176    }
177
178    /**
179     * Sets the paramVersion1.<p>
180     *
181     * @param paramVersion1 the paramVersion1 to set
182     */
183    public void setParamVersion1(String paramVersion1) {
184
185        m_paramVersion1 = paramVersion1;
186    }
187
188    /**
189     * Sets the paramVersion2.<p>
190     *
191     * @param paramVersion2 the paramVersion2 to set
192     */
193    public void setParamVersion2(String paramVersion2) {
194
195        m_paramVersion2 = paramVersion2;
196    }
197}