本文整理汇总了Java中javafx.scene.control.TreeTableColumn.setCellValueFactory方法的典型用法代码示例。如果您正苦于以下问题:Java TreeTableColumn.setCellValueFactory方法的具体用法?Java TreeTableColumn.setCellValueFactory怎么用?Java TreeTableColumn.setCellValueFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TreeTableColumn
的用法示例。
在下文中一共展示了TreeTableColumn.setCellValueFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupGroupView
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
private void setupGroupView() {
groupList = new JFXTreeTableView<>();
TreeTableColumn<GroupTreeObject, String> nameColumn = new JFXTreeTableColumn<>("Name");
nameColumn.setPrefWidth(150);
nameColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<GroupTreeObject, String> param) -> {
Group group = fromItem(param.getValue());
if (group == null) {
return new SimpleStringProperty();
}
return new SimpleStringProperty(group.getDisplayName());
});
groupList.getColumns().add(nameColumn);
TreeItem treeItem = new TreeItem<>();
treeItem.setExpanded(true);
groupList.setRoot(treeItem);
groupList.setShowRoot(false);
groupList.setPrefHeight(Short.MAX_VALUE);
}
示例2: getTestContainer
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
@Override
protected Node getTestContainer() {
treeOrTreeTableView = new TreeTableView<Data>();
treeOrTreeTableView.setMinSize(300, 500);
treeOrTreeTableView.setMaxSize(300, 500);
treeOrTreeTableView.setPrefSize(300, 500);
TreeTableColumn<Data, Node> column = new TreeTableColumn<Data, Node>("Items' name");
column.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Data, Node>, ObservableValue<Node>>() {
@Override
public ObservableValue<Node> call(final TreeTableColumn.CellDataFeatures<Data, Node> p) {
SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
text.setValue(new Label(p.getValue().getValue().getData()));
return text;
}
});
column.setPrefWidth(150);
((TreeTableView) treeOrTreeTableView).getColumns().add(column);
reset(0);
return treeOrTreeTableView;
}
示例3: testCollapsedNodeGraphicVisible
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
/**
* 8158784: [TEST BUG] Need test for JDK-8157398
*/
@Test
public void testCollapsedNodeGraphicVisible() throws Exception {
Color nodeColor = new Color(Math.random(), Math.random(), Math.random(), 1);
TreeTableView treeTable = (TreeTableView) testedControl.getControl();
TreeItem<String> root = new TreeItem<>("Root Node");
TreeItem<String> child = new TreeItem<>("Child", new Rectangle(10, 10, nodeColor));
TreeTableColumn<String, String> column = new TreeTableColumn<>("Column");
column.setCellValueFactory(item -> new SimpleStringProperty("Whatever"));
treeTable.getColumns().setAll(column);
root.getChildren().add(child);
root.setExpanded(true);
treeTable.setShowRoot(true);
runAndWait(() -> {
treeTable.setRoot(root);
});
Wrap nodeGraphic = parent.lookup(node -> node == child.getGraphic()).wrap();
Wrap sceneWrap = Root.ROOT.lookup().wrap();
waitForColor(nodeGraphic, 1, 1, nodeColor);
Bounds graphicBounds = child.getGraphic().localToScene(child.getGraphic().getBoundsInLocal());
root.setExpanded(false);
waitForColor(sceneWrap,
(int) (graphicBounds.getMinX() + graphicBounds.getWidth() / 2),
(int) (graphicBounds.getMinY() + graphicBounds.getHeight() / 2), Color.WHITE);
}
示例4: addColumnString
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
protected void addColumnString (String heading, int width, Justification justification,
String propertyName)
{
TreeTableColumn<T, String> column = new TreeTableColumn<> (heading);
column.setPrefWidth (width);
column
.setCellValueFactory (new TreeItemPropertyValueFactory<T, String> (propertyName));
getColumns ().add (column);
if (justification == Justification.CENTER)
column.setStyle ("-fx-alignment: CENTER;");
}
示例5: addColumnNumber
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
protected void addColumnNumber (String heading, int width, String propertyName)
{
TreeTableColumn<T, Number> column = new TreeTableColumn<> (heading);
column.setPrefWidth (width);
column
.setCellValueFactory (new TreeItemPropertyValueFactory<T, Number> (propertyName));
getColumns ().add (column);
column.setStyle ("-fx-alignment: CENTER-RIGHT;");
}
示例6: createDescriptionColumn
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
/**
* Method to create a column in the table.
* @param parent the {@link TreeTableView} parent to add the column to.
* @param columnName the name of the column.
* @param columnReference the index of the column in the table.
* @param columnWidth the width of the column.
*/
private void createDescriptionColumn( TreeTableView< TestTableItem > parent, String columnName, int columnReference, int columnWidth ) {
TreeTableColumn< TestTableItem, String > descriptionColumn = new TreeTableColumn<>( columnName );
descriptionColumn.setPrefWidth( columnWidth );
descriptionColumn.setEditable( false );
descriptionColumn.setCellValueFactory( object -> object.getValue().getValue().getColumnProperty( columnReference ) );
parent.getColumns().add( descriptionColumn );
}
示例7: insertColumn
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
/**
* Method to insert a single column into the tree.
* @param nodeRetriever the {@link Function} for supplying the {@link Node} to draw.
* @param width the preferred width of the column.
*/
protected final void insertColumn( Function< TreeItemValueT, ObjectProperty< Node > > nodeRetriever ){
TreeTableColumn< TreeItemValueT, Node > iconColumn = new TreeTableColumn<>();
iconColumn.setCellValueFactory( object -> {
if ( object.getValue().getValue() == null ) {
return null;
}
return nodeRetriever.apply( object.getValue().getValue() );
} );
getColumns().add( iconColumn );
}
示例8: ObjectTreeBrowser
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
public ObjectTreeBrowser() {
TreeTableColumn<Object, String> colName = new TreeTableColumn<>();
colName.setCellValueFactory(c -> ((ObjectTreeItem)c.getValue()).observableName);
TreeTableColumn<Object, String> colValue = new TreeTableColumn<>();
colValue.setCellValueFactory(c -> ((ObjectTreeItem)c.getValue()).observableValue);
treeTable.getColumns().add(colName);
treeTable.getColumns().add(colValue);
treeTable.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
treeTable.setEditable(false);
// Enable manual refreshing
ContextMenu menu = new ContextMenu();
MenuItem miRefresh = new MenuItem("Refresh");
miRefresh.setOnAction(e -> {
for (int i = 0; i < treeTable.getExpandedItemCount(); i++) {
TreeItem<Object> item = treeTable.getTreeItem(i);
if (item instanceof ObjectTreeItem)
((ObjectTreeItem)item).invalidate();
}
treeTable.refresh();
});
menu.getItems().add(miRefresh);
treeTable.setContextMenu(menu);
pane.setCenter(treeTable);
}
示例9: getTreeTableViewTab
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
/**
* Returns a <code>Tab</code> containing a <code>TreeTableView</code> displaying the with the given
* <code>root</code>.
*
* @param root
* the root of the tree to display
* @return a <code>Tab</code> containing the tree
*/
static Tab getTreeTableViewTab(TreeItem<TreeDumpNode> root) {
TreeTableView<TreeDumpNode> tableView = new TreeTableView<>(root);
TreeTableColumn<TreeDumpNode, String> id = new TreeTableColumn<>("ID");
TreeTableColumn<TreeDumpNode, String> label = new TreeTableColumn<>("AST Type");
tableView.setRowFactory(param -> {
TreeTableRow<TreeDumpNode> row = new TreeTableRow<>();
TreeDumpNode node = row.getItem();
if (node == null) {
return row;
}
String color = node.getFillColor();
if (color != null) {
try {
BackgroundFill fill = new BackgroundFill(Color.valueOf(color), CornerRadii.EMPTY, Insets.EMPTY);
row.setBackground(new Background(fill));
} catch (IllegalArgumentException e) {
LOG.fine(() -> String.format("Could not convert '%s' to a JavaFX Color.", color));
}
}
return row;
});
id.setCellValueFactory(param -> param.getValue().getValue().idProperty());
label.setCellValueFactory(param -> param.getValue().getValue().labelProperty());
tableView.getColumns().setAll(Arrays.asList(label, id));
return new Tab("Tree View", tableView);
}
示例10: buildSimpleLongValueColumn
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
private static TreeTableColumn<TorrentFileEntry, Long> buildSimpleLongValueColumn(
final String columnName, final String propertyName, final String style, final Insets padding,
final Function<TorrentFileEntry, String> valueGetter) {
final TreeTableColumn<TorrentFileEntry, Long> longValueColumn = new TreeTableColumn<TorrentFileEntry, Long>(columnName);
longValueColumn.setId(columnName);
longValueColumn.setGraphic(TableUtils.buildColumnHeader(longValueColumn, style));
longValueColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
longValueColumn.setCellFactory(column -> new TreeTableCell<TorrentFileEntry, Long>() {
final Label valueLabel = new Label();
@Override
protected final void updateItem(final Long value, final boolean empty) {
super.updateItem(value, empty);
if(empty) {
setText(null);
setGraphic(null);
}
else {
final TorrentFileEntry fileContent = this.getTreeTableRow().getItem();
if(fileContent == null) {
return;
}
final String formattedValue = valueGetter.apply(fileContent);
valueLabel.setText(formattedValue);
this.setGraphic(valueLabel);
this.setAlignment(Pos.CENTER_RIGHT);
super.setPadding(padding);
}
}
});
return longValueColumn;
}
示例11: buildPriorityColumn
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
private static TreeTableColumn<TorrentFileEntry, FilePriority> buildPriorityColumn() {
final TreeTableColumn<TorrentFileEntry, FilePriority> priorityColumn =
new TreeTableColumn<>(PRIORITY_COLUMN_NAME);
priorityColumn.setId(PRIORITY_COLUMN_NAME);
priorityColumn.setGraphic(TableUtils.buildColumnHeader(priorityColumn, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME));
priorityColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("priority"));
priorityColumn.setCellFactory(column -> new TreeTableCell<TorrentFileEntry, FilePriority>() {
final Label valueLabel = new Label();
@Override
protected final void updateItem(final FilePriority value, final boolean empty) {
super.updateItem(value, empty);
if(empty) {
setText(null);
setGraphic(null);
}
else {
final TorrentFileEntry fileContent = this.getTreeTableRow().getItem();
if(fileContent == null) {
return;
}
valueLabel.setText(fileContent.getPriority().toString());
this.setGraphic(valueLabel);
this.setAlignment(Pos.BASELINE_LEFT);
super.setPadding(GuiUtils.leftPadding());
}
}
});
return priorityColumn;
}
示例12: buildPathColumn
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
private static TreeTableColumn<TorrentFileEntry, String> buildPathColumn() {
final TreeTableColumn<TorrentFileEntry, String> pathColumn =
new TreeTableColumn<TorrentFileEntry, String>(PATH_COLUMN_NAME);
pathColumn.setId(PATH_COLUMN_NAME);
pathColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("path"));
pathColumn.setGraphic(TableUtils.buildColumnHeader(pathColumn, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME));
return pathColumn;
}
示例13: buildProgressColumn
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
private static TreeTableColumn<TorrentFileEntry, Double> buildProgressColumn(
final TreeTableView<TorrentFileEntry> treeTableView) {
final TreeTableColumn<TorrentFileEntry, Double> progressColumn =
new TreeTableColumn<TorrentFileEntry, Double>(PROGRESS_COLUMN_NAME);
progressColumn.setId(PROGRESS_COLUMN_NAME);
progressColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("progress"));
progressColumn.setGraphic(TableUtils.buildColumnHeader(progressColumn, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME));
progressColumn.setCellFactory(column -> new ProgressBarTreeTableCell<TorrentFileEntry>() {
@Override
public final void updateItem(final Double value, final boolean empty) {
super.updateItem(value, empty);
if(empty) {
super.setText(null);
super.setGraphic(null);
}
else {
final TorrentFileEntry fileContent = this.getTreeTableRow().getItem();
if(fileContent == null) {
return;
}
super.addEventFilter(MouseEvent.MOUSE_CLICKED, evt ->
treeTableView.getSelectionModel().select(super.getTreeTableRow().getIndex()));
super.getStyleClass().add(CssProperties.PROGRESSBAR_STOPPED);
super.setItem(fileContent.progressProperty().doubleValue());
super.setPadding(GuiUtils.noPadding());
}
}
});
return progressColumn;
}
示例14: render
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
public void render() {
if (_ttv == null) {
_ttv = new TreeTableView<FormItem<?>>(
new FormTreeItem(this, null, _rootItem));
_ttv.getRoot().setExpanded(true);
_ttv.setShowRoot(false);
TreeTableColumn<FormItem<?>, String> nameColumn = new TreeTableColumn<FormItem<?>, String>(
"Name");
nameColumn.setPrefWidth(250);
nameColumn.setCellValueFactory(param -> {
String displayName = param.getValue().getValue().displayName();
return new ReadOnlyStringWrapper(displayName);
});
nameColumn.setStyle("-fx-font-weight: bold;");
TreeTableColumn<FormItem<?>, FormItem<?>> valueColumn = new TreeTableColumn<FormItem<?>, FormItem<?>>(
"Value");
valueColumn.setPrefWidth(500);
valueColumn.setCellValueFactory(param -> {
return param.getValue().valueProperty();
});
valueColumn.setCellFactory(column -> {
return new FormTreeTableCell();
});
_ttv.getColumns().add(nameColumn);
_ttv.getColumns().add(valueColumn);
_stackPane.getChildren().setAll(_ttv);
FormTreeItem rootTreeItem = (FormTreeItem) _ttv.getRoot();
ObservableList<FormItem<?>> items = _rootItem.getItems();
if (items != null) {
for (FormItem<?> item : items) {
addTreeItem(rootTreeItem, item);
}
}
}
}
示例15: buildComponentCellColumn
import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
private TreeTableColumn<RefexDynamicGUI, RefexDynamicGUI> buildComponentCellColumn(DynamicRefexColumnType type)
{
TreeTableColumn<RefexDynamicGUI, RefexDynamicGUI> ttCol = new TreeTableColumn<>(type.toString());
HeaderNode<String> headerNode = new HeaderNode<>(
filterCache_,
ttCol,
ColumnId.getInstance(type),
rootNode_.getScene(),
new HeaderNode.DataProvider<String>() {
@Override
public String getData(RefexDynamicGUI source) {
return source.getDisplayStrings(type, null).getKey();
}
});
ttCol.setGraphic(headerNode.getNode());
ttCol.setSortable(true);
ttCol.setResizable(true);
ttCol.setComparator(new Comparator<RefexDynamicGUI>()
{
@Override
public int compare(RefexDynamicGUI o1, RefexDynamicGUI o2)
{
return o1.compareTo(type, null, o2);
}
});
ttCol.setCellFactory((colInfo) -> {return new ComponentDataCell(type);});
ttCol.setCellValueFactory((callback) -> {return new ReadOnlyObjectWrapper<RefexDynamicGUI>(callback.getValue().getValue());});
return ttCol;
}