@Override public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { final ActorConsumer<?, Color> listener = parser.parseAction(rawAttributeData, Color.WHITE); if (listener == null) { parser.throwErrorIfStrict( "Color picker attribute needs a reference to an action that consumes a Color instance. No method found for ID: " + rawAttributeData); return; } final ColorPickerListener colorPickerListener = getListener(listener); actor.addListener(new ClickListener() { @Override public void clicked(final InputEvent event, final float x, final float y) { if (actor instanceof Disableable && ((Disableable) actor).isDisabled()) { return; } final ColorPicker colorPicker = ColorPickerContainer.requestInstance(); colorPicker.setListener(null); colorPicker.setColor(actor.getColor()); colorPicker.setListener(colorPickerListener); colorPicker.centerWindow(); actor.getStage().addActor(colorPicker.fadeIn()); } }); }
private void updateWidgets () { for (Disableable disableable : disableTargets) { disableable.setDisabled(formInvalid); } if (messageLabel != null) { if (errorMsgText != null) { messageLabel.setText(errorMsgText); } else { messageLabel.setText(successMsg); //setText will default to "" if successMsg is null } Color targetColor = errorMsgText != null ? style.errorLabelColor : style.validLabelColor; if (targetColor != null && style.colorTransitionDuration != 0) { messageLabel.addAction(Actions.color(targetColor, style.colorTransitionDuration)); } else { messageLabel.setColor(targetColor); } } }
@Override public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { if (actor instanceof Disableable) { ((Disableable) actor).setDisabled(parser.parseBoolean(rawAttributeData, actor)); } else { parser.throwErrorIfStrict( "This widget cannot be disabled, as it does not implement Disableable interface. Received disabled attribute on tag: " + tag.getTagName() + " with actor: " + actor); } }
@Override protected void processFormAttribute(final LmlParser parser, final LmlTag tag, final VisFormTable parent, final Actor actor, final String rawAttributeData) { if (actor instanceof Disableable) { if (parser.parseBoolean(rawAttributeData, actor)) { parent.addWidgetToDisable((Disableable) actor); } } else { parser.throwErrorIfStrict( "Only Disableable widgets can be attached to the form with this attribute. Found widget that does not implement Disableable attribute: " + actor + " with tag: " + tag.getTagName()); } }
@Override public void clicked(final InputEvent event, final float x, final float y) { if (actor instanceof Disableable && ((Disableable) actor).isDisabled()) { return; } actor.getStage().addActor(visWindow.fadeIn()); }
/** * Sets the enabled property on the given components * * @param enabled * @param components */ protected void enableComponents(boolean enabled, Disableable... components) { for (Disableable c : components) { if (c != null) c.setDisabled(!enabled); } }
/** See {@link SimpleFormValidator#addDisableTarget(Disableable)}. * * @param disableable will be disabled if any errors are found in the form. */ public void addWidgetToDisable(final Disableable disableable) { formValidator.addDisableTarget(disableable); }
/** * @param targetToDisable target actor that will be disabled if form is invalid. Eg. you can pass form Confirm button. * May be null. * @param messageLabel label that text will be changed if from is valid or invalid. May be null. */ public SimpleFormValidator (Disableable targetToDisable, Label messageLabel, FormValidatorStyle style) { this.style = style; if (targetToDisable != null) disableTargets.add(targetToDisable); this.messageLabel = messageLabel; }
public void addDisableTarget (Disableable disableable) { disableTargets.add(disableable); updateWidgets(); }
public boolean removeDisableTarget (Disableable disableable) { boolean result = disableTargets.removeValue(disableable, true); updateWidgets(); return result; }
/** @see SimpleFormValidator#SimpleFormValidator(Disableable) */ public FormValidator (Disableable targetToDisable) { super(targetToDisable); }
/** @see SimpleFormValidator#SimpleFormValidator(Disableable, Label) */ public FormValidator (Disableable targetToDisable, Label messageLabel) { super(targetToDisable, messageLabel); }
/** @see SimpleFormValidator#SimpleFormValidator(Disableable, Label, String) */ public FormValidator (Disableable targetToDisable, Label messageLabel, String styleName) { super(targetToDisable, messageLabel, styleName); }
/** @see SimpleFormValidator#SimpleFormValidator(Disableable, Label, FormValidatorStyle) */ public FormValidator (Disableable targetToDisable, Label messageLabel, FormValidatorStyle style) { super(targetToDisable, messageLabel, style); }
public EnableActionListener(Disableable disableable) { this.disableable = disableable; }
/** * @param targetToDisable target actor that will be disabled if form is invalid. Eg. you can pass form Confirm button. * May be null. */ public SimpleFormValidator (Disableable targetToDisable) { this(targetToDisable, null, "default"); }
/** * @param targetToDisable target actor that will be disabled if form is invalid. Eg. you can pass form Confirm button. * May be null. * @param messageLabel label that text will be changed if from is valid or invalid. May be null. */ public SimpleFormValidator (Disableable targetToDisable, Label messageLabel) { this(targetToDisable, messageLabel, "default"); }
/** * @param targetToDisable target actor that will be disabled if form is invalid. Eg. you can pass form Confirm button. * May be null. * @param messageLabel label that text will be changed if from is valid or invalid. May be null. */ public SimpleFormValidator (Disableable targetToDisable, Label messageLabel, String styleName) { this(targetToDisable, messageLabel, VisUI.getSkin().get(styleName, FormValidatorStyle.class)); }
/** * @param actor might be a {@link Disableable}. * @return true if actor is disabled. */ protected boolean isDisabled (final Actor actor) { return actor instanceof Disableable && ((Disableable) actor).isDisabled(); }