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


Java CollectionDatasource.includeItem方法代码示例

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


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

示例1: addDateValueVolume

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
private void addDateValueVolume(CollectionDatasource<DateValueVolume, UUID> datasource,
                                int valueX1, int valueX2, int volumeX1, int volumeX2, int volumeX3,
                                Date date, int i) {
    Long value = Math.round(random.nextDouble() * (valueX1 + i)) + valueX2 + i;
    Long volume = Math.round(random.nextDouble() * (volumeX1 + i)) + volumeX2 + i + volumeX3;
    datasource.includeItem(dateValueVolume(date, value, volume));
}
 
开发者ID:cuba-platform,项目名称:sampler,代码行数:8,代码来源:StockChartMultipleDataSetsFrame.java

示例2: save

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
/**
 * Method that is invoked by clicking Ok button after editing an existing or creating a new record.
 */
@SuppressWarnings("unchecked")
public void save() {
    FieldGroup fieldGroup = getFieldGroup();
    List<Validatable> components = new ArrayList<>();
    for (Component component: fieldGroup.getComponents()) {
        if (component instanceof Validatable) {
            components.add((Validatable)component);
        }
    }
    if (!validate(components)) {
        return;
    }
    getDsContext().commit();

    ListComponent table = getTable();
    CollectionDatasource browseDs = table.getDatasource();
    Entity editedItem = fieldGroup.getDatasource().getItem();
    if (creating) {
        browseDs.includeItem(editedItem);
    } else {
        browseDs.updateItem(editedItem);
    }
    table.setSelected(editedItem);

    releaseLock();
    disableEditControls();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:31,代码来源:EntityCombinedScreen.java

示例3: testOptionsDatasource

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testOptionsDatasource() {
    OptionsList component = factory.createComponent(OptionsList.class);

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    Group g = new Group();
    g.setName("Group 0");
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    Group g1 = new Group();
    g1.setName("Group 1");
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    g2.setName("Group 2");
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);
    component.setValue(g2);

    assertEquals(g2, component.getValue());

    component.setDatasource(testDs, "group");
    component.setValue(g);
    assertEquals(g, testDs.getItem().getGroup());

    component.setValue(g1);
    assertEquals(g1, testDs.getItem().getGroup());

    testDs.getItem().setGroup(g2);
    assertEquals(g2, component.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:51,代码来源:OptionsListTest.java

示例4: testDatasource

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

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    Group g = new Group();
    g.setName("Group 0");
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    Group g1 = new Group();
    g1.setName("Group 1");
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    g2.setName("Group 2");
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);

    component.setValue(g2);
    assertEquals(g2, groupsDs.getItem());

    component.setDatasource(testDs, "group");
    assertEquals(g, component.getValue());

    assertEquals(g, groupsDs.getItem());
    assertFalse(groupsDs.containsItem(g.getId())); // due to #PL-4625

    component.setValue(g1);
    assertEquals(g1, testDs.getItem().getGroup());
    assertEquals(g1, groupsDs.getItem());

    testDs.getItem().setGroup(g2);
    assertEquals(g2, component.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:54,代码来源:LookupPickerFieldTest.java

示例5: testValueChangeListener

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

    final AtomicInteger counter = new AtomicInteger(0);

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    final Group g = new Group();
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    groupsDs.includeItem(g);
    Group g1 = new Group();
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);

    Component.ValueChangeListener listener1 = e -> {
        assertNull(e.getPrevValue());
        assertEquals(g2, e.getValue());

        counter.addAndGet(1);
    };
    component.addValueChangeListener(listener1);
    component.setValue(g2);

    component.removeValueChangeListener(listener1);
    assertEquals(1, counter.get());

    Component.ValueChangeListener listener2 = e -> {
        assertEquals(g2, e.getPrevValue());
        assertEquals(g, e.getValue());

        counter.addAndGet(1);
    };

    component.addValueChangeListener(listener2);

    component.setDatasource(testDs, "group");
    assertEquals(g, component.getValue());

    assertEquals(2, counter.get());

    component.removeValueChangeListener(listener2);
    component.setValue(g1);
    assertEquals(g1, testDs.getItem().getGroup());

    assertEquals(2, counter.get());

    Component.ValueChangeListener listener3 = e -> {
        assertEquals(g1, e.getPrevValue());
        assertEquals(g2, e.getValue());

        counter.addAndGet(1);
    };
    component.addValueChangeListener(listener3);
    testDs.getItem().setGroup(g2);
    assertEquals(g2, component.getValue());

    assertEquals(3, counter.get());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:82,代码来源:LookupPickerFieldTest.java

示例6: testValueLoadFromOptions

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

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    Group g = new Group();
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    groupsDs.includeItem(g);
    Group g1 = new Group();
    g1.setId(g.getId());
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);

    component.setDatasource(testDs, "group");

    assertTrue("Value should be from options ds", g1 == component.getValue());

    component.setValue(g2);

    Component.ValueChangeListener listener1 = e -> {
        assertEquals(g2, e.getPrevValue());
        assertEquals(g1, e.getValue());
    };
    component.addValueChangeListener(listener1);
    component.setValue(g);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:50,代码来源:LookupPickerFieldTest.java

示例7: testDatasource

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

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    Group g = new Group();
    g.setName("Group 0");
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    Group g1 = new Group();
    g1.setName("Group 1");
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    g2.setName("Group 2");
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);

    component.setValue(g2);
    assertEquals(g2, groupsDs.getItem());

    component.setDatasource(testDs, "group");
    assertEquals(g, component.getValue());

    assertEquals(g, groupsDs.getItem());
    assertFalse(groupsDs.containsItem(g.getId())); // due to #PL-4625

    component.setValue(g1);
    assertEquals(g1, testDs.getItem().getGroup());
    assertEquals(g1, groupsDs.getItem());

    testDs.getItem().setGroup(g2);
    assertEquals(g2, component.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:54,代码来源:LookupFieldTest.java

示例8: testValueChangeListener

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

    final AtomicInteger counter = new AtomicInteger(0);

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    final Group g = new Group();
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    groupsDs.includeItem(g);
    Group g1 = new Group();
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);

    Component.ValueChangeListener listener1 = e -> {
        assertNull(e.getPrevValue());
        assertEquals(g2, e.getValue());

        counter.addAndGet(1);
    };
    component.addValueChangeListener(listener1);
    component.setValue(g2);

    component.removeValueChangeListener(listener1);
    assertEquals(1, counter.get());

    Component.ValueChangeListener listener2 = e -> {
        assertEquals(g2, e.getPrevValue());
        assertEquals(g, e.getValue());

        counter.addAndGet(1);
    };

    component.addValueChangeListener(listener2);

    component.setDatasource(testDs, "group");
    assertEquals(g, component.getValue());

    assertEquals(2, counter.get());

    component.removeValueChangeListener(listener2);
    component.setValue(g1);
    assertEquals(g1, testDs.getItem().getGroup());

    assertEquals(2, counter.get());

    Component.ValueChangeListener listener3 = e -> {
        assertEquals(g1, e.getPrevValue());
        assertEquals(g2, e.getValue());

        counter.addAndGet(1);
    };
    component.addValueChangeListener(listener3);
    testDs.getItem().setGroup(g2);
    assertEquals(g2, component.getValue());

    assertEquals(3, counter.get());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:82,代码来源:LookupFieldTest.java

示例9: testValueLoadFromOptions

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

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    Group g = new Group();
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    groupsDs.includeItem(g);
    Group g1 = new Group();
    g1.setId(g.getId());
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);

    component.setDatasource(testDs, "group");

    assertTrue("Value should be from options ds", g1 == component.getValue());

    component.setValue(g2);

    Component.ValueChangeListener listener1 = e -> {
        assertEquals(g2, e.getPrevValue());
        assertEquals(g1, e.getValue());
    };
    component.addValueChangeListener(listener1);

    component.setValue(g);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:51,代码来源:LookupFieldTest.java

示例10: testOptionsDatasource

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testOptionsDatasource() {
    OptionsGroup component = factory.createComponent(OptionsGroup.class);

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());
    Group g = new Group();
    g.setName("Group 0");
    testDs.getItem().setGroup(g);

    //noinspection unchecked
    CollectionDatasource<Group, UUID> groupsDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    Group g1 = new Group();
    g1.setName("Group 1");
    groupsDs.includeItem(g1);
    Group g2 = new Group();
    g2.setName("Group 2");
    groupsDs.includeItem(g2);

    component.setOptionsDatasource(groupsDs);
    component.setValue(g2);

    assertEquals(g2, component.getValue());

    component.setDatasource(testDs, "group");
    component.setValue(g);
    assertEquals(g, testDs.getItem().getGroup());

    component.setValue(g1);
    assertEquals(g1, testDs.getItem().getGroup());

    testDs.getItem().setGroup(g2);
    assertEquals(g2, component.getValue());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:51,代码来源:OptionsGroupTest.java


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