use of com.haulmont.cuba.web.toolkit.ui.CubaHorizontalActionsLayout in project cuba by cuba-platform.
the class WebGroupBox method add.
@Override
public void add(Component childComponent, int index) {
if (childComponent.getParent() != null && childComponent.getParent() != this) {
throw new IllegalStateException("Component already has parent");
}
AbstractOrderedLayout newContent = null;
if (orientation == Orientation.VERTICAL && !(component.getContent() instanceof CubaVerticalActionsLayout)) {
newContent = new CubaVerticalActionsLayout();
} else if (orientation == Orientation.HORIZONTAL && !(component.getContent() instanceof CubaHorizontalActionsLayout)) {
newContent = new CubaHorizontalActionsLayout();
}
if (newContent != null) {
newContent.setStyleName("c-groupbox-inner");
component.setContent(newContent);
CubaOrderedActionsLayout currentContent = (CubaOrderedActionsLayout) component.getContent();
newContent.setMargin(currentContent.getMargin());
newContent.setSpacing(currentContent.isSpacing());
}
if (ownComponents.contains(childComponent)) {
int existingIndex = getComponentContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent));
if (index > existingIndex) {
index--;
}
remove(childComponent);
}
com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent);
getComponentContent().addComponent(vComponent, index);
getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
if (frame != null) {
if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) {
((BelongToFrame) childComponent).setFrame(frame);
} else {
frame.registerComponent(childComponent);
}
}
if (index == ownComponents.size()) {
ownComponents.add(childComponent);
} else {
ownComponents.add(index, childComponent);
}
childComponent.setParent(this);
}
use of com.haulmont.cuba.web.toolkit.ui.CubaHorizontalActionsLayout in project cuba by cuba-platform.
the class WebScrollBoxLayout method add.
@Override
public void add(Component childComponent, int index) {
if (childComponent.getParent() != null && childComponent.getParent() != this) {
throw new IllegalStateException("Component already has parent");
}
AbstractOrderedLayout newContent = null;
if (orientation == Orientation.VERTICAL && !(getContent() instanceof CubaVerticalActionsLayout)) {
newContent = new CubaVerticalActionsLayout();
newContent.setWidth("100%");
} else if (orientation == Orientation.HORIZONTAL && !(getContent() instanceof CubaHorizontalActionsLayout)) {
newContent = new CubaHorizontalActionsLayout();
}
if (newContent != null) {
newContent.setMargin((getContent()).getMargin());
newContent.setSpacing((getContent()).isSpacing());
newContent.setStyleName(SCROLLBOX_CONTENT_STYLENAME);
com.vaadin.ui.Component oldContent = component.getComponent(0);
newContent.setWidth(oldContent.getWidth(), oldContent.getWidthUnits());
newContent.setHeight(oldContent.getHeight(), oldContent.getHeightUnits());
component.removeAllComponents();
component.addComponent(newContent);
applyScrollBarsPolicy(scrollBarPolicy);
}
if (ownComponents.contains(childComponent)) {
int existingIndex = getContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent));
if (index > existingIndex) {
index--;
}
remove(childComponent);
}
com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent);
getContent().addComponent(vComponent, index);
getContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
if (frame != null) {
if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) {
((BelongToFrame) childComponent).setFrame(frame);
} else {
frame.registerComponent(childComponent);
}
}
if (index == ownComponents.size()) {
ownComponents.add(childComponent);
} else {
ownComponents.add(index, childComponent);
}
childComponent.setParent(this);
}
Aggregations