use of com.google.gwt.user.client.ui.HasValue in project gwt-material by GwtMaterialDesign.
the class MaterialCollectionItem method onLoad.
@Override
protected void onLoad() {
super.onLoad();
HandlerRegistration handlerRegistration = addClickHandler(event -> {
// been clicked to avoid duplicate events.
if (Element.as(event.getNativeEvent().getEventTarget()) != getElement()) {
if (getType() == CollectionType.CHECKBOX) {
event.stopPropagation();
event.preventDefault();
}
}
for (Widget w : MaterialCollectionItem.this) {
if (w instanceof MaterialCollectionSecondary) {
for (Widget a : (MaterialCollectionSecondary) w) {
if (a instanceof HasValue) {
try {
@SuppressWarnings("unchecked") HasValue<Boolean> cb = (HasValue<Boolean>) a;
if (cb.getValue()) {
cb.setValue(false);
} else {
cb.setValue(true);
}
} catch (ClassCastException ex) {
// Ignore non-boolean has value handlers.
}
}
}
}
}
});
registerHandler(handlerRegistration);
JsMaterialElement.initDismissableCollection();
}
Aggregations