/** * Checks and answers whether this validation result has messages or not. * * @return true if there are messages, false if not * * @see #getSeverity() * @see #hasErrors() * @see #hasWarnings() */ public boolean hasMessages() { return !isEmpty(); }
/** * Checks and answers whether this validation result has messages or not. * * @return true if there are messages, false if not * * @see #getSeverity() * @see #hasErrors() * @see #hasWarnings() */ public boolean hasMessages() { return !isEmpty(); }
private void updateComponentTreeMandatoryAndSeverity(ValidationResult result) { acceptAction.setEnabled(result.isEmpty()); }
/** * Returns a string representation intended for debugging purposes. * * @return a string representation intended for debugging * @see Object#toString() */ @Override public String toString() { if (isEmpty()) { return "Empty ValidationResult"; } StringBuilder builder = new StringBuilder(); builder.append(modifiable ? "Modifiable" : "Unmodifiable"); builder.append(" ValidationResult:"); for (ValidationMessage message : messageList) { builder.append("\n\t").append(message); } return builder.toString(); }
/** * Returns a string representation intended for debugging purposes. * * @return a string representation intended for debugging * @see Object#toString() */ @Override public String toString() { if (isEmpty()) { return "Empty ValidationResult"; } StringBuilder builder = new StringBuilder(); builder.append(modifiable ? "Modifiable" : "Unmodifiable"); builder.append(" ValidationResult:"); for (ValidationMessage message : messageList) { builder.append("\n\t").append(message); } return builder.toString(); }
private static void updateText(JLabel label, ValidationResult result) { if (result.isEmpty()) { label.setText(""); return; } Severity severity = result.getSeverity(); for (ValidationMessage message : result) { if (message.severity() == severity) { label.setText(message.formattedText()); return; } } }
protected abstract void updateValidation(ValidationResult result);
private void insertComponents() { ValidationResult result = model.getResult(); if (!result.isEmpty()) { for (ValidationMessage vm : result.getMessages()) { if (vm.key() instanceof JComponent) { Component c = (Component) vm.key(); if (c instanceof IToolTippableComponent) { c = ((IToolTippableComponent) c).getToolTipableComponent(); } List<ValidationMessage> vs = componentMap.get(c); if (vs == null) { vs = new ArrayList<ValidationMessage>(); componentMap.put(c, vs); c.addFocusListener(this); } vs.add(vm); Collections.sort(vs, SEVERITY_COMPARATOR); } } showWindow(); } }
/** * Sets the component background according to the associated * validation result: default, error, warning. * * @param component the component to be visited * @param keyMap maps messages keys to associated validation results */ public void visit(JComponent component, Map<Object, ValidationResult> keyMap) { Object messageKeys = getMessageKeys(component); if (messageKeys == null) { return; } JTextComponent textChild = (JTextComponent) component; ensureCustomBackgroundStored(textChild); ValidationResult result = getAssociatedResult(component, keyMap); if ((result == null) || result.isEmpty()) { restoreBackground(textChild); } else if (result.hasErrors()) { setErrorBackground(textChild); } else if (result.hasWarnings()) { setWarningBackground(textChild); } } }
/** * Sets the component background according to the associated * validation result: default, error, warning. * * @param component the component to be visited * @param keyMap maps messages keys to associated validation results */ @Override public void visit(JComponent component, Map<Object, ValidationResult> keyMap) { Object messageKeys = getMessageKeys(component); if (messageKeys == null) { return; } JTextComponent textChild = (JTextComponent) component; ensureCustomBackgroundStored(textChild); ValidationResult result = getAssociatedResult(component, keyMap); if (result == null || result.isEmpty()) { restoreBackground(textChild); } else if (result.hasErrors()) { setErrorBackground(textChild); } else if (result.hasWarnings()) { setWarningBackground(textChild); } } }