當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。