|
|
@@ -22,13 +22,10 @@ import java.util.Objects; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.function.BiConsumer; |
|
|
|
|
|
|
|
import com.google.gwt.event.dom.client.ChangeEvent; |
|
|
|
import com.google.gwt.event.dom.client.ChangeHandler; |
|
|
|
import com.google.gwt.user.client.ui.Composite; |
|
|
|
import com.google.gwt.user.client.ui.FlowPanel; |
|
|
|
import com.google.gwt.user.client.ui.HasEnabled; |
|
|
|
import com.google.gwt.user.client.ui.ListBox; |
|
|
|
|
|
|
|
import com.vaadin.client.FastStringSet; |
|
|
|
import com.vaadin.client.Focusable; |
|
|
|
import com.vaadin.client.connectors.AbstractMultiSelectConnector.MultiSelectWidget; |
|
|
@@ -41,8 +38,8 @@ import elemental.json.JsonObject; |
|
|
|
* |
|
|
|
* @author Vaadin Ltd |
|
|
|
*/ |
|
|
|
public class VListSelect extends Composite implements ChangeHandler, Field, |
|
|
|
Focusable, HasEnabled, MultiSelectWidget { |
|
|
|
public class VListSelect extends Composite |
|
|
|
implements Field, Focusable, HasEnabled, MultiSelectWidget { |
|
|
|
|
|
|
|
private List<BiConsumer<Set<String>, Set<String>>> selectionChangeListeners = new ArrayList<>(); |
|
|
|
|
|
|
@@ -64,7 +61,12 @@ public class VListSelect extends Composite implements ChangeHandler, Field, |
|
|
|
|
|
|
|
select = new ListBox(); |
|
|
|
select.setMultipleSelect(true); |
|
|
|
select.addChangeHandler(this); |
|
|
|
|
|
|
|
// Add event handlers |
|
|
|
select.addClickHandler( |
|
|
|
clickEvent -> selectionEvent(clickEvent.getSource())); |
|
|
|
select.addChangeHandler( |
|
|
|
changeEvent -> selectionEvent(changeEvent.getSource())); |
|
|
|
|
|
|
|
container.add(select); |
|
|
|
|
|
|
@@ -161,9 +163,8 @@ public class VListSelect extends Composite implements ChangeHandler, Field, |
|
|
|
return selectedItemKeys; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onChange(ChangeEvent changeEvent) { |
|
|
|
if (changeEvent.getSource() == select) { |
|
|
|
private void selectionEvent(Object source){ |
|
|
|
if (source == select) { |
|
|
|
// selection can change by adding and at the same time removing |
|
|
|
// previous keys, or by just adding (e.g. when modifier keys are |
|
|
|
// pressed) |