List of usage examples for com.google.gwt.dom.client Style clearProperty
public void clearProperty(String name)
From source file:com.google.gerrit.client.change.RightSidePopdownAction.java
License:Apache License
void show() { if (popup != null) { button.removeStyleName(style.selected()); popup.hide();//from w ww. j a v a 2 s . com return; } final PopupPanel p = new PopupPanel(true) { @Override public void setPopupPosition(int left, int top) { top -= Document.get().getBodyOffsetTop(); int w = Window.getScrollLeft() + Window.getClientWidth(); int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth(); int right = w - r; Style style = getElement().getStyle(); style.clearProperty("left"); style.setPropertyPx("right", right); style.setPropertyPx("top", top); } }; p.setStyleName(style.replyBox()); p.addAutoHidePartner(button.getElement()); p.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (popup == p) { button.removeStyleName(style.selected()); popup = null; } } }); p.add(getWidget()); p.showRelativeTo(relativeTo); GlobalKey.dialog(p); button.addStyleName(style.selected()); popup = p; }
From source file:com.googlesource.gerrit.plugins.cookbook.client.PopDownButton.java
License:Apache License
private void show() { if (popup != null) { getElement().getStyle().clearFontWeight(); popup.hide();//from w ww .ja va 2 s.c om return; } final Widget relativeTo = getParent(); final PopupPanel p = new PopupPanel(true) { @Override public void setPopupPosition(int left, int top) { top -= Document.get().getBodyOffsetTop(); int w = Window.getScrollLeft() + Window.getClientWidth(); int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth(); int right = w - r; Style style = getElement().getStyle(); style.clearProperty("left"); style.setPropertyPx("right", right); style.setPropertyPx("top", top); } }; Style popupStyle = p.getElement().getStyle(); popupStyle.setBorderWidth(0, Unit.PX); popupStyle.setBackgroundColor("#EEEEEE"); p.addAutoHidePartner(getElement()); p.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (popup == p) { getElement().getStyle().clearFontWeight(); popup = null; } } }); p.add(widget); p.showRelativeTo(relativeTo); GlobalKey.dialog(p); getElement().getStyle().setFontWeight(FontWeight.BOLD); popup = p; }
From source file:com.gwtm.ui.client.widgets.OverlayPanel.java
License:Apache License
private void doPosition(Style s) { if (isCentered) { setBottom(null);//from ww w .ja va2 s. c o m setRight(null); setTop("50%"); setLeft("50%"); int height = getWidget().getOffsetHeight(); int width = getWidget().getOffsetWidth(); int centralPointW = Window.getClientWidth() / 2; int centralPointH = Window.getClientHeight() / 2; int newLeft = centralPointW - (width / 2); int newTop = centralPointH - (height / 2); getWidget().getElement().getStyle().setLeft(newLeft, Unit.PX); getWidget().getElement().getStyle().setTop(newTop, Unit.PX); // XLog.info("height: " + height + ", getOffsetHeight(): " + // getOffsetHeight()); // int top_ = height >= getOffsetHeight() ? 0 : (height / 2); // int left_ = width >= getOffsetWidth() ? 0 : (width / 2); // // s.setProperty("marginTop", "-" + top_ + "px"); // s.setProperty("marginLeft", "-" + left_ + "px"); } else { if (top == null) { s.clearProperty("top"); } else { s.setProperty("top", top); } if (right == null) { s.clearProperty("right"); } else { s.setProperty("right", right); } if (bottom == null) { s.clearProperty("bottom"); } else { s.setProperty("bottom", bottom); } if (left == null) { s.clearProperty("left"); } else { s.setProperty("left", left); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.fieldgrouplayout.CubaFieldGroupLayoutComponentSlot.java
License:Apache License
@Override public void positionHorizontally(double currentLocation, double allocatedSpace, double marginRight) { if (!isCaptionInline()) { super.positionHorizontally(currentLocation, allocatedSpace, marginRight); return;//from w w w .j a v a2 s . c om } // CAUTION copied from VLayoutSlot.positionHorizontally(~) Style style = wrapper.getStyle(); double availableWidth = allocatedSpace; VCaption caption = getCaption(); Style captionStyle = caption != null ? caption.getElement().getStyle() : null; int captionWidth = getCaptionWidth(); boolean clearCaptionRight = false; boolean captionAboveCompnent; if (caption == null) { captionAboveCompnent = false; style.clearPaddingLeft(); clearCaptionRight = true; } else { captionAboveCompnent = !caption.shouldBePlacedAfterComponent(); if (!captionAboveCompnent) { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } captionStyle.clearLeft(); captionStyle.setRight(0, Style.Unit.PX); style.setPaddingRight(captionWidth, Style.Unit.PX); } else { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } style.setPaddingLeft(captionWidth, Style.Unit.PX); captionStyle.setLeft(0, Style.Unit.PX); captionStyle.clearRight(); clearCaptionRight = true; } } // Take into account right indicators double indicatorsWidth = 0; if (rightCaption != null) { indicatorsWidth = WidgetUtil.getRequiredWidth(rightCaption); availableWidth -= indicatorsWidth; if (availableWidth < 0) { availableWidth = 0; } style.setPaddingRight(indicatorsWidth, Style.Unit.PX); } else if (clearCaptionRight) { style.clearPaddingRight(); } if (marginRight > 0) { style.setMarginRight(marginRight, Style.Unit.PX); } else { style.clearMarginRight(); } if (isRelativeWidth()) { style.setPropertyPx("width", (int) availableWidth); } else { style.clearProperty("width"); } double allocatedContentWidth = 0; if (isRelativeWidth()) { String percentWidth = getWidget().getElement().getStyle().getWidth(); double percentage = parsePercent(percentWidth); allocatedContentWidth = availableWidth * (percentage / 100); reportActualRelativeWidth(Math.round((float) allocatedContentWidth)); } AlignmentInfo alignment = getAlignment(); if (!alignment.isLeft()) { double usedWidth; if (isRelativeWidth()) { if (isCaptionInline()) { usedWidth = allocatedContentWidth + indicatorsWidth + captionWidth; } else { usedWidth = allocatedContentWidth + indicatorsWidth; } } else { usedWidth = getWidgetWidth() + indicatorsWidth; } if (alignment.isHorizontalCenter()) { currentLocation += (allocatedSpace - usedWidth) / 2d; if (captionAboveCompnent) { captionStyle.setLeft(Math.round(usedWidth - captionWidth) / 2, Style.Unit.PX); } } else { currentLocation += (allocatedSpace - usedWidth); if (captionAboveCompnent) { captionStyle.setLeft(Math.round(usedWidth - captionWidth), Style.Unit.PX); } } } else { if (captionAboveCompnent) { captionStyle.setLeft(0, Style.Unit.PX); } } style.setLeft(Math.round(currentLocation), Style.Unit.PX); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.groupbox.CubaGroupBoxWidget.java
License:Apache License
public void setCollapsable(boolean collapsable) { Style expanderStyle = expander.getStyle(); if (collapsable) { expanderStyle.clearProperty("display"); removeStyleDependentName("nocollapsable"); } else {/*from w w w .j ava2 s . c om*/ addStyleDependentName("nocollapsable"); expanderStyle.setDisplay(Style.Display.NONE); } Tools.textSelectionEnable(captionNode, !collapsable); this.collapsable = collapsable; }
From source file:com.sencha.gxt.chart.client.draw.engine.VML.java
License:sencha.com license
/** * Applies the attributes of the passed {@link TextSprite} to its VML element. * // w ww . jav a 2s . c o m * @param sprite the sprite whose attributes to use */ private void setTextAttributes(TextSprite sprite, XElement element) { Element textPath = element.childElement("textPath").cast(); Style textStyle = textPath.getStyle(); textBBoxCache.remove(sprite); if (sprite.isFontSizeDirty() || ignoreOptimizations) { if (sprite.getFontSize() > 0) { textStyle.setFontSize(sprite.getFontSize(), Unit.PX); } else { textStyle.clearFontSize(); } } if (sprite.isFontStyleDirty() || ignoreOptimizations) { if (sprite.getFontStyle() != null) { textStyle.setFontStyle(sprite.getFontStyle()); } else { textStyle.clearFontStyle(); } } if (sprite.isFontWeightDirty() || ignoreOptimizations) { if (sprite.getFontWeight() != null) { textStyle.setFontWeight(sprite.getFontWeight()); } else { textStyle.clearFontWeight(); } } if (sprite.isFontDirty() || ignoreOptimizations) { if (sprite.getFont() != null) { textStyle.setProperty("fontFamily", sprite.getFont()); } else { textStyle.clearProperty("fontFamily"); } } // text-anchor emulation if (sprite.isTextAnchorDirty() || ignoreOptimizations) { if (sprite.getTextAnchor() == TextAnchor.MIDDLE) { setTextAlign(textStyle, "center"); } else if (sprite.getTextAnchor() == TextAnchor.END) { setTextAlign(textStyle, "right"); } else { setTextAlign(textStyle, "left"); } } if (sprite.isTextDirty() || ignoreOptimizations) { if (sprite.getText() != null) { textPath.setPropertyString("string", sprite.getText()); } else { textPath.setPropertyString("string", ""); } } if (sprite.isTextBaselineDirty() || sprite.isXDirty() || sprite.isYDirty() || ignoreOptimizations) { double height = sprite.getFontSize(); if (sprite.getTextBaseline() == TextBaseline.MIDDLE) { height = 0; } else if (sprite.getTextBaseline() == TextBaseline.BOTTOM) { height *= -1; } Element path = element.childElement("path").cast(); path.setPropertyString("v", new StringBuilder().append("m").append(Math.round(sprite.getX() * zoom)).append(",") .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).append(" l") .append(Math.round(sprite.getX() * zoom) + 1).append(",") .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).toString()); textRenderedPoints.put(sprite, new PrecisePoint(sprite.getX(), sprite.getY())); textRenderedBaseline.put(sprite, sprite.getTextBaseline()); } }
From source file:com.smartgwt.mobile.client.internal.util.AnimationUtil.java
License:Open Source License
/** * Fade-transition between the old and new widget. * * @param oldPane the old widget/* w w w . j a v a2 s . c o m*/ * @param newPane the new widget * @param container the container panel */ public static void fadeTransition(final Canvas oldPane, final Canvas newPane, final Canvas container, final Function<Void> beforeCallback, final Function<Void> callback, final boolean removeOldPane) { if (container instanceof Layout) { assert ((Layout) container).hasMember(oldPane) : "`container' does not contain `oldPane' as a member."; } else { assert container.hasChild(oldPane) : "`container' does not contain `oldPane' as a child."; } oldPane.setVisible(true); oldPane.getElement().getStyle().setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none"); newPane.getElement().getStyle().setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none"); oldPane.getElement().getStyle().setOpacity(1.0); if (container instanceof Layout) { if (!((Layout) container).hasMember(newPane)) ((Layout) container).addMember(newPane); } else { if (!container.hasChild(newPane)) container.addChild(newPane); } newPane.setVisible(true); newPane.getElement().getStyle().setOpacity(0.0); // To avoid issues with simultaneity, we use Timers. // http://www.w3.org/TR/css3-transitions/#starting new Timer() { @Override public void run() { if (beforeCallback != null) beforeCallback.execute(); oldPane.getElement().getStyle().setProperty( DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "opacity " + FADE_TRANSITION_DURATION_MILLIS + "ms linear"); newPane.getElement().getStyle().setProperty( DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "opacity " + FADE_TRANSITION_DURATION_MILLIS + "ms linear"); new Timer() { @Override public void run() { oldPane.getElement().getStyle().setOpacity(0.0); newPane.getElement().getStyle().setOpacity(1.0); new TransitionEndHandler() { private Timer fallbackTimer = new Timer() { @Override public void run() { if (fallbackTimer == this) { fallbackTimer = null; execute(); } } }; { fallbackTimer.schedule(FADE_TRANSITION_DURATION_MILLIS + 50); } private HandlerRegistration transitionEndRegistration = oldPane.getElement() .<SuperElement>cast().addTransitionEndHandler(this); @Override public void onTransitionEnd(TransitionEndEvent event) { if (transitionEndRegistration != null && oldPane.equals(event.getEventTarget())) { execute(); } } private void execute() { if (fallbackTimer != null) { fallbackTimer.cancel(); fallbackTimer = null; } if (transitionEndRegistration != null) { transitionEndRegistration.removeHandler(); transitionEndRegistration = null; } if (removeOldPane) { if (container instanceof Layout) { ((Layout) container).removeMember(oldPane); } else { container.removeChild(oldPane); } } else oldPane.setVisible(false); // Clear the transitions and opacity values. // This is particularly important for oldPane because it may be subsequently added to // a Layout, but the uncleared opacity would keep it invisible. final Style oldPaneStyle = oldPane.getElement().getStyle(); oldPaneStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none"); oldPaneStyle .clearProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName()); oldPaneStyle.clearOpacity(); final Style newPaneStyle = newPane.getElement().getStyle(); newPaneStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none"); newPaneStyle .clearProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName()); newPaneStyle.clearOpacity(); if (callback != null) { new Timer() { @Override public void run() { assert callback != null; callback.execute(); } }.schedule(1); } } }; } }.schedule(1); } }.schedule(1); }
From source file:com.smartgwt.mobile.client.internal.util.AnimationUtil.java
License:Open Source License
private static void completeSlideTransition(final Canvas oldPane, final Canvas newPane, final Layout container, final Direction direction, final Function<Void> callback, final boolean removeOldPane) { new TransitionEndHandler() { private Timer fallbackTimer = new Timer() { @Override/* www .jav a 2 s .co m*/ public void run() { if (fallbackTimer == this) { fallbackTimer = null; execute(); } } }; { fallbackTimer.schedule(SLIDE_TRANSITION_DURATION_MILLIS + 50); } private HandlerRegistration transitionEndRegistration = oldPane.getElement().<SuperElement>cast() .addTransitionEndHandler(this); @Override public void onTransitionEnd(TransitionEndEvent event) { if (transitionEndRegistration != null && oldPane.equals(event.getEventTarget())) { execute(); } } private void execute() { if (fallbackTimer != null) { fallbackTimer.cancel(); fallbackTimer = null; } if (transitionEndRegistration != null) { transitionEndRegistration.removeHandler(); transitionEndRegistration = null; } if (removeOldPane) container.removeMember(oldPane); else container.hideMember(oldPane); // Clear the transitions and transforms. // This is particularly important for oldPane because it may be subsequently added to // a Layout, but the uncleared transform would place it off screen. final Style oldPaneStyle = oldPane.getElement().getStyle(); oldPaneStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none"); oldPaneStyle.clearProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName()); oldPaneStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "none"); oldPaneStyle.clearProperty(DOMConstants.INSTANCE.getTransformPropertyName()); final Style newPaneStyle = newPane.getElement().getStyle(); newPaneStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none"); newPaneStyle.clearProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName()); newPaneStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "none"); newPaneStyle.clearProperty(DOMConstants.INSTANCE.getTransformPropertyName()); if (callback != null) { new Timer() { @Override public void run() { assert callback != null; callback.execute(); } }.schedule(1); } } }; }
From source file:com.smartgwt.mobile.client.widgets.BaseButton.java
License:Open Source License
private void doSetIcon(boolean fireContentChangedEvent) { assert icon != null && iconImage != null; final Element img = iconImage.getElement(); final Style imgStyle = img.getStyle(); if (masked) { iconImage.setResource(IconResources.INSTANCE.blank()); if ("IMG".equals(img.getTagName())) { final ImageElement iconImageImgElem = ImageElement.as(img); iconImageImgElem.removeAttribute("width"); iconImageImgElem.removeAttribute("height"); }//from w w w .j a va 2 s . co m imgStyle.clearWidth(); imgStyle.clearHeight(); img.setClassName(_CSS.maskedButtonIconClass()); imgStyle.clearBackgroundColor(); imgStyle.clearBackgroundImage(); // Note: Mobile WebKit automatically scales down the mask image to fit the element // to which the mask image is applied. imgStyle.setProperty("WebkitMaskBoxImage", "url(" + icon.getSafeUri().asString() + ")"); } else { if ("IMG".equals(img.getTagName())) { final ImageElement iconImageImgElem = ImageElement.as(img); iconImageImgElem.removeAttribute("width"); iconImageImgElem.removeAttribute("height"); } imgStyle.clearWidth(); imgStyle.clearHeight(); imgStyle.clearProperty("MozBackgroundSize"); imgStyle.clearProperty("OBackgroundSize"); imgStyle.clearProperty("WebkitBackgroundSize"); imgStyle.clearProperty("backgroundSize"); img.removeClassName(_CSS.maskedButtonIconClass()); } setIconAlign(iconAlign); if (iconColor != null) { setIconColor(iconColor); } imgStyle.clearVisibility(); if (fireContentChangedEvent) _fireContentChangedEvent(); }
From source file:com.smartgwt.mobile.client.widgets.layout.NavigationBar.java
License:Open Source License
@SGWTInternal public void _unfixPosition() { assert Canvas._getFixNavigationBarPositionDuringKeyboardFocus(); isPositionFixed = false;/*from w ww.j a v a2 s . c o m*/ if (mockScrollTimer != null) { mockScrollTimer.cancel(); mockScrollTimer = null; } if (unfixPositionTimer != null) { unfixPositionTimer.cancel(); unfixPositionTimer = null; } final Element elem = getElement(); final Style elemStyle = elem.getStyle(); elemStyle.clearPosition(); elemStyle.clearProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName()); elemStyle.clearProperty(DOMConstants.INSTANCE.getTransformPropertyName()); }