当前位置: 首页>>代码示例>>Java>>正文


Java TreeCell类代码示例

本文整理汇总了Java中javafx.scene.control.TreeCell的典型用法代码示例。如果您正苦于以下问题:Java TreeCell类的具体用法?Java TreeCell怎么用?Java TreeCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TreeCell类属于javafx.scene.control包,在下文中一共展示了TreeCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTreeCellFactory

import javafx.scene.control.TreeCell; //导入依赖的package包/类
/**
 * Customizing treeView
 *
 * @param tree treeView
 */
private void setTreeCellFactory(TreeView<SimpleTreeElement> tree) {
    tree.setCellFactory(param -> new TreeCell<SimpleTreeElement>() {
        @Override
        public void updateItem(SimpleTreeElement item, boolean empty) {
            super.updateItem(item, empty);
            //setDisclosureNode(null);

            if (empty) {
                setText("");
                setGraphic(null);
            } else {
                setText(item.getName());
            }
        }

    });

    tree.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            System.out.println(newValue.getValue());
        }
    });
}
 
开发者ID:StnetixDevTeam,项目名称:ariADDna,代码行数:29,代码来源:TreeViewFactory.java

示例2: initTreeView

import javafx.scene.control.TreeCell; //导入依赖的package包/类
private void initTreeView() {
    parentTreeView.setCellFactory(new Callback<TreeView<File>, TreeCell<File>>() {
        @Override public TreeCell<File> call(TreeView<File> param) {
            return new ParentFileCell();
        }
    });
    parentTreeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newVlaue) -> {
        TreeItem<File> selectedItem = parentTreeView.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            newFolderButton.setDisable(false);
            fileNameBox.setEditable(true);
            File selectedFile = selectedItem.getValue();
            fillUpChildren(selectedFile);
        } else {
            fileNameBox.setEditable(false);
            newFolderButton.setDisable(true);
            childrenListView.getItems().clear();
        }
    });
    File root = fileChooserInfo.getRoot();
    TreeItem<File> rootItem = new TreeItem<>(root);
    parentTreeView.setRoot(rootItem);
    rootItem.setExpanded(true);
    parentTreeView.getSelectionModel().select(0);
    populateChildren(root, rootItem);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:27,代码来源:MarathonFileChooser.java

示例3: createTree

import javafx.scene.control.TreeCell; //导入依赖的package包/类
private Node createTree() {
    VBox treeContentBox = new VBox();
    tree.setRoot(functionInfo.getRoot(true));
    tree.setShowRoot(false);
    tree.getSelectionModel().selectedItemProperty().addListener(new TreeViewSelectionChangeListener());
    tree.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
        @Override public TreeCell<Object> call(TreeView<Object> param) {
            return new FunctionTreeCell();
        }
    });
    filterByName.setOnAction((e) -> {
        tree.setRoot(functionInfo.refreshNode(filterByName.isSelected()));
        expandAll();
    });
    filterByName.setSelected(true);
    expandAll();
    treeContentBox.getChildren().addAll(topButtonBar, tree, filterByName);
    VBox.setVgrow(tree, Priority.ALWAYS);
    return treeContentBox;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:FunctionStage.java

示例4: getRowAt

import javafx.scene.control.TreeCell; //导入依赖的package包/类
public int getRowAt(TreeView<?> treeView, Point2D point) {
    if (point == null) {
        return treeView.getSelectionModel().getSelectedIndex();
    }
    point = treeView.localToScene(point);
    int itemCount = treeView.getExpandedItemCount();
    @SuppressWarnings("rawtypes")
    List<TreeCell> cells = new ArrayList<>();
    for (int i = 0; i < itemCount; i++) {
        cells.add(getCellAt(treeView, i));
    }
    TreeCell<?> selected = null;
    for (Node cellNode : cells) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (TreeCell<?>) cellNode;
            break;
        }
    }
    if (selected == null) {
        return -1;
    }
    return selected.getIndex();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:JavaFXElementPropertyAccessor.java

示例5: highlight

import javafx.scene.control.TreeCell; //导入依赖的package包/类
public static void highlight() {
    if (diagnostics != null) {
        Set<Node> treeCells = treeView.lookupAll(".tree-cell");
        cells = new ArrayList<>(treeCells);
        cells = cells.parallelStream().filter(c -> ((TreeCell) c).getTreeItem() != null).collect(Collectors.toList());
        treeItems = getAllTreeItems(treeView.getRoot());

        diagnostics.stream()
                .filter(JavaCompilerSyntax::isErrorKind)
                .map(HighlightCell::isCurrTreeItem)
                .forEach(HighlightCell::highlightCells);

        cells.parallelStream()
                .forEach(c -> c.setStyle(null));
    }
}
 
开发者ID:MrChebik,项目名称:Coconut-IDE,代码行数:17,代码来源:HighlightCell.java

示例6: getConverter

import javafx.scene.control.TreeCell; //导入依赖的package包/类
private static StringConverter getConverter(TreeCell cell) {
	StringConverter converter = null;
	try {
		Method m = cell.getClass().getMethod("converterProperty");
		if (m != null) {
			Object object = m.invoke(cell);
			if (object != null && object instanceof ObjectProperty) {
				ObjectProperty<StringConverter> convert = (ObjectProperty<StringConverter>) object;
				converter = convert.get();
			}
		}
	} catch (Exception e) {
		// Nothing...
	}
	return converter;
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:17,代码来源:FxTreeViewClipboardUtil.java

示例7: createTreeCell

import javafx.scene.control.TreeCell; //导入依赖的package包/类
protected TreeCell<MacroItemVO> createTreeCell() {
	return new TreeCell<MacroItemVO>() {

		@Override
		protected void updateItem(MacroItemVO item, boolean empty) {
			super.updateItem(item, empty);

			if (!empty) {
				String apply = stringConverter.apply(item);
				setText(apply);
			} else {
				setText("");
			}

		}
	};
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:18,代码来源:MacroFavorTreeView.java

示例8: call

import javafx.scene.control.TreeCell; //导入依赖的package包/类
@Override
public TreeCell<V> call(TreeView<V> param) {
	TextFieldTreeCell<V> textFieldTreeCell = new TextFieldTreeCell<V>(treeItemStringConverter) {

		@Override
		public void updateItem(V item, boolean empty) {
			super.updateItem(item, empty);
			if (empty) {
				setGraphic(null);
			} else {
				ObservableList<File> items = item.getItems();
				if (!items.isEmpty()) {
					File file = items.get(0);
					setGraphic(new FileIconImageView(file));
				}

			}
		}

	};

	return textFieldTreeCell;
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:24,代码来源:FilesAnalysisComposite.java

示例9: FxControlsTreeItem

import javafx.scene.control.TreeCell; //导入依赖的package包/类
public FxControlsTreeItem(TreeView<Node> tv) {
	this.tv = tv;

	tv.setCellFactory(param -> {
		TreeCell<Node> treeCell = new TextFieldTreeCell<Node>(new StringConverter<Node>() {
			@Override
			public String toString(Node n) {
				return getName(n);
			}

			@Override
			public Node fromString(String string) {
				return null;
			}

		});
		return treeCell;
	});

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:21,代码来源:FxControlsTreeItem.java

示例10: check

import javafx.scene.control.TreeCell; //导入依赖的package包/类
@Override
public boolean check(IndexedCell control) {
    if (control.isVisible() && control.getOpacity() == 1.0) {
        if (isTreeViewTests) {
            if (control instanceof TreeCell) {
                if ((((TreeCell) control).getTreeItem() != null) && ((TreeCell) control).getTreeItem().equals(item)) {
                    return true;
                }
            }
        } else {
            if (control instanceof TreeTableCell) {
                if ((((TreeTableCell) control).getTreeTableRow().getTreeItem() != null) && ((TreeTableCell) control).getTreeTableRow().getTreeItem().equals(item)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:20,代码来源:TreeViewTest.java

示例11: updateItem

import javafx.scene.control.TreeCell; //导入依赖的package包/类
@Override
protected void updateItem(Object data, boolean empty) {
	super.updateItem(data, empty);

	if (empty || data == null) {
		setText(null);
		setGraphic(null);
	} else {
		final Object item = mapping.apply(data);

		if (item instanceof VNode) {
			final VNode newVNode = VScenegraphFactory
				.customNode(TreeCell.class).child("graphic", (VNode) item);
			final Option<VNode> oldVNode = Option.of(getGraphic())
				.flatMap(node -> Option.of((VNode) node.getUserData()));

			final Map<Phase, Vector<Patch>> patches = Differ.diff(oldVNode, Option.of(newVNode));
			Patcher.patch(dispatcher, this, oldVNode, patches);

			Option.of(getGraphic()).forEach(node -> node.setUserData(newVNode));
		} else {
			this.setText(String.valueOf(item));
			this.setGraphic(null);
		}
	}
}
 
开发者ID:netopyr,项目名称:reduxfx,代码行数:27,代码来源:TreeViewCellFactoryAccessor.java

示例12: FileTreeView

import javafx.scene.control.TreeCell; //导入依赖的package包/类
public FileTreeView() {
  super();

  getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

  setCellFactory(new Callback<TreeView<File>, TreeCell<File>>() {
    @Override
    public TreeCell<File> call(TreeView<File> param) {
      return new FileFormatCell();
    }
  });

  final TreeItem<File> fakeRoot = new TreeItem<File>();
  setRoot(fakeRoot);
  setShowRoot(false);

  List<File> rootDevices = Sgf4jGuiUtil.getRootDevices();
  TreeItem<File>[] treeItems = new FileTreeItem[rootDevices.size()];
  for (int i = 0; i < rootDevices.size(); i++) {
    treeItems[i] = new FileTreeItem(rootDevices.get(i));
  }

  fakeRoot.getChildren().addAll(treeItems);

  openTreeAtRightLocation(fakeRoot);
}
 
开发者ID:toomasr,项目名称:sgf4j-gui,代码行数:27,代码来源:FileTreeView.java

示例13: isOnSelectedCell

import javafx.scene.control.TreeCell; //导入依赖的package包/类
/**
 * Checks if the given {@link MouseEvent} is on the selected cell.
 * 
 * @param pMouseEvent the {@link MouseEvent}.
 * @return {@code true} if the given event is on the selected cell.
 */
private boolean isOnSelectedCell(MouseEvent pMouseEvent)
{
	EventTarget target = pMouseEvent.getTarget();
	
	if (target instanceof Node)
	{
		Node targetNode = (Node)target;
		
		while (targetNode != null && !(targetNode instanceof FXDataBooksTree))
		{
			if (targetNode instanceof TreeCell<?>)
			{
				return ((TreeCell<?>)targetNode).isSelected();
			}
			
			targetNode = targetNode.getParent();
		}
	}
	
	return false;
}
 
开发者ID:ivartanian,项目名称:JVx.javafx,代码行数:28,代码来源:JavaFXTree.java

示例14: installForDocumentType

import javafx.scene.control.TreeCell; //导入依赖的package包/类
private <DOC extends DocumentProperty> Stream<MenuItem>
installForDocumentType(TreeCell<DocumentProperty> treeCell, DOC node) {
    final MenuItem expandAll   = new MenuItem("Expand All", ProjectTreeIcon.BOOK_OPEN.view());
    final MenuItem collapseAll = new MenuItem("Collapse All", ProjectTreeIcon.BOOK.view());

    expandAll.setOnAction(ev ->
        DocumentUtil.traverseOver(node)
            .filter(HasExpandedProperty.class::isInstance)
            .forEach(doc -> ((HasExpandedProperty) doc).expandedProperty().setValue(true))
    );

    collapseAll.setOnAction(ev ->
        DocumentUtil.traverseOver(node)
            .filter(HasExpandedProperty.class::isInstance)
            .forEach(doc -> ((HasExpandedProperty) doc).expandedProperty().setValue(false))
    );

    return Stream.of(expandAll, collapseAll);
}
 
开发者ID:speedment,项目名称:speedment,代码行数:20,代码来源:ToggleExpandedActionImpl.java

示例15: addDeleteMenuItem

import javafx.scene.control.TreeCell; //导入依赖的package包/类
private void addDeleteMenuItem(ContextMenu menu, TreeCell<NodeDraggable> currentTreeCell) {
	TreeItem<NodeDraggable> currentTreeItem = currentTreeCell.getTreeItem();
	MenuItem deleteMenuItem = new MenuItem("Delete");
	deleteMenuItem.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent event)
		{
			if (QueryBuilderHelper.getUserConfirmToDeleteNodeIfNecessary(currentTreeItem)) {
				if (currentTreeItem.getParent() == null) {
					queryNodeTreeView.setRoot(null);
					rootNodeTypeComboBox.getSelectionModel().clearSelection();

					nodeEditorGridPane.getChildren().clear();
				} else {
					currentTreeItem.getParent().getChildren().remove(currentTreeItem);

					nodeEditorGridPane.getChildren().clear();
				}	
			}
		}
	});
	menu.getItems().add(deleteMenuItem);
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:24,代码来源:RefsetSpecSearchTypeModel.java


注:本文中的javafx.scene.control.TreeCell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。