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;
029
030import org.opencms.ade.galleries.client.ui.CmsGalleryDialog;
031import org.opencms.gwt.client.A_CmsEntryPoint;
032import org.opencms.gwt.client.ui.CmsPopup;
033import org.opencms.gwt.client.ui.CmsToolbarPopup;
034
035import com.google.gwt.user.client.Command;
036import com.google.gwt.user.client.ui.SimplePanel;
037
038/**
039 * Gallery Dialog entry class to be open from the vfs tree.<p>
040 *
041 * @since 8.0.0
042 */
043public class CmsGallery extends A_CmsEntryPoint {
044
045    /**
046     * Closes the dialog.<p>
047     */
048    static native void closeDialog()/*-{
049
050        if (typeof $wnd.closeDialog === 'function') {
051            $wnd.closeDialog();
052        } else if ($wnd[@org.opencms.ade.galleries.shared.I_CmsGalleryProviderConstants::ATTR_CLOSE_LINK]) {
053            $wnd.location.href = $wnd[@org.opencms.ade.galleries.shared.I_CmsGalleryProviderConstants::ATTR_CLOSE_LINK];
054        }
055    }-*/;
056
057    /**
058     * @see org.opencms.gwt.client.A_CmsEntryPoint#onModuleLoad()
059     */
060    @Override
061    public void onModuleLoad() {
062
063        super.onModuleLoad();
064        int dialogHeight = CmsToolbarPopup.getAvailableHeight();
065        int dialogWidth = CmsToolbarPopup.getAvailableWidth();
066        CmsPopup popup = new CmsPopup(dialogWidth);
067        popup.setGlassEnabled(false);
068
069        popup.removePadding();
070        SimplePanel container = new SimplePanel();
071        popup.setMainContent(container);
072        popup.addDialogClose(new Command() {
073
074            public void execute() {
075
076                closeDialog();
077            }
078        });
079        popup.center();
080        popup.catchNotifications();
081        CmsGalleryDialog dialog = CmsGalleryFactory.createDialog(popup);
082        container.setWidget(dialog);
083        dialog.setDialogSize(dialogWidth, dialogHeight);
084        popup.center();
085
086    }
087}