List of usage examples for com.vaadin.ui Component getParent
@Override
public HasComponents getParent();
From source file:org.vaadin.addons.portallayout.portal.PortalBase.java
License:Apache License
/** * Removes a {@link Portlet} from current layout. * //www. j a v a 2 s .c om * @param portlet * {@link Portlet} to be removed. */ public void removePortlet(Portlet portlet) { Component portletContent = portlet.getParent(); getState().portlets().remove(portlet); if (portletContent.getParent() == this) { portletContent.setParent(null); } }
From source file:org.vaadin.alump.gridstack.GridStackLayout.java
License:Apache License
@Override public void replaceComponent(Component oldComponent, Component newComponent) { if (oldComponent == newComponent) { return;/*from ww w .j a va 2 s .c o m*/ } if (oldComponent.getParent() != this) { throw new IllegalArgumentException("Replacable component not child of this layout"); } GridStackChildOptions oldOptions = getState(false).childOptions.get(oldComponent); removeComponent(oldComponent); if (newComponent.getParent() == this) { removeComponent(newComponent); } addComponent(newComponent, oldOptions.x, oldOptions.y, oldOptions.width, oldOptions.height); }
From source file:org.vaadin.alump.gridstack.GridStackLayout.java
License:Apache License
protected GridStackChildOptions getComponentOptions(Component child, boolean modify, boolean throwIfMissing) { if (child == null || child.getParent() != this) { throw new IllegalArgumentException("Given component is not child of this layout"); }//from w w w .j a v a 2s . c o m GridStackChildOptions opt = getState(modify).childOptions.get(child); if (opt == null) { throw new IllegalStateException("Missing child options"); } return opt; }
From source file:org.vaadin.alump.masonry.DnDMasonryLayout.java
License:Apache License
/** * Get DragAndDropWrapper for given component * @param component Component added to this DndMasonryLayout * @return Wrapper of component or null if not set yet, or if component is not under this layout *///from w ww .j ava2 s . c o m protected DragAndDropWrapper getComponentDnDWrapper(Component component) { if (!(component.getParent() instanceof DragAndDropWrapper)) { return null; } DragAndDropWrapper wrapper = (DragAndDropWrapper) component.getParent(); if (wrapper.getParent() != this) { return null; } return wrapper; }
From source file:org.vaadin.alump.masonry.MasonryLayout.java
License:Apache License
@Override public void replaceComponent(Component oldComponent, Component newComponent) { if (oldComponent.getParent() != this) { throw new IllegalArgumentException("Old component has different parent"); }//from ww w.j ava 2 s. c o m if (oldComponent == newComponent) { return; } if (newComponent.getParent() == this) { removeComponent(newComponent); } int oldIndex = components.indexOf(oldComponent); removeComponent(oldComponent); addComponent(newComponent, oldIndex); }
From source file:org.vaadin.alump.masonry.MasonryLayout.java
License:Apache License
/** * Add component to given index//w w w . j a va 2 s .c om * @param component Component added * @param index Index where component is added */ public void addComponent(Component component, int index) { if (component.getParent() == this) { int currentIndex = components.indexOf(component); if (currentIndex == index) { return; } removeComponent(component); if (index < components.size()) { components.add(index, component); } else { components.add(component); } } else { components.add(component); } try { super.addComponent(component); markAsDirty(); } catch (IllegalArgumentException e) { components.remove(component); throw e; } }
From source file:org.vaadin.alump.masonry.MasonryLayout.java
License:Apache License
/** * Add component with style name added to wrapping element to given index * @param component Component added// w w w .j av a 2 s . com * @param wrapperStyleName Style name added to wrapping element, or null if no extra style names. Can be eq. used to have * double wide items. To update this you need to re add component. * @param index Index where component is added */ public void addComponent(Component component, String wrapperStyleName, int index) { // Correct index if already child of this layout int indexCorrection = 0; if (component.getParent() == this) { if (components.indexOf(component) < index) { indexCorrection = -1; } } addComponent(component, index + indexCorrection); if (wrapperStyleName != null) { getState().itemStyleNames.put(component, wrapperStyleName); } else { getState().itemStyleNames.remove(component); } }
From source file:org.vaadin.alump.masonry.MasonryLayout.java
License:Apache License
/** * Add component before given component//from www .j av a2 s . co m * @param added Component added * @param wrapperStyleName Wrapper style name of component * @param before Component will be added before this component */ public void addComponentBefore(Component added, String wrapperStyleName, Component before) { if (before.getParent() != this) { throw new IllegalArgumentException("Given target component is not child of this MasonryLayout"); } if (added == before) { return; } addComponent(added, wrapperStyleName, components.indexOf(before)); }
From source file:org.vaadin.alump.masonry.MasonryLayout.java
License:Apache License
/** * Add component after given component/*from w ww . j av a 2s . c om*/ * @param added Component added * @param wrapperStyleName Wrapper stylename of component * @param after Component will be added after this component */ public void addComponentAfter(Component added, String wrapperStyleName, Component after) { if (after.getParent() != this) { throw new IllegalArgumentException("Given target component is not child of this MasonryLayout"); } if (added == after) { return; } addComponent(added, wrapperStyleName, components.indexOf(after) + 1); }
From source file:org.vaadin.alump.masonry.MasonryLayout.java
License:Apache License
/** * Get optional wrapper style name of component * @param component Component added earlier * @return Wrapper style name given for component, null if not defined *///from w ww. j a v a2 s . c om public String getComponentWrapperStyleName(Component component) { if (component.getParent() != this) { throw new IllegalArgumentException("Given component is not child of this MasonryLayout"); } return getState().itemStyleNames.get(component); }