Search in sources :

Example 1 with FoldersPane

use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.

the class WebFilterHelper method getFoldersPane.

@Override
public Object getFoldersPane() {
    Window.TopLevelWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
    FoldersPane foldersPane = null;
    if (topLevelWindow instanceof Window.HasFoldersPane) {
        foldersPane = ((Window.HasFoldersPane) topLevelWindow).getFoldersPane();
    }
    if (foldersPane == null) {
        return null;
    }
    return foldersPane.unwrap(CubaFoldersPane.class);
}
Also used : AppFolderEditWindow(com.haulmont.cuba.web.app.folders.AppFolderEditWindow) FolderEditWindow(com.haulmont.cuba.web.app.folders.FolderEditWindow) FoldersPane(com.haulmont.cuba.gui.components.mainwindow.FoldersPane) CubaFoldersPane(com.haulmont.cuba.web.app.folders.CubaFoldersPane)

Example 2 with FoldersPane

use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.

the class WebWindowManager method createTopLevelWindow.

public void createTopLevelWindow(WindowInfo windowInfo) {
    ui.beforeTopLevelWindowInit();
    String template = windowInfo.getTemplate();
    Window.TopLevelWindow topLevelWindow;
    Map<String, Object> params = Collections.emptyMap();
    if (template != null) {
        // noinspection unchecked
        topLevelWindow = (Window.TopLevelWindow) createWindow(windowInfo, OpenType.NEW_TAB, params, LayoutLoaderConfig.getWindowLoaders(), true);
    } else {
        Class screenClass = windowInfo.getScreenClass();
        if (screenClass != null) {
            // noinspection unchecked
            topLevelWindow = (Window.TopLevelWindow) createWindowByScreenClass(windowInfo, params);
        } else {
            throw new DevelopmentException("Unable to load top level window");
        }
    }
    // detect work area
    Window windowImpl = ((Window.Wrapper) topLevelWindow).getWrappedWindow();
    if (topLevelWindow instanceof AbstractMainWindow) {
        AbstractMainWindow mainWindow = (AbstractMainWindow) topLevelWindow;
        // bind system UI components to AbstractMainWindow
        ComponentsHelper.walkComponents(windowImpl, component -> {
            if (component instanceof AppWorkArea) {
                mainWindow.setWorkArea((AppWorkArea) component);
            } else if (component instanceof UserIndicator) {
                mainWindow.setUserIndicator((UserIndicator) component);
            } else if (component instanceof FoldersPane) {
                mainWindow.setFoldersPane((FoldersPane) component);
            }
            return false;
        });
    }
    ui.setTopLevelWindow(topLevelWindow);
    // load menu
    ComponentsHelper.walkComponents(windowImpl, component -> {
        if (component instanceof TopLevelWindowAttachListener) {
            ((TopLevelWindowAttachListener) component).topLevelWindowAttached(topLevelWindow);
        }
        return false;
    });
    if (topLevelWindow instanceof Window.HasWorkArea) {
        AppWorkArea workArea = ((Window.HasWorkArea) topLevelWindow).getWorkArea();
        if (workArea != null) {
            workArea.addStateChangeListener(new AppWorkArea.StateChangeListener() {

                @Override
                public void stateChanged(AppWorkArea.State newState) {
                    if (newState == AppWorkArea.State.WINDOW_CONTAINER) {
                        initTabShortcuts();
                        // listener used only once
                        getConfiguredWorkArea(createWorkAreaContext(topLevelWindow)).removeStateChangeListener(this);
                    }
                }
            });
        }
    }
    afterShowWindow(topLevelWindow);
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) FoldersPane(com.haulmont.cuba.gui.components.mainwindow.FoldersPane) TopLevelWindowAttachListener(com.haulmont.cuba.gui.components.mainwindow.TopLevelWindowAttachListener) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) UserIndicator(com.haulmont.cuba.gui.components.mainwindow.UserIndicator)

Example 3 with FoldersPane

use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.

the class WebFilterHelper method saveFolder.

@Override
@Nullable
public AbstractSearchFolder saveFolder(AbstractSearchFolder folder) {
    Window.TopLevelWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
    FoldersPane foldersPane = null;
    if (topLevelWindow instanceof Window.HasFoldersPane) {
        foldersPane = ((Window.HasFoldersPane) topLevelWindow).getFoldersPane();
    }
    if (foldersPane == null)
        return null;
    CubaFoldersPane foldersPaneImpl = foldersPane.unwrap(CubaFoldersPane.class);
    AbstractSearchFolder savedFolder = (AbstractSearchFolder) foldersPaneImpl.saveFolder(folder);
    foldersPaneImpl.refreshFolders();
    return savedFolder;
}
Also used : AppFolderEditWindow(com.haulmont.cuba.web.app.folders.AppFolderEditWindow) FolderEditWindow(com.haulmont.cuba.web.app.folders.FolderEditWindow) FoldersPane(com.haulmont.cuba.gui.components.mainwindow.FoldersPane) CubaFoldersPane(com.haulmont.cuba.web.app.folders.CubaFoldersPane) CubaFoldersPane(com.haulmont.cuba.web.app.folders.CubaFoldersPane) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) Nullable(javax.annotation.Nullable)

Example 4 with FoldersPane

use of com.haulmont.cuba.gui.components.mainwindow.FoldersPane in project cuba by cuba-platform.

the class WebFilterHelper method removeFolderFromFoldersPane.

@Override
public void removeFolderFromFoldersPane(Folder folder) {
    Window.TopLevelWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
    FoldersPane foldersPane = null;
    if (topLevelWindow instanceof Window.HasFoldersPane) {
        foldersPane = ((Window.HasFoldersPane) topLevelWindow).getFoldersPane();
    }
    if (foldersPane == null) {
        return;
    }
    CubaFoldersPane foldersPaneImpl = foldersPane.unwrap(CubaFoldersPane.class);
    foldersPaneImpl.removeFolder(folder);
    foldersPaneImpl.refreshFolders();
}
Also used : AppFolderEditWindow(com.haulmont.cuba.web.app.folders.AppFolderEditWindow) FolderEditWindow(com.haulmont.cuba.web.app.folders.FolderEditWindow) FoldersPane(com.haulmont.cuba.gui.components.mainwindow.FoldersPane) CubaFoldersPane(com.haulmont.cuba.web.app.folders.CubaFoldersPane) CubaFoldersPane(com.haulmont.cuba.web.app.folders.CubaFoldersPane)

Aggregations

FoldersPane (com.haulmont.cuba.gui.components.mainwindow.FoldersPane)4 AppFolderEditWindow (com.haulmont.cuba.web.app.folders.AppFolderEditWindow)3 CubaFoldersPane (com.haulmont.cuba.web.app.folders.CubaFoldersPane)3 FolderEditWindow (com.haulmont.cuba.web.app.folders.FolderEditWindow)3 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 DevelopmentException (com.haulmont.cuba.core.global.DevelopmentException)1 Window (com.haulmont.cuba.gui.components.Window)1 AppWorkArea (com.haulmont.cuba.gui.components.mainwindow.AppWorkArea)1 TopLevelWindowAttachListener (com.haulmont.cuba.gui.components.mainwindow.TopLevelWindowAttachListener)1 UserIndicator (com.haulmont.cuba.gui.components.mainwindow.UserIndicator)1 WebWindow (com.haulmont.cuba.web.gui.WebWindow)1 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)1 Nullable (javax.annotation.Nullable)1