Skip to content

Commit 16812ba

Browse files
authored
Merge pull request #381 from GwtMaterialDesign/release_1.5.2
Release 1.5.2
2 parents d151be7 + 18bd8a7 commit 16812ba

File tree

16 files changed

+415
-203
lines changed

16 files changed

+415
-203
lines changed

.utility/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -ev
3-
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk7" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_1.5.1" ]; then
3+
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk7" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_1.5.2" ]; then
44
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
55
mvn deploy --settings ~/settings.xml
66
fi

gwt-material/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>gwt-material-parent</artifactId>
55
<groupId>com.github.gwtmaterialdesign</groupId>
6-
<version>1.5.1</version>
6+
<version>1.5.2</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99

@@ -25,6 +25,12 @@
2525
<version>4.11</version>
2626
<scope>test</scope>
2727
</dependency>
28+
<dependency>
29+
<groupId>org.apache.maven.surefire</groupId>
30+
<artifactId>surefire-junit4</artifactId>
31+
<version>2.12.4</version>
32+
<scope>test</scope>
33+
</dependency>
2834
</dependencies>
2935

3036
<build>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public AbstractIconButton(ButtonType type, String text, MaterialIcon icon) {
3838
super(type, text);
3939

4040
this.icon = icon;
41+
ensureIconAttached();
4142
}
4243

4344
public AbstractIconButton(ButtonType type, String text) {
@@ -74,7 +75,7 @@ public MaterialIcon getIcon() {
7475
@Override
7576
public void setIconType(IconType iconType) {
7677
icon.setIconType(iconType);
77-
insert(icon, 0);
78+
ensureIconAttached();
7879
}
7980

8081
@Override
@@ -106,4 +107,10 @@ public void setIconPrefix(boolean prefix) {
106107
public boolean isIconPrefix() {
107108
return icon.isIconPrefix();
108109
}
110+
111+
public void ensureIconAttached() {
112+
if(icon != null && !icon.isAttached()) {
113+
insert(icon, 0);
114+
}
115+
}
109116
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
/**
3636
* Footers are a great way to organize a lot of site navigation and information at the end of a page. This is where the user will look once hes finished scrolling through the current page or is looking for additional information about your website.
3737
* <h3>UiBinder Usage:</h3>
38-
*
38+
*
3939
* <pre>
40-
* {@code
40+
* {@code
4141
<m:MaterialFooter backgroundColor="blue">
4242
<m:MaterialRow>
4343
<m:MaterialColumn grid="s12 m6 l6">
@@ -56,7 +56,7 @@
5656
</m:MaterialFooter> }
5757
* </pre>
5858
* </p>
59-
*
59+
*
6060
* @author kevzlou7979
6161
* @author Ben Dol
6262
* @see <a href="http://gwt-material-demo.herokuapp.com/#footer">Material Footer</a>
@@ -75,7 +75,7 @@ public MaterialFooter() {
7575

7676
@Override
7777
public void add(Widget child) {
78-
if(child.getElement().getClassName().contains("footer-copyright")){
78+
if(child instanceof MaterialFooterCopyright) {
7979
super.add(child);
8080
} else {
8181
container.add(child);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ protected native void initializeMaterial(Element element) /*-{
162162
$wnd.jQuery(element).material_select();
163163
}-*/;
164164

165+
/**
166+
* Re initialize the material listbox component
167+
*/
168+
public void reinitialize() {
169+
initializeMaterial(getElement());
170+
}
171+
165172
/**
166173
* Sets whether this list allows multiple selections.
167174
*

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,8 @@ public void setOpacity(double opacity) {
220220
}
221221

222222
@Override
223-
public HandlerRegistration addCloseHandler(final CloseHandler<MaterialModal> handler) {
224-
return this.addHandler(new CloseHandler<MaterialModal>() {
225-
@Override
226-
public void onClose(CloseEvent<MaterialModal> event) {
227-
228-
}
229-
}, CloseEvent.getType());
223+
public HandlerRegistration addCloseHandler(CloseHandler<MaterialModal> handler) {
224+
return this.addHandler(handler, CloseEvent.getType());
230225
}
226+
231227
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public MaterialNoResult() {
6767
div.add(title);
6868
icon.setIconSize(IconSize.LARGE);
6969
title.insert(icon, 0);
70-
title.setMarginTop(-100);
7170
}
7271

7372
public MaterialNoResult(String bgColor, String textColor, IconType iconType, String title, String description) {

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

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@
3434
import com.google.gwt.user.client.ui.RootPanel;
3535
import com.google.gwt.user.client.ui.Widget;
3636
import com.google.web.bindery.event.shared.HandlerRegistration;
37-
import gwt.material.design.client.base.*;
37+
import gwt.material.design.client.base.HasSelectables;
38+
import gwt.material.design.client.base.HasType;
39+
import gwt.material.design.client.base.HasWaves;
40+
import gwt.material.design.client.base.MaterialWidget;
3841
import gwt.material.design.client.base.helper.DOMHelper;
3942
import gwt.material.design.client.base.mixin.CssTypeMixin;
4043
import gwt.material.design.client.base.mixin.ToggleStyleMixin;
4144
import gwt.material.design.client.constants.Edge;
4245
import gwt.material.design.client.constants.SideNavType;
4346
import gwt.material.design.client.events.*;
44-
import gwt.material.design.client.events.ClearActiveEvent.ClearActiveHandler;
4547
import gwt.material.design.client.events.SideNavClosedEvent.SideNavClosedHandler;
4648
import gwt.material.design.client.events.SideNavClosingEvent.SideNavClosingHandler;
4749
import gwt.material.design.client.events.SideNavOpenedEvent.SideNavOpenedHandler;
@@ -154,22 +156,24 @@ public HandlerRegistration addClosedHandler(SideNavClosedHandler handler) {
154156
return addHandler(handler, SideNavClosedEvent.TYPE);
155157
}
156158

157-
@Override
158-
public void add(Widget child) {
159+
public Widget wrap(Widget child) {
159160
if(child instanceof MaterialImage) {
160161
child.getElement().getStyle().setProperty("border", "1px solid #e9e9e9");
161162
child.getElement().getStyle().setProperty("textAlign", "center");
162163
}
163164

164-
boolean collapsible = child instanceof MaterialCollapsible;
165-
if(collapsible) {
166-
// Since the collapsible is separ
167-
((MaterialCollapsible)child).addClearActiveHandler(new ClearActiveHandler() {
168-
@Override
169-
public void onClearActive(ClearActiveEvent event) {
170-
clearActive();
165+
// Check whether the widget is not selectable by default
166+
boolean isNotSelectable = false;
167+
if(child instanceof MaterialWidget) {
168+
MaterialWidget widget = (MaterialWidget) child;
169+
if (widget.getInitialClasses() != null) {
170+
if (widget.getInitialClasses().length > 0) {
171+
String initialClass = widget.getInitialClasses()[0];
172+
if(initialClass.contains("side-profile") || initialClass.contains("collapsible")) {
173+
isNotSelectable = true;
174+
}
171175
}
172-
});
176+
}
173177
}
174178

175179
if(!(child instanceof ListItem)) {
@@ -187,9 +191,9 @@ public void onClearActive(ClearActiveEvent event) {
187191
child = listItem;
188192
}
189193

190-
// Collapsible's should not be selectable
194+
// Collapsible and Side Porfile should not be selectable
191195
final Widget finalChild = child;
192-
if(!collapsible) {
196+
if(!isNotSelectable) {
193197
// Active click handler
194198
finalChild.addDomHandler(new ClickHandler() {
195199
@Override
@@ -200,7 +204,17 @@ public void onClick(ClickEvent event) {
200204
}, ClickEvent.getType());
201205
}
202206
child.getElement().getStyle().setDisplay(Style.Display.BLOCK);
203-
super.add(child);
207+
return child;
208+
}
209+
210+
@Override
211+
public void add(Widget child) {
212+
super.add(wrap(child));
213+
}
214+
215+
@Override
216+
protected void insert(Widget child, com.google.gwt.user.client.Element container, int beforeIndex, boolean domInsert) {
217+
super.insert(wrap(child), container, beforeIndex, domInsert);
204218
}
205219

206220
@Override

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

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import com.google.gwt.event.logical.shared.ValueChangeHandler;
3030
import com.google.gwt.event.shared.HandlerRegistration;
3131
import com.google.gwt.user.client.ui.HasValue;
32-
import gwt.material.design.client.base.MaterialWidget;
3332
import gwt.material.design.client.base.HasError;
33+
import gwt.material.design.client.base.MaterialWidget;
3434
import gwt.material.design.client.base.mixin.ErrorMixin;
3535
import gwt.material.design.client.constants.InputType;
3636
import gwt.material.design.client.ui.html.Label;
@@ -39,25 +39,27 @@
3939
//@formatter:off
4040

4141
/**
42-
* Material Switch or other call it toggle - used for an alternative for checkbox
43-
*
44-
* <h3>UiBinder Usage:</h3>
45-
* <pre>
46-
*{@code<m:MaterialSwitch value="true"/>
47-
*<m:MaterialSwitch value="true" disabled="true"/>
48-
* }
49-
* </pre>
42+
* Material Switch or other call it toggle - used for an alternative for checkbox
43+
*
44+
* <h3>UiBinder Usage:</h3>
45+
* <pre>
46+
*{@code<m:MaterialSwitch value="true"/>
47+
*<m:MaterialSwitch value="true" disabled="true"/>
48+
* }
49+
* </pre>
5050
*
51-
* @author kevzlou7979
52-
* @see <a href="http://gwt-material-demo.herokuapp.com/#forms">Material Switch</a>
53-
*/
51+
* @author kevzlou7979
52+
* @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#!forms">Material Switch</a>
53+
*/
5454
//@formatter:on
5555
public class MaterialSwitch extends MaterialWidget implements HasValue<Boolean>, HasClickHandlers, HasError {
5656

5757
private MaterialInput input = new MaterialInput();
5858
private Span span = new Span();
5959
private Label label = new Label();
6060
private MaterialLabel lblError = new MaterialLabel();
61+
private Span onLabel = new Span();
62+
private Span offLabel = new Span();
6163

6264
private final ErrorMixin<MaterialSwitch, MaterialLabel> errorMixin = new ErrorMixin<>(this, lblError, null);
6365

@@ -68,6 +70,22 @@ public MaterialSwitch() {
6870
super(Document.get().createDivElement(), "switch");
6971
span.setStyleName("lever");
7072
input.setType(InputType.CHECKBOX);
73+
}
74+
75+
/**
76+
* Creates a material switch with default value.
77+
*/
78+
public MaterialSwitch(boolean value) {
79+
this();
80+
setValue(value);
81+
}
82+
83+
@Override
84+
protected void onLoad() {
85+
super.onLoad();
86+
if(!offLabel.getText().isEmpty()) {
87+
label.add(offLabel);
88+
}
7189
label.add(input);
7290
label.add(span);
7391
add(label);
@@ -84,14 +102,9 @@ public void onClick(ClickEvent event) {
84102
event.stopPropagation();
85103
}
86104
});
87-
}
88-
89-
/**
90-
* Creates a material switch with default value.
91-
*/
92-
public MaterialSwitch(boolean value) {
93-
this();
94-
setValue(value);
105+
if(!onLabel.getText().isEmpty()) {
106+
label.add(onLabel);
107+
}
95108
}
96109

97110
@Override
@@ -176,13 +189,15 @@ public void setSpan(Span span) {
176189
/**
177190
* @return the label
178191
*/
192+
@Deprecated
179193
public Label getLabel() {
180194
return label;
181195
}
182196

183197
/**
184198
* @param label the label to set
185199
*/
200+
@Deprecated
186201
public void setLabel(Label label) {
187202
this.label = label;
188203
}
@@ -213,4 +228,18 @@ public void setSuccess(String success) {
213228
public void clearErrorOrSuccess() {
214229
errorMixin.clearErrorOrSuccess();
215230
}
216-
}
231+
232+
/**
233+
* Set the On State Label of the switch component
234+
*/
235+
public void setOnLabel(String label) {
236+
onLabel.setText(label);
237+
}
238+
239+
/**
240+
* Set the Off State Label of the switch component
241+
*/
242+
public void setOffLabel(String label) {
243+
offLabel.setText(label);
244+
}
245+
}

0 commit comments

Comments
 (0)