本文整理汇总了Java中javafx.scene.control.TreeTableRow.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java TreeTableRow.getIndex方法的具体用法?Java TreeTableRow.getIndex怎么用?Java TreeTableRow.getIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TreeTableRow
的用法示例。
在下文中一共展示了TreeTableRow.getIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoint
import javafx.scene.control.TreeTableRow; //导入方法依赖的package包/类
protected Point2D getPoint(TreeTableView<?> treeTableView, int rowIndex, int columnIndex) {
Set<Node> treeTableRowCell = treeTableView.lookupAll(".tree-table-row-cell");
TreeTableRow<?> row = null;
for (Node tableRow : treeTableRowCell) {
TreeTableRow<?> r = (TreeTableRow<?>) tableRow;
if (r.getIndex() == rowIndex) {
row = r;
break;
}
}
Set<Node> cells = row.lookupAll(".tree-table-cell");
for (Node node : cells) {
TreeTableCell<?, ?> cell = (TreeTableCell<?, ?>) node;
if (treeTableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
Bounds bounds = cell.getBoundsInParent();
Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
Point2D rowLocal = row.localToScene(localToParent, true);
return rowLocal;
}
}
return null;
}
示例2: acceptable
import javafx.scene.control.TreeTableRow; //导入方法依赖的package包/类
private boolean acceptable(final Dragboard db, final TreeTableRow<GPXLineItem> row) {
boolean result = false;
if (db.hasContent(SERIALIZED_MIME_TYPE)) {
final int index = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
//System.out.println("index: " + index + ", row index:" + row.getIndex());
if (!row.isEmpty() && (row.getIndex() != index)) {
final TreeItem<GPXLineItem> target = row.getTreeItem();
final GPXLineItem.GPXLineItemType targetType = target.getValue().getType();
final TreeItem<GPXLineItem> item = myTreeTableView.getTreeItem(index);
final GPXLineItem.GPXLineItemType itemType = item.getValue().getType();
// don't create loops and only insert on same level or drop on direct parent type
result = !isParent(item, target) &&
(GPXLineItem.GPXLineItemType.isSameTypeAs(targetType, itemType) || GPXLineItem.GPXLineItemType.isParentTypeOf(targetType, itemType));
}
}
return result;
}
示例3: getVisibleCellAt
import javafx.scene.control.TreeTableRow; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes") public TreeTableCell getVisibleCellAt(TreeTableView<?> treeTableView, int row, int column) {
Set<Node> lookupAll = getTreeTableCells(treeTableView);
TreeTableCell cell = null;
for (Node node : lookupAll) {
TreeTableCell<?, ?> cell1 = (TreeTableCell<?, ?>) node;
TreeTableRow<?> tableRow = cell1.getTreeTableRow();
TreeTableColumn<?, ?> tableColumn = cell1.getTableColumn();
if (tableRow.getIndex() == row && tableColumn == treeTableView.getColumns().get(column)) {
cell = cell1;
break;
}
}
return cell;
}
示例4: isAcceptable
import javafx.scene.control.TreeTableRow; //导入方法依赖的package包/类
protected boolean isAcceptable(Dragboard db, TreeTableRow<T> row)
{
if(db.hasContent(JAVA_DATA_FORMAT))
{
int index = (Integer)db.getContent(JAVA_DATA_FORMAT);
if(row.getIndex() != index)
{
TreeItem target = getTarget(row);
TreeItem item = tree.getTreeItem(index);
return !isParent(item, target);
}
}
return false;
}
示例5: dragOver
import javafx.scene.control.TreeTableRow; //导入方法依赖的package包/类
public void dragOver(DragEvent event, TreeTableRow row) {
Dragboard dragboard = event.getDragboard();
if (dragboard.hasContent(SERIALIZED_MIME_TYPE)) {
if (row.getIndex() != (Integer) dragboard.getContent(SERIALIZED_MIME_TYPE)) {
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
event.consume();
}
}
}
示例6: onDragDropped
import javafx.scene.control.TreeTableRow; //导入方法依赖的package包/类
private void onDragDropped(final TreeTableRow<GPXLineItem> row, final DragEvent event) {
Dragboard db = event.getDragboard();
if (db.getContent(SERIALIZED_MIME_TYPE) != null) {
if (acceptable(db, row)) {
// get dragged item and item drop on to
final int draggedIndex = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
final int targetIndex = row.getIndex();
final TreeItem<GPXLineItem> draggedItem = myTreeTableView.getTreeItem(draggedIndex);
final TreeItem<GPXLineItem> targetItem = myTreeTableView.getTreeItem(targetIndex);
final GPXLineItem draggedLineItem = draggedItem.getValue();
final GPXLineItem targetLineItem = targetItem.getValue();
final GPXLineItem.GPXLineItemType draggedType = draggedLineItem.getType();
final GPXLineItem.GPXLineItemType targetType = targetLineItem.getType();
draggedItem.getParent().getChildren().remove(draggedItem);
final List<GPXLineItem> draggedList = draggedLineItem.getParent().getChildren();
draggedList.remove(draggedLineItem);
draggedLineItem.getParent().setChildren(draggedList);
List<GPXLineItem> targetList;
if (GPXLineItem.GPXLineItemType.isSameTypeAs(targetType, draggedType)) {
// index of dropped item under its parent - thats where we want to place the dragged item before
final int childIndex = targetItem.getParent().getChildren().indexOf(targetItem);
targetItem.getParent().getChildren().add(childIndex, draggedItem);
// update GPXLineItem as well
targetList = targetLineItem.getParent().getChildren();
targetList.add(childIndex, draggedLineItem);
targetLineItem.getParent().setChildren(targetList);
} else {
// droppped on parent type - always add in front
targetItem.getChildren().add(0, draggedItem);
// update GPXLineItem as well
targetList = targetLineItem.getChildren();
targetList.add(0, draggedLineItem);
targetLineItem.setChildren(targetList);
}
event.setDropCompleted(true);
myTreeTableView.getSelectionModel().clearSelection();
myTreeTableView.getSelectionModel().select(draggedItem);
myTreeTableView.refresh();
event.consume();
}
} else {
boolean success = false;
if (db.hasFiles()) {
success = true;
final List<File> files = new ArrayList<>();
for (File file:db.getFiles()) {
// accept only gpx files
if (GPXEditorWorker.GPX_EXT.equals(FilenameUtils.getExtension(file.getName()).toLowerCase())) {
files.add(file);
}
}
// read and add to list
myEditor.parseAndAddFiles(files);
}
event.setDropCompleted(success);
event.consume();
}
}