List of usage examples for com.google.gwt.dom.client Style getPadding
public String getPadding()
From source file:com.vaadin.client.ui.VComboBox.java
License:Apache License
/** * Calculates the width of the select if the select has undefined width. * Should be called when the width changes or when the icon changes. * <p>/*from w w w . j a v a2s. co m*/ * For internal use only. May be removed or replaced in the future. */ public void updateRootWidth() { debug("VComboBox: updateRootWidth()"); if (connector.isUndefinedWidth()) { /* * When the select has a undefined with we need to check that we are * only setting the text box width relative to the first page width * of the items. If this is not done the text box width will change * when the popup is used to view longer items than the text box is * wide. */ int w = WidgetUtil.getRequiredWidth(this); if (dataReceivedHandler.isWaitingForInitialData() && suggestionPopupMinWidth > w) { /* * We want to compensate for the paddings just to preserve the * exact size as in Vaadin 6.x, but we get here before * MeasuredSize has been initialized. * Util.measureHorizontalPaddingAndBorder does not work with * border-box, so we must do this the hard way. */ Style style = getElement().getStyle(); String originalPadding = style.getPadding(); String originalBorder = style.getBorderWidth(); style.setPaddingLeft(0, Unit.PX); style.setBorderWidth(0, Unit.PX); style.setProperty("padding", originalPadding); style.setProperty("borderWidth", originalBorder); // Use util.getRequiredWidth instead of getOffsetWidth here int iconWidth = selectedItemIcon == null ? 0 : WidgetUtil.getRequiredWidth(selectedItemIcon); int buttonWidth = popupOpener == null ? 0 : WidgetUtil.getRequiredWidth(popupOpener); /* * Instead of setting the width of the wrapper, set the width of * the combobox. Subtract the width of the icon and the * popupopener */ tb.setWidth(suggestionPopupMinWidth - iconWidth - buttonWidth + "px"); } /* * Lock the textbox width to its current value if it's not already * locked. This can happen after setWidth("") which resets the * textbox width to "100%". */ if (!tb.getElement().getStyle().getWidth().endsWith("px")) { int iconWidth = selectedItemIcon == null ? 0 : selectedItemIcon.getOffsetWidth(); tb.setWidth(tb.getOffsetWidth() - iconWidth + "px"); } } }
From source file:com.vaadin.client.ui.VFilterSelect.java
License:Apache License
/** * Calculates the width of the select if the select has undefined width. * Should be called when the width changes or when the icon changes. * <p>//from w w w . j a va 2 s .c o m * For internal use only. May be removed or replaced in the future. */ public void updateRootWidth() { ComponentConnector paintable = ConnectorMap.get(client).getConnector(this); if (paintable.isUndefinedWidth()) { /* * When the select has a undefined with we need to check that we are * only setting the text box width relative to the first page width * of the items. If this is not done the text box width will change * when the popup is used to view longer items than the text box is * wide. */ int w = WidgetUtil.getRequiredWidth(this); if ((!initDone || currentPage + 1 < 0) && suggestionPopupMinWidth > w) { /* * We want to compensate for the paddings just to preserve the * exact size as in Vaadin 6.x, but we get here before * MeasuredSize has been initialized. * Util.measureHorizontalPaddingAndBorder does not work with * border-box, so we must do this the hard way. */ Style style = getElement().getStyle(); String originalPadding = style.getPadding(); String originalBorder = style.getBorderWidth(); style.setPaddingLeft(0, Unit.PX); style.setBorderWidth(0, Unit.PX); style.setProperty("padding", originalPadding); style.setProperty("borderWidth", originalBorder); // Use util.getRequiredWidth instead of getOffsetWidth here int iconWidth = selectedItemIcon == null ? 0 : WidgetUtil.getRequiredWidth(selectedItemIcon); int buttonWidth = popupOpener == null ? 0 : WidgetUtil.getRequiredWidth(popupOpener); /* * Instead of setting the width of the wrapper, set the width of * the combobox. Subtract the width of the icon and the * popupopener */ tb.setWidth((suggestionPopupMinWidth - iconWidth - buttonWidth) + "px"); } /* * Lock the textbox width to its current value if it's not already * locked */ if (!tb.getElement().getStyle().getWidth().endsWith("px")) { int iconWidth = selectedItemIcon == null ? 0 : selectedItemIcon.getOffsetWidth(); tb.setWidth((tb.getOffsetWidth() - iconWidth) + "px"); } } }