/*
 * Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved.
 * Haulmont Technology proprietary and confidential.
 * Use is subject to license terms.
 */

package com.haulmont.cuba.web.sys;

import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.Messages;
import com.haulmont.cuba.gui.AppConfig;
import com.haulmont.cuba.web.App;
import com.haulmont.cuba.web.AppUI;
import com.vaadin.server.DefaultUIProvider;
import com.vaadin.server.UICreateEvent;

/**
 * @author artamonov
 * @version $Id$
 */
public class CubaUIProvider extends DefaultUIProvider {
    @Override
    public String getPageTitle(UICreateEvent event) {
        if (AppUI.class.isAssignableFrom(event.getUIClass())) {
            // vaadin7 problem with dynamic page title
            if (App.isBound()) {
                Messages messages = AppBeans.get(Messages.class);
                String messagesPack = AppConfig.getMessagesPack();
                App app = App.getInstance();
                if (app.getConnection().isConnected()) {
                    return messages.getMessage(messagesPack, "application.caption", app.getLocale());
                }
                else
                    return messages.getMessage(messagesPack, "loginWindow.caption", app.getLocale());
            }
            return super.getPageTitle(event);
        } else
            return super.getPageTitle(event);
    }
}
@@ -217,1241 +217,197 @@
 com.
-haulmont.cuba.core.global.AppBeans;%0D%0Aimport com.haulmont.cuba.core.global.Messages;%0D%0Aimport com.haulmont.cuba.gui.AppConfig;%0D%0Aimport com.haulmont.cuba.web.App;%0D%0Aimport com.haulmont.cuba.web.AppUI;%0D%0Aimport com.vaadin.server.DefaultUIProvider;%0D%0Aimport com.vaadin.server.UICreateEvent;%0D%0A%0D%0A/**%0D%0A * @author artamonov%0D%0A * @version $Id$%0D%0A */%0D%0Apublic class CubaUIProvider extends DefaultUIProvider %7B%0D%0A    @Override%0D%0A    public String getPageTitle(UICreateEvent event) %7B%0D%0A        if (AppUI.class.isAssignableFrom(event.getUIClass())) %7B%0D%0A            // vaadin7 problem with dynamic page title%0D%0A            if (App.isBound()) %7B%0D%0A                Messages messages = AppBeans.get(Messages.class);%0D%0A                String messagesPack = AppConfig.getMessagesPack();%0D%0A                App app = App.getInstance();%0D%0A                if (app.getConnection().isConnected()) %7B%0D%0A                    return messages.getMessage(messagesPack, %22application.caption%22, app.getLocale());%0D%0A                %7D%0D%0A                else%0D%0A                    return messages.getMessage(messagesPack, %22loginWindow.caption%22, app.getLocale());%0D%0A            %7D%0D%0A            return super.getPageTitle(event);%0D%0A        %7D else%0D%0A            return super.getPageTitle(event);%0D%0A    %7D
+vaadin.server.DefaultUIProvider;%0D%0A%0D%0A/**%0D%0A * Custom provider for possible extension%0D%0A *%0D%0A * @author artamonov%0D%0A * @version $Id$%0D%0A */%0D%0Apublic class CubaUIProvider extends DefaultUIProvider %7B%0D%0A
 %0D%0A%7D

Fix loss of title on a page refresh #PL-2285