Search in sources :

Example 1 with OpenMode

use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.

the class DesktopWindowManager method moveWindowTab.

/**
 * @param window   Window implementation (DesktopWindow)
 * @param position new tab position
 */
protected void moveWindowTab(Window window, int position) {
    if (isMainWindowManager && position >= 0 && position < tabsPane.getComponentCount()) {
        WindowOpenInfo openInfo = windowOpenMode.get(window);
        if (openInfo != null) {
            OpenMode openMode = openInfo.getOpenMode();
            if (openMode == OpenMode.NEW_TAB || openMode == OpenMode.THIS_TAB) {
                // show in tabsheet
                JComponent layout = (JComponent) openInfo.getData();
                int currentPosition = getTabPosition(layout);
                String label = tabsPane.getTitleAt(currentPosition);
                Icon icon = tabsPane.getIconAt(currentPosition);
                Icon iconDis = tabsPane.getDisabledIconAt(currentPosition);
                String tooltip = tabsPane.getToolTipTextAt(currentPosition);
                boolean enabled = tabsPane.isEnabledAt(currentPosition);
                int keycode = tabsPane.getMnemonicAt(currentPosition);
                int mnemonicLoc = tabsPane.getDisplayedMnemonicIndexAt(currentPosition);
                Color fg = tabsPane.getForegroundAt(currentPosition);
                Color bg = tabsPane.getBackgroundAt(currentPosition);
                java.awt.Component tabHeaderComponent = tabsPane.getTabComponentAt(currentPosition);
                tabsPane.remove(layout);
                tabsPane.insertTab(label, icon, layout, tooltip, position);
                tabsPane.setDisabledIconAt(position, iconDis);
                tabsPane.setEnabledAt(position, enabled);
                tabsPane.setMnemonicAt(position, keycode);
                tabsPane.setDisplayedMnemonicIndexAt(position, mnemonicLoc);
                tabsPane.setForegroundAt(position, fg);
                tabsPane.setBackgroundAt(position, bg);
                tabsPane.setTabComponentAt(position, tabHeaderComponent);
                tabsPane.setSelectedComponent(layout);
            }
        }
    }
}
Also used : OpenMode(com.haulmont.cuba.gui.screen.OpenMode) java.awt(java.awt)

Example 2 with OpenMode

use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.

the class DesktopWindowManager method selectWindowTab.

@Override
public void selectWindowTab(Window window) {
    if (isMainWindowManager) {
        WindowOpenInfo openInfo = windowOpenMode.get(window);
        if (openInfo != null) {
            OpenMode openMode = openInfo.getOpenMode();
            if (openMode == OpenMode.NEW_TAB || openMode == OpenMode.THIS_TAB) {
                // show in tabsheet
                JComponent layout = (JComponent) openInfo.getData();
                tabsPane.setSelectedComponent(layout);
            }
        }
    }
}
Also used : OpenMode(com.haulmont.cuba.gui.screen.OpenMode)

Example 3 with OpenMode

use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.

the class ScreenNavigationHandler method createScreen.

protected Screen createScreen(NavigationState requestedState, String screenRoute, WindowInfo windowInfo, AppUI ui) {
    Screen screen;
    if (isEditor(windowInfo)) {
        screen = createEditor(windowInfo, screenRoute, requestedState, ui);
    } else {
        OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), screenRoute, ui);
        screen = ui.getScreens().create(windowInfo.getId(), openMode);
    }
    return screen;
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) OpenMode(com.haulmont.cuba.gui.screen.OpenMode)

Example 4 with OpenMode

use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.

the class ScreenNavigationHandler method createEditor.

protected Screen createEditor(WindowInfo windowInfo, String screenRoute, NavigationState requestedState, AppUI ui) {
    Map<String, Object> options = createEditorScreenOptions(windowInfo, requestedState, ui);
    if (MapUtils.isEmpty(options)) {
        log.info("Unable to load entity for editor: '{}'. " + "Subscribe for 'UrlParamsChangedEvent' to obtain its serialized id", windowInfo.getId());
    }
    Screen editor;
    OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), screenRoute, ui);
    if (isLegacyScreen(windowInfo.getControllerClass())) {
        editor = ui.getScreens().create(windowInfo.getId(), openMode, new MapScreenOptions(options));
    } else {
        editor = ui.getScreens().create(windowInfo.getId(), openMode);
    }
    if (MapUtils.isNotEmpty(options)) {
        Entity entity = (Entity) options.get(WindowParams.ITEM.name());
        // noinspection unchecked
        ((EditorScreen<Entity>) editor).setEntityToEdit(entity);
    }
    return editor;
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) OpenMode(com.haulmont.cuba.gui.screen.OpenMode)

Example 5 with OpenMode

use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.

the class DesktopWindowManager method setWindowCaption.

@Override
public void setWindowCaption(Window window, String caption, String description) {
    Window desktopWindow = window;
    if (window instanceof Window.Wrapper) {
        desktopWindow = ((Window.Wrapper) window).getWrappedWindow();
    }
    window.setCaption(caption);
    String formattedCaption = formatTabDescription(caption, description);
    WindowOpenInfo openInfo = windowOpenMode.get(desktopWindow);
    if (openInfo != null) {
        OpenMode openMode = openInfo.getOpenMode();
        if (openMode != OpenMode.DIALOG) {
            if (tabsPane != null) {
                int selectedIndex = tabsPane.getSelectedIndex();
                if (selectedIndex != -1) {
                    setActiveWindowCaption(caption, description, selectedIndex);
                }
            } else if (!isMainWindowManager) {
                setTopLevelWindowCaption(formattedCaption);
            }
        } else {
            JDialog jDialog = (JDialog) openInfo.getData();
            if (jDialog != null) {
                jDialog.setTitle(formattedCaption);
            }
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) OpenMode(com.haulmont.cuba.gui.screen.OpenMode)

Aggregations

OpenMode (com.haulmont.cuba.gui.screen.OpenMode)5 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)2 Screen (com.haulmont.cuba.gui.screen.Screen)2 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)2 Entity (com.haulmont.cuba.core.entity.Entity)1 DesktopWindow (com.haulmont.cuba.desktop.gui.components.DesktopWindow)1 Window (com.haulmont.cuba.gui.components.Window)1 MapScreenOptions (com.haulmont.cuba.gui.screen.MapScreenOptions)1 java.awt (java.awt)1