List of usage examples for com.google.gwt.user.client.ui Widget addStyleName
public void addStyleName(String style)
From source file:gwt.material.design.addins.client.ui.MaterialSwipeablePanel.java
License:Apache License
public void setDisable(Widget... widgets) { for (Widget w : widgets) { w.addStyleName(DISABLED); } }
From source file:gwt.material.design.client.base.AbstractSideNav.java
License:Apache License
public Widget wrap(Widget child) { if (child instanceof MaterialImage) { child.getElement().getStyle().setProperty("border", "1px solid #e9e9e9"); child.getElement().getStyle().setProperty("textAlign", "center"); }//w w w. ja v a 2 s . c o m // Check whether the widget is not selectable by default boolean isNotSelectable = false; if (child instanceof MaterialWidget) { MaterialWidget widget = (MaterialWidget) child; if (widget.getInitialClasses() != null) { if (widget.getInitialClasses().length > 0) { if (child instanceof HasNoSideNavSelection) { isNotSelectable = true; } } } } if (!(child instanceof ListItem)) { // Direct list item not collapsible final ListItem listItem = new ListItem(); if (child instanceof MaterialCollapsible) { listItem.getElement().getStyle().setBackgroundColor("transparent"); } if (child instanceof HasWaves) { listItem.setWaves(((HasWaves) child).getWaves()); ((HasWaves) child).setWaves(null); } if (child instanceof HasNoSideNavSelection) { super.add(child); } else { listItem.add(child); child = listItem; } } // Collapsible and Side Porfile should not be selectable final Widget finalChild = child; if (!isNotSelectable) { // Active click handler registerHandler(finalChild.addDomHandler(event -> { clearActive(); finalChild.addStyleName(CssName.ACTIVE); }, ClickEvent.getType())); } child.getElement().getStyle().setDisplay(Style.Display.BLOCK); return child; }
From source file:gwt.material.design.client.base.helper.UiHelper.java
License:Apache License
/** * Adds a mouse pressed handler to a widget. Adds a CSS style to the widget * as long as the mouse is pressed (or the user touches the widget on mobile browser). * * @param widget The widget to which the style must be applied for mouse/touch event * @param cssStyleName CSS style name to be applied *//*from w ww.ja v a2s. c om*/ public static void addMousePressedHandlers(final Widget widget, final String cssStyleName) { widget.sinkEvents(Event.ONMOUSEDOWN); widget.sinkEvents(Event.ONMOUSEUP); widget.sinkEvents(Event.ONMOUSEOUT); widget.sinkEvents(Event.TOUCHEVENTS); widget.addHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent event) { widget.addStyleName(cssStyleName); } }, MouseDownEvent.getType()); widget.addHandler(new MouseUpHandler() { @Override public void onMouseUp(MouseUpEvent event) { widget.removeStyleName(cssStyleName); } }, MouseUpEvent.getType()); widget.addHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { widget.removeStyleName(cssStyleName); } }, MouseOutEvent.getType()); // Touch Events widget.addHandler(new TouchStartHandler() { @Override public void onTouchStart(TouchStartEvent event) { widget.addStyleName(cssStyleName); } }, TouchStartEvent.getType()); widget.addHandler(new TouchEndHandler() { @Override public void onTouchEnd(TouchEndEvent event) { widget.removeStyleName(cssStyleName); } }, TouchEndEvent.getType()); widget.addHandler(new TouchCancelHandler() { @Override public void onTouchCancel(TouchCancelEvent event) { widget.removeStyleName(cssStyleName); } }, TouchCancelEvent.getType()); }
From source file:gwt.material.design.client.base.mixin.ActiveMixin.java
License:Apache License
protected void applyActiveStyle(Widget widget, boolean active) { if (active) { widget.removeStyleName(CssName.INACTIVE); widget.addStyleName(CssName.ACTIVE); } else {// w ww. jav a 2 s. c om widget.removeStyleName(CssName.ACTIVE); widget.addStyleName(CssName.INACTIVE); } }
From source file:gwt.material.design.client.ui.animate.MaterialAnimator.java
License:Apache License
public static void animate(final Transition transition, final Widget w, int delayMillis, final Runnable callback) { final String name = String.valueOf(DOM.createUniqueId()); w.getElement().setId(name);/*ww w . j ava2 s.c o m*/ switch (transition) { case SHOW_STAGGERED_LIST: if (w instanceof UnorderedList) { UnorderedList ul = (UnorderedList) w; for (Widget li : ul) { if (li instanceof ListItem) { li.getElement().getStyle().setOpacity(0); } } } break; case SHOW_GRID: w.getElement().getStyle().setOpacity(0); break; default: // For core animation components w.addStyleName("animated " + transition.getCssName()); break; } new Timer() { @Override public void run() { callback.run(); switch (transition) { case SHOW_STAGGERED_LIST: showStaggeredList(name); break; case FADE_IN_IMAGE: fadeInImage(name); break; case SHOW_GRID: w.addStyleName("display-animation"); showGrid(name); break; case CLOSE_GRID: w.addStyleName("display-animation"); closeGrid(name); break; default: w.removeStyleName("animated " + transition.getCssName()); break; } } }.schedule(delayMillis); w.removeStyleName("materialcss"); }
From source file:gwt.material.design.client.ui.MaterialCardImage.java
License:Apache License
/** * {@inheritDoc}/* w w w.j a v a2s .c om*/ */ @Override public void add(final Widget child) { if (child instanceof MaterialImage) { child.addStyleName("activator"); } add(child, (Element) getElement()); }
From source file:gwt.material.design.client.ui.MaterialCollapsible.java
License:Apache License
public void setActive(int index) { clearActive();/*from w w w .j av a2 s. c o m*/ Widget activeWidget = getWidget(index); if (activeWidget != null) { activeWidget.addStyleName("active"); } }
From source file:gwt.material.design.client.ui.MaterialCollapsibleBody.java
License:Apache License
public void makeActive(Widget child) { parent.clearActive();/*w w w .jav a 2 s. c o m*/ // mark the collapsible item as active MaterialCollapsibleItem item = findCollapsibleItemParent(child); if (item != null) { item.expand(); } child.addStyleName("active"); }
From source file:gwt.material.design.client.ui.MaterialCollection.java
License:Apache License
public void setActive(int index) { this.index = index; Widget activeWidget = getActive(); if (activeWidget != null) { activeWidget.removeStyleName("active"); activeWidget.addStyleName("active"); }//from w w w . j a v a 2s. c o m }
From source file:gwt.material.design.client.ui.MaterialSideNav.java
License:Apache License
@Override public void add(Widget child) { if (child instanceof MaterialImage) { child.getElement().getStyle().setProperty("border", "1px solid #e9e9e9"); child.getElement().getStyle().setProperty("textAlign", "center"); }//from w w w . j ava 2 s . c om boolean collapsible = child instanceof MaterialCollapsible; if (collapsible) { // Since the collapsible is separ ((MaterialCollapsible) child).addClearActiveHandler(new ClearActiveHandler() { @Override public void onClearActive(ClearActiveEvent event) { clearActive(); } }); } if (!(child instanceof ListItem)) { // Direct list item not collapsible final ListItem listItem = new ListItem(); if (child instanceof MaterialCollapsible) { listItem.getElement().getStyle().setBackgroundColor("transparent"); } if (child instanceof HasWaves) { listItem.setWaves(((HasWaves) child).getWaves()); ((HasWaves) child).setWaves(null); } listItem.add(child); child = listItem; } // Collapsible's should not be selectable final Widget finalChild = child; if (!collapsible) { // Active click handler finalChild.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { clearActive(); finalChild.addStyleName("active"); } }, ClickEvent.getType()); } child.getElement().getStyle().setDisplay(Style.Display.BLOCK); super.add(child); }