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.file.CmsFile;
031import org.opencms.jsp.CmsJspActionElement;
032import org.opencms.util.CmsUUID;
033import org.opencms.workplace.CmsDialog;
034
035import javax.servlet.jsp.JspWriter;
036
037/**
038 * Provides a GUI for displaying two images.<p>
039 *
040 * @since 6.0.0
041 */
042public class CmsPointerComparisonDialog extends CmsDialog {
043
044    /** Parameter value for the structure Id of the first file. */
045    private String m_paramId1;
046
047    /** Parameter value for the structure Id of the second file. */
048    private String m_paramId2;
049
050    /** Parameter value for the version of the first file. */
051    private String m_paramVersion1;
052
053    /** Parameter value for the version of the second file. */
054    private String m_paramVersion2;
055
056    /**
057     * Default constructor.<p>
058     *
059     * @param jsp an initialized JSP action element
060     */
061    public CmsPointerComparisonDialog(CmsJspActionElement jsp) {
062
063        super(jsp);
064    }
065
066    /**
067     * Performs the dialog actions depending on the initialized action and displays the dialog form.<p>
068     *
069     * @throws Exception if writing to the JSP out fails
070     */
071    public void displayDialog() throws Exception {
072
073        if (getAction() == ACTION_CANCEL) {
074            actionCloseDialog();
075        }
076        CmsFile resource1 = CmsResourceComparisonDialog.readFile(
077            getCms(),
078            new CmsUUID(getParamId1()),
079            getParamVersion1());
080        CmsFile resource2 = CmsResourceComparisonDialog.readFile(
081            getCms(),
082            new CmsUUID(getParamId2()),
083            getParamVersion2());
084        String linkTarget1 = new String(resource1.getContents());
085        String linkTarget2 = new String(resource2.getContents());
086        JspWriter out = getJsp().getJspContext().getOut();
087        out.println(dialogBlockStart(key(Messages.GUI_COMPARE_CONTENT_0)));
088        out.println(dialogContentStart(null));
089        out.println("<table cellpadding='0' cellspacing='0' border='0' class='maxwidth'><tr align='center'><th>");
090        out.println(
091            key(
092                Messages.GUI_COMPARE_VERSION_1,
093                new String[] {CmsHistoryListUtil.getDisplayVersion(m_paramVersion1, getLocale())}));
094        out.println("</th><th>");
095        out.println(
096            key(
097                Messages.GUI_COMPARE_VERSION_1,
098                new String[] {CmsHistoryListUtil.getDisplayVersion(m_paramVersion2, getLocale())}));
099        out.println("</th></tr>");
100        out.print("<tr><td><a href=\"");
101        out.print(linkTarget1);
102        out.print("\">");
103        out.print(linkTarget1);
104        out.print("</a>");
105        out.print("</td><td width='50%'>\n");
106        out.print("<a href=\"");
107        out.print(linkTarget2);
108        out.print("\">");
109        out.print(linkTarget2);
110        out.print("</a>");
111        out.println("</td></td></table>");
112        out.println(dialogBlockEnd());
113        out.println(dialogContentEnd());
114        out.println(dialogEnd());
115        out.println(bodyEnd());
116        out.println(htmlEnd());
117    }
118
119    /**
120     * Returns the paramId1.<p>
121     *
122     * @return the paramId1
123     */
124    public String getParamId1() {
125
126        return m_paramId1;
127    }
128
129    /**
130     * Returns the paramId2.<p>
131     *
132     * @return the paramId2
133     */
134    public String getParamId2() {
135
136        return m_paramId2;
137    }
138
139    /**
140     * Returns the paramVersion1.<p>
141     *
142     * @return the paramVersion1
143     */
144    public String getParamVersion1() {
145
146        return m_paramVersion1;
147    }
148
149    /**
150     * Returns the paramVersion2.<p>
151     *
152     * @return the paramVersion2
153     */
154    public String getParamVersion2() {
155
156        return m_paramVersion2;
157    }
158
159    /**
160     * Sets the paramId1.<p>
161     *
162     * @param paramId1 the paramId1 to set
163     */
164    public void setParamId1(String paramId1) {
165
166        m_paramId1 = paramId1;
167    }
168
169    /**
170     * Sets the paramId2.<p>
171     *
172     * @param paramId2 the paramId2 to set
173     */
174    public void setParamId2(String paramId2) {
175
176        m_paramId2 = paramId2;
177    }
178
179    /**
180     * Sets the paramVersion1.<p>
181     *
182     * @param paramVersion1 the paramVersion1 to set
183     */
184    public void setParamVersion1(String paramVersion1) {
185
186        m_paramVersion1 = paramVersion1;
187    }
188
189    /**
190     * Sets the paramVersion2.<p>
191     *
192     * @param paramVersion2 the paramVersion2 to set
193     */
194    public void setParamVersion2(String paramVersion2) {
195
196        m_paramVersion2 = paramVersion2;
197    }
198}