@Nonnull @Override public List<LayoutTip> analyze(Component c, String path) { if (c instanceof ComponentContainer) { if (c.getWidth() < 0 && c.getHeight() < 0) { List<LayoutTip> tips = null; ComponentContainer container = (ComponentContainer) c; for (Component component : container.getOwnComponents()) { if (tips == null) { tips = new ArrayList<>(); } if (component.getAlignment() != null && component.getAlignment() != Component.Alignment.TOP_LEFT) { if (component instanceof Label) { // ignore align for labels continue; } String id = component.getId() != null ? component.getId() : component.getClass().getSimpleName(); tips.add(warn("Container '" + path + "', nested component '" + id + "'", "Nested component has align %s inside container with undefined size", component.getAlignment())); } } return tips != null ? tips : Collections.<LayoutTip>emptyList(); } } return Collections.emptyList(); } }
@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); if (ownComponents.contains(childComponent)) { int existingIndex = component.getComponentIndex(vComponent); if (index > existingIndex) { index--; } remove(childComponent); } component.addComponent(vComponent, index); component.setComponentAlignment(vComponent, toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { attachToFrame(childComponent); } } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); if (ownComponents.contains(childComponent)) { int existingIndex = component.getComponentIndex(vComponent); if (index > existingIndex) { index--; } remove(childComponent); } component.addComponent(vComponent, index); component.setComponentAlignment(vComponent, toVaadinAlignment(childComponent.getAlignment())); // CAUTION here we set this as fragment for nested components if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(this); } else { attachToFrame(childComponent); } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
@Override public void add(Component childComponent, int col, int row, int col2, int row2) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); component.addComponent(vComponent, col, row, col2, row2); component.setComponentAlignment(vComponent, toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
@Override public void add(Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); component.addComponent(vComponent); component.setComponentAlignment(vComponent, toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
@Override public void add(Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } final com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); component.addComponent(vComponent); component.setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else if (frame instanceof FrameImplementation) { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
@Override public void add(Component childComponent, int col, int row, int col2, int row2) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } final com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); component.addComponent(vComponent, col, row, col2, row2); component.setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else if (frame instanceof FrameImplementation) { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
((AbstractOrderedLayout)container).addComponent(vComponent, index); com.vaadin.ui.Alignment alignment = WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()); ((AbstractOrderedLayout) container).setComponentAlignment(vComponent, alignment);
getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
getContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));