@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (ownComponents.contains(childComponent)) { int existingIndex = component.getComponentIndex(WebComponentsHelper.getComposition(childComponent)); if (index > existingIndex) { index--; } remove(childComponent); } com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); component.addComponent(vComponent, index); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
@Nonnull public static Window getWindowNN(Component.BelongToFrame component) { Window window = getWindow(component); if (window == null) { throw new IllegalStateException("Unable to find window for component " + (component.getId() != null ? component.getId() : component.getClass())); } return window; }
@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 Accordion.Tab addTab(String name, Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } Tab tab = new Tab(name, childComponent); this.tabs.put(name, tab); com.vaadin.ui.Component tabComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); tabComponent.setSizeFull(); tabMapping.put(tabComponent, new ComponentDescriptor(name, childComponent)); com.vaadin.ui.Accordion.Tab tabControl = this.component.addTab(tabComponent); if (getDebugId() != null) { this.component.setTestId(tabControl, AppUI.getCurrent().getTestIdManager().getTestId(getDebugId() + "." + name)); } if (AppUI.getCurrent().isTestMode()) { this.component.setCubaId(tabControl, name); } if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } childComponent.setParent(this); return tab; }
@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 setPopupContent(Component popupContent) { if (this.popupContent != null) { if (this.popupContent instanceof BelongToFrame) { ((BelongToFrame) this.popupContent).setFrame(null); } else { detachFromFrame(this.popupContent); } this.popupContent.setParent(null); } this.popupContent = popupContent; if (popupContent != null) { component.setContent(new PopupContent()); if (frame != null) { if (popupContent instanceof BelongToFrame && ((BelongToFrame) popupContent).getFrame() == null) { ((BelongToFrame) popupContent).setFrame(frame); } else { attachToFrame(popupContent); } } popupContent.setParent(this); } else { component.setContent(new EmptyContent()); } }
@Override public void add(Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (component == null) { createComponentImpl(); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); component.addComponent(vComponent); 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); if (childComponent.getId() != null) { component.addComponent(vComponent, childComponent.getId()); } else { component.addComponent(vComponent); } 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, 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); }
/** * Get the topmost window for the specified component. * * @param component component instance * @return topmost client specific window in the hierarchy of frames for this component. * * <br>Can be null only if the component wasn't properly initialized. */ @Nullable public static Window getWindowImplementation(Component.BelongToFrame component) { Frame frame = component.getFrame(); while (frame != null) { if (frame instanceof Window && frame.getFrame() == frame) { Window window = (Window) frame; return window instanceof Window.Wrapper ? ((Window.Wrapper) window).getWrappedWindow() : window; } frame = frame.getFrame(); } return null; }
/** * Get the topmost window for the specified component. * * @param component component instance * @return topmost window in the hierarchy of frames for this component. * <br>Can be null only if the component wasn't properly initialized. */ @Nullable public static Window getWindow(Component.BelongToFrame component) { Frame frame = component.getFrame(); while (frame != null) { if (frame instanceof Window && frame.getFrame() == frame) { return (Window) frame; } frame = frame.getFrame(); } return null; }
@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) { 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); }
public static String getComponentPath(Component c) { StringBuilder sb = new StringBuilder(c.getId() == null ? "" : c.getId()); if (c instanceof Component.BelongToFrame) { Frame frame = ((Component.BelongToFrame) c).getFrame(); while (frame != null) { sb.insert(0, "."); String s = frame.getId(); if (s.contains(".")) { s = "[" + s + "]"; } sb.insert(0, s); if (frame instanceof Window) { break; } frame = frame.getFrame(); } } return sb.toString(); }