Search in sources :

Example 6 with OptionsBinder

use of com.haulmont.cuba.gui.components.data.options.OptionsBinder in project cuba by cuba-platform.

the class FieldGroupTest method setUp.

@BeforeEach
public void setUp() {
    addEntityPackage("com.haulmont.cuba");
    setupInfrastructure();
    fieldFactory = new TestFieldGroupFieldFactoryImpl();
    this.valueBinder = new TestValueBinder(beanLocator, messageTools, metadata.getTools(), beanValidation, security);
    this.optionsBinder = new OptionsBinder();
    new Expectations() {

        {
            AppBeans.get(BackgroundWorker.NAME);
            result = backgroundWorker;
            minTimes = 0;
            AppBeans.get(BackgroundWorker.class);
            result = backgroundWorker;
            minTimes = 0;
            AppBeans.get(BackgroundWorker.NAME, BackgroundWorker.class);
            result = backgroundWorker;
            minTimes = 0;
            AppBeans.get(FieldGroupFieldFactory.NAME);
            result = fieldFactory;
            minTimes = 0;
            AppBeans.get(FieldGroupFieldFactory.class);
            result = fieldFactory;
            minTimes = 0;
            AppBeans.get(FieldGroupFieldFactory.NAME, FieldGroupFieldFactory.class);
            result = fieldFactory;
            minTimes = 0;
            applicationContext.getAutowireCapableBeanFactory();
            result = beanFactory;
            minTimes = 0;
            beanFactory.autowireBean(any);
            result = new Delegate() {

                @SuppressWarnings("unused")
                void autowireBean(java.lang.Object o) throws org.springframework.beans.BeansException {
                    autowireUiComponent((Component) o);
                }
            };
            minTimes = 0;
            userSessionSource.getLocale();
            result = Locale.ENGLISH;
            minTimes = 0;
            beanLocator.get(MetadataTools.NAME);
            result = metadata.getTools();
            minTimes = 0;
            beanLocator.get(ValueBinder.NAME);
            result = valueBinder;
            minTimes = 0;
            beanLocator.get(ValueBinder.class);
            result = valueBinder;
            minTimes = 0;
            beanLocator.get(ValueBinder.NAME, ValueBinder.class);
            result = valueBinder;
            minTimes = 0;
            beanLocator.get(OptionsBinder.NAME);
            result = optionsBinder;
            minTimes = 0;
            beanLocator.get(OptionsBinder.NAME, OptionsBinder.class);
            result = optionsBinder;
            minTimes = 0;
            beanLocator.get(Configuration.NAME);
            result = configuration;
            minTimes = 0;
            beanLocator.get(FormatStringsRegistry.NAME);
            result = formatStringsRegistry;
            minTimes = 0;
        }
    };
    initExpectations();
    messages.init();
    DefaultComponentGenerationStrategy strategy = new DefaultComponentGenerationStrategy(messages, null);
    UiComponentsGenerator uiComponentsGenerator = new UiComponentsGenerator() {

        @Override
        protected List<ComponentGenerationStrategy> getComponentGenerationStrategies() {
            return Collections.singletonList(strategy);
        }
    };
    uiComponents = createComponentsFactory();
    strategy.setUiComponents(uiComponents);
    fieldFactory.setUiComponentsGenerator(uiComponentsGenerator);
}
Also used : Expectations(mockit.Expectations) DefaultComponentGenerationStrategy(com.haulmont.cuba.gui.components.factories.DefaultComponentGenerationStrategy) DefaultComponentGenerationStrategy(com.haulmont.cuba.gui.components.factories.DefaultComponentGenerationStrategy) TestValueBinder(com.haulmont.cuba.gui.components.AbstractComponentTestCase.TestValueBinder) OptionsBinder(com.haulmont.cuba.gui.components.data.options.OptionsBinder) Delegate(mockit.Delegate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with OptionsBinder

use of com.haulmont.cuba.gui.components.data.options.OptionsBinder in project cuba by cuba-platform.

the class WebLookupPickerField method setOptions.

@Override
public void setOptions(Options<V> options) {
    if (this.optionsBinding != null) {
        this.optionsBinding.unbind();
        this.optionsBinding = null;
    }
    if (options != null) {
        OptionsBinder optionsBinder = beanLocator.get(OptionsBinder.NAME);
        this.optionsBinding = optionsBinder.bind(options, this, this::setItemsToPresentation);
        this.optionsBinding.activate();
        if (getMetaClass() == null && options instanceof EntityOptions) {
            setMetaClass(((EntityOptions<V>) options).getEntityMetaClass());
        }
    }
}
Also used : OptionsBinder(com.haulmont.cuba.gui.components.data.options.OptionsBinder) EntityOptions(com.haulmont.cuba.gui.components.data.meta.EntityOptions)

Example 8 with OptionsBinder

use of com.haulmont.cuba.gui.components.data.options.OptionsBinder in project cuba by cuba-platform.

the class WebRadioButtonGroup method setOptions.

@Override
public void setOptions(Options<V> options) {
    if (this.optionsBinding != null) {
        this.optionsBinding.unbind();
        this.optionsBinding = null;
    }
    if (options != null) {
        OptionsBinder optionsBinder = beanLocator.get(OptionsBinder.NAME);
        this.optionsBinding = optionsBinder.bind(options, this, this::setItemsToPresentation);
        this.optionsBinding.activate();
    }
}
Also used : OptionsBinder(com.haulmont.cuba.gui.components.data.options.OptionsBinder)

Example 9 with OptionsBinder

use of com.haulmont.cuba.gui.components.data.options.OptionsBinder in project cuba by cuba-platform.

the class WebOptionsGroup method setOptions.

@Override
public void setOptions(Options<I> options) {
    if (this.optionsBinding != null) {
        this.optionsBinding.unbind();
        this.optionsBinding = null;
    }
    if (options != null) {
        OptionsBinder optionsBinder = beanLocator.get(OptionsBinder.NAME, OptionsBinder.class);
        this.optionsBinding = optionsBinder.bind(options, this, this::setOptionsToComponent);
        this.optionsBinding.activate();
    }
}
Also used : OptionsBinder(com.haulmont.cuba.gui.components.data.options.OptionsBinder)

Example 10 with OptionsBinder

use of com.haulmont.cuba.gui.components.data.options.OptionsBinder in project cuba by cuba-platform.

the class WebOptionsList method setOptions.

@Override
public void setOptions(Options<I> options) {
    if (this.optionsBinding != null) {
        this.optionsBinding.unbind();
        this.optionsBinding = null;
    }
    if (options != null) {
        OptionsBinder optionsBinder = beanLocator.get(OptionsBinder.NAME, OptionsBinder.class);
        this.optionsBinding = optionsBinder.bind(options, this, this::setItemsToPresentation);
        this.optionsBinding.activate();
    }
}
Also used : OptionsBinder(com.haulmont.cuba.gui.components.data.options.OptionsBinder)

Aggregations

OptionsBinder (com.haulmont.cuba.gui.components.data.options.OptionsBinder)10 EntityOptions (com.haulmont.cuba.gui.components.data.meta.EntityOptions)2 Delegate (mockit.Delegate)2 Expectations (mockit.Expectations)2 TestValueBinder (com.haulmont.cuba.gui.components.AbstractComponentTestCase.TestValueBinder)1 DefaultComponentGenerationStrategy (com.haulmont.cuba.gui.components.factories.DefaultComponentGenerationStrategy)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1