Skip to content

Commit 6079f7a

Browse files
authored
Merge pull request #449 from GwtMaterialDesign/release_1.6.2
Release 1.6.2
2 parents ce4f225 + 47c6eb9 commit 6079f7a

File tree

8 files changed

+59
-50
lines changed

8 files changed

+59
-50
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs
1616

1717

1818
## Maven
19-
### Current Version 1.6.1
19+
### Current Version 1.6.2
2020
```xml
2121
<dependency>
2222
<groupId>com.github.gwtmaterialdesign</groupId>
2323
<artifactId>gwt-material</artifactId>
24-
<version>1.6.1</version>
24+
<version>1.6.2</version>
2525
</dependency>
2626
```
2727
### Snapshot Version 2.0-SNAPSHOT

gwt-material/pom.xml

Lines changed: 1 addition & 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.6.1</version>
6+
<version>1.6.2</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public OptionElement getOptionElement(int index) {
144144
*/
145145
@Override
146146
public void clear() {
147+
values.clear();
147148
listBox.clear();
148149
if (initialized) {
149150
// reinitialize
@@ -237,7 +238,6 @@ public void onValueChange(ValueChangeEvent<T> event) {
237238

238239
@Override
239240
public void setAcceptableValues(Collection<T> values) {
240-
this.values.clear();
241241
clear();
242242

243243
for(T value : values) {
@@ -384,9 +384,9 @@ public void addItem(T item) {
384384
* the item's value, to be submitted if it is part of a
385385
* {@link FormPanel}; cannot be <code>null</code>
386386
*/
387-
public void addItem(T item, String value) {
388-
values.add(item);
389-
listBox.addItem(keyFactory.generateKey(item), value);
387+
public void addItem(String item, T value) {
388+
values.add(value);
389+
listBox.addItem(keyFactory.generateKey(value), item);
390390
if (initialized) {
391391
// reinitialize
392392
initializeMaterial(listBox.getElement());
@@ -405,9 +405,9 @@ public void addItem(T item, String value) {
405405
* the item's value, to be submitted if it is part of a
406406
* {@link FormPanel}; cannot be <code>null</code>
407407
*/
408-
public void addItem(T item, Direction dir, String value) {
409-
values.add(item);
410-
listBox.addItem(keyFactory.generateKey(item), dir, value);
408+
public void addItem(String item, Direction dir, T value) {
409+
values.add(value);
410+
listBox.addItem(keyFactory.generateKey(value), dir, item);
411411
if (initialized) {
412412
// reinitialize
413413
initializeMaterial(listBox.getElement());
@@ -427,7 +427,7 @@ public void addItem(T item, Direction dir, String value) {
427427
* the index at which to insert it
428428
*/
429429
public void insertItem(T item, int index) {
430-
values.add(item);
430+
values.add(index, item);
431431
listBox.insertItem(keyFactory.generateKey(item), index);
432432
if (initialized) {
433433
// reinitialize
@@ -451,7 +451,7 @@ public void insertItem(T item, int index) {
451451
* the index at which to insert it
452452
*/
453453
public void insertItem(T item, Direction dir, int index) {
454-
values.add(item);
454+
values.add(index, item);
455455
listBox.insertItem(keyFactory.generateKey(item), dir, index);
456456
if (initialized) {
457457
// reinitialize
@@ -475,9 +475,9 @@ public void insertItem(T item, Direction dir, int index) {
475475
* @param index
476476
* the index at which to insert it
477477
*/
478-
public void insertItem(T item, String value, int index) {
479-
values.add(item);
480-
listBox.insertItem(keyFactory.generateKey(item), value, index);
478+
public void insertItem(String item, T value, int index) {
479+
values.add(value);
480+
listBox.insertItem(keyFactory.generateKey(value), item, index);
481481
if (initialized) {
482482
// reinitialize
483483
initializeMaterial(listBox.getElement());

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

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,6 @@
2121
*/
2222

2323
import com.google.gwt.core.client.Scheduler;
24-
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
2524
import com.google.gwt.dom.client.Document;
2625
import com.google.gwt.dom.client.Element;
2726
import com.google.gwt.dom.client.Style;
@@ -77,7 +76,7 @@ public class MaterialSideNav extends MaterialWidget implements HasType<SideNavTy
7776
private boolean closeOnClick = false;
7877
private boolean alwaysShowActivator = false;
7978
private boolean allowBodyScroll = false;
80-
private boolean showOnAttach = false;
79+
private Boolean showOnAttach = null;
8180
private boolean open;
8281

8382
private Element activator;
@@ -91,6 +90,8 @@ public class MaterialSideNav extends MaterialWidget implements HasType<SideNavTy
9190
*/
9291
public MaterialSideNav() {
9392
super(Document.get().createULElement(), "side-nav");
93+
94+
typeMixin.setType(SideNavType.FIXED);
9495
}
9596

9697
/**
@@ -116,12 +117,27 @@ public void onLoad() {
116117
// Initialize the side nav
117118
initialize();
118119

119-
if(showOnAttach) {
120-
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
120+
if(showOnAttach != null) {
121+
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
121122
@Override
122123
public void execute() {
123-
if(Window.getClientWidth() > 960) {
124+
if (showOnAttach) {
125+
if (Window.getClientWidth() > 960) {
126+
show();
127+
}
128+
} else {
124129
show();
130+
final HandlerRegistration[] openedHandler = new HandlerRegistration[1];
131+
openedHandler[0] = addOpenedHandler(new SideNavOpenedHandler() {
132+
@Override
133+
public void onSideNavOpened(SideNavOpenedEvent event) {
134+
hide();
135+
136+
if (openedHandler[0] != null) {
137+
openedHandler[0].removeHandler();
138+
}
139+
}
140+
});
125141
}
126142
}
127143
});
@@ -297,7 +313,7 @@ public void run() {
297313
}}.schedule(500);
298314
break;
299315
case PUSH:
300-
applyPushType(getElement(), activator, width);
316+
applyPushType(width);
301317
break;
302318
}
303319
}
@@ -314,7 +330,7 @@ protected native boolean isSmall() /*-{
314330
/**
315331
* Push the header, footer, and main to the right part when Close type is applied.
316332
*/
317-
protected native void applyPushType(Element element, Element activator, double width) /*-{
333+
protected native void applyPushType(double width) /*-{
318334
var that = this;
319335
320336
$wnd.jQuery($wnd.window).off("resize");
@@ -373,25 +389,23 @@ protected void initialize() {
373389
}
374390

375391
protected void initialize(boolean strict) {
376-
if(activator == null) {
392+
if (activator == null) {
377393
activator = DOMHelper.getElementByAttribute("data-activates", getId());
378394
if (activator != null) {
379-
SideNavType type = getType();
380-
processType(type);
381-
382-
initialize(activator, width, closeOnClick, edge.getCssName());
383-
384-
if(alwaysShowActivator || !isFixed()) {
395+
if (alwaysShowActivator || !isFixed()) {
385396
String style = activator.getAttribute("style");
386397
activator.setAttribute("style", style + "; display: block !important");
387398
activator.removeClassName("navmenu-permanent");
388399
}
389-
} else if(strict) {
400+
} else if (strict) {
390401
throw new RuntimeException("Cannot find an activator for the MaterialSideNav, " +
391402
"please ensure you have a MaterialNavBar with an activator setup to match " +
392403
"this widgets id.");
393404
}
394405
}
406+
407+
processType(getType());
408+
initialize(activator, width, closeOnClick, edge.getCssName());
395409
}
396410

397411
protected native void initialize(Element e, int width, boolean closeOnClick, String edge)/*-{
@@ -533,7 +547,7 @@ public void setAlwaysShowActivator(boolean alwaysShowActivator) {
533547
* Will the menu forcefully show on attachment.
534548
*/
535549
public boolean isShowOnAttach() {
536-
return showOnAttach;
550+
return showOnAttach != null && showOnAttach;
537551
}
538552

539553
/**

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,13 @@ public MaterialSwitch(boolean value) {
9090
@Override
9191
protected void onLoad() {
9292
super.onLoad();
93-
if(offLabel.getText() != null && !offLabel.getText().isEmpty()) {
94-
label.add(offLabel);
95-
}
93+
label.add(offLabel);
9694
label.add(input);
9795
label.add(span);
9896
add(label);
9997
add(lblError);
10098
lblError.getElement().getStyle().setMarginTop(16, Unit.PX);
101-
102-
if(onLabel.getText() != null && !onLabel.getText().isEmpty()) {
103-
label.add(onLabel);
104-
}
99+
label.add(onLabel);
105100

106101
// register click handler here in order to have it at first position
107102
// and therefore it will deal with clicks as first and setup the value

gwt-material/src/main/resources/gwt/material/design/client/resources/js/materialize-0.97.5.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ $(document).ready(function(){
20332033
removeMenu(true);
20342034
}
20352035
else {
2036-
menu_id.removeAttr('style');
2036+
//menu_id.removeAttr('style'); GWT MATERIAL MODIFICATION
20372037
menu_id.css('width', options.menuWidth);
20382038
}
20392039
}
@@ -2077,7 +2077,7 @@ $(document).ready(function(){
20772077
complete: function() {
20782078
if (restoreNav === true) {
20792079
// Restore Fixed sidenav
2080-
menu_id.removeAttr('style');
2080+
//menu_id.removeAttr('style'); GWT MATERIAL MODIFICATION
20812081
menu_id.css('width', options.menuWidth);
20822082
}
20832083
$this.trigger("side-nav-closed");
@@ -2095,7 +2095,7 @@ $(document).ready(function(){
20952095
complete: function() {
20962096
if (restoreNav === true) {
20972097
// Restore Fixed sidenav
2098-
menu_id.removeAttr('style');
2098+
//menu_id.removeAttr('style'); GWT MATERIAL MODIFICATION
20992099
menu_id.css('width', options.menuWidth);
21002100
}
21012101
$this.trigger("side-nav-closed");

gwt-material/src/main/resources/gwt/material/design/client/resources/js/materialize-0.97.5.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>com.github.gwtmaterialdesign</groupId>
66
<artifactId>gwt-material-parent</artifactId>
77
<packaging>pom</packaging>
8-
<version>1.6.1</version>
8+
<version>1.6.2</version>
99

1010
<modules>
1111
<module>gwt-material</module>
@@ -62,7 +62,7 @@
6262
<connection>scm:git:[email protected]:GwtMaterialDesign/gwt-material.git</connection>
6363
<developerConnection>scm:git:[email protected]:GwtMaterialDesign/gwt-material.git</developerConnection>
6464
<url>http://github.com/GwtMaterialDesign/gwt-material</url>
65-
<tag>v1.6.1</tag>
65+
<tag>v1.6.2</tag>
6666
</scm>
6767

6868
<licenses>

0 commit comments

Comments
 (0)