Skip to content
Permalink
Browse files
8270314: TreeTableCell: inconsistent naming for tableRow and tableCol…
…umn property methods

Reviewed-by: aghaisas, fastegal
  • Loading branch information
kevinrushforth committed Jul 20, 2021
1 parent 63c3bba commit 748f464a7ada4ef1ae6ea3e81bfd592904451f8e
Showing 14 changed files with 154 additions and 91 deletions.
@@ -66,7 +66,7 @@ public TableCellBehaviorBase(C control) {
protected abstract TableSelectionModel<S> getSelectionModel();
protected abstract TableFocusModel<S,TC> getFocusModel();
protected abstract TablePositionBase getFocusedCell();
protected abstract boolean isTableRowSelected(); // tableCell.getTreeTableRow().isSelected()
protected abstract boolean isTableRowSelected(); // tableCell.getTableRow().isSelected()

/**
* Returns the position of the given table column in the visible leaf columns
@@ -88,7 +88,7 @@ public TreeTableCellBehavior(TreeTableCell<S,T> control) {

/** @{@inheritDoc} */
@Override protected boolean isTableRowSelected() {
return getNode().getTreeTableRow().isSelected();
return getNode().getTableRow().isSelected();
}

/** @{@inheritDoc} */
@@ -111,15 +111,15 @@ public TreeTableCellBehavior(TreeTableCell<S,T> control) {
}

@Override protected boolean handleDisclosureNode(double x, double y) {
final TreeItem<S> treeItem = getNode().getTreeTableRow().getTreeItem();
final TreeItem<S> treeItem = getNode().getTableRow().getTreeItem();

final TreeTableView<S> treeTableView = getNode().getTreeTableView();
final TreeTableColumn<S,T> column = getTableColumn();
final TreeTableColumn<S,?> treeColumn = treeTableView.getTreeColumn() == null ?
treeTableView.getVisibleLeafColumn(0) : treeTableView.getTreeColumn();

if (column == treeColumn) {
final Node disclosureNode = getNode().getTreeTableRow().getDisclosureNode();
final Node disclosureNode = getNode().getTableRow().getDisclosureNode();
// fix JDK-8253597: check disclosure node for visibility along with existence
if (disclosureNode != null && disclosureNode.isVisible()) {
double startX = 0;
@@ -142,7 +142,7 @@ public TreeTableCellBehavior(TreeTableCell<S,T> control) {
@Override
protected void handleClicks(MouseButton button, int clickCount, boolean isAlreadySelected) {
// handle editing, which only occurs with the primary mouse button
TreeItem<S> treeItem = getNode().getTreeTableRow().getTreeItem();
TreeItem<S> treeItem = getNode().getTableRow().getTreeItem();
if (button == MouseButton.PRIMARY) {
if (clickCount == 1 && isAlreadySelected) {
edit(getNode());
@@ -200,22 +200,22 @@ public TreeTableCell() {

// --- TableColumn
/**
* The TreeTableColumn instance that backs this TreeTableCell.
* The {@code TreeTableColumn} instance that backs this {@code TreeTableCell}.
*/
private ReadOnlyObjectWrapper<TreeTableColumn<S,T>> treeTableColumn =
new ReadOnlyObjectWrapper<TreeTableColumn<S,T>>(this, "treeTableColumn") {
private ReadOnlyObjectWrapper<TreeTableColumn<S,T>> tableColumn =
new ReadOnlyObjectWrapper<TreeTableColumn<S,T>>(this, "tableColumn") {
@Override protected void invalidated() {
updateColumnIndex();
}
};
public final ReadOnlyObjectProperty<TreeTableColumn<S,T>> tableColumnProperty() { return treeTableColumn.getReadOnlyProperty(); }
private void setTableColumn(TreeTableColumn<S,T> value) { treeTableColumn.set(value); }
public final TreeTableColumn<S,T> getTableColumn() { return treeTableColumn.get(); }
public final ReadOnlyObjectProperty<TreeTableColumn<S,T>> tableColumnProperty() { return tableColumn.getReadOnlyProperty(); }
private void setTableColumn(TreeTableColumn<S,T> value) { tableColumn.set(value); }
public final TreeTableColumn<S,T> getTableColumn() { return tableColumn.get(); }


// --- TableView
/**
* The TreeTableView associated with this TreeTableCell.
* The {@code TreeTableView} associated with this {@code TreeTableCell}.
*/
private ReadOnlyObjectWrapper<TreeTableView<S>> treeTableView;
private void setTreeTableView(TreeTableView<S> value) {
@@ -284,14 +284,29 @@ private ReadOnlyObjectWrapper<TreeTableView<S>> treeTableViewPropertyImpl() {

// --- TableRow
/**
* The TreeTableRow that this TreeTableCell currently finds itself placed within.
* The {@code TreeTableRow} that this {@code TreeTableCell} currently finds itself placed within.
*/
private ReadOnlyObjectWrapper<TreeTableRow<S>> treeTableRow =
new ReadOnlyObjectWrapper<TreeTableRow<S>>(this, "treeTableRow");
private void setTreeTableRow(TreeTableRow<S> value) { treeTableRow.set(value); }
public final TreeTableRow<S> getTreeTableRow() { return treeTableRow.get(); }
public final ReadOnlyObjectProperty<TreeTableRow<S>> tableRowProperty() { return treeTableRow; }
private ReadOnlyObjectWrapper<TreeTableRow<S>> tableRow =
new ReadOnlyObjectWrapper<TreeTableRow<S>>(this, "tableRow");
private void setTableRow(TreeTableRow<S> value) { tableRow.set(value); }
/**
* Gets the value of the property {@code tableRow}.
* @return the value of the property {@code tableRow}
* @since 17
*/
public final TreeTableRow<S> getTableRow() { return tableRow.get(); }
public final ReadOnlyObjectProperty<TreeTableRow<S>> tableRowProperty() {
return tableRow.getReadOnlyProperty();
}

// The following method was misnamed and is deprecated in favor of the
// correctly named method.
/**
* @deprecated Use {@link getTableRow} instead.
* @return the {@code TreeTableRow}
*/
@Deprecated(since = "17")
public final TreeTableRow<S> getTreeTableRow() { return getTableRow(); }


/***************************************************************************
@@ -309,7 +324,7 @@ private ReadOnlyObjectWrapper<TreeTableView<S>> treeTableViewPropertyImpl() {

final TreeTableView<S> table = getTreeTableView();
final TreeTableColumn<S,T> column = getTableColumn();
final TreeTableRow<S> row = getTreeTableRow();
final TreeTableRow<S> row = getTableRow();
if (!isEditable() ||
(table != null && !table.isEditable()) ||
(column != null && !column.isEditable()) ||
@@ -427,7 +442,7 @@ private ReadOnlyObjectWrapper<TreeTableView<S>> treeTableViewPropertyImpl() {
// out, as it is valid for an empty TableCell to be selected, as long
// as the parent TableRow is not empty (see RT-15529).
/*if (selected && isEmpty()) return;*/
if (getTreeTableRow() == null || getTreeTableRow().isEmpty()) return;
if (getTableRow() == null || getTableRow().isEmpty()) return;
setSelected(selected);
}

@@ -620,7 +635,7 @@ private void updateItem(int oldIndex) {
final boolean isEmpty = isEmpty();
final T oldValue = getItem();

final TreeTableRow<S> tableRow = getTreeTableRow();
final TreeTableRow<S> tableRow = getTableRow();
final S rowItem = tableRow == null ? null : tableRow.getItem();

final boolean indexExceedsItemCount = index >= itemCount;
@@ -702,39 +717,42 @@ private void updateItem(int oldIndex) {
**************************************************************************/

/**
* Updates the TreeTableView associated with this TreeTableCell. This is typically
* only done once when the TreeTableCell is first added to the TreeTableView.
*
* Updates the {@code TreeTableView} associated with this {@code TreeTableCell}.
* This is typically only done once when the {@code TreeTableCell} is first
* added to the {@code TreeTableView}.
* <p>
* Note: This function is intended to be used by experts, primarily
* by those implementing new Skins. It is not common
* for developers or designers to access this function directly.
* @param tv the TreeTableView associated with this TreeTableCell
* @param tv the {@code TreeTableView} associated with this {@code TreeTableCell}
*/
public final void updateTreeTableView(TreeTableView<S> tv) {
setTreeTableView(tv);
}

/**
* Updates the TreeTableRow associated with this TreeTableCell.
*
* Updates the {@code TreeTableRow} associated with this {@code TreeTableCell}.
* <p>
* Note: This function is intended to be used by experts, primarily
* by those implementing new Skins. It is not common
* for developers or designers to access this function directly.
* @param treeTableRow the TreeTableRow associated with this TreeTableCell
* @param row the {@code TreeTableRow} associated with this {@code TreeTableCell}
* @since 17
*/
public final void updateTreeTableRow(TreeTableRow<S> treeTableRow) {
this.setTreeTableRow(treeTableRow);
public final void updateTableRow(TreeTableRow<S> row) {
this.setTableRow(row);
}

/**
* Updates the TreeTableColumn associated with this TreeTableCell.
*
* Updates the {@code TreeTableColumn} associated with this {@code TreeTableCell}.
* <p>
* Note: This function is intended to be used by experts, primarily
* by those implementing new Skins. It is not common
* for developers or designers to access this function directly.
* @param col the TreeTableColumn associated with this TreeTableCell
* @param column the {@code TreeTableColumn} associated with this {@code TreeTableCell}
* @since 17
*/
public final void updateTreeTableColumn(TreeTableColumn<S,T> col) {
public final void updateTableColumn(TreeTableColumn<S,T> column) {
// remove style class of existing tree table column, if it is non-null
TreeTableColumn<S,T> oldCol = getTableColumn();
if (oldCol != null) {
@@ -754,20 +772,39 @@ public final void updateTreeTableColumn(TreeTableColumn<S,T> col) {
}
}

setTableColumn(col);
setTableColumn(column);

if (col != null) {
getStyleClass().addAll(col.getStyleClass());
col.getStyleClass().addListener(weakColumnStyleClassListener);
if (column != null) {
getStyleClass().addAll(column.getStyleClass());
column.getStyleClass().addListener(weakColumnStyleClassListener);

col.idProperty().addListener(weakColumnIdListener);
col.styleProperty().addListener(weakColumnStyleListener);
column.idProperty().addListener(weakColumnIdListener);
column.styleProperty().addListener(weakColumnStyleListener);

possiblySetId(col.getId());
possiblySetStyle(col.getStyle());
possiblySetId(column.getId());
possiblySetStyle(column.getStyle());
}
}

// The following methods were misnamed and are deprecated in favor of the
// correctly named methods.
/**
* @deprecated Use {@link updateTableRow} instead.
* @param row the {@code TreeTableRow}
*/
@Deprecated(since = "17")
public final void updateTreeTableRow(TreeTableRow<S> row) {
updateTableRow(row);
}

/**
* @deprecated Use {@link updateTableColumn} instead.
* @param column the {@code TreeTableColumn}
*/
@Deprecated(since = "17")
public final void updateTreeTableColumn(TreeTableColumn<S,T> column) {
updateTableColumn(column);
}


/***************************************************************************
@@ -810,7 +847,7 @@ public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object...
switch (attribute) {
case ROW_INDEX: return getIndex();
case COLUMN_INDEX: return columnIndex;
case SELECTED: return isInCellSelectionMode() ? isSelected() : getTreeTableRow().isSelected();
case SELECTED: return isInCellSelectionMode() ? isSelected() : getTableRow().isSelected();
default: return super.queryAccessibleAttribute(attribute, parameters);
}
}
@@ -725,9 +725,9 @@ private <T,S> void resizeColumnToFitContent(TreeTableView<T> ttv, TreeTableColum
treeTableRow.updateIndex(row);
treeTableRow.updateTreeItem(ttv.getTreeItem(row));

cell.updateTreeTableColumn(tc);
cell.updateTableColumn(tc);
cell.updateTreeTableView(ttv);
cell.updateTreeTableRow(treeTableRow);
cell.updateTableRow(treeTableRow);
cell.updateIndex(row);

if ((cell.getText() != null && !cell.getText().isEmpty()) || cell.getGraphic() != null) {
@@ -128,7 +128,7 @@ public TreeTableCellSkin(TreeTableCell<S,T> control) {
return leftPadding;
}

TreeTableRow<S> treeTableRow = cell.getTreeTableRow();
TreeTableRow<S> treeTableRow = cell.getTableRow();
if (treeTableRow == null) return leftPadding;

TreeItem<S> treeItem = treeTableRow.getTreeItem();
@@ -265,7 +265,7 @@ public final DoubleProperty indentProperty() {
TreeTableColumn tableColumn = (TreeTableColumn<T,?>) tcb;
TreeTableCell cell = (TreeTableCell) tableColumn.getCellFactory().call(tableColumn);

cell.updateTreeTableColumn(tableColumn);
cell.updateTableColumn(tableColumn);
cell.updateTreeTableView(tableColumn.getTreeTableView());

return cell;
@@ -321,7 +321,7 @@ public final DoubleProperty indentProperty() {

/** {@inheritDoc} */
@Override protected void updateCell(TreeTableCell<T, ?> cell, TreeTableRow<T> row) {
cell.updateTreeTableRow(row);
cell.updateTableRow(row);
}

/** {@inheritDoc} */
@@ -92,7 +92,7 @@ public CellTest(Class type) {
} else if (cell instanceof TreeTableCell) {
TreeTableRow tableRow = new TreeTableRow();
CellShim.updateItem(tableRow, "TableRow", false);
((TreeTableCell)cell).updateTreeTableRow(tableRow);
((TreeTableCell)cell).updateTableRow(tableRow);
TreeTableCellShim.set_lockItemOnEdit((TreeTableCell)cell, true);
}
}
@@ -176,7 +176,7 @@ public void setup() {
editingColumn.setCellValueFactory(param -> null);
table.getColumns().add(editingColumn);
cell.updateTreeTableView(table);
cell.updateTreeTableColumn(editingColumn);
cell.updateTableColumn(editingColumn);
// make sure that focus change doesn't interfere with tests
// (editing cell loosing focus will be canceled from focusListener in Cell)
// Note: not really needed for Tree/TableCell because the cell is never focused

1 comment on commit 748f464

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 748f464 Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.