this.columnIndex = columnIndex;
// Get the row data, represented as a Dictionary
Object tableRow = tableView.getTableData().get(rowIndex);
Dictionary<String, Object> rowData;
BeanAdapter beanAdapter = null;
if (tableRow instanceof Dictionary<?, ?>) {
rowData = (Dictionary<String, Object>)tableRow;
} else {
beanAdapter = new BeanAdapter(tableRow);
rowData = beanAdapter;
}
// Set up the editor component hierarchy
scrollPane = new ScrollPane(ScrollPane.ScrollBarPolicy.NEVER,
ScrollPane.ScrollBarPolicy.FILL);
setContent(scrollPane);
cardPane = new CardPane();
scrollPane.setView(cardPane);
cardPane.add(new ImageView(new ComponentImage(tableView,
tableView.getRowBounds(rowIndex))));
cardPane.setSelectedIndex(0);
cardPane.getStyles().put("selectionChangeEffect", editEffect);
cardPane.getStyles().put("selectionChangeDuration", editEffectDuration);
tablePane = new TablePane();
tablePane.getStyles().put("horizontalSpacing", 1);
cardPane.add(tablePane);
TablePane.Row tablePaneRow = new TablePane.Row(1, true);
tablePane.getRows().add(tablePaneRow);
// Match the table pane's columns to the table view's
TableView.ColumnSequence tableViewColumns = tableView.getColumns();
TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns();
for (int i = 0, n = tableViewColumns.getLength(); i < n; i++) {
// Add a new column to the table pane to match the table view column
TablePane.Column tablePaneColumn = new TablePane.Column();
tablePaneColumns.add(tablePaneColumn);
// Determine which component to use as the editor for this column
String columnName = tableViewColumns.get(i).getName();
Component editorComponent = null;
if (columnName != null) {
editorComponent = cellEditors.get(columnName);
}
// Default to a TextInput editor
if (editorComponent == null) {
TextInput editorTextInput = new TextInput();
editorTextInput.setTextKey(columnName);
editorComponent = editorTextInput;
// Disable the text input for read-only properties
if (beanAdapter != null
&& beanAdapter.isReadOnly(columnName)) {
editorTextInput.setTextBindType(BindType.LOAD);
editorTextInput.setEnabled(false);
}
}