Skip to content

Commit 46a2944

Browse files
authored
Merge pull request #288 from GwtMaterialDesign/release_2.0.1
Release 2.0.1
2 parents 340f27a + 74af262 commit 46a2944

File tree

24 files changed

+681
-77
lines changed

24 files changed

+681
-77
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ cache:
77
- $HOME/.m2
88
before_install:
99
# install the gwt-material-jquery library before we build the demo
10-
- git clone -b release_2.0 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
10+
- git clone -b release_2.0.1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
1111
- cd gwt-material-jquery
1212
- mvn install -DskipTests=true -DdryRun=true
1313
- cd ..
1414
# install the gwt-material library before we build the demo
15-
- git clone -b release_2.0 https://github.com/GwtMaterialDesign/gwt-material.git
15+
- git clone -b release_2.0.1 https://github.com/GwtMaterialDesign/gwt-material.git
1616
- cd gwt-material
1717
- mvn install -DskipTests=true -DdryRun=true
1818
- cd ..

.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" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.0" ]; then
3+
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.0.1" ]; 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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Gwt Material Design Extra Components for https://github.com/GwtMaterialDesign/gw
1111
<dependency>
1212
<groupId>com.github.gwtmaterialdesign</groupId>
1313
<artifactId>gwt-material-addins</artifactId>
14-
<version>2.0</version>
14+
<version>2.0.1</version>
1515
</dependency>
1616
```
1717

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
<parent>
66
<artifactId>gwt-material-parent</artifactId>
77
<groupId>com.github.gwtmaterialdesign</groupId>
8-
<version>2.0</version>
8+
<version>2.0.1</version>
99
</parent>
1010

1111
<artifactId>gwt-material-addins</artifactId>
1212

1313
<name>Gwt Material Addins</name>
14-
<version>2.0</version>
14+
<version>2.0.1</version>
1515
<description>Extra Components of GWT Material Framework</description>
1616

1717
<properties>
18-
<gwt-material.version>2.0</gwt-material.version>
18+
<gwt-material.version>2.0.1</gwt-material.version>
1919
</properties>
2020

2121
<scm>
2222
<connection>scm:git:[email protected]:GwtMaterialDesign/gwt-material-addins.git</connection>
2323
<developerConnection>scm:git:[email protected]:GwtMaterialDesign/gwt-material-addins.git</developerConnection>
2424
<url>http://github.com/GwtMaterialDesign/gwt-material-addins</url>
25-
<tag>v2.0</tag>
25+
<tag>v2.0.1</tag>
2626
</scm>
2727

2828
<licenses>

src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoComplete.java

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,25 @@ public MaterialAutoComplete(SuggestOracle suggestions) {
219219
setup(suggestions);
220220
}
221221

222+
private HandlerRegistration listHandler, itemBoxKeyDownHandler, itemBoxBlurHandler, itemBoxClickHandler;
223+
222224
@Override
223225
protected void onLoad() {
224226
super.onLoad();
225227

226-
registerHandler(list.addDomHandler(event -> suggestBox.showSuggestionList(), ClickEvent.getType()));
228+
loadHandlers();
229+
}
230+
231+
protected void loadHandlers() {
232+
listHandler = list.addDomHandler(event -> suggestBox.showSuggestionList(), ClickEvent.getType());
227233

228-
registerHandler(itemBox.addBlurHandler(blurEvent -> {
234+
itemBoxBlurHandler = itemBox.addBlurHandler(blurEvent -> {
229235
if (getValue().size() > 0) {
230236
label.addStyleName(CssName.ACTIVE);
231237
}
232-
}));
238+
});
233239

234-
registerHandler(itemBox.addKeyDownHandler(event -> {
240+
itemBoxKeyDownHandler = itemBox.addKeyDownHandler(event -> {
235241
boolean changed = false;
236242

237243
switch (event.getNativeKeyCode()) {
@@ -278,34 +284,52 @@ protected void onLoad() {
278284
itemBox.setFocus(true);
279285
break;
280286
}
287+
});
281288

282-
if (changed) {
283-
ValueChangeEvent.fire(MaterialAutoComplete.this, getValue());
284-
}
285-
}));
289+
itemBoxClickHandler = itemBox.addClickHandler(event -> suggestBox.showSuggestionList());
290+
}
286291

287-
registerHandler(itemBox.addClickHandler(event -> suggestBox.showSuggestionList()));
292+
@Override
293+
protected void onUnload() {
294+
super.onUnload();
288295

289-
registerHandler(suggestBox.addSelectionHandler(selectionEvent -> {
290-
Suggestion selectedItem = selectionEvent.getSelectedItem();
291-
itemBox.setValue("");
292-
if (addItem(selectedItem)) {
293-
ValueChangeEvent.fire(MaterialAutoComplete.this, getValue());
294-
}
295-
itemBox.setFocus(true);
296-
}));
296+
unloadHandlers();
297+
}
298+
299+
protected void unloadHandlers() {
300+
removeHandler(listHandler);
301+
removeHandler(itemBoxBlurHandler);
302+
removeHandler(itemBoxKeyDownHandler);
303+
removeHandler(itemBoxClickHandler);
297304
}
298305

299306
/**
300307
* Generate and build the List Items to be set on Auto Complete box.
301308
*/
302309
protected void setup(SuggestOracle suggestions) {
310+
311+
if (itemBoxKeyDownHandler != null) {
312+
itemBoxKeyDownHandler.removeHandler();
313+
}
314+
303315
list.setStyleName(AddinsCssName.MULTIVALUESUGGESTBOX_LIST);
304316
this.suggestions = suggestions;
305317
final ListItem item = new ListItem();
306318

307319
item.setStyleName(AddinsCssName.MULTIVALUESUGGESTBOX_INPUT_TOKEN);
320+
308321
suggestBox = new SuggestBox(suggestions, itemBox);
322+
suggestBox.addSelectionHandler(selectionEvent -> {
323+
Suggestion selectedItem = selectionEvent.getSelectedItem();
324+
itemBox.setValue("");
325+
if (addItem(selectedItem)) {
326+
ValueChangeEvent.fire(MaterialAutoComplete.this, getValue());
327+
}
328+
itemBox.setFocus(true);
329+
});
330+
331+
loadHandlers();
332+
309333
setLimit(this.limit);
310334
String autocompleteId = DOM.createUniqueId();
311335
itemBox.getElement().setId(autocompleteId);
@@ -316,7 +340,7 @@ protected void setup(SuggestOracle suggestions) {
316340

317341
panel.add(list);
318342
panel.getElement().setAttribute("onclick",
319-
"document.getElementById('" + autocompleteId + "').focus()");
343+
"document.getElementById('" + autocompleteId + "').focus()");
320344
panel.add(errorLabel);
321345
suggestBox.setFocus(true);
322346
}
@@ -355,7 +379,7 @@ protected boolean addItem(final Suggestion suggestion) {
355379

356380
if (getType() == AutocompleteType.TEXT) {
357381
suggestionMap.clear();
358-
itemBox.setText(suggestion.getDisplayString());
382+
itemBox.setText(suggestion.getReplacementString());
359383
} else {
360384
final MaterialChip chip = chipProvider.getChip(suggestion);
361385
if (chip == null) {
@@ -526,6 +550,7 @@ public void setLimit(int limit) {
526550
* Set the number of suggestions to be displayed to the user. This differs from
527551
* setLimit() which set both the suggestions displayed AND the limit of values
528552
* allowed within the autocomplete.
553+
*
529554
* @param limit
530555
*/
531556
public void setAutoSuggestLimit(int limit) {
@@ -545,9 +570,8 @@ public void setPlaceholder(String placeholder) {
545570
}
546571

547572
/**
548-
* @see gwt.material.design.client.ui.MaterialValueBox#setLabel(String)
549-
*
550573
* @param label
574+
* @see gwt.material.design.client.ui.MaterialValueBox#setLabel(String)
551575
*/
552576
public void setLabel(String label) {
553577
this.label.setText(label);

src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package gwt.material.design.addins.client.combobox;
2121

2222
import com.google.gwt.core.client.GWT;
23+
import com.google.gwt.core.client.Scheduler;
2324
import com.google.gwt.dom.client.Document;
2425
import com.google.gwt.dom.client.Style;
2526
import com.google.gwt.event.logical.shared.*;
@@ -33,10 +34,13 @@
3334
import gwt.material.design.addins.client.combobox.events.UnselectItemEvent;
3435
import gwt.material.design.addins.client.combobox.js.JsComboBox;
3536
import gwt.material.design.addins.client.combobox.js.JsComboBoxOptions;
37+
import gwt.material.design.addins.client.combobox.js.LanguageOptions;
3638
import gwt.material.design.client.MaterialDesignBase;
3739
import gwt.material.design.client.base.*;
40+
import gwt.material.design.client.base.mixin.EnabledMixin;
3841
import gwt.material.design.client.base.mixin.ErrorMixin;
3942
import gwt.material.design.client.base.mixin.ReadOnlyMixin;
43+
import gwt.material.design.client.base.mixin.WavesMixin;
4044
import gwt.material.design.client.constants.CssName;
4145
import gwt.material.design.client.ui.MaterialLabel;
4246
import gwt.material.design.client.ui.html.Label;
@@ -102,6 +106,8 @@ public class MaterialComboBox<T> extends AbstractValueWidget<List<T>> implements
102106

103107
private ErrorMixin<AbstractValueWidget, MaterialLabel> errorMixin;
104108
private ReadOnlyMixin<MaterialComboBox, MaterialWidget> readOnlyMixin;
109+
private EnabledMixin<MaterialWidget> enabledMixin;
110+
private WavesMixin<MaterialWidget> wavesMixin;
105111

106112
public MaterialComboBox() {
107113
super(Document.get().createDivElement(), CssName.INPUT_FIELD, AddinsCssName.COMBOBOX);
@@ -298,6 +304,31 @@ public JQueryElement getDropdownParent() {
298304
return options.dropdownParent;
299305
}
300306

307+
/**
308+
* Will get the Selection Results ul element containing all the combobox items.
309+
*/
310+
public JQueryElement getDropdownResultElement() {
311+
String dropdownId = getDropdownContainerElement().attr("id").toString();
312+
if (dropdownId != null && !(dropdownId.isEmpty())) {
313+
dropdownId = dropdownId.replace("container", "results");
314+
return $("#" + dropdownId);
315+
} else {
316+
GWT.log("The element dropdown-result ul element is undefined.", new NullPointerException());
317+
}
318+
return null;
319+
}
320+
321+
/**
322+
* Will get the Selection dropdown container rendered
323+
*/
324+
public JQueryElement getDropdownContainerElement() {
325+
JQueryElement element = $(getElement()).find(".select2 .selection .select2-selection__rendered");
326+
if (element == null) {
327+
GWT.log("The element dropdown-container element is undefined.", new NullPointerException());
328+
}
329+
return element;
330+
}
331+
301332
/**
302333
* Set the upper label above the combobox
303334
*/
@@ -315,16 +346,6 @@ public void setPlaceholder(String placeholder) {
315346
options.placeholder = placeholder;
316347
}
317348

318-
@Override
319-
public void setEnabled(boolean enabled) {
320-
listbox.setEnabled(enabled);
321-
}
322-
323-
@Override
324-
public boolean isEnabled() {
325-
return listbox.isEnabled();
326-
}
327-
328349
/**
329350
* Check if allow clear option is enabled
330351
*/
@@ -474,7 +495,7 @@ public void setSingleValue(T value, boolean fireEvents) {
474495
setSelectedIndex(index);
475496

476497
if (fireEvents) {
477-
ValueChangeEvent.fireIfNotEqual(this, before, values);
498+
ValueChangeEvent.fireIfNotEqual(this, before, Collections.singletonList(value));
478499
}
479500
}
480501
}
@@ -656,6 +677,28 @@ public void setTags(boolean tags) {
656677
options.tags = tags;
657678
}
658679

680+
/**
681+
* Will provide a set of text objecs that can be used for i18n language support.
682+
*/
683+
public void setLanguage(LanguageOptions language) {
684+
options.language = language;
685+
}
686+
687+
public LanguageOptions getLanguage() {
688+
return options.language;
689+
}
690+
691+
public void scrollTop(int offset) {
692+
Scheduler.get().scheduleDeferred(() -> getDropdownResultElement().scrollTop(offset));
693+
}
694+
695+
@Override
696+
public void setEnabled(boolean enabled) {
697+
super.setEnabled(enabled);
698+
699+
getEnabledMixin().updateWaves(enabled, this);
700+
}
701+
659702
public HandlerRegistration addSelectionHandler(SelectItemEvent.SelectComboHandler<T> selectionHandler) {
660703
return addHandler(selectionHandler, SelectItemEvent.getType());
661704
}
@@ -675,6 +718,14 @@ public HandlerRegistration addRemoveItemHandler(UnselectItemEvent.UnselectComboH
675718
return addHandler(handler, UnselectItemEvent.getType());
676719
}
677720

721+
@Override
722+
protected EnabledMixin<MaterialWidget> getEnabledMixin() {
723+
if (enabledMixin == null) {
724+
enabledMixin = new EnabledMixin<>(listbox);
725+
}
726+
return enabledMixin;
727+
}
728+
678729
@Override
679730
public ErrorMixin<AbstractValueWidget, MaterialLabel> getErrorMixin() {
680731
if (errorMixin == null) {

src/main/java/gwt/material/design/addins/client/combobox/js/JsComboBoxOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,7 @@ public static final JsComboBoxOptions create() {
6565

6666
@JsProperty
6767
public boolean tags;
68+
69+
@JsProperty
70+
public LanguageOptions language;
6871
}

0 commit comments

Comments
 (0)