Example usage for javafx.scene.control TreeItem TreeItem

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

Introduction

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

Prototype

public TreeItem() 

Source Link

Document

Creates an empty TreeItem.

Usage

From source file:com.exalttech.trex.ui.controllers.PacketViewerController.java

/**
 * Build packet detail tree//from w  w w  . ja va 2  s  . c  o  m
 *
 * @param packetData
 */
private void buildPacketDetailTree(String packetData) {
    String[] mainNode = packetData.split("\n");
    TreeItem root = new TreeItem();
    packetDetailTree.setRoot(root);
    packetDetailTree.setShowRoot(false);
    for (String node : mainNode) {
        node = node.replaceAll("\r", "").trim();
        if ("[".equals(node.substring(0, 1))) {
            TreeItem subRoot = new TreeItem(node);
            root.getChildren().add(subRoot);
        } else {
            TreeItem sub = new TreeItem(node);
            ((TreeItem) root.getChildren().get(root.getChildren().size() - 1)).getChildren().add(sub);
        }
    }

}

From source file:musicmetadatak1009705.FolderTreeView.java

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

From source file:org.ykc.usbcx.MainWindowController.java

@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    Preferences.genTempFolders();
    Preferences.loadPreferences();
    bOpen.setGraphic(new ImageView(new Image("/open.png")));
    bOpen.setTooltip(new Tooltip("Open ucx1 file"));
    bSave.setGraphic(new ImageView(new Image("/save.png")));
    bSave.setTooltip(new Tooltip("Save ucx1 file"));
    bStartStop.setGraphic(new ImageView(new Image("/start_stop.png")));
    bStartStop.setTooltip(new Tooltip("Start/Stop Capture"));
    bReset.setGraphic(new ImageView(new Image("/reset.png")));
    bReset.setTooltip(new Tooltip("Reset and clear"));
    bTrigger.setGraphic(new ImageView(new Image("/trigger.png")));
    bTrigger.setTooltip(new Tooltip("Set Trigger"));
    bGetVersion.setGraphic(new ImageView(new Image("/version.png")));
    bGetVersion.setTooltip(new Tooltip("Get Version"));
    bDownload.setGraphic(new ImageView(new Image("/download.png")));
    bDownload.setTooltip(new Tooltip("Download FW"));
    bAbout.setGraphic(new ImageView(new Image("/info.png")));
    bAbout.setTooltip(new Tooltip("About USBCx"));
    bFirstPage.setGraphic(new ImageView(new Image("/double_arrow_left.png")));
    bFirstPage.setTooltip(new Tooltip("Go to First Page"));
    bPrevPage.setGraphic(new ImageView(new Image("/arrow_left.png")));
    bPrevPage.setTooltip(new Tooltip("Go to Previous Page"));
    bNextPage.setGraphic(new ImageView(new Image("/arrow_right.png")));
    bNextPage.setTooltip(new Tooltip("Go to Next Page"));
    bLastPage.setGraphic(new ImageView(new Image("/double_arrow_right.png")));
    bLastPage.setTooltip(new Tooltip("Go to Last Page"));
    bCollapse.setGraphic(new ImageView(new Image("/collapse.png")));
    bCollapse.setTooltip(new Tooltip("Collapse Items"));
    bExpand.setGraphic(new ImageView(new Image("/expand.png")));
    bExpand.setTooltip(new Tooltip("Expand Items"));
    bGraphScrollLeft.setGraphic(new ImageView(new Image("/arrow_left.png")));
    bGraphScrollLeft.setTooltip(new Tooltip("Previous plot"));
    bGraphScrollRight.setGraphic(new ImageView(new Image("/arrow_right.png")));
    bGraphScrollRight.setTooltip(new Tooltip("Next plot"));

    ttColPVName.setCellValueFactory(new TreeItemPropertyValueFactory<DetailsRow, String>("name"));
    ttColPVValue.setCellValueFactory(new TreeItemPropertyValueFactory<DetailsRow, String>("value"));
    ttColPVDecimal.setCellValueFactory(new TreeItemPropertyValueFactory<DetailsRow, String>("decval"));
    ttColPVHex.setCellValueFactory(new TreeItemPropertyValueFactory<DetailsRow, String>("hexval"));
    ttColPVBinary.setCellValueFactory(new TreeItemPropertyValueFactory<DetailsRow, String>("binaryval"));
    ttColPVLength.setCellValueFactory(new TreeItemPropertyValueFactory<DetailsRow, String>("len"));
    ttColPVOffset.setCellValueFactory(new TreeItemPropertyValueFactory<DetailsRow, String>("offset"));
    TreeItem<DetailsRow> rootItem = new TreeItem<DetailsRow>();
    ttViewParseViewer.setRoot(rootItem);

    ttColPVName.setCellFactory((TreeTableColumn<DetailsRow, String> param) -> {
        TreeTableCell<DetailsRow, String> cell = new TreeTableCell<DetailsRow, String>() {
            @Override//from   www.  j av a  2s.  co  m
            protected void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                setText(empty ? "" : getItem().toString());
                TreeTableRow<DetailsRow> ttr = getTreeTableRow();
                DetailsRow x = ttr.getItem();
                DetailsRow.BG bg = BG.NORMAL;
                String style = "";
                if (x != null) {
                    bg = x.getBcolor();
                    style += x.getBold() ? "-fx-font-weight:bold;-fx-font-style:italic;" : "";
                }

                switch (bg) {
                case RED:
                    style += "-fx-text-fill:red;";
                    break;
                case GREEN:
                    style += "-fx-text-fill:green;";
                    break;
                case BLUE:
                    style += "-fx-text-fill:blue;";
                    break;
                case YELLOW:
                    style += "-fx-text-fill:yellow;";
                    break;
                case PINK:
                    style += "-fx-text-fill:pink;";
                    break;
                default:
                    style += "-fx-text-fill:white;" + "-fx-highlight-fill:dodgerblue;"
                            + "-fx-highlight-text-fill:white";
                    break;
                }
                setStyle(style);
            }
        };
        return cell;
    });

    tColMViewSno.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("sno"));
    tColMViewOk.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("ok"));
    tColMViewSop.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("sop"));
    tColMViewMsg.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("msg"));
    tColMViewId.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("id"));
    tColMViewDrole.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("drole"));
    tColMViewProle.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("prole"));
    tColMViewCount.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("count"));
    tColMViewRev.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("rev"));
    tColMViewDuration.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("duration"));
    tColMViewDelta.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("delta"));
    tColMViewVbus.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("vbus"));
    tColMViewData.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("data"));
    tColMViewStartTime.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("stime"));
    tColMViewEndTime.setCellValueFactory(new PropertyValueFactory<MainViewRow, String>("etime"));

    tColDataViewIndex.setCellValueFactory(new PropertyValueFactory<DataViewRow, Integer>("index"));
    tColDataViewValue.setCellValueFactory(new PropertyValueFactory<DataViewRow, String>("value"));

    cBoxMsgClass.getItems().addAll(PDUtils.MSG_CLASS);
    cBoxMsgClass.getSelectionModel().select(0);
    cBoxMsgType.getItems().addAll(PDUtils.CTRL_MSG_TYPE);
    cBoxMsgType.getSelectionModel().select(1);
    cBoxSop.getItems().addAll(PDUtils.SOP_TYPE);
    cBoxSop.getSelectionModel().select(0);

    bFirstPage.setDisable(true);
    bLastPage.setDisable(true);
    bPrevPage.setDisable(true);
    bNextPage.setDisable(true);

    lGraph = new XScope(lchartData, xAxis, yAxis, cboxGraphXScale, bGraphScrollLeft, bGraphScrollRight,
            chkGraphCC1, chkGraphCC2, chkGraphVbus, chkGraphAmp, lblGraphYValue, lblGraphXValue, lblGraphDeltaY,
            lblGraphDeltaX);

    usbcontrol = new USBControl(cBoxDeviceList, statusBar, lblVolt, lblCur, lblCC1, lblCC2);
    cordinator = new Cordinator(usbcontrol, tViewMain, tViewData, ttViewParseViewer, lblStartDelta, lGraph);

    Platform.runLater(() -> {
        handleArgs();
    });
}