use of com.vaadin.ui.AbstractOrderedLayout in project jmix by jmix-framework.
the class WindowImpl method expand.
@Override
public void expand(Component childComponent) {
if (getContainer() instanceof AbstractOrderedLayout) {
AbstractOrderedLayout container = (AbstractOrderedLayout) getContainer();
container.setExpandRatio(childComponent.unwrapComposition(com.vaadin.ui.Component.class), 1);
if (getExpandDirection() == ExpandDirection.VERTICAL) {
childComponent.setHeightFull();
} else {
childComponent.setWidthFull();
}
} else {
throw new UnsupportedOperationException();
}
}
use of com.vaadin.ui.AbstractOrderedLayout in project jmix by jmix-framework.
the class ScrollBoxLayoutImpl 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 JmixVerticalActionsLayout)) {
newContent = new JmixVerticalActionsLayout();
newContent.setWidth(100, Sizeable.Unit.PERCENTAGE);
} else if (orientation == Orientation.HORIZONTAL && !(getContent() instanceof JmixHorizontalActionsLayout)) {
newContent = new JmixHorizontalActionsLayout();
}
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(ComponentsHelper.getComposition(childComponent));
if (index > existingIndex) {
index--;
}
remove(childComponent);
}
com.vaadin.ui.Component vComponent = ComponentsHelper.getComposition(childComponent);
getContent().addComponent(vComponent, index);
getContent().setComponentAlignment(vComponent, WrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
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);
}
use of com.vaadin.ui.AbstractOrderedLayout in project jmix by jmix-framework.
the class AbstractCanvasLayout method setWeight.
@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);
}
}
}
}
use of com.vaadin.ui.AbstractOrderedLayout in project jmix by jmix-framework.
the class AbstractCanvasLayout method getWeight.
@Override
public int getWeight() {
Layout unwrapThis = this.unwrap(Layout.class);
HasComponents parent = unwrapThis.getParent();
if (parent instanceof AbstractOrderedLayout) {
int weight = (int) ((AbstractOrderedLayout) parent).getExpandRatio(unwrapThis);
return weight > 0 ? weight : 1;
} else {
return 1;
}
}
Aggregations