Skip to content

Commit

Permalink
Merge pull request #857 from GwtMaterialDesign/release_2.1.1
Browse files Browse the repository at this point in the history
Release 2.1.1
  • Loading branch information
kevzlou7979 authored Aug 30, 2018
2 parents a8ba884 + 424a651 commit 86feefb
Show file tree
Hide file tree
Showing 17 changed files with 164 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cache:
- $HOME/.m2
before_install:
# install the gwt-material-jquery because it will depends on built in jquery
- git clone -b master https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- git clone -b release_2.1.1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- cd gwt-material-jquery
- mvn install -DskipTests=true -DdryRun=true
- cd ..
Expand Down
2 changes: 1 addition & 1 deletion .utility/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -ev
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.1.1" ]; then
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
mvn deploy --settings ~/settings.xml
fi
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- [PWA Support](https://github.com/GwtMaterialDesign/gwt-material/wiki/PWA-:-Service-Worker-Automation)

## Demo
* [2.1 Release Demo](http://gwtmaterialdesign.github.io/gwt-material-demo/)
* [2.1.1 Release Demo](http://gwtmaterialdesign.github.io/gwt-material-demo/)
* [2.2 Snapshot Demo](http://gwtmaterialdesign.github.io/gwt-material-demo/snapshot/)

## Documentation
Expand All @@ -20,20 +20,20 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs


## Maven
### Current Version 2.1
### Current Version 2.1.1
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.1</version>
<version>2.1.1</version>
</dependency>
```
### Snapshot Version 2.1.1-SNAPSHOT
### Snapshot Version 2.2-SNAPSHOT
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.2-SNAPSHOT</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions gwt-material/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.1</version>
<version>2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-jquery</artifactId>
<version>2.1</version>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import gwt.material.design.client.js.JsSideNavOptions;
import gwt.material.design.client.ui.*;
import gwt.material.design.client.ui.html.ListItem;
import gwt.material.design.jquery.client.api.JQueryElement;

import static gwt.material.design.client.js.JsMaterialElement.$;

Expand Down Expand Up @@ -401,6 +402,7 @@ protected MaterialWidget getNavMenu() {

protected void onClosing() {
open = false;
$("#sidenav-overlay").remove();
SideNavClosingEvent.fire(this);
}

Expand All @@ -410,17 +412,18 @@ protected void onClosed() {

protected void onOpening() {
open = true;
SideNavOpeningEvent.fire(this);
// Ensure to clean all the overlays attached before opening
// This will fixed multiple sidenav implementations with edge support.
$(".drag-target").remove();

$("#sidenav-overlay").each((param1, element) -> element.removeFromParent());
SideNavOpeningEvent.fire(this);
}

protected void onOpened() {
if (allowBodyScroll) {
RootPanel.getBodyElement().getStyle().clearOverflow();
}

String overlayZIndex = $("#sidenav-overlay").css("zIndex");
$(".drag-target").css("zIndex", (overlayZIndex != null ? Integer.parseInt(overlayZIndex) : 1) + "");
SideNavOpenedEvent.fire(this);
}

Expand Down Expand Up @@ -555,6 +558,14 @@ public Element getActivator() {
return activator;
}

public JQueryElement getOverlayElement() {
return $("#sidenav-overlay");
}

public JQueryElement getDragTargetElement() {
return $(".drag-target");
}

@Override
public HandlerRegistration addOpeningHandler(SideNavOpeningEvent.SideNavOpeningHandler handler) {
return addHandler(handler, SideNavOpeningEvent.TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ public final class EventHelper {

public static void onAttachOnce(HasAttachHandlers has, AttachEvent.Handler handler) {
HandlerRegistration[] reg = new HandlerRegistration[1];
reg[0] = has.addAttachHandler(event -> {
if(event.isAttached()) {
handler.onAttachOrDetach(event);

if (reg[0] != null) {
reg[0].removeHandler();
if (has.isAttached()) {
handler.onAttachOrDetach(null);
} else {
reg[0] = has.addAttachHandler(event -> {
if (event.isAttached()) {
handler.onAttachOrDetach(event);

if (reg[0] != null) {
reg[0].removeHandler();
}
}
}
});
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.*;
import gwt.material.design.client.base.mixin.CssTypeMixin;
import gwt.material.design.client.constants.CollapsibleType;
import gwt.material.design.client.constants.CssName;
import gwt.material.design.client.constants.Display;
import gwt.material.design.client.events.ClearActiveEvent;
import gwt.material.design.client.events.ClearActiveEvent.ClearActiveHandler;
import gwt.material.design.client.events.CollapseEvent;
import gwt.material.design.client.events.ExpandEvent;
import gwt.material.design.client.base.HasCollapsibleHandlers;

import static gwt.material.design.client.js.JsMaterialElement.$;

Expand Down Expand Up @@ -173,13 +174,24 @@ public void clearActive() {
ClearActiveEvent.fire(this);
}

@Override
protected void clearActiveClass(HasWidgets widget) {
super.clearActiveClass(widget);

for (Widget child : widget) {
if (child instanceof MaterialCollapsibleBody) {
((MaterialCollapsibleBody) child).setDisplay(Display.NONE);
}
}
}

/**
* Open the given collapsible item.
*
* @param index the one-based collapsible item index.
*/
public void open(int index) {
setActive(index, true);
setActive(index);
}

/**
Expand Down Expand Up @@ -236,7 +248,9 @@ public boolean isAccordion() {

@Override
public void setActive(int index) {
clearActive();
if (isAccordion()) {
clearActive();
}
setActive(index, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void setActive(boolean active) {
header.removeStyleName(CssName.ACTIVE);
}
if (active) {
if (parent != null) {
if (parent != null && parent.isAccordion()) {
parent.clearActive();
}
addStyleName(CssName.ACTIVE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ public void reload() {

/**
* As of now use {@link MaterialDatePicker#setSelectionType(MaterialDatePickerType)}
*
* @param type
*/
@Deprecated
public void setDateSelectionType(MaterialDatePickerType type) {
Expand Down Expand Up @@ -399,28 +397,23 @@ public void setFormat(String format) {

@Override
public Date getValue() {
if (isAttached()) {
return getPickerDate();
}
else {
return this.date;
}
return isAttached() ? getPickerDate() : this.date;
}

@Override
public void setValue(Date value, boolean fireEvents) {
this.date = value;
if (value == null) {
clear();
return;
}
if (isAttached()) {
suppressChangeEvent = !fireEvents;
setPickerDate(JsDate.create((double) value.getTime()), pickatizedDateInput);
suppressChangeEvent = false;
label.addStyleName(CssName.ACTIVE);
} else {
if (isAttached()) {
suppressChangeEvent = !fireEvents;
setPickerDate(JsDate.create((double) value.getTime()), pickatizedDateInput);
suppressChangeEvent = false;
label.addStyleName(CssName.ACTIVE);
}
super.setValue(value, fireEvents);
}
super.setValue(value, fireEvents);
}

@Override
Expand Down Expand Up @@ -476,7 +469,7 @@ protected void setupLanguage(DatePickerLanguage language) {
if (language.getJs() != null) {
ScriptInjector.fromString(language.getJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
getPicker().stop();
Scheduler.get().scheduleDeferred(() -> load());
Scheduler.get().scheduleDeferred(this::load);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,11 @@ public void setValue(T value) {
@Override
public void setValue(T value, boolean fireEvents) {
int index = values.indexOf(value);
if (index >= 0) {
if (index < 0 && value instanceof String) {
index = getIndexByString((String) value);
}

if (index > -1) {
T before = getValue();
setSelectedIndexInternal(index);

Expand All @@ -637,6 +641,28 @@ public void setValue(T value, boolean fireEvents) {
}
}

// TODO: Optimize performance (maybe use a map)
public T getValueByString(String key) {
for (T value : values) {
if (keyFactory.generateKey(value).equals(key)) {
return value;
}
}
return null;
}

// TODO: Optimize performance (maybe use a map)
public int getIndexByString(String key) {
int index = -1;
for (T value : values) {
index++;
if (keyFactory.generateKey(value).equals(key)) {
return index;
}
}
return index;
}

public boolean isOld() {
return getToggleOldMixin().isOn();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@
//@formatter:on
public class MaterialRange extends AbstractValueWidget<Integer> implements HasChangeHandlers, HasStatusText {

private static String VALUE = "value";
private static String MAX = "max";
private static String MIN = "min";

private Paragraph paragraph = new Paragraph();
private MaterialInput rangeInputElement = new MaterialInput();
private Span thumb = new Span();
private Span value = new Span();
private static String VALUE = "value";
private static String MAX = "max";
private static String MIN = "min";

private MaterialLabel errorLabel = new MaterialLabel();
private StatusTextMixin<AbstractValueWidget, MaterialLabel> statusTextMixin;

Expand Down Expand Up @@ -195,41 +197,6 @@ public void setMax(Integer max) {
setIntToRangeElement(MAX, max);
}

@Override
public void setErrorText(String errorText) {
getStatusTextMixin().setErrorText(errorText);
}

@Override
public void setSuccessText(String successText) {
getStatusTextMixin().setSuccessText(successText);
}

@Override
public void setHelperText(String helperText) {
getStatusTextMixin().setHelperText(helperText);
}

@Override
public void clearStatusText() {
getStatusTextMixin().clearStatusText();
}

@Override
public void clearErrorText() {
getStatusTextMixin().clearErrorText();
}

@Override
public void clearHelperText() {
getStatusTextMixin().clearHelperText();
}

@Override
public void clearSuccessText() {
getStatusTextMixin().clearSuccessText();
}

public MaterialLabel getErrorLabel() {
return errorLabel;
}
Expand Down
Loading

0 comments on commit 86feefb

Please sign in to comment.