Search in sources :

Example 1 with ClientCacheManager

use of com.haulmont.cuba.client.sys.cache.ClientCacheManager in project cuba by cuba-platform.

the class App method connectionStateChanged.

@Override
public void connectionStateChanged(Connection connection) throws LoginException {
    MessagesClientImpl messagesClient = AppBeans.get(Messages.NAME);
    SessionMessagesNotifier messagesNotifier = AppBeans.get(SessionMessagesNotifier.NAME);
    ClientCacheManager clientCacheManager = AppBeans.get(ClientCacheManager.NAME);
    clientCacheManager.initialize();
    if (connection.isConnected()) {
        applicationSession = new ApplicationSession(new ConcurrentHashMap<>());
        messagesClient.setRemoteSearch(true);
        initExceptionHandlers(true);
        DesktopWindowManager windowManager = mainFrame.getWindowManager();
        mainFrame.setContentPane(createContentPane());
        mainFrame.repaint();
        windowManager.setTabsPane(tabsPane);
        initClientTime();
        messagesNotifier.activate();
        SwingUtilities.invokeLater(this::afterLoggedIn);
    } else {
        messagesNotifier.deactivate();
        messagesClient.setRemoteSearch(false);
        Iterator<TopLevelFrame> it = topLevelFrames.iterator();
        while (it.hasNext()) {
            TopLevelFrame frame = it.next();
            if (frame != mainFrame) {
                DesktopWindowManager windowManager = frame.getWindowManager();
                if (windowManager != null)
                    windowManager.dispose();
                frame.dispose();
                it.remove();
            }
        }
        DesktopWindowManager windowManager = mainFrame.getWindowManager();
        if (windowManager != null)
            windowManager.dispose();
        applicationSession = null;
        mainFrame.setContentPane(createStartContentPane());
        mainFrame.repaint();
        initExceptionHandlers(false);
        showLoginDialog();
    }
}
Also used : MessagesClientImpl(com.haulmont.cuba.client.sys.MessagesClientImpl) SessionMessagesNotifier(com.haulmont.cuba.desktop.gui.SessionMessagesNotifier) ClientCacheManager(com.haulmont.cuba.client.sys.cache.ClientCacheManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

MessagesClientImpl (com.haulmont.cuba.client.sys.MessagesClientImpl)1 ClientCacheManager (com.haulmont.cuba.client.sys.cache.ClientCacheManager)1 SessionMessagesNotifier (com.haulmont.cuba.desktop.gui.SessionMessagesNotifier)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1