List of usage examples for com.vaadin.ui AbstractComponent setComponentError
public void setComponentError(ErrorMessage componentError)
From source file:com.shopwiki.vaadin.Errors.java
License:Apache License
public static void set(AbstractComponent component, String errorMsg) { component.setComponentError(new UserError(errorMsg)); }
From source file:com.shopwiki.vaadin.Errors.java
License:Apache License
public static void clear(AbstractComponent component) { component.setComponentError(null); }
From source file:de.symeda.sormas.ui.SormasErrorHandler.java
License:Open Source License
public static void handleError(ErrorEvent event) { final Throwable t = event.getThrowable(); if (t instanceof SocketException) { // Most likely client browser closed socket logger.info(/*from w w w . jav a2s . c o m*/ "SocketException in CommunicationManager." + " Most likely client (browser) closed socket."); return; } ErrorMessage errorMessage = getErrorMessageForException(t); if (t != null) { // log the error or warning if (errorMessage instanceof SystemError) { logger.error(t.getMessage(), t); } else { logger.warn(t.getMessage(), t); } } // finds the original source of the error/exception AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event); if (errorMessage != null && component != null) { // Shows the error in AbstractComponent if (errorMessage instanceof SystemError) { Notification.show( I18nProperties.getString(Strings.errorOccurred, I18nProperties.getString(Strings.errorOccurred)), I18nProperties.getString(Strings.errorWasReported), Notification.Type.ERROR_MESSAGE); } else { // to prevent the original message from appearing, if necessary if (component instanceof AbstractField<?>) { ((AbstractField<?>) component).setCurrentBufferedSourceException(null); } Notification notification = new Notification( I18nProperties.getString(Strings.errorProblemOccurred, I18nProperties.getString(Strings.errorProblemOccurred)), errorMessage.getFormattedHtmlMessage(), Notification.Type.WARNING_MESSAGE, true); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); component.setComponentError(errorMessage); } } }
From source file:org.abstractform.binding.vaadin.internal.VaadinBindingFormInstanceImpl.java
License:Apache License
@Override public void setError(String fieldId, List<String> errors) { Component c = getComponentById(fieldId); List<String> realErrors = removeNullValues(errors); if (c instanceof AbstractComponent) { AbstractComponent co = (AbstractComponent) c; if (errors == null || errors.size() == 0) { co.setComponentError(null); } else if (realErrors.size() == 1) { co.setComponentError(new UserError(realErrors.get(0))); } else {/*from w w w. ja v a2 s . c o m*/ List<ErrorMessage> errorList = new ArrayList<ErrorMessage>(realErrors.size()); for (String error : realErrors) { errorList.add(new UserError(error)); } co.setComponentError(new CompositeErrorMessage(errorList)); } } else { // TODO Warning? Exception? assert false; } }
From source file:org.eclipse.emf.ecp.view.core.vaadin.AbstractControlRendererVaadin.java
License:Open Source License
@Override protected void applyValidation() { // TODO: FIXME Register final AbstractComponent abstractComponent = (AbstractComponent) getControlComponent(); abstractComponent.setComponentError(null); if (getVElement().getDiagnostic() == null) { return;/*from w w w . j a v a 2 s . c om*/ } if (Diagnostic.ERROR == getVElement().getDiagnostic().getHighestSeverity()) { abstractComponent.setComponentError(new UserError(getVElement().getDiagnostic().getMessage())); } }
From source file:org.eclipse.skalli.view.component.LinkWindow.java
License:Open Source License
private void validateInput(Validatable validatable) { try {//from w w w . j ava 2s . c om validatable.validate(); } catch (EmptyValueException e) { final AbstractComponent component = (AbstractComponent) validatable; component.setComponentError(new UserError("This field is required.")); ((Field) component).addListener(new ValueNotLongerEmptyListener()); } catch (InvalidValueException e) { // Automatically handled by validator implementations (onValueChange) LOG.debug("Invalid value", e); //$NON-NLS-1$ } }
From source file:org.lunarray.model.generation.vaadin.components.impl.EntityValidationListener.java
License:Open Source License
/** {@inheritDoc} */ @Override// ww w. j ava2 s . c om public void buttonClick(final ClickEvent event) { for (final String property : this.formComponent.getProperties()) { final Field field = this.formComponent.getForm().getField(property); if (field instanceof AbstractComponent) { final AbstractComponent component = (AbstractComponent) field; component.setComponentError(null); } } final EntityValidator validator = this.formComponent.getModel().getExtension(EntityValidator.class); if (!CheckUtil.isNull(validator)) { final Collection<PropertyViolation<E, ?>> violations = validator .validate(this.formComponent.getEntityDescriptor(), this.formComponent.getEntity()); for (final PropertyViolation<E, ?> violation : violations) { this.processViolation(violation); } } }
From source file:org.lunarray.model.generation.vaadin.components.impl.EntityValidationListener.java
License:Open Source License
/** * Process a violation./*from w w w. ja va 2 s.c om*/ * * @param violation * The violation. */ private void processViolation(final PropertyViolation<?, ?> violation) { final Field field = this.formComponent.getForm().getField(violation.getProperty().getName()); if (field instanceof AbstractComponent) { final AbstractComponent component = (AbstractComponent) field; component.setComponentError(new UserError(violation.getMessage())); } }
From source file:org.vaadin.viritin.MBeanFieldGroup.java
License:Apache License
protected boolean jsr303ValidateBean(T bean) { try {/*from w w w . java2 s. com*/ if (javaxBeanValidator == null) { javaxBeanValidator = getJavaxBeanValidatorFactory().getValidator(); } } catch (Throwable t) { // This may happen without JSR303 validation framework Logger.getLogger(getClass().getName()).fine("JSR303 validation failed"); return true; } Set<ConstraintViolation<T>> constraintViolations = new HashSet( javaxBeanValidator.validate(bean, getValidationGroups())); if (constraintViolations.isEmpty()) { return true; } Iterator<ConstraintViolation<T>> iterator = constraintViolations.iterator(); while (iterator.hasNext()) { ConstraintViolation<T> constraintViolation = iterator.next(); Class<? extends Annotation> annotationType = constraintViolation.getConstraintDescriptor() .getAnnotation().annotationType(); AbstractComponent errortarget = validatorToErrorTarget.get(annotationType); if (errortarget != null) { // user has declared a target component for this constraint errortarget.setComponentError(new UserError(constraintViolation.getMessage())); iterator.remove(); } // else leave as "bean level error" } this.jsr303beanLevelViolations = constraintViolations; return false; }
From source file:org.vaadin.viritin.MBeanFieldGroup.java
License:Apache License
private void clearMValidationErrors() { for (AbstractComponent value : mValidationErrors.values()) { if (value != null) { value.setComponentError(null); }//from w w w .ja va 2 s . c o m } mValidationErrors.clear(); for (AbstractComponent ac : validatorToErrorTarget.values()) { ac.setComponentError(null); } }