use of com.haulmont.cuba.gui.components.actions.GuiActionSupport in project cuba by cuba-platform.
the class BulkEditorFieldFactory method createEntityField.
protected Field createEntityField(Datasource datasource, MetaProperty property) {
Lookup lookup = property.getAnnotatedElement().getAnnotation(Lookup.class);
if (lookup != null && lookup.type() == LookupType.DROPDOWN) {
DataComponents dataComponents = AppBeans.get(DataComponents.class);
Metadata metadata = AppBeans.get(Metadata.class);
MetaClass metaClass = metadata.getClassNN(property.getJavaType());
CollectionContainer<Entity> container = dataComponents.createCollectionContainer(metaClass.getJavaClass());
CollectionLoader<Entity> loader = dataComponents.createCollectionLoader();
loader.setQuery("select e from " + metaClass.getName() + " e");
loader.setView(View.MINIMAL);
loader.setContainer(container);
loader.load();
LookupPickerField<Entity> lookupPickerField = componentsFactory.createComponent(LookupPickerField.NAME);
lookupPickerField.setDatasource(datasource, property.getName());
lookupPickerField.setOptions(new ContainerOptions(container));
GuiActionSupport guiActionSupport = AppBeans.get(GuiActionSupport.NAME);
guiActionSupport.createActionsByMetaAnnotations(lookupPickerField);
return lookupPickerField;
}
PickerField<Entity> pickerField = componentsFactory.createComponent(PickerField.NAME);
pickerField.setDatasource(datasource, property.getName());
GuiActionSupport guiActionSupport = AppBeans.get(GuiActionSupport.NAME);
guiActionSupport.createActionById(pickerField, PickerField.ActionType.LOOKUP.getId());
if (lookup == null || !guiActionSupport.createActionsByMetaAnnotations(pickerField)) {
guiActionSupport.createActionById(pickerField, PickerField.ActionType.CLEAR.getId());
}
return pickerField;
}
use of com.haulmont.cuba.gui.components.actions.GuiActionSupport in project cuba by cuba-platform.
the class LookupPickerFieldLoader method loadComponent.
@Override
public void loadComponent() {
super.loadComponent();
LookupPickerField lookupPickerField = (LookupPickerField) resultComponent;
String metaClass = element.attributeValue("metaClass");
if (!StringUtils.isEmpty(metaClass)) {
lookupPickerField.setMetaClass(getMetadata().getClass(metaClass));
}
loadActions(lookupPickerField, element);
if (lookupPickerField.getActions().isEmpty()) {
GuiActionSupport guiActionSupport = getGuiActionSupport();
boolean actionsByMetaAnnotations = guiActionSupport.createActionsByMetaAnnotations(lookupPickerField);
if (!actionsByMetaAnnotations) {
if (isLegacyFrame()) {
lookupPickerField.addLookupAction();
lookupPickerField.addClearAction();
} else {
Actions actions = getActions();
lookupPickerField.addAction(actions.create(LookupAction.ID));
lookupPickerField.addAction(actions.create(ClearAction.ID));
}
}
}
String refreshOptionsOnLookupClose = element.attributeValue("refreshOptionsOnLookupClose");
if (refreshOptionsOnLookupClose != null) {
lookupPickerField.setRefreshOptionsOnLookupClose(Boolean.parseBoolean(refreshOptionsOnLookupClose));
}
}
use of com.haulmont.cuba.gui.components.actions.GuiActionSupport in project cuba by cuba-platform.
the class PickerFieldLoader method loadComponent.
@Override
public void loadComponent() {
super.loadComponent();
loadTabIndex(resultComponent, element);
String captionProperty = element.attributeValue("captionProperty");
if (!StringUtils.isEmpty(captionProperty)) {
resultComponent.setCaptionMode(CaptionMode.PROPERTY);
resultComponent.setCaptionProperty(captionProperty);
}
final String metaClass = element.attributeValue("metaClass");
if (!StringUtils.isEmpty(metaClass)) {
resultComponent.setMetaClass(getMetadata().getClassNN(metaClass));
}
loadActions(resultComponent, element);
if (resultComponent.getActions().isEmpty()) {
GuiActionSupport guiActionSupport = getGuiActionSupport();
boolean actionsByMetaAnnotations = guiActionSupport.createActionsByMetaAnnotations(resultComponent);
if (!actionsByMetaAnnotations) {
if (isLegacyFrame()) {
resultComponent.addLookupAction();
resultComponent.addClearAction();
} else {
Actions actions = getActions();
resultComponent.addAction(actions.create(LookupAction.ID));
resultComponent.addAction(actions.create(ClearAction.ID));
}
}
}
loadBuffered(resultComponent, element);
}
Aggregations