Search in sources :

Example 6 with SingleComponentContainer

use of com.vaadin.ui.SingleComponentContainer in project cuba by cuba-platform.

the class DefaultFormLayoutDropHandler method handleDropFromLayout.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.AbstractDefaultLayoutDropHandler
     * #handleDropFromLayout(com.vaadin.event.dd.DragAndDropEvent)
     */
@Override
protected void handleDropFromLayout(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    FormLayoutTargetDetails details = (FormLayoutTargetDetails) event.getTargetDetails();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget();
    Component source = event.getTransferable().getSourceComponent();
    int idx = details.getOverIndex();
    Component comp = transferable.getComponent();
    // Check that we are not dragging an outer layout into an inner
    // layout
    Component parent = layout.getParent();
    while (parent != null) {
        if (parent == comp) {
            return;
        }
        parent = parent.getParent();
    }
    // Detach from old source
    if (source instanceof ComponentContainer) {
        ((ComponentContainer) source).removeComponent(comp);
    } else if (source instanceof SingleComponentContainer) {
        ((SingleComponentContainer) source).setContent(null);
    }
    // Increase index if component is dropped after or above a
    // previous
    // component
    VerticalDropLocation loc = (details).getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }
    // Add component
    if (idx >= 0) {
        layout.addComponent(comp, idx);
    } else {
        layout.addComponent(comp);
    }
    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(comp, dropAlignment);
    }
}
Also used : VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation) 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) FormLayoutTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDFormLayout.FormLayoutTargetDetails) Component(com.vaadin.ui.Component) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 7 with SingleComponentContainer

use of com.vaadin.ui.SingleComponentContainer in project cuba by cuba-platform.

the class DefaultPanelDropHandler method handleDropFromLayout.

@Override
protected void handleDropFromLayout(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    PanelTargetDetails details = (PanelTargetDetails) event.getTargetDetails();
    Component component = transferable.getComponent();
    DDPanel panel = (DDPanel) details.getTarget();
    // Detach from old source
    Component source = transferable.getSourceComponent();
    if (source instanceof ComponentContainer) {
        ((ComponentContainer) source).removeComponent(component);
    } else if (source instanceof SingleComponentContainer) {
        ((SingleComponentContainer) source).setContent(null);
    }
    // Attach to new source
    panel.setContent(component);
}
Also used : DDPanel(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDPanel) PanelTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDPanel.PanelTargetDetails) 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) Component(com.vaadin.ui.Component)

Example 8 with SingleComponentContainer

use of com.vaadin.ui.SingleComponentContainer in project cuba by cuba-platform.

the class DefaultVerticalLayoutDropHandler method handleDropFromLayout.

/**
 * Handle a drop from another layout
 *
 * @param event
 *            The drag and drop event
 */
@Override
protected void handleDropFromLayout(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event.getTargetDetails();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget();
    Component source = event.getTransferable().getSourceComponent();
    int idx = (details).getOverIndex();
    Component comp = transferable.getComponent();
    // Check that we are not dragging an outer layout into an inner
    // layout
    Component parent = layout.getParent();
    while (parent != null) {
        if (parent == comp) {
            return;
        }
        parent = parent.getParent();
    }
    // Detach from old source
    if (source instanceof ComponentContainer) {
        ((ComponentContainer) source).removeComponent(comp);
    } else if (source instanceof SingleComponentContainer) {
        ((SingleComponentContainer) source).setContent(null);
    }
    // Increase index if component is dropped after or above a
    // previous
    // component
    VerticalDropLocation loc = (details).getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }
    // Add component
    if (idx >= 0) {
        layout.addComponent(comp, idx);
    } else {
        layout.addComponent(comp);
    }
    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(comp, dropAlignment);
    }
}
Also used : VerticalLayoutTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDVerticalLayout.VerticalLayoutTargetDetails) VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation) 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) Component(com.vaadin.ui.Component) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 9 with SingleComponentContainer

use of com.vaadin.ui.SingleComponentContainer in project cuba by cuba-platform.

the class DefaultVerticalLayoutDropHandler method handleDropFromLayout.

/**
 * Handle a drop from another layout
 *
 * @param event
 *            The drag and drop event
 */
@Override
protected void handleDropFromLayout(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event.getTargetDetails();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget();
    Component source = event.getTransferable().getSourceComponent();
    int idx = (details).getOverIndex();
    Component comp = transferable.getComponent();
    // Check that we are not dragging an outer layout into an inner
    // layout
    Component parent = layout.getParent();
    while (parent != null) {
        if (parent == comp) {
            return;
        }
        parent = parent.getParent();
    }
    // Detach from old source
    if (source instanceof ComponentContainer) {
        ((ComponentContainer) source).removeComponent(comp);
    } else if (source instanceof SingleComponentContainer) {
        ((SingleComponentContainer) source).setContent(null);
    }
    // Increase index if component is dropped after or above a
    // previous
    // component
    VerticalDropLocation loc = (details).getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }
    // Add component
    if (idx >= 0) {
        layout.addComponent(comp, idx);
    } else {
        layout.addComponent(comp);
    }
    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(comp, dropAlignment);
    }
}
Also used : VerticalLayoutTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.v7.DDVerticalLayout.VerticalLayoutTargetDetails) VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation) 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) Component(com.vaadin.ui.Component) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 10 with SingleComponentContainer

use of com.vaadin.ui.SingleComponentContainer in project cuba by cuba-platform.

the class DefaultTabSheetDropHandler method handleDropFromLayout.

@Override
protected void handleDropFromLayout(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    TabSheetTargetDetails details = (TabSheetTargetDetails) event.getTargetDetails();
    DDTabSheet tabSheet = (DDTabSheet) details.getTarget();
    Component c = transferable.getComponent();
    HorizontalDropLocation location = details.getDropLocation();
    int idx = details.getOverIndex();
    ComponentContainer source = (ComponentContainer) transferable.getSourceComponent();
    // Detach from old source
    if (source instanceof ComponentContainer) {
        ((ComponentContainer) source).removeComponent(c);
    } else if (source instanceof SingleComponentContainer) {
        ((SingleComponentContainer) source).setContent(null);
    }
    if (location == HorizontalDropLocation.LEFT) {
        tabSheet.addTab(c, idx);
    } else if (location == HorizontalDropLocation.RIGHT) {
        tabSheet.addTab(c, idx + 1);
    }
}
Also used : TabSheetTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDTabSheet.TabSheetTargetDetails) DDTabSheet(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDTabSheet) 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) HorizontalDropLocation(com.vaadin.shared.ui.dd.HorizontalDropLocation) Component(com.vaadin.ui.Component)

Aggregations

LayoutBoundTransferable (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable)11 Component (com.vaadin.ui.Component)11 ComponentContainer (com.vaadin.ui.ComponentContainer)11 SingleComponentContainer (com.vaadin.ui.SingleComponentContainer)11 VerticalDropLocation (com.vaadin.shared.ui.dd.VerticalDropLocation)4 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)3 DDAbsoluteLayout (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDAbsoluteLayout)2 DDAccordion (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDAccordion)1 DDCssLayout (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDCssLayout)1 CssLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDCssLayout.CssLayoutTargetDetails)1 FormLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDFormLayout.FormLayoutTargetDetails)1 DDGridLayout (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDGridLayout)1 GridLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDGridLayout.GridLayoutTargetDetails)1 DDHorizontalSplitPanel (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel)1 HorizontalSplitPanelTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDHorizontalSplitPanel.HorizontalSplitPanelTargetDetails)1 DDPanel (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDPanel)1 PanelTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDPanel.PanelTargetDetails)1 DDTabSheet (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDTabSheet)1 TabSheetTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDTabSheet.TabSheetTargetDetails)1 VerticalLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDVerticalLayout.VerticalLayoutTargetDetails)1