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.ade.galleries.client.preview;
029
030import org.opencms.ade.galleries.client.preview.ui.A_CmsPreviewDialog;
031import org.opencms.ade.galleries.client.ui.CmsGalleryDialog;
032import org.opencms.ade.galleries.shared.CmsResourceInfoBean;
033import org.opencms.ade.galleries.shared.I_CmsGalleryProviderConstants.GalleryMode;
034import org.opencms.util.CmsUUID;
035
036import java.util.Map;
037
038import com.google.gwt.user.client.Command;
039
040/**
041 * Interface for resource preview within the galleries dialog.<p>
042 *
043 * @param <T> the resource info bean type
044 *
045 * @since 8.0.0
046 */
047public interface I_CmsResourcePreview<T extends CmsResourceInfoBean> {
048
049    /**
050     * Gets the gallery dialog in which this preview is displayed.<p>
051     *
052     * @return the gallery dialog
053     */
054    CmsGalleryDialog getGalleryDialog();
055
056    /**
057     * Returns the gallery mode.<p>
058     *
059     * @return the gallery mode
060     */
061    GalleryMode getGalleryMode();
062
063    /**
064     * Returns the preview handler.<p>
065     *
066     * @return the preview handler
067     */
068    I_CmsPreviewHandler<T> getHandler();
069
070    /**
071     * Returns the current locale.<p>
072     *
073     * @return the current locale
074     */
075    String getLocale();
076
077    /**
078     * Returns the preview dialog widget.<p>
079     *
080     * @return the preview dialog widget
081     */
082    A_CmsPreviewDialog<T> getPreviewDialog();
083
084    /**
085     * Returns the preview name, should return the same as in {@link org.opencms.ade.galleries.preview.I_CmsPreviewProvider#getPreviewName()}.<p>
086     *
087     * @return the preview name
088     */
089    String getPreviewName();
090
091    /**
092     * Returns the resource path of the current resource.<p>
093     *
094     * @return the resource path
095     */
096    String getResourcePath();
097
098    /**
099     * Returns the site independent perma link.<p>
100     *
101     * @return the site independent link
102     */
103    String getViewLink();
104
105    /**
106     * Loads the resource info and displays the retrieved data.<p>
107     *
108     * @param resourcePath the resource path
109     */
110    void loadResourceInfo(String resourcePath);
111
112    /**
113     * Opens the preview for the given resource in the given gallery mode.<p>
114     *
115     * @param resourcePath the resource path
116     * @param disableSelection if the selection from the preview should be disabled
117     */
118    void openPreview(String resourcePath, boolean disableSelection);
119
120    /**
121     * Removes the preview widget.<p>
122     */
123    void removePreview();
124
125    /**
126     * Saves the changed properties.<p>
127     *
128     * @param properties the changed properties
129     * @param afterSaveCommand the command to execute after saving the properties
130     */
131    void saveProperties(Map<String, String> properties, Command afterSaveCommand);
132
133    /**
134     * Sets the selected resource in the opening editor for the given gallery mode.<p>
135     *
136     * @param resourcePath the resource path
137     * @param structureId the structure id
138     * @param title the resource title
139     */
140    void selectResource(String resourcePath, CmsUUID structureId, String title);
141
142    /**
143     * Checks if further user input is required and other wise sets the selected resource
144     * via the provided integrator functions <code>setLink</code> and <code>setImage</code>.<p>
145     * Returning <code>true</code> when all data has been.
146     * If there are any changes, the user will be requested to save those and the editor OK function will be called again.<p>
147     *
148     * @return <code>true</code> when all data has been set, <code>false</code> if there were any changes that need saving
149     */
150    boolean setDataInEditor();
151
152    /**
153     * Sets the current resource within the editor or xml-content.<p>
154     */
155    void setResource();
156
157    /**
158     * Calls the preview handler to display the given data.<p>
159     *
160     * @param resourceInfo the resource info data
161     */
162    void showData(T resourceInfo);
163}