gwt.material.design.client.base.MaterialWidget Java Examples
The following examples show how to use
gwt.material.design.client.base.MaterialWidget.
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: MaterialStepperTest.java From gwt-material-addins with 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 #2
Source File: MaterialLoaderTest.java From gwt-material with 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 File: MaterialProgressTest.java From gwt-material with 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 #4
Source File: MaterialCollapsibleTest.java From gwt-material with 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 #5
Source File: MaterialWidgetTestCase.java From gwt-material with 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 #6
Source File: MaterialWidgetTestCase.java From gwt-material with 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 #7
Source File: ThemeManager.java From gwt-material-demo with 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 #8
Source File: NavigatedView.java From gwt-material-demo with 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 #9
Source File: MaterialCircularProgress.java From gwt-material-addins with Apache License 2.0 | 5 votes |
@Override protected FontSizeMixin<MaterialWidget> getFontSizeMixin() { if (fontSizeMixin == null) { fontSizeMixin = new FontSizeMixin<>(label); } return fontSizeMixin; }
Example #10
Source File: MaterialProgressTest.java From gwt-material with 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 #11
Source File: StatusDisplayMixin.java From gwt-material with 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 #12
Source File: MaterialStepperTest.java From gwt-material-addins with Apache License 2.0 | 5 votes |
public void testStructure() { // UiBinder // given MaterialWidget stepper = getWidget(); // when / then steps.forEach(step -> { int i = steps.indexOf(step) + 1; assertEquals(i, step.getStep()); assertEquals(step.getWidget(0), step.getHeader()); Div conCircle = step.getHeader(); assertEquals(step.getWidget(1), step.getDivLine()); Div conBody = step.getConBody(); assertEquals(step.getAxis(), Axis.HORIZONTAL); assertEquals(step.getDivCircle(), conCircle.getWidget(0)); assertEquals(step.getDivTitle(), conCircle.getWidget(1)); assertEquals(step.getDivDescription(), conCircle.getWidget(2)); step.setAxis(Axis.VERTICAL); assertEquals(step.getDivTitle(), conBody.getWidget(0)); assertEquals(step.getDivDescription(), conBody.getWidget(1)); assertEquals(step.getDivCircle(), conCircle.getWidget(0)); assertEquals(step.getDivLine(), conCircle.getWidget(1)); }); assertEquals(stepper.getWidgetCount(), 5); }
Example #13
Source File: StatusDisplayMixin.java From gwt-material with 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 #14
Source File: MaterialTreeTest.java From gwt-material-addins with Apache License 2.0 | 5 votes |
@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 #15
Source File: MaterialTreeTest.java From gwt-material-addins with Apache License 2.0 | 5 votes |
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 #16
Source File: MaterialSideNavMini.java From gwt-material with 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 #17
Source File: MaterialTreeTest.java From gwt-material-addins with Apache License 2.0 | 5 votes |
protected void checkTreeItemVisibility(MaterialWidget tree, boolean expand) { for (Widget widget : tree) { assertTrue(widget instanceof MaterialTreeItem); MaterialTreeItem item = (MaterialTreeItem) widget; if (expand) { assertTrue(item.isHide()); } else { assertFalse(item.isHide()); } } }
Example #18
Source File: EnabledMixin.java From gwt-material with 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 #19
Source File: MaterialWidgetTestCase.java From gwt-material with 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 #20
Source File: MaterialCutOut.java From gwt-material-addins with 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 #21
Source File: MaterialCardTest.java From gwt-material with 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 #22
Source File: MaterialWidgetTestCase.java From gwt-material with 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 #23
Source File: MaterialOverlayTab.java From gwt-material-addins with 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 #24
Source File: ColorHelper.java From gwt-material with 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 #25
Source File: MaterialWidgetTestCase.java From gwt-material with 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 #26
Source File: MaterialWidgetTestCase.java From gwt-material with 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 #27
Source File: MaterialWindowTest.java From gwt-material-addins with Apache License 2.0 | 5 votes |
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 #28
Source File: InfiniteScrollView.java From gwt-material-demo with 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 #29
Source File: MaterialSplitPanel.java From gwt-material-addins with 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); } } }
Example #30
Source File: LanguageSelector.java From gwt-material-addins with 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(); }