List of usage examples for com.vaadin.ui Component getParent
@Override
public HasComponents getParent();
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;//from w ww. j a va 2 s .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.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 www. j a v a2 s . 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.DefaultGridLayoutDropHandler.java
License:Apache License
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); GridLayoutTargetDetails details = (GridLayoutTargetDetails) event.getTargetDetails(); DDGridLayout layout = (DDGridLayout) details.getTarget(); Component source = event.getTransferable().getSourceComponent(); Component comp = transferable.getComponent(); if (comp == layout) { // Dropping myself on myself, if parent is absolute layout then // move/*from w ww .jav a2 s. com*/ if (comp.getParent() instanceof DDAbsoluteLayout) { MouseEventDetails mouseDown = transferable.getMouseDownEvent(); MouseEventDetails mouseUp = details.getMouseEvent(); int movex = mouseUp.getClientX() - mouseDown.getClientX(); int movey = mouseUp.getClientY() - mouseDown.getClientY(); DDAbsoluteLayout parent = (DDAbsoluteLayout) comp.getParent(); ComponentPosition position = parent.getPosition(comp); float x = position.getLeftValue() + movex; float y = position.getTopValue() + movey; position.setLeft(x, Sizeable.UNITS_PIXELS); position.setTop(y, Sizeable.UNITS_PIXELS); return; } } else { // 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); } } int row = details.getOverRow(); int column = details.getOverColumn(); addComponent(event, comp, column, row); }
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. ja v a 2 s . c om*/ * * @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/* w w w.j ava 2s . co 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); } }
From source file:com.hybridbpm.ui.component.chart.ChartEditor.java
License:Apache License
private DevelopmentView getDevelopmentView() { Component result = this; while (!(result instanceof DevelopmentView)) { result = result.getParent(); if (result == null) { return null; }//from w w w . j a va2s .c o m } return (DevelopmentView) result; }
From source file:com.jain.addon.i18N.handlers.factory.I18NComponentHandlerFactory.java
License:Apache License
/** * Method to find I18NHandler for the component * @param component/* w ww .java2s. co m*/ * @return {@link I18NComponentHandler} */ public static I18NComponentHandler getHandler(Component component) { if (componentHandler != null && component != null) { I18NComponentHandler handler = componentHandler.get(component.getClass()); if (handler != null) return handler; } if (component instanceof Label) return new I18NLableHandler((Label) component); if (component instanceof AbstractTextField) return new I18NFieldHandler((AbstractTextField) component); if (component instanceof PopupDateField) return new I18NFieldHandler((PopupDateField) component); if (component instanceof Table) return new I18NTableHandler((Table) component); if (component instanceof AbstractSelect) return new I18NAbstractSelectHandler((AbstractSelect) component); if (component instanceof TabSheet || component.getParent() instanceof TabSheet) return new I18NTabSheetHandler(component); if (component instanceof JUploader) return new I18NJUploadHandler((JUploader) component); if (component instanceof MenuBar) return new I18NMenuBarHandler((MenuBar) component); if (component instanceof AbstractComponent) return new I18NAbstractComponentHandler((AbstractComponent) component); return new I18NComponentHandler(component); }
From source file:com.jain.addon.i18N.handlers.I18NTabSheetHandler.java
License:Apache License
private void initialize(final Component component) { if (component instanceof TabSheet) { TabSheet sheet = (TabSheet) component; for (Component c : sheet) { Tab tab = sheet.getTab(c);/*ww w. j a v a 2 s . com*/ tabMap.put(tab, tab.getCaption()); } } else if (component.getParent() instanceof TabSheet) { TabSheet sheet = (TabSheet) component.getParent(); Tab tab = sheet.getTab(component); tabMap.put(tab, tab.getCaption()); } }
From source file:com.jain.addon.web.bean.helper.JainHelper.java
License:Apache License
/** * Method will fetch a parent component for the given class name for the given component. <br/> * E.g Component A is B as a parent and B is having C as parent. <br/> * If we pass A as a component and C as a class then returned Component Will be C. * @param component/*from ww w .ja v a2 s .c o m*/ * @param clazz * @return Component */ public static Component getParent(Component component, Class clazz) { if (component == null) return null; if (component.getClass().equals(clazz)) return component; return getParent(component.getParent(), clazz); }
From source file:com.mycollab.mobile.module.crm.view.activity.RelatedItemSelectionView.java
License:Open Source License
@Override public void attach() { super.attach(); Component parent = this.getParent(); while (parent != null && !(parent instanceof NavigationManager)) { parent = parent.getParent(); }/*from w w w . j ava 2s. co m*/ if (parent != null) { this.previousView = ((NavigationManager) parent).getCurrentComponent(); } }