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


Java LazyList类代码示例

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


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

示例1: getSortableContainerPropertyIds

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Collection<?> getSortableContainerPropertyIds() {
    if (backingList instanceof SortableLazyList) {
        // Assume SortableLazyList can sort by any Comparable property
    } else if (backingList instanceof LazyList) {
        // When using LazyList, don't support sorting by default
        // as the sorting should most probably be done at backend call level
        return Collections.emptySet();
    }
    final ArrayList<String> props = new ArrayList<>();
    for (Object a : getContainerPropertyIds()) {
        String propName = a.toString();
        try {
            Class<?> propType = getType(propName);
            if (propType != null && (propType.isPrimitive() || Comparable.class.isAssignableFrom(propType))) {
                props.add(propName);
            }
        } catch (Exception e) {
        }
    }
    return props;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:23,代码来源:ListContainer.java

示例2: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Component getTestComponent() {

    MGrid<Person> g = new MGrid<>(
            new LazyList.PagingProvider<Person>() {
                private static final long serialVersionUID = -9072230332041322210L;

                @Override
                public List<Person> findEntities(int firstRow) {
                    return Service.findAll(firstRow,
                            LazyList.DEFAULT_PAGE_SIZE);
                }
            },
            new LazyList.CountProvider() {
                private static final long serialVersionUID = -6915320247020779461L;

                @Override
                public int size() {
                    return (int) Service.count();
                }
            }
    );
    
    return g;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:26,代码来源:GridLazyLoading.java

示例3: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Component getTestComponent() {

    MTable<Person> g = new MTable<>(
            new LazyList.PagingProvider<Person>() {
                private static final long serialVersionUID = -9072230332041322210L;

                @Override
                public List<Person> findEntities(int firstRow) {
                    return Service.findAll(firstRow,
                            LazyList.DEFAULT_PAGE_SIZE);
                }
            },
            new LazyList.CountProvider() {
                private static final long serialVersionUID = -6915320247020779461L;

                @Override
                public int size() {
                    return (int) Service.count();
                }
            }
    );
    return g;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:25,代码来源:MTableLazyLoading.java

示例4: getSortableContainerPropertyIds

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Collection<?> getSortableContainerPropertyIds() {
    if (backingList instanceof SortableLazyList) {
        // Assume SortableLazyList can sort by any Comparable property
    } else if (backingList instanceof LazyList) {
        // When using LazyList, don't support sorting by default
        // as the sorting should most probably be done at backend call level
        return Collections.emptySet();
    }
    final ArrayList<String> properties = new ArrayList<String>();
    for (final Object a : getContainerPropertyIds()) {
        final DynaProperty db = getDynaClass().getDynaProperty(a.toString());
        if (db != null && db.getType() != null && (db.getType().
                isPrimitive() || Comparable.class.isAssignableFrom(
                db.getType()))) {
            properties.add(db.getName());
        }
    }
    return properties;
}
 
开发者ID:ExtaSoft,项目名称:extacrm,代码行数:21,代码来源:NListContainer.java

示例5: refreshRows

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
/**
 * Manually forces refresh of the whole data. ListContainer backing
 * MGrid/MTable don't support property change listeners (to save memory and
 * CPU cycles). This method explicitly forces Grid's row cache invalidation.
 */
public void refreshRows() {
    if (getContainerDataSource() instanceof ListContainer) {
        ListContainer<T> listContainer = getListContainer();
        if (listContainer.getItemIds() instanceof LazyList) {
            ((LazyList) listContainer.getItemIds()).reset();
        }
        listContainer.fireItemSetChange();
    }
    refreshVisibleRows();
}
 
开发者ID:viritin,项目名称:viritin,代码行数:16,代码来源:MGrid.java

示例6: lazyLoadFrom

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
/**
 * Makes the table lazy load its content with given strategy.
 *
 * @param pageProvider the interface via entities are fetched
 * @param countProvider the interface via the count of items is detected
 * @return this MTable object
 */
public MGrid<T> lazyLoadFrom(
        SortableLazyList.SortablePagingProvider<T> pageProvider,
        LazyList.CountProvider countProvider) {
    setRows(new SortableLazyList<T>(pageProvider, countProvider,
            DEFAULT_PAGE_SIZE));
    ensureSortListener();
    return this;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:16,代码来源:MGrid.java

示例7: lazyLoadFrom

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
/**
 * Makes the table lazy load its content with given strategy.
 *
 * @param pageProvider the interface via entities are fetched
 * @param countProvider the interface via the count of items is detected
 * @return this MTable object
 */
public MTable<T> lazyLoadFrom(
        SortableLazyList.SortablePagingProvider<T> pageProvider,
        LazyList.CountProvider countProvider) {
    setBeans(new SortableLazyList(pageProvider, countProvider,
            DEFAULT_PAGE_SIZE));
    return this;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:15,代码来源:MTable.java

示例8: refreshRows

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
/**
 * Clears caches in case the Table is backed by a LazyList implementation.
 * Also resets "pageBuffer" used by table. If you know you have changes in
 * the listing, you can call this method to ensure the UI gets updated.
 */
public void refreshRows() {
    if (bic != null && bic.getItemIds() instanceof LazyList) {
        ((LazyList) bic.getItemIds()).reset();
    }
    resetPageBuffer();
}
 
开发者ID:viritin,项目名称:viritin,代码行数:12,代码来源:MTable.java

示例9: loadFrom

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
/**
 * Set a new strategies how to load options.
 *
 * @param filterablePagingProvider the paging provider that gives the actual
 * options in pages
 * @param filterableCountProvider the count provider to give the total about
 * of options with current filter
 * @param pageLength the length of the pages that component should use to
 * access providers
 */
public void loadFrom(FilterablePagingProvider<T> filterablePagingProvider, FilterableCountProvider filterableCountProvider, int pageLength) {
    this.fpp = filterablePagingProvider;
    this.fcp = filterableCountProvider;
    // Need to re-create the piggybackList & set container, some refactoring should be done here
    piggybackLazyList = new LazyList<>(new LazyList.PagingProvider<T>() {

        private static final long serialVersionUID = 1027614132444478021L;

        @Override
        public List<T> findEntities(int firstRow) {
            return fpp.findEntities(firstRow,
                    getCurrentFilter());
        }
    },
            new LazyList.CountProvider() {
        private static final long serialVersionUID = -7339189124024626177L;

        @Override
        public int size() {
            return fcp.size(getCurrentFilter());
        }
    }, pageLength);
    setBic(new DummyFilterableListContainer<T>(getType(),
            piggybackLazyList));
    getSelect().setContainerDataSource(getBic());
}
 
开发者ID:viritin,项目名称:viritin,代码行数:37,代码来源:LazyComboBox.java

示例10: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Component getTestComponent() {
    MGrid<Person> g = new MGrid<>(Person.class).lazyLoadFrom(
            new LazyList.PagingProvider<Person>() {
        private static final long serialVersionUID = -9072230332041322210L;

        @Override
        public List<Person> findEntities(int firstRow) {
            return Service.findAll(firstRow,
                    LazyList.DEFAULT_PAGE_SIZE);
        }
    },
            new LazyList.CountProvider() {
        private static final long serialVersionUID = -6915320247020779461L;

        @Override
        public int size() {
            return (int) Service.count();
        }
    }
    ).withGeneratedColumn("name", p -> p.getFirstName() + " " + p.getLastName())
            .withFullWidth();

    MGrid<Person> g2 = new MGrid<>(Person.class).setRows(Service.findAll(0, 100))
            .withGeneratedColumn("name", p -> p.getFirstName() + " " + p.getLastName())
            .withFullWidth();
    return new MVerticalLayout().expand(g, g2);
}
 
开发者ID:viritin,项目名称:viritin,代码行数:29,代码来源:Issue219MGridGeneratedColumnWithLazyLoading.java

示例11: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Component getTestComponent() {
    pagingProvider = new LazyList.PagingProvider<Person>() {
        private static final long serialVersionUID = -9072230332041322210L;
        
        @Override
        public List<Person> findEntities(int firstRow) {
            return Service.findByFirstName(firstNameFilter, firstRow,
                    LazyList.DEFAULT_PAGE_SIZE);
        }
    };
    countProvider = new LazyList.CountProvider() {
        private static final long serialVersionUID = -6915320247020779461L;
        
        @Override
        public int size() {
            return (int) Service.countByFirstName(firstNameFilter);
        }
    };

    MGrid<Person> g = new MGrid<>(Person.class)
            .lazyLoadFrom(pagingProvider, countProvider);

    Grid.HeaderRow filteringHeader = g.appendHeaderRow();

    // Add new TextFields to each column which filters the data from
    // that column
    String columnId = "firstName";
    TextField filter = new MTextField()
            .withFullWidth().withStyleName(ValoTheme.TEXTFIELD_TINY)
            .withInputPrompt("Filter");
    filter.addTextChangeListener(event -> {
        firstNameFilter = event.getText();
        g.refreshRows();
    });
    filteringHeader.getCell(columnId).setComponent(filter);
    filteringHeader.getCell(columnId).setStyleName("filter-header");
    
    return g;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:41,代码来源:GridLazyLoadingAndFiltering.java

示例12: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Component getTestComponent() {

    MTable<Person> g = new MTable<>(
            Person.class)
            .withGeneratedColumn("age", p -> p.getAge() + " years")
            .withProperties("age", "firstName", "lastName")
            .withColumnHeaders("Ikä/Age", "Etu/First", "Suku/Last")
            .lazyLoadFrom(
                    firstRow -> Service.findAll(firstRow,
                    LazyList.DEFAULT_PAGE_SIZE), () -> (int) Service.count()
            );
    return g;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:15,代码来源:MTableGeneratedColumnOrder.java

示例13: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Component getTestComponent() {

    MTable<Person> g = new MTable<>();

        g.withGeneratedColumn("age", p -> p.getAge() + " years");
        g.withProperties("age", "firstName", "lastName");
        g.withColumnHeaders("Ikä/Age", "Etu/First", "Suku/Last");

        g.lazyLoadFrom(
                firstRow -> Service.findAll(firstRow,
                        LazyList.DEFAULT_PAGE_SIZE), () -> (int) Service.count()
        );
    return new MVerticalLayout(g);
}
 
开发者ID:viritin,项目名称:viritin,代码行数:16,代码来源:MTableGeneratedColumnOrder2.java

示例14: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
public Component getTestComponent() {
       
       Random r = new Random(0);

	final List<User> listOfPersons = 
			Service
			.getListOfPersons(1000).stream()
			.map(person -> {
                   User u = new User(person);
                   u.setLocale(r.nextBoolean() ? Locale.ENGLISH : Locale.FRENCH);
                   return u;
               })
			.collect(Collectors.toList());
	
	MTable<User> table = new MTable<>(
			(firstRow, sortAscending, property) -> {
				if (property != null) {
                                               if(property.equals("localizedSalutation")) {
                                                   Collections.sort(listOfPersons, new Comparator<User>(){
                                                       @Override
                                                       public int compare(User o1, User o2) {
                                                           return localizedSalutation(o1).compareTo(localizedSalutation(o2));
                                                       }
                                                   });
                                               } else {
					Collections.sort(listOfPersons, new BeanComparator<>(
							property));
                                                   
                                               }
					if (!sortAscending) {
						Collections.reverse(listOfPersons);
					}
				}
				int last = firstRow + LazyList.DEFAULT_PAGE_SIZE;
				if (last > listOfPersons.size()) {
					last = listOfPersons.size();
				}
				return new ArrayList<User>(listOfPersons.subList(firstRow,
						last));
			},
			() -> (int)Service.count()
			)
			.withProperties("localizedSalutation","locale", "person.firstName", "person.lastName")
			.withColumnHeaders("Salutation", "Locale", "Forename", "Name")
			.withFullWidth()
               .withGeneratedColumn("localizedSalutation", u-> localizedSalutation(u));

	return table;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:51,代码来源:MTableLazyLoadingWithEntityAspect.java

示例15: getTestComponent

import org.vaadin.viritin.LazyList; //导入依赖的package包/类
@Override
    public Component getTestComponent() {
        
        final List<Person> backingList = Service.getListOfPersons(0);
        
        MTable<Person> mTable = new MTable<>(
                new LazyList.PagingProvider<Person>() {

                    private static final long serialVersionUID = 4212839156216191152L;

                    @Override
                    public List<Person> findEntities(int firstRow) {
                        return backingList.subList(firstRow, 0);
                    }
                },
                new LazyList.CountProvider() {

                    private static final long serialVersionUID = -3958524394327292732L;

                    @Override
                    public int size() {
                        return 0;
                    }
                }
        ).withProperties("firstName", "lastName", "email");

        mTable.withFullWidth().withHeight("300px");
        
        // Alternative way, with explicitly defined bean type
//        mTable = new MTable<Person>(Person.class).lazyLoadFrom(
//                new LazyList.PagingProvider<Person>() {
//                    
//                    @Override
//                    public List<Person> findEntities(int firstRow) {
//                        return backingList.subList(firstRow, 0);
//                    }
//                },
//                new LazyList.CountProvider() {
//                    
//                    @Override
//                    public int size() {
//                        return 0;
//                    }
//                }
//        );
        
        return mTable;
    }
 
开发者ID:viritin,项目名称:viritin,代码行数:49,代码来源:MTableLazyLoadingEmptyList.java


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