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


Java CollectionDatasource.addItemChangeListener方法代码示例

本文整理汇总了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));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:LookupPickerFieldDsTest.java

示例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));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:LookupFieldDsTest.java

示例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);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:15,代码来源:WebDataGrid.java

示例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));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:CollectionDsActionsNotifier.java

示例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);
        }
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:16,代码来源:EntityCombinedScreen.java

示例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]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:36,代码来源:LookupPickerFieldDsTest.java

示例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]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:32,代码来源:LookupFieldDsTest.java


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