/** * Notifies all registered ListDataListeners that the ValidationResult * in this adapter's underlying ValidationResultModel has changed. */ public void propertyChange(PropertyChangeEvent evt) { int newSize = getSize(); int oldLastIndex = oldSize - 1; int newLastIndex = newSize - 1; oldSize = newSize; fireListChanged(oldLastIndex, newLastIndex); }
/** * Traverses a component tree and sets mandatory backgrounds * to text components that have blank content and have been marked * as mandatory with {@link #setMandatory(JComponent, boolean)} before. * The iteration starts at the given container. * * @param container the component tree root * * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBackground(JTextComponent) */ public static void updateComponentTreeMandatoryAndBlankBackground(Container container) { visitComponentTree(container, null, new MandatoryAndBlankBackgroundVisitor()); }
/** * Traverses a component tree and sets mandatory borders * to text components that have been marked as mandatory * with {@link #setMandatory(JComponent, boolean)} before. * The iteration starts at the given container. * * @param container the component tree root * * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBorder(JTextComponent) */ public static void updateComponentTreeMandatoryBorder(Container container) { visitComponentTree(container, null, new MandatoryBorderVisitor()); }
protected void addValidationComponentUtils(JComponent component, String text) { ValidationComponentUtils.setMandatory(component, true); ValidationComponentUtils.setInputHint(component, text); ValidationComponentUtils.setMessageKey(component, component); }
/** * 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 */ public void visit(JComponent component, Map<Object, ValidationResult> keyMap) { if ((component instanceof JTextComponent) && isMandatory(component)) { setMandatoryBorder((JTextComponent) component); } } }
/** * Traverses a component tree and sets mandatory backgrounds * to text components that have been marked as mandatory * with {@link #setMandatory(JComponent, boolean)} before. * The iteration starts at the given container. * * @param container the component tree root * * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBackground(JTextComponent) */ public static void updateComponentTreeMandatoryBackground(Container container) { visitComponentTree(container, null, new MandatoryBackgroundVisitor()); }
protected ValidationResult getAssociatedResult(JComponent comp, Map<Object, ValidationResult> keyMap) { ValidationResult result = ValidationComponentUtils.getAssociatedResult( comp, keyMap); return result == null ? ValidationResult.EMPTY : result; } }
/** * Creates and returns a text area that is intended to show validation * messages. The area is bound to the given {@link ValidationResultModel}: the text content reflects * the validation result message text and the component is visible * if and only if the model has messages. * * @param model the model that provides the observable validation result * @return a text area intended to show validation messages */ public static JTextArea createReportTextArea(ValidationResultModel model) { return createReportTextArea(model, DEFAULT_REPORT_BACKGROUND); }
/** * Creates and returns a list that presents validation messages. * The list content is bound to the given {@link ValidationResultModel} * using a {@link ValidationResultListAdapter}. * * @param model the model that provides the observable validation result * @return a {@code JList} that shows validation messages */ public static JComponent createReportList(ValidationResultModel model) { return createReportList(model, DEFAULT_REPORT_BACKGROUND); }
/** * Creates and returns a text area wrapped by a scroll pane that is * intended to show validation messages. The component is bound to * the given {@link ValidationResultModel}: the text content reflects * the validation result message text and the component is visible * if and only if the model has messages. * * @param model the model that provides the observable validation result * @return a scrollable text component intended to show validation messages */ public static JComponent createReportTextPane(ValidationResultModel model) { return createReportTextPane(model, DEFAULT_REPORT_BACKGROUND); }
private void addValidationComponentUtils(JComponent component, Object value, String text) { ValidationComponentUtils.setMandatory(component, true); ValidationComponentUtils.setInputHint(component, text); ValidationComponentUtils.setMessageKey(component, value); }
/** * 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); } }
/** * Notifies all registered ListDataListeners that the ValidationResult * in this adapter's underlying ValidationResultModel has changed. */ @Override public void propertyChange(PropertyChangeEvent evt) { int newSize = getSize(); int oldLastIndex = oldSize - 1; int newLastIndex = newSize - 1; oldSize = newSize; fireListChanged(oldLastIndex, newLastIndex); }
/** * Traverses a component tree and sets mandatory backgrounds * to text components that have blank content and have been marked * as mandatory with {@link #setMandatory(JComponent, boolean)} before. * The iteration starts at the given container. * * @param container the component tree root * * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBackground(JTextComponent) */ public static void updateComponentTreeMandatoryAndBlankBackground(Container container) { visitComponentTree(container, null, new MandatoryAndBlankBackgroundVisitor()); }
/** * Traverses a component tree and sets mandatory borders * to text components that have been marked as mandatory * with {@link #setMandatory(JComponent, boolean)} before. * The iteration starts at the given container. * * @param container the component tree root * * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBorder(JTextComponent) */ public static void updateComponentTreeMandatoryBorder(Container container) { visitComponentTree(container, null, new MandatoryBorderVisitor()); }
/** * Traverses a component tree and sets mandatory backgrounds * to text components that have been marked as mandatory * with {@link #setMandatory(JComponent, boolean)} before. * The iteration starts at the given container. * * @param container the component tree root * * @see #setMandatory(JComponent, boolean) * @see #setMandatoryBackground(JTextComponent) */ public static void updateComponentTreeMandatoryBackground(Container container) { visitComponentTree(container, null, new MandatoryBackgroundVisitor()); }
/** * Creates and returns a text area that is intended to show validation * messages. The area is bound to the given {@link ValidationResultModel}: the text content reflects * the validation result message text and the component is visible * if and only if the model has messages. * * @param model the model that provides the observable validation result * @return a text area intended to show validation messages */ public static JTextArea createReportTextArea(ValidationResultModel model) { return createReportTextArea(model, DEFAULT_REPORT_BACKGROUND); }
/** * Creates and returns a list that presents validation messages. * The list content is bound to the given {@link ValidationResultModel} * using a {@link ValidationResultListAdapter}. * * @param model the model that provides the observable validation result * @return a <code>JList</code> that shows validation messages */ public static JComponent createReportList(ValidationResultModel model) { return createReportList(model, DEFAULT_REPORT_BACKGROUND); }
/** * Creates and returns a text area wrapped by a scroll pane that is * intended to show validation messages. The component is bound to * the given {@link ValidationResultModel}: the text content reflects * the validation result message text and the component is visible * if and only if the model has messages. * * @param model the model that provides the observable validation result * @return a scrollable text component intended to show validation messages */ public static JComponent createReportTextPane(ValidationResultModel model) { return createReportTextPane(model, DEFAULT_REPORT_BACKGROUND); }