Search in sources :

Example 1 with DashboardRefreshEvent

use of io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent in project jmix by jmix-framework.

the class PersistentDashboardEdit method onWidgetMoved.

@EventListener
public void onWidgetMoved(WidgetMovedEvent event) {
    UUID targetLayoutId = event.getParentLayoutUuid();
    DashboardModel dashboard = getDashboardModel();
    dropLayoutTools.moveComponent(event.getSource(), targetLayoutId, event.getLocation());
    uiEventPublisher.publishEvent(new DashboardRefreshEvent(dashboard.getVisualModel(), event.getSource().getId()));
}
Also used : DashboardModel(io.jmix.dashboards.model.DashboardModel) DashboardRefreshEvent(io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent) EventListener(org.springframework.context.event.EventListener)

Example 2 with DashboardRefreshEvent

use of io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent in project jmix by jmix-framework.

the class PersistentDashboardEdit method onWeightChanged.

@EventListener
public void onWeightChanged(WeightChangedEvent event) {
    DashboardLayout source = event.getSource();
    if (isParentResponsiveLayout(source)) {
        ResponsiveLayout parentLayout = (ResponsiveLayout) findParentLayout(getDashboardModel().getVisualModel(), source.getId());
        ResponsiveArea responsiveArea = parentLayout.getAreas().stream().filter(ra -> source.getId().equals(ra.getComponent().getId())).findFirst().orElseThrow(() -> new RuntimeException("Can't find layout with uuid " + source.getId()));
        screens.create(ResponsiveCreationDialog.class, OpenMode.DIALOG, new MapScreenOptions(getDisplaySizeMap(responsiveArea))).show().addAfterCloseListener(e -> {
            StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
            ResponsiveCreationDialog dialog = (ResponsiveCreationDialog) e.getSource();
            if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
                responsiveArea.setXs(dialog.getXs());
                responsiveArea.setSm(dialog.getSm());
                responsiveArea.setMd(dialog.getMd());
                responsiveArea.setLg(dialog.getLg());
                uiEventPublisher.publishEvent(new DashboardRefreshEvent(getDashboardModel().getVisualModel(), source.getId()));
            }
        });
    } else {
        screens.create(WeightDialog.class, OpenMode.DIALOG, new MapScreenOptions(ParamsMap.of(WeightDialog.WIDGET, source))).show().addAfterCloseListener(e -> {
            StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
            if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
                uiEventPublisher.publishEvent(new DashboardRefreshEvent(getDashboardModel().getVisualModel(), source.getId()));
            }
        });
    }
}
Also used : ResponsiveCreationDialog(io.jmix.dashboardsui.screen.dashboard.editor.responsive.ResponsiveCreationDialog) DashboardLayoutUtils.isParentResponsiveLayout(io.jmix.dashboards.utils.DashboardLayoutUtils.isParentResponsiveLayout) DashboardRefreshEvent(io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent) EventListener(org.springframework.context.event.EventListener)

Example 3 with DashboardRefreshEvent

use of io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent in project jmix by jmix-framework.

the class PersistentDashboardEdit method onColspanChanged.

@EventListener
public void onColspanChanged(ColspanChangedEvent event) {
    DashboardLayout source = event.getSource();
    screens.create(ColspanDialog.class, OpenMode.DIALOG, new MapScreenOptions(ParamsMap.of(WeightDialog.WIDGET, source))).show().addAfterCloseListener(e -> {
        StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
        if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
            uiEventPublisher.publishEvent(new DashboardRefreshEvent(getDashboardModel().getVisualModel(), source.getId()));
        }
    });
}
Also used : DashboardRefreshEvent(io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent) EventListener(org.springframework.context.event.EventListener)

Example 4 with DashboardRefreshEvent

use of io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent in project jmix by jmix-framework.

the class PersistentDashboardEdit method onOpenWidgetEditor.

@EventListener
public void onOpenWidgetEditor(WidgetEditEvent event) {
    Widget widget = event.getSource().getWidget();
    screenBuilders.editor(Widget.class, this).editEntity(widget).withOpenMode(OpenMode.DIALOG).build().show().addAfterCloseListener(e -> {
        StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
        if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
            WidgetLayout widgetLayout = getDashboardModel().getWidgetLayout(widget.getId());
            widgetLayout.setWidget(((WidgetEdit) e.getSource()).getEditedEntity());
            uiEventPublisher.publishEvent(new DashboardRefreshEvent(getDashboardModel().getVisualModel(), widget.getId()));
        }
    });
}
Also used : Widget(io.jmix.dashboards.model.Widget) DashboardRefreshEvent(io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent) EventListener(org.springframework.context.event.EventListener)

Example 5 with DashboardRefreshEvent

use of io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent in project jmix by jmix-framework.

the class DropLayoutTools method reorderWidgetsAndPushEvents.

private void reorderWidgetsAndPushEvents(DashboardLayout layout, DashboardLayout targetLayout, WidgetDropLocation location) {
    DashboardLayout parentLayout = targetLayout instanceof WidgetLayout ? findParentLayout(getDashboard().getVisualModel(), targetLayout) : targetLayout;
    boolean added = addChild(parentLayout, layout);
    if (!added && parentLayout instanceof GridLayout) {
        showDropOnGridLayoutNotAllowedNotification();
        return;
    }
    layout.setParent(parentLayout);
    moveComponent(layout, targetLayout.getId(), location);
    uiEventPublisher.publishEvent(new DashboardRefreshEvent(getDashboard().getVisualModel()));
    uiEventPublisher.publishEvent(new WidgetSelectedEvent(layout.getId(), WidgetSelectedEvent.Target.CANVAS));
}
Also used : WidgetSelectedEvent(io.jmix.dashboardsui.dashboard.event.WidgetSelectedEvent) DashboardRefreshEvent(io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent)

Aggregations

DashboardRefreshEvent (io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent)8 EventListener (org.springframework.context.event.EventListener)7 DashboardModel (io.jmix.dashboards.model.DashboardModel)2 Widget (io.jmix.dashboards.model.Widget)1 DashboardLayoutUtils.isParentResponsiveLayout (io.jmix.dashboards.utils.DashboardLayoutUtils.isParentResponsiveLayout)1 WidgetSelectedEvent (io.jmix.dashboardsui.dashboard.event.WidgetSelectedEvent)1 ExpandDialog (io.jmix.dashboardsui.screen.dashboard.editor.expand.ExpandDialog)1 ResponsiveCreationDialog (io.jmix.dashboardsui.screen.dashboard.editor.responsive.ResponsiveCreationDialog)1 StyleDialog (io.jmix.dashboardsui.screen.dashboard.editor.style.StyleDialog)1