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


Java CollectionDatasource类代码示例

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


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

示例1: createTagsDs

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected CollectionDatasource<Tag, UUID> createTagsDs(TagType required) {
    DsBuilder builder;
    if (required == null) {
        builder = new DsBuilder(getDsContext())
                .setViewName("tag-with-type")
                .setAllowCommit(false)
                .setRefreshMode(CollectionDatasource.RefreshMode.NEVER);
    } else {
        builder = new DsBuilder()
                .setDsClass(TagsCollectionDatasource.class);
    }
    builder.setJavaClass(Tag.class);
    if (required == null) {
        return builder.buildCollectionDatasource();
    } else {
        TagsCollectionDatasource ds = (TagsCollectionDatasource) builder.buildCollectionDatasource();
        ds.setRequiredTagType(required);
        ds.refresh();
        return ds;
    }
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:23,代码来源:TimeEntryEdit.java

示例2: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    SearchField searchField = factory.createComponent(SearchField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    searchField.setOptionsDatasource(groupsDs);

    Datasource<User> userDs = getTestUserDatasource();
    Group group = groupsDs.getItems().iterator().next();
    User user = userDs.getItem();
    user.setGroup(group);
    searchField.setDatasource(userDs, "group");

    // unbind
    searchField.setDatasource(null, null);

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    searchField.addValueChangeListener(listener);

    user.setGroup(metadata.create(Group.class));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:SearchFieldDsTest.java

示例3: postValidate

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Override
public void postValidate(ValidationErrors errors) {
    @SuppressWarnings("unchecked")
    CollectionDatasource<CategoryAttribute, UUID> parent
            = (CollectionDatasource<CategoryAttribute, UUID>) ((DatasourceImplementation) attributeDs).getParent();
    if (parent != null) {
        CategoryAttribute categoryAttribute = getItem();
        for (UUID id : parent.getItemIds()) {
            CategoryAttribute ca = parent.getItemNN(id);
            if (ca.getName().equals(categoryAttribute.getName())
                    && (!ca.equals(categoryAttribute))) {
                errors.add(getMessage("uniqueName"));
                return;
            } else if (ca.getCode() != null && ca.getCode().equals(categoryAttribute.getCode())
                    && (!ca.equals(categoryAttribute))) {
                errors.add(getMessage("uniqueCode"));
                return;
            }
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:AttributeEditor.java

示例4: getTestCollectionDatasource

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected CollectionDatasource<Group, UUID> getTestCollectionDatasource() {
    // noinspection unchecked
    CollectionDatasource<Group, UUID> collectionDatasource = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    for (int i = 0; i < 3; i++) {
        Group group = metadata.create(Group.class);
        group.setName("Group #" + (i + 1));

        Group parentGroup = metadata.create(Group.class);
        parentGroup.setName("Parent group #" + (i + 1));
        group.setParent(parentGroup);

        collectionDatasource.addItem(group);
    }
    ((CollectionDatasourceImpl) collectionDatasource).valid();

    return collectionDatasource;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:DsApiConsistencyTestCase.java

示例5: testUnsubscribeSubscribeDsListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Test
public void testUnsubscribeSubscribeDsListener() {
    SearchField searchField = factory.createComponent(SearchField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    searchField.setOptionsDatasource(groupsDs);

    Datasource<User> userDs = getTestUserDatasource();
    Group group = groupsDs.getItems().iterator().next();
    userDs.getItem().setGroup(group);
    searchField.setDatasource(userDs, "group");

    // unbind
    searchField.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Datasource.ItemPropertyChangeListener<User> listener = e -> valueWasChanged[0] = true;
    userDs.addItemPropertyChangeListener(listener);

    searchField.setDatasource(userDs, "group");
    searchField.setValue(null);
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:SearchFieldDsTest.java

示例6: CollectionDsWrapper

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public CollectionDsWrapper(CollectionDatasource datasource, Collection<MetaPropertyPath> properties,
                           boolean autoRefresh, CollectionDsListenersWrapper collectionDsListenersWrapper) {
    this.datasource = datasource;
    this.autoRefresh = autoRefresh;
    this.collectionDsListenersWrapper = collectionDsListenersWrapper;

    final View view = datasource.getView();
    final MetaClass metaClass = datasource.getMetaClass();

    if (properties == null) {
        createProperties(view, metaClass);
    } else {
        this.properties.addAll(properties);
    }

    cdsItemPropertyChangeListener = createItemPropertyChangeListener();
    cdsStateChangeListener = createStateChangeListener();
    cdsCollectionChangeListener = createCollectionChangeListener();

    collectionDsListenersWrapper.addItemPropertyChangeListener(cdsItemPropertyChangeListener);
    collectionDsListenersWrapper.addStateChangeListener(cdsStateChangeListener);
    collectionDsListenersWrapper.addCollectionChangeListener(cdsCollectionChangeListener);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:CollectionDsWrapper.java

示例7: createCondition

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected AbstractCondition createCondition(ConditionType type, Element element, Filter filter, String xml) {
    String filterComponentName = filter.getId();
    String messagesPack = filter.getFrame().getMessagesPack();
    CollectionDatasource datasource = filter.getDatasource();
    switch (type) {
        case GROUP:
            return new GroupCondition(element, filterComponentName);
        case PROPERTY:
            return new PropertyCondition(element, messagesPack, filterComponentName, datasource);
        case CUSTOM:
            return new CustomCondition(element, messagesPack, filterComponentName, datasource);
        case RUNTIME_PROPERTY:
            return new DynamicAttributesCondition(element, messagesPack, filterComponentName, datasource);
        case FTS:
            return new FtsCondition(element, messagesPack, filterComponentName, datasource);
        default:
            throw new IllegalStateException("Unknown condition type: " + type + " in " + xml);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:FilterParserImpl.java

示例8: testUnsubscribeSubscribeDsListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Test
public void testUnsubscribeSubscribeDsListener() {
    LookupPickerField component = (LookupPickerField) factory.createComponent(LookupPickerField.NAME);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    component.setOptionsDatasource(groupsDs);
    List<Group> groups = new ArrayList<>(groupsDs.getItems());

    Datasource<User> userDs = getTestUserDatasource();
    userDs.getItem().setGroup(groups.get(0));

    component.setDatasource(userDs, "group");

    // unbind
    component.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Datasource.ItemPropertyChangeListener<User> listener = e -> valueWasChanged[0] = true;
    userDs.addItemPropertyChangeListener(listener);
    component.setDatasource(userDs, "group");

    component.setValue(null);
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:LookupPickerFieldDsTest.java

示例9: testUnsubscribeDsListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Test
public void testUnsubscribeDsListener() {
    LookupField lookupField = factory.createComponent(LookupField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    lookupField.setOptionsDatasource(groupsDs);

    Datasource<User> userDs = getTestUserDatasource();
    Group group = groupsDs.getItems().iterator().next();
    userDs.getItem().setGroup(group);
    lookupField.setDatasource(userDs, "group");

    // unbind
    lookupField.setDatasource(null, null);

    Datasource.ItemPropertyChangeListener<User> propertyChangeListener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    userDs.addItemPropertyChangeListener(propertyChangeListener);

    lookupField.setValue(metadata.create(Group.class));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:LookupFieldDsTest.java

示例10: ItemWrapper

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
public ItemWrapper(Object item, MetaClass metaClass, Collection<MetaPropertyPath> properties) {
    this.item = item;
    this.metaClass = metaClass;

    for (MetaPropertyPath property : properties) {
        this.properties.put(property, createPropertyWrapper(item, property));
    }

    if (item instanceof CollectionDatasource) {
        cdsCollectionChangeListener = e -> fireItemPropertySetChanged();

        CollectionDatasource datasource = (CollectionDatasource) item;
        weakCollectionChangeListener = new WeakCollectionChangeListener(datasource, cdsCollectionChangeListener);
        //noinspection unchecked
        datasource.addCollectionChangeListener(weakCollectionChangeListener);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:18,代码来源:ItemWrapper.java

示例11: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    LookupPickerField component = (LookupPickerField) factory.createComponent(LookupPickerField.NAME);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    component.setOptionsDatasource(groupsDs);
    List<Group> groups = new ArrayList<>(groupsDs.getItems());

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setGroup(groups.get(0));

    component.setDatasource(userDs, "group");

    // unbind
    component.setDatasource(null, null);

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    component.addValueChangeListener(listener);

    user.setGroup(metadata.create(Group.class));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:LookupPickerFieldDsTest.java

示例12: onNextClick

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected void onNextClick() {
    if (!(datasource instanceof CollectionDatasource.SupportsPaging)) {
        return;
    }

    CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource;
    int firstResult = ds.getFirstResult();
    ds.setFirstResult(ds.getFirstResult() + ds.getMaxResults());
    refreshDatasource(ds);

    if (state == State.LAST && size == 0) {
        ds.setFirstResult(firstResult);
        int maxResults = ds.getMaxResults();
        ds.setMaxResults(maxResults + 1);
        refreshDatasource(ds);
        ds.setMaxResults(maxResults);
    }
    if (owner instanceof WebAbstractTable) {
        com.vaadin.ui.Table vTable = (com.vaadin.ui.Table) ((WebAbstractTable) owner).getComponent();
        vTable.setCurrentPageFirstItemIndex(0);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:WebRowsCount.java

示例13: testValueChangeListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Test
public void testValueChangeListener() {
    LookupField lookupField = factory.createComponent(LookupField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    lookupField.setOptionsDatasource(groupsDs);
    List<Group> groups = new ArrayList<>(groupsDs.getItems());

    Datasource<User> userDs = getTestUserDatasource();
    User user = userDs.getItem();
    user.setGroup(groups.get(0));

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    lookupField.addValueChangeListener(listener);

    lookupField.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:LookupFieldDsTest.java

示例14: createOptionsDatasourceForLookup

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
/**
 * Creates the collection datasource that is used for selecting the dynamic attribute value. If the
 * CategoryAttribute has "where" or "join" clauses then only items that satisfy these clauses will be presented in
 * the options datasource
 */
public CollectionDatasource createOptionsDatasourceForLookup(MetaClass metaClass, String joinClause, String whereClause) {
    CollectionDatasource optionsDatasource = DsBuilder.create()
            .setMetaClass(metaClass)
            .setViewName(View.MINIMAL)
            .buildCollectionDatasource();

    String query = "select e from " + metaClass.getName() + " e";

    if (!Strings.isNullOrEmpty(joinClause)) {
        query += " " + joinClause;
    }
    if (!Strings.isNullOrEmpty(whereClause)) {
        query += " where " + whereClause.replaceAll("\\{E\\}", "e");
    }

    optionsDatasource.setQuery(query);
    optionsDatasource.refresh();
    return optionsDatasource;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:DynamicAttributesGuiTools.java

示例15: testUnsubscribeSubscribeDsListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Test
public void testUnsubscribeSubscribeDsListener() {
    LookupField lookupField = factory.createComponent(LookupField.class);

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    lookupField.setOptionsDatasource(groupsDs);

    Datasource<User> userDs = getTestUserDatasource();
    Group group = groupsDs.getItems().iterator().next();
    userDs.getItem().setGroup(group);
    lookupField.setDatasource(userDs, "group");

    // unbind
    lookupField.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Datasource.ItemPropertyChangeListener<User> listener = e -> valueWasChanged[0] = true;
    userDs.addItemPropertyChangeListener(listener);

    lookupField.setDatasource(userDs, "group");
    lookupField.setValue(null);
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:LookupFieldDsTest.java


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