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.setup.ui;
029
030import org.opencms.setup.CmsSetupBean;
031import org.opencms.ui.A_CmsUI;
032import org.opencms.ui.CmsVaadinUtils;
033
034import com.vaadin.server.VaadinRequest;
035import com.vaadin.server.VaadinServletRequest;
036import com.vaadin.ui.Button;
037import com.vaadin.ui.Label;
038import com.vaadin.ui.VerticalLayout;
039
040/**
041 * Setup step: Configuration notes.
042 */
043public class CmsSetupStep07ConfigNotes extends A_CmsSetupStep {
044
045    /** The forward button. */
046    private Button m_forwardButton;
047
048    /** The main layout. */
049    private VerticalLayout m_mainLayout;
050
051    private VerticalLayout m_notesContainer;
052
053    /**
054     * Creates a new instance.
055     *
056     * @param context the setup context
057     */
058    public CmsSetupStep07ConfigNotes(I_SetupUiContext context) {
059
060        super(context);
061
062        CmsVaadinUtils.readAndLocalizeDesign(this, null, null);
063        String name = "browser_config.html";
064        Label label = htmlLabel(readSnippet(name));
065        label.setWidth("100%");
066        m_notesContainer.addComponent(label);
067        m_forwardButton.addClickListener(evt -> forward());
068    }
069
070    /**
071     * Proceed to next step.
072     */
073    public void forward() {
074
075        m_context.getSetupBean().prepareStep10();
076        CmsSetupBean bean = m_context.getSetupBean();
077        VaadinServletRequest request = (VaadinServletRequest)(VaadinRequest.getCurrent());
078        String servletMapping = bean.getServletMapping();
079        String openLink = null;
080
081        if (!servletMapping.startsWith("/")) {
082            servletMapping = "/" + servletMapping;
083        }
084        if (servletMapping.endsWith("/*")) {
085            // usually a mapping must be in the form "/opencms/*", cut off all slashes
086            servletMapping = servletMapping.substring(0, servletMapping.length() - 2);
087        }
088        openLink = request.getContextPath() + servletMapping + (bean.hasIndexHtml() ? "/index.html" : "/system/login");
089
090        A_CmsUI.get().getPage().setLocation(openLink);
091    }
092
093}