List of usage examples for com.vaadin.shared.ui.dd HorizontalDropLocation LEFT
HorizontalDropLocation LEFT
To view the source code for com.vaadin.shared.ui.dd HorizontalDropLocation LEFT.
Click Source Link
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultCssLayoutDropHandler.java
License:Apache License
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); CssLayoutTargetDetails details = (CssLayoutTargetDetails) event.getTargetDetails(); DDCssLayout layout = (DDCssLayout) details.getTarget(); HorizontalDropLocation hl = details.getHorizontalDropLocation(); VerticalDropLocation vl = details.getVerticalDropLocation(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); Component comp = transferable.getComponent(); Component over = details.getOverComponent(); if (over == layout) { if (vl == VerticalDropLocation.TOP || hl == HorizontalDropLocation.LEFT) { idx = 0;// www. j ava 2s.c om } else if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) { idx = -1; } } else { if (vl == VerticalDropLocation.BOTTOM || hl == HorizontalDropLocation.RIGHT) { idx++; } } // 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(); } // If source is an instance of a component container then remove // it // from there, // the component cannot have two parents. if (source instanceof ComponentContainer) { ComponentContainer sourceLayout = (ComponentContainer) source; sourceLayout.removeComponent(comp); } // Add component if (idx >= 0 && idx < layout.getComponentCount()) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultCssLayoutDropHandler.java
License:Apache License
@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;/*w w w . ja v a 2 s. c o m*/ } 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)); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultHorizontalSplitPanelDropHandler.java
License:Apache License
@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); }//from ww w . ja v a 2 s .c o m 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); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultHorizontalSplitPanelDropHandler.java
License:Apache License
@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)); }/*from w w w . java2 s.c o m*/ }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultTabSheetDropHandler.java
License:Apache License
@Override protected void handleComponentReordering(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); TabSheetTargetDetails details = (TabSheetTargetDetails) event.getTargetDetails(); DDTabSheet tabSheet = (DDTabSheet) details.getTarget(); Component c = transferable.getComponent(); Tab tab = tabSheet.getTab(c);/*from w w w .ja v a 2s. co m*/ HorizontalDropLocation location = details.getDropLocation(); int idx = details.getOverIndex(); if (location == HorizontalDropLocation.LEFT) { // Left of previous tab int originalIndex = tabSheet.getTabPosition(tab); if (originalIndex > idx) { tabSheet.setTabPosition(tab, idx); } else if (idx - 1 >= 0) { tabSheet.setTabPosition(tab, idx - 1); } } else if (location == HorizontalDropLocation.RIGHT) { // Right of previous tab int originalIndex = tabSheet.getTabPosition(tab); if (originalIndex > idx) { tabSheet.setTabPosition(tab, idx + 1); } else { tabSheet.setTabPosition(tab, idx); } } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultTabSheetDropHandler.java
License:Apache License
@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); }/*from w w w .j a v a 2 s .c o m*/ if (location == HorizontalDropLocation.LEFT) { tabSheet.addTab(c, idx); } else if (location == HorizontalDropLocation.RIGHT) { tabSheet.addTab(c, idx + 1); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultTabSheetDropHandler.java
License:Apache License
@Override protected void handleHTML5Drop(DragAndDropEvent event) { TabSheetTargetDetails details = (TabSheetTargetDetails) event.getTargetDetails(); HorizontalDropLocation location = details.getDropLocation(); DDTabSheet tabSheet = (DDTabSheet) details.getTarget(); int idx = details.getOverIndex(); Component c = resolveComponentFromHTML5Drop(event); c.setCaption(resolveCaptionFromHTML5Drop(event)); if (location == HorizontalDropLocation.LEFT) { tabSheet.addTab(c, idx);// ww w . j a v a 2 s .c om } else if (location == HorizontalDropLocation.RIGHT) { tabSheet.addTab(c, idx + 1); } }
From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.csslayout.VDDCssLayout.java
License:Apache License
public void updateDrag(VDragEvent drag) { if (placeHolderElement == null) { /*//from w ww . j a va 2 s. c o m * Drag image might not have been detach due to lazy attaching in * the DragAndDropManager. Detach it again here if it has not been * detached. */ attachDragImageToLayout(drag); return; } if (drag.getElementOver().isOrHasChild(placeHolderElement)) { return; } if (placeHolderElement.hasParentElement()) { /* * Remove the placeholder from the DOM so we can reposition */ placeHolderElement.removeFromParent(); } Widget w = Util.findWidget(drag.getElementOver(), null); ComponentConnector draggedConnector = (ComponentConnector) drag.getTransferable() .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT); if (draggedConnector != null && w == draggedConnector.getWidget()) { /* * Dragging drag image over the placeholder should not have any * effect (except placeholder should be removed) */ return; } if (w != null && w != this) { HorizontalDropLocation hl = getHorizontalDropLocation(w, drag); VerticalDropLocation vl = getVerticalDropLocation(w, drag); if (hl == HorizontalDropLocation.LEFT || vl == VerticalDropLocation.TOP) { Element prev = w.getElement().getPreviousSibling().cast(); if (draggedConnector == null || prev == null || !draggedConnector.getWidget().getElement().isOrHasChild(prev)) { w.getElement().getParentElement().insertBefore(placeHolderElement, w.getElement()); } } else if (hl == HorizontalDropLocation.RIGHT || vl == VerticalDropLocation.BOTTOM) { Element next = w.getElement().getNextSibling().cast(); if (draggedConnector == null || next == null || !draggedConnector.getWidget().getElement().isOrHasChild(next)) { w.getElement().getParentElement().insertAfter(placeHolderElement, w.getElement()); } } else { Element prev = w.getElement().getPreviousSibling().cast(); if (draggedConnector == null || prev == null || !draggedConnector.getWidget().getElement().isOrHasChild(prev)) { w.getElement().getParentElement().insertBefore(placeHolderElement, w.getElement()); } } } else { /* * First child or hoovering outside of current components */ getElement().appendChild(placeHolderElement); } updatePlaceHolderStyleProperties(drag); }
From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.gridlayout.VDDGridLayout.java
License:Apache License
/** * Returns the horizontal drop location// w ww . ja v a2s.c o m * * @param cell * The cell details * @param event * The drag event * @return */ protected HorizontalDropLocation getHorizontalDropLocation(CellDetails cell, VDragEvent event) { // Get the horizontal location HorizontalDropLocation hdetail; int x = Util.getTouchOrMouseClientX(event.getCurrentGwtEvent()) - getAbsoluteLeft() - cell.x; assert (x >= 0 && x <= cell.width); if (x < cell.width * cellLeftRightDropRatio) { hdetail = HorizontalDropLocation.LEFT; } else if (x < cell.width * (1.0 - cellLeftRightDropRatio)) { hdetail = HorizontalDropLocation.CENTER; } else { hdetail = HorizontalDropLocation.RIGHT; } return hdetail; }
From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.gridlayout.VDDGridLayout.java
License:Apache License
/** * Removes any emphasis previously set by emphasis *///from w ww .j a v a 2 s .c o m protected void deEmphasis() { setStyleName(dragShadow.getElement(), OVER, false); // Horizontal styles setStyleName(dragShadow.getElement(), OVER + "-" + HorizontalDropLocation.LEFT.toString().toLowerCase(), false); setStyleName(dragShadow.getElement(), OVER + "-" + HorizontalDropLocation.CENTER.toString().toLowerCase(), false); setStyleName(dragShadow.getElement(), OVER + "-" + HorizontalDropLocation.RIGHT.toString().toLowerCase(), false); // Vertical styles setStyleName(dragShadow.getElement(), OVER + "-" + VerticalDropLocation.TOP.toString().toLowerCase(), false); setStyleName(dragShadow.getElement(), OVER + "-" + VerticalDropLocation.MIDDLE.toString().toLowerCase(), false); setStyleName(dragShadow.getElement(), OVER + "-" + VerticalDropLocation.BOTTOM.toString().toLowerCase(), false); }