Search in sources :

Example 16 with VerticalDropLocation

use of com.vaadin.shared.ui.dd.VerticalDropLocation in project cuba by cuba-platform.

the class VDDVerticalLayout method emphasis.

/**
 * Empasises the drop location of the component when hovering over a
 * ĆhildComponentContainer. Passing null as the container removes any
 * previous emphasis.
 *
 * @param container
 *            The container which we are hovering over
 * @param event
 *            The drag event
 */
protected void emphasis(Widget container, VDragEvent event) {
    // Remove emphasis from previous hovers
    deEmphasis();
    // validate container
    if (container == null || !getElement().isOrHasChild(container.getElement())) {
        return;
    }
    currentlyEmphasised = container;
    VerticalDropLocation location = null;
    // Add drop location specific style
    if (currentlyEmphasised != this) {
        location = getVerticalDropLocation(currentlyEmphasised, event);
    } else {
        location = VerticalDropLocation.MIDDLE;
    }
    setStyleName(currentlyEmphasised.getElement(), OVER, true);
    setStyleName(currentlyEmphasised.getElement(), OVER + "-" + location.toString().toLowerCase(), true);
}
Also used : VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation)

Example 17 with VerticalDropLocation

use of com.vaadin.shared.ui.dd.VerticalDropLocation in project cuba by cuba-platform.

the class DefaultCssLayoutDropHandler method handleHTML5Drop.

@Override
protected void handleHTML5Drop(DragAndDropEvent event) {
    CssLayoutTargetDetails details = (CssLayoutTargetDetails) event.getTargetDetails();
    Component over = details.getOverComponent();
    DDCssLayout layout = (DDCssLayout) details.getTarget();
    int idx = (details).getOverIndex();
    HorizontalDropLocation hl = details.getHorizontalDropLocation();
    VerticalDropLocation vl = details.getVerticalDropLocation();
    if (over == layout) {
        if (vl == VerticalDropLocation.TOP || hl == HorizontalDropLocation.LEFT) {
            idx = 0;
        } else if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) {
            idx = -1;
        }
    } else {
        if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) {
            idx++;
        }
    }
    if (idx >= 0 && idx < layout.getComponentCount()) {
        layout.addComponent(resolveComponentFromHTML5Drop(event), idx);
    } else {
        layout.addComponent(resolveComponentFromHTML5Drop(event));
    }
}
Also used : DDCssLayout(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDCssLayout) CssLayoutTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDCssLayout.CssLayoutTargetDetails) VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation) HorizontalDropLocation(com.vaadin.shared.ui.dd.HorizontalDropLocation) Component(com.vaadin.ui.Component)

Example 18 with VerticalDropLocation

use of com.vaadin.shared.ui.dd.VerticalDropLocation in project cuba by cuba-platform.

the class DefaultFormLayoutDropHandler method handleComponentReordering.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.AbstractDefaultLayoutDropHandler
     * #handleComponentReordering(com.vaadin.event.dd.DragAndDropEvent)
     */
@Override
protected void handleComponentReordering(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    FormLayoutTargetDetails details = (FormLayoutTargetDetails) event.getTargetDetails();
    DDFormLayout layout = (DDFormLayout) details.getTarget();
    Component comp = transferable.getComponent();
    int idx = details.getOverIndex();
    int oldIdx = layout.getComponentIndex(comp);
    if (idx == oldIdx) {
        // Dropping on myself
        return;
    }
    // Detach
    layout.removeComponent(comp);
    if (idx > 0 && idx > oldIdx) {
        idx--;
    }
    // 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 : DDFormLayout(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDFormLayout) VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation) LayoutBoundTransferable(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable) FormLayoutTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDFormLayout.FormLayoutTargetDetails) Component(com.vaadin.ui.Component)

Example 19 with VerticalDropLocation

use of com.vaadin.shared.ui.dd.VerticalDropLocation 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 20 with VerticalDropLocation

use of com.vaadin.shared.ui.dd.VerticalDropLocation in project cuba by cuba-platform.

the class DefaultVerticalLayoutDropHandler method handleHTML5Drop.

@Override
protected void handleHTML5Drop(DragAndDropEvent event) {
    VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event.getTargetDetails();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget();
    int idx = (details).getOverIndex();
    // Increase index if component is dropped after or above a
    // previous
    // component
    VerticalDropLocation loc = (details).getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }
    Component comp = resolveComponentFromHTML5Drop(event);
    // 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) Component(com.vaadin.ui.Component) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Aggregations

VerticalDropLocation (com.vaadin.shared.ui.dd.VerticalDropLocation)25 Component (com.vaadin.ui.Component)13 LayoutBoundTransferable (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable)9 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)8 HorizontalDropLocation (com.vaadin.shared.ui.dd.HorizontalDropLocation)5 ComponentContainer (com.vaadin.ui.ComponentContainer)5 SingleComponentContainer (com.vaadin.ui.SingleComponentContainer)5 DDAccordion (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDAccordion)3 FormLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDFormLayout.FormLayoutTargetDetails)3 VerticalLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDVerticalLayout.VerticalLayoutTargetDetails)3 AccordionTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.details.AccordionTargetDetails)3 VerticalLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.v7.DDVerticalLayout.VerticalLayoutTargetDetails)3 ComponentConnector (com.vaadin.client.ComponentConnector)3 MouseEventDetails (com.vaadin.shared.MouseEventDetails)3 Element (com.google.gwt.dom.client.Element)2 Widget (com.google.gwt.user.client.ui.Widget)2 DDCssLayout (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDCssLayout)2 CssLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDCssLayout.CssLayoutTargetDetails)2 Style (com.google.gwt.dom.client.Style)1 Element (com.google.gwt.user.client.Element)1