Java 类javafx.scene.control.TreeItem 实例源码

项目:shuffleboard    文件:NetworkTableTreeTest.java   
@Test
public void testBranches() {
  table.getEntry("branch/entry").setString("x");
  NetworkTableInstance.getDefault().waitForEntryListenerQueue(-1.0);
  waitForFxEvents();
  ObservableList<TreeItem<NetworkTableSourceEntry>> children = root.getChildren();

  assertEquals(1, children.size(), "There should be 1 first-level child");
  assertEquals(1, children.get(0).getChildren().size(), "There should be 1 second-level child");
  final TreeItem<NetworkTableSourceEntry> branch = children.get(0);
  final TreeItem<NetworkTableSourceEntry> leaf = branch.getChildren().get(0);

  assertThat(branch, hasKey("/branch"));
  assertThat(branch, hasDisplayString(""));
  assertThat("Branch should not be a leaf", branch, not(isLeaf()));
  assertThat("Branch should be expanded", branch, isExpanded());

  assertThat(leaf, hasKey("/branch/entry"));
  assertThat(leaf, hasSimpleKey("entry"));
  assertThat(leaf, hasDisplayString("x"));
  assertThat(leaf, isLeaf());
}
项目:Coconut-IDE    文件:TreeUpdater.java   
public ChangeListener<Boolean> expanderListener() {
    return (observable, oldValue, newValue) -> {
        BooleanProperty bb = (BooleanProperty) observable;

        TreeItem t = (TreeItem) bb.getBean();

        CustomIcons customIcons = new CustomIcons();
        t.setGraphic(new ImageView(newValue ? customIcons.getFolderExpandImage() : customIcons.getFolderCollapseImage()));

        if (newValue) {
            scheduleHighlight();
        }
    };
}
项目: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);
}
项目:vars-annotation    文件:TreeViewController.java   
public TreeView<Concept> getTreeView() {
    if (treeView == null) {
        TreeCellFactory cellFactory = new TreeCellFactory(conceptService);
        treeView = new TreeView<>();
        treeView.getStyleClass().add("concepttree-treeview");
        treeView.setEditable(false);
        treeView.setCellFactory(tv -> cellFactory.build());
        treeView.setContextMenu(getContextMenu());
        conceptService.findRoot()
                .thenApply(root -> {
                    Platform.runLater(() -> {
                        TreeItem<Concept> rootItem = buildTreeItem(root, null);
                        treeView.setRoot(rootItem);
                    });
                    return null;
                });
    }
    return treeView;
}
项目:nitrite-database    文件:NitriteHelper.java   
List<TreeItem<String>> getCollections() {
    Set<String> mapNames = dbStore.getMapNames();

    List<TreeItem<String>> treeItems = new ArrayList<>();
    mapNames.stream().filter(this::isCollection)
            .forEachOrdered(name -> {
                TreeItem<String> collectionItem = new TreeItem<>(name, getIcon("collection.png"));
                if (!name.contains(META_MAP_NAME)) {

                    TreeItem<String> indicesItem = new TreeItem<>("Indices");
                    indicesItem.getChildren().addAll(getIndices(mapNames, name));

                    TreeItem<String> metaItem = new TreeItem<>("Metadata");
                    metaItem.getChildren().add(getMeta(mapNames, name));

                    collectionItem.getChildren().add(indicesItem);
                    collectionItem.getChildren().add(metaItem);
                }
                treeItems.add(collectionItem);
            });
    return treeItems;
}
项目:marathonv5    文件:FunctionStage.java   
@Override public void changed(ObservableValue<? extends TreeItem<Object>> observable, TreeItem<Object> oldValue,
        TreeItem<Object> newValue) {
    if (newValue == null) {
        okButton.setDisable(true);
        documentArea.setText("");
        argumentPane.getChildren().clear();
        return;
    }
    TreeItem<Object> item = tree.getSelectionModel().getSelectedItem();
    String doc = "";
    boolean disable = true;
    functionItem = item;
    Object value = item.getValue();
    if (value instanceof Module) {
        doc = ((Module) value).getDocumentation();
    } else {
        doc = ((Function) value).getDocumentation();
        disable = false;
    }
    okButton.setDisable(disable);
    documentArea.setText(doc);
    argumentPane.getChildren().clear();
    if (item.isLeaf()) {
        addArguments(item);
    }
}
项目:jmonkeybuilder    文件:LayerNodeTree.java   
/**
 * Notify about removed a spatial.
 *
 * @param spatial the spatial.
 */
public void notifyRemoved(@NotNull final Spatial spatial) {
    spatial.depthFirstTraversal(child -> {

        final SceneLayer layer = SceneLayer.getLayer(child);
        if (layer == SceneLayer.NO_LAYER) return;

        final TreeItem<TreeNode<?>> newLayerItem = findItemForValue(getTreeView(), layer);
        final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), child);

        if (newLayerItem != null && treeItem != null) {
            newLayerItem.getChildren().remove(treeItem);
        }

    }, Spatial.DFSMode.POST_ORDER);
}
项目:OpenVSP3Plugin    文件:OpenVSP3File.java   
public void updateCompGeom(Map<String, String> map) throws Exception {
    compGeomContainer.getChildren().clear();
    String groupName = "";
    TreeItem<DesignVariableGroup> group = null;
    for (String key : map.keySet()) {
        String[] names = key.split(":");
        if (names.length == 3) {
            if (!groupName.equals(names[1])) {
                groupName = names[1];
                group = new TreeItem<>(new DesignVariableGroup(groupName));
                compGeomContainer.getChildren().add(group);
            }   
            if (group != null) addDesignVariable(compGeomContainer, group, names[2], names[0], "0", "", true);
        }
    }
}
项目:WebPLP    文件:ProjectExplorerTree.java   
private int getGlobalIndexOf(TreeItem<String> fileNode)
{
    TreeItem<String> root = projectTreeDisplay.getRoot();
    ObservableList<TreeItem<String>> projectNodes = root.getChildren();

    int index = 0;
    for (TreeItem<String> node : projectNodes)
    {
        if (node.equals(fileNode))
            return index;

        index++;
        for (TreeItem<String> child : node.getChildren())
        {
            if (child.equals(fileNode))
                return index;
            index++;
        }
    }

    throw new IllegalArgumentException(fileNode.getValue() + " not found in tree");
}
项目:jmonkeybuilder    文件:LayerNodeTree.java   
/**
 * Notify about added a spatial.
 *
 * @param spatial the spatial.
 */
public void notifyAdded(@NotNull final Spatial spatial) {
    spatial.depthFirstTraversal(child -> {

        final SceneLayer layer = SceneLayer.getLayer(child);
        if (layer == SceneLayer.NO_LAYER) return;

        final TreeItem<TreeNode<?>> newLayerItem = findItemForValue(getTreeView(), layer);
        final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), child);

        if (newLayerItem != null && treeItem == null) {
            final TreeNode<?> objectNode = FACTORY_REGISTRY.createFor(child);
            newLayerItem.getChildren().add(new TreeItem<>(objectNode));
        }

    }, Spatial.DFSMode.POST_ORDER);
}
项目:marathonv5    文件:CollatedTreeItem.java   
public CollatedTreeItem() {
    children = FXCollections.observableArrayList();
    filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
        @Override public boolean test(TreeItem<T> t) {
            return filter.test(t.getValue());
        }
    });
    sortedChildren = new SortedList<>(filteredChildren);
    ObservableList<TreeItem<T>> original = super.getChildren();
    sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
            while (c.next()) {
                original.removeAll(c.getRemoved());
                original.addAll(c.getFrom(), c.getAddedSubList());
            }
        }
    });
}
项目:marathonv5    文件:CollatedTreeItem.java   
public void setCollation() {
    if (comparator == null) {
        sortedChildren.setComparator(null);
    } else {
        sortedChildren.setComparator((o1, o2) -> comparator.compare(o1.getValue(), o2.getValue()));
    }
    if (filter == null) {
        filteredChildren.setPredicate(null);
    } else {
        filteredChildren.setPredicate(new Predicate<TreeItem<T>>() {
            @Override public boolean test(TreeItem<T> t) {
                return filter.test(t.getValue());
            }
        });
    }
}
项目:WebPLP    文件:OptionsSettingsTree.java   
/**
 * Fills sections treeview with passed in sectionsList
 *
 * @param sectionsList
 */
private void populateSectionsTree( Set<OptionSection> sectionsList )
{
    for ( OptionSection section : sectionsList )
    {
        //TODO this feels disgusting. Fix this
        if ( !section.getFullPath().contains(".") )
        {
            TreeItem<String> sectionItem = new TreeItem<>(section.getName());
            if ( section.size() > 0 )
                sectionItem.getChildren().addAll(getSectionChildren(section));

            sections.getRoot().getChildren().add(sectionItem);
        }
    }
}
项目:marathonv5    文件:TestRunner.java   
public void onNextFailure() {
    if (testTree.getRoot() == null) {
        return;
    }
    TreeItem<Test> item = testTree.getSelectionModel().getSelectedItem();
    TestTreeItem nextFailure = null;
    if (item != null) {
        if (item.isLeaf()) {
            nextFailure = findNextFailureInSiblings((TestTreeItem) item);
        } else {
            nextFailure = findNextFailureInChildren((TestTreeItem) item, true);
        }
    } else {
        nextFailure = findNextFailureInChildren((TestTreeItem) testTree.getRoot(), false);
    }
    if (nextFailure == null) {
        return;
    }
    isExpandNeeded(nextFailure);
    int failureIndex = testTree.getRow(nextFailure);
    testTree.getSelectionModel().clearAndSelect(failureIndex);
    testTree.scrollTo(failureIndex);
}
项目:marathonv5    文件:TestRunner.java   
private TestTreeItem findNextFailureInChildren(TestTreeItem parent, boolean findInSibling) {
    TestTreeItem found = null;
    for (TreeItem<Test> child : parent.getChildren()) {
        if (child.isLeaf()
                && (((TestTreeItem) child).getState() == State.FAILURE || ((TestTreeItem) child).getState() == State.ERROR)) {
            found = (TestTreeItem) child;
            break;
        } else {
            found = findNextFailureInChildren((TestTreeItem) child, findInSibling);
            if (found != null) {
                break;
            }
        }
    }
    if (found == null && findInSibling) {
        TestTreeItem sib = (TestTreeItem) parent.nextSibling();
        if (isFailure(sib)) {
            found = sib;
        } else {
            if (sib != null) {
                found = findNextFailureInChildren(sib, true);
            }
        }
    }
    return found;
}
项目:WebPLP    文件:OptionsSettingsTree.java   
/**
 * Retrieval of respective tree item {@link OptionSection} and its most root parent.
 * Then use of BiConsumer onSectionDoubleClicked.
 *
 * @param event
 */
private void onTreeClick( MouseEvent event )
{
    if ( event.getClickCount() == 2 )
    {
        TreeItem<String> selectionItem = sections.getSelectionModel().getSelectedItem();

        if ( onSectionDoubleClicked != null && selectionItem != null )
        {
            TreeItem<String> rootParentItem = findRootParent(selectionItem);

            OptionSection rootParent = getOptionFromTree(rootParentItem.getValue());
            OptionSection selection = getOptionFromTree(rootParent, findChildFullPath(selectionItem));

            onSectionDoubleClicked.accept(selection, rootParent);
        }
    }
}
项目:marathonv5    文件:AssertionTreeView.java   
@Override public ObservableList<TreeItem<AssertionTreeView.PropertyWrapper>> getChildren() {
    if (done) {
        return super.getChildren();
    }
    done = true;
    ArrayList<TreeItem<AssertionTreeView.PropertyWrapper>> r = new ArrayList<>();
    Object object = getValue().value;
    if (object instanceof List) {
        fillListValues((List<?>) object, r);
    }
    if (object instanceof Map) {
        fillMapValues((Map<?, ?>) object, r);
    } else if (object.getClass().isArray()) {
        fillArrayValues(object, r);
    } else if (object instanceof Collection<?>) {
        fillCollectionValues((Collection<?>) object, r);
    } else {
        fillObjectValues(object, r);
    }
    super.getChildren().setAll(r);
    return super.getChildren();
}
项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
private String getTreeItemText(TreeItem<?> lastPathComponent) {
    if (lastPathComponent == null || lastPathComponent.getValue() == null) {
        return "";
    }
    String original = lastPathComponent.getValue().toString();
    String itemText = original;
    int suffixIndex = 0;
    TreeItem<?> parent = lastPathComponent.getParent();
    if (parent == null)
        return itemText;
    ObservableList<?> children = parent.getChildren();
    for (int i = 0; i < children.indexOf(lastPathComponent); i++) {
        TreeItem<?> child = (TreeItem<?>) children.get(i);
        String current = child.getValue().toString();
        if (current.equals(original)) {
            itemText = String.format("%s(%d)", original, ++suffixIndex);
        }
    }
    return itemText;
}
项目:keyboard-light-composer    文件:LayerBaseTreeCell.java   
private void droppedOnTreeItem(DragEvent event,
        TreeItem<LayerBaseContainer<? extends LayerBase>> currentlyDraggedLayerTreeItem,
        LayerBaseContainer<? extends LayerBase> targetItem) {
    LayerBase targetLayer = targetItem.getLayerBase();

    double y = event.getY();
    double height = getHeight();
    boolean above = y < height / 2;

    TreeItem<LayerBaseContainer<? extends LayerBase>> targetParent = this.getTreeItem().getParent();
    ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> targetParentChildren = targetParent
            .getChildren();

    TreeItem<LayerBaseContainer<? extends LayerBase>> draggedItem = currentlyDraggedLayerTreeItem;
    TreeItem<LayerBaseContainer<? extends LayerBase>> draggedParent = draggedItem.getParent();
    ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> draggedParentChildren = draggedParent != null
            ? draggedParent.getChildren() : null;

    if (targetLayer instanceof EffectGroupLayer && (y >= height / 4 && y < height * 3 / 4)) {
        // inside group
        ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> groupChildren = getTreeItem()
                .getChildren();
        if (!groupChildren.equals(draggedParentChildren)) {
            if (draggedParentChildren != null) {
                draggedParentChildren.remove(draggedItem);
            }
            DelayedExecuter.execute(100, () -> groupChildren.add(0, draggedItem));
        }
    } else {
        if (draggedParentChildren != null) {
            ListItemUtil.swapItemsJavaFxThread(draggedParentChildren, targetParentChildren, draggedItem, this.getTreeItem(),
                    above);
        } else {
            ListItemUtil.insertItem(targetParentChildren, draggedItem, this.getTreeItem(), above);
        }
    }
}
项目:jmonkeybuilder    文件:AssetEditorDialog.java   
/**
 * Handle selecting file event.
 */
@FXThread
private void processEvent(@NotNull final RequestSelectFileEvent event) {

    final Path file = event.getFile();

    final ResourceTree resourceTree = getResourceTree();
    final ResourceElement element = createFor(file);
    final TreeItem<ResourceElement> treeItem = findItemForValue(resourceTree.getRoot(), element);

    if (treeItem == null) {
        getWaitedFilesToSelect().add(file);
        return;
    }

    resourceTree.expandTo(treeItem, true);
}
项目:marathonv5    文件:ChoiceBoxTreeViewSample.java   
public ChoiceBoxTreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 1"), new TreeItem<String>("Option 2"),
            new TreeItem<String>("Option 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 4"),
            new TreeItem<String>("Option 5"), new TreeItem<String>("Option 6")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);
    treeView.setEditable(true);
    treeView.setCellFactory(ChoiceBoxTreeCell.forTreeView(items));

    getChildren().add(treeView);
}
项目:marathonv5    文件:TreeViewSample.java   
public TreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(
            new TreeItem<String>("Child Node 1"),
            new TreeItem<String>("Child Node 2"),
            new TreeItem<String>("Child Node 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(
            new TreeItem<String>("Child Node 4"),
            new TreeItem<String>("Child Node 5"),
            new TreeItem<String>("Child Node 6"),
            new TreeItem<String>("Child Node 7"),
            new TreeItem<String>("Child Node 8"),
            new TreeItem<String>("Child Node 9"),
            new TreeItem<String>("Child Node 10"),
            new TreeItem<String>("Child Node 11"),
            new TreeItem<String>("Child Node 12")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);

    getChildren().add(treeView);
}
项目:marathonv5    文件:AssertionTreeView.java   
@Override
public ObservableList<TreeItem<AssertionTreeView.PropertyWrapper>> getChildren() {
    if (done)
        return super.getChildren();
    done = true;
    ArrayList<TreeItem<AssertionTreeView.PropertyWrapper>> r = new ArrayList<>();
    Object object = getValue().value;
    if (object instanceof List)
        fillListValues((List) object, r);
    if (object instanceof Map)
        fillMapValues((Map) object, r);
    else if (object.getClass().isArray())
        fillArrayValues(object, r);
    else
        fillObjectValues(object, r);
    super.getChildren().setAll(r);
    return super.getChildren();
}
项目:marathonv5    文件:ComboBoxTreeTableSample.java   
private void updateObservableListProperties(TreeTableColumn<Employee, String> empColumn) {
    empColumn.setOnEditCommit(new EventHandler<TreeTableColumn.CellEditEvent<Employee, String>>() {

        @Override public void handle(CellEditEvent<Employee, String> t) {
            TreeItem<Employee> treeItem = t.getTreeTableView().getTreeItem(t.getTreeTablePosition().getRow());
            treeItem.getValue().setName(t.getNewValue());
        }
    });
}
项目:Squid    文件:SessionAuditController.java   
/**
 * Displays all nodes in the tree starting from the root. 
 * Displays only duplicate spot tree if showDupesOnly is true. Displays entire spot tree if hasBeenChecked is false.
 * @param parentItem the root item for this tree
 * @param squidPrefixTree the current instance of SquidPrefixTree
 * @param showDupesOnly implies both that SquidPrefixTree has duplicates, and that the CheckBox has been checked
 */
private void populatePrefixTreeView(TreeItem<String> parentItem, SquidPrefixTree squidPrefixTree, boolean showDupesOnly) {

    List<SquidPrefixTree> children = squidPrefixTree.getChildren();

    for (int i = 0; i < children.size(); i++) {
        if (!children.get(i).isleaf()) {
            TreeItem<String> childItem
                    = new TreeItem<>(children.get(i).getStringValue()
                            + children.get(i).buildSummaryDataString()
                    );
            if(showDupesOnly){
                if(children.get(i).getCountOfDups() > 0){
                    parentItem.getChildren().add(childItem);
                }
            }
            else{
                parentItem.getChildren().add(childItem);
            }

            if (children.get(i).hasChildren()) {
                populatePrefixTreeView(childItem, children.get(i), showDupesOnly);
            }

        } else {
            parentItem.setValue(children.get(i).getParent().getStringValue()
                    + " Dups=" + String.format("%1$ 2d", children.get(i).getParent().getCountOfDups())
                    + " Species=" + String.format("%1$ 2d", children.get(i).getCountOfSpecies())
                    + " Scans=" + String.format("%1$ 2d", children.get(i).getCountOfScans())
                    + ((String) (children.size() > 1 ? " ** see duplicates below **" : ""))
            );
        }
    }
}
项目:MythRedisClient    文件:MyTreeItem.java   
/**
 * 设置所有孩子节点的上下文菜单.
 * @param menu 上下文菜单
 */
public void setNextContextMenu(ContextMenu menu) {
    ObservableList<TreeItem<T>> items = this.getChildren();
    for (TreeItem item : items) {
        ((Label)item.getValue()).setContextMenu(menu);
    }
}
项目:Coconut-IDE    文件:HighlightCell.java   
private static List<TreeItem<Path>> getAllTreeItems(TreeItem<Path> root) {
    List<TreeItem<Path>> treeItems = new ArrayList<>();
    if (root.equals(treeView.getRoot())) {
        treeItems.add(root);
    }

    for (TreeItem<Path> child : root.getChildren()) {
        treeItems.add(child);
        if (!child.getChildren().isEmpty()) {
            treeItems.addAll(getAllTreeItems(child));
        }
    }

    return treeItems;
}
项目:MythRedisClient    文件:CreateKeyMenu.java   
/**
 * 点击处理方法.
 *
 * @param treeView treeView
 */
@Override
protected void setAction(TreeView treeView) {
    super.setOnAction(
        (event) -> {
            TreeItem<Label> item = (TreeItem) treeView.getSelectionModel().getSelectedItem();
            String flag = item.getValue().getAccessibleHelp();
            if ("db".equals(flag)) {
                showPanel(treeView, item);
            }
        }
    );
}
项目:WebPLP    文件:OptionsSettingsTree.java   
/**
 * Find path for {@link OptionSection} for use in retrieving correct {@link OptionSection} from {@link
 * OptionsSettingsTree#optionSet}.
 *
 * @param selection
 * @param childPath
 *
 * @return
 */
private String findChildFullPath( TreeItem<String> selection, String childPath )
{
    TreeItem<String> parent = selection.getParent();
    if ( parent != null && parent.getValue().length() > 0 )
        return findChildFullPath(parent, Joiner.on(".").join(parent.getValue(), childPath));
    else if ( parent.getValue().length() <= 0 )
        return childPath;
    else
        throw new IllegalArgumentException(
                "OptionsSettingsTree does not support a null root or a root with a value");
}
项目:OpenVSP3Plugin    文件:OpenVSP3File.java   
private void addContainer(TreeItem<DesignVariableGroup> container, String prefix) throws Exception {
    NodeList nodes = xpu.getElementNode(prefix).getChildNodes();
    for (int i = 1; i <= nodes.getLength(); i++) {
        Node node = nodes.item(i);
        if (node != null) {
            String group = node.getNodeName();
            if (group.equals("ID") || group.equals("Name") || group.equals("#text")) continue;
            addGroup(container, node, prefix + "/" + group);
        }
    }
}
项目:plep    文件:DeleteSubtaskCommand.java   
@Override
protected void executionHook() {
    if (treeViewItems.isEmpty()) {
        throw new IllegalStateException("cannot delete item from empty treeview");
    }

    // Flatten the list to use the index.
    List<HomeworkTask> flattenedList = treeViewItems.stream()
            .flatMap(Collection::stream)
            .collect(Collectors.toList());

    deletedTask = flattenedList.get(indexState);

    // Remove task from saved state.
    for (int i = 0; i < treeViewItems.size(); i++) {
        List<HomeworkTask> taskList = treeViewItems.get(i);
        if (taskList.contains(deletedTask)) {
            parentIndex = i;
            // Subtract one because the parent is the first item in the list.
            indexWithinParent = taskList.indexOf(deletedTask) - 1;
            taskList.remove(deletedTask);
        }
    }

    if (tree != null) {
        TreeItem<HomeworkTask> parent = tree.getRoot().getChildren().get(parentIndex);
        parent.getChildren().remove(indexWithinParent);

        controller.updateDatabase(dayState, treeViewItems);
        controller.cleanUp(tree);
    }
}
项目:plep    文件:DeleteSubtaskCommand.java   
@Override
protected void undoHook() {
    // We add one to the index because the first one in the list is the parent task, and we count from there.
    treeViewItems.get(parentIndex).add(indexWithinParent+1, deletedTask);

    // Tree will be null when testing
    if (tree != null) {
        TreeItem<HomeworkTask> parent = tree.getRoot().getChildren().get(parentIndex);
        parent.getChildren().add(indexWithinParent, new TreeItem<>(deletedTask));

        controller.updateDatabase(dayState, treeViewItems);
        controller.cleanUp(tree);
    }
}
项目:Coconut-IDE    文件:CustomTreeItem.java   
@Override
public ObservableList<TreeItem<Path>> getChildren() {
    if (isFirstTimeChildren) {
        isFirstTimeChildren = false;
        super.getChildren().setAll(buildChildren());
    }

    return super.getChildren();
}
项目:cayenne-modeler    文件:DataDomainTreeItem.java   
public DataDomainTreeItem(final DataDomainAdapter dataDomainAdapter, final TreeItem<String> treeRoot)
//    public DataDomainTreeItem(final DataDomainAdapter dataDomainAdapter, final TreeItem<CayenneTreeItem<String>> treeRoot)
//    public DataDomainTreeItem(final DataDomainAdapter dataDomainAdapter)
    {
        this.dataDomainAdapter = dataDomainAdapter;

        valueProperty().bindBidirectional(dataDomainAdapter.nameProperty());
        setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.DATABASE, TREE_ICON_SIZE));
        treeRoot.getChildren().add(this);
        setExpanded(true);
    }
项目:marathonv5    文件:NavigatorPanel.java   
public VLToolBar createToolbar(ResourceView resourceView) {
    VLToolBar toolbar = new VLToolBar();
    Button expandAll = FXUIUtils.createButton("expandAll", "Expand the resource tree");
    expandAll.setOnAction((event) -> resourceView.expandAll());
    toolbar.add(expandAll);
    Button collapseAll = FXUIUtils.createButton("collapseAll", "Collapse the resource tree");
    collapseAll.setOnAction((event) -> resourceView.collapseAll());
    toolbar.add(collapseAll);
    toolbar.add(new Separator(javafx.geometry.Orientation.VERTICAL));
    Button cut = FXUIUtils.createButton("cut", "Cut the selected content to clipboard");
    cut.setOnAction((event) -> resourceView.cut());
    toolbar.add(cut);
    Button copy = FXUIUtils.createButton("copy", "Copy the selected content to clipboard");
    copy.setOnAction((event) -> resourceView.copy());
    toolbar.add(copy);
    Button paste = FXUIUtils.createButton("paste", "Paste clipboard contents");
    paste.setOnAction((event) -> resourceView.paste());
    toolbar.add(paste);
    ListChangeListener<? super TreeItem<Resource>> listener = new ListChangeListener<TreeItem<Resource>>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<Resource>> c) {
            cut.setDisable(resourceView.getSelectionModel().getSelectedItems().size() <= 0);
            copy.setDisable(resourceView.getSelectionModel().getSelectedItems().size() <= 0);
            paste.setDisable(resourceView.getSelectionModel().getSelectedItems().size() != 1);
        }
    };
    resourceView.getSelectionModel().getSelectedItems().addListener(listener);
    return toolbar;
}
项目:marathonv5    文件:MarathonFileChooser.java   
private void onNewFolder() {
    MarathonInputStage testNameStage = new MarathonInputStage("Folder name", "Create a new folder",
            FXUIUtils.getIcon("fldr_closed")) {

        @Override protected String validateInput(String name) {
            String errorMessage = null;
            if (name.length() == 0 || name.trim().isEmpty()) {
                errorMessage = "Enter a valid name";
            }
            return errorMessage;
        }

        @Override protected String getInputFiledLabelText() {
            return "Enter a folder name: ";
        }

        @Override protected void setDefaultButton() {
            okButton.setDefaultButton(true);
        }
    };
    FolderNameHandler testNameHandler = new FolderNameHandler();
    testNameStage.setInputHandler(testNameHandler);
    testNameStage.getStage().showAndWait();
    TreeItem<File> selectedItem = parentTreeView.getSelectionModel().getSelectedItem();
    String testName = testNameHandler.getTestName();
    if (testName == null || "".equals(testName)) {
        return;
    }
    File file = new File(selectedItem.getValue(), testName);
    if (file.exists()) {
        FXUIUtils.showMessageDialog(getStage(), "Folder with name '" + testName + "' already exists.", "File exists",
                AlertType.INFORMATION);
    } else {
        selectedItem.getChildren().add(new TreeItem<File>(file));
        if (!file.mkdir()) {
            FXUIUtils.showMessageDialog(getStage(), "Couldn't create folder with name '" + testName + "'", "Creation Fail",
                    AlertType.ERROR);
        }
    }
}
项目:marathonv5    文件:MarathonFileChooser.java   
private void populateChildren(File root, TreeItem<File> rootItem) {
    ObservableList<TreeItem<File>> children = rootItem.getChildren();
    File[] files = root.listFiles();
    if (files != null) {
        for (File file : files) {
            if (!file.getName().contains(".") && file.isDirectory()) {
                TreeItem<File> item = new TreeItem<File>(file);
                children.add(item);
                populateChildren(file, item);
            }
        }
    }
}
项目:marathonv5    文件:ProjectGroupResource.java   
@Override public ObservableList<TreeItem<Resource>> getChildren() {
    ObservableList<TreeItem<Resource>> original = super.getChildren();
    if (loaded) {
        return original;
    }
    loadGroups();
    return original;
}
项目:marathonv5    文件:TreeViewSample.java   
private CheckBoxTreeItem<File> buildNode(File file) {
    CheckBoxTreeItem<File> node = new CheckBoxTreeItem<File>(file);
    if (file.isDirectory()) {
        ObservableList<TreeItem<File>> children = node.getChildren();
        File[] listFiles = file.listFiles();
        for (File f : listFiles) {
            children.add(buildNode(f));
        }
    }
    return node;
}
项目:LIRE-Lab    文件:CollectionTree.java   
private TreeItem<String> buildCollectionItem(Collection collection) {
    TreeItem<String> collectionItem = createCollectionItem(collection);

    for (Image image : collection.getImages()) {
        TreeItem<String> imageItem = createImageItem(image.getImagePath());
        imageMap.put(imageItem, image);
        addImageItemToCollectionItem(collectionItem, imageItem);
    }

    return collectionItem;
}