Skip to content

Commit

Permalink
Merge pull request #499 from GwtMaterialDesign/release_2.0
Browse files Browse the repository at this point in the history
Preparation for 2.0-rc2 release
  • Loading branch information
kevzlou7979 committed Nov 11, 2016
2 parents 684eedc + 56c8ebc commit b7212cf
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -6,7 +6,7 @@
<br/>

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

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


## Maven
### Current Version 2.0-rc1
### Current Version 2.0-rc2
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.0-rc1</version>
<version>2.0-rc2</version>
</dependency>
```
### Snapshot Version 2.0-SNAPSHOT
Expand Down
4 changes: 2 additions & 2 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-SNAPSHOT</version>
<version>2.0-rc2</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>1.0-SNAPSHOT</version>
<version>1.0-rc2</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
Expand Down
Expand Up @@ -20,15 +20,29 @@
* #L%
*/


import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.ui.RootPanel;
import gwt.material.design.client.base.MaterialWidget;
import gwt.material.design.client.constants.Color;

public class ColorHelper {

/**
* Returns first enum constant found..
*
* @param styleName Space-separated list of styles
* @param enumClass Type of enum
* @param defaultValue Default value of no match was found
* @return First enum constant found or default value
*/
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
final Class<E> enumClass,
final E defaultValue) {
return EnumHelper.fromStyleName(styleName, enumClass, defaultValue, true);
}

public static String setupComputedBackgroundColor(Color color) {
MaterialWidget temp = new MaterialWidget(Document.get().createDivElement());
temp.setBackgroundColor(color);
Expand All @@ -45,5 +59,4 @@ protected static native String getComputedBackgroundColor(Element e)/*-{
var cs = $wnd.document.defaultView.getComputedStyle(e, null);
return cs.getPropertyValue('background-color');
}-*/;

}
Expand Up @@ -35,10 +35,25 @@ public final class EnumHelper {
* @param defaultValue Default value of no match was found
* @return First enum constant found or default value
*/
@SuppressWarnings("unchecked")
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
final Class<E> enumClass,
final E defaultValue) {
return EnumHelper.fromStyleName(styleName, enumClass, defaultValue, false);
}

/**
* Returns first enum constant found in at space-separated list of style names.
*
* @param styleName Space-separated list of styles
* @param enumClass Type of enum
* @param defaultValue Default value of no match was found
* @return First enum constant found or default value
*/
@SuppressWarnings("unchecked")
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
final Class<E> enumClass,
final E defaultValue,
final boolean ignoreSpaces) {
if (styleName == null || enumClass == null) {
return defaultValue;
}
Expand All @@ -47,8 +62,16 @@ public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final
final Style.HasCssName anEnum = (Style.HasCssName) constant;
final String cssClass = anEnum.getCssName();

if (cssClass != null && StyleHelper.containsStyle(styleName, cssClass)) {
return (E) anEnum;
if(cssClass != null) {
boolean contains;
if (ignoreSpaces) {
contains = styleName.equals(cssClass);
} else {
contains = StyleHelper.containsStyle(styleName, cssClass);
}
if (contains) {
return (E) anEnum;
}
}
}
return defaultValue;
Expand Down
Expand Up @@ -105,7 +105,6 @@ public static <E extends Style.HasCssName> void removeEnumStyleName(final UIObje
*/
public static boolean containsStyle(final String styleNames,
final String style) {

if (styleNames == null || style == null) {
return false;
}
Expand Down
Expand Up @@ -320,12 +320,12 @@ public void setHtml(String html) {

Element element = widget.getElement();
if (widget.isAttached()) {
JsMaterialElement.$("#" + element.getAttribute("data-tooltip-id"))
$("#" + element.getAttribute("data-tooltip-id"))
.find("span")
.html(html != null ? html : "");
} else {
htmlAttachHandler = widget.addAttachHandler(attachEvent -> {
JsMaterialElement.$("#" + element.getAttribute("data-tooltip-id"))
$("#" + element.getAttribute("data-tooltip-id"))
.find("span")
.html(html != null ? html : "");
});
Expand Down
Expand Up @@ -65,8 +65,6 @@ public int getIndex() {
return OptionElement.as(this.getElement()).getIndex();
}

;

/**
* Option label for use in hierarchical menus.
*
Expand Down Expand Up @@ -130,8 +128,6 @@ public boolean isSelected() {
return OptionElement.as(this.getElement()).isSelected();
}

;

/**
* Represents the value of the HTML selected attribute. The value of this
* attribute does not change if the state of the corresponding form control,
Expand All @@ -145,8 +141,6 @@ public void setDefaultSelected(boolean selected) {
OptionElement.as(this.getElement()).setDefaultSelected(selected);
}

;

/**
* The control is unavailable in this context.
*
Expand All @@ -158,8 +152,6 @@ public void setDisabled(boolean disabled) {
OptionElement.as(this.getElement()).setDisabled(disabled);
}

;

/**
* Option label for use in hierarchical menus.
*
Expand Down Expand Up @@ -199,4 +191,9 @@ public void setValue(String value) {
OptionElement.as(this.getElement()).setValue(value);
}

@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
setDisabled(!enabled);
}
}
Expand Up @@ -24,6 +24,7 @@
import gwt.material.design.client.resources.WithJQueryResources;
import gwt.material.design.client.ui.*;
import gwt.material.design.client.ui.animation.AnimationTest;
import gwt.material.design.client.ui.base.helper.ColorHelperTest;
import org.junit.Test;

import static gwt.material.design.jquery.client.api.JQuery.$;
Expand Down Expand Up @@ -58,6 +59,11 @@ public void setup() {
assertNotNull($("body"));
}

@Test
public void testHelpers() {
new ColorHelperTest();
}

@Test
public void testAnimation() {
new AnimationTest().init();
Expand Down
@@ -0,0 +1,39 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2016 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.ui.base.helper;

import gwt.material.design.client.base.helper.ColorHelper;
import gwt.material.design.client.constants.Color;
import junit.framework.TestCase;

/**
* Test case for {@link gwt.material.design.client.base.helper.ColorHelper}.
*/
public class ColorHelperTest extends TestCase {

public ColorHelperTest() {
checkFromStyleName();
}

private void checkFromStyleName() {
assertEquals(Color.PINK_LIGHTEN_1,
ColorHelper.fromStyleName("pink lighten-1", Color.class, Color.DEFAULT));
}
}
@@ -0,0 +1,47 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2016 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.ui.base.helper;

import gwt.material.design.client.base.helper.ColorHelper;
import gwt.material.design.client.base.helper.EnumHelper;
import gwt.material.design.client.base.helper.StyleHelper;
import gwt.material.design.client.constants.Color;
import junit.framework.TestCase;

/**
* Test case for {@link EnumHelper}.
*/
public class EnumHelperTest extends TestCase {

public EnumHelperTest() {
checkFromStyleName();
}

private void checkFromStyleName() {
assertEquals(Color.PINK,
EnumHelper.fromStyleName("pink", Color.class, Color.DEFAULT));

assertEquals(Color.PINK,
EnumHelper.fromStyleName("pink lighten-1", Color.class, Color.DEFAULT));

assertEquals(Color.PINK_LIGHTEN_1,
EnumHelper.fromStyleName("pink lighten-1", Color.class, Color.DEFAULT, true));
}
}
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -6,7 +6,7 @@
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-parent</artifactId>
<packaging>pom</packaging>
<version>2.0-SNAPSHOT</version>
<version>2.0-rc2</version>

<modules>
<module>gwt-material</module>
Expand Down Expand Up @@ -63,7 +63,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.0-SNAPSHOT</tag>
<tag>v2.0-rc2</tag>
</scm>

<licenses>
Expand Down

0 comments on commit b7212cf

Please sign in to comment.