Java Code Examples for gwt.material.design.client.base.MaterialWidget
The following examples show how to use
gwt.material.design.client.base.MaterialWidget. These examples are extracted from open source projects.
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 Project: gwt-material Source File: MaterialProgressTest.java License: Apache License 2.0 | 6 votes |
protected void checkProgressBar(MaterialProgress progress) { assertNotNull(progress); // Check default type progress.setType(ProgressType.INDETERMINATE); assertEquals(ProgressType.INDETERMINATE, progress.getType()); progress.setType(ProgressType.DETERMINATE); assertEquals(ProgressType.DETERMINATE, progress.getType()); progress.setPercent(90); assertEquals((double) 90, progress.getPercent()); // Get the target widget for percentage update assertNotNull(progress.getWidget(0)); assertTrue(progress.getWidget(0) instanceof MaterialWidget); MaterialWidget progressDiv = (MaterialWidget) progress.getWidget(0); assertEquals("90%", progressDiv.getElement().getStyle().getWidth()); // Check color MaterialWidgetTest.checkColor(progress); }
Example 2
Source Project: gwt-material Source File: MaterialLoaderTest.java License: Apache License 2.0 | 6 votes |
protected void checkLoader(ComplexPanel panel) { assertTrue(panel.getWidget(0) instanceof MaterialWidget); MaterialWidget loaderWrapper = (MaterialWidget) panel.getWidget(0); assertTrue(loaderWrapper.getElement().hasClassName(CssName.LOADER_WRAPPER)); assertTrue(loaderWrapper.getElement().hasClassName(CssName.VALIGN_WRAPPER)); assertTrue(loaderWrapper.getWidget(0) instanceof MaterialPreLoader); MaterialPreLoader preLoader = (MaterialPreLoader) loaderWrapper.getWidget(0); checkPreLoader(preLoader); assertEquals(4, preLoader.getChildren().size()); for (Widget w : preLoader.getChildren()) { assertTrue(w instanceof MaterialSpinner); MaterialSpinner spinner = (MaterialSpinner) w; checkSpinner(spinner); } MaterialLoader.loading(false); assertEquals(panel.getWidgetCount(), 0); }
Example 3
Source Project: gwt-material Source File: MaterialCollapsibleTest.java License: Apache License 2.0 | 6 votes |
public void testTypes() { // given MaterialCollapsible collapsible = getWidget(); // when / then collapsible.enableFeature(MaterialWidget.Feature.ONLOAD_ADD_QUEUE, false); collapsible.setType(CollapsibleType.FLAT); assertEquals(CollapsibleType.FLAT, collapsible.getType()); assertTrue(collapsible.getElement().hasClassName(CollapsibleType.FLAT.getCssName())); collapsible.setType(CollapsibleType.POPOUT); assertEquals(CollapsibleType.POPOUT, collapsible.getType()); assertTrue(collapsible.getElement().hasClassName(CollapsibleType.POPOUT.getCssName())); collapsible.setAccordion(true); assertTrue(collapsible.isAccordion()); collapsible.setAccordion(false); assertFalse(collapsible.isAccordion()); }
Example 4
Source Project: gwt-material Source File: MaterialWidgetTestCase.java License: Apache License 2.0 | 6 votes |
protected <H extends MaterialWidget> void checkGestureEvents(H widget) { // Gesture Start final boolean[] isGestureStartFired = {false}; widget.addGestureStartHandler(gestureStartEvent -> isGestureStartFired[0] = true); fireGestureStartEvent(widget); // Gesture End final boolean[] isGestureEndFired = {false}; widget.addGestureEndHandler(gestureEndEvent -> isGestureEndFired[0] = true); fireGestureEndEvent(widget); // Gesture Change final boolean[] isGestureChangeFired = {false}; widget.addGestureChangeHandler(gestureChangeEvent -> isGestureChangeFired[0] = true); fireGestureChangeEvent(widget); assertEquals(widget.isEnabled(), isGestureStartFired[0]); assertEquals(widget.isEnabled(), isGestureChangeFired[0]); assertEquals(widget.isEnabled(), isGestureEndFired[0]); }
Example 5
Source Project: gwt-material Source File: MaterialWidgetTestCase.java License: Apache License 2.0 | 6 votes |
protected <H extends MaterialWidget> void checkTouchEvents(H widget) { // Touch Start final boolean[] isTouchStartFired = {false}; widget.addTouchStartHandler(touchStartEvent -> isTouchStartFired[0] = true); fireTouchStartEvent(widget); // Touch Move final boolean[] isTouchMoveFired = {false}; widget.addTouchMoveHandler(touchMoveEvent -> isTouchMoveFired[0] = true); fireTouchMoveEvent(widget); // Touch End final boolean[] isTouchEndFired = {false}; widget.addTouchEndHandler(touchEndEvent -> isTouchEndFired[0] = true); fireTouchEndEvent(widget); // Touch Cancel final boolean[] isTouchCancelFired = {false}; widget.addTouchCancelHandler(touchCancelEvent -> isTouchCancelFired[0] = true); fireTouchCancelEvent(widget); assertEquals(widget.isEnabled(), isTouchStartFired[0]); assertEquals(widget.isEnabled(), isTouchMoveFired[0]); assertEquals(widget.isEnabled(), isTouchEndFired[0]); assertEquals(widget.isEnabled(), isTouchCancelFired[0]); }
Example 6
Source Project: gwt-material-demo Source File: ThemeManager.java License: Apache License 2.0 | 6 votes |
public static void setColor(Color color, Color darkerColor, Color lighterColor) { final long DURATION = 1000 * 60 * 60 * 24 * 14; //duration remembering login - 2 weeks Date expires = new Date(System.currentTimeMillis() + DURATION); Cookies.setCookie(COLOR, color.getCssName(), expires, null, "/", false); for (MaterialWidget w : map.keySet()) { switch (map.get(w)) { case REGULAR_SHADE: w.setBackgroundColor(color); break; case DARKER_SHADE: w.setBackgroundColor(darkerColor); break; case LIGHTER_SHADE: w.setBackgroundColor(lighterColor); break; default: break; } } }
Example 7
Source Project: gwt-material-demo Source File: NavigatedView.java License: Apache License 2.0 | 6 votes |
@Override public void buildScrollSpy(List<Links> links, MaterialWidget panel) { this.panel = panel; for(Links link : links) { MaterialLink spy = new MaterialLink(); spy.setText(link.getTitle()); spy.setHref(link.getLink()); scrollspy.add(spy); } panel.setMarginTop(40); scrollspy.setHideOn(HideOn.HIDE_ON_MED_DOWN); scrollspy.setTop(0); panel.add(scrollspy); scrollspy.addAttachHandler(attachEvent -> { MaterialPushpin.apply(scrollspy, 300.0, 10000.0, 64.0); }); }
Example 8
Source Project: gwt-material-addins Source File: MaterialStepperTest.java License: Apache License 2.0 | 6 votes |
protected void checkErrorSuccess(MaterialStepper stepper) { MaterialStep step = stepper.getCurrentStep(); MaterialWidget conCircle = (MaterialWidget) step.getWidget(0); // when / then stepper.setErrorText("error"); assertTrue(step.getElement().hasClassName(AddinsCssName.ERROR)); assertEquals(step.getIconError(), conCircle.getWidget(0)); assertEquals(State.ERROR, step.getState()); stepper.setSuccessText("success"); assertFalse(step.getElement().hasClassName(AddinsCssName.ERROR)); assertTrue(step.getElement().hasClassName(AddinsCssName.SUCCESS)); assertEquals(step.getIconSuccess(), conCircle.getWidget(0)); assertEquals(State.SUCCESS, step.getState()); stepper.clearStatusText(); assertFalse(step.getElement().hasClassName(AddinsCssName.ERROR)); assertFalse(step.getElement().hasClassName(AddinsCssName.SUCCESS)); }
Example 9
Source Project: gwt-material Source File: ColorHelper.java License: Apache License 2.0 | 5 votes |
public static String setupComputedBackgroundColor(Color color) { MaterialWidget temp = new MaterialWidget(Document.get().createDivElement()); temp.setBackgroundColor(color); RootPanel.get().add(temp); String computed = getComputedBackgroundColor(temp.getElement()).toLowerCase(); temp.removeFromParent(); return computed; }
Example 10
Source Project: gwt-material Source File: StatusDisplayMixin.java License: Apache License 2.0 | 5 votes |
@Override public void updateStatusDisplay(StatusType statusType) { if (displayType == StatusDisplayType.HOVERABLE) { if (!statusIcon.getElement().hasClassName(CssName.STATUS_ICON)) { statusIcon.addStyleName(CssName.STATUS_ICON); } if (statusType == StatusType.ERROR) { statusIcon.setIconType(IconType.ERROR); statusIcon.setIconColor(Color.RED); } else { statusIcon.setIconType(IconType.CHECK_CIRCLE); statusIcon.setIconColor(Color.GREEN); } if (uiObject instanceof HasWidgets && uiObject instanceof MaterialWidget) { if (container != null && container instanceof MaterialWidget) { ((MaterialWidget) container).insert(statusIcon, 0); } else { ((HasWidgets) uiObject).add(statusIcon); } registerHandlers(); } } else { resetStatusDisplay(); } }
Example 11
Source Project: gwt-material Source File: StatusDisplayMixin.java License: Apache License 2.0 | 5 votes |
protected void registerHandlers() { MaterialWidget widget = (MaterialWidget) uiObject; statusIcon.getHandlerRegistry().clearHandlers(); statusIcon.registerHandler(statusIcon.addMouseOverHandler(event -> showStatus())); statusIcon.registerHandler(statusIcon.addMouseOutHandler(event -> hideStatus())); widget.getHandlerRegistry().clearHandlers(); widget.registerHandler(widget.addFocusHandler(event -> showStatus())); widget.registerHandler(widget.addBlurHandler(event -> hideStatus())); widget.registerHandler(widget.addKeyUpHandler(event -> { if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { hideStatus(); } })); }
Example 12
Source Project: gwt-material Source File: EnabledMixin.java License: Apache License 2.0 | 5 votes |
public void setEnabled(MaterialWidget widget, boolean enabled) { setEnabled(enabled); if(isPropagateToChildren()) { for (Widget child : widget.getChildren()) { if (child instanceof MaterialWidget) { ((MaterialWidget) child).setEnabled(enabled); } else if (child instanceof HasEnabled) { ((HasEnabled) child).setEnabled(enabled); } } } }
Example 13
Source Project: gwt-material Source File: EnabledMixin.java License: Apache License 2.0 | 5 votes |
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 14
Source Project: gwt-material Source File: MaterialSideNavMini.java License: Apache License 2.0 | 5 votes |
@Override protected void setup() { applyBodyScroll(); if (isExpandable()) { setType(SideNavType.MINI_WITH_EXPAND); applyTransition(getElement()); int originalWidth = getWidth(); int miniWidth = 64; pushElement(getMain(), miniWidth); pushElementMargin(getFooter(), miniWidth); setWidth(miniWidth); registerHandler(addOpeningHandler(event -> expand(originalWidth))); registerHandler(addClosingHandler(event -> collapse(miniWidth))); // Add Opening when sidenav link is clicked by default for (Widget w : getChildren()) { if (w instanceof MaterialWidget && isExpandOnClick()) { $(w.getElement()).off("click").on("click", (e, param1) -> { if (!getElement().hasClassName("expanded")) { open(); } return true; }); } } } else { setType(SideNavType.MINI); setWidth(64); } }
Example 15
Source Project: gwt-material Source File: ThemeManager.java License: Apache License 2.0 | 5 votes |
public static List<WidgetTheme> getWidgetThemes(MaterialWidget object, Class clazz, List<WidgetTheme> widgetThemes) { List<WidgetTheme> cachedThemes = themeCache.get(clazz); if (themes != null && cachedThemes == null) { cachedThemes = new ArrayList<>(); for(Theme theme : themes) { // Check by widgets class name first WidgetTheme widgetTheme = theme.get(clazz.getName()); if (widgetTheme != null) { cachedThemes.add(widgetTheme); } // Check by widget class selector for (String styleName : object.getStyleName().split(" ")) { WidgetTheme styleWidgetTheme = theme.get(styleName); if (styleWidgetTheme != null) { cachedThemes.add(styleWidgetTheme); } } } themeCache.put(clazz, cachedThemes); } if (cachedThemes != null) { widgetThemes.addAll(cachedThemes); } // check the supertype if (clazz.getSuperclass() != null && !clazz.getSuperclass().equals(MaterialWidget.class)) { return getWidgetThemes(object, clazz.getSuperclass(), widgetThemes); } else { return widgetThemes; } }
Example 16
Source Project: gwt-material Source File: ThemeManager.java License: Apache License 2.0 | 5 votes |
public static List<WidgetTheme> applyLoad(MaterialWidget object) { List<WidgetTheme> widgetThemes = getWidgetThemes(object); for (WidgetTheme widgetTheme : widgetThemes) { object = widgetTheme.onWidgetLoad(object); } return widgetThemes; }
Example 17
Source Project: gwt-material Source File: ThemeManager.java License: Apache License 2.0 | 5 votes |
public static List<WidgetTheme> applyUnload(MaterialWidget object) { List<WidgetTheme> widgetThemes = getWidgetThemes(object); for (WidgetTheme widgetTheme : widgetThemes) { object = widgetTheme.onWidgetUnload(object); } return widgetThemes; }
Example 18
Source Project: gwt-material Source File: MaterialProgressTest.java License: Apache License 2.0 | 5 votes |
protected void checkProgress(ComplexPanel panel) { assertNotNull(panel.getWidget(0)); assertTrue(panel.getWidget(0) instanceof MaterialWidget); MaterialWidget loaderWrapper = (MaterialWidget) panel.getWidget(0); assertTrue(loaderWrapper.getElement().hasClassName(CssName.PROGRESS_WRAPPER)); assertTrue(loaderWrapper.getElement().hasClassName(CssName.VALIGN_WRAPPER)); assertTrue(loaderWrapper.getWidget(0) instanceof MaterialProgress); MaterialProgress progress = (MaterialProgress) loaderWrapper.getWidget(0); checkProgressBar(progress); checkProgressValue(progress); MaterialLoader.loading(false); assertEquals(0, panel.getWidgetCount()); }
Example 19
Source Project: gwt-material Source File: MaterialCollapsibleTest.java License: Apache License 2.0 | 5 votes |
protected void generateCollapsibleItems(MaterialWidget parent) { for (int i = 1; i <= 5; i++) { MaterialCollapsibleItem item = new MaterialCollapsibleItem(); MaterialCollapsibleHeader header = new MaterialCollapsibleHeader(); MaterialCollapsibleBody body = new MaterialCollapsibleBody(); item.add(header); item.add(body); parent.add(item); } }
Example 20
Source Project: gwt-material Source File: MaterialCardTest.java License: Apache License 2.0 | 5 votes |
public void testStructure() { // given MaterialCard card = getWidget(); // when / then MaterialCardContent content = new MaterialCardContent(); card.add(content); MaterialCardTitle title = new MaterialCardTitle(); card.add(title); MaterialCardAction action = new MaterialCardAction(); card.add(action); MaterialCardReveal cardReveal = new MaterialCardReveal(); card.add(cardReveal); MaterialCardImage cardImage = new MaterialCardImage(); card.add(cardImage); assertEquals(5, card.getChildren().size()); assertTrue(card.getWidget(0) instanceof MaterialCardContent); assertTrue(card.getWidget(1) instanceof MaterialCardTitle); assertTrue(card.getWidget(2) instanceof MaterialCardAction); assertTrue(card.getWidget(3) instanceof MaterialCardReveal); assertTrue(card.getWidget(4) instanceof MaterialCardImage); for (Widget w : card.getChildren()) { assertNotNull(w); assertTrue(w instanceof MaterialWidget); } card.clear(); assertEquals(0, card.getChildren().size()); }
Example 21
Source Project: gwt-material Source File: MaterialWidgetTestCase.java License: Apache License 2.0 | 5 votes |
protected <H extends MaterialWidget> void checkClickAndDoubleClickEvents(H widget) { // Check Click Event final boolean[] isClickFired = {false}; widget.addClickHandler(clickEvent -> isClickFired[0] = true); fireClickEvent(widget); // Check Double Click Event final boolean[] isDoubleClickFired = {false}; widget.addDoubleClickHandler(doubleClickEvent -> isDoubleClickFired[0] = true); fireDoubleClickEvent(widget); assertEquals(widget.isEnabled(), isClickFired[0]); assertEquals(widget.isEnabled(), isDoubleClickFired[0]); }
Example 22
Source Project: gwt-material Source File: MaterialWidgetTestCase.java License: Apache License 2.0 | 5 votes |
protected <H extends MaterialWidget> void checkMouseEvents(H widget) { // Check Mouse Down Event final boolean[] isMouseDownFired = {false}; widget.addMouseDownHandler(mouseDownEvent -> isMouseDownFired[0] = true); fireMouseDownEvent(widget); // Check Mouse Up Event final boolean[] isMouseUpFired = {false}; widget.addMouseUpHandler(mouseUpEvent -> isMouseUpFired[0] = true); fireMouseUpEvent(widget); // Check Mouse Over final boolean[] isMouseOverFired = {false}; widget.addMouseOverHandler(mouseOverEvent -> isMouseOverFired[0] = true); fireMouseOverEvent(widget); // Check Mouse Move final boolean[] isMouseMoveFired = {false}; widget.addMouseMoveHandler(mouseMoveEvent -> isMouseMoveFired[0] = true); fireMouseMoveEvent(widget); // Check Mouse Wheel final boolean[] isMouseWheelFired = {false}; widget.addMouseWheelHandler(mouseWheelEvent -> isMouseWheelFired[0] = true); fireMouseWheelEvent(widget); assertEquals(isMouseUpFired[0], widget.isEnabled()); assertEquals(isMouseDownFired[0], widget.isEnabled()); assertEquals(isMouseMoveFired[0], widget.isEnabled()); assertEquals(isMouseWheelFired[0], widget.isEnabled()); assertEquals(isMouseOverFired[0], widget.isEnabled()); }
Example 23
Source Project: gwt-material Source File: MaterialWidgetTestCase.java License: Apache License 2.0 | 5 votes |
public <H extends MaterialWidget & HasOpenHandlers> void checkOpenHandler(H widget) { // Check Open Event final boolean[] fired = {false}; widget.addOpenHandler(event -> { fired[0] = true; }); fireOpenHandler(widget); assertTrue(fired[0]); }
Example 24
Source Project: gwt-material Source File: MaterialWidgetTestCase.java License: Apache License 2.0 | 5 votes |
protected <H extends MaterialWidget & HasSelectionHandlers> void checkSelectionHandler(H widget, Object selectedItem) { // Check Open Event final boolean[] fired = {false}; widget.addSelectionHandler(event -> { assertEquals(event.getSelectedItem(), selectedItem); fired[0] = true; }); fireSelectionHandler(widget, selectedItem); assertTrue(fired[0]); }
Example 25
Source Project: gwt-material-demo Source File: InfiniteScrollView.java License: Apache License 2.0 | 5 votes |
protected MaterialWidget createColumn(Person person) { MaterialColumn column = new MaterialColumn(12, 12, 12); MaterialCard card = new MaterialCard(); card.setMargin(12); card.setPadding(40); MaterialLabel title = new MaterialLabel(person.getFirstName()); title.setFontWeight(Style.FontWeight.BOLD); card.add(title); card.add(new MaterialLabel("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ")); column.add(card); return column; }
Example 26
Source Project: gwt-material-addins Source File: LanguageSelector.java License: Apache License 2.0 | 5 votes |
protected <T extends MaterialWidget & HasActivates> void setActivator(T widget) { String activator = DOM.createUniqueId(); widget.setActivates(activator); widget.addStyleName(IncubatorCssName.LANGUAGE_ACTIVATOR); add(widget); dropdown.setActivator(activator); dropdown.reload(); }
Example 27
Source Project: gwt-material-addins Source File: MaterialCircularProgress.java License: Apache License 2.0 | 5 votes |
@Override protected FontSizeMixin<MaterialWidget> getFontSizeMixin() { if (fontSizeMixin == null) { fontSizeMixin = new FontSizeMixin<>(label); } return fontSizeMixin; }
Example 28
Source Project: gwt-material-addins Source File: MaterialCutOut.java License: Apache License 2.0 | 5 votes |
/** * Gets the computed background color, based on the backgroundColor CSS * class. */ protected void setupComputedBackgroundColor() { // temp is just a widget created to evaluate the computed background // color MaterialWidget temp = new MaterialWidget(Document.get().createDivElement()); temp.setBackgroundColor(backgroundColor); // setting a style to make it invisible for the user Style style = temp.getElement().getStyle(); style.setPosition(Position.FIXED); style.setWidth(1, Unit.PX); style.setHeight(1, Unit.PX); style.setLeft(-10, Unit.PX); style.setTop(-10, Unit.PX); style.setZIndex(-10000); // adding it to the body (on Chrome the component must be added to the // DOM before getting computed values). String computed = ColorHelper.setupComputedBackgroundColor(backgroundColor); // convert rgb to rgba, considering the opacity field if (opacity < 1 && computed.startsWith("rgb(")) { computed = computed.replace("rgb(", "rgba(").replace(")", ", " + opacity + ")"); } computedBackgroundColor = computed; }
Example 29
Source Project: gwt-material-addins Source File: MaterialOverlayTab.java License: Apache License 2.0 | 5 votes |
public void setActivator(MaterialWidget activator) { if (this.activator == null) { this.activator = activator; this.activator.addStyleName(AddinsCssName.OVERLAY_TAB_INDICATOR); this.activator.addClickHandler(e -> restore()); this.activator.add(badge); } }
Example 30
Source Project: gwt-material-addins Source File: MaterialSplitPanel.java License: Apache License 2.0 | 5 votes |
protected void applySplitterLineColor(Color splitterLineColor) { if (splitterLineColor != null) { JQueryElement splitterBar = $(getElement()).find(".splitter-bar"); if (splitterBar != null) { MaterialWidget widget = new MaterialWidget(splitterBar); widget.setBackgroundColor(splitterLineColor); } } }