use of com.vaadin.server.ErrorMessage in project VaadinUtils by rlsutton1.
the class ReportParameterTable method validateMe.
public void validateMe() {
grid.setComponentError(null);
setComponentErrorForValidateListener(null);
grid.setComponentError(null);
setComponentErrorForValidateListener(null);
Collection<Long> ids = getSelectedIds();
if (ids.size() == 0) {
ErrorMessage error = new ErrorMessage() {
private static final long serialVersionUID = -6437991860908562482L;
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.ERROR;
}
@Override
public String getFormattedHtmlMessage() {
return "You must select at least one " + caption;
}
};
grid.setComponentError(error);
setComponentErrorForValidateListener(error);
}
}
use of com.vaadin.server.ErrorMessage in project VaadinUtils by rlsutton1.
the class TimePicker method buildUI.
protected void buildUI(String title) {
field = new TextField();
field.setWidth("125");
field.setImmediate(true);
displayTime.setImmediate(true);
displayTime.addValidator(timeValidator);
field.addValidator(timeValidator);
field.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("deprecation")
@Override
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
try {
final Date parsedDate = parseDate((String) event.getProperty().getValue());
if (parsedDate != null) {
dateTime.set(Calendar.HOUR_OF_DAY, parsedDate.getHours());
dateTime.set(Calendar.MINUTE, parsedDate.getMinutes());
isSet = true;
setNewValue();
}
TimePicker.this.valueChange(event);
field.setComponentError(null);
} catch (final InvalidValueException e) {
field.setComponentError(new ErrorMessage() {
private static final long serialVersionUID = 1L;
@Override
public String getFormattedHtmlMessage() {
return e.getMessage();
}
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.ERROR;
}
});
}
}
});
this.title = title;
CssLayout hl = new CssLayout();
hl.addStyleName("v-component-group");
hl.setWidth("100%");
hl.setHeight("35");
pickerButton = new Button();
pickerButton.setIcon(FontAwesome.CLOCK_O);
hl.addComponent(pickerButton);
hl.addComponent(field);
pickerButton.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
showPopupTimePicker();
}
});
addComponent(hl);
}
use of com.vaadin.server.ErrorMessage in project cuba by cuba-platform.
the class WebSearchField method createComponent.
@Override
protected void createComponent() {
this.component = new CubaSearchSelect() {
@Override
public void setPropertyDataSource(Property newDataSource) {
if (newDataSource == null) {
super.setPropertyDataSource(null);
} else {
super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
}
}
@Override
public void setComponentError(ErrorMessage componentError) {
boolean handled = false;
if (componentErrorHandler != null) {
handled = componentErrorHandler.handleError(componentError);
}
if (!handled) {
super.setComponentError(componentError);
}
}
};
getSearchComponent().setFilterHandler(this::executeSearch);
}
use of com.vaadin.server.ErrorMessage in project cuba by cuba-platform.
the class WebLookupField method createComponent.
protected void createComponent() {
this.component = new CubaComboBox() {
@Override
public void setPropertyDataSource(Property newDataSource) {
if (newDataSource == null)
super.setPropertyDataSource(null);
else
super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
}
@Override
public void setComponentError(ErrorMessage componentError) {
boolean handled = false;
if (componentErrorHandler != null)
handled = componentErrorHandler.handleError(componentError);
if (!handled)
super.setComponentError(componentError);
}
};
}
use of com.vaadin.server.ErrorMessage in project VaadinUtils by rlsutton1.
the class ReportFilterUIBuilder method buildLayout.
@Override
public List<ExpanderComponent> buildLayout(Boolean hideDateFields) {
List<ExpanderComponent> components = new LinkedList<ExpanderComponent>();
boolean hasExpandingComponents = false;
Accordion accordian = null;
if (hasFilters()) {
for (ReportParameter<?> rparam : rparams) {
if (rparam.showFilter()) {
// scheduler
if (!hideDateFields || !rparam.isDateField()) {
if (rparam.shouldExpand()) {
if (accordian == null) {
accordian = new Accordion();
accordian.setSizeFull();
}
final Tab tab = accordian.addTab(rparam.getComponent(), rparam.getLabel(""));
rparam.addValidateListener(new ValidateListener() {
@Override
public void setComponentError(ErrorMessage componentError) {
tab.setComponentError(componentError);
}
});
rparam.validate();
} else {
components.add(new ExpanderComponent(rparam.getComponent(), rparam.shouldExpand()));
}
}
}
}
}
if (accordian != null) {
hasExpandingComponents = true;
components.add(new ExpanderComponent(accordian, true));
}
if (!hasExpandingComponents) {
// there are no expanding components, so add an empty expanding
// component so the fields will group together at the top
components.add(new ExpanderComponent(new VerticalLayout(), true));
}
// add 15px high layout to pack up the bottom of the layout, otherwise
// on
// some sets of filters the last component is hidden
VerticalLayout spacer = new VerticalLayout();
spacer.setHeight("15");
components.add(new ExpanderComponent(spacer, false));
return components;
}
Aggregations