/** * Will be raised before actual switch, so getValue() will return "old" value. * <br> For getting "new" value use addValueChangeHandler(). * <br> If used as header widget on JQMCollapsible then manual refresh() call is needed to update checkmark. */ public HandlerRegistration addClickHandler(ClickHandler handler) { return addDomHandler(handler, ClickEvent.getType()); }
private void initValueChangeHandler() { // Initialization code if (!valueChangeHandlerInitialized) { valueChangeHandlerInitialized = true; for (JQMCheckbox cb : checks) { cb.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (!inProgressSetValue) { SelectionEvent.fire(JQMCheckset.this, getValue()); ValueChangeEvent.fire(JQMCheckset.this, getValue()); } } }); } } }
@Override protected void onLoad() { super.onLoad(); bindCreated(getElement(), this); }
@Override protected void onUnload() { unbindCreated(getElement()); super.onUnload(); }
private void created() { // workaround for issue with data-iconpos resetting on js checkbox initialization IconPos pos = getIconPos(); if (pos != iconPos) { setIconPos(iconPos); refresh(); } // Also data-corners is ignored, and 'ui-corner-all' class is added on init if (JQMCommon.isCorners(label) != JQMCommon.isCornersEx(label)) { setCorners(JQMCommon.isCorners(label)); } }
@UiConstructor public JQMCheckbox(String name, String text) { this(); String id = Document.get().createUniqueId(); TextBox input = new TextBox(); input.getElement().setId(id); input.getElement().setAttribute("type", getInputType()); input.setName(name); FormLabel label = new FormLabel(); label.setFor(id); label.setText(text); init(input, label, null/* id for flow is not needed */); }
@Override public boolean isInline() { return JQMCommon.isInlineEx(getElement(), "ui-inline"); }
private void addLabelsBlurHandler(final BlurHandler handler) { for (JQMCheckbox cb : checks) { FormLabel label = cb.getLabel(); blurHandlers.add(label.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { handler.onBlur(null); } }, ClickEvent.getType())); } }
@Override public String getTheme() { if (checks.isEmpty()) return theme; return checks.get(0).getTheme(); }
@Override public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler) { // Initialization code if (!valueChangeHandlerInitialized) { valueChangeHandlerInitialized = true; input.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ValueChangeEvent.fire(JQMCheckbox.this, getValue()); } }); } return addHandler(handler, ValueChangeEvent.getType()); }
private void created() { // workaround for issue with data-iconpos resetting on js checkbox initialization IconPos pos = getIconPos(); if (pos != iconPos) { setIconPos(iconPos); refresh(); } // Also data-corners is ignored, and 'ui-corner-all' class is added on init if (JQMCommon.isCorners(label) != JQMCommon.isCornersEx(label)) { setCorners(JQMCommon.isCorners(label)); } }
@Override protected void onUnload() { unbindCreated(getElement()); super.onUnload(); }
@UiConstructor public JQMCheckbox(String name, String text) { this(); String id = Document.get().createUniqueId(); TextBox input = new TextBox(); input.getElement().setId(id); input.getElement().setAttribute("type", getInputType()); input.setName(name); FormLabel label = new FormLabel(); label.setFor(id); label.setText(text); init(input, label, null/* id for flow is not needed */); }
@Override public void setInline(boolean value) { JQMCommon.setInlineEx(getElement(), value, "ui-inline"); }
private void addLabelsBlurHandler(final BlurHandler handler) { for (JQMCheckbox cb : checks) { FormLabel label = cb.getLabel(); blurHandlers.add(label.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { handler.onBlur(null); } }, ClickEvent.getType())); } }
@Override public String getTheme() { if (checks.isEmpty()) return theme; return checks.get(0).getTheme(); }