Example usage for com.vaadin.client Util getRequiredWidth

List of usage examples for com.vaadin.client Util getRequiredWidth

Introduction

In this page you can find the example usage for com.vaadin.client Util getRequiredWidth.

Prototype

@Deprecated
public static int getRequiredWidth(Widget widget) 

Source Link

Usage

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.csslayout.VDDCssLayout.java

License:Apache License

private void updatePlaceHolderStyleProperties(VDragEvent drag) {
    int width = 0;
    int height = 0;
    String className = "";

    placeHolderElement.setClassName(DRAG_SHADOW_STYLE_NAME);

    ComponentConnector draggedConnector = (ComponentConnector) drag.getTransferable()
            .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT);
    if (draggedConnector != null) {
        height = Util.getRequiredHeight(draggedConnector.getWidget());
        width = Util.getRequiredWidth(draggedConnector.getWidget());
        className = draggedConnector.getWidget().getElement().getClassName();
        className = className.replaceAll(VLayoutDragDropMouseHandler.ACTIVE_DRAG_SOURCE_STYLENAME, "");
        placeHolderElement.addClassName(className);
    } else if (drag.getElementOver() != getElement()) {
        width = 3;//from  ww  w.  ja v  a2 s.  com
        height = drag.getElementOver().getOffsetHeight();
    }

    placeHolderElement.getStyle().setWidth(width, Unit.PX);
    placeHolderElement.getStyle().setHeight(height, Unit.PX);
}

From source file:org.vaadin.tepi.listbuilder.widgetset.client.ui.VListBuilder.java

License:Apache License

void clearInternalWidths() {
    int cols = -1;
    if (getColumns() > 0) {
        cols = getColumns();//from   www.  j av a 2 s  . com
    } else if (!widthSet) {
        cols = DEFAULT_COLUMN_COUNT;
    }

    if (cols >= 0) {
        String colWidth = cols + "em";
        String containerWidth = (2 * cols + 2 * buttonWidthEm + 0.5) + "em";
        // Caption wrapper width == optionsSelect + buttons +
        // selectionsSelect
        String captionWrapperWidth = (2 * cols + 2 * buttonWidthEm) + "em";

        options.setWidth(colWidth);
        if (optionsCaption != null) {
            optionsCaption.setWidth(Util.getRequiredWidth(options) + "px");
        }
        selections.setWidth(colWidth);
        if (selectionsCaption != null) {
            selectionsCaption.setWidth(Util.getRequiredWidth(selections) + "px");
        }
        buttons.setWidth(String.valueOf(buttonWidthEm) + "em");
        moveButtons.setWidth(String.valueOf(buttonWidthEm) + "em");
        container.setWidth(containerWidth);
        captionWrapper.setWidth(captionWrapperWidth);
    }
}

From source file:org.vaadin.tepi.listbuilder.widgetset.client.ui.VListBuilder.java

License:Apache License

void setInternalWidths() {
    DOM.setStyleAttribute(getElement(), "position", "relative");
    int bordersAndPaddings = Util.measureHorizontalPaddingAndBorder(buttons.getElement(), 0)
            + Util.measureHorizontalPaddingAndBorder(moveButtons.getElement(), 0);
    int buttonWidth = Util.getRequiredWidth(buttons);
    int moveButtonWidth = Util.getRequiredWidth(moveButtons);
    int totalWidth = getOffsetWidth();

    int spaceForSelect = (totalWidth - buttonWidth - moveButtonWidth - bordersAndPaddings) / 2;

    options.setWidth(spaceForSelect + "px");
    if (optionsCaption != null) {
        optionsCaption.setWidth(spaceForSelect + "px");
    }//w ww. j ava 2s.co  m

    selections.setWidth(spaceForSelect + "px");
    if (selectionsCaption != null) {
        selectionsCaption.setWidth(spaceForSelect + "px");
    }
    int captionWidth = totalWidth - moveButtonWidth;
    captionWrapper.setWidth(captionWidth + "px");
}