Skip to content

Commit

Permalink
Merge branch 'release_2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
kevzlou7979 committed Jun 11, 2019
2 parents 4183bbf + 17a67c2 commit d0e40b3
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 24 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs


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

Expand Down
2 changes: 1 addition & 1 deletion 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.2-rc1</version>
<version>2.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public void updateStatusDisplay(StatusType statusType) {
}

if (uiObject instanceof HasWidgets && uiObject instanceof MaterialWidget) {
MaterialWidget widget = ((MaterialWidget) uiObject);
if (container != null && container instanceof MaterialWidget) {
((MaterialWidget) container).insert(statusIcon, 0);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public boolean isValid(T value) {
if (value instanceof Collection<?>) {
return ((Collection<?>) value).size() > 0;
}
return value != null && !"".equals(value.toString());
return value != null && !"".equals(value.toString().trim());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,16 @@
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.ValueBoxBase;
import com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.*;
import gwt.material.design.client.base.mixin.*;
import gwt.material.design.client.constants.*;
import gwt.material.design.client.events.DragEndEvent;
import gwt.material.design.client.events.DragEnterEvent;
import gwt.material.design.client.events.DragLeaveEvent;
import gwt.material.design.client.events.*;
import gwt.material.design.client.events.DragOverEvent;
import gwt.material.design.client.events.DragStartEvent;
import gwt.material.design.client.events.DropEvent;
import gwt.material.design.client.events.*;
import gwt.material.design.client.ui.html.Label;

//@formatter:off
Expand Down Expand Up @@ -87,7 +86,6 @@ public class MaterialValueBox<T> extends AbstractValueWidget<T> implements HasCh
private FocusableMixin<MaterialWidget> focusableMixin;
private ActiveMixin<MaterialValueBox> activeMixin;
private FieldTypeMixin<MaterialValueBox> fieldTypeMixin;
private AttributeMixin<Widget> autocompleteAttributeMixin;

public class MaterialValueBoxEditor<V> extends ValueBoxEditor<V> {
private final ValueBoxBase<V> valueBoxBase;
Expand Down Expand Up @@ -534,12 +532,12 @@ public void setFieldWidth(double percentWidth) {

@Override
public void setAutocomplete(boolean value) {
getAutocompleteAttributeMixin().setAttribute(value ? "on" : "off");
valueBoxBase.getElement().setAttribute("autocomplete", value ? "on" : "off");
}

@Override
public boolean isAutocomplete() {
return getAutocompleteAttributeMixin().getAttributeAsBoolean();
return valueBoxBase.getElement().getAttribute("autocomplete").equals("on");
}

@Ignore
Expand Down Expand Up @@ -877,11 +875,4 @@ protected FieldTypeMixin<MaterialValueBox> getFieldTypeMixin() {
}
return fieldTypeMixin;
}

public AttributeMixin<Widget> getAutocompleteAttributeMixin() {
if (autocompleteAttributeMixin == null) {
autocompleteAttributeMixin = new AttributeMixin<>(valueBoxBase, "autocomplete");
}
return autocompleteAttributeMixin;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4174,7 +4174,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
P.$root.addClass( CLASSES.opened )
aria( P.$root[0], 'hidden', false )

}, 100 )
}, 0 )

// If we have to give focus, bind the element and doc events.
if ( dontGiveFocus !== false ) {
Expand Down Expand Up @@ -4574,6 +4574,14 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
readonly: false,
owns: ELEMENT.id + '_root'
})

// Chrome 73 suggested solution for DatePicker being fubared when opening.
// Refer to https://github.com/GwtMaterialDesign/gwt-material/commit/0670c85ce2a1ee2c28be906fb12f4c0435321ce6
document.querySelector("#" + ELEMENT.id).addEventListener('pointerdown', function (event) {
if (event.target && event.target.setPointerCapture) {
event.target.setPointerCapture(event.pointerId)
}
});
}


Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.ValueBoxBase;
import gwt.material.design.client.constants.StatusDisplayType;
import gwt.material.design.client.ui.base.AbstractValueWidgetTest;

/**
Expand Down Expand Up @@ -73,6 +74,65 @@ public void testValueReturnAsNull() {
}
}

public void testAutocomplete() {
T widget = getWidget();

checkAutocomplete(widget);
}

public void testMandatoryField() {
T widget = getWidget(false);

checkMandatoryField(widget);

attachWidget();

checkMandatoryField(widget);
}

public void testStatusDisplayType() {
T widget = getWidget(false);

assertEquals(null, widget.getStatusDisplayType());

widget.setStatusDisplayType(StatusDisplayType.DEFAULT);
assertEquals(StatusDisplayType.DEFAULT, widget.getStatusDisplayType());
assertTrue(widget.getElement().hasClassName(StatusDisplayType.DEFAULT.getCssName()));

widget.setStatusDisplayType(StatusDisplayType.HOVERABLE);
assertEquals(StatusDisplayType.HOVERABLE, widget.getStatusDisplayType());
assertTrue(widget.getElement().hasClassName(StatusDisplayType.HOVERABLE.getCssName()));
}

protected <W extends MaterialValueBox> void checkMandatoryField(W widget) {
String REQUIRED = "required";
assertFalse(widget.isRequired());

widget.setRequired(true);
assertTrue(widget.isRequired());
assertTrue(widget.getStatusTextMixin().getPlaceholder().getElement().hasClassName(REQUIRED));

widget.setRequired(false);
assertFalse(widget.isRequired());
assertFalse(widget.getStatusTextMixin().getPlaceholder().getElement().hasClassName(REQUIRED));
}

protected <W extends MaterialValueBox> void checkAutocomplete(W widget) {
ValueBoxBase valueBoxBase = widget.getValueBoxBase();
assertFalse(widget.isAutocomplete());
assertFalse(valueBoxBase.getElement().hasAttribute("autocomplete"));

widget.setAutocomplete(true);
assertTrue(widget.isAutocomplete());
assertEquals(valueBoxBase.getElement().getAttribute("autocomplete"), "on");

widget.setAutocomplete(false);
assertFalse(widget.isAutocomplete());
assertEquals(valueBoxBase.getElement().getAttribute("autocomplete"), "off");

valueBoxBase.getElement().removeAttribute("autocomplete");
}

protected void checkValueReturnAsNull(T widget) {
assertTrue(widget.isBlank());
assertFalse(widget.isReturnBlankAsNull());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public void testType() {
widget.setType(ButtonType.OUTLINED);
assertEquals(ButtonType.OUTLINED, widget.getType());

widget.setType(ButtonType.GHOST);
assertEquals(ButtonType.GHOST, widget.getType());

// Standard
// given
attachWidget();
Expand All @@ -96,6 +99,9 @@ public void testType() {

widget.setType(ButtonType.OUTLINED);
assertTrue(element.hasClassName(ButtonType.OUTLINED.getCssName()));

widget.setType(ButtonType.GHOST);
assertTrue(element.hasClassName(ButtonType.GHOST.getCssName()));
}

public void testActivates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,16 @@ public void testIcon() {
icon.setIconFontSize(2, Style.Unit.PX);
assertEquals("2px", icon.getElement().getStyle().getFontSize());
}

public void testCustomIcon() {
final String CUSTOM_ICON = "fas_custom";
T widget = getWidget();
widget.setCustomIconType(CUSTOM_ICON);
assertEquals(CUSTOM_ICON, widget.getCustomIconType());
assertTrue(widget.getIcon().getElement().hasClassName(CUSTOM_ICON));

widget.setCustomIconType(null);
assertNull(widget.getCustomIconType());
assertFalse(widget.getIcon().getElement().hasClassName(CUSTOM_ICON));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@
@Ignore
public abstract class AbstractValueWidgetTest<T extends AbstractValueWidget> extends MaterialWidgetTest<T> {


}
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,82 @@ public void testTransform() {
assertEquals(FINAL_TRANSFORM_VALUE, widget.getElement().getStyle().getProperty("transform"));
}

public void testCursor() {
// UiBinder
// given
T widget = getWidget(false);

checkCursor(widget);

// Standard
// given
attachWidget();

// when / then
checkCursor(widget);
}

public void testValignWrapper() {
// UiBinder
// given
T widget = getWidget(false);

checkCursor(widget);

// Standard
// given
attachWidget();

// when / then
checkCursor(widget);
}

protected <W extends MaterialWidget> void checkValignWrapper(W widget) {
assertFalse(widget.isValignWrapper());
assertFalse(widget.getElement().hasClassName(CssName.VALIGN_WRAPPER));

assertFalse(widget.isContainerEnabed());
assertFalse(widget.getElement().hasClassName(CssName.CONTAINER));

widget.setValignWrapper(true);
assertTrue(widget.isValignWrapper());
assertTrue(widget.getElement().hasClassName(CssName.VALIGN_WRAPPER));

widget.setValignWrapper(false);
assertFalse(widget.isValignWrapper());
assertFalse(widget.getElement().hasClassName(CssName.VALIGN_WRAPPER));

widget.setContainerEnabled(true);
assertTrue(widget.isContainerEnabed());
assertTrue(widget.getElement().hasClassName(CssName.CONTAINER));

widget.setContainerEnabled(false);
assertFalse(widget.isContainerEnabed());
assertFalse(widget.getElement().hasClassName(CssName.CONTAINER));
}

protected <W extends MaterialWidget> void checkCursor(W widget) {
widget.setCursor(Style.Cursor.POINTER);
assertEquals(Style.Cursor.POINTER.getCssName().toLowerCase(), widget.getCursor());
assertEquals(Style.Cursor.POINTER.getCssName().toLowerCase(), widget.getElement().getStyle().getCursor());

widget.setCursor(Style.Cursor.DEFAULT);
assertEquals(Style.Cursor.DEFAULT.getCssName().toLowerCase(), widget.getCursor());
assertEquals(Style.Cursor.DEFAULT.getCssName().toLowerCase(), widget.getElement().getStyle().getCursor());

widget.setCursor(Style.Cursor.AUTO);
assertEquals(Style.Cursor.AUTO.getCssName().toLowerCase(), widget.getCursor());
assertEquals(Style.Cursor.AUTO.getCssName().toLowerCase(), widget.getElement().getStyle().getCursor());

widget.setCursor(Style.Cursor.HELP);
assertEquals(Style.Cursor.HELP.getCssName().toLowerCase(), widget.getCursor());
assertEquals(Style.Cursor.HELP.getCssName().toLowerCase(), widget.getElement().getStyle().getCursor());

widget.setCursor(Style.Cursor.TEXT);
assertEquals(Style.Cursor.TEXT.getCssName().toLowerCase(), widget.getCursor());
assertEquals(Style.Cursor.TEXT.getCssName().toLowerCase(), widget.getElement().getStyle().getCursor());
}

protected <W extends HasPlaceholder> void checkPlaceholder(W widget) {
// when / then
widget.setPlaceholder("Placeholder");
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-parent</artifactId>
<version>2.2-rc1</version>
<version>2.2</version>
<packaging>pom</packaging>
<modules>
<module>gwt-material</module>
Expand Down Expand Up @@ -65,7 +65,7 @@
<connection>scm:git:git@github.com:GwtMaterialDesign/gwt-material.git</connection>
<developerConnection>scm:git:git@github.com:GwtMaterialDesign/gwt-material.git</developerConnection>
<url>http://github.com/GwtMaterialDesign/gwt-material</url>
<tag>v2.2-rc1</tag>
<tag>v2.2</tag>
</scm>

<licenses>
Expand Down

0 comments on commit d0e40b3

Please sign in to comment.