当前位置: 首页>>代码示例>>Java>>正文


Java CollectionDatasource.containsItem方法代码示例

本文整理汇总了Java中com.haulmont.cuba.gui.data.CollectionDatasource.containsItem方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionDatasource.containsItem方法的具体用法?Java CollectionDatasource.containsItem怎么用?Java CollectionDatasource.containsItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.haulmont.cuba.gui.data.CollectionDatasource的用法示例。


在下文中一共展示了CollectionDatasource.containsItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterCommitOpenedEntity

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
protected void afterCommitOpenedEntity(Entity item) {
    if (pickerField instanceof LookupField) {
        LookupField lookupPickerField = ((LookupField) pickerField);

        CollectionDatasource optionsDatasource = lookupPickerField.getOptionsDatasource();
        //noinspection unchecked
        if (optionsDatasource != null && optionsDatasource.containsItem(item.getId())) {
            //noinspection unchecked
            optionsDatasource.updateItem(item);
        }
    }

    if (pickerField.getDatasource() != null) {
        boolean modified = pickerField.getDatasource().isModified();

        pickerField.setValue(item);

        ((DatasourceImplementation) pickerField.getDatasource()).setModified(modified);
    } else {
        pickerField.setValue(item);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:PickerField.java

示例2: handleLookupWindowSelection

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
protected void handleLookupWindowSelection(Collection items) {
    if (items.isEmpty()) {
        return;
    }

    Entity item = (Entity) items.iterator().next();
    Entity newValue = transformValueFromLookupWindow(item);

    if (pickerField instanceof LookupPickerField) {
        LookupPickerField lookupPickerField = (LookupPickerField) pickerField;

        CollectionDatasource optionsDatasource = lookupPickerField.getOptionsDatasource();
        if (optionsDatasource != null) {
            //noinspection unchecked
            if (optionsDatasource.containsItem(newValue.getId())) {
                //noinspection unchecked
                optionsDatasource.updateItem(newValue);
            }

            if (lookupPickerField.isRefreshOptionsOnLookupClose()) {
                optionsDatasource.refresh();
            }
        }
    }

    pickerField.setValue(newValue);

    afterSelect(items);
    if (afterLookupSelectionHandler != null) {
        afterLookupSelectionHandler.onSelect(items);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:33,代码来源:PickerField.java

示例3: commit

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void commit() {
    backgroundWorker.checkUIAccess();

    if (!allowCommit) {
        return;
    }

    if (getCommitMode() == CommitMode.DATASTORE) {
        final DataSupplier supplier = getDataSupplier();
        item = supplier.commit(item, getView());

        clearCommitLists();
        modified = false;

    } else if (getCommitMode() == CommitMode.PARENT) {
        if (parentDs == null) {
            throw new IllegalStateException("parentDs is null while commitMode=PARENT");
        }

        if (parentDs instanceof CollectionDatasource) {
            CollectionDatasource ds = (CollectionDatasource) parentDs;
            if (ds.containsItem(item.getId())) {
                ds.modifyItem(item);
            } else {
                ds.addItem(item);
                ds.setItem(item); // This is necessary for nested property datasources to work correctly
            }
        } else {
            parentDs.setItem(item);
            if (AppBeans.get(EntityStates.class).isNew(item)) {
                ((DatasourceImplementation) parentDs).modified(item);
            }
        }
        clearCommitLists();
        modified = false;

    } else {
        throw new UnsupportedOperationException("Unsupported commitMode: " + getCommitMode());
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:43,代码来源:DatasourceImpl.java

示例4: handleLookup

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleLookup(Collection items) {
    if (items == null || items.isEmpty()) {
        return;
    }

    final CollectionDatasource ds = target.getDatasource();
    if (ds == null) {
        return;
    }

    Metadata metadata = AppBeans.get(Metadata.NAME);
    ExtendedEntities extendedEntities = metadata.getExtendedEntities();

    ds.suspendListeners();
    try {
        Entity masterEntity = null;
        MetaProperty inverseProp = null;
        boolean initializeMasterReference = false;

        if (ds instanceof NestedDatasource) {
            Datasource masterDs = ((NestedDatasource) ds).getMaster();
            if (masterDs != null) {
                MetaProperty metaProperty = ((NestedDatasource) ds).getProperty();
                masterEntity = masterDs.getItem();

                if (metaProperty != null) {
                    inverseProp = metaProperty.getInverse();

                    if (inverseProp != null && !inverseProp.getRange().getCardinality().isMany()) {
                        Class inversePropClass = extendedEntities.getEffectiveClass(inverseProp.getDomain());
                        Class dsClass = extendedEntities.getEffectiveClass(ds.getMetaClass());

                        initializeMasterReference = inversePropClass.isAssignableFrom(dsClass);
                    }
                }
            }
        }

        for (Object item : items) {
            if (item instanceof Entity) {
                Entity entity = (Entity) item;
                if (!ds.containsItem(entity.getId())) {
                    // Initialize reference to master entity
                    if (initializeMasterReference) {
                        entity.setValue(inverseProp.getName(), masterEntity);
                    }
                    ds.addItem(entity);
                }
            }
        }
    } finally {
        ds.resumeListeners();
    }

    if (afterAddHandler != null) {
        afterAddHandler.handle(items);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:61,代码来源:AddAction.java


注:本文中的com.haulmont.cuba.gui.data.CollectionDatasource.containsItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。