Skip to content

Commit b7212cf

Browse files
authored
Merge pull request #499 from GwtMaterialDesign/release_2.0
Preparation for 2.0-rc2 release
2 parents 684eedc + 56c8ebc commit b7212cf

File tree

11 files changed

+147
-23
lines changed

11 files changed

+147
-23
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<br/>
77

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

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

1616

1717
## Maven
18-
### Current Version 2.0-rc1
18+
### Current Version 2.0-rc2
1919
```xml
2020
<dependency>
2121
<groupId>com.github.gwtmaterialdesign</groupId>
2222
<artifactId>gwt-material</artifactId>
23-
<version>2.0-rc1</version>
23+
<version>2.0-rc2</version>
2424
</dependency>
2525
```
2626
### Snapshot Version 2.0-SNAPSHOT

gwt-material/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>gwt-material-parent</artifactId>
66
<groupId>com.github.gwtmaterialdesign</groupId>
7-
<version>2.0-SNAPSHOT</version>
7+
<version>2.0-rc2</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>com.github.gwtmaterialdesign</groupId>
1919
<artifactId>gwt-material-jquery</artifactId>
20-
<version>1.0-SNAPSHOT</version>
20+
<version>1.0-rc2</version>
2121
</dependency>
2222
<dependency>
2323
<groupId>com.google.gwt</groupId>

gwt-material/src/main/java/gwt/material/design/client/base/helper/ColorHelper.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,29 @@
2020
* #L%
2121
*/
2222

23-
2423
import com.google.gwt.dom.client.Document;
2524
import com.google.gwt.dom.client.Element;
25+
import com.google.gwt.dom.client.Style;
2626
import com.google.gwt.user.client.ui.RootPanel;
2727
import gwt.material.design.client.base.MaterialWidget;
2828
import gwt.material.design.client.constants.Color;
2929

3030
public class ColorHelper {
3131

32+
/**
33+
* Returns first enum constant found..
34+
*
35+
* @param styleName Space-separated list of styles
36+
* @param enumClass Type of enum
37+
* @param defaultValue Default value of no match was found
38+
* @return First enum constant found or default value
39+
*/
40+
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
41+
final Class<E> enumClass,
42+
final E defaultValue) {
43+
return EnumHelper.fromStyleName(styleName, enumClass, defaultValue, true);
44+
}
45+
3246
public static String setupComputedBackgroundColor(Color color) {
3347
MaterialWidget temp = new MaterialWidget(Document.get().createDivElement());
3448
temp.setBackgroundColor(color);
@@ -45,5 +59,4 @@ protected static native String getComputedBackgroundColor(Element e)/*-{
4559
var cs = $wnd.document.defaultView.getComputedStyle(e, null);
4660
return cs.getPropertyValue('background-color');
4761
}-*/;
48-
4962
}

gwt-material/src/main/java/gwt/material/design/client/base/helper/EnumHelper.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,25 @@ public final class EnumHelper {
3535
* @param defaultValue Default value of no match was found
3636
* @return First enum constant found or default value
3737
*/
38-
@SuppressWarnings("unchecked")
3938
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
4039
final Class<E> enumClass,
4140
final E defaultValue) {
41+
return EnumHelper.fromStyleName(styleName, enumClass, defaultValue, false);
42+
}
43+
44+
/**
45+
* Returns first enum constant found in at space-separated list of style names.
46+
*
47+
* @param styleName Space-separated list of styles
48+
* @param enumClass Type of enum
49+
* @param defaultValue Default value of no match was found
50+
* @return First enum constant found or default value
51+
*/
52+
@SuppressWarnings("unchecked")
53+
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
54+
final Class<E> enumClass,
55+
final E defaultValue,
56+
final boolean ignoreSpaces) {
4257
if (styleName == null || enumClass == null) {
4358
return defaultValue;
4459
}
@@ -47,8 +62,16 @@ public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final
4762
final Style.HasCssName anEnum = (Style.HasCssName) constant;
4863
final String cssClass = anEnum.getCssName();
4964

50-
if (cssClass != null && StyleHelper.containsStyle(styleName, cssClass)) {
51-
return (E) anEnum;
65+
if(cssClass != null) {
66+
boolean contains;
67+
if (ignoreSpaces) {
68+
contains = styleName.equals(cssClass);
69+
} else {
70+
contains = StyleHelper.containsStyle(styleName, cssClass);
71+
}
72+
if (contains) {
73+
return (E) anEnum;
74+
}
5275
}
5376
}
5477
return defaultValue;

gwt-material/src/main/java/gwt/material/design/client/base/helper/StyleHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public static <E extends Style.HasCssName> void removeEnumStyleName(final UIObje
105105
*/
106106
public static boolean containsStyle(final String styleNames,
107107
final String style) {
108-
109108
if (styleNames == null || style == null) {
110109
return false;
111110
}

gwt-material/src/main/java/gwt/material/design/client/ui/MaterialTooltip.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ public void setHtml(String html) {
320320

321321
Element element = widget.getElement();
322322
if (widget.isAttached()) {
323-
JsMaterialElement.$("#" + element.getAttribute("data-tooltip-id"))
323+
$("#" + element.getAttribute("data-tooltip-id"))
324324
.find("span")
325325
.html(html != null ? html : "");
326326
} else {
327327
htmlAttachHandler = widget.addAttachHandler(attachEvent -> {
328-
JsMaterialElement.$("#" + element.getAttribute("data-tooltip-id"))
328+
$("#" + element.getAttribute("data-tooltip-id"))
329329
.find("span")
330330
.html(html != null ? html : "");
331331
});

gwt-material/src/main/java/gwt/material/design/client/ui/html/Option.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public int getIndex() {
6565
return OptionElement.as(this.getElement()).getIndex();
6666
}
6767

68-
;
69-
7068
/**
7169
* Option label for use in hierarchical menus.
7270
*
@@ -130,8 +128,6 @@ public boolean isSelected() {
130128
return OptionElement.as(this.getElement()).isSelected();
131129
}
132130

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

148-
;
149-
150144
/**
151145
* The control is unavailable in this context.
152146
*
@@ -158,8 +152,6 @@ public void setDisabled(boolean disabled) {
158152
OptionElement.as(this.getElement()).setDisabled(disabled);
159153
}
160154

161-
;
162-
163155
/**
164156
* Option label for use in hierarchical menus.
165157
*
@@ -199,4 +191,9 @@ public void setValue(String value) {
199191
OptionElement.as(this.getElement()).setValue(value);
200192
}
201193

194+
@Override
195+
public void setEnabled(boolean enabled) {
196+
super.setEnabled(enabled);
197+
setDisabled(!enabled);
198+
}
202199
}

gwt-material/src/test/java/gwt/material/design/client/GwtMaterialTestComponent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import gwt.material.design.client.resources.WithJQueryResources;
2525
import gwt.material.design.client.ui.*;
2626
import gwt.material.design.client.ui.animation.AnimationTest;
27+
import gwt.material.design.client.ui.base.helper.ColorHelperTest;
2728
import org.junit.Test;
2829

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

62+
@Test
63+
public void testHelpers() {
64+
new ColorHelperTest();
65+
}
66+
6167
@Test
6268
public void testAnimation() {
6369
new AnimationTest().init();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2016 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client.ui.base.helper;
21+
22+
import gwt.material.design.client.base.helper.ColorHelper;
23+
import gwt.material.design.client.constants.Color;
24+
import junit.framework.TestCase;
25+
26+
/**
27+
* Test case for {@link gwt.material.design.client.base.helper.ColorHelper}.
28+
*/
29+
public class ColorHelperTest extends TestCase {
30+
31+
public ColorHelperTest() {
32+
checkFromStyleName();
33+
}
34+
35+
private void checkFromStyleName() {
36+
assertEquals(Color.PINK_LIGHTEN_1,
37+
ColorHelper.fromStyleName("pink lighten-1", Color.class, Color.DEFAULT));
38+
}
39+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2016 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client.ui.base.helper;
21+
22+
import gwt.material.design.client.base.helper.ColorHelper;
23+
import gwt.material.design.client.base.helper.EnumHelper;
24+
import gwt.material.design.client.base.helper.StyleHelper;
25+
import gwt.material.design.client.constants.Color;
26+
import junit.framework.TestCase;
27+
28+
/**
29+
* Test case for {@link EnumHelper}.
30+
*/
31+
public class EnumHelperTest extends TestCase {
32+
33+
public EnumHelperTest() {
34+
checkFromStyleName();
35+
}
36+
37+
private void checkFromStyleName() {
38+
assertEquals(Color.PINK,
39+
EnumHelper.fromStyleName("pink", Color.class, Color.DEFAULT));
40+
41+
assertEquals(Color.PINK,
42+
EnumHelper.fromStyleName("pink lighten-1", Color.class, Color.DEFAULT));
43+
44+
assertEquals(Color.PINK_LIGHTEN_1,
45+
EnumHelper.fromStyleName("pink lighten-1", Color.class, Color.DEFAULT, true));
46+
}
47+
}

0 commit comments

Comments
 (0)