use of com.haulmont.cuba.gui.actions.picker.ClearAction in project cuba by cuba-platform.
the class InputDialog method createEntityField.
@SuppressWarnings("unchecked")
protected Field createEntityField(InputParameter parameter) {
MetaClass metaClass = metadata.getClassNN(parameter.getEntityClass());
Action lookupAction = actions.create(LookupAction.ID);
Action clearAction = actions.create(ClearAction.ID);
if (persistenceManagerService.useLookupScreen(metaClass.getName())) {
PickerField pickerField = uiComponents.create(PickerField.NAME);
pickerField.setMetaClass(metadata.getClass(parameter.getEntityClass()));
pickerField.addAction(lookupAction);
pickerField.addAction(clearAction);
pickerField.setWidthFull();
return pickerField;
} else {
LookupPickerField lookupPickerField = uiComponents.create(LookupPickerField.NAME);
lookupPickerField.addAction(lookupAction);
lookupPickerField.addAction(clearAction);
lookupPickerField.setWidthFull();
CollectionContainer container = dataComponents.createCollectionContainer(parameter.getEntityClass());
CollectionLoader loader = dataComponents.createCollectionLoader();
loader.setQuery("select e from " + metaClass.getName() + " e");
loader.setView(View.MINIMAL);
loader.setContainer(container);
loader.load();
lookupPickerField.setOptions(new ContainerOptions(container));
return lookupPickerField;
}
}
Aggregations