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.portal.base.events;
020
021import java.io.IOException;
022import java.io.Writer;
023import java.util.List;
024
025import org.jdrupes.json.JsonObject;
026
027/**
028 * Sent by the server to the browser in response to {@link PortalPrepared} 
029 * (see this event's description for details). The provided information
030 * enables the portal to restore portlets to their previous positions.
031 */
032public class LastPortalLayout extends PortalCommand {
033
034    private final List<String> previewLayout;
035    private final List<String> tabsLayout;
036    private final JsonObject xtraInfo;
037
038    /**
039     * @param previewLayout
040     * @param tabsLayout
041     */
042    public LastPortalLayout(List<String> previewLayout,
043            List<String> tabsLayout, JsonObject xtraInfo) {
044        this.previewLayout = previewLayout;
045        this.tabsLayout = tabsLayout;
046        this.xtraInfo = xtraInfo;
047    }
048
049    /**
050     * @return the previewLayout
051     */
052    public List<String> previewLayout() {
053        return previewLayout;
054    }
055
056    /**
057     * @return the tabsLayout
058     */
059    public List<String> tabsLayout() {
060        return tabsLayout;
061    }
062
063    /**
064     * @return the extra information
065     */
066    public JsonObject xtraInfo() {
067        return xtraInfo;
068    }
069
070    @Override
071    public void toJson(Writer writer) throws IOException {
072        toJson(writer, "lastPortalLayout", previewLayout(), tabsLayout(),
073            xtraInfo());
074    }
075
076}