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


Java CollectionDatasource.getItems方法代码示例

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


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

示例1: testUnsubscribeComponentListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testUnsubscribeComponentListener() {
    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.setDatasource(null, null);

    Component.ValueChangeListener listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    component.addValueChangeListener(listener);

    user.setGroup(metadata.create(Group.class));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:LookupPickerFieldDsTest.java

示例2: testUnsubscribeDsListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testUnsubscribeDsListener() {
    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();
    userDs.getItem().setGroup(groups.get(0));

    component.setDatasource(userDs, "group");

    // unbind
    component.setDatasource(null, null);

    Datasource.ItemPropertyChangeListener<User> listener = e -> {
        throw new RuntimeException("Value was changed externally");
    };
    userDs.addItemPropertyChangeListener(listener);

    component.setValue(metadata.create(Group.class));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:LookupPickerFieldDsTest.java

示例3: 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

示例4: testUnsubscribeSubscribeDsListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeDsListener() {
    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();
    userDs.getItem().setGroup(groups.get(0));

    component.setDatasource(userDs, "group");

    // unbind
    component.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Datasource.ItemPropertyChangeListener<User> listener = e -> valueWasChanged[0] = true;
    userDs.addItemPropertyChangeListener(listener);
    component.setDatasource(userDs, "group");

    component.setValue(null);
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:LookupPickerFieldDsTest.java

示例5: 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

示例6: testValueChangeListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的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]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:LookupFieldDsTest.java

示例7: testValueChangeListener

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

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    searchField.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;
    searchField.addValueChangeListener(listener);

    searchField.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:SearchFieldDsTest.java

示例8: createPermissionItem

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
/**
 * Add or edit permission item in datasource
 * @param ds Datasource
 * @param roleDs Role datasource
 * @param permissionTarget Permission identifier
 * @param type Permission type
 * @param value Permission value
 */
public static void createPermissionItem(CollectionDatasource<Permission, UUID> ds, Datasource<Role> roleDs,
                                        final String permissionTarget, PermissionType type, Integer value) {
    Permission permission = null;
    for (Permission p : ds.getItems()) {
        if (Objects.equals(p.getTarget(), permissionTarget)) {
            permission = p;
            break;
        }
    }

    if (permission == null) {
        // workaround for idx_sec_permission_unique
        // restore entity instead of create
        if (ds instanceof RestorablePermissionDatasource) {
            RestorablePermissionDatasource datasource = (RestorablePermissionDatasource) ds;

            permission = datasource.findRemovedEntity(p ->
                p != null && Objects.equals(p.getTarget(), permissionTarget)
            );
            if (permission != null) {
                datasource.restoreEntity(permission);
            }
        }
    }

    if (permission == null) {
        Metadata metadata = AppBeans.get(Metadata.NAME);

        Permission newPermission = metadata.create(Permission.class);
        newPermission.setRole(roleDs.getItem());
        newPermission.setTarget(permissionTarget);
        newPermission.setType(type);
        newPermission.setValue(value);

        ds.addItem(newPermission);
    } else {
        permission.setValue(value);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:48,代码来源:PermissionUiHelper.java

示例9: testValueChangeListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testValueChangeListener() {
    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));

    // listener before datasource

    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
    component.addValueChangeListener(listener);

    component.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);

    // reset state
    valueWasChanged[0] = false;
    component.removeValueChangeListener(listener);
    component.setDatasource(null, null);

    // datasource before listener

    component.setDatasource(userDs, "group");
    component.addValueChangeListener(listener);
    user.setGroup(null);
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:34,代码来源:LookupPickerFieldDsTest.java

示例10: testUnsubscribeSubscribeComponentListener

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入方法依赖的package包/类
@Test
public void testUnsubscribeSubscribeComponentListener() {
    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.setDatasource(null, null);

    // setup
    boolean[] valueWasChanged = {false};
    Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;

    // datasource before listener

    component.setDatasource(userDs, "group");
    component.addValueChangeListener(listener);
    user.setGroup(metadata.create(Group.class));
    assertEquals(true, valueWasChanged[0]);

    // reset state
    component.setDatasource(null, null);
    component.removeValueChangeListener(listener);
    valueWasChanged[0] = false;
    component.setValue(null);

    // listener before datasource
    component.addValueChangeListener(listener);
    component.setDatasource(userDs, "group");
    assertEquals(true, valueWasChanged[0]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:40,代码来源:LookupPickerFieldDsTest.java

示例11: 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

示例12: 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.getItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。