<commit_before>/**
 * Copyright (C) 2011  jtalks.org Team
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * Also add information on how to contact you by electronic and paper mail.
 * Creation date: Apr 12, 2011 / 8:05:19 PM
 * The jtalks.org Project
 */
package org.jtalks.poulpe.web.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Messagebox;

/**
 * The class represents the ZK implementation of the manager for showing
 * different types of dialog messages.
 * 
 * @author <NAME>
 * 
 */
public class DialogManagerImpl implements DialogManager {

    private static final Logger LOGGER = LoggerFactory.getLogger(DialogManagerImpl.class);

    /** {@inheritDoc} */
    @Override
    public void notify(String str) {
        try {
            Messagebox.show(Labels.getLabel(str), Labels.getLabel("window.warning"), Messagebox.OK,
                    Messagebox.EXCLAMATION);
        } catch (InterruptedException e) {
            LOGGER.error("Problem with showing messagebox.", e);
            throw new AssertionError(e);    // it's unlikely to happen
        }
    }

    /** {@inheritDoc} */
    @Override
    public void confirmDeletion(final String victim, final DialogManager.Performable confirmable) {
        final String title = Labels.getLabel("item.delete.$") + " " + victim + "?";
        final String text = Labels.getLabel("item.delete.question") + " " + victim + "?";
        try {
            Messagebox.show(text, title, Messagebox.YES | Messagebox.CANCEL, Messagebox.QUESTION,
                    Messagebox.CANCEL, new DialogDeleteListener(confirmable));
        } catch (InterruptedException e) {
            LOGGER.error("Problem with showing deleting messagebox.", e);
            throw new AssertionError(e);    // it's unlikely to happen
        }
    }

    /**
     * The class for deciding if the item ought to be deleted in accordance with
     * the message button user clicked on.
     * 
     * @author <NAME>
     * 
     */
    private static class DialogDeleteListener implements EventListener {

        private Performable confirmable;

        /**
         * Constructor of the listener which initialises the object whose
         * {@code execute} method will be invoked.
         * 
         * @param confirmable
         *            the object whose {@code execute} method will be invoked
         */
        public DialogDeleteListener(Performable confirmable) {
            this.confirmable = confirmable;
        }<commit_msg>#POULPE-6 The set of buttons in deletion MesageBox was changed to YES & NO.<commit_after>/**
 * Copyright (C) 2011  jtalks.org Team
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * Also add information on how to contact you by electronic and paper mail.
 * Creation date: Apr 12, 2011 / 8:05:19 PM
 * The jtalks.org Project
 */
package org.jtalks.poulpe.web.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Messagebox;

/**
 * The class represents the ZK implementation of the manager for showing
 * different types of dialog messages.
 * 
 * @author <NAME>
 * 
 */
public class DialogManagerImpl implements DialogManager {

    private static final Logger LOGGER = LoggerFactory.getLogger(DialogManagerImpl.class);

    /** {@inheritDoc} */
    @Override
    public void notify(String str) {
        try {
            Messagebox.show(Labels.getLabel(str), Labels.getLabel("window.warning"), Messagebox.OK,
                    Messagebox.EXCLAMATION);
        } catch (InterruptedException e) {
            LOGGER.error("Problem with showing messagebox.", e);
            throw new AssertionError(e);    // it's unlikely to happen
        }
    }

    /** {@inheritDoc} */
    @Override
    public void confirmDeletion(final String victim, final DialogManager.Performable confirmable) {
        final String title = Labels.getLabel("item.delete.$") + " " + victim + "?";
        final String text = Labels.getLabel("item.delete.question") + " " + victim + "?";
        try {
            Messagebox.show(text, title, Messagebox.YES | Messagebox.NO, Messagebox.QUESTION,
                    Messagebox.NO, new DialogDeleteListener(confirmable));
        } catch (InterruptedException e) {
            LOGGER.error("Problem with showing deleting messagebox.", e);
            throw new AssertionError(e);    // it's unlikely to happen
        }
    }

    /**
     * The class for deciding if the item ought to be deleted in accordance with
     * the message button user clicked on.
     * 
     * @author <NAME>
     * 
     */
    private static class DialogDeleteListener implements EventListener {

        private Performable confirmable;

        /**
         * Constructor of the listener which initialises the object whose
         * {@code execute} method will be invoked.
         * 
         * @param confirmable
         *            the object whose {@code execute} method will be invoked
         */
        public DialogDeleteListener(Performable confirmable) {
            this.confirmable = confirmable;
        }
{'fraction_non_alphanumeric': 0.08564607579826918, 'fraction_numerical': 0.009101760668457177, 'mean_word_length': 2.7699662542182226, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '685948', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1726, 'n_words': 654}