gwt.material.design.client.ui.MaterialIcon Java Examples

The following examples show how to use gwt.material.design.client.ui.MaterialIcon. 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: AlertTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testStructure() {
    Alert alert = getWidget();

    final String TEXT = "text";
    final IconType ICON = IconType.AC_UNIT;
    // Check Structure
    assertEquals(alert.getWidgetCount(), 2);
    assertTrue(alert.getWidget(0) instanceof MaterialIcon);
    assertTrue(alert.getWidget(1) instanceof MaterialLabel);
    // Check setText()
    alert.setText(TEXT);
    assertEquals(alert.getText(), TEXT);
    // Check setIconType()
    alert.setIconType(ICON);
    assertEquals(alert.getIcon().getIconType(), ICON);
}
 
Example #2
Source File: IconsView.java    From gwt-material-demo with Apache License 2.0 6 votes vote down vote up
protected void getAllIcons() {
    for (IconType i : IconType.values()) {
        MaterialColumn column = new MaterialColumn(4, 3, 2);
        column.setTextAlign(TextAlign.CENTER);
        column.setPadding(40);
        MaterialIcon icon = new MaterialIcon();
        icon.setIconSize(IconSize.MEDIUM);
        icon.setIconType(i);

        MaterialLabel label = new MaterialLabel();
        label.setFontSize("0.8em");
        label.setText(i.name().toUpperCase());

        column.add(icon);
        column.add(label);
        iconsRow.add(column);
    }
}
 
Example #3
Source File: LoadingStateTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testStructure() {
    LoadingStatePanel statePanel = getWidget();

    // By Default Loading State Panel must be invisible by default
    assertFalse(statePanel.isVisible());
    assertTrue(statePanel.getElement().hasClassName(IncubatorCssName.LOADING_STATE));
    // Check widget structure
    assertTrue(statePanel.getWidget(0) instanceof MaterialIcon);
    MaterialIcon icon = (MaterialIcon) statePanel.getWidget(0);
    statePanel.setIcon(IconType.POLYMER);
    assertEquals(statePanel.getIcon(), icon);

    final String TITLE = "title";
    final String DESCRIPTION = "description";
    assertTrue(statePanel.getWidget(1) instanceof MaterialLabel);
    MaterialLabel title = (MaterialLabel) statePanel.getWidget(1);
    statePanel.setTitle(TITLE);
    assertTrue(title.getElement().hasClassName(CssName.TITLE));
    assertEquals(title.getText(), TITLE);

    assertTrue(statePanel.getWidget(2) instanceof MaterialLabel);
    MaterialLabel description = (MaterialLabel) statePanel.getWidget(2);
    statePanel.setDescription(DESCRIPTION);
    assertTrue(description.getElement().hasClassName(AddinsCssName.DESCRIPTION));
    assertEquals(description.getText(), DESCRIPTION);
}
 
Example #4
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testRestriction() {
    // UiBinder
    // given
    MaterialPanel panel = getWidget(false);
    MaterialIcon iconIgnore = new MaterialIcon();
    MaterialLabel labelIgnore = new MaterialLabel();
    panel.add(iconIgnore);
    panel.add(labelIgnore);

    // when / then
    checkRestriction(panel, iconIgnore.getElement(), labelIgnore.getElement());

    // Standard
    // given
    attachWidget();

    // when / then
    checkRestriction(panel, iconIgnore.getElement(), labelIgnore.getElement());
}
 
Example #5
Source File: MaterialRatingTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testStructure() {
    // UiBinder
    // given
    MaterialRating rating = getWidget();

    // when / then
    final int MAX_RATING = rating.getMaxRating();
    assertEquals(5, MAX_RATING);
    IconType selectedIcon = rating.getSelectedRatingIcon();
    IconType unselectedIcon = rating.getUnselectedRatingIcon();
    assertEquals(IconType.STAR, selectedIcon);
    assertEquals(IconType.STAR_BORDER, unselectedIcon);
    assertEquals(rating.getWidgetCount(), MAX_RATING);
    for (Widget w : rating) {
        assertTrue(w instanceof MaterialIcon);
        MaterialIcon icon = (MaterialIcon) w;
        assertEquals(IconType.STAR_BORDER, icon.getIconType());
    }
}
 
Example #6
Source File: MaterialRatingTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void testRatingUpdate(Integer value, int maxRating, MaterialRating rating) {
    rating.setMaxRating(maxRating);
    rating.setValue(value);
    assertEquals(maxRating, rating.getMaxRating());
    assertEquals(value, rating.getValue());
    for (Widget w : rating) {
        assertTrue(w instanceof MaterialIcon);
        MaterialIcon icon = (MaterialIcon) w;
        if (rating.getWidgetIndex(w) < value) {
            assertEquals(IconType.FAVORITE, icon.getIconType());
            assertTrue(icon.getElement().hasClassName(AddinsCssName.MATERIAL_RATING_SELECTED));
        } else {
            assertEquals(IconType.FAVORITE_BORDER, icon.getIconType());
            assertTrue(icon.getElement().hasClassName(AddinsCssName.MATERIAL_RATING_UNSELECTED));
        }
    }
    checkValueChangeEvent(rating, 5, 2);
}
 
Example #7
Source File: MaterialTreeTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
public void testChildren() {
    // given
    MaterialTree tree = getWidget();

    // when / then
    for (int i = 0; i < NUMBER_OF_ITEM; i++) {
        MaterialTreeItem item = (MaterialTreeItem) tree.getWidget(i);
        MaterialWidget divHeader = (MaterialWidget) item.getWidget(0);
        // Check Url
        assertEquals(URL, item.getUrl());
        assertTrue(divHeader.getWidget(0) instanceof MaterialImage);
        MaterialImage image = (MaterialImage) divHeader.getWidget(0);
        assertEquals(URL, image.getUrl());
        assertTrue(image.getElement().hasAttribute("src"));

        // Check Icon
        assertTrue(divHeader.getWidget(1) instanceof MaterialIcon);
        MaterialIcon icon = (MaterialIcon) divHeader.getWidget(1);
        assertEquals(ICON, icon.getIconType());

        // Check Text
        assertEquals(TEXT, item.getText());
        assertTrue(divHeader.getWidget(2) instanceof Span);
        Span span = (Span) divHeader.getWidget(2);
        assertEquals(TEXT, span.getText());

        // Add more nested child
        for (int k = 1; k <= 3; k++) {
            MaterialTreeItem child = new MaterialTreeItem("item" + k);
            item.add(child);
        }
    }
    assertEquals(NUMBER_OF_ITEM, tree.getChildren().size());
}
 
Example #8
Source File: MaterialStep.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void applyIconStatus(MaterialIcon icon, String description) {
    iconError.removeFromParent();
    iconSuccess.removeFromParent();
    divCircle.removeFromParent();
    header.insert(icon, 0);
    if (description != null) {
        divDescription.getElement().setInnerSafeHtml(SafeHtmlUtils.fromString(description));
    }
}
 
Example #9
Source File: MaterialIconMorph.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
protected void onLoad() {
    super.onLoad();

    if (getWidgetCount() >= 2) {
        source = (MaterialIcon) getWidget(0);
        source.addStyleName(AddinsCssName.ICONS + " " + AddinsCssName.SOURCE);
        target = (MaterialIcon) getWidget(1);
        target.addStyleName(AddinsCssName.ICONS + " " + AddinsCssName.TARGET);
    }
}
 
Example #10
Source File: MaterialCutoutTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
protected MaterialCutOut createWidget() {
    // given
    MaterialCutOut cutOut = new MaterialCutOut();
    target = new MaterialIcon(IconType.POLYMER);
    RootPanel.get().add(target);

    // when
    cutOut.setTarget(target);

    // then
    assertEquals(target.getElement(), cutOut.getTargetElement());
    return cutOut;
}
 
Example #11
Source File: MaterialRatingTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void checkEditable(MaterialRating rating) {
    // when / then
    rating.setEnabled(true);
    rating.setValue(5);
    rating.setMaxRating(10);
    rating.setEditable(false);
    assertFalse(rating.isEditable());
    // Get single icon to test whether mouse out / click handler will be fired (Expected : false)
    // And the value should not be changed (Expected : 5)
    assertTrue(rating.getWidget(3) instanceof MaterialIcon);
    MaterialIcon icon = (MaterialIcon) rating.getWidget(0);
    fireClickEvent(icon);
    assertEquals(5, Math.toIntExact(rating.getValue()));
}
 
Example #12
Source File: MaterialIconMorphTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
protected MaterialIconMorph createWidget() {
    MaterialIconMorph iconMorph = new MaterialIconMorph();
    MaterialIcon icon1 = new MaterialIcon();
    icon1.setIconType(IconType.POLYMER);
    MaterialIcon icon2 = new MaterialIcon();
    icon2.setIconType(IconType.AC_UNIT);
    iconMorph.add(icon1);
    iconMorph.add(icon2);
    return iconMorph;
}
 
Example #13
Source File: MaterialEmptyStateTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testStructure() {
    // UiBinder
    // given
    MaterialEmptyState emptyState = getWidget(true);

    // when / then
    final String TITLE = "title";
    final String DESCRIPTION = "description";
    final IconType ICON = IconType.POLL;

    // when
    emptyState.setTitle(TITLE);
    emptyState.setDescription(DESCRIPTION);
    emptyState.setIconType(ICON);

    // then
    assertTrue(emptyState.getElement().hasClassName(AddinsCssName.EMPTY_STATE));
    assertTrue(emptyState.getElement().hasClassName(CssName.VALIGN_WRAPPER));
    assertEquals(1, emptyState.getWidgetCount());
    assertEquals(emptyState.getContainer(), emptyState.getWidget(0));

    // given
    Div container = emptyState.getContainer();

    // when / then
    assertEquals(1, container.getWidgetCount());
    assertTrue(container.getElement().hasClassName(CssName.VALIGN));
    assertTrue(container.getElement().hasClassName(CssName.CENTER));
    assertTrue(container.getWidget(0) instanceof MaterialTitle);
    MaterialTitle title = (MaterialTitle) container.getWidget(0);
    assertEquals(TITLE, title.getHeader().getText());
    assertEquals(DESCRIPTION, title.getParagraph().getText());
    assertTrue(title.getWidget(0) instanceof MaterialIcon);
    MaterialIcon icon = (MaterialIcon) title.getWidget(0);
    assertEquals(ICON, icon.getIconType());
}
 
Example #14
Source File: MaterialTreeTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testStructure() {
    // given
    MaterialTree tree = getWidget();

    // when / then
    assertNotNull(tree.getWidget(0));
    assertTrue(tree.getWidget(0) instanceof MaterialTreeItem);
    MaterialTreeItem item = (MaterialTreeItem) tree.getWidget(0);
    assertTrue(item.getDivHeader().getElement().hasClassName(AddinsCssName.TREE_HEADER));
    MaterialWidget divHeader = item.getDivHeader();
    assertTrue(divHeader.getWidget(0) instanceof MaterialImage);
    assertTrue(divHeader.getWidget(1) instanceof MaterialIcon);
    assertTrue(divHeader.getWidget(2) instanceof Span);
}
 
Example #15
Source File: MaterialStep.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIconSuccess() {
    return iconSuccess;
}
 
Example #16
Source File: MaterialStep.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIconError() {
    return iconError;
}
 
Example #17
Source File: MaterialWindow.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIconMaximize() {
    return iconMaximize;
}
 
Example #18
Source File: MaterialEmptyState.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
@Override
public MaterialIcon getIcon() {
    return icon;
}
 
Example #19
Source File: MaterialWindow.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIconClose() {
    return iconClose;
}
 
Example #20
Source File: MaterialOverlay.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getMinimizeIcon() {
    return minimizeIcon;
}
 
Example #21
Source File: MaterialIconMorph.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getTarget() {
    return target;
}
 
Example #22
Source File: MaterialIconMorph.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getSource() {
    return source;
}
 
Example #23
Source File: MaterialNote.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
@Override
public MaterialIcon getIcon() {
    return icon;
}
 
Example #24
Source File: MaterialTimePicker.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
@Override
public MaterialIcon getIcon() {
    return icon;
}
 
Example #25
Source File: MaterialUploadLabel.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIcon() {
    return icon;
}
 
Example #26
Source File: MaterialUploadHeader.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIconColaps() {
    return iconColaps;
}
 
Example #27
Source File: MaterialUploadHeader.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIconClose() {
    return iconClose;
}
 
Example #28
Source File: DateRangePicker.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
@Override
public MaterialIcon getIcon() {
    return icon;
}
 
Example #29
Source File: LoadingStatePanel.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
public MaterialIcon getIcon() {
    return icon;
}
 
Example #30
Source File: AbstractIconButtonTest.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void testIcon() {
    // UiBinder
    // given
    T widget = getWidget(false);

    // when / then
    MaterialIcon icon = widget.getIcon();
    assertNotNull(icon);

    icon.setIconType(IconType.POLYMER);
    assertEquals(IconType.POLYMER, icon.getIconType());

    icon.setIconSize(IconSize.LARGE);
    assertEquals(IconSize.LARGE, icon.getIconSize());
    icon.setIconSize(IconSize.MEDIUM);
    assertEquals(IconSize.MEDIUM, icon.getIconSize());
    icon.setIconSize(IconSize.SMALL);
    assertEquals(IconSize.SMALL, icon.getIconSize());
    icon.setIconSize(IconSize.TINY);
    assertEquals(IconSize.TINY, icon.getIconSize());

    icon.setIconPosition(IconPosition.RIGHT);
    icon.setIconPosition(IconPosition.LEFT);
    icon.setIconColor(Color.AMBER);

    icon.setIconPrefix(true);
    assertTrue(icon.isIconPrefix());
    icon.setIconPrefix(false);
    assertFalse(icon.isIconPrefix());

    icon.setIconFontSize(2, Style.Unit.PX);

    // Standard
    // given
    attachWidget();

    // when / then
    icon.setIconType(IconType.POLYMER);
    assertEquals(IconType.POLYMER.getCssName(), icon.getElement().getInnerHTML());

    icon.setIconSize(IconSize.LARGE);
    assertTrue(icon.getElement().hasClassName(IconSize.LARGE.getCssName()));
    icon.setIconSize(IconSize.MEDIUM);
    assertTrue(icon.getElement().hasClassName(IconSize.MEDIUM.getCssName()));
    icon.setIconSize(IconSize.SMALL);
    assertTrue(icon.getElement().hasClassName(IconSize.SMALL.getCssName()));
    icon.setIconSize(IconSize.TINY);
    assertTrue(icon.getElement().hasClassName(IconSize.TINY.getCssName()));

    icon.setIconPosition(IconPosition.RIGHT);
    assertTrue(icon.getElement().hasClassName(IconPosition.RIGHT.getCssName()));
    icon.setIconPosition(IconPosition.LEFT);
    assertTrue(icon.getElement().hasClassName(IconPosition.LEFT.getCssName()));
    icon.setIconColor(Color.AMBER);
    assertTrue(icon.getElement().hasClassName(Color.AMBER.getCssName() + "-text"));

    icon.setIconPrefix(true);
    assertTrue(icon.isIconPrefix());
    assertTrue(icon.getElement().hasClassName("prefix"));
    icon.setIconPrefix(false);
    assertFalse(icon.getElement().hasClassName("prefix"));

    icon.setIconFontSize(2, Style.Unit.PX);
    assertEquals("2px", icon.getElement().getStyle().getFontSize());
}