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.ui.apps.cacheadmin;
029
030import org.opencms.ui.CmsVaadinUtils;
031import org.opencms.ui.FontOpenCms;
032import org.opencms.ui.apps.cacheadmin.CmsFlushCache.I_CloseableDialog;
033import org.opencms.ui.components.CmsBasicDialog;
034
035import com.vaadin.v7.shared.ui.label.ContentMode;
036import com.vaadin.ui.Button;
037import com.vaadin.ui.Button.ClickEvent;
038import com.vaadin.ui.Button.ClickListener;
039import com.vaadin.v7.ui.Label;
040
041/**
042 * Dialog to confirm flush without any options.<p>
043 */
044public class CmsConfirmSimpleFlushDialog extends CmsBasicDialog implements I_CloseableDialog {
045
046    /**Vaadin serial id.*/
047    private static final long serialVersionUID = 6454462284178282427L;
048
049    /**Runnable for close action.*/
050    Runnable m_closeRunnable;
051
052    /**Runnable for ok action. */
053    Runnable m_okRunnable;
054
055    /**Vaadin button.*/
056    private Button m_cancelButton;
057
058    /**Vaadin label.*/
059    private Label m_icon;
060
061    /**Vaadin label.*/
062    private Label m_label;
063
064    /**Vaadin button.*/
065    private Button m_okButton;
066
067    /**
068     * Public constructor.<p>
069     *
070     * @param message to be shown
071     */
072    public CmsConfirmSimpleFlushDialog(String message) {
073        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
074
075        m_label.setValue(message);
076
077        m_icon.setContentMode(ContentMode.HTML);
078        m_icon.setValue(FontOpenCms.WARNING.getHtml());
079
080        m_okButton.addClickListener(new ClickListener() {
081
082            private static final long serialVersionUID = 1336535963768785962L;
083
084            public void buttonClick(ClickEvent event) {
085
086                m_closeRunnable.run();
087                if (m_okRunnable != null) {
088                    m_okRunnable.run();
089                }
090            }
091        });
092
093        m_cancelButton.addClickListener(new ClickListener() {
094
095            private static final long serialVersionUID = 3918008642649054392L;
096
097            public void buttonClick(ClickEvent event) {
098
099                m_closeRunnable.run();
100            }
101        });
102    }
103
104    /**
105     * @see org.opencms.ui.apps.cacheadmin.CmsFlushCache.I_CloseableDialog#setCloseRunnable(java.lang.Runnable)
106     */
107    public void setCloseRunnable(Runnable closeRunnable) {
108
109        m_closeRunnable = closeRunnable;
110
111    }
112
113    /**
114     * @see org.opencms.ui.apps.cacheadmin.CmsFlushCache.I_CloseableDialog#setOkRunnable(java.lang.Runnable)
115     */
116    public void setOkRunnable(Runnable okRunnable) {
117
118        m_okRunnable = okRunnable;
119
120    }
121}