Example usage for javafx.scene.control TreeItem setExpanded

List of usage examples for javafx.scene.control TreeItem setExpanded

Introduction

In this page you can find the example usage for javafx.scene.control TreeItem setExpanded.

Prototype

public final void setExpanded(boolean value) 

Source Link

Document

Sets the expanded state of this TreeItem.

Usage

From source file:Testing.TestMain.java

public static void treeSample(Stage stage, Collection root) {
    TreeItem<String> rootItem = new TreeItem<String>("D:\\");

    rootItem.setExpanded(true);

    for (Iterator it = root.iterator(); it.hasNext();) {
        Object i = it.next();/*from w  w w  . ja  va 2s.  co  m*/
        TreeItem<String> item = new TreeItem<String>(i.toString());
        rootItem.getChildren().add(item);
    }
    /*
     for (int i = 1; i < 6; i++) {
     TreeItem<String> item = new TreeItem<String>("Message" + i);
     rootItem.getChildren().add(item);
     }*/
    TreeView<String> tree = new TreeView<String>(rootItem);
    StackPane rootpane = new StackPane();
    rootpane.getChildren().add(tree);
    stage.setScene(new Scene(rootpane, 300, 250));
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    TreeItem<String> rootItem = new TreeItem<>("Root");
    rootItem.setExpanded(true);

    TreeItem<String> item = new TreeItem<>("A");
    rootItem.getChildren().add(item);//from   w w w. ja v  a2  s  .  c o m

    item = new TreeItem<>("B");
    rootItem.getChildren().add(item);

    TreeView<String> tree = new TreeView<>(rootItem);
    StackPane root = new StackPane();
    root.getChildren().add(tree);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    final Scene scene = new Scene(new Group(), 200, 400);
    Group sceneRoot = (Group) scene.getRoot();

    TreeItem<String> childNode1 = new TreeItem<>("Node 1");
    TreeItem<String> childNode2 = new TreeItem<>("Node 2");
    TreeItem<String> childNode3 = new TreeItem<>("Node 3");

    TreeItem<String> root = new TreeItem<>("Root");
    root.setExpanded(true);

    root.getChildren().setAll(childNode1, childNode2, childNode3);

    TreeTableColumn<String, String> column = new TreeTableColumn<>("Column");
    column.setPrefWidth(150);/*from ww  w. jav  a 2 s  . c o m*/

    column.setCellValueFactory(
            (CellDataFeatures<String, String> p) -> new ReadOnlyStringWrapper(p.getValue().getValue()));

    TreeTableView<String> treeTableView = new TreeTableView<>(root);
    treeTableView.getColumns().add(column);
    sceneRoot.getChildren().add(treeTableView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Button Sample");
    stage.setWidth(300);//from w ww  .ja  v a  2s .  c om
    stage.setHeight(190);

    VBox vbox = new VBox();
    vbox.setLayoutX(20);
    vbox.setLayoutY(20);

    TreeItem<String> root = new TreeItem<String>("Root Node");
    root.setExpanded(true);
    root.getChildren().addAll(new TreeItem<String>("Item 1"), new TreeItem<String>("Item 2"),
            new TreeItem<String>("Item 3"));
    TreeView<String> treeView = new TreeView<String>(root);

    vbox.getChildren().add(treeView);
    vbox.setSpacing(10);
    ((Group) scene.getRoot()).getChildren().add(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:musicmetadatak1009705.FolderTreeView.java

public TreeView<File> proxyCreateNode(ArrayList<TreeItem> arrayListTreeItem) {
    TreeItem<File> proxyItem = new TreeItem<>();
    proxyItem.setExpanded(true);
    for (TreeItem<File> item : arrayListTreeItem) {
        proxyItem.getChildren().addAll(item);
    }// ww  w . j  a v a 2 s .c o m
    TreeView<File> tree = new TreeView<>(proxyItem);
    tree.setShowRoot(false);
    return tree;
}

From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java

private void rebuildTree() {
    currentlyRebuilding = true;//from   ww  w.  j a  v a  2s  .c  o m

    treeRoot.getChildren().clear();

    for (int n = 0; n < schemaList.length; n++) {
        TreeItem<Branch> item = new TreeItem<>(new Branch(this, schemaList[n]));
        item.setExpanded(true);
        treeRoot.getChildren().add(item);

        for (int i = 0; i < schemaList[n].numAssays(); i++) {
            Schema.Assay assay = schemaList[n].getAssay(i);
            item.getChildren().add(new TreeItem<Branch>(new Branch(this, schemaList[n], assay)));
        }
    }

    currentlyRebuilding = false;
}

From source file:net.rptools.tokentool.client.TokenTool.java

/**
 * //from  ww  w . j  av a2  s.  com
 * @author Jamz
 * @throws IOException
 * @since 2.0
 * 
 *        This method loads and processes all the overlays found in user.home/overlays and it can take a minute to load as it creates thumbnail versions for the comboBox so we call this during the
 *        init and display progress in the preLoader (splash screen).
 * 
 */
private TreeItem<Path> cacheOverlays(File dir, TreeItem<Path> parent, int THUMB_SIZE) throws IOException {
    TreeItem<Path> root = new TreeItem<>(dir.toPath());
    root.setExpanded(false);

    log.debug("caching " + dir.getAbsolutePath());

    File[] files = dir.listFiles();
    for (File file : files) {
        if (file.isDirectory()) {
            cacheOverlays(file, root, THUMB_SIZE);
        } else {
            Path filePath = file.toPath();
            TreeItem<Path> imageNode = new TreeItem<>(filePath,
                    ImageUtil.getOverlayThumb(new ImageView(), filePath));
            root.getChildren().add(imageNode);

            notifyPreloader(new Preloader.ProgressNotification((double) loadCount++ / overlayCount));
        }
    }

    if (parent != null) {
        // When we show the overlay image, the TreeItem value is "" so we need to
        // sort those to the bottom for a cleaner look and keep sub dir's at the top.
        // If a node has no children then it's an overlay, otherwise it's a directory...
        root.getChildren().sort(new Comparator<TreeItem<Path>>() {
            @Override
            public int compare(TreeItem<Path> o1, TreeItem<Path> o2) {
                if (o1.getChildren().size() == 0 && o2.getChildren().size() == 0)
                    return 0;
                else if (o1.getChildren().size() == 0)
                    return Integer.MAX_VALUE;
                else if (o2.getChildren().size() == 0)
                    return Integer.MIN_VALUE;
                else
                    return o1.getValue().compareTo(o2.getValue());
            }
        });

        parent.getChildren().add(root);
    }

    return root;
}

From source file:edu.kit.trufflehog.command.usercommand.SelectionCommand.java

private void updateNodeStatistics(Set<INode> nodes) {

    assert (nodes != null);

    //clearStatistics();

    if (nodes.size() == 1) {

        final TreeItem<StatisticsViewModel.IEntry<StringProperty, ? extends Property>> infos = nodes.iterator()
                .next().stream().collect(collector);
        logger.debug(infos);//from   ww w . j av  a  2 s .  c  o  m
        infos.setExpanded(true);
        Platform.runLater(() -> statisticsViewModel.setSelectionValues(infos));

    } else {

        //TODO calculate statistics for multiple selected nodes?

    }

}

From source file:edu.kit.trufflehog.command.usercommand.SelectionCommand.java

private void updateConnectionStatistics(Set<IConnection> connections) {

    assert (connections != null);
    //clearStatistics();

    if (connections.size() == 1) {

        final TreeItem<StatisticsViewModel.IEntry<StringProperty, ? extends Property>> infos = connections
                .iterator().next().stream().collect(collector);
        logger.debug(infos);//  w w  w  .  j  a va  2s. c o  m
        infos.setExpanded(true);

        Platform.runLater(() -> statisticsViewModel.setSelectionValues(infos));

    } else {

        //TODO calculate statistics for multiple selected connections?

    }

}

From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.NavPanel.java

/**
 * Set the tree to the passed in group//from ww w  .j av  a2 s  . co  m
 *
 * @param grouping
 */
@ThreadConfined(type = ThreadType.JFX)
public void setFocusedGroup(DrawableGroup grouping) {

    List<String> path = groupingToPath(grouping);

    final GroupTreeItem treeItemForGroup = ((GroupTreeItem) activeTreeProperty.get().getRoot())
            .getTreeItemForPath(path);

    if (treeItemForGroup != null) {
        /* When we used to run the below code on the FX thread, it would
         * get into infinite loops when the next group button was pressed
         * quickly because the udpates became out of order and History could
         * not
         * keep track of what was current.
         *
         * Currently (4/2/15), this method is already on the FX thread, so
         * it is OK. */
        //Platform.runLater(() -> {
        TreeItem<TreeNode> ti = treeItemForGroup;
        while (ti != null) {
            ti.setExpanded(true);
            ti = ti.getParent();
        }
        int row = activeTreeProperty.get().getRow(treeItemForGroup);
        if (row != -1) {
            activeTreeProperty.get().getSelectionModel().select(treeItemForGroup);
            activeTreeProperty.get().scrollTo(row);
        }
        //});   //end Platform.runLater
    }
}