Java Code Examples for com.google.gwt.dom.client.Style#clearWhiteSpace()
The following examples show how to use
com.google.gwt.dom.client.Style#clearWhiteSpace() .
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: CubaGridLayoutSlot.java From cuba with Apache License 2.0 | 5 votes |
protected int getButtonHeight(CubaButtonWidget widget) { Element element = widget.getElement(); if (!element.hasClassName("link")) { return getWidgetHeight(widget); } Element captionElement = findLinkButtonCaptionElement(element); if (captionElement == null) { return getWidgetHeight(widget); } // The LinkButton component has an ability to wrap caption onto multiple rows. // Thus, at the first recalculation of the heights for the slots, the "getWidgetHeight()" call // returns an invalid multiline component height. // In order to calculate the really required caption height, regardless of the 'white-space' mode, // we need to explicitly set it to 'nowrap'. After calculation, it's reverted back. Style style = captionElement.getStyle(); String prevWhiteSpace = style.getWhiteSpace(); style.setWhiteSpace(Style.WhiteSpace.NOWRAP); int buttonHeight = element.getOffsetHeight(); if (prevWhiteSpace != null && !prevWhiteSpace.isEmpty()) { style.setWhiteSpace(Style.WhiteSpace.valueOf(prevWhiteSpace)); } else { style.clearWhiteSpace(); } return buttonHeight; }
Example 2
Source File: CubaFieldGroupLayoutConnector.java From cuba with Apache License 2.0 | 5 votes |
protected int getMaxCaptionWidth(VGridLayout.Cell cell) { VCaption caption = cell.slot.getCaption(); Element captionElement = caption.getElement(); com.google.gwt.dom.client.Element childElement = findCaptionTextChildElement(captionElement); if (childElement != null) { // In some cases, e.g. by changing CheckBox 'captionManagedByLayout' attribute, // a slot has no Caption at first iteration of 'maxCaptionWidth' calculation, // as the result, for the second and so forth iterations, when the rest of // components get their captions, 'caption.getRenderedWidth()' returns an incorrect value. // In order to calculate the really required caption width, regardless of the 'white-space' mode, // we need to explicitly set it to 'nowrap'. After calculation, it's reverted back. Style style = childElement.getStyle(); String prevWhiteSpace = style.getWhiteSpace(); style.setWhiteSpace(Style.WhiteSpace.NOWRAP); int renderedWidth = caption.getRenderedWidth(); if (prevWhiteSpace != null && !prevWhiteSpace.isEmpty()) { style.setWhiteSpace(Style.WhiteSpace.valueOf(prevWhiteSpace)); } else { style.clearWhiteSpace(); } return renderedWidth; } return caption.getRenderedWidth(); }