Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.         // Use a custom callback to determine the style of the tree item
  2.         layersTree.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
  3.             @Override
  4.             public TreeCell<String> call(TreeView<String> param) {
  5.                 return new CheckBoxTreeCell<String>(){
  6.                     @Override
  7.                     public void updateItem(String item, boolean empty){
  8.                         super.updateItem(item, empty);
  9.                         // If there is no information for the Cell, make it empty
  10.                         if(empty){
  11.                             setGraphic(null);
  12.                             setText(null);
  13.                         // Otherwise if it's not representation as an item of the tree
  14.                         // is not a CheckBoxTreeItem, remove the checkbox item
  15.                         }else if (!(getTreeItem() instanceof CheckBoxTreeItem)){
  16.                             setGraphic(null);
  17.                         }
  18.                     }
  19.                 };
  20.             }
  21.         });