/** * Marks the given component as mandatory or optional. * The value will be stored as a client property value. * * @param comp the component to be marked * @param mandatory true for mandatory, false for optional * * @see #isMandatory(JComponent) * @see #isMandatoryAndBlank(JComponent) * @see #setMandatoryBackground(JTextComponent) * @see #setMandatoryBorder(JTextComponent) */ public static void setMandatory(JComponent comp, boolean mandatory) { boolean oldMandatory = isMandatory(comp); if (oldMandatory != mandatory) { comp.putClientProperty(MANDATORY_KEY, Boolean.valueOf(mandatory)); } }
/** * Marks the given component as mandatory or optional. * The value will be stored as a client property value. * * @param comp the component to be marked * @param mandatory true for mandatory, false for optional * * @see #isMandatory(JComponent) * @see #isMandatoryAndBlank(JComponent) * @see #setMandatoryBackground(JTextComponent) * @see #setMandatoryBorder(JTextComponent) */ public static void setMandatory(JComponent comp, boolean mandatory) { boolean oldMandatory = isMandatory(comp); if (oldMandatory != mandatory) { comp.putClientProperty(MANDATORY_KEY, Boolean.valueOf(mandatory)); } }
/** * Sets the mandatory background to text components that have been marked * as mandatory. * * @param component the component to be visited * @param keyMap ignored */ public void visit(JComponent component, Map<Object, ValidationResult> keyMap) { if ((component instanceof JTextComponent) && isMandatory(component)) { setMandatoryBackground((JTextComponent) component); } }
/** * Sets the mandatory border to text components that have been marked * as mandatory. * * @param component the component to be visited * @param keyMap ignored */ @Override public void visit(JComponent component, Map<Object, ValidationResult> keyMap) { if (component instanceof JTextComponent && isMandatory(component)) { setMandatoryBorder((JTextComponent) component); } } }
/** * Sets the mandatory border to text components that have been marked * as mandatory. * * @param component the component to be visited * @param keyMap ignored */ public void visit(JComponent component, Map<Object, ValidationResult> keyMap) { if ((component instanceof JTextComponent) && isMandatory(component)) { setMandatoryBorder((JTextComponent) component); } } }
/** * Sets the mandatory background to text components that have been marked * as mandatory. * * @param component the component to be visited * @param keyMap ignored */ @Override public void visit(JComponent component, Map<Object, ValidationResult> keyMap) { if (component instanceof JTextComponent && isMandatory(component)) { setMandatoryBackground((JTextComponent) component); } }
/** * Returns if the component is a {@link JTextComponent} with blank content * and has been marked as mandatory. * * @param comp the component to be checked * @return true if the component's has a blank content and has been marked * as mandatory * * @see #isMandatory(JComponent) * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBackground(JTextComponent) * @see #setMandatoryBorder(JTextComponent) */ public static boolean isMandatoryAndBlank(JComponent comp) { if (!(comp instanceof JTextComponent)) { return false; } JTextComponent textComponent = (JTextComponent) comp; return isMandatory(textComponent) && ValidationUtils.isBlank(textComponent.getText()); }
/** * Returns if the component is a {@link JTextComponent} with blank content * and has been marked as mandatory. * * @param comp the component to be checked * @return true if the component's has a blank content and has been marked * as mandatory * * @see #isMandatory(JComponent) * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBackground(JTextComponent) * @see #setMandatoryBorder(JTextComponent) */ public static boolean isMandatoryAndBlank(JComponent comp) { if (!(comp instanceof JTextComponent)) { return false; } JTextComponent textComponent = (JTextComponent) comp; return isMandatory(textComponent) && Strings.isBlank(textComponent.getText()); }
if ( ValidationComponentUtils.isMandatory( component ) ) { ValidationComponentUtils.updateComponentTreeMandatoryAndBlankBackground( metawidget );