javafx.scene.control.cell.CheckBoxListCell#javafx.scene.control.TreeCell源码实例Demo

下面列出了javafx.scene.control.cell.CheckBoxListCell#javafx.scene.control.TreeCell 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void setCellFactory() {
    // A shiny cell factory so the tree nodes show the correct text and graphic.
    treeView.setCellFactory(p -> new TreeCell<SchemaTransactionType>() {
        @Override
        protected void updateItem(final SchemaTransactionType item, boolean empty) {
            super.updateItem(item, empty);
            if (!empty && item != null) {
                setText(item.getName());
                if (item.getColor() != null) {
                    final Rectangle icon = getSquare(item.getColor().getJavaFXColor());
                    icon.setSmooth(true);
                    icon.setCache(true);
                    setGraphic(icon);
                }
            } else {
                setGraphic(null);
                setText(null);
            }
        }
    });
}
 
源代码2 项目: pmd-designer   文件: TreeViewWrapper.java
/**
 * Returns true if the item at the given index
 * is visible in the TreeView.
 */
boolean isIndexVisible(int index) {
    if (reflectionImpossibleWarning) {
        return false;
    }

    if (virtualFlow == null && wrapped.getSkin() == null) {
        return false;
    } else if (virtualFlow == null && wrapped.getSkin() != null) {
        // the flow is cached, so the skin must not be changed
        virtualFlow = getVirtualFlow(wrapped.getSkin());
    }

    if (virtualFlow == null) {
        return false;
    }

    Optional<TreeCell<T>> first = getFirstVisibleCell();
    Optional<TreeCell<T>> last = getLastVisibleCell();

    return first.isPresent()
            && last.isPresent()
            && first.get().getIndex() < index
            && last.get().getIndex() > index;
}
 
源代码3 项目: milkman   文件: DnDCellFactory.java
private void dragDetected(MouseEvent event, TreeCell<Node> treeCell, TreeView<Node> treeView) {
    draggedItem = treeCell.getTreeItem();

    // root can't be dragged
    if (draggedItem.getParent() == null) return;
    
    //only Requests can be dragged for now:
    if (!(draggedItem.getValue().getUserData() instanceof RequestContainer))
    	return;
    
    Dragboard db = treeCell.startDragAndDrop(TransferMode.MOVE);

    ClipboardContent content = new ClipboardContent();
    content.put(JAVA_FORMAT, serialize(draggedItem.getValue().getUserData()));
    db.setContent(content);
    db.setDragView(treeCell.snapshot(null, null));
    event.consume();
}
 
源代码4 项目: milkman   文件: DnDCellFactory.java
private void dragOver(DragEvent event, TreeCell<Node> treeCell, TreeView<Node> treeView) {
    if (!event.getDragboard().hasContent(JAVA_FORMAT)) return;
    TreeItem<Node> thisItem = treeCell.getTreeItem();

    // can't drop on itself
    if (draggedItem == null || thisItem == null || thisItem == draggedItem) return;
    // ignore if this is the root
    if (draggedItem.getParent() == null) {
        clearDropLocation();
        return;
    }

    event.acceptTransferModes(TransferMode.MOVE);
    if (!Objects.equals(dropZone, treeCell)) {
        clearDropLocation();
        this.dropZone = treeCell;
        dropZone.setStyle(DROP_HINT_STYLE);
    }
}
 
源代码5 项目: milkman   文件: DnDCellFactory.java
private void drop(DragEvent event, TreeCell<Node> treeCell, TreeView<Node> treeView) {
  	
      try {
	Dragboard db = event.getDragboard();
	boolean success = false;
	if (!db.hasContent(JAVA_FORMAT)) return;

	TreeItem<Node> thisItem = treeCell.getTreeItem();
	RequestContainer draggedRequest = (RequestContainer) draggedItem.getValue().getUserData();
	// remove from previous location
	removeFromPreviousContainer(draggedRequest);
	
	addToNewLocation(treeView, thisItem, draggedRequest);
	treeView.getSelectionModel().select(draggedItem);
	event.setDropCompleted(success);
} catch (Throwable t) {
	t.printStackTrace();
}
  }
 
源代码6 项目: PreferencesFX   文件: NavigationPresenter.java
/**
 * Makes the TreeItems' text update when the description of a Category changes (due to i18n).
 */
public void setupCellValueFactory() {
  navigationView.treeView.setCellFactory(param -> new TreeCell<Category>() {
    @Override
    protected void updateItem(Category category, boolean empty) {
      super.updateItem(category, empty);
      textProperty().unbind();
      if (empty || category == null) {
        setText(null);
        setGraphic(null);
      } else {
        textProperty().bind(category.descriptionProperty());
        setGraphic(category.getItemIcon());
      }
    }
  });
}
 
源代码7 项目: marathonv5   文件: FunctionStage.java
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;
}
 
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();
}
 
源代码9 项目: ariADDna   文件: TreeViewFactory.java
/**
 * 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());
                }
            });
}
 
源代码10 项目: erlyberly   文件: ModFuncTreeCellFactory.java
@Override
public TreeCell<ModFunc> call(TreeView<ModFunc> tree) {
    ModFuncGraphic mfg;

    mfg = new ModFuncGraphic(
        dbgController::toggleTraceModFunc,
        dbgController::isTraced
    );
    mfg.setShowModuleName(isShowModuleName());

    dbgController.addTraceListener((Observable o) -> {
        mfg.onTracesChange();
    });

    return new FXTreeCell<ModFunc>(mfg, mfg);
}
 
源代码11 项目: PeerWasp   文件: Synchronization.java
private void createTreeView(FileNode fileNode){
		PathItem pathItem = new PathItem(userConfig.getRootPath(), false, fileNode.getUserPermissions());
		SyncTreeItem invisibleRoot = new SyncTreeItem(pathItem);
//		invisibleRoot.setIndependent(true);
	    fileTreeView.setRoot(invisibleRoot);
        fileTreeView.setEditable(false);

        fileTreeView.setCellFactory(new Callback<TreeView<PathItem>, TreeCell<PathItem>>(){
            @Override
            public TreeCell<PathItem> call(TreeView<PathItem> p) {
                return new CustomizedTreeCell(getFileEventManager(),
                		recoverFileHandlerProvider,
                		shareFolderHandlerProvider,
                		forceSyncHandlerProvider);
            }
        });

        fileTreeView.setShowRoot(false);


        addChildrensToTreeView(fileNode);
	}
 
源代码12 项目: pmd-designer   文件: TreeViewWrapper.java
private Optional<TreeCell<T>> getCellFromAccessor(Method accessor) {
    return Optional.ofNullable(accessor).map(m -> {
        try {
            @SuppressWarnings("unchecked")
            TreeCell<T> cell = (TreeCell<T>) m.invoke(virtualFlow);
            return cell;
        } catch (IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
        return null;
    });
}
 
源代码13 项目: PDF4Teachers   文件: TextTreeSection.java
public void updateCell(TreeCell cell){
    cell.setOnMouseClicked(null);

    cell.setMaxHeight(30);
    cell.setStyle("-fx-padding: 6 6 6 2; -fx-background-color: " + StyleManager.getHexAccentColor() + ";");
    cell.setContextMenu(menu);

    cell.setGraphic(pane);
}
 
源代码14 项目: PDF4Teachers   文件: TextTreeItem.java
public void updateCell(TreeCell<String> cell){ // Réattribue une cell à la pane

		if(cell == null) return;
		if(name.getText().isEmpty()) updateGraphic();

		name.setFill(StyleManager.convertColor(color.get()));
		rect.setFill(StyleManager.convertColor(Color.WHITE));

		cell.setGraphic(pane);
		cell.setStyle(null);
		cell.setStyle("-fx-padding: 0 -35;");
		cell.setContextMenu(menu);
		cell.setOnMouseClicked(onMouseCLick);

	}
 
源代码15 项目: PDF4Teachers   文件: GradeTreeView.java
public GradeTreeView(LBGradeTab gradeTab){

        disableProperty().bind(MainWindow.mainScreen.statusProperty().isNotEqualTo(MainScreen.Status.OPEN));
        setBackground(new Background(new BackgroundFill(Color.rgb(244, 244, 244), CornerRadii.EMPTY, Insets.EMPTY)));
        prefHeightProperty().bind(gradeTab.pane.heightProperty().subtract(layoutYProperty()));
        prefWidthProperty().bind(gradeTab.pane.widthProperty());

        setCellFactory(new Callback<>() {
            @Override
            public TreeCell<String> call(TreeView<String> param) {
                return new TreeCell<>() {
                    @Override protected void updateItem(String item, boolean empty){
                        super.updateItem(item, empty);

                        // Enpty cell or String Data
                        if(empty || item != null){
                            setGraphic(null);
                            setStyle(null);
                            setContextMenu(null);
                            setOnMouseClicked(null);
                            setTooltip(null);
                            return;
                        }
                        // TreeGradeData
                        if(getTreeItem() instanceof GradeTreeItem){
                            ((GradeTreeItem) getTreeItem()).updateCell(this);
                            return;
                        }
                        // Other
                        setStyle(null);
                        setGraphic(null);
                        setContextMenu(null);
                        setOnMouseClicked(null);
                        setTooltip(null);
                    }
                };
            }
        });
    }
 
源代码16 项目: marathonv5   文件: MarathonFileChooser.java
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);
}
 
源代码17 项目: marathonv5   文件: ResourceView.java
public ResourceView(IResourceActionSource source, Resource root, IResourceActionHandler handler,
        IResourceChangeListener listener) {
    this.source = source;
    this.handler = handler;
    setEditable(true);
    setRoot(root);
    getRoot().addEventHandler(ResourceModificationEvent.ANY, (event) -> {
        if (event.getEventType() == ResourceModificationEvent.DELETE) {
            listener.deleted(source, event.getResource());
        }
        if (event.getEventType() == ResourceModificationEvent.UPDATE) {
            listener.updated(source, event.getResource());
        }
        if (event.getEventType() == ResourceModificationEvent.MOVED) {
            listener.moved(source, event.getFrom(), event.getTo());
        }
        if (event.getEventType() == ResourceModificationEvent.COPIED) {
            listener.copied(source, event.getFrom(), event.getTo());
        }
    });
    setContextMenu(contextMenu);
    setContextMenuItems();
    getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getSelectionModel().getSelectedItems().addListener(new ListChangeListener<TreeItem<Resource>>() {
        @Override
        public void onChanged(Change<? extends TreeItem<Resource>> c) {
            setContextMenuItems();
        }
    });
    Callback<TreeView<Resource>, TreeCell<Resource>> value = new Callback<TreeView<Resource>, TreeCell<Resource>>() {
        @Override
        public TreeCell<Resource> call(TreeView<Resource> param) {
            return new TextFieldTreeCellImpl();
        }
    };
    setCellFactory(value);
}
 
源代码18 项目: marathonv5   文件: JavaFXElementPropertyAccessor.java
private Set<Node> getTreeCells(TreeView<?> treeView) {
    Set<Node> l = treeView.lookupAll("*");
    Set<Node> r = new HashSet<>();
    for (Node node : l) {
        if (node instanceof TreeCell<?>) {
            if (!((TreeCell<?>) node).isEmpty())
                r.add(node);
        }
    }
    return r;
}
 
源代码19 项目: marathonv5   文件: JavaFXTreeCellElement.java
@Override
public String _getValue() {
    TreeCell<?> cell = (TreeCell<?>) getComponent();
    Node graphic = cell.getGraphic();
    JavaFXElement cellElement = (JavaFXElement) JavaFXElementFactory.createElement(graphic, driver, window);
    if (graphic != null && cellElement != null) {
        return cellElement._getValue();
    }
    return super._getValue();
}
 
源代码20 项目: marathonv5   文件: JavaFXTreeViewNodeElement.java
@SuppressWarnings({ "rawtypes", "unchecked" })
private Node getEditor() {
    TreeCell cell = (TreeCell) getPseudoComponent();
    TreeView treeView = (TreeView) getComponent();
    treeView.edit(cell.getTreeItem());
    Node cellComponent = cell.getGraphic();
    cellComponent.getProperties().put("marathon.celleditor", true);
    cellComponent.getProperties().put("marathon.cell", cell);
    return cellComponent;
}
 
源代码21 项目: marathonv5   文件: JavaFXTreeViewNodeElement.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    Node cell = getPseudoComponent();
    target = getTextObj((TreeCell<?>) cell);
    Point2D targetXY = node.localToScene(xoffset, yoffset);
    super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
 
源代码22 项目: marathonv5   文件: JavaFXTreeViewNodeElement.java
private Node getTextObj(TreeCell<?> cell) {
    for (Node child : cell.getChildrenUnmodifiable()) {
        if (child instanceof Text) {
            return child;
        }
    }
    return cell;
}
 
源代码23 项目: marathonv5   文件: RFXTreeView.java
private String getTreeCellValue(TreeView<?> treeView, int index) {
    if (index == -1) {
        return null;
    }
    TreeCell<?> treeCell = getCellAt(treeView, index);
    RFXComponent cellComponent = getFinder().findRCellComponent(treeCell, null, recorder);
    return cellComponent == null ? null : cellComponent.getValue();
}
 
源代码24 项目: marathonv5   文件: RFXComponentTest.java
public Point2D getPoint(TreeView<?> treeView, int index) {
    Set<Node> cells = treeView.lookupAll(".tree-cell");
    for (Node node : cells) {
        TreeCell<?> cell = (TreeCell<?>) node;
        if (cell.getIndex() == index) {
            Bounds bounds = cell.getBoundsInParent();
            return cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
        }
    }
    return null;
}
 
源代码25 项目: marathonv5   文件: RFXComponentTest.java
public TreeCell<?> getCellAt(TreeView<?> treeView, int index) {
    Set<Node> lookupAll = treeView.lookupAll(".tree-cell");
    for (Node node : lookupAll) {
        TreeCell<?> cell = (TreeCell<?>) node;
        if (cell.getIndex() == index) {
            return cell;
        }
    }
    return null;
}
 
EditableTreeCellFactory(@NotNull EditableTreeView<Tv, Td> treeView, @Nullable TreeCellSelectionUpdate treeCellSelectionUpdate) {
	this.treeCellSelectionUpdate = treeCellSelectionUpdate;
	this.treeView = treeView;
	this.setEditable(true);
	// first method called when the user clicks and drags a tree item
	TreeCell<Td> myTreeCell = this;

	//		addDragListeners(treeView, myTreeCell);
}
 
源代码27 项目: markdown-writer-fx   文件: ProjectFileTreeView.java
private TreeCell<File> createCell(TreeView<File> treeView) {
	FileTreeCell treeCell = new FileTreeCell();
	treeCell.setOnDragDetected(event -> {
		TreeItem<File> draggedItem = treeCell.getTreeItem();
		Dragboard db = treeCell.startDragAndDrop(TransferMode.COPY);

		ClipboardContent content = new ClipboardContent();
		content.putString(draggedItem.getValue().getAbsolutePath());
		content.put(DataFormat.FILES, Collections.singletonList(draggedItem.getValue()));
		db.setContent(content);

		event.consume();
	});
	return treeCell;
}
 
源代码28 项目: constellation   文件: VertexTypeNodeProvider.java
public VertexTypeNodeProvider() {
    schemaLabel = new Label(SeparatorConstants.HYPHEN);
    schemaLabel.setPadding(new Insets(5));
    treeView = new TreeView<>();
    vertexTypes = new ArrayList<>();
    detailsView = new HBox();
    detailsView.setPadding(new Insets(5));
    backgroundIcons = new HashMap<>();
    foregroundIcons = new HashMap<>();
    startsWithRb = new RadioButton("Starts with");
    filterText = new TextField();

    // A shiny cell factory so the tree nodes show the correct text and graphic.
    treeView.setCellFactory(p -> new TreeCell<SchemaVertexType>() {
        @Override
        protected void updateItem(final SchemaVertexType item, boolean empty) {
            super.updateItem(item, empty);
            if (!empty && item != null) {
                setText(item.getName());
                if (item.getForegroundIcon() != null) {
                    // Background icon, sized, clipped, colored.
                    final Color color = item.getColor().getJavaFXColor();

                    if (!backgroundIcons.containsKey(item)) {
                        backgroundIcons.put(item, item.getBackgroundIcon().buildImage());
                    }
                    final ImageView bg = new ImageView(backgroundIcons.get(item));
                    bg.setFitWidth(SMALL_ICON_IMAGE_SIZE);
                    bg.setPreserveRatio(true);
                    bg.setSmooth(true);
                    final ImageView clip = new ImageView(bg.getImage());
                    clip.setFitWidth(SMALL_ICON_IMAGE_SIZE);
                    clip.setPreserveRatio(true);
                    clip.setSmooth(true);
                    bg.setClip(clip);
                    final ColorAdjust adjust = new ColorAdjust();
                    adjust.setSaturation(-1);
                    final ColorInput ci = new ColorInput(0, 0, SMALL_ICON_IMAGE_SIZE, SMALL_ICON_IMAGE_SIZE, color);
                    final Blend blend = new Blend(BlendMode.MULTIPLY, adjust, ci);
                    bg.setEffect(blend);

                    // Foreground icon, sized.
                    if (!foregroundIcons.containsKey(item)) {
                        foregroundIcons.put(item, item.getForegroundIcon().buildImage());
                    }
                    final ImageView fg = new ImageView(foregroundIcons.get(item));
                    fg.setFitWidth(SMALL_ICON_IMAGE_SIZE);
                    fg.setPreserveRatio(true);
                    fg.setSmooth(true);
                    fg.setCache(true);

                    // Combine foreground and background icons.
                    final Group iconGroup = new Group(bg, fg);

                    setGraphic(iconGroup);
                }
            } else {
                setGraphic(null);
                setText(null);
            }
        }
    });
}
 
源代码29 项目: pmd-designer   文件: TreeViewWrapper.java
private Optional<TreeCell<T>> getFirstVisibleCell() {
    return getCellFromAccessor(treeViewFirstVisibleMethod);
}
 
源代码30 项目: pmd-designer   文件: TreeViewWrapper.java
private Optional<TreeCell<T>> getLastVisibleCell() {
    return getCellFromAccessor(treeViewLastVisibleMethod);
}