本文整理汇总了Java中com.vaadin.shared.data.sort.SortDirection类的典型用法代码示例。如果您正苦于以下问题:Java SortDirection类的具体用法?Java SortDirection怎么用?Java SortDirection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SortDirection类属于com.vaadin.shared.data.sort包,在下文中一共展示了SortDirection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ReleasesView
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
public ReleasesView() {
setSizeFull();
setMargin(false);
ButtonBar buttonBar = new ButtonBar();
addButton = buttonBar.addButton("Add", FontAwesome.PLUS, e -> add());
editButton = buttonBar.addButton("Edit", FontAwesome.EDIT, e -> edit());
exportButton = buttonBar.addButton("Export", FontAwesome.DOWNLOAD, e -> export());
archiveButton = buttonBar.addButton("Archive", FontAwesome.ARCHIVE, e -> archive());
// TODO add support for the archive button
archiveButton.setVisible(false);
finalizeButton = buttonBar.addButton("Finalize", FontAwesome.CUBE, e -> finalize());
addComponent(buttonBar);
enableDisableButtonsForSelectionSize(0);
grid = new Grid();
grid.setSizeFull();
grid.setSelectionMode(SelectionMode.MULTI);
grid.addItemClickListener(e->rowClicked(e));
grid.addSelectionListener((e) -> rowSelected(e));
container = new BeanItemContainer<>(ReleasePackage.class);
grid.setContainerDataSource(container);
grid.setColumns("name", "versionLabel", "releaseDate", "released");
grid.sort("releaseDate", SortDirection.DESCENDING);
addComponent(grid);
setExpandRatio(grid, 1);
progressBar = new ProgressBar(0.0f);
}
示例2: fetchFromBackEnd
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
@Override
protected Stream<T> fetchFromBackEnd(Query<T, ExampleFilter<T>> query) {
int page = query.getOffset() / query.getLimit();
List<Sort.Order> sortOrders = query.getSortOrders().stream()
.map(sortOrder -> new Sort.Order(sortOrder.getDirection() == SortDirection.ASCENDING ? Sort.Direction.ASC
: Sort.Direction.DESC,
sortOrder.getSorted()))
.collect(Collectors.toList());
PageRequest pageRequest = new PageRequest(page, query.getLimit(), sortOrders.isEmpty() ? null : new Sort(sortOrders));
List<T> items = null;
if (query.getFilter().isPresent()) {
items = repository.findAll(query.getFilter().get().example, pageRequest).getContent();
}
else {
items = repository.findAll(pageRequest).getContent();
}
return items.subList(query.getOffset() % query.getLimit(), items.size()).stream(); // TODO: comment why this is done
}
示例3: loadSortOrder
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
private void loadSortOrder() {
Callback saveFunc = new Callback() {
@Override
public void onValueDetected(String value) {
List<SortOrder> sortOrderList = new ArrayList<>();
if (!StringUtils.isEmpty(value)) {
String[] sortOrder = value.split(SEMI_COLOMN_DELIMITER);
for (String so : sortOrder) {
String[] colIdWithSort = so.split(COLOMN_DELIMITER);
Object propertyId = colIdWithSort[0];
SortDirection direction = SortDirection.valueOf(
colIdWithSort[1]);
SortOrder soCreated = new SortOrder(propertyId,
direction);
sortOrderList.add(soCreated);
}
}
grid.setSortOrder(sortOrderList);
}
};
BrowserCookie.detectCookieValue(SORT_ORDER_SETTINGS_NAME, saveFunc);
}
示例4: getPrefCandSortDirection
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
/**
* @return la direction du trie
*/
public SortDirection getPrefCandSortDirection(SortDirection defaultSortDirection) {
PreferenceInd pref = userController.getPreferenceIndividu();
if (pref.getCandColSortDirectionPref()!=null && pref.getCandColSortDirectionPref().equals(ConstanteUtils.PREFERENCE_SORT_DIRECTION_ASCENDING)){
return SortDirection.ASCENDING;
}else if (pref.getCandColSortDirectionPref()!=null && pref.getCandColSortDirectionPref().equals(ConstanteUtils.PREFERENCE_SORT_DIRECTION_DESCENDING)){
return SortDirection.DESCENDING;
}
return defaultSortDirection;
}
示例5: getSorts
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
private Bson getSorts(List<QuerySortOrder> list) {
if (list == null || list.size() == 0) return defaultSort;
List<Bson> newSorts = new ArrayList<>();
for (QuerySortOrder querySortOrder : list) {
if (querySortOrder.getDirection() == null || querySortOrder.getDirection().equals(SortDirection.ASCENDING)) newSorts.add(Sorts.ascending(querySortOrder.getSorted()));
else newSorts.add(Sorts.descending(querySortOrder.getSorted()));
}
return Sorts.orderBy(newSorts);
}
示例6: fetchFromBackEnd
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
@Override
protected Stream<T> fetchFromBackEnd(Query<T, String> query) {
// The index of the first item to load
int offset = query.getOffset();
// The number of items to load
int limit = query.getLimit();
List<Sort> sortOrders = new ArrayList<>();
if (!sortInMemory) {
query.getSortOrders().forEach(queryOrder -> {
Sort sort = service.createSort(
// The name of the sorted property
queryOrder.getSorted(),
// The sort direction for this property
queryOrder.getDirection() == SortDirection.DESCENDING);
sortOrders.add(sort);
});
}
List<T> list = new ArrayList<>();
if (StringUtils.isNoneBlank(filterProperty) && StringUtils.isNoneBlank(filterText)) {
list = service.findAllByLikePaged(filterProperty, filterText, offset, limit);
} else {
list = service.findAllPagedOrderBy(offset, limit, sortOrders);
}
Stream<T> stream = list.stream();
if (sortInMemory) {
Optional<Comparator<T>> comparing = Stream.of(query.getInMemorySorting()).filter(c -> c != null).reduce((c1, c2) -> c1.thenComparing(c2));
if (comparing.isPresent()) {
stream = stream.sorted(comparing.get());
}
}
return stream;
}
示例7: testGetSortProperties
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
@Test
public void testGetSortProperties() {
SortOrder sortOrder = new SortOrder("caption", SortDirection.ASCENDING);
SortOrder[] sortOrderArray = generator.getSortProperties(sortOrder);
assertThat(sortOrderArray, is(arrayWithSize(1)));
assertThat(sortOrder, is(sameInstance(sortOrderArray[0])));
}
示例8: testGetSortPropertiesWithPrefix
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
@Test
public void testGetSortPropertiesWithPrefix() {
SortOrder sortOrder = new SortOrder("something", SortDirection.ASCENDING);
SortOrder[] sortOrderArray = generator.getSortProperties(sortOrder);
assertThat(sortOrderArray, is(arrayWithSize(1)));
assertThat(sortOrder, is(sameInstance(sortOrderArray[0])));
}
示例9: getEntriesPaged
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
/**
* Finds a set of entries from database with given filter, starting from
* given row. The "page size" (aka max results limit passed for the query)
* is 45.
*
* @param filter the filters string
* @param firstRow the first row to be fetched
* @param maxresults maximum number of results
* @return
*/
public List<PhoneBookEntry> getEntriesPaged(String filter, int firstRow, int maxresults, List<QuerySortOrder> sortOrder) {
QueryResult<PhoneBookEntry> qr = entryRepo.findByNameLikeIgnoreCase("%" + filter + "%");
for (QuerySortOrder qso : sortOrder) {
if(qso.getDirection() == SortDirection.ASCENDING) {
qr = qr.orderAsc(qso.getSorted());
} else {
qr = qr.orderDesc(qso.getSorted());
}
}
return qr
.firstResult(firstRow).maxResults(maxresults)
.getResultList();
}
示例10: buildGrid
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
protected void buildGrid() {
grid = new Grid();
grid.setEditorEnabled(true);
grid.setSizeFull();
grid.setSelectionMode(SelectionMode.SINGLE);
grid.setColumns("projectName","newDeployName","newDeployVersion",
"newDeployType","existingDeployName","existingDeployVersion",
"existingDeployType","upgrade");
container = new BeanItemContainer<>(DeploymentLine.class);
buildContainer();
grid.setContainerDataSource(container);
grid.sort("projectName", SortDirection.DESCENDING);
}
示例11: test
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
@Test
public void test() {
Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
Person p2 = new Person(1, "George", LocalDate.of(1991, Month.JUNE, 19));
Person p3 = new Person(1, "Tim", LocalDate.of(1995, Month.APRIL, 7));
List<Person> persons = Arrays.asList(p1, p2, p3);
ListDataProvider<Person> dataProvider = DataProvider.ofCollection(persons);
FGrid<Person> grid = new FGrid<Person>(Person.class).withColumns("name", "birthday")
.withSelectionMode(SelectionMode.SINGLE)
.withFrozenColumnCount(1)
.withHeaderVisible(false)
.withFooterVisible(false)
.withRowHeight(25)
.withColumnReorderingAllowed(false)
.withHeightByRows(12)
.withDataProvider(dataProvider)
.withSort("birthday", SortDirection.DESCENDING);
grid.withItemClickListener(event -> grid.setDetailsVisible(event.getItem(), !grid.isDetailsVisible(event.getItem())))
.withDetailsGenerator(person -> new Label(person.getName()))
.withSortListener(event -> System.out.println("sort changed"));
Column<Person, ?> birthdayColumn = grid.getColumn("birthday");
assertNotNull(grid.getColumn("name"));
assertNotNull(birthdayColumn);
assertTrue(grid.getSelectionModel() instanceof SingleSelectionModel);
assertEquals(1, grid.getFrozenColumnCount());
assertFalse(grid.isHeaderVisible());
assertFalse(grid.isFooterVisible());
assertFalse(grid.isColumnReorderingAllowed());
assertEquals(25, grid.getRowHeight(), 0);
assertEquals(12, grid.getHeightByRows(), 0);
assertEquals(dataProvider, grid.getDataProvider());
assertEquals(birthdayColumn, grid.getSortOrder().get(0).getSorted());
assertEquals(SortDirection.DESCENDING, grid.getSortOrder().get(0).getDirection());
assertEquals(1, grid.getListeners(ItemClick.class).size());
assertEquals(1, grid.getListeners(SortEvent.class).size());
}
示例12: enter
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
@Override
public void enter(ViewChangeEvent event) {
super.enter(event);
grid.sort("name", SortDirection.ASCENDING);
}
示例13: testGetSortPropertiesWithPropertyNotInBean
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
@Test
public void testGetSortPropertiesWithPropertyNotInBean() {
SortOrder sortOrder = new SortOrder("notinbean", SortDirection.ASCENDING);
SortOrder[] sortOrderArray = generator.getSortProperties(sortOrder);
assertThat(sortOrderArray, is(arrayWithSize(0)));
}
示例14: initColumn
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
/**
* Initialisation des colonnes par défaut
*
* @param fieldsOrder
* @param prefixeProperty
* @param sortProperty
*/
public void initColumn(String[] fieldsOrder, String prefixeProperty, String sortProperty) {
initColumn(fieldsOrder, fieldsOrder, fieldsOrder, prefixeProperty, sortProperty, SortDirection.ASCENDING, null);
}
示例15: withSort
import com.vaadin.shared.data.sort.SortDirection; //导入依赖的package包/类
/**
* Sort this Grid in user-specified direction by a column.
*
* @param column
* a column to sort against
* @param direction
* a sort order value (ascending/descending)
* @return this for method chaining
* @see Grid#sort(Column, SortDirection)
*/
@SuppressWarnings("unchecked")
public default THIS withSort(Column<ITEM, ?> column, SortDirection direction) {
((Grid<ITEM>) this).sort(column, direction);
return (THIS) this;
}