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.ui;
029
030import org.opencms.ade.galleries.client.CmsGalleryController;
031import org.opencms.ade.galleries.client.CmsGalleryControllerHandler;
032import org.opencms.ade.galleries.client.I_CmsGalleryHandler;
033import org.opencms.ade.galleries.client.I_CmsGalleryWidgetHandler;
034import org.opencms.ade.galleries.shared.CmsResultItemBean;
035import org.opencms.ade.galleries.shared.I_CmsGalleryConfiguration;
036import org.opencms.gwt.client.dnd.CmsDNDHandler;
037import org.opencms.gwt.client.ui.CmsPopup;
038import org.opencms.gwt.client.ui.CmsToolbarPopup;
039import org.opencms.gwt.client.ui.I_CmsAutoHider;
040
041import com.google.gwt.user.client.ui.Panel;
042import com.google.gwt.user.client.ui.SimplePanel;
043import com.google.gwt.user.client.ui.Widget;
044
045/**
046 * The gallery dialog popup.<p>
047 */
048public class CmsGalleryPopup extends CmsPopup implements I_CmsGalleryHandler {
049
050    /** The main panel. */
051    private SimplePanel m_container;
052
053    /** The gallery controller. */
054    private CmsGalleryController m_controller;
055
056    /**
057     * Constructor.<p>
058     *
059     * @param handler the widget handler, used to set the widgets value
060     * @param conf the gallery configuration
061     */
062    public CmsGalleryPopup(I_CmsGalleryWidgetHandler handler, I_CmsGalleryConfiguration conf) {
063
064        this();
065        int dialogHeight = CmsToolbarPopup.getAvailableHeight();
066        int dialogWidth = CmsToolbarPopup.getAvailableWidth();
067        setWidth(dialogWidth);
068        CmsGalleryDialog galleryDialog = new CmsGalleryDialog(this);
069        galleryDialog.setDialogSize(dialogWidth, dialogHeight);
070        m_controller = new CmsGalleryController(new CmsGalleryControllerHandler(galleryDialog), conf);
071        galleryDialog.setWidgetHandler(handler);
072        m_container.setWidget(galleryDialog);
073    }
074
075    /**
076     * Constructor.<p>
077     */
078    private CmsGalleryPopup() {
079
080        super(650);
081        setGlassEnabled(true);
082        catchNotifications();
083        removePadding();
084        m_container = new SimplePanel();
085        setMainContent(m_container);
086        addDialogClose(null);
087    }
088
089    /**
090     * @see org.opencms.ade.galleries.client.I_CmsGalleryHandler#filterDnd(org.opencms.ade.galleries.shared.CmsResultItemBean)
091     */
092    public boolean filterDnd(CmsResultItemBean resultBean) {
093
094        return true;
095    }
096
097    /**
098     * @see org.opencms.ade.galleries.client.I_CmsGalleryHandler#getAdditionalTypeTabControl()
099     */
100    public Widget getAdditionalTypeTabControl() {
101
102        // TODO Auto-generated method stub
103        return null;
104    }
105
106    /**
107     * @see org.opencms.ade.galleries.client.I_CmsGalleryHandler#getAutoHideParent()
108     */
109    public I_CmsAutoHider getAutoHideParent() {
110
111        return this;
112    }
113
114    /**
115     * Returns the popup content.<p>
116     *
117     * @return the popup content
118     */
119    public Panel getContainer() {
120
121        return m_container;
122    }
123
124    /**
125     * @see org.opencms.ade.galleries.client.I_CmsGalleryHandler#getDndHandler()
126     */
127    public CmsDNDHandler getDndHandler() {
128
129        return null;
130    }
131
132    /**
133     * @see org.opencms.ade.galleries.client.I_CmsGalleryHandler#processResultItem(org.opencms.ade.galleries.client.ui.CmsResultListItem)
134     */
135    public void processResultItem(CmsResultListItem item) {
136
137        // do nothing
138
139    }
140
141    /**
142     * Searches for a specific element and opens it's preview if found.<p>
143     *
144     * @param path the element path
145     */
146    public void searchElement(String path) {
147
148        //center();
149        m_controller.searchElement(path, new Runnable() {
150
151            public void run() {
152
153                center();
154            }
155        });
156    }
157}