Search in sources :

Example 71 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class CheckBoxTableCellExam method start.

/*
	 * (non-Javadoc)
	 *
	 * @see javafx.application.Application#start(javafx.stage.Stage)
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    TableView<SampleVO> center = new TableView<>();
    center.setEditable(true);
    TableColumn<SampleVO, Boolean> e = new TableColumn<SampleVO, Boolean>();
    e.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<SampleVO, Boolean>, ObservableValue<Boolean>>() {

        @Override
        public ObservableValue<Boolean> call(CellDataFeatures<SampleVO, Boolean> param) {
            return param.getValue().checked;
        }
    });
    e.setCellFactory(new Callback<TableColumn<SampleVO, Boolean>, TableCell<SampleVO, Boolean>>() {

        @Override
        public TableCell<SampleVO, Boolean> call(TableColumn<SampleVO, Boolean> param) {
            return new CheckBoxTableCell<SampleVO, Boolean>() {

                /*
					 * (non-Javadoc)
					 *
					 * @see
					 * javafx.scene.control.cell.CheckBoxTableCell#updateItem(
					 * java.lang.Object, boolean)
					 */
                @Override
                public void updateItem(Boolean item, boolean empty) {
                    super.updateItem(item, empty);
                }

                /*
					 * (non-Javadoc)
					 *
					 * @see
					 * javafx.scene.control.Cell#isItemChanged(java.lang.Object,
					 * java.lang.Object)
					 */
                @Override
                protected boolean isItemChanged(Boolean oldItem, Boolean newItem) {
                    System.out.println(oldItem + " : " + newItem);
                    return super.isItemChanged(oldItem, newItem);
                }
            };
        }
    });
    e.setEditable(true);
    TableColumn<SampleVO, String> e2 = new TableColumn<SampleVO, String>();
    e2.setCellValueFactory(new PropertyValueFactory<SampleVO, String>("name"));
    center.getColumns().add(e);
    center.getColumns().add(e2);
    center.getItems().add(new SampleVO(true, "kim"));
    center.getItems().add(new SampleVO(true, "young"));
    BorderPane borderPane = new BorderPane(center);
    primaryStage.setScene(new Scene(borderPane));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ObservableValue(javafx.beans.value.ObservableValue) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) SampleVO(com.kyj.fx.voeditor.visual.example.CheckBoxTableCellExam.SampleVO) TableView(javafx.scene.control.TableView)

Example 72 with TableColumn

use of javafx.scene.control.TableColumn 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)

Example 73 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class ClipboardKeyEventInstaller method install.

/********************************
	 * 작성일 :  2016. 9. 3. 작성자 : KYJ
	 *
	 *
	 * @param tb
	 ********************************/
public static void install(TableView<?> tb) {
    tb.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
        int type = -1;
        if (e.isControlDown() && e.getCode() == KeyCode.C) {
            if (e.isShiftDown()) {
                type = 2;
            } else {
                type = 1;
            }
            if (type == -1)
                return;
            ObservableList<TablePosition> selectedCells = tb.getSelectionModel().getSelectedCells();
            TablePosition tablePosition = selectedCells.get(0);
            TableColumn tableColumn = tablePosition.getTableColumn();
            int row = tablePosition.getRow();
            int col = tb.getColumns().indexOf(tableColumn);
            switch(type) {
                case 1:
                    StringBuilder sb = new StringBuilder();
                    for (TablePosition cell : selectedCells) {
                        if (row != cell.getRow()) {
                            sb.append("\n");
                            row++;
                        } else if (col != tb.getColumns().indexOf(cell.getTableColumn())) {
                            sb.append("\t");
                        }
                        Object cellData = getDisplayText(cell, row);
                        sb.append(ValueUtil.decode(cellData, cellData, "").toString());
                    }
                    FxClipboardUtil.putString(sb.toString());
                    break;
                case 2:
                    Object cellData = getDisplayText(tableColumn, row);
                    FxClipboardUtil.putString(ValueUtil.decode(cellData, cellData, "").toString());
                    break;
            }
            e.consume();
        }
    });
}
Also used : TablePosition(javafx.scene.control.TablePosition) TableColumn(javafx.scene.control.TableColumn)

Example 74 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class TableViewWithVisibleRowCountExam method start.

/* (non-Javadoc)
	 * @see javafx.application.Application#start(javafx.stage.Stage)
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    TableViewWithVisibleRowCount<Object> center = new TableViewWithVisibleRowCount<>();
    TableColumn<Object, Object> e = new TableColumn<>();
    e.setCellValueFactory(new PropertyValueFactory<>("name"));
    center.getColumns().add(e);
    center.getItems().add(new Person("ssss"));
    center.getItems().add(new Person("ssss"));
    center.getItems().add(new Person("ssss"));
    center.getItems().add(new Person("ssss"));
    center.getItems().add(new Person("ssss"));
    center.getItems().add(new Person("ssss"));
    primaryStage.setScene(new Scene(new BorderPane(center), 300, 400));
    primaryStage.show();
    Platform.runLater(() -> {
        System.out.println(center.getVisibleRowCount());
    });
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn)

Example 75 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxTableViewUtil method installCopyHandler.

@SuppressWarnings("rawtypes")
public static void installCopyHandler(TableView<?> table) {
    table.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
        if (e.isConsumed())
            return;
        int type = -1;
        if (e.isControlDown() && e.getCode() == KeyCode.C) {
            if (e.isShiftDown()) {
                type = 2;
            } else {
                type = 1;
            }
        }
        if (type == -1)
            return;
        TableViewSelectionModel<?> selectionModel = table.getSelectionModel();
        SelectionMode selectionMode = selectionModel.getSelectionMode();
        boolean cellSelectionEnabled = selectionModel.isCellSelectionEnabled();
        if (!cellSelectionEnabled) {
            Object selectedItem = table.getSelectionModel().getSelectedItem();
            ObservableList<?> columns = table.getColumns();
            Optional<String> reduce = columns.stream().filter(ob -> ob instanceof TableColumn).map(obj -> (TableColumn) obj).map(tc -> tc.getCellData(selectedItem)).filter(v -> v != null).map(v -> v.toString()).reduce((o1, o2) -> o1.toString().concat("\t").concat(o2.toString()));
            reduce.ifPresent(str -> {
                FxClipboardUtil.putString(str);
                e.consume();
            });
        } else if (cellSelectionEnabled) {
            ObservableList<TablePosition> selectedCells = selectionModel.getSelectedCells();
            TablePosition tablePosition = selectedCells.get(0);
            TableColumn tableColumn = tablePosition.getTableColumn();
            int row = tablePosition.getRow();
            int col = table.getColumns().indexOf(tableColumn);
            switch(type) {
                case 1:
                    StringBuilder sb = new StringBuilder();
                    for (TablePosition cell : selectedCells) {
                        if (row != cell.getRow()) {
                            sb.append("\n");
                            row++;
                        } else if (col != table.getColumns().indexOf(cell.getTableColumn())) {
                            sb.append("\t");
                        }
                        Object cellData = cell.getTableColumn().getCellData(cell.getRow());
                        sb.append(ValueUtil.decode(cellData, cellData, "").toString());
                    }
                    FxClipboardUtil.putString(sb.toString());
                    e.consume();
                    break;
                case 2:
                    Object cellData = tableColumn.getCellData(row);
                    FxClipboardUtil.putString(ValueUtil.decode(cellData, cellData, "").toString());
                    e.consume();
                    break;
            }
        }
    });
}
Also used : KeyCode(javafx.scene.input.KeyCode) ObjectProperty(javafx.beans.property.ObjectProperty) TablePosition(javafx.scene.control.TablePosition) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) KeyEvent(javafx.scene.input.KeyEvent) StringConverter(javafx.util.StringConverter) Field(java.lang.reflect.Field) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) SelectionMode(javafx.scene.control.SelectionMode) ComboBoxTableCell(javafx.scene.control.cell.ComboBoxTableCell) Clipboard(javafx.scene.input.Clipboard) Optional(java.util.Optional) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Method(java.lang.reflect.Method) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) TableColumn(javafx.scene.control.TableColumn) ObservableList(javafx.collections.ObservableList) TablePosition(javafx.scene.control.TablePosition) SelectionMode(javafx.scene.control.SelectionMode)

Aggregations

TableColumn (javafx.scene.control.TableColumn)132 TableView (javafx.scene.control.TableView)68 TableCell (javafx.scene.control.TableCell)66 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)46 Button (javafx.scene.control.Button)44 VBox (javafx.scene.layout.VBox)41 Tooltip (javafx.scene.control.Tooltip)40 Callback (javafx.util.Callback)40 ObservableList (javafx.collections.ObservableList)39 Insets (javafx.geometry.Insets)37 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)36 Label (javafx.scene.control.Label)35 ArrayList (java.util.ArrayList)33 List (java.util.List)33 Scene (javafx.scene.Scene)32 Res (bisq.core.locale.Res)31 FxmlView (bisq.desktop.common.view.FxmlView)31 Inject (javax.inject.Inject)31 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)30 SortedList (javafx.collections.transformation.SortedList)27