本文整理汇总了Java中com.haulmont.cuba.gui.components.LookupField.setDatasource方法的典型用法代码示例。如果您正苦于以下问题:Java LookupField.setDatasource方法的具体用法?Java LookupField.setDatasource怎么用?Java LookupField.setDatasource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.haulmont.cuba.gui.components.LookupField
的用法示例。
在下文中一共展示了LookupField.setDatasource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUnsubscribeComponentListener
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
LookupField lookupField = factory.createComponent(LookupField.class);
CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
lookupField.setOptionsDatasource(groupsDs);
Datasource<User> userDs = getTestUserDatasource();
Group group = groupsDs.getItems().iterator().next();
User user = userDs.getItem();
user.setGroup(group);
lookupField.setDatasource(userDs, "group");
// unbind
lookupField.setDatasource(null, null);
Component.ValueChangeListener listener = e -> {
throw new RuntimeException("Value was changed externally");
};
lookupField.addValueChangeListener(listener);
user.setGroup(metadata.create(Group.class));
}
示例2: testUnsubscribeDsListener
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的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));
}
示例3: testOptionsDsUnsubscribe
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的package包/类
@Test
public void testOptionsDsUnsubscribe() {
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();
userDs.getItem().setGroup(groups.get(0));
lookupField.setDatasource(userDs, "group");
// unbind
lookupField.setOptionsDatasource(null);
Datasource.ItemChangeListener<Group> itemChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
groupsDs.addItemChangeListener(itemChangeListener);
lookupField.setValue(groups.get(1));
}
示例4: testValueChangeListener
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的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]);
}
示例5: testUnsubscribeSubscribeDsListener
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的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]);
}
示例6: testSetValueWithoutOptions
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的package包/类
@Test
public void testSetValueWithoutOptions() {
LookupField lookupField = (LookupField) factory.createComponent(LookupField.NAME);
// noinspection unchecked
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setName("Test name");
lookupField.setDatasource(userDs, "name");
assertEquals("Test name", lookupField.getValue());
}
示例7: testUnsubscribeSubscribeComponentListener
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
LookupField lookupField = factory.createComponent(LookupField.class);
CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
lookupField.setOptionsDatasource(groupsDs);
Datasource<User> userDs = getTestUserDatasource();
Group group = groupsDs.getItems().iterator().next();
User user = userDs.getItem();
user.setGroup(group);
lookupField.setDatasource(userDs, "group");
// unbind
lookupField.setDatasource(null, null);
// setup
boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
// datasource before listener
lookupField.setDatasource(userDs, "group");
lookupField.addValueChangeListener(listener);
user.setGroup(metadata.create(Group.class));
assertEquals(true, valueWasChanged[0]);
// reset state
valueWasChanged[0] = false;
lookupField.setDatasource(null, null);
lookupField.removeValueChangeListener(listener);
lookupField.setValue(null);
// listener before datasource
lookupField.addValueChangeListener(listener);
lookupField.setDatasource(userDs, "group");
assertEquals(true, valueWasChanged[0]);
}
示例8: testUnsubscribeSubscribeOptions
import com.haulmont.cuba.gui.components.LookupField; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeOptions() {
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();
userDs.getItem().setGroup(groups.get(0));
lookupField.setDatasource(userDs, "group");
// unbind
lookupField.setOptionsDatasource(null);
Datasource.ItemChangeListener<Group> listener = e -> {
throw new RuntimeException("Value was changed externally");
};
groupsDs.addItemChangeListener(listener);
lookupField.setValue(groups.get(1));
// setup
groupsDs.removeItemChangeListener(listener);
boolean[] valueWasChanged = {false};
listener = e -> valueWasChanged[0] = true;
groupsDs.addItemChangeListener(listener);
lookupField.setOptionsDatasource(groupsDs);
lookupField.setValue(groups.get(2));
assertEquals(true, valueWasChanged[0]);
}