Search in sources :

Example 1 with DDHorizontalSplitPanel

use of com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel in project cuba by cuba-platform.

the class DefaultHorizontalSplitPanelDropHandler method handleHTML5Drop.

@Override
protected void handleHTML5Drop(DragAndDropEvent event) {
    HorizontalSplitPanelTargetDetails details = (HorizontalSplitPanelTargetDetails) event.getTargetDetails();
    DDHorizontalSplitPanel panel = (DDHorizontalSplitPanel) details.getTarget();
    if (details.getDropLocation() == HorizontalDropLocation.LEFT) {
        // Dropped in the left area
        panel.setFirstComponent(resolveComponentFromHTML5Drop(event));
    } else if (details.getDropLocation() == HorizontalDropLocation.RIGHT) {
        // Dropped in the right area
        panel.setSecondComponent(resolveComponentFromHTML5Drop(event));
    }
}
Also used : HorizontalSplitPanelTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel.HorizontalSplitPanelTargetDetails) DDHorizontalSplitPanel(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel)

Example 2 with DDHorizontalSplitPanel

use of com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel in project cuba by cuba-platform.

the class DefaultHorizontalSplitPanelDropHandler method handleDropFromLayout.

@Override
protected void handleDropFromLayout(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    ComponentContainer source = (ComponentContainer) transferable.getSourceComponent();
    HorizontalSplitPanelTargetDetails details = (HorizontalSplitPanelTargetDetails) event.getTargetDetails();
    Component component = transferable.getComponent();
    DDHorizontalSplitPanel panel = (DDHorizontalSplitPanel) details.getTarget();
    // Detach from old source
    if (source instanceof ComponentContainer) {
        ((ComponentContainer) source).removeComponent(component);
    } else if (source instanceof SingleComponentContainer) {
        ((SingleComponentContainer) source).setContent(null);
    }
    if (details.getDropLocation() == HorizontalDropLocation.LEFT) {
        // Dropped in the left area
        panel.setFirstComponent(component);
    } else if (details.getDropLocation() == HorizontalDropLocation.RIGHT) {
        // Dropped in the right area
        panel.setSecondComponent(component);
    }
}
Also used : LayoutBoundTransferable(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable) ComponentContainer(com.vaadin.ui.ComponentContainer) SingleComponentContainer(com.vaadin.ui.SingleComponentContainer) SingleComponentContainer(com.vaadin.ui.SingleComponentContainer) HorizontalSplitPanelTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel.HorizontalSplitPanelTargetDetails) Component(com.vaadin.ui.Component) DDHorizontalSplitPanel(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel)

Aggregations

DDHorizontalSplitPanel (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel)2 HorizontalSplitPanelTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel.HorizontalSplitPanelTargetDetails)2 LayoutBoundTransferable (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable)1 Component (com.vaadin.ui.Component)1 ComponentContainer (com.vaadin.ui.ComponentContainer)1 SingleComponentContainer (com.vaadin.ui.SingleComponentContainer)1