javafx.scene.control.TreeView.setCellFactory()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(257)

本文整理了Java中javafx.scene.control.TreeView.setCellFactory()方法的一些代码示例,展示了TreeView.setCellFactory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeView.setCellFactory()方法的具体详情如下:
包路径:javafx.scene.control.TreeView
类名称:TreeView
方法名:setCellFactory

TreeView.setCellFactory介绍

暂无

代码示例

代码示例来源:origin: speedment/speedment

private void prepareTree(ProjectProperty project) {
  requireNonNull(project);
  events.notify(new ProjectLoaded(project));
  Bindings.bindContent(ui.getSelectedTreeItems(), hierarchy.getSelectionModel().getSelectedItems());
  hierarchy.setCellFactory(view -> new DocumentPropertyCell(projectTreeComponent));
  hierarchy.getSelectionModel().setSelectionMode(SINGLE);
  populateTree(project);
}

代码示例来源:origin: pmd/pmd

@Override
protected void beforeParentInit() {
  xpathAttributesListView.setPlaceholder(new Label("No available attributes"));
  EventStreams.valuesOf(scopeHierarchyTreeView.getSelectionModel().selectedItemProperty())
        .filter(Objects::nonNull)
        .map(TreeItem::getValue)
        .filterMap(o -> o instanceof NameDeclaration, o -> (NameDeclaration) o)
        .filter(nd -> !Objects.equals(nd.getNode(), selectedNode))
        .subscribe(declaration -> Platform.runLater(() -> parent.onNodeItemSelected(declaration.getNode(), true)));
  scopeHierarchyTreeView.setCellFactory(view -> new ScopeHierarchyTreeCell());
  hideCommonAttributesProperty()
    .values()
    .distinct()
    .subscribe(show -> displayAttributes(selectedNode));
}

代码示例来源:origin: pmd/pmd

@Override
protected void beforeParentInit() {
  treeViewWrapper = new TreeViewWrapper<>(astTreeView);
  astTreeView.setCellFactory(treeView -> new ASTTreeCell(parent));
  initializeLanguageSelector(); // languageVersionProperty() must be initialized
  languageVersionProperty().values()
               .filterMap(Objects::nonNull, LanguageVersion::getLanguage)
               .distinct()
               .subscribe(this::updateSyntaxHighlighter);
  languageVersionProperty().values()
               .filter(Objects::nonNull)
               .map(LanguageVersion::getShortName)
               .map(lang -> "Source Code (" + lang + ")")
               .subscribe(editorTitledPane::setTitle);
  EventStreams.valuesOf(astTreeView.getSelectionModel().selectedItemProperty())
        .filterMap(Objects::nonNull, TreeItem::getValue)
        .subscribe(parent::onNodeItemSelected);
  codeEditorArea.plainTextChanges()
         .filter(t -> !t.isIdentity())
         .successionEnds(AST_REFRESH_DELAY)
         // Refresh the AST anytime the text, classloader, or language version changes
         .or(auxclasspathClassLoader.changes())
         .or(languageVersionProperty().changes())
         .subscribe(tick -> {
           // Discard the AST if the language version has changed
           tick.ifRight(c -> astTreeView.setRoot(null));
           Platform.runLater(parent::refreshAST);
         });
  codeEditorArea.setParagraphGraphicFactory(lineNumberFactory());
}

代码示例来源:origin: com.powsybl/powsybl-gse-util

public static <T> void setWaitingCellFactory(TreeView<T> treeView, T waitingValue, Function<T, String> itemToString) {
  Objects.requireNonNull(treeView);
  Objects.requireNonNull(waitingValue);
  treeView.setCellFactory(param -> new TextFieldTreeCell<T>() {
    @Override
    public void updateItem(T item, boolean empty) {
      super.updateItem(item, empty);
      if (!empty) {
        if (waitingValue.equals(item)) {
          setWaitingText(this);
        } else {
          setText(itemToString.apply(item));
          setTextFill(Color.BLACK);
          setGraphic(getTreeItem().getGraphic());
        }
      }
    }
  });
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.code.editor.fx

private TreeView<OutlineItem> createView() {
  TreeView<OutlineItem> outlineView = new TreeView<>();
  outlineView.setShowRoot(false);
  outlineView.setCellFactory(this::createCell);
  return outlineView;
}

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.code.editor.fx

private TreeView<OutlineItem> createView() {
  TreeView<OutlineItem> outlineView = new TreeView<>();
  outlineView.setShowRoot(false);
  outlineView.setCellFactory(this::createCell);
  return outlineView;
}

代码示例来源:origin: org.copper-engine/copper-monitoring-client

treeView.setCellFactory(new Callback<TreeView<DisplayableNode>, TreeCell<DisplayableNode>>() {
  @Override
  public TreeCell<DisplayableNode> call(TreeView<DisplayableNode> param) {

代码示例来源:origin: org.copper-engine/copper-monitoring-client

public void refresh(List<WorkflowVersion> newItems) {
  treeView.setShowRoot(false);
  TreeItem<DisplayWorkflowClassesModel> rootItem = new TreeItem<DisplayWorkflowClassesModel>();
  rootItem.getChildren().addAll(groupToTreeItem(newItems));
  treeView.setRoot(rootItem);
  treeView.setCellFactory(new Callback<TreeView<DisplayWorkflowClassesModel>, TreeCell<DisplayWorkflowClassesModel>>() {
    @Override
    public TreeCell<DisplayWorkflowClassesModel> call(TreeView<DisplayWorkflowClassesModel> listView) {
      return new TextFieldTreeCell<DisplayWorkflowClassesModel>(new StringConverter<DisplayWorkflowClassesModel>() {
        @Override
        public DisplayWorkflowClassesModel fromString(String string) {
          return null;
        }
        @Override
        public String toString(DisplayWorkflowClassesModel object) {
          return object.displayName;
        }
      });
    }
  });
  rootItem.setExpanded(true);
}

代码示例来源:origin: eu.agrosense.client/util-javafx

@Override
public void addNotify() {
  super.addNotify();
  em = ExplorerManager.find(this);
  if (em != null) {
    TreeItem<Node> rootItem = createFromNode(em.getRootContext());
    rootItem.setExpanded(true);
    final TreeView<Node> treeView = new TreeView<>(rootItem);
    treeView.setEditable(true);
    treeView.setShowRoot(rootVisible);
    treeView.setCellFactory(
        new Callback<TreeView<Node>, TreeCell<Node>>() {
          @Override
          public TreeCell<Node> call(final TreeView<Node> p) {
            return new TextFieldTreeCellImpl();
          }
        });
    Platform.runLater(new Runnable() {
      @Override
      public void run() {
        StackPane root = new StackPane();
        root.getChildren().add(treeView);
        Scene scene = new Scene(root, 300, 250);
        setScene(scene);
      }
    });
  }
}
// for custom cell editor with edit capabilities:

代码示例来源:origin: nl.cloudfarming.client/calendar-api

treeView.setCellFactory(createCellFactory(contextMenu));
treeView.setShowRoot(false);
treeView.getStyleClass().add("node-list");

代码示例来源:origin: com.aquafx-project/aquafx

treeView.setCellFactory(CheckBoxTreeCell.<String> forTreeView());
treeView1.setCellFactory(CheckBoxTreeCell.<String> forTreeView());

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

/**
 * Create a new skin
 *
 * @param control
 *            the control
 * @param selectedItems
 *            the selected items
 */
public ResourceTreeViewSkin(ResourceTreeView control,
    ObservableList<ResourceItem> selectedItems) {
  super(control);
  this.selectedItems = selectedItems;
  this.tree = new TreeView<>();
  this.tree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
  this.tree.setCellFactory((v) -> new SimpleTreeCell<@NonNull ResourceItem>(
      ResourceTreeViewSkin::handleDirLabel, this::handleStyleclass));
  this.tree.setShowRoot(false);
  this.tree.getSelectionModel().getSelectedItems()
      .addListener(this::handleSelectionChange);
  this.tree.setOnMouseClicked( e -> {
    if( e.getClickCount() > 1 ) {
      openSelectedResources();
    }
  });
  getChildren().add(this.tree);
  control.rootDirectoriesProperty().addListener(this::rebuildTable);
  control.iconSizeProperty().addListener(this::rebuildTable);
  rebuildTable(control.rootDirectoriesProperty());
}

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

/**
 * Create a new skin
 *
 * @param control
 *            the control
 * @param selectedItems
 *            the selected items
 */
public DirectoryTreeViewSkin(DirectoryTreeView control,
    ObservableList<DirItem> selectedItems) {
  super(control);
  this.selectedItems = selectedItems;
  this.tree = new TreeView<>();
  this.tree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
  this.tree.setCellFactory((v) -> new SimpleTreeCell<@NonNull DirItem>(
      DirectoryTreeViewSkin::handleDirLabel, this::handleStyleclass));
  this.tree.setShowRoot(false);
  this.tree.getSelectionModel().getSelectedItems()
      .addListener(this::handleSelectionChange);
  this.tree.setOnMouseClicked( e -> {
    if( e.getClickCount() > 1 ) {
      openSelectedResources();
    }
  });
  getChildren().add(this.tree);
  control.rootDirectoriesProperty().addListener(this::rebuildTable);
  control.iconSizeProperty().addListener(this::rebuildTable);
  rebuildTable(control.rootDirectoriesProperty());
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls

/**
 * Create a new skin
 *
 * @param control
 *            the control
 * @param selectedItems
 *            the selected items
 */
public ResourceTreeViewSkin(ResourceTreeView control,
    ObservableList<ResourceItem> selectedItems) {
  super(control);
  this.selectedItems = selectedItems;
  this.tree = new TreeView<>();
  this.tree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
  this.tree.setCellFactory((v) -> new SimpleTreeCell<@NonNull ResourceItem>(
      ResourceTreeViewSkin::handleDirLabel, this::handleStyleclass));
  this.tree.setShowRoot(false);
  this.tree.getSelectionModel().getSelectedItems()
      .addListener(this::handleSelectionChange);
  this.tree.setOnMouseClicked( e -> {
    if( e.getClickCount() > 1 ) {
      openSelectedResources();
    }
  });
  getChildren().add(this.tree);
  control.rootDirectoriesProperty().addListener(this::rebuildTable);
  control.iconSizeProperty().addListener(this::rebuildTable);
  rebuildTable(control.rootDirectoriesProperty());
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls

/**
 * Create a new skin
 *
 * @param control
 *            the control
 * @param selectedItems
 *            the selected items
 */
public DirectoryTreeViewSkin(DirectoryTreeView control,
    ObservableList<DirItem> selectedItems) {
  super(control);
  this.selectedItems = selectedItems;
  this.tree = new TreeView<>();
  this.tree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
  this.tree.setCellFactory((v) -> new SimpleTreeCell<@NonNull DirItem>(
      DirectoryTreeViewSkin::handleDirLabel, this::handleStyleclass));
  this.tree.setShowRoot(false);
  this.tree.getSelectionModel().getSelectedItems()
      .addListener(this::handleSelectionChange);
  this.tree.setOnMouseClicked( e -> {
    if( e.getClickCount() > 1 ) {
      openSelectedResources();
    }
  });
  getChildren().add(this.tree);
  control.rootDirectoriesProperty().addListener(this::rebuildTable);
  control.iconSizeProperty().addListener(this::rebuildTable);
  rebuildTable(control.rootDirectoriesProperty());
}

代码示例来源:origin: com.powsybl/powsybl-gse-afs-ext-base

ToolBar toolBar = new ToolBar(saveButton, removeButton);
contingencyTree.setCellFactory(param -> new ContingencyTreeCell());
contingencyTree.setShowRoot(false);

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

if (StringUtils.isNotBlank(presenter)) {
 final Object userdata = this;
 treeView.setCellFactory(param -> {
  final EpTreeCell<OperationData> cell = new EpTreeCell<>();
  cell.setPresenterId(presenter);

代码示例来源:origin: io.github.factoryfx/javafxDataEditing

private Node createTree(){
  TreeView<TreeData> tree = new TreeView<>();
  tree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
  tree.setCellFactory(param -> new DataTextFieldTreeCell<>(TreeData::getData, TreeData::getDisplayText));
  tree.setRoot(constructTreeFromRoot());

相关文章