Search in sources :

Example 1 with TableFilter

use of org.controlsfx.control.table.TableFilter in project Gargoyle by callakrsos.

the class FilterTableExample method start.

@Override
public void start(Stage primaryStage) throws Exception {
    TableView<DataItem> tableView = new TableView<>();
    FxUtil.installClipboardKeyEvent(tableView);
    tableView.setItems(FXCollections.observableArrayList());
    IntStream.range(0, 20000).mapToObj(i -> new DataItem()).forEach(d -> tableView.getItems().add(d));
    TableColumn<DataItem, Integer> smallInt = new TableColumn<>("Small Int");
    smallInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getSmallIntValue()));
    TableColumn<DataItem, Integer> largeInt = new TableColumn<>("Large Int");
    largeInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getLargeIntValue()));
    TableColumn<DataItem, String> randomLetter = new TableColumn<>("Letter");
    randomLetter.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomLetter()));
    TableColumn<DataItem, String> randomString1 = new TableColumn<>("AlphaNum 1");
    randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr1()));
    TableColumn<DataItem, String> randomString2 = new TableColumn<>("AlphaNum 2");
    randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr2()));
    tableView.getColumns().addAll(smallInt, largeInt, randomLetter, randomString1, randomString2);
    Platform.runLater(() -> new TableFilter<>(tableView));
    GridPane grp = new GridPane();
    GridPane.setFillHeight(tableView, true);
    GridPane.setFillWidth(tableView, true);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    grp.getChildren().add(tableView);
    Scene scene = new Scene(grp);
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : IntStream(java.util.stream.IntStream) Scene(javafx.scene.Scene) FXCollections(javafx.collections.FXCollections) Random(java.util.Random) UUID(java.util.UUID) TableColumn(javafx.scene.control.TableColumn) Application(javafx.application.Application) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Stage(javafx.stage.Stage) TableFilter(org.controlsfx.control.table.TableFilter) TableView(javafx.scene.control.TableView) GridPane(javafx.scene.layout.GridPane) GridPane(javafx.scene.layout.GridPane) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) TableView(javafx.scene.control.TableView)

Aggregations

FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 Random (java.util.Random)1 UUID (java.util.UUID)1 IntStream (java.util.stream.IntStream)1 Application (javafx.application.Application)1 Platform (javafx.application.Platform)1 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)1 FXCollections (javafx.collections.FXCollections)1 Scene (javafx.scene.Scene)1 TableColumn (javafx.scene.control.TableColumn)1 TableView (javafx.scene.control.TableView)1 GridPane (javafx.scene.layout.GridPane)1 Priority (javafx.scene.layout.Priority)1 Stage (javafx.stage.Stage)1 TableFilter (org.controlsfx.control.table.TableFilter)1