I have this code:
package eu.relsys.vdma.vaadin.ui.Selector;
import org.vaadin.addon.customfield.CustomField;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.JPAContainerFactory;
import com.vaadin.data.Property;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CssLayout;
import eu.relsys.vdma.vaadin.MyVaadinApplication;
import eu.relsys.vdma.vaadin.domain.Country;
public class CountrySelector extends CustomField {
private ComboBox country = new ComboBox();
private JPAContainer<Country> container;
public CountrySelector() {
container = JPAContainerFactory.make(Country.class,
MyVaadinApplication.PERSISTENCE_UNIT);
setCaption("Country");
container.setApplyFiltersImmediately(false);
country.setContainerDataSource(container);
country.setItemCaptionPropertyId("name");
country.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(
com.vaadin.data.Property.ValueChangeEvent event) {
/*
* Modify the actual value of the custom field.
*/
if (country.getValue() == null) {
setValue(null, false);
} else {
Country entity = container
.getItem(country.getValue()).getEntity();
setValue(entity, false);
}
}
});
CssLayout cssLayout = new CssLayout();
cssLayout.addComponent(country);
setCompositionRoot(cssLayout);
}
@Override
public void setPropertyDataSource(Property newDataSource) {
super.setPropertyDataSource(newDataSource);
setDepartment(newDataSource.getValue());
}
@Override
public void setValue(Object newValue) throws ReadOnlyException {
setDepartment(newValue);
}
private void setDepartment(Object newValue) {
Country value = (Country) newValue;
country.setValue(value != null ? value.getId() : null);
}
@Override
public Class<?> getType() {
return Country.class;
}
}
Eclipse says:
The type com.vaadin.terminal.ErrorMessage cannot be resolved. It is indirectly referenced from required .class files