Search in sources :

Example 11 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class AppWorkAreaImpl method getCurrentBreadcrumbs.

@Override
public Collection<Screen> getCurrentBreadcrumbs() {
    TabWindowContainer layout = getCurrentWindowContainer();
    if (layout != null) {
        WindowBreadCrumbs breadCrumbs = layout.getBreadCrumbs();
        List<Screen> screens = new ArrayList<>(breadCrumbs.getWindows().size());
        Iterator<Window> windowIterator = breadCrumbs.getWindows().descendingIterator();
        while (windowIterator.hasNext()) {
            Screen frameOwner = windowIterator.next().getFrameOwner();
            screens.add(frameOwner);
        }
        return screens;
    }
    return Collections.emptyList();
}
Also used : Screen(io.jmix.ui.screen.Screen)

Example 12 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class AppWorkAreaImpl method reflectTabChangeToUrl.

protected void reflectTabChangeToUrl(boolean userOriginated) {
    if (!userOriginated) {
        return;
    }
    Component selectedTab = tabbedContainer.getTabSheetBehaviour().getSelectedTab();
    if (selectedTab == null) {
        return;
    }
    Window selectedWindow = ((TabWindowContainer) selectedTab).getBreadCrumbs().getCurrentWindow();
    WindowImpl windowImpl = (WindowImpl) selectedWindow;
    if (windowImpl != null) {
        NavigationState resolvedState = windowImpl.getResolvedState();
        if (resolvedState != null) {
            int stateMark = generateUrlStateMark();
            NavigationState newState = new NavigationState(resolvedState.getRoot(), String.valueOf(stateMark), resolvedState.getNestedRoute(), resolvedState.getParams());
            windowImpl.setResolvedState(newState);
            Screen screen = selectedWindow.getFrameOwner();
            UrlRouting urlRouting = UiControllerUtils.getScreenContext(screen).getUrlRouting();
            urlRouting.pushState(screen, newState.getParams());
        }
    }
}
Also used : NavigationState(io.jmix.ui.navigation.NavigationState) Screen(io.jmix.ui.screen.Screen) Component(com.vaadin.ui.Component) UrlRouting(io.jmix.ui.navigation.UrlRouting)

Example 13 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class AppWorkAreaImpl method closeWindowStack.

protected boolean closeWindowStack(WindowStack windowStack) {
    boolean closed = true;
    Collection<Screen> tabScreens = windowStack.getBreadcrumbs();
    for (Screen screen : tabScreens) {
        if (isNotCloseable(screen.getWindow())) {
            continue;
        }
        if (isWindowClosePrevented(screen.getWindow(), CloseOriginType.CLOSE_BUTTON)) {
            closed = false;
            // focus tab
            windowStack.select();
            break;
        }
        OperationResult closeResult = screen.close(FrameOwner.WINDOW_CLOSE_ACTION);
        if (closeResult.getStatus() != OperationResult.Status.SUCCESS) {
            closed = false;
            // focus tab
            windowStack.select();
            break;
        }
    }
    return closed;
}
Also used : Screen(io.jmix.ui.screen.Screen) OperationResult(io.jmix.ui.util.OperationResult)

Example 14 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class EntitySuggestionFieldImpl method showSuggestions.

protected void showSuggestions(List<V> suggestions, boolean userOriginated) {
    FrameOwner frameOwner = getFrame().getFrameOwner();
    Collection<Screen> dialogScreens = UiControllerUtils.getScreenContext(frameOwner).getScreens().getOpenedScreens().getDialogScreens();
    Screen lastDialog = null;
    for (Screen dialogScreen : dialogScreens) {
        lastDialog = dialogScreen;
    }
    if (frameOwner instanceof ScreenFragment) {
        frameOwner = ComponentsHelper.getScreen((ScreenFragment) frameOwner);
    }
    if (lastDialog == null || Objects.equals(frameOwner, lastDialog)) {
        getComponent().showSuggestions(suggestions, userOriginated);
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Screen(io.jmix.ui.screen.Screen)

Example 15 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class DropLayoutTools method addComponent.

public void addComponent(DashboardLayout layout, UUID targetLayoutUuid, WidgetDropLocation location) {
    DashboardLayout targetLayout = findLayout(getDashboard().getVisualModel(), targetLayoutUuid);
    if (layout instanceof CssLayout) {
        Screen screen = createScreen(CssLayoutCreationDialog.class);
        screen.addAfterCloseListener(e -> {
            StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
            if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
                CssLayoutCreationDialog dialog = (CssLayoutCreationDialog) e.getSource();
                CssLayout cssLayout = layoutManager.createCssLayout(dialog.getResponsive(), dialog.getCssStyleName());
                reorderWidgetsAndPushEvents(cssLayout, targetLayout, location);
            }
        });
    }
    if (layout instanceof GridLayout) {
        Screen screen = createScreen(GridCreationDialog.class);
        screen.addAfterCloseListener(e -> {
            StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
            if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
                GridCreationDialog dialog = (GridCreationDialog) e.getSource();
                GridLayout gridLayout = layoutManager.createGridLayout(dialog.getCols(), dialog.getRows());
                reorderWidgetsAndPushEvents(gridLayout, targetLayout, location);
            }
        });
    } else if (layout instanceof WidgetTemplateLayout) {
        WidgetLayout widgetLayout = layoutManager.createWidgetLayout(((WidgetTemplateLayout) layout).getWidget(), true);
        reorderWidgetsAndPushEvents(widgetLayout, targetLayout, location);
    } else if (layout instanceof WidgetLayout) {
        WidgetLayout widgetLayout = layoutManager.createWidgetLayout(((WidgetLayout) layout).getWidget(), false);
        screenBuilders.editor(Widget.class, dashboardEdit).newEntity(widgetLayout.getWidget()).withOpenMode(OpenMode.DIALOG).build().show().addAfterCloseListener(e -> {
            StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
            if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
                widgetLayout.setWidget(((WidgetEdit) e.getSource()).getEditedEntity());
                reorderWidgetsAndPushEvents(widgetLayout, targetLayout, location);
            }
        });
    } else if (layout instanceof VerticalLayout) {
        reorderWidgetsAndPushEvents(metadata.create(VerticalLayout.class), targetLayout, location);
    } else if (layout instanceof HorizontalLayout) {
        reorderWidgetsAndPushEvents(metadata.create(HorizontalLayout.class), targetLayout, location);
    } else if (layout instanceof ResponsiveLayout) {
        Screen screen = createScreen(ResponsiveCreationDialog.class);
        screen.addAfterCloseListener(e -> {
            StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
            ResponsiveCreationDialog dialog = (ResponsiveCreationDialog) e.getSource();
            if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
                ResponsiveLayout responsiveLayout = layoutManager.createResponsiveLayout(dialog.getXs(), dialog.getSm(), dialog.getMd(), dialog.getLg());
                reorderWidgetsAndPushEvents(responsiveLayout, targetLayout, location);
            }
        });
    }
}
Also used : java.util(java.util) WidgetSelectedEvent(io.jmix.dashboardsui.dashboard.event.WidgetSelectedEvent) UiEventPublisher(io.jmix.ui.UiEventPublisher) DashboardRefreshEvent(io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent) GridCreationDialog(io.jmix.dashboardsui.screen.dashboard.editor.grid.GridCreationDialog) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Frame(io.jmix.ui.component.Frame) DashboardLayoutUtils(io.jmix.dashboards.utils.DashboardLayoutUtils) Widget(io.jmix.dashboards.model.Widget) Scope(org.springframework.context.annotation.Scope) Messages(io.jmix.core.Messages) Notifications(io.jmix.ui.Notifications) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) InstanceContainer(io.jmix.ui.model.InstanceContainer) ScreenBuilders(io.jmix.ui.ScreenBuilders) WidgetDropLocation(io.jmix.dashboardsui.dashboard.event.WidgetDropLocation) WidgetEdit(io.jmix.dashboardsui.screen.widget.WidgetEdit) DashboardLayoutManager(io.jmix.dashboards.utils.DashboardLayoutManager) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Window(io.jmix.ui.component.Window) Logger(org.slf4j.Logger) Metadata(io.jmix.core.Metadata) Screen(io.jmix.ui.screen.Screen) io.jmix.dashboards.model.visualmodel(io.jmix.dashboards.model.visualmodel) PersistentDashboardEdit(io.jmix.dashboardsui.screen.dashboard.editor.PersistentDashboardEdit) UiControllerUtils(io.jmix.ui.screen.UiControllerUtils) OpenMode(io.jmix.ui.screen.OpenMode) Component(org.springframework.stereotype.Component) DashboardModel(io.jmix.dashboards.model.DashboardModel) ResponsiveCreationDialog(io.jmix.dashboardsui.screen.dashboard.editor.responsive.ResponsiveCreationDialog) CssLayoutCreationDialog(io.jmix.dashboardsui.screen.dashboard.editor.css.CssLayoutCreationDialog) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) GridCreationDialog(io.jmix.dashboardsui.screen.dashboard.editor.grid.GridCreationDialog) Screen(io.jmix.ui.screen.Screen) ResponsiveCreationDialog(io.jmix.dashboardsui.screen.dashboard.editor.responsive.ResponsiveCreationDialog) Widget(io.jmix.dashboards.model.Widget) CssLayoutCreationDialog(io.jmix.dashboardsui.screen.dashboard.editor.css.CssLayoutCreationDialog)

Aggregations

Screen (io.jmix.ui.screen.Screen)82 EditorScreen (io.jmix.ui.screen.EditorScreen)20 LookupScreen (io.jmix.ui.screen.LookupScreen)15 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)11 Nullable (javax.annotation.Nullable)9 Messages (io.jmix.core.Messages)6 WindowImpl (io.jmix.ui.component.impl.WindowImpl)6 Screens (io.jmix.ui.Screens)5 io.jmix.ui.component (io.jmix.ui.component)5 NavigationState (io.jmix.ui.navigation.NavigationState)5 FrameOwner (io.jmix.ui.screen.FrameOwner)5 UiControllerUtils (io.jmix.ui.screen.UiControllerUtils)5 java.util (java.util)5 Collectors (java.util.stream.Collectors)5 LoggerFactory (org.slf4j.LoggerFactory)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)4 ScreenEditorWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)4 MetaClass (io.jmix.core.metamodel.model.MetaClass)4 BaseAction (io.jmix.ui.action.BaseAction)4