Java Code Examples for com.vaadin.server.Sizeable#Unit

The following examples show how to use com.vaadin.server.Sizeable#Unit . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebWrapperUtils.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static Sizeable.Unit toVaadinUnit(SizeUnit sizeUnit) {
    checkNotNullArgument(sizeUnit);

    switch (sizeUnit) {
        case PIXELS:
            return Sizeable.Unit.PIXELS;
        case PERCENTAGE:
            return Sizeable.Unit.PERCENTAGE;
        default:
            throw new UnsupportedOperationException("Unsupported Size Unit");
    }
}
 
Example 2
Source File: WebWrapperUtils.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static SizeUnit toSizeUnit(Sizeable.Unit units) {
    checkNotNullArgument(units);

    switch (units) {
        case PIXELS:
            return SizeUnit.PIXELS;
        case PERCENTAGE:
            return SizeUnit.PERCENTAGE;
        default:
            throw new UnsupportedOperationException("Unsupported Size Unit");
    }
}
 
Example 3
Source File: MSize.java    From viritin with Apache License 2.0 4 votes vote down vote up
private MSize(float width, Sizeable.Unit widthUnit, float height, Sizeable.Unit heightUnit) {
    this.width = width;
    this.widthUnit = widthUnit;
    this.height = height;
    this.heightUnit = heightUnit;
}
 
Example 4
Source File: MSize.java    From viritin with Apache License 2.0 4 votes vote down vote up
public Sizeable.Unit getWidthUnit() {
    return widthUnit;
}
 
Example 5
Source File: MSize.java    From viritin with Apache License 2.0 4 votes vote down vote up
public Sizeable.Unit getHeightUnit() {
    return heightUnit;
}
 
Example 6
Source File: MSize.java    From viritin with Apache License 2.0 4 votes vote down vote up
public static MSize size(float width, Sizeable.Unit widthUnit, float height, Sizeable.Unit heightUnit) {
    return new MSize(width, widthUnit, height, heightUnit);
}
 
Example 7
Source File: NumberFieldWidthTest.java    From viritin with Apache License 2.0 3 votes vote down vote up
@Test
public void testSizeDefined() {

    IntegerField integerField = new IntegerField() {
        private static final long serialVersionUID = -2915829267538851760L;

        @Override
        public void setWidth(float width, Sizeable.Unit unit) {
            super.setWidth(width, unit);
            underlayingField = tf;
        }
        
    };
    
    Assert.assertEquals(-1, integerField.getWidth(),0.001);
    
    integerField.setWidth("99%");
    
    Assert.assertEquals(99, integerField.getWidth(),0.001);
    Assert.assertEquals(100, underlayingField.getWidth(),0.001);

    integerField.setSizeUndefined();;

    Assert.assertEquals(-1, integerField.getWidth(),0.001);
    Assert.assertEquals(-1, underlayingField.getWidth(),0.001);
    
}