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.sitemap.client.toolbar;
029
030import org.opencms.ade.sitemap.client.Messages;
031import org.opencms.ade.sitemap.client.control.CmsSitemapController;
032import org.opencms.gwt.client.ui.I_CmsButton;
033
034import com.google.gwt.event.dom.client.ClickEvent;
035import com.google.gwt.event.dom.client.ClickHandler;
036
037/**
038 * Sitemap toolbar clipboard button.<p>
039 *
040 * @since 8.0.0
041 */
042public class CmsToolbarClipboardButton extends A_CmsToolbarListMenuButton {
043
044    /** The clear deleted list button enabled flag. */
045    private boolean m_clearDeleted;
046
047    /** The clear modified list button enabled flag. */
048    private boolean m_clearModified;
049
050    /** The modified list tab. */
051    private CmsListTab m_modifiedTab;
052
053    /** The deleted list tab. */
054    private CmsListTab m_deletedTab;
055
056    /**
057     * Constructor.<p>
058     *
059     * @param toolbar the toolbar instance
060     * @param controller the sitemap controller
061     */
062    public CmsToolbarClipboardButton(final CmsSitemapToolbar toolbar, final CmsSitemapController controller) {
063
064        super(
065            I_CmsButton.ButtonData.CLIPBOARD_BUTTON.getTitle(),
066            I_CmsButton.ButtonData.CLIPBOARD_BUTTON.getIconClass(),
067            toolbar,
068            controller);
069    }
070
071    /**
072     * Enables/disables the clear deleted list button.<p>
073     *
074     * @param enable <code>true</code> to enable
075     */
076    public void enableClearDeleted(boolean enable) {
077
078        m_clearDeleted = enable;
079        if (m_deletedTab != null) {
080            m_deletedTab.setClearButtonEnabled(enable);
081        }
082    }
083
084    /**
085     * Enables/disables the clear modified list button.<p>
086     *
087     * @param enable <code>true</code> to enable
088     */
089    public void enableClearModified(boolean enable) {
090
091        m_clearModified = enable;
092        if (m_modifiedTab != null) {
093            m_modifiedTab.setClearButtonEnabled(enable);
094        }
095    }
096
097    /**
098     * @see org.opencms.ade.sitemap.client.toolbar.A_CmsToolbarListMenuButton#initContent()
099     */
100    @Override
101    protected boolean initContent() {
102
103        CmsToolbarClipboardView view = new CmsToolbarClipboardView(this, getController());
104        m_modifiedTab = createTab(view.getModified());
105        m_modifiedTab.addClearListButton(new ClickHandler() {
106
107            /**
108             * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
109             */
110            public void onClick(ClickEvent event) {
111
112                getController().clearModifiedList();
113            }
114        });
115        m_modifiedTab.setClearButtonEnabled(m_clearModified);
116        addTab(m_modifiedTab, Messages.get().key(Messages.GUI_CLIPBOARD_MODIFIED_TITLE_0));
117        m_deletedTab = createTab(view.getDeleted());
118
119        m_deletedTab.addClearListButton(new ClickHandler() {
120
121            /**
122             * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
123             */
124            public void onClick(ClickEvent event) {
125
126                getController().clearDeletedList();
127            }
128        });
129        m_deletedTab.setClearButtonEnabled(m_clearDeleted);
130        addTab(m_deletedTab, Messages.get().key(Messages.GUI_CLIPBOARD_DELETED_TITLE_0));
131        return true;
132    }
133}