/* * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.scene.control; import java.lang.ref.WeakReference; import javafx.beans.NamedArg; /** * This class is used to represent a single row/column/cell in a TreeTableView. * This is used throughout the TreeTableView API to represent which rows/columns/cells * are currently selected, focused, being edited, etc. Note that this class is * immutable once it is created. * *
Because the TreeTableView can have different
* {@link SelectionMode selection modes}, the row and column properties in
* TablePosition can be 'disabled' to represent an entire row or column. This is
* done by setting the unrequired property to -1 or null.
*
* @param The type of the {@link TreeItem} instances contained within the
* TreeTableView.
* @param extends TablePositionBase treeTableView, @NamedArg("row") int row, @NamedArg("tableColumn") TreeTableColumn tableColumn) {
super(row, tableColumn);
this.controlRef = new WeakReference<>(treeTableView);
this.treeItemRef = new WeakReference<>(treeTableView.getTreeItem(row));
}
/***************************************************************************
* *
* Instance Variables *
* *
**************************************************************************/
private final WeakReference tableView = getTreeTableView();
TreeTableColumn tableColumn = getTableColumn();
return tableView == null || tableColumn == null ? -1 :
tableView.getVisibleLeafIndex(tableColumn);
}
/**
* The TreeTableView that this TreeTablePosition is related to.
*/
public final TreeTableView getTreeTableView() {
return controlRef.get();
}
@Override public final TreeTableColumn getTableColumn() {
// Forcing the return type to be TreeTableColumn, not TableColumnBase
return super.getTableColumn();
}
/**
* Returns the {@link TreeItem} that backs the {@link #getRow()} row}.
*/
public final TreeItem getTreeItem() {
return treeItemRef.get();
}
}