本文整理汇总了Java中com.haulmont.cuba.gui.data.CollectionDatasource.addItemChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionDatasource.addItemChangeListener方法的具体用法?Java CollectionDatasource.addItemChangeListener怎么用?Java CollectionDatasource.addItemChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.haulmont.cuba.gui.data.CollectionDatasource
的用法示例。
在下文中一共展示了CollectionDatasource.addItemChangeListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOptionsDsUnsubscribe
import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testOptionsDsUnsubscribe() {
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.setOptionsDatasource(null);
Datasource.ItemChangeListener<Group> listener = e -> {
throw new RuntimeException("Value was changed externally");
};
groupsDs.addItemChangeListener(listener);
component.setValue(groups.get(1));
}
示例2: testOptionsDsUnsubscribe
import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的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));
}
示例3: bind
import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void bind(CollectionDatasource ds) {
weakItemChangeListener = new WeakItemChangeListener(ds, this);
ds.addItemChangeListener(weakItemChangeListener);
weakItemPropertyChangeListener = new WeakItemPropertyChangeListener(ds, this);
ds.addItemPropertyChangeListener(weakItemPropertyChangeListener);
weakStateChangeListener = new WeakStateChangeListener(ds, this);
ds.addStateChangeListener(weakStateChangeListener);
weakCollectionChangeListener = new WeakCollectionChangeListener(ds, this);
ds.addCollectionChangeListener(weakCollectionChangeListener);
}
示例4: bind
import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void bind(CollectionDatasource ds) {
ds.addItemChangeListener(new WeakItemChangeListener(ds, this));
ds.addItemPropertyChangeListener(new WeakItemPropertyChangeListener(ds, this));
ds.addStateChangeListener(new WeakStateChangeListener(ds, this));
ds.addCollectionChangeListener(new WeakCollectionChangeListener(ds, this));
}
示例5: initBrowseItemChangeListener
import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
/**
* Adds a listener that reloads the selected record with the specified view and sets it to editDs.
*/
@SuppressWarnings("unchecked")
protected void initBrowseItemChangeListener() {
CollectionDatasource browseDs = getTable().getDatasource();
Datasource editDs = getFieldGroup().getDatasource();
browseDs.addItemChangeListener(e -> {
if (e.getItem() != null) {
Entity reloadedItem = getDsContext().getDataSupplier().reload(e.getDs().getItem(), editDs.getView());
editDs.setItem(reloadedItem);
}
});
}
示例6: testUnsubscribeSubscribeOptions
import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeOptions() {
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.setOptionsDatasource(null);
Datasource.ItemChangeListener<Group> listener = e -> {
throw new RuntimeException("Value was changed externally");
};
groupsDs.addItemChangeListener(listener);
component.setValue(groups.get(1));
//bind
component.setOptionsDatasource(groupsDs);
groupsDs.removeItemChangeListener(listener);
boolean[] valueWasChanged = {false};
listener = e -> valueWasChanged[0] = true;
groupsDs.addItemChangeListener(listener);
component.setValue(groups.get(2));
assertEquals(true, valueWasChanged[0]);
}
示例7: testUnsubscribeSubscribeOptions
import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的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]);
}