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

项目:marathonv5    文件:JavaFXTreeViewCheckBoxTreeCellElementTest.java   
@Test public void selectTreeItemCheckBoxSelectedSelected() {
    TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeViewNode.getTreeItem(2);
    treeItem.setSelected(true);
    JSONObject o = new JSONObject();
    o.put("select", "/Root node/Child Node 2");
    IJavaFXElement item = treeView.findElementByCssSelector(".::select-by-properties('" + o.toString() + "')");
    IJavaFXElement cb = item.findElementByCssSelector(".::editor");
    cb.marathon_select("Child Node 2:checked");
    new Wait("Wait for tree item check box to be selected") {
        @Override public boolean until() {
            String selected = cb.getAttribute("selected");
            return selected.equals("true");
        }
    };
}
项目:marathonv5    文件:JavaFXTreeViewCheckBoxTreeCellElementTest.java   
@Test public void selectTreeItemCheckBoxSelectedNotSelected() {
    TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeViewNode.getTreeItem(2);
    treeItem.setSelected(true);
    JSONObject o = new JSONObject();
    o.put("select", "/Root node/Child Node 2");
    IJavaFXElement item = treeView.findElementByCssSelector(".::select-by-properties('" + o.toString() + "')");
    IJavaFXElement cb = item.findElementByCssSelector(".::editor");
    cb.marathon_select("Child Node 2:unchecked");
    new Wait("Wait for tree item check box to be deselected") {
        @Override public boolean until() {
            String selected = cb.getAttribute("selected");
            return selected.equals("false");
        }
    };
}
项目:marathonv5    文件:CheckBoxTreeViewSample.java   
public CheckBoxTreeViewSample() {
    final CheckBoxTreeItem<String> treeRoot = new CheckBoxTreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new CheckBoxTreeItem<String>("Child Node 1"),
            new CheckBoxTreeItem<String>("Child Node 2"), new CheckBoxTreeItem<String>("Child Node 3")));

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

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

    getChildren().add(treeView);
}
项目:marathonv5    文件:RFXTreeViewCheckBoxTreeCellTest.java   
@Test public void select() {
    TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            Point2D point = getPoint(treeView, 1);
            RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
            rfxListView.focusGained(rfxListView);
            CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
            treeItem.setSelected(true);
            rfxListView.focusLost(rfxListView);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Child Node 1:checked", recording.getParameters()[0]);
}
项目:marathonv5    文件:RFXTreeViewCheckBoxTreeCellTest.java   
@Test public void selectSelectedTreeItemCheckBox() {
    TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            Point2D point = getPoint(treeView, 1);
            RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
            CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
            treeItem.setSelected(true);
            rfxListView.focusGained(rfxListView);
            treeItem.setSelected(false);
            rfxListView.focusLost(rfxListView);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Child Node 1:unchecked", recording.getParameters()[0]);
}
项目:Kramer    文件:SchemaView.java   
private CheckBoxTreeItem<String> buildItem(Relation node) {
    final CheckBoxTreeItem<String> item = new CheckBoxTreeItem<String>(node.getLabel());
    item.setExpanded(true);
    item.setIndependent(true);
    item.setSelected(!node.isFold());
    item.selectedProperty()
        .addListener((o, p, c) -> {
            node.setFold(!c);
        });
    node.getChildren()
        .stream()
        .filter(c -> c instanceof Relation)
        .map(c -> (Relation) c)
        .forEach(c -> {
            item.getChildren()
                .add(buildItem(c));
        });
    return item;
}
项目:JGitFX    文件:GitFileStatusTreeCell.java   
public GitFileStatusTreeCell() {
    super(
            treeItem -> ((CheckBoxTreeItem<ModifiedPath>) treeItem).selectedProperty(),
            CONVERTER
    );

    getStyleClass().add("git-file-status-tree-cell");

    // set up pseudo style classes
    unchanged   = new SimpleBooleanProperty(false);
    added       = new SimpleBooleanProperty(false);
    modified    = new SimpleBooleanProperty(false);
    removed     = new SimpleBooleanProperty(false);

    unchanged   .addListener(c -> pseudoClassStateChanged(UNCHANGED,    unchanged.get()));
    added       .addListener(c -> pseudoClassStateChanged(ADDED,        added.get()));
    modified    .addListener(c -> pseudoClassStateChanged(MODIFIED,     modified.get()));
    removed     .addListener(c -> pseudoClassStateChanged(REMOVED,      removed.get()));
}
项目:CloudRaid-DesktopApp    文件:SyncManagerController.java   
private void setTreeChildren(CheckBoxTreeItem<FileItem> parent){
    FileItem parentItem = parent.getValue();
    CopyOnWriteArrayList<FileItem> items = new CopyOnWriteArrayList<>(dataManager.getContent(parentItem));
    for (FileItem i :items) {
        if (i.isDir()){
            CheckBoxTreeItem<FileItem> item = new CheckBoxTreeItem<>(i);

            parent.getChildren().add(item);
            setTreeChildren(item);
            if (i.isSync()){
                /*
                нельзя сразу сделать setSelected(true) для элемента
                ибо к ним не привяжется слушатель. Поэтому вначале добавляю их в список
                и после инициализации TreeView делаю их selected
                 */
                selected.add(item);
            }
        }


    }
}
项目:openjfx-8u-dev-tests    文件:CheckBoxTreeItemTest.java   
protected void selectionChecker(final Boolean selected) {
    tree.waitState(new State<Boolean>() {
        public Boolean reached() {
            final Lookup<CheckBoxTreeItem> lookup = treeAsParent.lookup(CheckBoxTreeItem.class, new LookupCriteria<CheckBoxTreeItem>() {
                public boolean check(CheckBoxTreeItem item) {
                    return getLevel(item) > 0;
                }
            });
            for (int i = 0; i < lookup.size(); i++) {
                final int _i = i;
                if (selected != new GetAction<Boolean>() {
                    @Override
                    public void run(Object... os) throws Exception {
                        setResult(lookup.get(_i).isSelected());
                    }
                }.dispatch(tree.getEnvironment())) {
                    return Boolean.FALSE;
                }
            }
            return Boolean.TRUE;
        }
    }, Boolean.TRUE);
}
项目:ariADDna    文件:SyncSettingsController.java   
/**
 * Native init method.
 * Create VUFS folders tree view
 * @param location
 * @param resources
 */
@Override
public void initialize(URL location, ResourceBundle resources) {
    //TODO: replace to getting elements from Repository
    CheckBoxTreeItem<String> root = new CheckBoxTreeItem<>("Root");
    root.setExpanded(true);
    CheckBoxTreeItem<String> folder1 = new CheckBoxTreeItem<>("Folder1");
    folder1.getChildren().addAll(
            new CheckBoxTreeItem<>("MyFoto"),
            new CheckBoxTreeItem<>("OtherFiles")
    );
    root.getChildren().addAll(
            folder1,
            new CheckBoxTreeItem<>("Documents"),
            new CheckBoxTreeItem<>("WorkFiles"),
            new CheckBoxTreeItem<>("Projects"));

    // Create the CheckTreeView with the data
    final CheckTreeView<String> checkTreeView = new CheckTreeView<>(root);
    checkTreeView.getCheckModel().getCheckedItems().addListener((ListChangeListener<TreeItem<String>>) c -> {
        System.out.println(checkTreeView.getCheckModel().getCheckedItems());
    });
    checkTreeView.setId("sync-tree-view");
    container.getChildren().add(checkTreeView);
}
项目:jfx-torrent    文件:TorrentContentTreeRow.java   
private void onPriorityAction(final RadioMenuItem priorityMenuItem) {
    final CheckBoxTreeItem<TorrentFileEntry> treeItem = (CheckBoxTreeItem<TorrentFileEntry>)getTreeItem();
    final FilePriority newPriorityValue = FilePriority.values()[Integer.parseInt(priorityMenuItem.getId())];
    if(treeItem.getValue().getPriority() != newPriorityValue) { 
        if(treeItem.isIndeterminate()) {
            treeItem.setSelected(true);
            treeItem.getValue().selectedProperty().set(newPriorityValue != FilePriority.SKIP);
        }
        else {
            treeItem.setSelected(newPriorityValue != FilePriority.SKIP);
        }

        if(!treeItem.isLeaf()) {
            fileTreeViewer.onUpdateChildrenPriority(treeItem, newPriorityValue);
        }
        treeItem.getValue().priorityProperty().set(newPriorityValue);
        fileTreeViewer.onUpdateParentPriority(treeItem.getParent());
        fileTreeViewer.selectItem(treeItem);
    }
}
项目:Elegit    文件:WorkingTreePanelView.java   
private void addNewRepoFile(RepoFile repoFile, CheckBoxTreeItem<RepoFile> newItem, TreeItem<RepoFile> root) {
    Path pathToParent = repoFile.getFilePath().getParent();
    if (pathToParent != null) {
        // Check if the file should be added to an existing directory
        CheckBoxTreeItem<RepoFile> parentDirectory = null;
        for (TreeItem<RepoFile> directory : root.getChildren()) {
            if (!directory.equals(checkBox) && directory.getValue().toString().equals(pathToParent.toString())) {
                parentDirectory = (CheckBoxTreeItem<RepoFile>) directory;
                break;
            }
        }
        if (parentDirectory == null) {
            // Create a new directory and add it to the root
            DirectoryRepoFile parent = new DirectoryRepoFile(pathToParent, this.sessionModel.getCurrentRepoHelper());
            parent.setShowFullPath(true);
            parentDirectory = new CheckBoxTreeItem<>(parent);
            parentDirectory.setExpanded(true);
            root.getChildren().add(parentDirectory);
        }
        parentDirectory.getChildren().add(newItem);
    } else {
        root.getChildren().add(newItem);
    }
}
项目:marathonv5    文件:TreeViewSample.java   
public TreeViewSample() {
    String dir = "./src";
    final CheckBoxTreeItem<File> treeRoot = buildRoot(dir);

    treeView = new TreeView<File>();
    treeView.setCellFactory(CheckBoxTreeCell.<File> forTreeView());
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);

    getChildren().add(treeView);
}
项目: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;
}
项目:JGitFX    文件:SelectableFileViewer.java   
private void buildRoot() {
    root.getChildren().clear();

    for (ModifiedPath firstLevelPath : getNamesAtIndex(0)) {
        CheckBoxTreeItem<ModifiedPath> firstLevelItem = new CheckBoxTreeItem<>(firstLevelPath);
        if (changedFiles.contains(firstLevelPath)) {
            fileSelectionStates.add(Tuples.t(firstLevelPath, firstLevelItem.selectedProperty()));
        } else {
            buildTreeRecursively(firstLevelPath, firstLevelItem, 1);
        }
        selectAndExpandTreeItem(firstLevelItem);
        root.getChildren().add(firstLevelItem);
    }
}
项目:CloudRaid-DesktopApp    文件:SyncManagerController.java   
private void initTreeView(){

        CheckBoxTreeItem<FileItem> root = new CheckBoxTreeItem<>( dataManager.getRoot());
        setTreeChildren(root);
        treeView = new CheckTreeView<>(root);
        treeViewPane.getChildren().add(treeView);
        root.setExpanded(true);
        treeView.setShowRoot(true);
        treeView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        treeView.getCheckModel().getCheckedItems().addListener(this::onCheckListener);
        selected.forEach(item -> item.setSelected(true));

    }
项目:openjfx-8u-dev-tests    文件:CheckBoxTreeItemTest.java   
@Before
public void setUp() {
    parent.lookup(Button.class, new ByID<Button>(CheckBoxTreeItemApp.RESET_SCENE_BTN_ID)).wrap().mouse().click();
    new TreeViewTest().expand(treeAsParent.lookup());

    treeAsSelectable.selector().select(treeAsSelectable.getStates().get(0));
    Wrap<? extends TreeItem> item = treeAsParent.lookup(new LookupCriteria<TreeItem>() {
        public boolean check(TreeItem cntrl) {
            return treeAsSelectable.getStates().get(0).equals(cntrl);
        }
    }).wrap();
    propertyTableHelper = new PropertyGridHelper<CheckBoxTreeItem>((Wrap<? extends CheckBoxTreeItem>) item, parent.lookup(PropertyCheckingGrid.class).wrap());
}
项目:openjfx-8u-dev-tests    文件:CheckBoxTreeItemTest.java   
protected void checkChildDependency(boolean select) {
    Lookup<CheckBoxTreeItem> lookup = levelLookup(CheckBoxTreeItemApp.DATA_ITEMS_DEPTH);
    for (int i = 0; i < lookup.size(); i++) {
        Wrap<? extends CheckBox> check = lookup.wrap(i).as(Parent.class, Node.class).lookup(CheckBox.class).wrap();
        check.as(Selectable.class, Boolean.class).selector().select(select);
    }
    selectionChecker(select);
}
项目:openjfx-8u-dev-tests    文件:CheckBoxTreeItemTest.java   
protected Lookup<CheckBoxTreeItem> levelLookup(final int level) {
    return treeAsParent.lookup(CheckBoxTreeItem.class, new LookupCriteria<CheckBoxTreeItem>() {
        public boolean check(CheckBoxTreeItem item) {
            return getLevel(item) == level;
        }
    });
}
项目:openjfx-8u-dev-tests    文件:CheckBoxTreeApp.java   
protected void addLevel(CheckBoxTreeItem<String> parent, int level) {
    if (level == 0) {
        return;
    }
    for (int i = 0; i < DATA_ITEMS_SIZE; i++) {
        final CheckBoxTreeItem<String> checkBoxTreeItem = new CheckBoxTreeItem<String>("DataItem " + i + " Level " + (DATA_ITEMS_DEPTH - level));
        parent.getChildren().add(checkBoxTreeItem);
        addLevel(checkBoxTreeItem, level - 1);
    }
}
项目:jfx-torrent    文件:TorrentContentTreeRow.java   
private void onUnselectAction() {
    final CheckBoxTreeItem<TorrentFileEntry> checkBoxItem = (CheckBoxTreeItem<TorrentFileEntry>)getTreeItem();
    if(checkBoxItem.isIndeterminate()) {
        checkBoxItem.setSelected(true);
    }
    getItem().setSelected(false);
    selectMenuItem.setDisable(false);
}
项目:jfx-torrent    文件:TorrentContentTreeRow.java   
private void onSelectAction() {
    final CheckBoxTreeItem<TorrentFileEntry> checkBoxItem = (CheckBoxTreeItem<TorrentFileEntry>)getTreeItem();
    if(checkBoxItem.isIndeterminate()) {
        checkBoxItem.setSelected(false);
    }
    getItem().setSelected(true);
    unselectMenuItem.setDisable(false);
}
项目:jfx-torrent    文件:FileTreeViewer.java   
/**
 * Handler for deselection of all torrent file entries
 */
public void deselectAllEntries() {
    final int selectedIndex = currentTree.getSelectionModel().getSelectedIndex();
    currentTree.getRoot().getChildren().forEach(child -> {
        final CheckBoxTreeItem<TorrentFileEntry> checkBoxItem = (CheckBoxTreeItem<TorrentFileEntry>)child;
        if(checkBoxItem.isIndeterminate()) {
            checkBoxItem.setSelected(true);
        }
        child.getValue().selectedProperty().set(false);
    });
    currentTree.getSelectionModel().select(selectedIndex);
}
项目:jfx-torrent    文件:FileTreeViewer.java   
/**
 * Update the children when their parent's priority changes
 *
 * @param parent Parent for which the priority has been changed
 * @param priority New priority
 */
protected void onUpdateChildrenPriority(final TreeItem<TorrentFileEntry> parent, final FilePriority priority) {
    parent.getChildren().forEach(c -> {
        final CheckBoxTreeItem<TorrentFileEntry> child = (CheckBoxTreeItem<TorrentFileEntry>)c;
        if(!child.isLeaf()) {
            onUpdateChildrenPriority(child, priority);
        }
        final boolean isSelected = child.isSelected();
        child.setSelected(!isSelected && priority != FilePriority.SKIP ||
                isSelected && priority == FilePriority.SKIP || isSelected);
        child.getValue().setPriority(priority);
    });
}
项目:jfx-torrent    文件:FileTreeViewer.java   
private TreeItem<TorrentFileEntry> buildSingleFileTree(final FileTree fileTree) {
    final String fileName = fileTree.getName();
    final long fileLength = fileTree.getLength();
    final TorrentFileEntry fileEntry = new TorrentFileEntry(fileName, ". (current path)",
            fileLength, true, ImageUtils.getFileTypeImage(fileName));
    fileEntry.setPieceCount((long)Math.ceil(fileLength / fileTree.getPieceLength()));
    fileEntry.setFirstPiece(0);

    final TreeItem<TorrentFileEntry> treeItem = initTreeItem(fileEntry);
    final CheckBoxTreeItem<TorrentFileEntry> root = new CheckBoxTreeItem<>(new TorrentFileEntry(
            "root", ". (current path)", fileLength, true, null));
    root.getChildren().add(treeItem);

    fileEntry.selectedProperty().addListener((obs, oldV, newV) -> {
        root.getValue().updateSelectionLength(newV? fileLength : -fileLength);
        fileTree.setFilePriority(fileTree.getFiles().get(0), newV?
                FilePriority.NORMAL : FilePriority.SKIP, false);
    });

    fileEntry.priorityProperty().addListener((obs, oldV, newV) ->
            fileTree.setFilePriority(fileTree.getFiles().get(0), newV, true));

    final FilePriority filePriority = fileTree.getFilePriority(fileTree.getFiles().get(0));
    if(filePriority == FilePriority.SKIP || filePriority == FilePriority.MIXED) {
        fileEntry.setSelected(false);
    }

    return root;
}
项目:jfx-torrent    文件:FileTreeViewer.java   
private TreeItem<TorrentFileEntry> initTreeItem(final TorrentFileEntry fileEntry) {
    final CheckBoxTreeItem<TorrentFileEntry> treeItem = new CheckBoxTreeItem<>(fileEntry);
    treeItem.selectedProperty().bindBidirectional(fileEntry.selectedProperty());

    treeItem.setSelected(fileEntry.isSelected());
    addTreeItemListener(treeItem);

    return treeItem;
}
项目:jfx-torrent    文件:FileTreeViewer.java   
private void addTreeItemListener(final CheckBoxTreeItem<TorrentFileEntry> treeItem) {
    treeItem.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if(treeItem.isLeaf()) {
            treeItem.getValue().setSelected(newValue);
        }
        treeItem.getValue().setPriority(newValue? FilePriority.NORMAL : FilePriority.SKIP);

        currentTree.getSelectionModel().select(treeItem);
        currentTree.requestFocus();

        final CheckBoxTreeItem<TorrentFileEntry> parentItem = (CheckBoxTreeItem<TorrentFileEntry>)treeItem.getParent();
        onUpdateParentPriority(parentItem);
    });
}
项目:jfx-torrent    文件:FileTreeViewer.java   
private void applyOnParents(final TreeItem<TorrentFileEntry> child,
                            final Consumer<CheckBoxTreeItem<TorrentFileEntry>> consumer) {
    CheckBoxTreeItem<TorrentFileEntry> current = (CheckBoxTreeItem<TorrentFileEntry>)child.getParent();
    while(current != null) {
        consumer.accept(current);
        current = (CheckBoxTreeItem<TorrentFileEntry>)current.getParent();
    }
}
项目:Elegit    文件:WorkingTreePanelView.java   
@Override
protected TreeItem<RepoFile> getRootTreeItem(DirectoryRepoFile rootDirectory) {
    TreeItem<RepoFile> item = new CheckBoxTreeItem<>(rootDirectory);
    initCheckBox();
    item.getChildren().add(checkBox);
    return item;
}
项目:Elegit    文件:WorkingTreePanelView.java   
private void initCheckBox() {
    Text txt = new Text("select all");
    txt.setFont(new Font(10));
    checkBox = new CheckBoxTreeItem<>(null, txt);
    checkBox.selectedProperty().addListener(((observable, oldValue, newValue) -> {
        if(newValue) {
            setAllFilesSelected(true);
            txt.setText("deselect all");
        } else {
            setAllFilesSelected(false);
            txt.setText("select all");
        }
    }));
}
项目:Elegit    文件:WorkingTreePanelView.java   
/**
 * Checks through all the files and finds all whose checkbox is checked.
 *
 * @return an array of RepoFiles whose CheckBoxTreeItem cells are checked.
 */
public ArrayList<RepoFile> getCheckedFilesInDirectory() {
    ArrayList<RepoFile> checkedFiles = new ArrayList<>();
    for (TreeItem fileLeaf : this.displayedFiles) {
        CheckBoxTreeItem checkBoxFile = (CheckBoxTreeItem) fileLeaf;
        if (checkBoxFile.isSelected())
            checkedFiles.add((RepoFile)fileLeaf.getValue());
    }
    return checkedFiles;
}
项目:Elegit    文件:WorkingTreePanelView.java   
/**
 * Sets all displayed items to have the given selected status
 * @param selected true to check every box, false to uncheck every box
 */
public void setAllFilesSelected(boolean selected) {
    for (TreeItem fileLeaf : displayedFiles) {
        CheckBoxTreeItem checkBoxFile = (CheckBoxTreeItem) fileLeaf;
        checkBoxFile.setSelected(selected);
    }
}
项目:PeerWasp    文件:ClickEventHandler.java   
@Override
public void handle(TreeModificationEvent<PathItem> arg0) {
    if (arg0 != null && arg0.getSource() != null) {
        if (arg0.getSource() instanceof CheckBoxTreeItem) {

            @SuppressWarnings("unchecked")
            CheckBoxTreeItem<PathItem> source = (CheckBoxTreeItem<PathItem>) arg0.getSource();
            PathItem pathItem = source.getValue();

            if (pathItem != null) {
                Path path = pathItem.getPath();
                FileInfo file = new FileInfo(pathItem);
                if (source.isSelected()) {
                    logger.trace("Add {} to SYNC", path);
                    getSynchronization().getToSynchronize().add(file);
                    getSynchronization().getToDesynchronize().remove(file);
                } else if (!source.isIndeterminate()) {
                    logger.trace("Remove {} from SYNC", path);
                    getSynchronization().getToSynchronize().remove(file);
                    getSynchronization().getToDesynchronize().add(file);
                }

                arg0.consume();
            }
        }
    }
}
项目:marathonv5    文件:TreeViewSample.java   
private CheckBoxTreeItem<File> buildRoot(String dir) {
    return buildNode(new File(dir));
}
项目:JGitFX    文件:SelectableFileViewer.java   
private void selectAndExpandTreeItem(CheckBoxTreeItem<ModifiedPath> item) {
    item.setSelected(true);
    item.setExpanded(true);
}
项目:jfx-torrent    文件:TorrentContentTreeRow.java   
@Override
protected void updateItem(final TorrentFileEntry item, final boolean empty) {                   
    super.updateItem(item, empty);

    if(empty) {
           getStyleClass().removeAll(CssProperties.ALTERNATE_LIST_ROW_ODD);
           getStyleClass().add(CssProperties.ALTERNATE_LIST_ROW_EVEN);
           setContextMenu(null);
           return;
       } 
    else {
           TableUtils.applyTableRowColorization(this);

        final CheckBoxTreeItem<TorrentFileEntry> treeItem = (CheckBoxTreeItem<TorrentFileEntry>)super.getTreeItem();
        expandFolderTreeMenuItem.setDisable(treeItem.isLeaf() || treeItem.isExpanded());
        collapseFolderTreeMenuItem.setDisable((treeItem.isLeaf() && (treeItem.getParent() == 
                this.getTreeTableView().getRoot())) || (!treeItem.isLeaf() && !treeItem.isExpanded()));
        selectMenuItem.setDisable(treeItem.isLeaf() && treeItem.isSelected() ||
                !treeItem.isLeaf() && !treeItem.isIndeterminate() && treeItem.isSelected());
        unselectMenuItem.setDisable(treeItem.isLeaf() && !treeItem.isSelected() ||
                !treeItem.isLeaf() && !treeItem.isIndeterminate() && !treeItem.isSelected());
           setContextMenu(contextMenu);                     

           final FilePriority filePriority = item.getPriority();
           if(filePriority != FilePriority.MIXED) {
            priorityMenuItems[item.getPriority().getValue()].setSelected(true);
           }
           else {
            final Toggle selectedPriorityToggle = radioMenuGroup.getSelectedToggle();
            if(selectedPriorityToggle != null) {
                selectedPriorityToggle.setSelected(false);
            }
           }
       }

    Arrays.asList(priorityMenuItems).stream().forEach(priorityMenuItem -> priorityMenuItem.setOnAction(
            event -> onPriorityAction(priorityMenuItem)));

    expandFolderTreeMenuItem.setOnAction(evt -> fileTreeViewer.onExpandFolderTree(getTreeItem()));
    collapseFolderTreeMenuItem.setOnAction(evt -> fileTreeViewer.onCollapseTreeItem(getTreeItem()));
}
项目:Elegit    文件:WorkingTreePanelView.java   
private void updateRepoFile(CheckBoxTreeItem<RepoFile> oldItem, CheckBoxTreeItem<RepoFile> newItem, int index) {
    newItem.setSelected(oldItem.isSelected());
    List<TreeItem<RepoFile>> directoryFiles = oldItem.getParent().getChildren();
    directoryFiles.set(directoryFiles.indexOf(oldItem), newItem);
    displayedFiles.set(index, newItem);
}
项目:efiscen    文件:OutputController.java   
/**
 * Initializer for OutputController. Call constructor before initializing.
 * Initializes elements and loads settings.
 * @param url not in use
 * @param rb the given resource bundle
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    this.rb=rb;
    //type.getItems().addAll("ODBC","MySQL","PostgreSQL");
    for(DriverType driver : DriverType.values()) {
        type.getItems().add(driver.toString());
    }
    CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>(rb.getString("key.alloutputs"));
    rootItem.setExpanded(true);
    outputselection.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    outputselection.setCellFactory(CheckBoxTreeCell.<String>forTreeView());    
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.base")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.carboncountry")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.carbonsoil")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.fellingmatrix")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.fellingresidues")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.naturalmortality")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.thinningmatrix")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.thinningresidues")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.treecarbon")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.generalregions")));
    rootItem.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.generalspecies")));
    rootItem.selectedProperty().set(true);

    outputselection.setRoot(rootItem);
    CheckBoxTreeItem<String> rootItem2 = new CheckBoxTreeItem<>(rb.getString("key.alloutputs"));
    rootItem2.setExpanded(true);
    databaseTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    databaseTree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());    
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.base")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.carboncountry")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.carbonsoil")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.deadwood")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.fellingmatrix")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.fellingresidues")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.naturalmortality")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.thinningmatrix")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.thinningresidues")));
    rootItem2.getChildren().add(new CheckBoxTreeItem<>(rb.getString("key.treecarbon")));
    rootItem2.selectedProperty().set(true);

    databaseTree.setRoot(rootItem2);
    rootItem.selectedProperty().set(true);
    update();
    chooser = new DirectoryChooser();
    chooser.setTitle(rb.getString("key.outputpath"));
}
项目:openjfx-8u-dev-tests    文件:CheckBoxTreeApp.java   
protected void reset() {
    CheckBoxTreeItem<String> root = new CheckBoxTreeItem<String>("Root");

    root.setExpanded(true);

    addLevel(root, DATA_ITEMS_DEPTH);

    treeView.setRoot(root);
    treeView.setShowRoot(true);
}
项目:jfx-torrent    文件:FileTreeViewer.java   
/**
 * Select a tree item
 *
 * @param treeItem Tree item to select
 */
protected void selectItem(final CheckBoxTreeItem<TorrentFileEntry> treeItem) {
    currentTree.getSelectionModel().select(treeItem);
}