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.containerpage.client.ui;
029
030import org.opencms.ade.containerpage.client.CmsContainerpageController;
031import org.opencms.ade.containerpage.client.CmsContainerpageHandler;
032import org.opencms.ade.containerpage.shared.CmsCntPageData;
033import org.opencms.gwt.client.CmsCoreProvider;
034import org.opencms.gwt.client.ui.A_CmsToolbarButton;
035import org.opencms.gwt.client.ui.I_CmsButton;
036import org.opencms.gwt.client.util.CmsEmbeddedDialogHandler;
037import org.opencms.gwt.shared.CmsCoreData;
038import org.opencms.gwt.shared.CmsGwtConstants;
039import org.opencms.util.CmsUUID;
040
041import java.util.ArrayList;
042import java.util.HashMap;
043import java.util.Map;
044
045/**
046 * The toolbar button for the favorite dialog.
047 */
048public class CmsToolbarFavLocationButton extends A_CmsToolbarButton<CmsContainerpageHandler> {
049
050    /**
051     * Constructor.<p>
052     *
053     * @param handler the container page handler
054     */
055    public CmsToolbarFavLocationButton(CmsContainerpageHandler handler) {
056
057        super(I_CmsButton.ButtonData.BOOKMARKS_BUTTON, handler);
058    }
059
060    /**
061     * @see org.opencms.gwt.client.ui.I_CmsToolbarButton#onToolbarActivate()
062     */
063    public void onToolbarActivate() {
064
065        // not used
066
067    }
068
069    /**
070     * @see org.opencms.gwt.client.ui.A_CmsToolbarButton#onToolbarClick()
071     */
072    @Override
073    public void onToolbarClick() {
074
075        CmsEmbeddedDialogHandler handler = new CmsEmbeddedDialogHandler();
076        Map<String, String> params = new HashMap<>();
077        CmsCntPageData pageData = CmsContainerpageController.get().getData();
078        CmsCoreData coreData = CmsCoreProvider.get();
079        CmsUUID projectId = coreData.getProjectId();
080        CmsUUID pageId = coreData.getStructureId();
081        CmsUUID detailId = pageData.getDetailId();
082        String siteRoot = coreData.getSiteRoot();
083        params.put(CmsGwtConstants.Favorites.PARAM_DETAIL, "" + detailId);
084        params.put(CmsGwtConstants.Favorites.PARAM_PAGE, "" + pageId);
085        params.put(CmsGwtConstants.Favorites.PARAM_SITE, siteRoot);
086        params.put(CmsGwtConstants.Favorites.PARAM_PROJECT, "" + projectId);
087        handler.openDialog("org.opencms.ui.actions.CmsFavoriteDialogAction", null, new ArrayList<CmsUUID>(), params);
088    }
089
090    /**
091     * @see org.opencms.gwt.client.ui.I_CmsToolbarButton#onToolbarDeactivate()
092     */
093    public void onToolbarDeactivate() {
094
095        // not used
096    }
097
098}