javafx.scene.control.TableColumn Java Examples

The following examples show how to use javafx.scene.control.TableColumn. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableSample.java    From marathonv5 with Apache License 2.0 7 votes vote down vote up
public TableSample() {
    final ObservableList<Person> data = FXCollections.observableArrayList(
        new Person("Jacob",     "Smith",    "[email protected]" ),
        new Person("Isabella",  "Johnson",  "[email protected]" ),
        new Person("Ethan",     "Williams", "[email protected]" ),
        new Person("Emma",      "Jones",    "[email protected]" ),
        new Person("Michael",   "Brown",    "[email protected]" )
    );
    TableColumn firstNameCol = new TableColumn();
    firstNameCol.setText("First");
    firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
    TableColumn lastNameCol = new TableColumn();
    lastNameCol.setText("Last");
    lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
    TableColumn emailCol = new TableColumn();
    emailCol.setText("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory("email"));
    TableView tableView = new TableView();
    tableView.setItems(data);
    tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
    getChildren().add(tableView);
}
 
Example #2
Source File: EventDetectionUI.java    From SONDY with GNU General Public License v3.0 6 votes vote down vote up
public final void initializeParameterTable(){
    parameterTable.setEditable(true);
    TableColumn keyColumn = new TableColumn("Parameter");
    keyColumn.setMinWidth(Main.columnWidthRIGHT/2-1);
    keyColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
    TableColumn valueColumn = new TableColumn("Value");
    valueColumn.setMinWidth(Main.columnWidthRIGHT/2-1);
    valueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    valueColumn.setCellValueFactory(new PropertyValueFactory<>("value")); 
    valueColumn.setOnEditCommit(
        new EventHandler<CellEditEvent<Parameter, String>>() {
            @Override
            public void handle(CellEditEvent<Parameter, String> t) {
                ((Parameter) t.getTableView().getItems().get(t.getTablePosition().getRow())).setValue(t.getNewValue());
            }
        }
    );
    parameterTable.getColumns().addAll(keyColumn,valueColumn);
}
 
Example #3
Source File: TableDateCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, Long> call(TableColumn<T, Long> param) {
    TableCell<T, Long> cell = new TableCell<T, Long>() {
        private final Text text = new Text();

        @Override
        protected void updateItem(final Long item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null || (long) item <= 0) {
                setText(null);
                setGraphic(null);
                return;
            }
            text.setText(DateTools.datetimeToString((long) item));
            setGraphic(text);
        }
    };
    return cell;
}
 
Example #4
Source File: TableMessageCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, P> call(TableColumn<T, P> param) {

    TableCell<T, P> cell = new TableCell<T, P>() {
        @Override
        public void updateItem(P item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null) {
                setText(null);
                setGraphic(null);
                return;
            }
            setText(AppVariables.message((String) item));
            setGraphic(null);
        }
    };
    return cell;
}
 
Example #5
Source File: Tools.java    From logbook-kai with MIT License 6 votes vote down vote up
/**
 * テーブルソート列の設定を行う
 * @param table テーブル
 * @param key テーブルのキー名
 */
public static <S> void setSortOrder(TableView<S> table, String key) {
    Map<String, String> setting = AppConfig.get()
            .getColumnSortOrderMap()
            .get(key);
    ObservableList<TableColumn<S, ?>> sortOrder = table.getSortOrder();
    if (setting != null) {
        // 初期設定
        Map<String, TableColumn<S, ?>> columnsMap = getColumns(table)
                .collect(Collectors.toMap(Tables::getColumnName, c -> c, (c1, c2) -> c1));
        setting.forEach((k, v) -> {
            Optional.ofNullable(columnsMap.get(k)).ifPresent(col -> {
                sortOrder.add(col);
                col.setSortType(SortType.valueOf(v));
            });
        });
    }
    // ソート列またはソートタイプが変更された時に設定を保存する
    sortOrder.addListener((ListChangeListener<TableColumn<S, ?>>) e -> storeSortOrder(table, key));
    getColumns(table).forEach(col -> {
        col.sortTypeProperty().addListener((ob, o, n) -> storeSortOrder(table, key));
    });
}
 
Example #6
Source File: TableFileSizeCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, Long> call(TableColumn<T, Long> param) {
    TableCell<T, Long> cell = new TableCell<T, Long>() {
        private final Text text = new Text();

        @Override
        protected void updateItem(final Long item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null || (long) item <= 0) {
                setText(null);
                setGraphic(null);
                return;
            }
            text.setText(FileTools.showFileSize((long) item));
            setGraphic(text);
        }
    };
    return cell;
}
 
Example #7
Source File: TableNumberCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, Long> call(TableColumn<T, Long> param) {
    TableCell<T, Long> cell = new TableCell<T, Long>() {
        private final Text text = new Text();

        @Override
        protected void updateItem(final Long item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null || (long) item <= 0) {
                setText(null);
                setGraphic(null);
                return;
            }
            text.setText(StringTools.format((long) item));
            setGraphic(text);
        }
    };
    return cell;
}
 
Example #8
Source File: RFXTableViewTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void selectCell() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TableColumn column = getTableColumnAt(tableView, 1);
        tableView.getSelectionModel().select(1, column);
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", recording.getParameters()[0]);
}
 
Example #9
Source File: SpreadView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void initialize() {
    tableView = new TableView<>();

    int gridRow = 0;
    GridPane.setRowIndex(tableView, gridRow);
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    root.getChildren().add(tableView);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData"));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    TableColumn<SpreadItem, SpreadItem> currencyColumn = getCurrencyColumn();
    tableView.getColumns().add(currencyColumn);
    numberOfOffersColumn = getNumberOfOffersColumn();
    tableView.getColumns().add(numberOfOffersColumn);
    numberOfBuyOffersColumn = getNumberOfBuyOffersColumn();
    tableView.getColumns().add(numberOfBuyOffersColumn);
    numberOfSellOffersColumn = getNumberOfSellOffersColumn();
    tableView.getColumns().add(numberOfSellOffersColumn);
    totalAmountColumn = getTotalAmountColumn();
    tableView.getColumns().add(totalAmountColumn);
    TableColumn<SpreadItem, SpreadItem> spreadColumn = getSpreadColumn();
    tableView.getColumns().add(spreadColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    currencyColumn.setComparator(Comparator.comparing(o -> CurrencyUtil.getNameByCode(o.currencyCode)));
    numberOfOffersColumn.setComparator(Comparator.comparingInt(o3 -> o3.numberOfOffers));
    numberOfBuyOffersColumn.setComparator(Comparator.comparingInt(o3 -> o3.numberOfBuyOffers));
    numberOfSellOffersColumn.setComparator(Comparator.comparingInt(o2 -> o2.numberOfSellOffers));
    totalAmountColumn.setComparator(Comparator.comparing(o -> o.totalAmount));
    spreadColumn.setComparator(Comparator.comparingDouble(o -> o.percentageValue));

    numberOfOffersColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(numberOfOffersColumn);
    itemListChangeListener = c -> updateHeaders();
}
 
Example #10
Source File: TableVisualisation.java    From constellation with Apache License 2.0 6 votes vote down vote up
public void addColumn(final String columnName, final int percentWidth) {
    final TableColumn<C, Object> column = new TableColumn<>(columnName);
    tableColumns.put(columnName, column);

    column.prefWidthProperty().bind(table.widthProperty().multiply(percentWidth / 100.0));

    column.setCellValueFactory(cellData -> new SimpleObjectProperty<>(translator.getCellData(cellData.getValue(), columnName)));

    column.setCellFactory(columnData -> {
        return new TableCell<C, Object>() {
            @Override
            public void updateItem(final Object item, final boolean empty) {
                super.updateItem(item, empty);
                if (item != null) {
                    this.setText(translator.getCellText(this.getTableRow().getItem(), item, columnName));
                    final ConstellationColor color = translator.getCellColor(this.getTableRow().getItem(), item, columnName);
                    this.setBackground(new Background(new BackgroundFill(color.getJavaFXColor(), CornerRadii.EMPTY, Insets.EMPTY)));
                }
            }
        };
    });

    column.setSortable(true);

    table.getColumns().add(column);
}
 
Example #11
Source File: RFXTableViewTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void getText() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<Object> text = new ArrayList<>();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TableColumn column = getTableColumnAt(tableView, 1);
        tableView.getSelectionModel().select(1, column);
        rfxTableView.focusLost(null);
        text.add(rfxTableView.getAttribute("text"));
    });
    new Wait("Waiting for table text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", text.get(0));
}
 
Example #12
Source File: TableBooleanCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
    public TableCell<T, Boolean> call(TableColumn<T, Boolean> param) {
        final ImageView imageview = new ImageView(ControlStyle.getIcon("iconYes.png"));
        imageview.setPreserveRatio(true);
        imageview.setFitWidth(AppVariables.iconSize);
        imageview.setFitHeight(AppVariables.iconSize);
        TableCell<T, Boolean> cell = new TableCell<T, Boolean>() {
            @Override
            public void updateItem(Boolean item, boolean empty) {
                super.updateItem(item, empty);
                if (empty || item == null || !((boolean) item)) {
                    setText(null);
                    setGraphic(null);
                    return;
                }
//                setGraphic(AppVariables.getTrueImage());
//                setText(AppVariables.message("True"));
//                setGraphic(null);

                setGraphic(imageview);
                setText(null);
            }
        };
        return cell;
    }
 
Example #13
Source File: BadaboomController.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initialize(final URL location, final ResourceBundle resources) {
	final ObservableList<TableColumn<Throwable, ?>> cols = table.getColumns();
	((TableColumn<Throwable, String>) cols.get(0)).setCellValueFactory(cell -> new ReadOnlyStringWrapper(cell.getValue().toString()));
	((TableColumn<Throwable, String>) cols.get(1)).setCellValueFactory(cell -> new ReadOnlyStringWrapper(cell.getValue().getMessage()));
	((TableColumn<Throwable, String>) cols.get(2)).setCellValueFactory(cell -> {
		final StackTraceElement[] stackTrace = cell.getValue().getStackTrace();
		final String msg = stackTrace.length > 0 ? stackTrace[0].toString() : "";
		return new ReadOnlyStringWrapper(msg);
	});
	cols.forEach(col -> col.prefWidthProperty().bind(table.widthProperty().divide(3)));
	table.itemsProperty().bind(BadaboomCollector.INSTANCE.errorsProperty());
	table.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

	final Callable<String> converter = () -> {
		final Throwable ex = table.getSelectionModel().getSelectedItem();
		if(ex == null) {
			return "";
		}
		return Arrays.stream(ex.getStackTrace()).map(Object::toString).collect(Collectors.joining("\n\tat ", ex.toString() + "\n\tat ", "")); //NON-NLS
	};
	stack.textProperty().bind(Bindings.createStringBinding(converter, table.getSelectionModel().selectedItemProperty()));
}
 
Example #14
Source File: DepositView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setUsageColumnCellFactory() {
    usageColumn.getStyleClass().add("last-column");
    usageColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    usageColumn.setCellFactory(new Callback<>() {

        @Override
        public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem,
                DepositListItem> column) {
            return new TableCell<>() {

                @Override
                public void updateItem(final DepositListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        setGraphic(new AutoTooltipLabel(item.getUsage()));
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
}
 
Example #15
Source File: OpenOffersView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setPriceColumnCellFactory() {
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<OpenOfferListItem, OpenOfferListItem> call(
                        TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final OpenOfferListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            getStyleClass().removeAll("offer-disabled");

                            if (item != null) {
                                if (model.isDeactivated(item)) getStyleClass().add("offer-disabled");
                                setGraphic(new AutoTooltipLabel(model.getPrice(item)));
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
}
 
Example #16
Source File: LockedView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setDateColumnCellFactory() {
    dateColumn.getStyleClass().add("first-column");
    dateColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    dateColumn.setCellFactory(new Callback<>() {

        @Override
        public TableCell<LockedListItem, LockedListItem> call(TableColumn<LockedListItem,
                LockedListItem> column) {
            return new TableCell<>() {

                @Override
                public void updateItem(final LockedListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (getTradable(item).isPresent())
                            setGraphic(new AutoTooltipLabel(DisplayUtils.formatDateTime(getTradable(item).get().getDate())));
                        else
                            setGraphic(new AutoTooltipLabel(Res.get("shared.noDateAvailable")));
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
}
 
Example #17
Source File: AnimatedTableRow.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
private TableView<Person> createTable() {
    final TableView<Person> table = new TableView<Person>();
    table.setEditable(true);

    TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name");
    firstNameCol.setMinWidth(100);
    firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));

    TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name");
    lastNameCol.setMinWidth(100);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));

    TableColumn<Person, String> emailCol = new TableColumn<>("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));

    table.getColumns().addAll(Arrays.asList(firstNameCol, lastNameCol, emailCol));
    return table;
}
 
Example #18
Source File: PendingTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setRoleColumnCellFactory() {
    roleColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    roleColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<PendingTradesListItem, PendingTradesListItem> call(
                        TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final PendingTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null && !empty)
                                setGraphic(new AutoTooltipLabel(model.getMyRole(item)));
                            else
                                setGraphic(null);
                        }
                    };
                }
            });
}
 
Example #19
Source File: PendingTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setPaymentMethodColumnCellFactory() {
    paymentMethodColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    paymentMethodColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<PendingTradesListItem, PendingTradesListItem> call(
                        TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final PendingTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null && !empty)
                                setGraphic(new AutoTooltipLabel(model.getPaymentMethod(item)));
                            else
                                setGraphic(null);
                        }
                    };
                }
            });
}
 
Example #20
Source File: StringTable.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void handleKey(final KeyEvent event)
{
    if (event.getCode() == KeyCode.TAB)
    {
        // Commit value from combo's text field into combo's value...
        combo.commitValue();
        // .. and use that for the cell
        commitEdit(combo.getValue());

        // Edit next/prev column in same row
        final ObservableList<TableColumn<List<ObservableCellValue>, ?>> columns = getTableView().getColumns();
        final int col = columns.indexOf(getTableColumn());
        final int next = event.isShiftDown()
                       ? (col + columns.size() - 1) % columns.size()
                       : (col + 1) % columns.size();
        editCell(getIndex(), columns.get(next));
        event.consume();
    }
}
 
Example #21
Source File: TableScrollSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TableScrollSample() {
    final ObservableList<Person> data = FXCollections.observableArrayList(
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"));
    TableColumn firstNameCol = new TableColumn();
    firstNameCol.setText("First");
    firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
    TableColumn lastNameCol = new TableColumn();
    lastNameCol.setText("Last");
    lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
    TableColumn emailCol = new TableColumn();
    emailCol.setText("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory("email"));
    TableView tableView = new TableView();
    tableView.setItems(data);
    ObservableList items = tableView.getItems();
    for (int i = 0; i < 10; i++)
        items.add(new Person("Name" + i, "Last" + i, "Email " + i));
    tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
    getChildren().add(tableView);
}
 
Example #22
Source File: FormulaPane.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private TableView<InputItem> createInputs()
{
    TableColumn<InputItem, String> col = new TableColumn<>(Messages.FormulaTabInput);
    col.setCellValueFactory(c ->  c.getValue().input_name);
    input_table.getColumns().add(col);

    col = new TableColumn<>(Messages.FormulaTabVariable);
    col.setCellValueFactory(c ->  c.getValue().variable_name);
    col.setCellFactory(TextFieldTableCell.forTableColumn());
    // When variable is renamed, re-evaluate formula
    col.setOnEditCommit(event -> parseFormula());
    col.setEditable(true);
    input_table.getColumns().add(col);

    input_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    input_table.setTooltip(new Tooltip(Messages.FormulaTabTT));
    input_table.setEditable(true);
    // Double-click (on input column) adds that variable name to formula
    input_table.addEventHandler(MouseEvent.MOUSE_PRESSED, event ->
    {
        if (event.getClickCount() == 2)
            insert(input_table.getSelectionModel().getSelectedItem().variable_name.get());
    });

    return input_table;
}
 
Example #23
Source File: FailedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setVolumeColumnCellFactory() {
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<FailedTradesListItem, FailedTradesListItem> call(
                        TableColumn<FailedTradesListItem, FailedTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final FailedTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null)
                                setGraphic(new AutoTooltipLabel(model.getVolume(item)));
                            else
                                setGraphic(null);
                        }
                    };
                }
            });
}
 
Example #24
Source File: OpenOffersView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setVolumeColumnCellFactory() {
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<OpenOfferListItem, OpenOfferListItem> call(
                        TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final OpenOfferListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            getStyleClass().removeAll("offer-disabled");

                            if (item != null) {
                                if (model.isDeactivated(item)) getStyleClass().add("offer-disabled");
                                setGraphic(new AutoTooltipLabel(model.getVolume(item)));
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
}
 
Example #25
Source File: TableAutoCommitCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void commitEdit(final T valNew) {
    if (isEditing()) {
        super.commitEdit(valNew);
    } else {
        final TableView<S> tbl = getTableView();
        if (tbl != null) {
            final TablePosition<S, T> pos = new TablePosition<>(tbl, getTableRow().getIndex(), getTableColumn()); // instead of tbl.getEditingCell()
            final CellEditEvent<S, T> ev = new CellEditEvent<>(tbl, pos, TableColumn.editCommitEvent(), valNew);
            Event.fireEvent(getTableColumn(), ev);
        }
        updateItem(valNew, false);
        if (tbl != null) {
            tbl.edit(-1, null);
        }
        // TODO ControlUtils.requestFocusOnControlOnlyIfCurrentFocusOwnerIsChild(tbl);
    }
}
 
Example #26
Source File: TableController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
private void addCol() {
    TableColumn tc = new TableColumn();
    tc.setEditable(true);
    tc.setCellValueFactory(param -> {
        CellDataFeatures<ZRow, String> dtf = (CellDataFeatures<ZRow, String>) param;
        return new SimpleStringProperty(dtf.getValue().getRow().get(0));
    });

    tc.setCellFactory(TextFieldTableCell.forTableColumn());
    tc.setOnEditCommit(t -> {
        CellEditEvent<ZRow, String> evt = (CellEditEvent<ZRow, String>) t;
        List<String> row = evt.getTableView().getItems().get(evt.getTablePosition().getRow()).getRow();
        row.set(evt.getTablePosition().getColumn(), evt.getNewValue());
    });
    tc.setPrefWidth(150);
    TextField txf = new TextField();
    txf.setPrefWidth(150);
    txf.setPromptText(Configuration.getBundle().getString("ui.dialog.table_editor.colon") +
            (tableView.getColumns().size()+1));
    tc.setGraphic(txf);
    tableView.getColumns().addAll(tc);
    postAddColumn();
}
 
Example #27
Source File: FailedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setMarketColumnCellFactory() {
    marketColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    marketColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<FailedTradesListItem, FailedTradesListItem> call(
                        TableColumn<FailedTradesListItem, FailedTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final FailedTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            setGraphic(new AutoTooltipLabel(model.getMarketLabel(item)));
                        }
                    };
                }
            });
}
 
Example #28
Source File: RunPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
public ImportDefinition createDefinition() {

        RowFilter rf = rowFilter;
        if (filter == null || filter.isEmpty()) {
            rf = null;
        } else {
            rf.setColumns(currentColumnLabels);
        }

        final ImportDefinition definition = new ImportDefinition(1, rf);

        for (final TableColumn<TableRow, ?> column : sampleDataView.getColumns()) {
            final ImportTableColumn importTableColumn = (ImportTableColumn) column;
            final AttributeNode attributeNode = importTableColumn.getAttributeNode();
            if (attributeNode != null) {
                // We added an artificial column at the beginning of the table ("Row"),
                // so we need to subtract 1 to allow for that offset.
                final ImportAttributeDefinition attributeDefinition = new ImportAttributeDefinition(importTableColumn.getColumnIndex() - 1, attributeNode.getAttribute(), attributeNode.getTranslator(), attributeNode.getDefaultValue(), attributeNode.getTranslatorParameters());
                definition.addDefinition(attributeNode.getAttributeList().getAttributeType(), attributeDefinition);
            }
        }

        sourceVertexAttributeList.createDefinition(definition);
        destinationVertexAttributeList.createDefinition(definition);
        transactionAttributeList.createDefinition(definition);

        return definition;
    }
 
Example #29
Source File: FxSchema.java    From FxDock with Apache License 2.0 5 votes vote down vote up
private static void storeTableView(String prefix, TableView t)
{
	ObservableList<TableColumn<?,?>> cs = t.getColumns();
	int sz = cs.size();
	ObservableList<TableColumn<?,?>> sorted = t.getSortOrder();
	
	// columns: count,[id,width,sortOrder(0 for none, negative for descending, positive for ascending)
	SStream s = new SStream();
	s.add(sz);
	for(int i=0; i<sz; i++)
	{
		TableColumn<?,?> c = cs.get(i);
		
		int sortOrder = sorted.indexOf(c);
		if(sortOrder < 0)
		{
			sortOrder = 0;
		}
		else
		{
			sortOrder++;
			if(c.getSortType() == TableColumn.SortType.DESCENDING)
			{
				sortOrder = -sortOrder;
			}
		}
		
		s.add(c.getId());
		s.add(c.getWidth());
		s.add(sortOrder);
	}
	// FIX separate columns and width/sort
	GlobalSettings.setStream(prefix + SFX_COLUMNS, s);
	
	// selection
	int ix = t.getSelectionModel().getSelectedIndex();
	GlobalSettings.setInt(prefix + SFX_SELECTION, ix);
}
 
Example #30
Source File: StringTable.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Start 'edit' mode for a cell
 *  @param row
 *  @param table_column
 */
private void editCell(final int row, final TableColumn<List<ObservableCellValue>, ?> table_column)
{
    TIMER.schedule(() ->
        Platform.runLater(() ->
        {
            table.getSelectionModel().clearAndSelect(row, table_column);
            table.edit(row, table_column);
        }),
        100, TimeUnit.MILLISECONDS);
}