-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/test/java/com/flowingcode/vaadin/addons/twincolgrid/DoubleClickDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*- | ||
* #%L | ||
* TwinColGrid add-on | ||
* %% | ||
* Copyright (C) 2017 - 2022 Flowing Code | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package com.flowingcode.vaadin.addons.twincolgrid; | ||
|
||
import com.flowingcode.vaadin.addons.demo.DemoSource; | ||
import com.vaadin.flow.component.html.Span; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.router.PageTitle; | ||
import com.vaadin.flow.router.Route; | ||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@SuppressWarnings("serial") | ||
@PageTitle("Double click") | ||
@DemoSource | ||
@Route(value = "twincolgrid/doubleclick", layout = TwincolDemoView.class) | ||
public class DoubleClickDemo extends VerticalLayout { | ||
|
||
private final Set<Book> selectedBooks = new HashSet<>(); | ||
private final List<Book> availableBooks = new ArrayList<>(); | ||
|
||
public DoubleClickDemo() { | ||
initializeData(); | ||
|
||
final TwinColGrid<Book> twinColGrid = | ||
new TwinColGrid<>(availableBooks, null) | ||
.addSortableColumn(Book::getIsbn, Comparator.comparing(Book::getIsbn), "ISBN") | ||
.addSortableColumn(Book::getTitle, Comparator.comparing(Book::getTitle), "Title") | ||
.withAvailableGridCaption("Available books") | ||
.withSelectionGridCaption("Added books") | ||
.withSizeFull() | ||
.selectRowOnClick(); | ||
twinColGrid.setValue(selectedBooks); | ||
twinColGrid.setMoveItemsByDoubleClick(true); | ||
|
||
add(new Span("Move items by double click"), twinColGrid); | ||
setSizeFull(); | ||
} | ||
|
||
private void initializeData() { | ||
selectedBooks.add(new Book("1478375108", "Vaadin Recipes")); | ||
selectedBooks.add(new Book("9789526800677", "Book of Vaadin: Volume 2 ")); | ||
availableBooks.add(new Book("1478375108", "Vaadin Recipes")); | ||
availableBooks.add(new Book("9781849515221", "Learning Vaadin")); | ||
availableBooks.add( | ||
new Book("9781782162261", "Vaadin 7 UI Design By Example: Beginner\u2019s Guide")); | ||
availableBooks.add(new Book("9781849518802", "Vaadin 7 Cookbook")); | ||
availableBooks.add(new Book("9526800605", "Book of Vaadin: 7th Edition, 1st Revision")); | ||
availableBooks.add(new Book("9789526800677", "Book of Vaadin: Volume 2 ")); | ||
availableBooks.add(new Book("9529267533", "Book of Vaadin")); | ||
availableBooks.add(new Book("1782169776", "Learning Vaadin 7, Second Edition")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters