001/*
002 * JGrapes Event Driven Framework
003 * Copyright (C) 2017-2018 Michael N. Lipp
004 * 
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Affero General Public License as published by 
007 * the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 * 
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Affero General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jgrapes.webconsole.base.events;
020
021import java.util.Set;
022import org.jgrapes.core.Event;
023import org.jgrapes.webconsole.base.Conlet.RenderMode;
024import org.jgrapes.webconsole.base.RenderSupport;
025
026/**
027 * A notification that a conlet view was deleted in the browser.
028 */
029public class ConletDeleted extends Event<Void> {
030
031    private final RenderSupport renderSupport;
032    private final String conletId;
033    private final Set<RenderMode> renderModes;
034
035    /**
036     * Creates a new event.
037     *
038     * @param renderSupport the render support from the web console in case
039     * the response requires it
040     * @param conletId the web console component model that the notification is
041     * directed at
042     * @param renderModes the kind of views that have been deleted. If
043     * empty, the last view has been deleted, i.e. the conlet is no longer
044     * used in the broweser.
045     */
046    public ConletDeleted(RenderSupport renderSupport,
047            String conletId, Set<RenderMode> renderModes) {
048        this.renderSupport = renderSupport;
049        this.conletId = conletId;
050        this.renderModes = renderModes;
051    }
052
053    /**
054     * Returns the render support.
055     * 
056     * @return the render support
057     */
058    public RenderSupport renderSupport() {
059        return renderSupport;
060    }
061
062    /**
063     * Returns the web console component id.
064     * 
065     * @return the web console component id
066     */
067    public String conletId() {
068        return conletId;
069    }
070
071    /**
072     * Returns the render modes that have been deleted. An empty
073     * set indicates that all views have been deleted, i.e.
074     * the conlet is no longer used in the browser.
075     *
076     * @return the render modes
077     */
078    public Set<RenderMode> renderModes() {
079        return renderModes;
080    }
081}