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.ui;
029
030import org.opencms.ade.galleries.client.preview.CmsImageFormatHandler;
031import org.opencms.ade.galleries.client.preview.CmsImagePreviewHandler;
032import org.opencms.ade.galleries.client.preview.I_CmsPreviewHandler;
033import org.opencms.ade.galleries.client.ui.css.I_CmsLayoutBundle;
034import org.opencms.ade.galleries.shared.CmsImageInfoBean;
035import org.opencms.ade.galleries.shared.I_CmsGalleryProviderConstants.GalleryMode;
036import org.opencms.gwt.client.CmsCoreProvider;
037
038import java.util.Map;
039
040import com.google.gwt.user.client.ui.FlowPanel;
041
042/**
043 * The widget to display the format information of the selected image.<p>
044 *
045 * @since 8.0.
046 */
047public class CmsImageFormatsTab extends A_CmsPreviewDetailTab {
048
049    /** The content panel. */
050    private FlowPanel m_content;
051
052    /** The preview handler. */
053    private CmsImagePreviewHandler m_handler;
054
055    /**
056     * The constructor.<p>
057     *
058     * @param dialogMode the mode of the gallery
059     * @param height the height of the tab
060     * @param width the width of the height
061     * @param handler the preview handler
062     * @param formats the map with format values for the select box
063     */
064    public CmsImageFormatsTab(
065        GalleryMode dialogMode,
066        int height,
067        int width,
068        CmsImagePreviewHandler handler,
069        Map<String, String> formats) {
070
071        super(dialogMode, height, width);
072        m_content = new FlowPanel();
073        m_content.addStyleName(I_CmsLayoutBundle.INSTANCE.previewDialogCss().propertiesList());
074        m_content.addStyleName(I_CmsLayoutBundle.INSTANCE.previewDialogCss().formatsPanel());
075        m_main.insert(m_content, 0);
076        m_handler = handler;
077
078    }
079
080    /**
081     * Displays the provided image information.<p>
082     *
083     * @param imageInfo the image information
084     */
085    public void fillContent(CmsImageInfoBean imageInfo) {
086
087        String viewLink = imageInfo.getViewLink() != null
088        ? imageInfo.getViewLink()
089        : CmsCoreProvider.get().link(imageInfo.getResourcePath());
090        CmsCroppingDialog croppingDialog = new CmsCroppingDialog(viewLink);
091        m_handler.getGalleryDialog().getParentPanel().add(croppingDialog);
092        CmsImageFormatHandler formatHandler = new CmsImageFormatHandler(
093            getDialogMode(),
094            m_handler.getGalleryDialog(),
095            imageInfo.getSelectedPath(),
096            imageInfo.getHeight(),
097            imageInfo.getWidth());
098        CmsImageFormatsForm formatsForm = new CmsImageFormatsForm(formatHandler);
099        formatHandler.init(formatsForm, croppingDialog);
100        m_handler.setFormatHandler(formatHandler);
101        m_content.clear();
102        m_content.add(formatsForm);
103    }
104
105    /**
106     * @see org.opencms.ade.galleries.client.preview.ui.A_CmsPreviewDetailTab#getHandler()
107     */
108    @Override
109    protected I_CmsPreviewHandler<?> getHandler() {
110
111        return m_handler;
112    }
113}