/******************************************************************************* * Copyright (c) 2013 BestSolution.at and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Tom Schindl - initial API and implementation *******************************************************************************/ package org.eclipse.fx.ui.databinding; import java.text.MessageFormat; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import org.eclipse.core.databinding.property.value.IValueProperty; import org.eclipse.jdt.annotation.NonNull; /** * Utility to setup a {@link TableView} with {@link TableColumn} */ public class TableUtil { /** * Setup a table column using the property for the cell text * * @param column * the column * @param property * the property * @param * row and cell type * @see PropertyTableCellFactory#textFactory(IValueProperty) */ public static void setupColumn(@NonNull TableColumn column, @NonNull IValueProperty property) { column.setCellValueFactory((param) -> new SimpleObjectProperty(param.getValue())); column.setCellFactory(PropertyTableCellFactory. textFactory(property)); } /** * Setup a table column using the properties and the template for the cell * text using {@link MessageFormat} * * @param column * the column * @param template * the template * @param property * the properties * @param * row and cell type * @see PropertyTableCellFactory#textFactory(String, IValueProperty...) */ public static void setupColumn(@NonNull TableColumn column, @NonNull String template, @NonNull IValueProperty... property) { column.setCellValueFactory((param) -> new SimpleObjectProperty(param.getValue())); column.setCellFactory(PropertyTableCellFactory. textFactory(template, property)); } }