Skip to content

Commit

Permalink
Merge pull request #655 from GwtMaterialDesign/release_2.0
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
kevzlou7979 committed Oct 20, 2017
2 parents 22a420b + 5b48f51 commit c135530
Show file tree
Hide file tree
Showing 186 changed files with 10,413 additions and 6,417 deletions.
15 changes: 12 additions & 3 deletions README.md
Expand Up @@ -7,7 +7,7 @@
<br/>

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

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


## Maven
### Current Version 2.0-rc6
### Current Version 2.0-rc7
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.0-rc6</version>
<version>2.0-rc7</version>
</dependency>
```
### Snapshot Version 2.0-SNAPSHOT
Expand Down Expand Up @@ -64,6 +64,15 @@ Please follow the [contribution document](https://github.com/GwtMaterialDesign/g
<li><a href="https://github.com/GwtMaterialDesign/gwt-material-patterns" >Patterns</a></li>
</ul>

## JUnit Test

| Project | Number of Tests |
| --- | --- |
| gwt-material | 1545 |
| gwt-material-addins | 1048 |
| gwt-material-table | 100 |
| **Total Unit Tests** | **2693** |

## Testing Platform
<p>Many thanks to BrowserStack for sponsoring our Open Source projects</p>
<a href="https://www.browserstack.com/" target="_blank">
Expand Down
11 changes: 3 additions & 8 deletions gwt-material/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.0-rc6</version>
<version>2.0-rc7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-jquery</artifactId>
<version>2.0-rc6</version>
<version>2.0-rc7</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
Expand Down Expand Up @@ -58,18 +58,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
<includes>
<include>**/GwtMaterialTest*.java</include>
</includes>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
<additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
</additionalClasspathElements>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
<argLine>-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog</argLine>
</configuration>
</plugin>
<plugin>
Expand Down
Expand Up @@ -106,7 +106,7 @@ public static void injectCss(TextResource resource) {
StyleInjector.inject(resource.getText());
}

protected static boolean checkJQuery(boolean debug) {
public static boolean checkJQuery(boolean debug) {
if (!isjQueryLoaded()) {
if(isProvidingJQuery()) {
if (debug) {
Expand Down
Expand Up @@ -33,13 +33,12 @@
public abstract class AbstractButton extends MaterialWidget implements HasHref, HasGrid, HasActivates,
HasTargetHistoryToken, HasType<ButtonType> {

private final ActivatesMixin<AbstractButton> activatesMixin = new ActivatesMixin<>(this);
private final CssTypeMixin<ButtonType, AbstractButton> cssTypeMixin = new CssTypeMixin<>(this);

private String targetHistoryToken;
private Span span = new Span();
private ButtonSize size;

private String targetHistoryToken;
private ActivatesMixin<AbstractButton> activatesMixin;
private CssTypeMixin<ButtonType, AbstractButton> typeMixin;

/**
* Creates button with RAISED type.
Expand Down Expand Up @@ -105,23 +104,23 @@ public String getTarget() {
@Override
public void setActivates(String activates) {
removeStyleName(getActivates() + " " + CssName.DROPDOWN_BUTTON);
activatesMixin.setActivates(activates);
getActivatesMixin().setActivates(activates);
addStyleName(activates + " " + CssName.DROPDOWN_BUTTON);
}

@Override
public String getActivates() {
return activatesMixin.getActivates();
return getActivatesMixin().getActivates();
}

@Override
public void setType(ButtonType type) {
cssTypeMixin.setType(type);
getTypeMixin().setType(type);
}

@Override
public ButtonType getType() {
return cssTypeMixin.getType();
return getTypeMixin().getType();
}

/**
Expand Down Expand Up @@ -192,4 +191,18 @@ public String getTargetHistoryToken() {
public Span getSpan() {
return span;
}

protected ActivatesMixin<AbstractButton> getActivatesMixin() {
if (activatesMixin == null) {
activatesMixin = new ActivatesMixin<>(this);
}
return activatesMixin;
}

protected CssTypeMixin<ButtonType, AbstractButton> getTypeMixin() {
if (typeMixin == null) {
typeMixin = new CssTypeMixin<>(this);
}
return typeMixin;
}
}
Expand Up @@ -94,6 +94,11 @@ public void setIconColor(Color iconColor) {
icon.setIconColor(iconColor);
}

@Override
public Color getIconColor() {
return icon.getIconColor();
}

@Override
public void setIconPrefix(boolean prefix) {
icon.setIconPrefix(prefix);
Expand Down
Expand Up @@ -20,11 +20,9 @@
package gwt.material.design.client.base;

import com.google.gwt.dom.client.Element;
import com.google.gwt.editor.client.Editor;
import com.google.gwt.editor.client.EditorError;
import com.google.gwt.editor.client.HasEditorErrors;
import com.google.gwt.editor.client.LeafValueEditor;
import com.google.gwt.event.logical.shared.AttachEvent;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
Expand All @@ -47,12 +45,9 @@ public abstract class AbstractValueWidget<V> extends MaterialWidget implements H

private boolean allowBlank = true;
private BlankValidator<V> blankValidator;
private HandlerRegistration blurHandler, attachHandler;

private ValidatorMixin<AbstractValueWidget<V>, V> validatorMixin;

private ErrorMixin<AbstractValueWidget, ?> errorMixin;
private final ErrorHandlerMixin<V> errorHandlerMixin = new ErrorHandlerMixin<>(this);
private ErrorHandlerMixin<V> errorHandlerMixin;

public AbstractValueWidget(Element element) {
super(element);
Expand All @@ -74,9 +69,14 @@ public void setValue(V value, boolean fireEvents) {
}
}

@Override
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<V> handler) {
return addHandler(handler, ValueChangeEvent.getType());
public void setValue(V value, boolean fireEvents, boolean reload) {
setValue(value, fireEvents);

if (this instanceof HasReload) {
if (reload) {
((HasReload)this).reload();
}
}
}

@Override
Expand All @@ -101,27 +101,27 @@ public void clearErrorOrSuccess() {

@Override
public void showErrors(List<EditorError> errors) {
errorHandlerMixin.showErrors(errors);
getErrorHandlerMixin().showErrors(errors);
}

@Override
public ErrorHandler getErrorHandler() {
return errorHandlerMixin.getErrorHandler();
return getErrorHandlerMixin().getErrorHandler();
}

@Override
public void setErrorHandler(ErrorHandler errorHandler) {
errorHandlerMixin.setErrorHandler(errorHandler);
getErrorHandlerMixin().setErrorHandler(errorHandler);
}

@Override
public ErrorHandlerType getErrorHandlerType() {
return errorHandlerMixin.getErrorHandlerType();
return getErrorHandlerMixin().getErrorHandlerType();
}

@Override
public void setErrorHandlerType(ErrorHandlerType errorHandlerType) {
errorHandlerMixin.setErrorHandlerType(errorHandlerType);
getErrorHandlerMixin().setErrorHandlerType(errorHandlerType);
}

@Override
Expand Down Expand Up @@ -165,11 +165,6 @@ public boolean validate(boolean show) {
return getValidatorMixin().validate(show);
}

@Override
public HandlerRegistration addValidationChangedHandler(ValidationChangedEvent.ValidationChangedHandler handler) {
return getValidatorMixin().addValidationChangedHandler(handler);
}

/**
* Enable or disable the default blank validator.
*/
Expand Down Expand Up @@ -207,22 +202,22 @@ protected BlankValidator<V> createBlankValidator() {
protected void setupBlurValidation() {
final AbstractValueWidget inputWidget = getValidatorMixin().getInputWidget();
if (!inputWidget.isAttached()) {
if(attachHandler == null) {
attachHandler = inputWidget.addAttachHandler(event -> {
if (blurHandler == null) {
blurHandler = inputWidget.addBlurHandler(blurEvent -> {
validate(isValidateOnBlur());
});
}
});
}
registerHandler(inputWidget.addAttachHandler(attachEvent -> registerHandler(inputWidget.addBlurHandler(blurEvent -> validate(isValidateOnBlur())))));
} else {
if(blurHandler == null) {
blurHandler = inputWidget.addBlurHandler(event -> validate(isValidateOnBlur()));
}
registerHandler(inputWidget.addBlurHandler(blurEvent -> validate(isValidateOnBlur())));
}
}

@Override
public HandlerRegistration addValidationChangedHandler(ValidationChangedEvent.ValidationChangedHandler handler) {
return getValidatorMixin().addValidationChangedHandler(handler);
}

@Override
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<V> handler) {
return addHandler(handler, ValueChangeEvent.getType());
}

protected ValidatorMixin<AbstractValueWidget<V>, V> getValidatorMixin() {
if (validatorMixin == null) {
validatorMixin = new ValidatorMixin<>(this, getErrorHandler());
Expand All @@ -236,4 +231,11 @@ protected ValidatorMixin<AbstractValueWidget<V>, V> getValidatorMixin() {
}
return errorMixin;
}

protected ErrorHandlerMixin<V> getErrorHandlerMixin() {
if (errorHandlerMixin == null) {
errorHandlerMixin = new ErrorHandlerMixin<>(this);
}
return errorHandlerMixin;
}
}
Expand Up @@ -322,18 +322,6 @@ public void setAccessKey(char key) {
inputElem.setAccessKey("" + key);
}

/**
* Checks or unchecks this check box. Does not fire {@link ValueChangeEvent}.
* (If you want the event to fire, use {@link #setValue(Boolean, boolean)})
*
* @param checked <code>true</code> to check the check box.
* @deprecated Use {@link #setValue(Boolean)} instead
*/
@Deprecated
public void setChecked(boolean checked) {
setValue(checked);
}

/**
* {@inheritDoc}
* <p>
Expand Down Expand Up @@ -535,57 +523,4 @@ protected void onUnload() {
DOM.setEventListener(inputElem, null);
setValue(getValue());
}

/**
* Replace the current input element with a new one. Preserves all state
* except for the name property, for nasty reasons related to radio button
* grouping. (See implementation of {@link RadioButton#setName}.)
*
* @param elem the new input element
*/
protected void replaceInputElement(Element elem) {
replaceInputElement(DOM.asOld(elem));
}

/**
* @deprecated Call and use {@link #replaceInputElement(Element)} instead.
*/
@Deprecated
protected void replaceInputElement(com.google.gwt.user.client.Element elem) {
InputElement newInputElem = InputElement.as(elem);
// Collect information we need to set
int tabIndex = getTabIndex();
boolean checked = getValue();
boolean enabled = isEnabled();
String formValue = getFormValue();
String uid = inputElem.getId();
String accessKey = inputElem.getAccessKey();
int sunkEvents = Event.getEventsSunk(inputElem);

// Clear out the old input element
DOM.setEventListener(inputElem, null);

getElement().replaceChild(newInputElem, inputElem);

// Sink events on the new element
Event.sinkEvents(elem, Event.getEventsSunk(inputElem));
Event.sinkEvents(inputElem, 0);
inputElem = newInputElem;

// Setup the new element
Event.sinkEvents(inputElem, sunkEvents);
inputElem.setId(uid);
if (!"".equals(accessKey)) {
inputElem.setAccessKey(accessKey);
}
setTabIndex(tabIndex);
setValue(checked);
setEnabled(enabled);
setFormValue(formValue);

// Set the event listener
if (isAttached()) {
DOM.setEventListener(inputElem, this);
}
}
}

0 comments on commit c135530

Please sign in to comment.