/** * Checks whether captions are interpreted as html or plain text. * * @return true if the captions are used as html, false if used as plain * text * @see #setHtmlContentAllowed(boolean) */ public boolean isHtmlContentAllowed() { return getState(false).htmlContentAllowed; }
@Override public Registration addFocusListener(FocusListener listener) { return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); }
@Override protected AbstractSingleSelect<ITEM> buildInternalField(Class<? extends T> type) { RenderingMode mode = getRenderingMode(); if (mode == null) { mode = RenderingMode.SELECT; } if (mode == RenderingMode.NATIVE_SELECT) { final NativeSelect<ITEM> field = new NativeSelect<>(); field.setItemCaptionGenerator(i -> generateItemCaption(i)); field.addSelectionListener(e -> setupDescriptionFromSelection(e)); field.addSelectionListener(e -> fireSelectionListeners(buildSelectionEvent(e))); return field; } if (mode == RenderingMode.OPTIONS) { final RadioButtonGroup<ITEM> field = new RadioButtonGroup<>(); field.setItemCaptionGenerator(i -> generateItemCaption(i)); field.setItemIconGenerator(i -> generateItemIcon(i)); field.setItemDescriptionGenerator(i -> generateItemDescription(i)); field.addSelectionListener(e -> fireSelectionListeners(buildSelectionEvent(e))); return field; } final ComboBox<ITEM> field = new ComboBox<>(); field.setItemCaptionGenerator(i -> generateItemCaption(i)); field.setItemIconGenerator(i -> generateItemIcon(i)); field.addSelectionListener(e -> setupDescriptionFromSelection(e)); field.addSelectionListener(e -> fireSelectionListeners(buildSelectionEvent(e))); return field; }
private RadioButtonGroup createCreditOrDebit () { RadioButtonGroup<Boolean> radio = new RadioButtonGroup<>(); radio.setItems(Boolean.FALSE, Boolean.TRUE); radio.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL); ItemCaptionGenerator itemCaptionGenerator = (ItemCaptionGenerator) item -> Boolean.TRUE.equals(item) ? app.getMessage("credit") : app.getMessage("debit"); radio.setItemCaptionGenerator(itemCaptionGenerator); return radio; }
@Override protected RadioButtonGroup<T> createSelectionField() { return new RadioButtonGroup<>(); } }
@Override protected void readItems(Element design, DesignContext context) { setItemEnabledProvider(new DeclarativeItemEnabledProvider<>()); super.readItems(design, context); }
registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent)); addDataGenerator(new DataGenerator<T>() { @Override public void generateData(T data, JsonObject jsonObject) {
/** * Sets the description generator that is used for generating descriptions * for items. Description is shown as a tooltip when hovering on * corresponding element. If the generator returns {@code null}, no tooltip * is shown. * * @param descriptionGenerator * the item description generator to set, not {@code null} * * @since 8.2 */ public void setItemDescriptionGenerator( DescriptionGenerator<T> descriptionGenerator) { Objects.requireNonNull(descriptionGenerator); if (this.descriptionGenerator != descriptionGenerator) { this.descriptionGenerator = descriptionGenerator; getDataProvider().refreshAll(); } }
@SuppressWarnings("unchecked") public void setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider) { if (getInternalField() instanceof RadioButtonGroup) { ((RadioButtonGroup<T>) getInternalField()).setItemEnabledProvider(itemEnabledProvider); } }
/** * Sets whether html is allowed in the item captions. If set to true, the * captions are passed to the browser as html and the developer is * responsible for ensuring no harmful html is used. If set to false, the * content is passed to the browser as plain text. * * @param htmlContentAllowed * true if the captions are used as html, false if used as plain * text */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { getState().htmlContentAllowed = htmlContentAllowed; }
@Override public Registration addBlurListener(BlurListener listener) { return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); }
@Override protected CubaRadioButtonGroupState getState() { return ((CubaRadioButtonGroupState) super.getState()); }
@Override protected CubaRadioButtonGroupState getState(boolean markAsDirty) { return ((CubaRadioButtonGroupState) super.getState(markAsDirty)); }