/** * Adds a component into this container. The component is added to the left * or on top of the other components. * * @param c * the component to be added. */ public void addComponentAsFirst(Component c) { // If c is already in this, we must remove it before proceeding // see ticket #7668 if (equals(c.getParent())) { removeComponent(c); } components.addFirst(c); try { super.addComponent(c); } catch (IllegalArgumentException e) { components.remove(c); throw e; } }
addComponent(newComponent); } else if (newLocation == -1) { removeComponent(oldComponent); addComponent(newComponent, oldLocation); } else {
/** * Adds a component into indexed position in this container. * * @param c * the component to be added. * @param index * the index of the component position. The components currently * in and after the position are shifted forwards. */ public void addComponent(Component c, int index) { // If c is already in this, we must remove it before proceeding // see ticket #7668 if (equals(c.getParent())) { // When c is removed, all components after it are shifted down if (index > getComponentIndex(c)) { index--; } removeComponent(c); } components.add(index, c); try { super.addComponent(c); } catch (IllegalArgumentException e) { components.remove(c); throw e; } }
public void removeSection(Component section) { sectionsLayout.removeComponent(section); } }
@Override public void remove(Component childComponent) { component.removeComponent(WebComponentsHelper.getComposition(childComponent)); ownComponents.remove(childComponent); childComponent.setParent(null); }
public void setCurrencyLabelPosition(CurrencyLabelPosition currencyLabelPosition) { container.removeStyleName(this.currencyLabelPosition.name().toLowerCase()); this.currencyLabelPosition = currencyLabelPosition; container.addStyleName(currencyLabelPosition.name().toLowerCase()); container.removeComponent(currencyLabel); if (CurrencyLabelPosition.LEFT == currencyLabelPosition) { container.addComponent(currencyLabel, 0); } else { container.addComponent(currencyLabel, 1); } }
@Override public void removeQueueRolePermissionBox(QueueRolePermissionBox box) { rolePermissionLayout.removeComponent(box); roleNameComboBox.addItem(box.getQueueRolePermission().getRoleName()); if (queue.getRolePermissions() != null) { queue.getRolePermissions().remove(box.getQueueRolePermission()); } }
@Override public void setInitialLayout(VBoxLayout initialLayout) { checkNotNullArgument(initialLayout); if (state == State.WINDOW_CONTAINER) { throw new IllegalStateException("Unable to change AppWorkArea initial layout in WINDOW_CONTAINER state"); } if (this.initialLayout != null) { component.removeComponent(this.initialLayout.unwrapComposition(com.vaadin.ui.Component.class)); } this.initialLayout = initialLayout; initialLayout.setParent(this); initialLayout.setSizeFull(); Component vInitialLayout = initialLayout.unwrapComposition(com.vaadin.ui.Component.class); vInitialLayout.addStyleName(INITIAL_LAYOUT_STYLENAME); component.addComponent(vInitialLayout); }
/** * Adds a logo to the very top of the side bar, above the header. The logo's primary style is automatically * set to {@link ValoTheme#MENU_LOGO} ands its size to undefined. * * @param logo a {@link com.vaadin.ui.Label} or {@link com.vaadin.ui.Button} to use as the logo, or {@code null} to remove the logo completely. */ public void setLogo(Component logo) { if (getCompositionRoot() != null && this.logo != null) { getCompositionRoot().removeComponent(this.logo); } this.logo = logo; if (logo != null) { logo.setPrimaryStyleName(ValoTheme.MENU_LOGO); logo.setSizeUndefined(); if (getCompositionRoot() != null) { getCompositionRoot().addComponentAsFirst(logo); } } }
/** * Adds a header to the top of the side bar, below the logo. The {@link ValoTheme#MENU_TITLE} style * will automatically be added to the layout. * * @param headerLayout the layout containing the header, or {@code null} to remove. */ public void setHeader(Layout headerLayout) { if (getCompositionRoot() != null && this.headerLayout != null) { getCompositionRoot().removeComponent(this.headerLayout); } this.headerLayout = headerLayout; if (headerLayout != null) { headerLayout.addStyleName(ValoTheme.MENU_TITLE); if (getCompositionRoot() != null) { if (this.logo != null) { getCompositionRoot().addComponent(headerLayout, 1); } else { getCompositionRoot().addComponentAsFirst(headerLayout); } } } }