com.google.gwt.user.client.ui.UIObject Java Examples

The following examples show how to use com.google.gwt.user.client.ui.UIObject. 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: Animate.java    From gwtbootstrap3-extras with Apache License 2.0 7 votes vote down vote up
/**
 * Animate any element with specific animation. Animation is done by CSS and runs multiple times.
 *
 * Animation is started when element is appended to the DOM or new (not same) animation is added
 * to already displayed element. Animation runs on hidden elements too and is not paused/stopped
 * when element is set as hidden.
 *
 * @param widget Widget to apply animation to.
 * @param animation Custom CSS class name used as animation.
 * @param count Number of animation repeats. 0 disables animation, any negative value set repeats to infinite.
 * @param duration Animation duration in ms. 0 disables animation, any negative value keeps default of original animation.
 * @param delay Delay before starting the animation loop in ms. Value <= 0 means no delay.
 * @param <T> Any object extending UIObject class (typically Widget).
 * @return Animation's CSS class name, which can be removed to stop animation.
 */
public static <T extends UIObject> String animate(final T widget, final String animation, final int count, final int duration, final int delay) {

    if (widget != null && animation != null) {
        // on valid input
        if (widget.getStyleName().contains(animation)) {
            // animation is present, remove it and run again.
            stopAnimation(widget, animation);
            Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
                @Override
                public boolean execute() {
                    styleElement(widget.getElement(), animation, count, duration, delay);
                    return false;
                }
            }, 200);
            return animation + " " + getStyleNameFromAnimation(animation,count,duration,delay);
        } else {
            // animation was not present, run immediately
            return styleElement(widget.getElement(), animation, count, duration, delay);
        }
    } else {
        return null;
    }

}
 
Example #2
Source File: Animate.java    From gwtbootstrap3-extras with Apache License 2.0 6 votes vote down vote up
/**
 * Animate any element with specific animation. Animation is done by CSS and runs multiple times.
 *
 * Animation is started when element is appended to the DOM or new (not same) animation is added
 * to already displayed element. Animation runs on hidden elements too and is not paused/stopped
 * when element is set as hidden.
 *
 * @param widget Widget to apply animation to.
 * @param animation Type of animation to apply.
 * @param count Number of animation repeats. 0 disables animation, any negative value set repeats to infinite.
 * @param duration Animation duration in ms. 0 disables animation, any negative value keeps default of original animation.
 * @param delay Delay before starting the animation loop in ms. Value <= 0 means no delay.
 * @param <T> Any object extending UIObject class (typically Widget).
 * @return Animation's CSS class name, which can be removed to stop animation.
 */
public static <T extends UIObject> String animate(final T widget, final Animation animation, final int count, final int duration, final int delay) {

    if (widget != null && animation != null) {
        // on valid input
        if (widget.getStyleName().contains(animation.getCssName())) {
            // animation is present, remove it and run again.
            stopAnimation(widget, animation.getCssName() + " " + getStyleNameFromAnimation(animation.getCssName(),count,duration,delay));
            Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
                @Override
                public boolean execute() {
                    styleElement(widget.getElement(), animation.getCssName(), count, duration, delay);
                    return false;
                }
            }, 200);
            return animation.getCssName() + " " + getStyleNameFromAnimation(animation.getCssName(),count,duration,delay);
        } else {
            // animation was not present, run immediately
            return styleElement(widget.getElement(), animation.getCssName(), count, duration, delay);
        }
    } else {
        return null;
    }

}
 
Example #3
Source File: VDDHorizontalLayout.java    From cuba with Apache License 2.0 6 votes vote down vote up
/**
 * Removes any applies drag and drop style applied by emphasis()
 */
protected void deEmphasis() {
    if (currentlyEmphasised != null) {
        // Universal over style
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER,
                false);
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER_SPACED,
                false);

        // Horizontal styles
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER + "-"
                + HorizontalDropLocation.LEFT.toString().toLowerCase(),
                false);
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER + "-"
                + HorizontalDropLocation.CENTER.toString().toLowerCase(),
                false);
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER + "-"
                + HorizontalDropLocation.RIGHT.toString().toLowerCase(),
                false);

        currentlyEmphasised = null;
    }
}
 
Example #4
Source File: VDDVerticalLayout.java    From cuba with Apache License 2.0 6 votes vote down vote up
/**
 * Removes any applies drag and drop style applied by emphasis()
 */
protected void deEmphasis() {
    if (currentlyEmphasised != null) {
        // Universal over style
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER,
                false);
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER_SPACED,
                false);

        // Vertical styles
        UIObject.setStyleName(currentlyEmphasised.getElement(),
                OVER + "-"
                        + VerticalDropLocation.TOP.toString().toLowerCase(),
                false);
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER + "-"
                + VerticalDropLocation.MIDDLE.toString().toLowerCase(),
                false);
        UIObject.setStyleName(currentlyEmphasised.getElement(), OVER + "-"
                + VerticalDropLocation.BOTTOM.toString().toLowerCase(),
                false);

        currentlyEmphasised = null;
    }
}
 
Example #5
Source File: FilterBox.java    From unitime with Apache License 2.0 6 votes vote down vote up
private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) {
	int textBoxOffsetWidth = relativeObject.getOffsetWidth();
	int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;
	int left = relativeObject.getAbsoluteLeft();
	if (offsetWidthDiff > 0) {
		int windowRight = Window.getClientWidth() + Window.getScrollLeft();
		int windowLeft = Window.getScrollLeft();
		int distanceToWindowRight = windowRight - left;
		int distanceFromWindowLeft = left - windowLeft;
		if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) {
			left -= offsetWidthDiff;
		}
	}
	int top = relativeObject.getAbsoluteTop();
	int windowTop = Window.getScrollTop();
	int windowBottom = Window.getScrollTop() + Window.getClientHeight();
	int distanceFromWindowTop = top - windowTop;
	int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight());
	if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) {
		top -= offsetHeight;
	} else {
		top += relativeObject.getOffsetHeight();
	}
	setPopupPosition(left, top);
}
 
Example #6
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
protected <H extends UIObject & HasEnabled> void checkEnabled(HasEnabled widget, H target, boolean checkElement) {
    final Element element = target.getElement();
    if(checkElement) {
        assertFalse(element.hasClassName(CssName.DISABLED));
        assertFalse(element.hasAttribute(CssName.DISABLED));
    }
    widget.setEnabled(true);
    if(checkElement) {
        assertFalse(element.hasClassName(CssName.DISABLED));
        assertFalse(element.hasAttribute(CssName.DISABLED));
    }
    assertEquals(widget.isEnabled(), true);
    widget.setEnabled(false);
    if(checkElement) {
        assertTrue(element.hasClassName(CssName.DISABLED));
        assertTrue(element.hasAttribute(CssName.DISABLED));
    }
    assertEquals(target.isEnabled(), false);
}
 
Example #7
Source File: MaterialWidgetTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
protected <W extends UIObject & HasReadOnly> void checkReadOnly(W widget, UIObject target, boolean checkElement) {
    // given
    Element widgetElement = widget.getElement();
    Element targetElement = target.getElement();

    // when / then
    widget.setReadOnly(true);
    if (checkElement) {
        assertTrue(targetElement.hasAttribute("disabled"));
        assertTrue(widgetElement.hasClassName(CssName.READ_ONLY));
    }
    assertTrue(widget.isReadOnly());
    widget.setReadOnly(false);
    if (checkElement) {
        assertFalse(targetElement.hasAttribute("disabled"));
        assertFalse(widgetElement.hasClassName(CssName.READ_ONLY));
    }
    assertFalse(widget.isReadOnly());

    widget.setToggleReadOnly(true);
    if (checkElement) {
        assertTrue(widgetElement.hasClassName(CssName.READ_ONLY_TOGGLE));
    }
    assertTrue(widget.isToggleReadOnly());
    widget.setToggleReadOnly(false);
    if (checkElement) {
        assertFalse(widgetElement.hasClassName(CssName.READ_ONLY_TOGGLE));
    }
    assertFalse(widget.isToggleReadOnly());
}
 
Example #8
Source File: VDDVerticalLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Empasises the drop location of the component when hovering over a
 * ĆhildComponentContainer. Passing null as the container removes any
 * previous emphasis.
 * 
 * @param container
 *            The container which we are hovering over
 * @param event
 *            The drag event
 */
protected void emphasis(Widget container, VDragEvent event) {

    // Remove emphasis from previous hovers
    deEmphasis();

    // validate container
    if (container == null
            || !getElement().isOrHasChild(container.getElement())) {
        return;
    }

    currentlyEmphasised = container;

    VerticalDropLocation location = null;

    // Add drop location specific style
    if (currentlyEmphasised != this) {
        location = getVerticalDropLocation(currentlyEmphasised, event);

    } else {
        location = VerticalDropLocation.MIDDLE;
    }

    UIObject.setStyleName(currentlyEmphasised.getElement(), OVER, true);
    UIObject.setStyleName(currentlyEmphasised.getElement(),
            OVER + "-" + location.toString().toLowerCase(), true);
}
 
Example #9
Source File: VDDHorizontalLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Empasises the drop location of the component when hovering over a
 * ĆhildComponentContainer. Passing null as the container removes any
 * previous emphasis.
 * 
 * @param container
 *            The container which we are hovering over
 * @param event
 *            The drag event
 */
protected void emphasis(Widget container, VDragEvent event) {

    // Remove emphasis from previous hovers
    deEmphasis();

    // validate container
    if (container == null
            || !getElement().isOrHasChild(container.getElement())) {
        return;
    }

    currentlyEmphasised = container;

    HorizontalDropLocation location = null;

    // Add drop location specific style
    if (currentlyEmphasised != this) {
        location = getHorizontalDropLocation(container, event);

    } else {
        location = HorizontalDropLocation.CENTER;
    }

    UIObject.setStyleName(currentlyEmphasised.getElement(), OVER, true);
    UIObject.setStyleName(currentlyEmphasised.getElement(),
            OVER + "-" + location.toString().toLowerCase(), true);
}
 
Example #10
Source File: StyleHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Convenience method for first removing all enum style constants and then adding the single one.
 *
 * @see #removeEnumStyleNames(UIObject, Class)
 * @see #addEnumStyleName(UIObject, Style.HasCssName)
 */
public static <E extends Style.HasCssName, F extends Enum<? extends Style.HasCssName>> void addUniqueEnumStyleName(final UIObject uiObject,
                                                                                                                   final Class<F> enumClass,
                                                                                                                   final E style) {
    removeEnumStyleNames(uiObject, enumClass);
    addEnumStyleName(uiObject, style);
}
 
Example #11
Source File: StyleHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Toggles a style name on a ui object
 *
 * @param uiObject    Object to toggle style on
 * @param toggleStyle whether or not to toggle the style name on the object
 * @param styleName   Style name
 */
public static void toggleStyleName(final UIObject uiObject,
                                   final boolean toggleStyle,
                                   final String styleName) {
    if (toggleStyle) {
        uiObject.addStyleName(styleName);
    } else {
        uiObject.removeStyleName(styleName);
    }
}
 
Example #12
Source File: SuggestionsContainer.java    From cuba with Apache License 2.0 5 votes vote down vote up
public void clearItems() {
    selectItem(null);

    container.removeAllChildren();

    for (UIObject item : items) {
        item.getElement().setPropertyInt("colSpan", 1);
        ((SuggestionItem) item).setSuggestionsContainer(null);
    }

    items.clear();
}
 
Example #13
Source File: StyleHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Removes enum value style name from UIObject unless style is {@code null}.
 *
 * @param uiObject Object to remove style from
 * @param style    Style name
 */
public static <E extends Style.HasCssName> void removeEnumStyleName(final UIObject uiObject,
                                                                    final E style) {

    if (style != null && style.getCssName() != null && !style.getCssName().isEmpty()) {
        uiObject.removeStyleName(style.getCssName());
    }
}
 
Example #14
Source File: StyleHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Adds enum value style name to UIObject unless style is {@code null}.
 *
 * @param uiObject Object to add style to
 * @param style    Style name
 */
public static <E extends Style.HasCssName> void addEnumStyleName(final UIObject uiObject,
                                                                 final E style) {

    if (style != null && style.getCssName() != null && !style.getCssName().isEmpty()) {
        uiObject.addStyleName(style.getCssName());
    }
}
 
Example #15
Source File: StyleHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Removes all CSS style names specified by an enum that implements {@link Style.HasCssName} from an UIObject.
 *
 * @param uiObject  Object to remove CSS class names from
 * @param enumClass Enum representing CSS class names
 * @param <E>       Enum type implementing {@link Style.HasCssName}
 */
public static <E extends Enum<? extends Style.HasCssName>> void removeEnumStyleNames(final UIObject uiObject,
                                                                                     final Class<E> enumClass) {

    for (final Enum<? extends Style.HasCssName> constant : enumClass.getEnumConstants()) {
        final String cssClass = ((Style.HasCssName) constant).getCssName();

        if (cssClass != null && !cssClass.isEmpty()) {
            uiObject.removeStyleName(cssClass);
        }
    }
}
 
Example #16
Source File: EnabledMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
private void applyEnabled(boolean enabled, UIObject obj) {
    if (enabled) {
        obj.removeStyleName(CssName.DISABLED);
        obj.getElement().removeAttribute(DISABLED);
    } else {
        obj.addStyleName(CssName.DISABLED);
        obj.getElement().setAttribute(DISABLED, "");
    }

    updateWaves(enabled, obj);
}
 
Example #17
Source File: EnabledMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void updateWaves(boolean enabled, UIObject obj) {
    if (obj instanceof MaterialWidget) {
        MaterialWidget widget = (MaterialWidget) obj;
        if (enabled) {
            if (widget.getWaves() != null) {
                widget.getElement().addClassName(CssName.WAVES_EFFECT);
            }
        } else {
            widget.getElement().removeClassName(CssName.WAVES_EFFECT);
        }
    }
}
 
Example #18
Source File: CubaRichTextToolbarWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
public void setLocaleMap(Map<String,String> localeMap) {
    Map<String, UIObject> locales = new HashMap<>();
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_BOLD_LABEL, bold);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_ITALIC_LABEL, italic);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_UNDERLINE_LABEL, underline);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_SUBSCRIPT_LABEL, subscript);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_SUPERSCRIPT_LABEL, superscript);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_JUSTIFYCENTER_LABEL, justifyCenter);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_JUSTIFYRIGHT_LABEL, justifyRight);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_JUSTIFYLEFT_LABEL, justifyLeft);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_STRIKETHROUGH_LABEL, strikethrough);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_INDENT_LABEL, indent);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_OUTDENT_LABEL, outdent);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_HR_LABEL, hr);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_OL_LABEL, ol);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_UL_LABEL, ul);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_INSERTIMAGE_LABEL, insertImage);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_CREATELINK_LABEL, createLink);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_REMOVELINK_LABEL, removeLink);
    locales.put(CubaRichTextAreaState.RICH_TEXT_AREA_REMOVEFORMAT_LABEL, removeFormat);

    for (Map.Entry<String, UIObject> entry : locales.entrySet()) {
        entry.getValue().setTitle(localeMap.get(entry.getKey()));
        entry.getValue().getElement().setAttribute("icon-id", entry.getKey());
    }

    setBackgroundColorLocaleMap(localeMap);
    setForegroundColorLocaleMap(localeMap);
    setSizeLocaleMap(localeMap);
    setFontLocaleMap(localeMap);
}
 
Example #19
Source File: AbstractButtonTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
protected <H extends UIObject & HasEnabled> void checkEnabled(HasEnabled widget, H target) {
    super.checkEnabled(widget, target);

    widget.setEnabled(false);
    assertTrue(target.getElement().hasAttribute("onclick"));
    assertEquals("return false", target.getElement().getAttribute("onclick"));

    widget.setEnabled(true);
    assertFalse(target.getElement().hasAttribute("onclick"));
}
 
Example #20
Source File: MaterialWidgetTestCase.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public static <H extends UIObject & HasColors> void checkColor(H hasColors) {
    final Element element = hasColors.getElement();
    hasColors.setTextColor(Color.WHITE);
    assertTrue(element.hasClassName(Color.WHITE.getCssName() + "-text"));
    hasColors.setBackgroundColor(Color.BLACK);
    assertTrue(element.hasClassName(Color.BLACK.getCssName()));
}
 
Example #21
Source File: MaterialSwipeablePanel.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
/**
 * Ignore any elements to be swipeable
 */
public void ignore(UIObject object, UIObject... objects) {
    object.addStyleName(AddinsCssName.IGNORED);

    if (objects != null) {
        for (UIObject obj : objects) {
            obj.addStyleName(AddinsCssName.IGNORED);
        }
    }
}
 
Example #22
Source File: MaterialSwipeablePanel.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
/**
 * Remove Ignore property to any ignored elements
 */
public void removeIgnore(UIObject object, UIObject... objects) {
    object.removeStyleName(AddinsCssName.IGNORED);

    if (objects != null) {
        for (UIObject obj : objects) {
            obj.removeStyleName(AddinsCssName.IGNORED);
        }
    }
}
 
Example #23
Source File: MaterialWindow.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
/**
 * Set the area for the drag and drop, can be an {@link Element}
 * or a {@link String} selector.
 */
public void setDndArea(Object dndArea) {
    if (dndArea instanceof UIObject) {
        dndArea = ((UIObject) dndArea).getElement();
    }
    if (dnd != null) {
        dnd.draggable(JsDragOptions.create(new Restriction(dndArea, true, 0, 0, 1.2, 1)));
    }
}
 
Example #24
Source File: WebTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void setStyleName(String styleName) {
	super.setStyleName(styleName);
	for (UIObject c: iContent) {
		c.setStyleName(styleName);
		c.getElement().getStyle().setBorderWidth(0, Unit.PX);
	}
}
 
Example #25
Source File: WebClient.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private void setupWavePanel() {
  // Hide the frame until waves start getting opened.
  UIObject.setVisible(waveFrame.getElement(), false);

  Document.get().getElementById("signout").setInnerText(messages.signout());

  // Handles opening waves.
  ClientEvents.get().addWaveSelectionEventHandler(new WaveSelectionEventHandler() {
    @Override
    public void onSelection(WaveRef waveRef) {
      openWave(waveRef, false, null);
    }
  });
}
 
Example #26
Source File: WebClient.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private void setupWavePanel() {
  // Hide the frame until waves start getting opened.
  UIObject.setVisible(waveFrame.getElement(), false);

  Document.get().getElementById("signout").setInnerText(messages.signout());

  // Handles opening waves.
  ClientEvents.get().addWaveSelectionEventHandler(new WaveSelectionEventHandler() {
    @Override
    public void onSelection(WaveRef waveRef) {
      openWave(waveRef, false, null);
    }
  });
}
 
Example #27
Source File: Geometry.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the size of a UIObject
 */
public static final void setSize(UIObject o, Rect size) {
    o.setPixelSize(size.w, size.h);

}
 
Example #28
Source File: FilterBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
public final void moveRelativeTo(final UIObject target) {
	position(target, getOffsetWidth(), getOffsetHeight());
}
 
Example #29
Source File: GwtMockitoTestRunner.java    From gwtmockito with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a collection of classes whose non-abstract methods should always be replaced with
 * no-ops. By default, this list includes {@link Composite}, {@link DOM} {@link UIObject},
 * {@link Widget}, {@link Image}, and most subclasses of {@link Panel}. It will also include any
 * classes specified via the {@link WithClassesToStub} annotation on the test class. This makes
 * it much safer to test code that uses or extends these types.
 * <p>
 * This list can be customized via {@link WithClassesToStub} or by defining a new test runner
 * extending {@link GwtMockitoTestRunner} and overriding this method. This allows users to
 * explicitly stub out particular classes that are causing problems in tests. If you override this
 * method, you will probably want to retain the classes that are stubbed here by doing something
 * like this:
 *
 * <pre>
 * &#064;Override
 * protected Collection&lt;Class&lt;?&gt;&gt; getClassesToStub() {
 *   Collection&lt;Class&lt;?&gt;&gt; classes = super.getClassesToStub();
 *   classes.add(MyBaseWidget.class);
 *   return classes;
 * }
 * </pre>
 *
 * @return a collection of classes whose methods should be stubbed with no-ops while running tests
 */
protected Collection<Class<?>> getClassesToStub() {
  Collection<Class<?>> classes = new LinkedList<Class<?>>();
  classes.add(Composite.class);
  classes.add(DOM.class);
  classes.add(UIObject.class);
  classes.add(Widget.class);

  classes.add(DataGrid.class);
  classes.add(HTMLTable.class);
  classes.add(Image.class);

  classes.add(AbsolutePanel.class);
  classes.add(CellList.class);
  classes.add(CellPanel.class);
  classes.add(CellTable.class);
  classes.add(ComplexPanel.class);
  classes.add(DeckLayoutPanel.class);
  classes.add(DeckPanel.class);
  classes.add(DecoratorPanel.class);
  classes.add(DockLayoutPanel.class);
  classes.add(DockPanel.class);
  classes.add(FlowPanel.class);
  classes.add(FocusPanel.class);
  classes.add(HorizontalPanel.class);
  classes.add(HTMLPanel.class);
  classes.add(LayoutPanel.class);
  classes.add(Panel.class);
  classes.add(PopupPanel.class);
  classes.add(RenderablePanel.class);
  classes.add(ResizeLayoutPanel.class);
  classes.add(SimpleLayoutPanel.class);
  classes.add(SimplePanel.class);
  classes.add(SplitLayoutPanel.class);
  classes.add(StackPanel.class);
  classes.add(VerticalPanel.class);
  classes.add(ValueListBox.class);

  WithClassesToStub annotation = unitTestClass.getAnnotation(WithClassesToStub.class);
  if (annotation != null) {
    classes.addAll(Arrays.asList(annotation.value()));
  }

  return classes;
}
 
Example #30
Source File: Animate.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
/**
 * Styles element with animation class. New class name is generated to customize count, duration and delay.
 * Style is removed on animation end (if not set to infinite).
 *
 * @param element Element to apply animation to.
 * @param animation Type of animation to apply.
 * @param count Number of animation repeats. 0 disables animation, any negative value set repeats to infinite.
 * @param duration Animation duration in ms. 0 disables animation, any negative value keeps default of original animation.
 * @param delay Delay before starting the animation loop in ms. Value <= 0 means no delay.
 * @param <T> Any object extending UIObject class (typically Widget).
 * @return Animation's CSS class name, which can be removed to stop animation.
 */
private static <T extends UIObject> String styleElement(Element element, String animation, int count, int duration, int delay) {

    if (!usedStyles.contains(animation + " " + getStyleNameFromAnimation(animation,count,duration,delay))) {

        String styleSheet = "." + getStyleNameFromAnimation(animation, count, duration, delay) + " {";

        // 1 is default, 0 disable animation, any negative -> infinite loop
        if (count >= 0) {

            styleSheet += "-webkit-animation-iteration-count: " + count + ";" +
                    "-moz-animation-iteration-count:" + count + ";" +
                    "-ms-animation-iteration-count:" + count + ";" +
                    "-o-animation-iteration-count:" + count + ";" +
                    "animation-iteration-count:" + count + ";";

        } else {

            styleSheet += "-webkit-animation-iteration-count: infinite;" +
                    "-moz-animation-iteration-count: infinite;" +
                    "-ms-animation-iteration-count: infinite;" +
                    "-o-animation-iteration-count: infinite;" +
                    "animation-iteration-count: infinite;";

        }

        // if not default (any negative -> use default)
        if (duration >= 0) {

            styleSheet += "-webkit-animation-duration: " + duration + "ms;" +
                    "-moz-animation-duration:" + duration + "ms;" +
                    "-ms-animation-duration:" + duration + "ms;" +
                    "-o-animation-duration:" + duration + "ms;" +
                    "animation-duration:" + duration + "ms;";

        }

        // if not default (any negative -> use default)
        if (delay >= 0) {

            styleSheet += "-webkit-animation-delay: " + delay + "ms;" +
                    "-moz-animation-delay:" + delay + "ms;" +
                    "-ms-animation-delay:" + delay + "ms;" +
                    "-o-animation-delay:" + delay + "ms;" +
                    "animation-delay:" + delay + "ms;";

        }

        styleSheet += "}";

        // inject new style
        StyleInjector.injectAtEnd(styleSheet, true);

        usedStyles.add(animation + " " + getStyleNameFromAnimation(animation, count, duration, delay));

    }

    // start animation
    element.addClassName(animation + " " + getStyleNameFromAnimation(animation,count,duration,delay));

    // remove animation on end so we could start it again
    // removeAnimationOnEnd(element, animation + " anim-"+count+"-"+duration+"-"+delay);

    return animation + " " + getStyleNameFromAnimation(animation,count,duration,delay);

}