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;
029
030import org.opencms.main.OpenCmsServlet;
031import org.opencms.setup.ui.CmsSetupErrorDialog;
032import org.opencms.setup.updater.dialogs.A_CmsUpdateDialog;
033import org.opencms.setup.updater.dialogs.CmsUpdateStep01LicenseDialog;
034import org.opencms.ui.A_CmsUI;
035import org.opencms.ui.components.CmsBasicDialog;
036import org.opencms.ui.components.CmsBasicDialog.DialogWidth;
037
038import com.vaadin.annotations.Theme;
039import com.vaadin.server.VaadinRequest;
040import com.vaadin.ui.Window;
041
042@Theme("opencms")
043public class CmsUpdateUI extends A_CmsUI {
044
045    private Window m_window;
046
047    private CmsUpdateBean m_updateBean;
048
049    public void displayDialog(A_CmsUpdateDialog dialog) {
050
051        if (dialog.init(this)) {
052            m_window.setContent(dialog);
053            m_window.setCaption(dialog.getCaption());
054            m_window.center();
055        }
056
057    }
058
059    public CmsUpdateBean getUpdateBean() {
060
061        return m_updateBean;
062    }
063
064    @Override
065    protected void init(VaadinRequest request) {
066
067        this.addStyleName("opencms");
068        m_updateBean = new CmsUpdateBean();
069        if (!m_updateBean.checkOceeVersion(org.opencms.main.OpenCms.getSystemInfo().getVersionNumber())) {
070
071        } else {
072            m_updateBean.init(
073                CmsUpdateServlet.instance.getServletConfig().getServletContext().getRealPath("/"),
074                CmsUpdateServlet.instance.getServletContext().getInitParameter(
075                    OpenCmsServlet.SERVLET_PARAM_OPEN_CMS_SERVLET),
076                CmsUpdateServlet.instance.getServletContext().getInitParameter(
077                    OpenCmsServlet.SERVLET_PARAM_DEFAULT_WEB_APPLICATION));
078            // check wizards accessability
079            boolean wizardEnabled = m_updateBean.getWizardEnabled();
080            Window window = createWindow();
081            addWindow(window);
082            if (!wizardEnabled) {
083                window.setContent(new CmsSetupErrorDialog("Wizard not enabled", null, new Runnable() {
084
085                    public void run() {
086
087                        //
088
089                    }
090                }, window));
091            } else {
092                displayDialog(new CmsUpdateStep01LicenseDialog());
093            }
094
095        }
096
097    }
098
099    private Window createWindow() {
100
101        if (m_window != null) {
102            m_window.close();
103        }
104        Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
105        window.setDraggable(false);
106        window.setResizable(false);
107        window.setClosable(false);
108        m_window = window;
109        return m_window;
110    }
111
112}