List of usage examples for com.vaadin.ui AbstractOrderedLayout getParent
@Override
public HasComponents getParent()
From source file:com.foc.vaadin.gui.layouts.FVHorizontal_WYSIWYG_DropHandler.java
License:Apache License
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) 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//from w w w .j a v a2 s .c o m 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. ComponentContainer sourceLayout = null; if (source instanceof ComponentContainer) { sourceLayout = (ComponentContainer) source; sourceLayout.removeComponent(comp); } // Increase index if component is dropped after or above a // previous // component HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } AttributesImpl newAttributes = removeNotNeededAttributes(((FocXMLGuiComponent) comp).getAttributes(), (FVLayout) sourceLayout); if (newAttributes.getIndex(FXML.ATT_IDX) > -1) { newAttributes.setValue(newAttributes.getIndex(FXML.ATT_IDX), idx + ""); } ((FocXMLGuiComponent) comp).setAttributes(newAttributes); // 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); } }
From source file:com.foc.vaadin.gui.layouts.FVVertical_WYSIWYG_DropHandler.java
License:Apache License
@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/*from w ww .j a v a2s. c o m*/ 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. ComponentContainer sourceLayout = null; if (source instanceof ComponentContainer) { sourceLayout = (ComponentContainer) source; sourceLayout.removeComponent(comp); } // 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); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultFormLayoutDropHandler.java
License:Apache License
@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/*from w w w .j av a2s .c o m*/ 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); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultHorizontalLayoutDropHandler.java
License:Apache License
/** * Handle a drop from another layout// w w w.j a v a 2 s . co m * * @param event * The drag and drop event */ @Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) 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 HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { 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); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultVerticalLayoutDropHandler.java
License:Apache License
/** * Handle a drop from another layout/*from w w w . j ava 2 s .c o m*/ * * @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); } }