Search in sources :

Example 1 with ClearAction

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;
    }
}
Also used : ContainerOptions(com.haulmont.cuba.gui.components.data.options.ContainerOptions) LookupAction(com.haulmont.cuba.gui.actions.picker.LookupAction) ClearAction(com.haulmont.cuba.gui.actions.picker.ClearAction) InputDialogAction(com.haulmont.cuba.gui.components.inputdialog.InputDialogAction) CollectionLoader(com.haulmont.cuba.gui.model.CollectionLoader) MetaClass(com.haulmont.chile.core.model.MetaClass) CollectionContainer(com.haulmont.cuba.gui.model.CollectionContainer)

Aggregations

MetaClass (com.haulmont.chile.core.model.MetaClass)1 ClearAction (com.haulmont.cuba.gui.actions.picker.ClearAction)1 LookupAction (com.haulmont.cuba.gui.actions.picker.LookupAction)1 ContainerOptions (com.haulmont.cuba.gui.components.data.options.ContainerOptions)1 InputDialogAction (com.haulmont.cuba.gui.components.inputdialog.InputDialogAction)1 CollectionContainer (com.haulmont.cuba.gui.model.CollectionContainer)1 CollectionLoader (com.haulmont.cuba.gui.model.CollectionLoader)1