List of usage examples for javafx.scene.control TreeTableCell TreeTableCell
public TreeTableCell()
From source file:ca.wumbo.doommanager.client.controller.file.DoomFileController.java
@FXML private void initialize() { // Keep the left window the same size when resizing/maximizing. SplitPane.setResizableWithParent(leftBorderPane, false); // Allow selection of multiple cells. entryTreeTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); // Make the cells update accordingly. nameColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().entryProperty()); sizeColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().dataLengthStringProperty()); typeColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().entryTypeProperty()); // Resize the splitter to a reasonable position. // Since we can't use Platform.runlater() to do this, we have to use a listener that removes itself. // Note: The old way it was done was to pass the tabPane's width to the function after this is initialized. InvalidationListener invalidationListener = new InvalidationListener() { @Override/*from ww w . java 2 s.c o m*/ public void invalidated(Observable observable) { setSplitterPosition((int) splitPane.getWidth()); splitPane.widthProperty().removeListener(this); // Remove itself after the size is set. } }; splitPane.widthProperty().addListener(invalidationListener); // Handle item selection. This will clean up our GUI and add/remove panes on the right of the splitter. entryTreeTable.getSelectionModel().selectedItemProperty().addListener((obsValue, oldValue, newValue) -> { updateGUIFromEntrySelection(oldValue, newValue); }); // Support right clicking menus on the rows, source: https://gist.github.com/james-d/7758918 entryTreeTable.setRowFactory(new Callback<TreeTableView<Entry>, TreeTableRow<Entry>>() { @Override public TreeTableRow<Entry> call(TreeTableView<Entry> tableView) { // Create the row to return. TreeTableRow<Entry> row = new TreeTableRow<>(); ContextMenu contextMenu = new ContextMenu(); // Whenever this row gets a new item (or is updated), rebuild the right click menu. row.itemProperty().addListener((observableValue, oldValue, newValue) -> { // TODO - Dynamically generate a new context menu - contextMenu.getItems().add(new MenuItem()); }); // Set context menu on row, but use a binding to make it only show for non-empty rows: row.contextMenuProperty() .bind(Bindings.when(row.emptyProperty()).then((ContextMenu) null).otherwise(contextMenu)); return row; } }); // Instead of assigning graphics to each node, only do it for the cells. // This should help reduce object creation by having it only required for the visible rows. nameColumn.setCellFactory(new Callback<TreeTableColumn<Entry, Entry>, TreeTableCell<Entry, Entry>>() { @Override public TreeTableCell<Entry, Entry> call(TreeTableColumn<Entry, Entry> param) { return new TreeTableCell<Entry, Entry>() { @Override protected void updateItem(Entry item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { setText(item.getName()); Image img = resources.getImage(item.getClass().getSimpleName().toLowerCase()); setGraphic(new ImageView(img)); } else { setText(null); setGraphic(null); } } }; } }); }
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/* w w w . ja va 2 s . com*/ 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(); }); }