List of usage examples for com.vaadin.ui AbstractComponent setComponentError
public void setComponentError(ErrorMessage componentError)
From source file:annis.gui.ReportBugWindow.java
License:Apache License
public ReportBugWindow(final String bugEMailAddress, final byte[] screenImage, final String imageMimeType, Throwable cause) {//from w w w . j a v a 2 s .c om this.cause = cause; setSizeUndefined(); setCaption("Report Problem"); ReportFormLayout layout = new ReportFormLayout(); setContent(layout); layout.setWidth("100%"); layout.setHeight("-1px"); setHeight("420px"); setWidth("750px"); form = new FieldGroup(new BeanItem<>(new BugReport())); form.bindMemberFields(layout); form.setBuffered(true); final ReportBugWindow finalThis = this; btSubmit = new Button("Submit problem report", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { form.commit(); if (sendBugReport(bugEMailAddress, screenImage, imageMimeType)) { Notification.show("Problem report was sent", "We will answer your problem report as soon as possible", Notification.Type.HUMANIZED_MESSAGE); } UI.getCurrent().removeWindow(finalThis); } catch (FieldGroup.CommitException ex) { List<String> errorFields = new LinkedList<>(); for (Field f : form.getFields()) { if (f instanceof AbstractComponent) { AbstractComponent c = (AbstractComponent) f; if (f.isValid()) { c.setComponentError(null); } else { errorFields.add(f.getCaption()); c.setComponentError(new UserError("Validation failed: ")); } } } // for each field String message = "Please check the error messages " + "(place mouse over red triangle) for the following fields:<br />"; message = message + StringUtils.join(errorFields, ",<br/>"); Notification notify = new Notification("Validation failed", message, Notification.Type.WARNING_MESSAGE, true); notify.show(UI.getCurrent().getPage()); } catch (Exception ex) { log.error("Could not send bug report", ex); Notification.show("Could not send bug report", ex.getMessage(), Notification.Type.WARNING_MESSAGE); } } }); btCancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { form.discard(); UI.getCurrent().removeWindow(finalThis); } }); addScreenshotPreview(layout, screenImage, imageMimeType); HorizontalLayout buttons = new HorizontalLayout(); buttons.addComponent(btSubmit); buttons.addComponent(btCancel); layout.addComponent(buttons); }
From source file:com.expressui.core.view.field.FormField.java
License:Open Source License
/** * Clears any errors on this field./* w w w .j a va 2s .co m*/ * * @param clearConversionError true to clear data-type conversion error as well */ public void clearError(boolean clearConversionError) { if (clearConversionError) { hasConversionError = false; } if (getField() instanceof AbstractComponent) { AbstractComponent abstractComponent = (AbstractComponent) getField(); abstractComponent.setComponentError(null); } }
From source file:com.expressui.core.view.field.FormField.java
License:Open Source License
/** * Add error message to this field./*ww w .j ava2 s .co m*/ * * @param errorMessage error message, builds Vaadin composite error message */ public void addError(ErrorMessage errorMessage) { Assert.PROGRAMMING.instanceOf(getField(), AbstractComponent.class, "Error message cannot be added to field that is not an AbstractComponent for property " + getTypeAndPropertyId()); AbstractComponent abstractComponent = (AbstractComponent) getField(); ErrorMessage existingErrorMessage = abstractComponent.getComponentError(); if (existingErrorMessage == null) { abstractComponent.setComponentError(errorMessage); } else if (existingErrorMessage instanceof CompositeErrorMessage) { CompositeErrorMessage existingCompositeErrorMessage = (CompositeErrorMessage) existingErrorMessage; Iterator<ErrorMessage> iterator = existingCompositeErrorMessage.iterator(); Set<ErrorMessage> newErrorMessages = new LinkedHashSet<ErrorMessage>(); while (iterator.hasNext()) { ErrorMessage next = iterator.next(); newErrorMessages.add(next); } newErrorMessages.add(errorMessage); CompositeErrorMessage newCompositeErrorMessage = new CompositeErrorMessage(newErrorMessages); abstractComponent.setComponentError(newCompositeErrorMessage); } else { Set<ErrorMessage> newErrorMessages = new LinkedHashSet<ErrorMessage>(); newErrorMessages.add(existingErrorMessage); newErrorMessages.add(errorMessage); CompositeErrorMessage newCompositeErrorMessage = new CompositeErrorMessage(newErrorMessages); abstractComponent.setComponentError(newCompositeErrorMessage); } }
From source file:com.expressui.core.view.form.FormFieldSet.java
License:Open Source License
/** * Sets component error./*from w ww .java 2s.c om*/ * * @param propertyId property id to identify field to set * @param errorMessage error message */ public void setComponentError(String propertyId, ErrorMessage errorMessage) { Assert.PROGRAMMING.instanceOf(getFormField(propertyId).getField(), AbstractComponent.class); AbstractComponent abstractComponent = (AbstractComponent) getFormField(propertyId).getField(); abstractComponent.setComponentError(errorMessage); }
From source file:com.haulmont.cuba.web.gui.components.WebAbstractComponent.java
License:Apache License
protected void setValidationError(String errorMessage) { if (getComposition() instanceof AbstractComponent) { AbstractComponent composition = (AbstractComponent) getComposition(); if (errorMessage == null) { composition.setComponentError(null); } else {//from w w w. j a va2s . com composition.setComponentError(new UserError(errorMessage)); } } }
From source file:com.lizardtech.expresszip.vaadin.ExportOptionsViewComponent.java
License:Apache License
public void setComponentErrorMessage(AbstractComponent c, String message) { c.setComponentError(new UserError(message)); }
From source file:com.lizardtech.expresszip.vaadin.ExportOptionsViewComponent.java
License:Apache License
public void clearComponentErrorMessage(AbstractComponent c) { c.setComponentError(null); }
From source file:com.lst.deploymentautomation.vaadin.util.Utils.java
License:Open Source License
/** * Shows (or hides, if msg is null) localized error message on the given component. * @param component//from w w w . j a v a 2 s . c o m * @param msg * @param args */ public static void setComponentError(AbstractComponent component, String msg, Object... args) { if (msg == null) { component.setComponentError(null); } else { String localizedMsg = getLocalizedString(component.getUI().getLocale(), msg, args); component.setComponentError(new UserError(localizedMsg)); } }
From source file:com.purebred.core.view.field.FormField.java
License:Open Source License
/** * Add error message to this field.// ww w.j av a 2 s . c om * * @param errorMessage error message, builds Vaadin composite error message */ public void addError(ErrorMessage errorMessage) { Assert.PROGRAMMING.assertTrue(getField() instanceof AbstractComponent, "Error message cannot be added to field that is not an AbstractComponent"); AbstractComponent abstractComponent = (AbstractComponent) getField(); ErrorMessage existingErrorMessage = abstractComponent.getComponentError(); if (existingErrorMessage == null) { abstractComponent.setComponentError(errorMessage); } else if (existingErrorMessage instanceof CompositeErrorMessage) { CompositeErrorMessage existingCompositeErrorMessage = (CompositeErrorMessage) existingErrorMessage; Iterator<ErrorMessage> iterator = existingCompositeErrorMessage.iterator(); Set<ErrorMessage> newErrorMessages = new LinkedHashSet<ErrorMessage>(); while (iterator.hasNext()) { ErrorMessage next = iterator.next(); newErrorMessages.add(next); } newErrorMessages.add(errorMessage); CompositeErrorMessage newCompositeErrorMessage = new CompositeErrorMessage(newErrorMessages); abstractComponent.setComponentError(newCompositeErrorMessage); } else { Set<ErrorMessage> newErrorMessages = new LinkedHashSet<ErrorMessage>(); newErrorMessages.add(existingErrorMessage); newErrorMessages.add(errorMessage); CompositeErrorMessage newCompositeErrorMessage = new CompositeErrorMessage(newErrorMessages); abstractComponent.setComponentError(newCompositeErrorMessage); } }
From source file:com.purebred.core.view.field.FormFields.java
License:Open Source License
public void setComponentError(String propertyId, ErrorMessage errorMessage) { Assert.PROGRAMMING.assertTrue(getFormField(propertyId).getField() instanceof AbstractComponent, "field is not of the right type"); AbstractComponent abstractComponent = (AbstractComponent) getFormField(propertyId).getField(); abstractComponent.setComponentError(errorMessage); }