modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

*** 1,7 **** /* ! * Copyright (c) 2010, 2014, 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 --- 1,7 ---- /* ! * Copyright (c) 2010, 2015, 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
*** 31,52 **** import javafx.scene.control.TreeCell; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.input.MouseButton; - import java.util.Collections; - public class TreeCellBehavior<T> extends CellBehaviorBase<TreeCell<T>> { /*************************************************************************** * * * Constructors * * * **************************************************************************/ public TreeCellBehavior(final TreeCell<T> control) { ! super(control, Collections.emptyList()); } /*************************************************************************** --- 31,50 ---- import javafx.scene.control.TreeCell; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.input.MouseButton; public class TreeCellBehavior<T> extends CellBehaviorBase<TreeCell<T>> { /*************************************************************************** * * * Constructors * * * **************************************************************************/ public TreeCellBehavior(final TreeCell<T> control) { ! super(control); } /***************************************************************************
*** 65,75 **** return getCellContainer().getFocusModel(); } @Override protected TreeView<T> getCellContainer() { ! return getControl().getTreeView(); } @Override protected void edit(TreeCell<T> cell) { TreeItem<T> treeItem = cell == null ? null : cell.getTreeItem(); --- 63,73 ---- return getCellContainer().getFocusModel(); } @Override protected TreeView<T> getCellContainer() { ! return getNode().getTreeView(); } @Override protected void edit(TreeCell<T> cell) { TreeItem<T> treeItem = cell == null ? null : cell.getTreeItem();
*** 77,105 **** } @Override protected void handleClicks(MouseButton button, int clickCount, boolean isAlreadySelected) { // handle editing, which only occurs with the primary mouse button ! TreeItem<T> treeItem = getControl().getTreeItem(); if (button == MouseButton.PRIMARY) { if (clickCount == 1 && isAlreadySelected) { ! edit(getControl()); } else if (clickCount == 1) { // cancel editing edit(null); } else if (clickCount == 2 && treeItem.isLeaf()) { // attempt to edit ! edit(getControl()); } else if (clickCount % 2 == 0) { // try to expand/collapse branch tree item treeItem.setExpanded(! treeItem.isExpanded()); } } } @Override protected boolean handleDisclosureNode(double x, double y) { ! TreeCell<T> treeCell = getControl(); Node disclosureNode = treeCell.getDisclosureNode(); if (disclosureNode != null) { if (disclosureNode.getBoundsInParent().contains(x, y)) { if (treeCell.getTreeItem() != null) { treeCell.getTreeItem().setExpanded(! treeCell.getTreeItem().isExpanded()); --- 75,103 ---- } @Override protected void handleClicks(MouseButton button, int clickCount, boolean isAlreadySelected) { // handle editing, which only occurs with the primary mouse button ! TreeItem<T> treeItem = getNode().getTreeItem(); if (button == MouseButton.PRIMARY) { if (clickCount == 1 && isAlreadySelected) { ! edit(getNode()); } else if (clickCount == 1) { // cancel editing edit(null); } else if (clickCount == 2 && treeItem.isLeaf()) { // attempt to edit ! edit(getNode()); } else if (clickCount % 2 == 0) { // try to expand/collapse branch tree item treeItem.setExpanded(! treeItem.isExpanded()); } } } @Override protected boolean handleDisclosureNode(double x, double y) { ! TreeCell<T> treeCell = getNode(); Node disclosureNode = treeCell.getDisclosureNode(); if (disclosureNode != null) { if (disclosureNode.getBoundsInParent().contains(x, y)) { if (treeCell.getTreeItem() != null) { treeCell.getTreeItem().setExpanded(! treeCell.getTreeItem().isExpanded());