@Override public void readDesign(Element design, DesignContext designContext) { // process default attributes super.readDesign(design, designContext); setMargin(readMargin(design, getMargin(), designContext)); // handle children for (Element childComponent : design.children()) { Attributes attr = childComponent.attributes(); Component newChild = designContext.readDesign(childComponent); addComponent(newChild); // handle alignment setComponentAlignment(newChild, DesignAttributeHandler.readAlignment(attr)); // handle expand ratio if (attr.hasKey(":expand")) { String value = attr.get(":expand"); if (!value.isEmpty()) { try { float ratio = Float.valueOf(value); setExpandRatio(newChild, ratio); } catch (NumberFormatException nfe) { getLogger() .info("Failed to parse expand ratio " + value); } } else { setExpandRatio(newChild, 1.0f); } } } }
/** * 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; } componentAdded(c); }
addComponent(newComponent); } else if (newLocation == -1) { Alignment alignment = getComponentAlignment(oldComponent); float expandRatio = getExpandRatio(oldComponent); removeComponent(oldComponent); addComponent(newComponent, oldLocation); applyLayoutSettings(newComponent, alignment, expandRatio); } else { markAsDirty();
private void applyLayoutSettings(Component target, Alignment alignment, float expandRatio) { setComponentAlignment(target, alignment); setExpandRatio(target, expandRatio); }
Component comp = transferable.getComponent(); int idx = details.getOverIndex(); int oldIndex = layout.getComponentIndex(comp); layout.removeComponent(comp); layout.addComponent(comp, idx); } else { layout.addComponent(comp); layout.setComponentAlignment(comp, dropAlignment);
protected <LayoutType extends AbstractOrderedLayout> LayoutType attachActionButtons(LayoutType layout) { Component buttons = wrapButtons(createActionButtons()); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_CENTER); return layout; }
Component parent = layout.getParent(); while (parent != null) { if (parent == comp) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); layout.setComponentAlignment(comp, dropAlignment);
@Override public com.holonplatform.vaadin7.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator addAlignAndExpand( Component component, Alignment alignment, float expandRatio) { getInstance().addComponent(component); getInstance().setComponentAlignment(component, alignment); getInstance().setExpandRatio(component, expandRatio); return builder(); }
@Override public B addAndExpand(Component component, float expandRatio) { getInstance().addComponent(component); getInstance().setExpandRatio(component, expandRatio); return builder(); }
if (orientation == Orientation.VERTICAL && !(getContent() instanceof CubaVerticalActionsLayout)) { newContent = new CubaVerticalActionsLayout(); newContent.setWidth(100, Sizeable.Unit.PERCENTAGE); } else if (orientation == Orientation.HORIZONTAL && !(getContent() instanceof CubaHorizontalActionsLayout)) { newContent = new CubaHorizontalActionsLayout(); newContent.setMargin((getContent()).getMargin()); newContent.setSpacing((getContent()).isSpacing()); newContent.setStyleName(SCROLLBOX_CONTENT_STYLENAME); newContent.setWidth(oldContent.getWidth(), oldContent.getWidthUnits()); newContent.setHeight(oldContent.getHeight(), oldContent.getHeightUnits()); int existingIndex = getContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent)); if (index > existingIndex) { index--; getContent().addComponent(vComponent, index); getContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
/** * 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. * @return this (for method chaining) * @see AbstractOrderedLayout#addComponent(Component, int) */ public default S withComponent(Component c, int index) { ((AbstractOrderedLayout) this).addComponent(c, index); return (S) 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())); 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); }
newContent.setStyleName("c-groupbox-inner"); component.setContent(newContent); newContent.setMargin(currentContent.getMargin()); newContent.setSpacing(currentContent.isSpacing()); int existingIndex = getComponentContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent)); if (index > existingIndex) { index--; getComponentContent().addComponent(vComponent, index); getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
/** * @deprecated This method currently has no effect as expand ratios are not * implemented in FormLayout */ @Override @Deprecated public void setExpandRatio(Component component, float ratio) { super.setExpandRatio(component, ratio); }
int currentIndex = m_layout.getComponentIndex(sourceComponent); if ((currentIndex != -1) && (currentIndex < index)) { index--; m_layout.removeComponent(sourceComponent); if (m_layout.getComponentCount() < index) { index = m_layout.getComponentCount(); m_layout.addComponent(sourceComponent, index);
m_deletedResourceContainer.removeAllComponents(); m_selectionContainer = new IndexedContainer(); m_selectionContainer.addContainerProperty(PROP_SELECTED, Boolean.class, Boolean.FALSE); m_okButton.setEnabled(!deletedResources.isEmpty()); if (deletedResources.isEmpty()) { m_deletedResourceContainer.addComponent( new Label(CmsVaadinUtils.getMessageText(org.opencms.workplace.list.Messages.GUI_LIST_EMPTY_0))); checkbox.setPropertyDataSource( m_selectionContainer.getItem(deleted.getStructureId()).getItemProperty(PROP_SELECTED)); m_deletedResourceContainer.addComponent(hl);
@Override public void setWeight(int weight) { Layout unwrapThis = this.unwrap(Layout.class); HasComponents parent = unwrapThis.getParent(); if (parent instanceof AbstractOrderedLayout) { for (com.vaadin.ui.Component child : parent) { if (unwrapThis.equals(child)) { ((AbstractOrderedLayout) parent).setExpandRatio(unwrapThis, weight); } else if (((AbstractOrderedLayout) parent).getExpandRatio(child) == 0) { ((AbstractOrderedLayout) parent).setExpandRatio(child, 1); } } } }
@Override public void remove(Component childComponent) { component.removeComponent(WebComponentsHelper.getComposition(childComponent)); ownComponents.remove(childComponent); childComponent.setParent(null); }
/** * 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; } componentAdded(c); }
writeMargin(design, getMargin(), def.getMargin(), designContext); design.appendChild(childElement); Alignment alignment = getComponentAlignment(child); if (alignment.isMiddle()) { childElement.attr(":middle", true); float expandRatio = getExpandRatio(child); if (expandRatio == 1.0f) { childElement.attr(":expand", true);