List of usage examples for com.google.gwt.dom.client Style clearMarginLeft
public void clearMarginLeft()
From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java
License:Apache License
/** * Update the offset off the caption relative to the slot * <p>//w w w .j a v a 2 s.c om * For internal use only. May be removed or replaced in the future. * * @param caption * The caption element * @deprecated As of 7.2, call or override * {@link #updateCaptionOffset(Element)} instead */ @Deprecated public void updateCaptionOffset(com.google.gwt.user.client.Element caption) { Element captionWrap = caption.getParentElement(); Style captionWrapStyle = captionWrap.getStyle(); captionWrapStyle.clearPaddingTop(); captionWrapStyle.clearPaddingRight(); captionWrapStyle.clearPaddingBottom(); captionWrapStyle.clearPaddingLeft(); Style captionStyle = caption.getStyle(); captionStyle.clearMarginTop(); captionStyle.clearMarginRight(); captionStyle.clearMarginBottom(); captionStyle.clearMarginLeft(); // Get caption position from the classname CaptionPosition captionPosition = getCaptionPositionFromElement(captionWrap); if (captionPosition == CaptionPosition.LEFT || captionPosition == CaptionPosition.RIGHT) { int captionWidth; if (layoutManager != null) { captionWidth = layoutManager.getOuterWidth(caption) - layoutManager.getMarginWidth(caption); } else { captionWidth = caption.getOffsetWidth(); } if (captionWidth > 0) { if (captionPosition == CaptionPosition.LEFT) { captionWrapStyle.setPaddingLeft(captionWidth, Unit.PX); captionStyle.setMarginLeft(-captionWidth, Unit.PX); } else { captionWrapStyle.setPaddingRight(captionWidth, Unit.PX); captionStyle.setMarginRight(-captionWidth, Unit.PX); } } } if (captionPosition == CaptionPosition.TOP || captionPosition == CaptionPosition.BOTTOM) { int captionHeight; if (layoutManager != null) { captionHeight = layoutManager.getOuterHeight(caption) - layoutManager.getMarginHeight(caption); } else { captionHeight = caption.getOffsetHeight(); } if (captionHeight > 0) { if (captionPosition == CaptionPosition.TOP) { captionWrapStyle.setPaddingTop(captionHeight, Unit.PX); captionStyle.setMarginTop(-captionHeight, Unit.PX); } else { captionWrapStyle.setPaddingBottom(captionHeight, Unit.PX); captionStyle.setMarginBottom(-captionHeight, Unit.PX); } } } }
From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java
License:Apache License
/** * Assigns relative sizes to the children that should expand based on their * expand ratios./*from ww w. j a v a 2s . com*/ */ public void updateExpandedSizes() { // Ensure the expand wrapper is in place if (expandWrapper == null) { expandWrapper = DOM.createDiv(); expandWrapper.setClassName("v-expand"); // Detach all widgets before modifying DOM for (Widget widget : getChildren()) { orphan(widget); } while (getElement().getChildCount() > 0) { Node el = getElement().getChild(0); expandWrapper.appendChild(el); } getElement().appendChild(expandWrapper); // Attach all widgets again for (Widget widget : getChildren()) { adopt(widget); } } // Sum up expand ratios to get the denominator double total = 0; for (Slot slot : widgetToSlot.values()) { // FIXME expandRatio might be <0 total += slot.getExpandRatio(); } // Give each expanded child its own share for (Slot slot : widgetToSlot.values()) { Element slotElement = slot.getElement(); slotElement.removeAttribute("aria-hidden"); Style slotStyle = slotElement.getStyle(); slotStyle.clearVisibility(); slotStyle.clearMarginLeft(); slotStyle.clearMarginTop(); if (slot.getExpandRatio() != 0) { // FIXME expandRatio might be <0 double size = 100 * (slot.getExpandRatio() / total); if (vertical) { slot.setHeight(size + "%"); if (slot.hasRelativeHeight()) { Util.notifyParentOfSizeChange(this, true); } } else { slot.setWidth(size + "%"); if (slot.hasRelativeWidth()) { Util.notifyParentOfSizeChange(this, true); } } } else if (slot.isRelativeInDirection(vertical)) { // Relative child without expansion gets no space at all if (vertical) { slot.setHeight("0"); } else { slot.setWidth("0"); } slotStyle.setVisibility(Visibility.HIDDEN); slotElement.setAttribute("aria-hidden", "true"); } else { // Non-relative child without expansion should be unconstrained if (BrowserInfo.get().isIE8()) { // unconstrained in IE8 is auto if (vertical) { slot.setHeight("auto"); } else { slot.setWidth("auto"); } } else { if (vertical) { slotStyle.clearHeight(); } else { slotStyle.clearWidth(); } } } } }
From source file:org.kie.dockerui.client.widgets.container.navigator.item.view.NavigationItemView.java
License:Apache License
private void show(final String id, final String _title, final String _text, final SafeUri imageUri, final int containersRunningCount) { showTitle(_title);/* ww w. j ava2s. c o m*/ showRunningContainers(id, containersRunningCount); // Show the navigation item image. final boolean isImage = imageUri != null; if (isImage) { image.setUrl(imageUri); image.setSize(getSizeInPx(), getSizeInPx()); } image.setVisible(isImage); // Show the navigation item text. final boolean isText = _text != null; if (isText) { text.setText(new SafeHtmlBuilder().appendEscaped(_text).toSafeHtml().asString()); } // Styles for placing the text over the image. final Style textStyle = text.getElement().getStyle(); if (isImage && isText) { textStyle.setPosition(Style.Position.ABSOLUTE); textStyle.setMarginTop(size / 2, Style.Unit.PX); final int tSize = (int) (_text.length() * 5); textStyle.setMarginLeft((size / 2) - tSize, Style.Unit.PX); } else if (isText) { textStyle.setPosition(Style.Position.RELATIVE); textStyle.clearMarginTop(); textStyle.clearMarginLeft(); } text.setVisible(isText); // Add the click handler. addItemDetailClickHandler(id); }
From source file:org.waveprotocol.wave.client.editor.content.paragraph.DefaultParagraphHtmlRenderer.java
License:Apache License
@Override public void updateRendering(HasImplNodelets element, String type, String listStyle, int indent, Alignment alignment, Direction direction) { Element implNodelet = element.getImplNodelet(); ParagraphBehaviour behaviour = ParagraphBehaviour.of(type); boolean toListItem = behaviour == ParagraphBehaviour.LIST; boolean isListItem = implNodelet.getTagName().equalsIgnoreCase(LIST_IMPL_TAGNAME); if (isListItem != toListItem) { Element newNodelet = createNodeletInner(toListItem); DomHelper.replaceElement(implNodelet, newNodelet); element.setBothNodelets(newNodelet); // Ideally onRepair shouldn't require a ContentElement ParagraphHelper.INSTANCE.onRepair((ContentElement) element); implNodelet = newNodelet;/* w ww. j a va2s .c om*/ } //// Type logic //// double fontSize = -1; FontWeight fontWeight = null; implNodelet.removeClassName(NUMBERED_CLASSNAME); switch (behaviour) { case LIST: if (Paragraph.LIST_STYLE_DECIMAL.equals(listStyle)) { implNodelet.addClassName(NUMBERED_CLASSNAME); } break; case HEADING: fontWeight = FontWeight.BOLD; double headingNum = Integer.parseInt(type.substring(1)); // Do this with CSS instead. // h1 -> 1.75, h4 -> 1, others linearly in between. double factor = 1 - (headingNum - 1) / (Paragraph.NUM_HEADING_SIZES - 1); fontSize = MIN_HEADING_SIZE_EM + factor * (MAX_HEADING_SIZE_EM - MIN_HEADING_SIZE_EM); break; } //// Indent logic //// for (String bulletType : BULLET_CLASSNAMES) { implNodelet.removeClassName(bulletType); } if (behaviour == ParagraphBehaviour.LIST) { if (listStyle == null) { implNodelet.addClassName(bulletClassName(indent)); } indent++; } int margin = indent * INDENT_UNIT_SIZE_PX; //// Update actual values //// // NOTE(danilatos): For these, it might be more efficient to check that the // value has changed before changing it. This is not currently known. Style style = implNodelet.getStyle(); if (fontSize != -1) { style.setFontSize(fontSize, Unit.EM); } else { style.clearFontSize(); } if (fontWeight != null) { style.setFontWeight(fontWeight); } else { style.clearFontWeight(); } if (alignment != null) { style.setProperty("textAlign", alignment.cssValue()); } else { style.clearProperty("textAlign"); } if (direction != null) { style.setProperty("direction", direction.cssValue()); } else { style.clearProperty("direction"); } if (margin == 0) { style.clearMarginLeft(); style.clearMarginRight(); } else { if (direction == Direction.RTL) { style.setMarginRight(margin, Unit.PX); style.clearMarginLeft(); } else { style.setMarginLeft(margin, Unit.PX); style.clearMarginRight(); } } }