diff --git a/README.md b/README.md
index 46ae9f22e..a3f275290 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
## 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
@@ -15,12 +15,12 @@ We created > E fromStyleName(final String styleName,
final Class 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 fromStyleName(final String styleName,
+ final Class enumClass,
+ final E defaultValue,
+ final boolean ignoreSpaces) {
if (styleName == null || enumClass == null) {
return defaultValue;
}
@@ -47,8 +62,16 @@ public static > 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;
diff --git a/gwt-material/src/main/java/gwt/material/design/client/base/helper/StyleHelper.java b/gwt-material/src/main/java/gwt/material/design/client/base/helper/StyleHelper.java
index fe27a62eb..580469b73 100644
--- a/gwt-material/src/main/java/gwt/material/design/client/base/helper/StyleHelper.java
+++ b/gwt-material/src/main/java/gwt/material/design/client/base/helper/StyleHelper.java
@@ -105,7 +105,6 @@ public static void removeEnumStyleName(final UIObje
*/
public static boolean containsStyle(final String styleNames,
final String style) {
-
if (styleNames == null || style == null) {
return false;
}
diff --git a/gwt-material/src/main/java/gwt/material/design/client/ui/MaterialTooltip.java b/gwt-material/src/main/java/gwt/material/design/client/ui/MaterialTooltip.java
index eb55191e1..a2cb9232e 100644
--- a/gwt-material/src/main/java/gwt/material/design/client/ui/MaterialTooltip.java
+++ b/gwt-material/src/main/java/gwt/material/design/client/ui/MaterialTooltip.java
@@ -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 : "");
});
diff --git a/gwt-material/src/main/java/gwt/material/design/client/ui/html/Option.java b/gwt-material/src/main/java/gwt/material/design/client/ui/html/Option.java
index 82af998eb..4e9d0288f 100644
--- a/gwt-material/src/main/java/gwt/material/design/client/ui/html/Option.java
+++ b/gwt-material/src/main/java/gwt/material/design/client/ui/html/Option.java
@@ -65,8 +65,6 @@ public int getIndex() {
return OptionElement.as(this.getElement()).getIndex();
}
- ;
-
/**
* Option label for use in hierarchical menus.
*
@@ -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,
@@ -145,8 +141,6 @@ public void setDefaultSelected(boolean selected) {
OptionElement.as(this.getElement()).setDefaultSelected(selected);
}
- ;
-
/**
* The control is unavailable in this context.
*
@@ -158,8 +152,6 @@ public void setDisabled(boolean disabled) {
OptionElement.as(this.getElement()).setDisabled(disabled);
}
- ;
-
/**
* Option label for use in hierarchical menus.
*
@@ -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);
+ }
}
diff --git a/gwt-material/src/test/java/gwt/material/design/client/GwtMaterialTestComponent.java b/gwt-material/src/test/java/gwt/material/design/client/GwtMaterialTestComponent.java
index a362f370d..5a9f3681a 100644
--- a/gwt-material/src/test/java/gwt/material/design/client/GwtMaterialTestComponent.java
+++ b/gwt-material/src/test/java/gwt/material/design/client/GwtMaterialTestComponent.java
@@ -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.$;
@@ -58,6 +59,11 @@ public void setup() {
assertNotNull($("body"));
}
+ @Test
+ public void testHelpers() {
+ new ColorHelperTest();
+ }
+
@Test
public void testAnimation() {
new AnimationTest().init();
diff --git a/gwt-material/src/test/java/gwt/material/design/client/ui/base/helper/ColorHelperTest.java b/gwt-material/src/test/java/gwt/material/design/client/ui/base/helper/ColorHelperTest.java
new file mode 100644
index 000000000..a550ad9b4
--- /dev/null
+++ b/gwt-material/src/test/java/gwt/material/design/client/ui/base/helper/ColorHelperTest.java
@@ -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));
+ }
+}
diff --git a/gwt-material/src/test/java/gwt/material/design/client/ui/base/helper/EnumHelperTest.java b/gwt-material/src/test/java/gwt/material/design/client/ui/base/helper/EnumHelperTest.java
new file mode 100644
index 000000000..980f1b9aa
--- /dev/null
+++ b/gwt-material/src/test/java/gwt/material/design/client/ui/base/helper/EnumHelperTest.java
@@ -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));
+ }
+}
diff --git a/pom.xml b/pom.xml
index 162bbc8e0..2d95858f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.github.gwtmaterialdesign
gwt-material-parent
pom
- 2.0-SNAPSHOT
+ 2.0-rc2
gwt-material
@@ -63,7 +63,7 @@
scm:git:git@github.com:GwtMaterialDesign/gwt-material.git
scm:git:git@github.com:GwtMaterialDesign/gwt-material.git
http://github.com/GwtMaterialDesign/gwt-material
- v2.0-SNAPSHOT
+ v2.0-rc2