• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CollectionDatasource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CollectionDatasource类属于com.haulmont.cuba.gui.data包,在下文中一共展示了CollectionDatasource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createTagsDs

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected CollectionDatasource<Tag, UUID> createTagsDs(TagType required) {
    DsBuilder builder;
    if (required == null) {
        builder = new DsBuilder(getDsContext())
                .setViewName("tag-with-type")
                .setAllowCommit(false)
                .setRefreshMode(CollectionDatasource.RefreshMode.NEVER);
    } else {
        builder = new DsBuilder()
                .setDsClass(TagsCollectionDatasource.class);
    }
    builder.setJavaClass(Tag.class);
    if (required == null) {
        return builder.buildCollectionDatasource();
    } else {
        TagsCollectionDatasource ds = (TagsCollectionDatasource) builder.buildCollectionDatasource();
        ds.setRequiredTagType(required);
        ds.refresh();
        return ds;
    }
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:23,代码来源:TimeEntryEdit.java


示例2: testUnsubscribeComponentListener

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

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    searchField.setOptionsDatasource(groupsDs);

    Datasource<User> userDs = getTestUserDatasource();
    Group group = groupsDs.getItems().iterator().next();
    User user = userDs.getItem();
    user.setGroup(group);
    searchField.setDatasource(userDs, "group");

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

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

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


示例3: postValidate

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Override
public void postValidate(ValidationErrors errors) {
    @SuppressWarnings("unchecked")
    CollectionDatasource<CategoryAttribute, UUID> parent
            = (CollectionDatasource<CategoryAttribute, UUID>) ((DatasourceImplementation) attributeDs).getParent();
    if (parent != null) {
        CategoryAttribute categoryAttribute = getItem();
        for (UUID id : parent.getItemIds()) {
            CategoryAttribute ca = parent.getItemNN(id);
            if (ca.getName().equals(categoryAttribute.getName())
                    && (!ca.equals(categoryAttribute))) {
                errors.add(getMessage("uniqueName"));
                return;
            } else if (ca.getCode() != null && ca.getCode().equals(categoryAttribute.getCode())
                    && (!ca.equals(categoryAttribute))) {
                errors.add(getMessage("uniqueCode"));
                return;
            }
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:AttributeEditor.java


示例4: getTestCollectionDatasource

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected CollectionDatasource<Group, UUID> getTestCollectionDatasource() {
    // noinspection unchecked
    CollectionDatasource<Group, UUID> collectionDatasource = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    for (int i = 0; i < 3; i++) {
        Group group = metadata.create(Group.class);
        group.setName("Group #" + (i + 1));

        Group parentGroup = metadata.create(Group.class);
        parentGroup.setName("Parent group #" + (i + 1));
        group.setParent(parentGroup);

        collectionDatasource.addItem(group);
    }
    ((CollectionDatasourceImpl) collectionDatasource).valid();

    return collectionDatasource;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:DsApiConsistencyTestCase.java


示例5: testUnsubscribeSubscribeDsListener

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

    CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
    searchField.setOptionsDatasource(groupsDs);

    Datasource<User> userDs = getTestUserDatasource();
    Group group = groupsDs.getItems().iterator().next();
    userDs.getItem().setGroup(group);
    searchField.setDatasource(userDs, "group");

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

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

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


示例6: CollectionDsWrapper

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public CollectionDsWrapper(CollectionDatasource datasource, Collection<MetaPropertyPath> properties,
                           boolean autoRefresh, CollectionDsListenersWrapper collectionDsListenersWrapper) {
    this.datasource = datasource;
    this.autoRefresh = autoRefresh;
    this.collectionDsListenersWrapper = collectionDsListenersWrapper;

    final View view = datasource.getView();
    final MetaClass metaClass = datasource.getMetaClass();

    if (properties == null) {
        createProperties(view, metaClass);
    } else {
        this.properties.addAll(properties);
    }

    cdsItemPropertyChangeListener = createItemPropertyChangeListener();
    cdsStateChangeListener = createStateChangeListener();
    cdsCollectionChangeListener = createCollectionChangeListener();

    collectionDsListenersWrapper.addItemPropertyChangeListener(cdsItemPropertyChangeListener);
    collectionDsListenersWrapper.addStateChangeListener(cdsStateChangeListener);
    collectionDsListenersWrapper.addCollectionChangeListener(cdsCollectionChangeListener);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:CollectionDsWrapper.java


示例7: createCondition

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected AbstractCondition createCondition(ConditionType type, Element element, Filter filter, String xml) {
    String filterComponentName = filter.getId();
    String messagesPack = filter.getFrame().getMessagesPack();
    CollectionDatasource datasource = filter.getDatasource();
    switch (type) {
        case GROUP:
            return new GroupCondition(element, filterComponentName);
        case PROPERTY:
            return new PropertyCondition(element, messagesPack, filterComponentName, datasource);
        case CUSTOM:
            return new CustomCondition(element, messagesPack, filterComponentName, datasource);
        case RUNTIME_PROPERTY:
            return new DynamicAttributesCondition(element, messagesPack, filterComponentName, datasource);
        case FTS:
            return new FtsCondition(element, messagesPack, filterComponentName, datasource);
        default:
            throw new IllegalStateException("Unknown condition type: " + type + " in " + xml);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:FilterParserImpl.java


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


示例9: testUnsubscribeDsListener

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


示例10: ItemWrapper

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
public ItemWrapper(Object item, MetaClass metaClass, Collection<MetaPropertyPath> properties) {
    this.item = item;
    this.metaClass = metaClass;

    for (MetaPropertyPath property : properties) {
        this.properties.put(property, createPropertyWrapper(item, property));
    }

    if (item instanceof CollectionDatasource) {
        cdsCollectionChangeListener = e -> fireItemPropertySetChanged();

        CollectionDatasource datasource = (CollectionDatasource) item;
        weakCollectionChangeListener = new WeakCollectionChangeListener(datasource, cdsCollectionChangeListener);
        //noinspection unchecked
        datasource.addCollectionChangeListener(weakCollectionChangeListener);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:18,代码来源:ItemWrapper.java


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


示例12: onNextClick

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected void onNextClick() {
    if (!(datasource instanceof CollectionDatasource.SupportsPaging)) {
        return;
    }

    CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource;
    int firstResult = ds.getFirstResult();
    ds.setFirstResult(ds.getFirstResult() + ds.getMaxResults());
    refreshDatasource(ds);

    if (state == State.LAST && size == 0) {
        ds.setFirstResult(firstResult);
        int maxResults = ds.getMaxResults();
        ds.setMaxResults(maxResults + 1);
        refreshDatasource(ds);
        ds.setMaxResults(maxResults);
    }
    if (owner instanceof WebAbstractTable) {
        com.vaadin.ui.Table vTable = (com.vaadin.ui.Table) ((WebAbstractTable) owner).getComponent();
        vTable.setCurrentPageFirstItemIndex(0);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:WebRowsCount.java


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


示例14: createOptionsDatasourceForLookup

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
/**
 * Creates the collection datasource that is used for selecting the dynamic attribute value. If the
 * CategoryAttribute has "where" or "join" clauses then only items that satisfy these clauses will be presented in
 * the options datasource
 */
public CollectionDatasource createOptionsDatasourceForLookup(MetaClass metaClass, String joinClause, String whereClause) {
    CollectionDatasource optionsDatasource = DsBuilder.create()
            .setMetaClass(metaClass)
            .setViewName(View.MINIMAL)
            .buildCollectionDatasource();

    String query = "select e from " + metaClass.getName() + " e";

    if (!Strings.isNullOrEmpty(joinClause)) {
        query += " " + joinClause;
    }
    if (!Strings.isNullOrEmpty(whereClause)) {
        query += " where " + whereClause.replaceAll("\\{E\\}", "e");
    }

    optionsDatasource.setQuery(query);
    optionsDatasource.refresh();
    return optionsDatasource;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:DynamicAttributesGuiTools.java


示例15: testUnsubscribeSubscribeDsListener

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


示例16: setLookupSelectHandler

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Override
public void setLookupSelectHandler(Runnable selectHandler) {
    impl.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                int rowForLocation = impl.getRowForLocation(e.getX(), e.getY());
                TreePath pathForLocation = impl.getPathForRow(rowForLocation);
                if (pathForLocation != null) {
                    CollectionDatasource treeCds = getDatasource();
                    if (treeCds != null) {
                        TreeModelAdapter.Node treeItem =
                                (TreeModelAdapter.Node) pathForLocation.getLastPathComponent();
                        if (treeItem != null) {
                            treeCds.setItem(treeItem.getEntity());
                            selectHandler.run();
                        }
                    }
                }
            }
        }
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:DesktopTree.java


示例17: setDatasource

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
@Override
public void setDatasource(CollectionDatasource datasource) {
    this.datasource = datasource;
    if (datasource != null) {
        collectionChangeListener = e -> {
            samePage = Operation.REFRESH != e.getOperation()
                        && Operation.CLEAR != e.getOperation();
            onCollectionChanged();
        };
        //noinspection unchecked
        this.datasource.addCollectionChangeListener(new WeakCollectionChangeListener(this.datasource, collectionChangeListener));

        impl.getCountButton().addActionListener(e -> onLinkClick());

        impl.getPrevButton().addActionListener(e -> onPrevClick());
        impl.getNextButton().addActionListener(e -> onNextClick());
        impl.getFirstButton().addActionListener(e -> onFirstClick());
        impl.getLastButton().addActionListener(e -> onLastClick());
        if (datasource.getState() == Datasource.State.VALID) {
            onCollectionChanged();
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:DesktopRowsCount.java


示例18: createOptionsDataSource

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected CollectionDatasource<Entity<Object>, Object> createOptionsDataSource(MetaClass metaClass) {
    CollectionDatasource ds = DsBuilder.create(datasource.getDsContext())
            .setMetaClass(metaClass)
            .setViewName(entityView)
            .buildCollectionDatasource();

    ds.setRefreshOnComponentValueChange(true);
    ((DatasourceImplementation) ds).initialized();

    if (!StringUtils.isBlank(entityWhere)) {
        QueryTransformer transformer = QueryTransformerFactory.createTransformer(
                "select e from " + metaClass.getName() + " e");
        transformer.addWhere(entityWhere);
        String q = transformer.getResult();
        ds.setQuery(q);
    }

    if (WindowParams.DISABLE_AUTO_REFRESH.getBool(datasource.getDsContext().getFrameContext())) {
        if (ds instanceof CollectionDatasource.Suspendable)
            ((CollectionDatasource.Suspendable) ds).refreshIfNotSuspended();
        else
            ds.refresh();
    }

    return ds;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:Param.java


示例19: createAggregatableRow

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
protected int createAggregatableRow(Table table, List<Table.Column> columns, int rowNumber, int aggregatableRow, CollectionDatasource datasource) {
    HSSFRow row = sheet.createRow(rowNumber);
    Map<Object, Object> results = table.getAggregationResults();

    int i = 0;
    for (Table.Column column : columns) {
        AggregationInfo agr = column.getAggregation();
        if (agr != null) {
            Object agregationResult = results.get(agr.getPropertyPath());
            if (agregationResult != null) {
                HSSFCell cell = row.createCell(i);
                formatValueCell(cell, agregationResult, null, i, rowNumber, 0, null);
            }
        }
        i++;
    }
    return rowNumber;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:ExcelExporter.java


示例20: refreshClickListeners

import com.haulmont.cuba.gui.data.CollectionDatasource; //导入依赖的package包/类
public void refreshClickListeners(ItemClickListener listener) {
    if (datasource != null && CollectionDatasource.State.VALID.equals(datasource.getState())) {
        for (Object id : datasource.getItemIds()) {
            Instance item = datasource.getItem(id);
            final TokenListLabel label = itemComponents.get(item);
            if (label != null) {
                if (listener == null) {
                    label.setClickListener(null);
                } else {
                    label.setClickListener(new ClickListener() {
                        @Override
                        public void onClick(TokenListLabel source) {
                            doClick(label);
                        }
                    });
                }
            }
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:DesktopTokenList.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ChecksumProto类代码示例发布时间:2022-05-22
下一篇:
Java StatusCode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap