Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

Gwt Material Design Extra Components for https://github.com/GwtMaterialDesign/gwt-material <br>

## Current Version 2.8.3
## Current Version 2.8.5
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-addins</artifactId>
<version>2.8.3</version>
<version>2.8.5</version>
</dependency>
```

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 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.8.3</version>
<version>2.8.5</version>
</parent>

<artifactId>gwt-material-addins</artifactId>
Expand All @@ -24,7 +24,7 @@
<connection>scm:git:[email protected]:GwtMaterialDesign/gwt-material-addins.git</connection>
<developerConnection>scm:git:[email protected]:GwtMaterialDesign/gwt-material-addins.git</developerConnection>
<url>http://github.com/GwtMaterialDesign/gwt-material-addins</url>
<tag>v2.8.3</tag>
<tag>v2.8.5</tag>
</scm>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class MaterialComboBox<T> extends AbstractValueWidget<List<T>> implements
protected List<T> values = new ArrayList<>();
private Label label = new Label();
private MaterialLabel errorLabel = new MaterialLabel();
private MaterialLabel helperText = new MaterialLabel();
protected MaterialWidget listbox = new MaterialWidget(Document.get().createSelectElement());
private KeyFactory<T, String> keyFactory = new AllowBlankKeyFactory<>();
private JsComboBoxOptions options = JsComboBoxOptions.create();
Expand Down Expand Up @@ -150,6 +151,8 @@ protected void onLoad() {
addWidget(listbox);
addWidget(label);
addWidget(errorLabel);
helperText.addStyleName("help-description");

errorLabel.setMarginTop(8);
listbox.setGwtDisplay(Style.Display.BLOCK);

Expand Down Expand Up @@ -341,7 +344,7 @@ public void clear() {
final Iterator<Widget> it = iterator();
while (it.hasNext()) {
final Widget widget = it.next();
if (widget != label && widget != errorLabel && widget != listbox) {
if (widget != label && widget != errorLabel && widget != listbox && widget != helperText) {
it.remove();
}
}
Expand Down Expand Up @@ -627,6 +630,11 @@ public void setSingleValue(T value) {
setValue(Collections.singletonList(value));
}

public void setSingleValue(T value, String text, boolean addAsDefault) {
setValue(Collections.singletonList(value));
addItem(text, value);
}

/**
* Set the selected value using a single item, generally used
* in single selection mode.
Expand Down Expand Up @@ -1376,4 +1384,10 @@ public AsyncWidgetMixin<MaterialComboBox, List<T>> getAsyncWidgetMixin() {
}
return asyncWidgetMixin;
}

@Override
public void setHelperText(String helperText) {
this.helperText.setText(helperText);
addWidget(this.helperText);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class AbstractInputMask<T> extends MaterialValueBox<T>
}

private String mask;
protected boolean autoReload;
protected JsInputMaskOptions options = new JsInputMaskOptions();

public AbstractInputMask() {
Expand Down Expand Up @@ -196,6 +197,21 @@ public void setValue(T value) {
super.setValue(value);
}

@Override
public void setValue(T value, boolean fireEvents) {
super.setValue(value, fireEvents);

if (autoReload) reload();
}

public boolean isAutoReload() {
return autoReload;
}

public void setAutoReload(boolean autoReload) {
this.autoReload = autoReload;
}

@Override
public HandlerRegistration addCompleteHandler(CompleteEvent.CompleteHandler handler) {
return addHandler(handler, CompleteEvent.TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package gwt.material.design.addins.client.inputmask;

import com.google.gwt.editor.client.EditorError;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.logical.shared.InitializeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
Expand All @@ -35,13 +36,14 @@
import gwt.material.design.client.events.ToggleReadOnlyEvent;

import java.util.Date;
import java.util.List;

public class MaterialDateInputMask extends AbstractValueWidget<Date>
implements HasFieldTypes, HasLabel, HasInputMaskHandlers, HasPlaceholder, HasReadOnly, HasActive, HasToggleReadOnlyHandler, HasAutocomplete, HasPasteHandlers, HasFieldSensitivity {

private String format = "YYYY-mm-dd";
private MaterialInputMask inputMask;
private DateInputParser inputParser;
protected String format = "YYYY-mm-dd";
protected MaterialInputMask inputMask;
protected DateInputParser inputParser;

public MaterialDateInputMask() {
super(DOM.createDiv());
Expand All @@ -50,8 +52,8 @@ public MaterialDateInputMask() {
inputParser = new DateInputParser(inputMask);
inputMask.setPlaceholder(format.toUpperCase());
setMask(format);

setValidateOnBlur(true);
addStyleName("input-field date-mask");
}

@Override
Expand All @@ -65,6 +67,16 @@ protected void onLoad() {
});
}

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

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

public void setMask(String mask) {
this.format = mask
.replace("m", "M")
Expand Down Expand Up @@ -208,6 +220,22 @@ public HandlerRegistration addPasteHandler(PasteEvent.PasteEventHandler handler)
return inputMask.addPasteHandler(handler);
}

public DateInputParser getInputParser() {
return inputParser;
}

public void setInputParser(DateInputParser inputParser) {
this.inputParser = inputParser;
}

public MaterialInputMask getInputMask() {
return inputMask;
}

public void setInputMask(MaterialInputMask inputMask) {
this.inputMask = inputMask;
}

@Override
public String getPlaceholder() {
return inputMask.getPlaceholder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class DateInputParser<T extends AbstractInputMask<String>> {

private final T valuebox;
protected final T valuebox;

public DateInputParser(T valuebox) {
this.valuebox = valuebox;
Expand All @@ -43,33 +43,39 @@ public Date parseDate(String format) {
public void setValue(String format, Date value) {
if (value != null) {
valuebox.setValue(DateTimeFormat.getFormat(format).format(value), true);
} else {
valuebox.clear();
}
}

public boolean validate(String format) {
if (valuebox.getText() != null && !valuebox.getText().isEmpty()
&& valuebox.getMask() != null && format != null) {
format = format.toLowerCase();
String dateString = valuebox.getText();
String month = dateString.substring(format.indexOf("m"), format.indexOf("m") + 2);
String day = dateString.substring(format.indexOf("d"), format.indexOf("d") + 2);
String year = dateString.substring(format.indexOf("y"), format.lastIndexOf("y") + 1);

boolean validLeapYear = validateLeapYear(day, month, Integer.parseInt(year));
if (!validLeapYear) {
valuebox.setErrorText("Not a valid date");
try {
if (valuebox.getText() != null && !valuebox.getText().isEmpty()
&& valuebox.getMask() != null && format != null) {
format = format.toLowerCase();
String dateString = valuebox.getValueWithMask();
String month = dateString.substring(format.indexOf("m"), format.indexOf("m") + 2);
String day = dateString.substring(format.indexOf("d"), format.indexOf("d") + 2);
String year = dateString.substring(format.indexOf("y"), format.lastIndexOf("y") + 1);

boolean validLeapYear = validateLeapYear(day, month, Integer.parseInt(year));
if (!validLeapYear) {
valuebox.setErrorText("Not a valid date");
}

boolean valid = validate(month, getMonthRegex(), getMothDoesNotMatchError())
&& validate(day, getDayRegex(), getDayDoesNotMatchError())
&& validate(year, getYearRegex(), getYearDoesNotMatchError())
&& validLeapYear;

if (valid) {
valuebox.clearStatusText();
}

return valid;
}

boolean valid = validate(month, getMonthRegex(), getMothDoesNotMatchError())
&& validate(day, getDayRegex(), getDayDoesNotMatchError())
&& validate(year, getYearRegex(), getYearDoesNotMatchError())
&& validLeapYear;

if (valid) {
valuebox.clearStatusText();
}

return valid;
} catch (Exception e) {
valuebox.setErrorText("Not a valid date");
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,7 @@ public class Moment {
*/
@JsMethod
public native String toJDFString(String format);

public native MomentTimezone tz(String timeZone);

@JsMethod(namespace = "moment")
public static native void updateLocale(String locale, LocaleOptions localeOptions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@
*/
package gwt.material.design.addins.client.moment;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "moment")
public class MomentTimezone {
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "moment.tz")
public class MomentTimezone extends Moment {

@JsConstructor
public MomentTimezone(String date, String timezone) { // moment.tz("asd", "asd")

}

public native MomentTimezone zone(String timeZone);

public native String format(String format);

@JsMethod(namespace = "moment.tz")
@JsMethod
public static native String guess();

public native MomentTimezone add(int amount, String unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ public class DateRangePicker extends AbstractValueWidget<Date[]> implements HasD
static {
if (AddinsIncubator.isDebug()) {
MaterialDesignBase.injectDebugJs(MomentClientDebugBundle.INSTANCE.momentDebugJs());
MaterialDesignBase.injectDebugJs(MomentClientDebugBundle.INSTANCE.momentLocale());
MaterialDesignBase.injectDebugJs(MomentClientDebugBundle.INSTANCE.momentJDateConverterDebugJs());
MaterialDesignBase.injectDebugJs(MomentClientDebugBundle.INSTANCE.momentWithTimezone());
MaterialDesignBase.injectDebugJs(DateRangeClientDebugBundle.INSTANCE.dateRangePickerDebugJs());
MaterialDesignBase.injectCss(DateRangeClientDebugBundle.INSTANCE.dateRangePickerDebugCss());
MaterialDesignBase.injectCss(DateRangeClientDebugBundle.INSTANCE.dateRangePickerOverrideDebugCss());
} else {
MaterialDesignBase.injectJs(MomentClientBundle.INSTANCE.momentJs());
MaterialDesignBase.injectJs(MomentClientBundle.INSTANCE.momentWithLocale());
MaterialDesignBase.injectJs(MomentClientBundle.INSTANCE.momentJDateConverterJs());
MaterialDesignBase.injectJs(MomentClientBundle.INSTANCE.momentWithTimezone());
MaterialDesignBase.injectJs(DateRangeClientBundle.INSTANCE.dateRangePickerJs());
MaterialDesignBase.injectCss(DateRangeClientBundle.INSTANCE.dateRangePickerCss());
MaterialDesignBase.injectCss(DateRangeClientBundle.INSTANCE.dateRangePickerOverrideCss());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,13 @@ public void setTypes(AddressType... types) {
* Will identify the {@link GeocoderAddressComponent} and will return it's value based on {@link AddressComponentType}
*/
public GeocoderAddressComponent getAddressComponent(AddressComponentType addressComponentType) {
for (GeocoderAddressComponent component : getPlace().getAddressComponents()) {
for (String type : component.getTypes()) {
if (addressComponentType.getName().equals(type)) {
return component;
PlaceResult place = getPlace();
if (place != null) {
for (GeocoderAddressComponent component : getPlace().getAddressComponents()) {
for (String type : component.getTypes()) {
if (addressComponentType.getName().equals(type)) {
return component;
}
}
}
}
Expand Down