Skip to content

Commit 4f7767a

Browse files
authored
Merge pull request #501 from GwtMaterialDesign/release_2.0
Release 2.0-rc3
2 parents b7212cf + 6d00e5b commit 4f7767a

File tree

95 files changed

+967
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+967
-519
lines changed

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-rc2</version>
7+
<version>2.0-SNAPSHOT</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-rc2</version>
20+
<version>1.0-SNAPSHOT</version>
2121
</dependency>
2222
<dependency>
2323
<groupId>com.google.gwt</groupId>

gwt-material/src/main/java/gwt/material/design/client/base/AbstractValueWidget.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,7 @@ public abstract class AbstractValueWidget<V> extends MaterialWidget implements H
4646

4747
private boolean allowBlank = true;
4848
private BlankValidator<V> blankValidator;
49-
50-
private AttachEvent.Handler attachHandler = new AttachEvent.Handler() {
51-
HandlerRegistration registration;
52-
53-
@Override
54-
public void onAttachOrDetach(AttachEvent event) {
55-
if (registration != null) {
56-
registration.removeHandler();
57-
}
58-
AbstractValueWidget inputWidget = getValidatorMixin().getInputWidget();
59-
registration = inputWidget.addBlurHandler(blurEvent -> {
60-
validate(isValidateOnBlur());
61-
});
62-
}
63-
};
49+
private HandlerRegistration blurHandler, attachHandler;
6450

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

@@ -160,6 +146,7 @@ public void reset() {
160146
@Override
161147
public void setValidateOnBlur(boolean validateOnBlur) {
162148
getValidatorMixin().setValidateOnBlur(validateOnBlur);
149+
setupBlurValidation();
163150
}
164151

165152
@Override
@@ -216,12 +203,22 @@ protected BlankValidator<V> createBlankValidator() {
216203
return new BlankValidator<>();
217204
}
218205

219-
protected HandlerRegistration setupBlurValidation() {
220-
AbstractValueWidget inputWidget = getValidatorMixin().getInputWidget();
206+
protected void setupBlurValidation() {
207+
final AbstractValueWidget inputWidget = getValidatorMixin().getInputWidget();
221208
if (!inputWidget.isAttached()) {
222-
return inputWidget.addAttachHandler(attachHandler);
209+
if(attachHandler == null) {
210+
attachHandler = inputWidget.addAttachHandler(event -> {
211+
if (blurHandler == null) {
212+
blurHandler = inputWidget.addBlurHandler(blurEvent -> {
213+
validate(isValidateOnBlur());
214+
});
215+
}
216+
});
217+
}
223218
} else {
224-
return inputWidget.addBlurHandler(event -> validate(isValidateOnBlur()));
219+
if(blurHandler == null) {
220+
blurHandler = inputWidget.addBlurHandler(event -> validate(isValidateOnBlur()));
221+
}
225222
}
226223
}
227224

gwt-material/src/main/java/gwt/material/design/client/base/MaterialWidget.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ public Appender(Widget widget) {
125125
public MaterialWidget() {
126126
}
127127

128+
public MaterialWidget(JQueryElement jQueryElement) {
129+
setElement(jQueryElement.asElement());
130+
131+
// We are already attached to the DOM.
132+
// This will happen in instances where
133+
// we are taking an element from JQuery.
134+
onAttach();
135+
}
136+
128137
public MaterialWidget(Element element) {
129138
setElement(element);
130139
}
@@ -207,6 +216,22 @@ public void insert(final Widget child, final int beforeIndex) {
207216
insert(child, (Element) getElement(), beforeIndex, true);
208217
}
209218

219+
/**
220+
* Set the style attribute of your element.
221+
* Note that this will override any {@link Element#getStyle()} changes and vice-versa.
222+
*/
223+
public void setStyle(String style) {
224+
getElement().setAttribute("style", style);
225+
}
226+
227+
/**
228+
* Set the 'class' attribute of this element.
229+
* Note that this will override {@link #addStyleName(String)} and vice-versa.
230+
*/
231+
public void setClass(String cssClasses) {
232+
getElement().setAttribute("class", cssClasses);
233+
}
234+
210235
// Events
211236

212237
@Override
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.base;
21+
22+
import com.google.gwt.dom.client.Element;
23+
import com.google.gwt.user.client.DOM;
24+
import com.google.gwt.user.client.ui.HasText;
25+
import gwt.material.design.client.base.mixin.TextMixin;
26+
27+
public class TextWidget extends MaterialWidget implements HasText {
28+
29+
private final TextMixin<TextWidget> textMixin = new TextMixin<>(this);
30+
31+
public TextWidget() {
32+
super(DOM.createDiv());
33+
}
34+
35+
public TextWidget(Element element) {
36+
super(element);
37+
}
38+
39+
public TextWidget(Element element, String... initialClass) {
40+
super(element, initialClass);
41+
}
42+
43+
@Override
44+
public String getText() {
45+
return textMixin.getText();
46+
}
47+
48+
@Override
49+
public void setText(String text) {
50+
textMixin.setText(text);
51+
}
52+
}

gwt-material/src/main/java/gwt/material/design/client/base/mixin/TextMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
* #L%
2121
*/
2222

23+
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
2324
import com.google.gwt.user.client.ui.UIObject;
2425

2526
/**
26-
* @author Grant Slender
27+
* @author Ben Dol
2728
*/
2829
public class TextMixin<T extends UIObject> extends AbstractMixin<T> {
2930

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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.constants;
21+
22+
/**
23+
* Types of Loader.<br>
24+
*
25+
* @author kevzlou7979
26+
*/
27+
public enum LoaderType {
28+
29+
CIRCULAR, PROGRESS
30+
}

gwt-material/src/main/java/gwt/material/design/client/js/JsDatePickerOptions.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ public class JsDatePickerOptions {
3939
@JsProperty
4040
public String format;
4141

42-
@JsProperty
43-
public Functions.Func open;
44-
45-
@JsProperty
46-
public Functions.Func close;
47-
4842
@JsProperty
4943
public Functions.Func1<Thing> set;
5044
}

gwt-material/src/main/java/gwt/material/design/client/js/JsMaterialElement.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ public class JsMaterialElement extends JQueryElement {
193193
@JsMethod
194194
public native JsMaterialElement off(JsDatePickerOptions options);
195195

196+
@JsMethod
197+
public native JsMaterialElement off(String action);
198+
196199
@JsMethod
197200
public native JsMaterialElement on(JsDatePickerOptions options);
198201

@@ -221,16 +224,16 @@ public class JsMaterialElement extends JQueryElement {
221224
* Animation Component
222225
*/
223226
@JsMethod(namespace = JsPackage.GLOBAL)
224-
public static native void closeGrid(String selector);
227+
public static native void closeGrid(Object selector);
225228

226229
@JsMethod(namespace = JsPackage.GLOBAL)
227-
public static native void showGrid(String selector);
230+
public static native void showGrid(Object selector);
228231

229232
@JsMethod(namespace = "Materialize")
230-
public static native double fadeInImage(String selector);
233+
public static native double fadeInImage(Object selector);
231234

232235
@JsMethod(namespace = "Materialize")
233-
public static native double showStaggeredList(String selector);
236+
public static native double showStaggeredList(Object selector);
234237

235238
@JsMethod(namespace = "Waves")
236239
public static native void displayEffect();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* // Adding icon
4242
* <m:MaterialButton text="Button" waves="LIGHT" backgroundColor="BLUE" iconType="CLOUD" iconPosition="LEFT"/>
4343
*
44-
* // FLOATING+ Button
44+
* // FLOATING Button
4545
* <m:MaterialButton type="FLOATING" waves="LIGHT" size="LARGE" iconType="ADD"/>
4646
*
4747
* // FLAT Button
@@ -52,7 +52,7 @@
5252
* </pre>
5353
*
5454
* @author kevzlou7979
55-
* @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#!buttons">Material Button</a>
55+
* @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#buttons">Material Button</a>
5656
*/
5757
//@formatter:on
5858
public class MaterialAnchorButton extends AbstractIconButton {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* </pre>
3838
*
3939
* @author kevzlou7979
40-
* @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#!badges">Material Badge</a>
40+
* @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#badges">Material Badge</a>
4141
*/
4242
//@formatter:on
4343
public class MaterialBadge extends Span {

0 commit comments

Comments
 (0)