Search in sources :

Example 1 with WidgetSelectedEvent

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

the class CanvasDropComponentsFactory method addLayoutClickListener.

protected void addLayoutClickListener(CanvasLayout layout) {
    layout.addLayoutClickListener(e -> {
        CanvasLayout selectedLayout = null;
        Component clickedComponent = e.getClickedComponent();
        if (clickedComponent == null) {
            HasComponents source = e.getSource();
            if (source instanceof ComponentContainer) {
                Component parent = ((ComponentContainer) source).getParent();
                if (parent instanceof CanvasLayout) {
                    selectedLayout = (CanvasLayout) parent;
                }
            }
        } else {
            selectedLayout = findCanvasLayout(clickedComponent);
        }
        if (selectedLayout != null) {
            uiEventPublisher.publishEvent(new WidgetSelectedEvent(selectedLayout.getUuid(), WidgetSelectedEvent.Target.CANVAS));
        }
    });
}
Also used : WidgetSelectedEvent(io.jmix.dashboardsui.dashboard.event.WidgetSelectedEvent) CanvasLayout(io.jmix.dashboardsui.component.CanvasLayout) AbstractComponent(com.vaadin.ui.AbstractComponent)

Example 2 with WidgetSelectedEvent

use of io.jmix.dashboardsui.dashboard.event.WidgetSelectedEvent 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

WidgetSelectedEvent (io.jmix.dashboardsui.dashboard.event.WidgetSelectedEvent)2 AbstractComponent (com.vaadin.ui.AbstractComponent)1 CanvasLayout (io.jmix.dashboardsui.component.CanvasLayout)1 DashboardRefreshEvent (io.jmix.dashboardsui.dashboard.event.DashboardRefreshEvent)1