Search in sources :

Example 1 with StandardCloseAction

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

the class SaveSetWindow method onInsertBtnClick.

@Subscribe("insertBtn")
protected void onInsertBtnClick(Button.ClickEvent event) {
    SearchFolder folder = folderSelect.getValue();
    AppUI appUI = AppUI.getCurrent();
    if (appUI != null && folder == null) {
        appUI.getNotifications().create(Notifications.NotificationType.TRAY).withCaption(getMessage("saveSetWindow.notSelected")).show();
        return;
    }
    String filterXml = folder.getFilterXml();
    folder.setFilterXml(UserSetHelper.addEntities(filterXml, ids));
    foldersPane.saveFolder(folder);
    foldersPane.refreshFolders();
    close(new StandardCloseAction(COMMIT_ACTION_ID, false));
}
Also used : StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) AppUI(io.jmix.ui.AppUI) Subscribe(io.jmix.ui.screen.Subscribe)

Example 2 with StandardCloseAction

use of io.jmix.ui.screen.StandardCloseAction 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)

Example 3 with StandardCloseAction

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

the class MultipleResourcePolicyModelCreateScreen method initScreenActions.

protected void initScreenActions() {
    Window window = getWindow();
    Messages messages = getApplicationContext().getBean(Messages.class);
    Icons icons = getApplicationContext().getBean(Icons.class);
    String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
    Action commitAndCloseAction = new BaseAction(COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
        ValidationErrors validationErrors = validateScreen();
        if (!validationErrors.isEmpty()) {
            screenValidation.showValidationErrors(this, validationErrors);
        } else {
            close(new StandardCloseAction(COMMIT_ACTION_ID));
        }
    });
    window.addAction(commitAndCloseAction);
    Action closeAction = new BaseAction(CANCEL_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> close(new StandardCloseAction(CANCEL_ACTION_ID)));
    window.addAction(closeAction);
}
Also used : Window(io.jmix.ui.component.Window) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Messages(io.jmix.core.Messages) UiScreenProperties(io.jmix.ui.UiScreenProperties) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) ValidationErrors(io.jmix.ui.component.ValidationErrors) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Example 4 with StandardCloseAction

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

the class DialogWindowImpl method onCloseShortcutTriggered.

protected void onCloseShortcutTriggered(@SuppressWarnings("unused") Object sender, @SuppressWarnings("unused") Object target) {
    if (this.isCloseable()) {
        Component component = getComponent();
        AppUI ui = (AppUI) component.getUI();
        if (!ui.isAccessibleForUser(component)) {
            LoggerFactory.getLogger(WindowImpl.class).debug("Ignore shortcut action because Window is inaccessible for user");
            return;
        }
        BeforeCloseEvent event = new BeforeCloseEvent(this, CloseOriginType.SHORTCUT);
        fireBeforeClose(event);
        if (!event.isClosePrevented()) {
            getFrameOwner().close(new StandardCloseAction(Window.CLOSE_ACTION_ID));
        }
    }
}
Also used : StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) Component(com.vaadin.ui.Component) AppUI(io.jmix.ui.AppUI)

Example 5 with StandardCloseAction

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

the class DialogWindowImpl method onCloseButtonClick.

protected void onCloseButtonClick(JmixWindow.PreCloseEvent preCloseEvent) {
    preCloseEvent.setPreventClose(true);
    Component component = getComponent();
    AppUI ui = (AppUI) component.getUI();
    if (!ui.isAccessibleForUser(component)) {
        LoggerFactory.getLogger(WindowImpl.class).debug("Ignore close button click because Window is inaccessible for user");
        return;
    }
    BeforeCloseEvent event = new BeforeCloseEvent(this, CloseOriginType.CLOSE_BUTTON);
    fireBeforeClose(event);
    if (!event.isClosePrevented()) {
        // user has clicked on X
        getFrameOwner().close(new StandardCloseAction(Window.CLOSE_ACTION_ID));
    }
}
Also used : StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) Component(com.vaadin.ui.Component) AppUI(io.jmix.ui.AppUI)

Aggregations

StandardCloseAction (io.jmix.ui.screen.StandardCloseAction)5 AppUI (io.jmix.ui.AppUI)3 Component (com.vaadin.ui.Component)2 Messages (io.jmix.core.Messages)2 Window (io.jmix.ui.component.Window)2 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)1 Metadata (io.jmix.core.Metadata)1 DashboardModel (io.jmix.dashboards.model.DashboardModel)1 Widget (io.jmix.dashboards.model.Widget)1 io.jmix.dashboards.model.visualmodel (io.jmix.dashboards.model.visualmodel)1 DashboardLayoutManager (io.jmix.dashboards.utils.DashboardLayoutManager)1 DashboardLayoutUtils (io.jmix.dashboards.utils.DashboardLayoutUtils)1 DashboardRefreshEvent (io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent)1 WidgetDropLocation (io.jmix.dashboardsui.dashboard.event.WidgetDropLocation)1 WidgetSelectedEvent (io.jmix.dashboardsui.dashboard.event.WidgetSelectedEvent)1 PersistentDashboardEdit (io.jmix.dashboardsui.screen.dashboard.editor.PersistentDashboardEdit)1 CssLayoutCreationDialog (io.jmix.dashboardsui.screen.dashboard.editor.css.CssLayoutCreationDialog)1 GridCreationDialog (io.jmix.dashboardsui.screen.dashboard.editor.grid.GridCreationDialog)1 ResponsiveCreationDialog (io.jmix.dashboardsui.screen.dashboard.editor.responsive.ResponsiveCreationDialog)1 WidgetEdit (io.jmix.dashboardsui.screen.widget.WidgetEdit)1