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()));
}
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()));
}
});
}
}
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()));
}
});
}
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()));
}
});
}
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));
}
Aggregations