gwt.material.design.client.base.viewport.Resolution Java Examples

The following examples show how to use gwt.material.design.client.base.viewport.Resolution. 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: AbstractSideNavTest.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public void testAutoHideOnResize() {
    T sideNav = getWidget();

    if (sideNav instanceof MaterialSideNavPush) {
        assertTrue(sideNav.isAutoHideOnResize());
    } else {
        assertFalse(sideNav.isAutoHideOnResize());
    }

    sideNav.setAutoHideOnResize(true);
    assertTrue(sideNav.isAutoHideOnResize());

    sideNav.setAutoHideOnResize(false);
    assertFalse(sideNav.isAutoHideOnResize());

    assertNotNull(sideNav.getClosingBoundary());

    WidthBoundary boundary = sideNav.getClosingBoundary();
    assertEquals(0, boundary.getMin());
    assertEquals(992, boundary.getMax());

    sideNav.setClosingBoundary(Resolution.ALL_MOBILE.getBoundary());
    assertEquals(Resolution.ALL_MOBILE.getBoundary(), sideNav.getClosingBoundary());
}
 
Example #2
Source File: ExpandableInlineSearch.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
@Override
public void open() {
    super.open();

    getToggleStyleMixin().setOn(true);

    ViewPort.when(Resolution.ALL_MOBILE, Resolution.TABLET).then(param1 -> {
        if (isOpen()) {
            super.setWidth("90%");
        }
    }, viewPort -> {
        if (isOpen()) {
            super.setWidth(width);
        }
        return false;
    });
}
 
Example #3
Source File: InlineSearch.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoad() {
    super.onLoad();

    ViewPort.when(Resolution.ALL_MOBILE).then(portChange -> {
        focusHandler = registerHandler(addFocusHandler(focusEvent -> addStyleName(AddinsCssName.WIDE)));
        blurHandler = registerHandler(addBlurHandler(blurEvent -> removeStyleName(AddinsCssName.WIDE)));
    }, viewPortRect -> {
        if (focusHandler != null && blurHandler != null) {
            focusHandler.removeHandler();
            blurHandler.removeHandler();
        }

        focusHandler = null;
        blurHandler = null;
        return true;
    });

    IncubatorDarkThemeReloader.get().reload(InlineSearchDarkTheme.class);
}
 
Example #4
Source File: MaterialWindow.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
/**
 * Open the window.
 */
public void open() {
    if (!isAttached()) {
        RootPanel.get().add(this);
    }
    windowCount++;
    if (windowOverlay != null && !windowOverlay.isAttached()) {
        RootPanel.get().add(windowOverlay);
    }

    if (fullsceenOnMobile && Window.matchMedia(Resolution.ALL_MOBILE.asMediaQuery())) {
        setMaximize(true);
    }

    if (openAnimation == null) {
        getOpenMixin().setOn(true);
        OpenEvent.fire(this, true);
    } else {
        setOpacity(0);
        Scheduler.get().scheduleDeferred(() -> {
            getOpenMixin().setOn(true);
            openAnimation.animate(this, () -> OpenEvent.fire(this, true));
        });
    }
}
 
Example #5
Source File: AdaptiveWidget.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public AdaptiveWidget register(Resolution resolution, T widget) {
    if (widgetMap == null) {
        widgetMap = new AdaptiveWidgetMap<>();
    }

    widgetMap.put(resolution, widget);
    return this;
}
 
Example #6
Source File: FieldTypeMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public void setFieldType(FieldType type) {
    if (type.equals(FieldType.ALIGNED_LABEL)) {
        ViewPort.when(Resolution.ALL_MOBILE).then(param1 -> {
            getCssNameMixin().setCssName(FieldType.DEFAULT);
        }, viewPort -> {
            getCssNameMixin().setCssName(type);
            return false;
        });
    } else {
        getCssNameMixin().setCssName(type);
    }
}
 
Example #7
Source File: HelperView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
protected void detectViewPort() {
    ViewPort.when(Resolution.MOBILE_SMALL).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Mobile Small");
        lblViewPort.setIconType(IconType.PHONE_ANDROID);
    });

    ViewPort.when(Resolution.MOBILE_MEDIUM).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Mobile Medium");
        lblViewPort.setIconType(IconType.PHONE_ANDROID);
    });

    ViewPort.when(Resolution.MOBILE_LARGE).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Mobile Large");
        lblViewPort.setIconType(IconType.PHONE_ANDROID);
    });

    ViewPort.when(Resolution.TABLET).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Tablet");
        lblViewPort.setIconType(IconType.TABLET_ANDROID);
    });

    ViewPort.when(Resolution.LAPTOP).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Laptop");
        lblViewPort.setIconType(IconType.LAPTOP);
    });

    ViewPort.when(Resolution.LAPTOP_LARGE).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Laptop Large");
        lblViewPort.setIconType(IconType.LAPTOP);
    });

    ViewPort.when(Resolution.LAPTOP_4K).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Laptop 4K");
        lblViewPort.setIconType(IconType.LAPTOP);
    });
}
 
Example #8
Source File: MaterialStepper.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void detectAndApplyOrientation() {
    if (getAxis() != null && getAxis() == Axis.VERTICAL && !Window.matchMedia(Resolution.ALL_MOBILE.asMediaQuery())) {
        return;
    }

    if (Window.matchMedia("(orientation: portrait)")) {
        setAxis(Axis.VERTICAL);
    } else {
        setAxis(Axis.HORIZONTAL);
    }
}
 
Example #9
Source File: AdaptiveWidget.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void load() {
    ViewPort.when(Resolution.ALL_DEVICES).then(viewPortChange -> loadViewPort());
}
 
Example #10
Source File: AdaptiveWidget.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public AdaptiveWidget unregister(Resolution resolution) {
    if (widgetMap != null) {
        widgetMap.remove(resolution);
    }
    return this;
}
 
Example #11
Source File: AdaptiveWidgetMap.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void put(Resolution resolution, T widget) {
    put(resolution.getBoundary(), widget);
}
 
Example #12
Source File: DateRangePicker.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
protected void load() {

        add(dateInput);
        add(label);
        add(errorLabel);

        getInputElement().daterangepicker(options, (startDate, endDate) -> {
            setValue(new Date[]{new Date(startDate.format()), new Date(endDate.format())}, true);
        });

        getInputElement().on(DateRangeEvents.UPDATE_CALENDAR, (e, picker) -> {
            toggleTypeAssist();
            return true;
        });

        getInputElement().on(DateRangeEvents.NEXT, (e, picker) -> {
            NextCalendarEvent.fire(this, picker);
            toggleTypeAssist();
            return true;
        });

        getInputElement().on(DateRangeEvents.PREV, (e, picker) -> {
            PreviousCalendarEvent.fire(this, picker);
            toggleTypeAssist();
            return true;
        });

        getInputElement().on(DateRangeEvents.SELECT, (e, picker) -> {
            SelectionEvent.fire(this, picker);
            toggleTypeAssist();
            return true;
        });

        getInputElement().on(DateRangeEvents.OPEN, (e, picker) -> {
            if (Window.matchMedia(Resolution.ALL_MOBILE.asMediaQuery()) || Window.matchMedia(Resolution.TABLET.asMediaQuery())) {
                JQuery.$(dateInput.getElement()).blur();
            }
            OpenEvent.fire(this, picker);
            detectPosition();
            return true;
        });

        getInputElement().on(DateRangeEvents.CLOSE, (e, picker) -> {
            CloseEvent.fire(this, picker);
            return true;
        });

        getInputElement().on(DateRangeEvents.CLOSE_CALENDAR, (e, picker) -> {
            CloseCalendarEvent.fire(this, picker);
            return true;
        });

        getInputElement().on(DateRangeEvents.OPEN_CALENDAR, (e, picker) -> {
            OpenCalendarEvent.fire(this, picker);
            return true;
        });

        getInputElement().on(DateRangeEvents.APPLY, (e, picker) -> {
            ApplyEvent.fire(this, picker);
            return true;
        });

        getInputElement().on(DateRangeEvents.CANCEL, (e, picker) -> {
            CancelEvent.fire(this, picker);
            return true;
        });

        getInputElement().on(DateRangeEvents.TIME_CHANGED, (e, picker) -> {
            toggleTimePickerTypeAssist();
            return true;
        });

        getHandlerRegistry().registerHandler(Window.addResizeHandler(event -> detectPosition()));

        setId(DOM.createUniqueId());

        IncubatorDarkThemeReloader.get().reload(DateRangeDarkTheme.class);
    }