本文整理汇总了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));
}
示例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();
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}