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

The following examples show how to use gwt.material.design.client.ui.MaterialPanel. 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: QueryView.java    From lumongo with Apache License 2.0 6 votes vote down vote up
public QueryView() {
	splitPanel = new MaterialSplitPanel();
	splitPanel.setHeight(Window.getClientHeight() - 102 + "px");
	splitPanel.setBarPosition(25);
	leftPanel = new MaterialPanel();
	leftPanel.setBackgroundColor(Color.WHITE);
	leftPanel.setGrid("s6 l3");
	leftScrollPanel = new ScrollPanel();
	leftScrollPanel.setHeight(Window.getClientHeight() - 130 + "px");

	rightPanel = new MaterialPanel();
	rightPanel.setBackgroundColor(Color.GREY_LIGHTEN_2);
	rightPanel.setGrid("s6 l9");
	rightScrollPanel = new ScrollPanel();
	rightScrollPanel.setHeight(Window.getClientHeight() - 130 + "px");

	splitPanel.add(leftPanel);
	splitPanel.add(rightPanel);

	add(splitPanel);
}
 
Example #2
Source File: MaterialWidgetTest.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public void testChildren() {
    // given
    T widget = getWidget();

    // when / then
    if (widget.getChildren().size() == 0) {
        int childCount = 3;
        for (int i = 1; i <= childCount; i++) {
            MaterialPanel panel = new MaterialPanel();
            widget.add(panel);
        }
        assertTrue(widget.getChildren().size() != 0);
        assertEquals(3, widget.getChildren().size());
        widget.getChildren().remove(0);
        assertEquals(2, widget.getChildren().size());
        widget.clear();
        assertEquals(0, widget.getChildren().size());
    }
}
 
Example #3
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 #4
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void checkRestriction(MaterialPanel panel, Element... ignoredWidgets) {
    // when
    Restriction restriction = new Restriction();
    restriction.setBottom(20);
    restriction.setLeft(20);
    restriction.setRight(20);
    restriction.setTop(20);
    restriction.setEndOnly(true);
    restriction.setRestriction(Restriction.Restrict.PARENT);
    MaterialDnd dnd = MaterialDnd.draggable(panel, JsDragOptions.create(restriction));
    dnd.ignoreFrom(ignoredWidgets);
    JsDragOptions options = dnd.getDragOptions();

    // then
    assertEquals(panel, dnd.getTarget());
    assertEquals(Double.valueOf(20), options.restrict.elementRect.top);
    assertEquals(Double.valueOf(20), options.restrict.elementRect.left);
    assertEquals(Double.valueOf(20), options.restrict.elementRect.right);
    assertEquals(Double.valueOf(20), options.restrict.elementRect.bottom);
    assertEquals(Restriction.Restrict.PARENT, options.restrict.restriction);
    assertTrue(options.restrict.endOnly);
    assertEquals(2, dnd.getIgnoreFrom().length);
    for (Element element : dnd.getIgnoreFrom()) {
        assertTrue(element.hasClassName(AddinsCssName.INTERACT_IGNORED_CONTENT));
    }
}
 
Example #5
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void checkDropEvents(MaterialPanel panel) {
    MaterialDnd.draggable(panel);
    // Drop Activate Event
    final boolean[] isDropActivateFired = {false};
    panel.addDropActivateHandler(event -> isDropActivateFired[0] = true);
    panel.fireEvent(new DropActivateEvent() {
    });
    assertTrue(isDropActivateFired[0]);
    // Drop Deactivate Event
    final boolean[] isDropDeactivateFired = {false};
    panel.addDropDeactivateHandler(event -> isDropDeactivateFired[0] = true);
    panel.fireEvent(new DropDeactivateEvent() {
    });
    assertTrue(isDropDeactivateFired[0]);
    // Drop Event
    final boolean[] isDropFired = {false};
    panel.addDropHandler(event -> isDropFired[0] = true);
    panel.fireEvent(new DropEvent($(panel.getElement())) {
    });
    assertTrue(isDropFired[0]);
}
 
Example #6
Source File: MaterialWindowTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testDndArea() {
    // UiBinder
    // given
    MaterialWindow window = getWidget(false);
    MaterialPanel dndArea = new MaterialPanel();
    window.setDndArea(dndArea);

    attachWidget();

    window.open();

    assertTrue(window.getDnd().getDragOptions().restrict.restriction instanceof Element);
    Element element = (Element) window.getDnd().getDragOptions().restrict.restriction;
    assertEquals(dndArea.getElement().getInnerHTML(), element.getInnerHTML());
    assertEquals(dndArea.getElement(), element);
}
 
Example #7
Source File: MaterialSubheaderTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testContainer() {
    // UiBinder
    // given
    MaterialSubHeaderContainer container = getWidget(true);

    // when / then
    assertEquals(5, container.getWidgetCount());
    container.clear();
    assertEquals(0, container.getWidgetCount());

    MaterialPanel notSubHeader = new MaterialPanel();
    container.add(notSubHeader);

    assertEquals(notSubHeader, container.getWidget(0));
    assertFalse(notSubHeader.getElement().hasClassName(AddinsCssName.SUBHEADER));
}
 
Example #8
Source File: AnimationTest.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public void testAnimation() {
    MaterialPanel panel = new MaterialPanel();
    RootPanel.get().add(panel);
    MaterialAnimation animation = new MaterialAnimation();
    animation.delay(0);
    assertEquals(animation.getDelay(), 0);
    animation.infinite(true);
    assertTrue(animation.isInfinite());
    animation.infinite(false);
    assertFalse(animation.isInfinite());
    animation.duration(20);
    assertEquals(animation.getDuration(), 20);
    animation.transition(Transition.FADEIN);
    assertEquals(animation.getTransition(), Transition.FADEIN);
    animation.animate(panel);
    assertEquals(animation.getWidget(), panel);
    // Check Advance Logic
    String WEBKIT_ANIMATION_DURATION = panel.getElement().getStyle().getProperty("WebkitAnimationDuration");
    assertEquals(WEBKIT_ANIMATION_DURATION, animation.getDuration() + "ms");
}
 
Example #9
Source File: MaterialSplitPanelTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testStructure() {
    // UiBinder
    // given
    MaterialSplitPanel splitPanel = getWidget(false);
    MaterialPanel leftPanel = new MaterialPanel();
    MaterialPanel rightPanel = new MaterialPanel();
    splitPanel.add(leftPanel);
    splitPanel.add(rightPanel);

    // when / then
    checkStructure(splitPanel, leftPanel, rightPanel);

    // Standard
    // given
    attachWidget();

    // when / then
    checkStructure(splitPanel, leftPanel, rightPanel);
}
 
Example #10
Source File: ScrollHelperTest.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
protected void checkProperties(MaterialPanel target, MaterialPanel container) {
    final boolean[] firedCallback = {false};
    final String LINEAR_EASING = "linear";
    Functions.Func CALLBACK = () -> {
        firedCallback[0] = true;
    };

    ScrollHelper scrollHelper = new ScrollHelper();

    scrollHelper.setEasing(LINEAR_EASING);
    scrollHelper.setCompleteCallback(CALLBACK);
    scrollHelper.setContainer(container);
    scrollHelper.scrollTo(target);
    checkOffsetPositioning(scrollHelper);

    assertEquals(LINEAR_EASING, scrollHelper.getEasing());
    assertEquals(CALLBACK, scrollHelper.getCompleteCallback());
    assertEquals(container.getElement(), scrollHelper.getContainerElement().asElement());
}
 
Example #11
Source File: MaterialCarouselTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testStructure() {
    // given
    MaterialCarousel carousel = getWidget();

    // when / then
    assertEquals(carousel.getBtnNextArrow(), carousel.getWidget(0));
    assertTrue(carousel.getWidget(0).getElement().hasClassName(AddinsCssName.CAROUSEL_NEXT_ARROW));

    assertEquals(carousel.getBtnPrevArrow(), carousel.getWidget(1));
    assertTrue(carousel.getWidget(1).getElement().hasClassName(AddinsCssName.CAROUSEL_PREV_ARROW));

    assertEquals(carousel.getWrapper(), carousel.getWidget(2));
    assertTrue(carousel.getWidget(2).getElement().hasClassName(AddinsCssName.MATERIAL_CAROUSEL_CONTAINER));

    for (int i = 1; i <= 5; i++) {
        MaterialPanel panel = new MaterialPanel();
        carousel.add(panel);
    }

    assertEquals(5, carousel.getContainer().getChildren().size());
}
 
Example #12
Source File: MaterialScrollfireTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void checkScrollfire(MaterialPanel panel) {
    final boolean[] isScrollFired = {false};
    // when / then
    MaterialScrollfire scrollfire = new MaterialScrollfire(panel.getElement());
    scrollfire.setCallback(() -> isScrollFired[0] = true);
    scrollfire.apply();
    $("body").scrollTop(1000);
    Scheduler.get().scheduleDeferred(() -> assertTrue(isScrollFired[0]));
}
 
Example #13
Source File: MaterialScrollfireTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testScrollfire() {
    // UiBinder
    // given
    MaterialPanel panel = getWidget(false);

    // when / then
    checkScrollfire(panel);

    // Standard
    // given
    attachWidget();

    // when / then
    checkScrollfire(panel);
}
 
Example #14
Source File: MaterialTimePickerTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
public void testChildren() {
    // UiBinder
    // given
    MaterialTimePicker timePicker = getWidget(true);

    assertEquals(1, timePicker.getWidgetCount());
    assertTrue(timePicker.getWidget(0) instanceof MaterialPanel);
    MaterialPanel panel = (MaterialPanel) timePicker.getWidget(0);
    assertEquals(3, panel.getWidgetCount());
    assertTrue(panel.getWidget(0) instanceof MaterialInput);
    assertTrue(panel.getWidget(1) instanceof Label);
    assertTrue(panel.getWidget(2) instanceof MaterialLabel);
}
 
Example #15
Source File: MaterialWindowTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testStructure() {
    // UiBinder
    // given
    MaterialWindow window = getWidget(false);

    // when / then
    assertNotNull(window);
    // Check Window Toolbar Structure
    assertTrue(window.getWidget(0) instanceof MaterialWidget);
    MaterialWidget toolbar = (MaterialWidget) window.getWidget(0);
    assertEquals(toolbar, window.getToolbar());
    assertTrue(toolbar.getElement().hasClassName(AddinsCssName.WINDOW_TOOLBAR));
    assertEquals(toolbar.getWidget(0), window.getLabelTitle());
    assertTrue(toolbar.getWidget(0).getElement().hasClassName(AddinsCssName.WINDOW_TITLE));
    window.setTitle("Title");
    assertEquals("Title", window.getLabelTitle().getText());
    assertEquals(toolbar.getWidget(1), window.getIconClose());
    assertTrue(toolbar.getWidget(1).getElement().hasClassName(AddinsCssName.WINDOW_ACTION));
    assertEquals(toolbar.getWidget(2), window.getIconMaximize());
    assertTrue(toolbar.getWidget(2).getElement().hasClassName(AddinsCssName.WINDOW_ACTION));
    // Check Window Content structure
    assertNotNull(window.getWidget(1));
    assertTrue(window.getWidget(1) instanceof MaterialWidget);
    MaterialWidget content = (MaterialWidget) window.getWidget(1);
    assertEquals(window.getContent(), content);
    MaterialPanel panel = new MaterialPanel();
    window.add(panel);
    assertEquals(content.getWidget(0), panel);
}
 
Example #16
Source File: MaterialPathAnimatorTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testStaticInstance() {
    // given
    MaterialPanel source = new MaterialPanel();
    MaterialPanel target = new MaterialPanel();
    RootPanel.get().add(source);
    RootPanel.get().add(target);

    // when / then
    target.setVisibility(Style.Visibility.HIDDEN);
    target.setOpacity(0);
    assertEquals("hidden", target.getElement().getStyle().getVisibility());
    assertEquals("0", target.getElement().getStyle().getOpacity());
    MaterialPathAnimator.animate(source, target);
    MaterialPathAnimator.reverseAnimate(source, target);
}
 
Example #17
Source File: MaterialPathAnimatorTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testProperties() {
    // given
    final int DURATION = 300;
    final int TARGET_DURATION = 500;
    final int EXTRA_DURATION = 800;
    final Functions.Func animateCallback = () -> {};
    final Functions.Func reverseCallback = () -> {};
    MaterialPathAnimator animator = new MaterialPathAnimator();

    // when / then
    animator.setDuration(DURATION);
    assertEquals(DURATION, animator.getDuration());
    animator.setTargetShowDuration(TARGET_DURATION);
    assertEquals(TARGET_DURATION, animator.getTargetShowDuration());
    animator.setAnimateCallback(animateCallback);
    assertEquals(animateCallback, animator.getAnimateCallback());
    animator.setReverseCallback(reverseCallback);
    assertEquals(reverseCallback, animator.getReverseCallback());
    animator.setExtraTransitionDuration(EXTRA_DURATION);
    assertEquals(EXTRA_DURATION, animator.getExtraTransitionDuration());
    MaterialPanel source = getWidget();
    animator.setSourceElement(source.getElement());
    assertEquals(source.getElement(), animator.getSourceElement());
    assertNotNull(target);
    animator.setTargetElement(target.getElement());
    assertEquals(target.getElement(), animator.getTargetElement());
}
 
Example #18
Source File: MaterialPathAnimatorTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
protected MaterialPanel createWidget() {
    source = new MaterialPanel();
    target = new MaterialPanel();
    RootPanel.get().add(target);
    return source;
}
 
Example #19
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void checkDragEvents(MaterialPanel panel) {
    MaterialDnd.draggable(panel);
    // Drag Start Event
    final boolean[] isDragStartFired = {false};
    panel.addDragStartHandler(event -> isDragStartFired[0] = true);
    panel.fireEvent(new DragStartEvent() {
    });
    assertTrue(isDragStartFired[0]);
    // Drag Enter Event
    final boolean[] isDragEnterFired = {false};
    panel.addDragEnterHandler(event -> isDragEnterFired[0] = true);
    panel.fireEvent(new DragEnterEvent($(panel.getElement())) {
    });
    assertTrue(isDragEnterFired[0]);
    // Drag Move Event
    final boolean[] isDragMoveFired = {false};
    panel.addDragMoveHandler(event -> isDragMoveFired[0] = true);
    panel.fireEvent(new DragMoveEvent() {
    });
    assertTrue(isDragMoveFired[0]);
    // Drag End Event
    final boolean[] isDragEndFired = {false};
    panel.addDragEndHandler(event -> isDragEndFired[0] = true);
    panel.fireEvent(new DragEndEvent() {
    });
    assertTrue(isDragEndFired[0]);
    // Drag Over Event
    final boolean[] isDragOverFired = {false};
    panel.addDragOverHandler(event -> isDragOverFired[0] = true);
    panel.fireEvent(new DragOverEvent() {
    });
    assertTrue(isDragOverFired[0]);
}
 
Example #20
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testDragEvents() {
    // UiBinder
    // given
    MaterialPanel panel = getWidget(false);

    // when / then
    checkDragEvents(panel);

    // Standard
    // given
    attachWidget();

    // when / then
    checkDragEvents(panel);
}
 
Example #21
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testDropEvents() {
    // UiBinder
    // given
    MaterialPanel panel = getWidget(false);

    // when / then
    checkDropEvents(panel);

    // Standard
    // given
    attachWidget();

    // when / then
    checkDropEvents(panel);
}
 
Example #22
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testInertia() {
    // UiBinder
    // given
    MaterialPanel panel = getWidget(false);

    // when / then
    checkInertia(panel);

    // Standard
    // given
    attachWidget();

    // when / then
    checkInertia(panel);
}
 
Example #23
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void checkAxis(MaterialPanel panel) {
    final String VERTICAL_AXIS = "y";
    final String HORIZONTAL_AXIS = "x";
    MaterialDnd dnd = MaterialDnd.draggable(panel, JsDragOptions.create(Axis.VERTICAL));
    assertEquals(VERTICAL_AXIS, dnd.getDragOptions().axis);
    dnd.getDragOptions().axis = HORIZONTAL_AXIS;
    assertEquals(HORIZONTAL_AXIS, dnd.getDragOptions().axis);
}
 
Example #24
Source File: ScrollHelperTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
protected MaterialPanel createWidget() {
    MaterialPanel container = new MaterialPanel();
    MaterialPanel target = new MaterialPanel();
    container.add(target);
    return container;
}
 
Example #25
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void checkDropzone(MaterialPanel panel) {
    final String ACCEPT = "accept";
    final double OVERLAP = 20;
    MaterialDnd dnd = MaterialDnd.dropzone(panel, JsDropOptions.create(ACCEPT, OVERLAP));
    JsDropOptions options = dnd.getDropOptions();
    assertEquals(ACCEPT, options.accept);
    assertEquals(OVERLAP, options.overlap);
}
 
Example #26
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testDropzone() {
    // UiBinder
    // given
    MaterialPanel panel = getWidget(false);

    // when / then
    checkDropzone(panel);

    // Standard
    // given
    attachWidget();

    // when / then
    checkDropzone(panel);
}
 
Example #27
Source File: ScrollHelperTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void testProperties() {
    // UiBinder
    // Given
    MaterialPanel container = getWidget(false);
    MaterialPanel target = (MaterialPanel) container.getWidget(0);

    checkProperties(target, container);

    // Standard
    // Given
    attachWidget();

    checkProperties(target, container);
}
 
Example #28
Source File: TimerProgressTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testStructure() {
    TimerProgress timerProgress = getWidget();

    assertTrue(timerProgress.getElement().hasClassName(IncubatorCssName.TIMER_PROGRESS));
    assertTrue(timerProgress.getElement().hasClassName(IncubatorCssName.BOUNCING));

    assertEquals(timerProgress.getWidgetCount(), 1);
    assertTrue(timerProgress.getWidget(0) instanceof MaterialPanel);
    MaterialPanel fillPanel = (MaterialPanel) timerProgress.getWidget(0);
    assertTrue(fillPanel.getElement().hasClassName(IncubatorCssName.FILL));
    assertEquals(fillPanel, timerProgress.getFill());
}
 
Example #29
Source File: ScrollHelperTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void testScrollOnTarget() {
    // UiBinder
    // Given
    MaterialPanel container = getWidget();
    MaterialPanel target = (MaterialPanel) container.getWidget(0);
    target.setMarginTop(2000);
    target.setPaddingTop(0);

    double targetOffset = $(target.getElement()).offset().top;
    ScrollHelper scrollHelper = new ScrollHelper();
    scrollHelper.setCompleteCallback(() -> assertEquals(2000.0, targetOffset));

    scrollHelper.scrollTo(target);
}
 
Example #30
Source File: ScrollHelperTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void testDefaultContainer() {
    MaterialPanel target = new MaterialPanel();
    ScrollHelper scrollHelper = new ScrollHelper();
    scrollHelper.scrollTo(target);

    assertEquals($("html, body").asElement(), scrollHelper.getContainerElement().asElement());
}