Java Code Examples for javafx.scene.control.TreeTableColumn#setCellFactory()
The following examples show how to use
javafx.scene.control.TreeTableColumn#setCellFactory() .
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: NumberRangeType.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override @Nonnull public List<TreeTableColumn<ModularFeatureListRow, Object>> createSubColumns( @Nullable RawDataFile raw) { List<TreeTableColumn<ModularFeatureListRow, Object>> cols = new ArrayList<>(); // create column per name TreeTableColumn<ModularFeatureListRow, Object> min = new TreeTableColumn<>("min"); DataTypeCellValueFactory cvFactoryMin = new DataTypeCellValueFactory(raw, this); min.setCellValueFactory(cvFactoryMin); min.setCellFactory(new DataTypeCellFactory(raw, this, 0)); TreeTableColumn<ModularFeatureListRow, Object> max = new TreeTableColumn<>("max"); DataTypeCellValueFactory cvFactoryMax = new DataTypeCellValueFactory(raw, this); max.setCellValueFactory(cvFactoryMax); max.setCellFactory(new DataTypeCellFactory(raw, this, 1)); // add all cols.add(min); cols.add(max); return cols; }
Example 2
Source File: FeaturesType.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override @Nonnull public List<TreeTableColumn<ModularFeatureListRow, Object>> createSubColumns( final @Nullable RawDataFile raw) { List<TreeTableColumn<ModularFeatureListRow, Object>> cols = new ArrayList<>(); // create bar chart TreeTableColumn<ModularFeatureListRow, Object> barsCol = new TreeTableColumn<>("Area Bars"); barsCol.setCellValueFactory(new DataTypeCellValueFactory(null, this)); barsCol.setCellFactory(new DataTypeCellFactory(null, this, cols.size())); cols.add(barsCol); TreeTableColumn<ModularFeatureListRow, Object> sharesCol = new TreeTableColumn<>("Area Share"); sharesCol.setCellValueFactory(new DataTypeCellValueFactory(null, this)); sharesCol.setCellFactory(new DataTypeCellFactory(null, this, cols.size())); cols.add(sharesCol); TreeTableColumn<ModularFeatureListRow, Object> shapes = new TreeTableColumn<>("Shapes"); shapes.setCellValueFactory(new DataTypeCellValueFactory(null, this)); shapes.setCellFactory(new DataTypeCellFactory(null, this, cols.size())); cols.add(shapes); /* * sample columns are created in the FeatureListFX class */ return cols; }
Example 3
Source File: DataType.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Creates a TreeTableColumn or null if the value is not represented in a column. A * {@link SubColumnsFactory} DataType can also add multiple sub columns to the main column * generated by this class. * * @param raw null if this is a FeatureListRow column. For Feature columns: the raw data file * specifies the feature. * * @return the TreeTableColumn or null if this DataType.value is not represented in a column */ @Nullable public TreeTableColumn<ModularFeatureListRow, Object> createColumn( final @Nullable RawDataFile raw) { if (this instanceof NullColumnType) return null; // create column TreeTableColumn<ModularFeatureListRow, Object> col = new TreeTableColumn<>(getHeaderString()); if (this instanceof SubColumnsFactory) { col.setSortable(false); // add sub columns (no value factory needed for parent column) List<TreeTableColumn<ModularFeatureListRow, ?>> children = ((SubColumnsFactory) this).createSubColumns(raw); col.getColumns().addAll(children); return col; } else { col.setSortable(true); // define observable DataTypeCellValueFactory cvFactory = new DataTypeCellValueFactory(raw, this); col.setCellValueFactory(cvFactory); // value representation if (this instanceof EditableColumnType) { col.setCellFactory(new EditableDataTypeCellFactory(raw, this)); col.setEditable(true); col.setOnEditCommit(event -> { Object data = event.getNewValue(); if (data != null) { if (raw == null) event.getRowValue().getValue().set(this, data); else event.getRowValue().getValue().getFeatures().get(raw).set(this, data); } }); } else col.setCellFactory(new DataTypeCellFactory(raw, this)); } return col; }
Example 4
Source File: CDecimalField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, LockableBigDecimal> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn< ObjectDataElt, LockableBigDecimal> thiscolumn = new TreeTableColumn<ObjectDataElt, LockableBigDecimal>( this.getLabel()); thiscolumn.setEditable(true); thiscolumn.setStyle("-fx-alignment: CENTER-RIGHT;"); int length = 110; thiscolumn.setMinWidth(length); CDecimalField thisdecimalfield = this; BigDecimalFormatValidator validator = new BigDecimalFormatValidator(precision, scale); // big display disabled as hardcoded thiscolumn.setCellFactory(column -> { return new LargeTextTreeTableCell<ObjectDataElt, LockableBigDecimal>( new NiceLockableBigDecimalStringConverter(precision, scale), validator, this.decimalformatter, false, true,1) { @Override public void updateItem(LockableBigDecimal decimal, boolean empty) { logger.fine("Updating field for decimal = " + decimal + " empty = " + empty); super.updateItem(decimal, empty); super.setMaxHeight(12); super.setPrefHeight(12); super.setMinHeight(12); if (decimal != null) { if (decimal.isLocked()) { logger.fine("set to lock"); super.setEditable(false); } else { logger.fine("set to unlock"); super.setEditable(true); } } } }; }); thiscolumn.setCellValueFactory(new Callback< TreeTableColumn.CellDataFeatures<ObjectDataElt, LockableBigDecimal>, ObservableValue<LockableBigDecimal>>() { @Override public ObservableValue<LockableBigDecimal> call( TreeTableColumn.CellDataFeatures<ObjectDataElt, LockableBigDecimal> p) { SimpleDataElt lineelement = p.getValue().getValue().lookupEltByName(thisdecimalfield.getFieldname()); if (lineelement == null) return new SimpleObjectProperty<LockableBigDecimal>(null); if (!(lineelement instanceof DecimalDataElt)) return new SimpleObjectProperty<LockableBigDecimal>(null); DecimalDataElt linedataelt = (DecimalDataElt) lineelement; boolean locked = true; logger.finest(" *-*-*-* processing DecimalDataElt " + Integer.toHexString(linedataelt.hashCode()) + " locked = " + linedataelt.islocked() + ", payload = " + linedataelt.getPayload() + " name = " + linedataelt.getName()); return new SimpleObjectProperty<LockableBigDecimal>( new LockableBigDecimal(locked, linedataelt.getPayload())); } }); return thiscolumn; }
Example 5
Source File: CDateField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, Date> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, Date> thiscolumn = new TreeTableColumn<ObjectDataElt, Date>(this.getLabel()); thiscolumn.setEditable(true); int length = 110; thiscolumn.setMinWidth(length); thiscolumn.setCellFactory(column -> { return new TreeTableCell<ObjectDataElt, Date>() { @Override protected void updateItem(Date date, boolean empty) { super.updateItem(date, empty); if (date == null || empty) { setText(null); } else { setText(dateformat.format(date)); this.setTooltip(new Tooltip(fulldateformat.format(date))); } } }; }); CDateField thisdatefield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, Date>, ObservableValue<Date>>() { @Override public ObservableValue<Date> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, Date> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thisdatefield.getFieldname(); if (line == null) return new SimpleObjectProperty<Date>(null); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) return new SimpleObjectProperty<Date>(null); if (!(lineelement instanceof DateDataElt)) return new SimpleObjectProperty<Date>(null); DateDataElt linedataelt = (DateDataElt) lineelement; return new SimpleObjectProperty<Date>(linedataelt.getPayload()); } }); return thiscolumn; }
Example 6
Source File: FileBrowserController.java From phoebus with Eclipse Public License 1.0 | 4 votes |
@FXML public void initialize() { treeView.setShowRoot(false); treeView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); // Create table columns final TreeTableColumn<FileInfo, File> name_col = new TreeTableColumn<>(Messages.ColName); name_col.setPrefWidth(200); name_col.setCellValueFactory(p -> new ReadOnlyObjectWrapper<>(p.getValue().getValue().file)); name_col.setCellFactory(info -> new FileTreeCell()); name_col.setComparator(FileTreeItem.fileTreeItemComparator); treeView.getColumns().add(name_col); // Linux (Gnome) and Mac file browsers list size before time final TreeTableColumn<FileInfo, Number> size_col = new TreeTableColumn<>(Messages.ColSize); size_col.setCellValueFactory(p -> p.getValue().getValue().size); size_col.setCellFactory(info -> new FileSizeCell()); treeView.getColumns().add(size_col); final TreeTableColumn<FileInfo, String> time_col = new TreeTableColumn<>(Messages.ColTime); time_col.setCellValueFactory(p -> p.getValue().getValue().time); treeView.getColumns().add(time_col); // This would cause columns to fill table width, // but _always_ does that, not allowing us to restore // saved widths from memento: // treeView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY); // Last column fills remaining space final InvalidationListener resize = prop -> { // Available with, less space used for the TableMenuButton '+' on the right // so that the up/down column sort markers remain visible double available = treeView.getWidth() - 10; if (name_col.isVisible()) { // Only name visible? Use the space! if (!size_col.isVisible() && !time_col.isVisible()) name_col.setPrefWidth(available); else available -= name_col.getWidth(); } if (size_col.isVisible()) { if (! time_col.isVisible()) size_col.setPrefWidth(available); else available -= size_col.getWidth(); } if (time_col.isVisible()) time_col.setPrefWidth(available); }; treeView.widthProperty().addListener(resize); name_col.widthProperty().addListener(resize); size_col.widthProperty().addListener(resize); name_col.visibleProperty().addListener(resize); size_col.visibleProperty().addListener(resize); time_col.visibleProperty().addListener(resize); // Allow users to show/hide columns treeView.setTableMenuButtonVisible(true); // Prepare ContextMenu items open.setOnAction(event -> openSelectedResources()); contextMenu.getItems().addAll(open, openWith); treeView.setOnKeyPressed(this::handleKeys); }
Example 7
Source File: FxTreeTable.java From FxDock with Apache License 2.0 | 4 votes |
public void setCellFactory(FxTreeTableCellFactory<T> f) { TreeTableColumn c = lastColumn(); c.setCellFactory(f); }