List of usage examples for com.google.gwt.dom.client Style setProperty
public void setProperty(String name, String value)
From source file:com.smartgwt.mobile.client.internal.util.AnimationUtil.java
License:Open Source License
/** * Flip-transition between the old and new widget. * * @param oldPane the old widget// w ww.j av a2 s .co m * @param newPane the new widget * @param container the container panel */ public static void flipTransition(final Canvas oldPane, Canvas newPane, final Layout container) { Style oldStyle = oldPane.getElement().getStyle(); Style newStyle = newPane.getElement().getStyle(); oldStyle.setPosition(Style.Position.ABSOLUTE); newStyle.setPosition(Style.Position.ABSOLUTE); // flip the new element (instantly) newStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none"); newStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "rotateY(-180deg)"); // set both to invisible when flipped oldStyle.setProperty(DOMConstants.INSTANCE.getBackfaceVisibilityPropertyName(), "hidden"); newStyle.setProperty(DOMConstants.INSTANCE.getBackfaceVisibilityPropertyName(), "hidden"); // will be initially invisible container.addMember(newPane); // set both to animate oldStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + " 0.3s ease-in-out"); newStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + " 0.3s ease-in-out"); // rotate old to 180, making it invisible since the back face is showing oldStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "rotateY(180deg)"); // flip the new widget back to 0 newStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "rotateY(0deg)"); new Timer() { public void run() { container.removeMember(oldPane); } }.schedule(350); }
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//from w ww . j av a 2s . co 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//from www . j a v a 2s. c o 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"); }// ww w.jav a2 s . c o 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 _fixPosition() { assert Canvas._getFixNavigationBarPositionDuringKeyboardFocus(); if (unfixPositionTimer != null) { unfixPositionTimer.cancel();/*from w w w . ja va2s.c o m*/ unfixPositionTimer = null; } if (!isPositionFixed) { final SuperElement elem = getElement().<SuperElement>cast(); final Style elemStyle = elem.getStyle(); isPositionFixed = true; elemStyle.setPosition(Style.Position.FIXED); elemStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + " 200ms"); //elemStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "none"); } // In a UIWebView, the 'scroll' event is not fired on the window when the Previous/Next // buttons are used to move from <input> to <input>. It is when the app is run in // Mobile Safari, however. if (Canvas.isUIWebView()) { if (mockScrollTimer != null) mockScrollTimer.cancel(); mockScrollTimer = new Timer() { @Override public void run() { assert this == mockScrollTimer; mockScrollTimer = null; _updateFixedPosition(); } }; mockScrollTimer.schedule(1); } }
From source file:com.smartgwt.mobile.client.widgets.Progressbar.java
License:Open Source License
/** * Number from 0 to 100, inclusive, for the percentage to be displayed graphically in this progressbar. * Sets {@link #getPercentDone() percentDone} to <code>newPercentDone</code>. * * @param newPercentDone percent to show as done (0-100). Default value is 0 * @param duration in seconds for bar to reach this percent done *///ww w.ja v a2 s. co m public void setPercentDone(final int newPercentDone, int duration) { if (percentDone == newPercentDone) return; if (0 <= newPercentDone && newPercentDone <= 100) { percentDone = newPercentDone; final Style barStyle = bar.getStyle(); if (duration == 0 || !isAttached() || !isVisible()) { barStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "none"); barStyle.setWidth(newPercentDone, Style.Unit.PCT); PercentChangedEvent.fire(this, percentDone); } else { barStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "width"); barStyle.setProperty(DOMConstants.INSTANCE.getTransitionDurationPropertyName(), duration + "s"); new Timer() { @Override public void run() { barStyle.setWidth(newPercentDone, Style.Unit.PCT); } }.schedule(1); } } else { throw new RuntimeException(newPercentDone + " is out of bounds"); } }
From source file:com.square.composant.ged.square.client.composant.tagcloud.SelecteurTagCloud.java
License:Open Source License
/** * Remplissage du nuage de tags.//from w w w . ja v a2 s .c o m * @param typeDocParent le typeDoc parent pour le remplissage. */ private void remplirNuageTags(final TypeDocumentModel typeDocParent) { tagCloud.clear(); listeTagsVisibles.clear(); int frequenceMin = FREQUENCE_MIN; int frequenceMax = 0; // On parcours la liste une premire fois pour dterminer la frquence min & max for (TypeDocumentModel typeDoc : typeDocParent.getListeTypesDocuments()) { if (frequenceMin > typeDoc.getNombreDocs() + 1) { frequenceMin = typeDoc.getNombreDocs() + 1; } if (frequenceMax < typeDoc.getNombreDocs() + 1) { frequenceMax = typeDoc.getNombreDocs() + 1; } } for (final TypeDocumentModel typeDoc : typeDocParent.getListeTypesDocuments()) { final String text = typeDoc.getDescription() != null && !"".equals(typeDoc.getDescription().trim()) ? typeDoc.getDescription() : typeDoc.getNom(); // Le tag doit tre inscable final Anchor tagLink = new Anchor(text.replaceAll(" ", " ") + " ", true); tagLink.setStylePrimaryName("cloudTag"); final Style linkStyle = tagLink.getElement().getStyle(); final double weight = (Math.log(typeDoc.getNombreDocs() + 1) - Math.log(frequenceMin)) / (Math.log(frequenceMax) - Math.log(frequenceMin)); final int fontSize = TAILLE_POLICE_MIN + (int) Math.round((TAILLE_POLICE_MAX - TAILLE_POLICE_MIN) * weight); linkStyle.setProperty("fontSize", Integer.toString(fontSize) + "pt"); tagLink.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { selectionnerElement(typeDoc, typeDocParent); } }); tagCloud.add(tagLink); listeTagsVisibles.add(tagLink); } }
From source file:com.tractionsoftware.gwt.user.client.util.Geometry.java
License:Apache License
public static final void setInvisibleToMeasure(Element e) { Style s = e.getStyle(); s.setProperty("visibility", "hidden"); s.setProperty("display", "block"); }
From source file:com.tractionsoftware.gwt.user.client.util.Geometry.java
License:Apache License
public static final void unsetInvisibleToMeasure(Element e) { Style s = e.getStyle(); s.setProperty("display", "none"); s.setProperty("visibility", ""); }
From source file:com.vaadin.client.AnimationUtil.java
License:Apache License
/** * For internal use only. May be removed or replaced in the future. * /* ww w. j a va 2 s .c o m*/ * Set the animation-duration CSS property. * * @param elem * the element whose animation-duration to set * @param duration * the duration as a valid CSS value */ public static void setAnimationDuration(Element elem, String duration) { Style style = elem.getStyle(); style.setProperty(ANIMATION_PROPERTY_NAME + "Duration", duration); }