/* * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ 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) {
this(treeTableView, row, tableColumn, true);
}
// Not public API
TreeTablePosition(@NamedArg("treeTableView") TreeTableView treeTableView, @NamedArg("row") int row, @NamedArg("tableColumn") TreeTableColumn tableColumn, boolean doLookup) {
super(row, tableColumn);
this.controlRef = new WeakReference<>(treeTableView);
this.treeItemRef = new WeakReference<>(doLookup ? treeTableView.getTreeItem(row) : null);
nonFixedColumnIndex = treeTableView == null || tableColumn == null ? -1 : treeTableView.getVisibleLeafIndex(tableColumn);
}
/***************************************************************************
* *
* Instance Variables *
* *
**************************************************************************/
private final WeakReference 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}.
* @return the {@link TreeItem} that backs the {@link #getRow()} row}
*/
public final TreeItem getTreeItem() {
return treeItemRef.get();
}
}