类javafx.scene.control.TableRow源码实例Demo

下面列出了怎么用javafx.scene.control.TableRow的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Open-Lowcode   文件: OLcClient.java
private ActionSourceTransformer getActionSourceTransformer() {
	return new ActionSourceTransformer() {

		@Override
		public Object getParentWidget(Object originwidget) {
			if (originwidget instanceof GanttTaskCell) {
				GanttTaskCell<?> gantttaskcell = (GanttTaskCell<?>) originwidget;
				GanttDisplay<?> parentdisplay = gantttaskcell.getParentGanttDisplay();
				return parentdisplay;
			}
			if (originwidget instanceof TableRow) {
				TableRow<?> tablerow = (TableRow<?>) originwidget;
				TableView<?> table = tablerow.getTableView();
				return table;
			}
			return originwidget;
		}
	};
}
 
源代码2 项目: kafka-message-tool   文件: BrokerConfigView.java
private void bindActionsToSelectedRow(KafkaClusterProxy proxy) {

        topicsTableView.setRowFactory(tableView -> {
            final TableRow<TopicAggregatedSummary> row = new TableRow<>();

            bindPopupMenuToSelectedRow(proxy, row);

            row.setOnMouseClicked(event -> {
                if (event.getClickCount() == 1 && (!row.isEmpty())) {
                    showAssignedConsumerInfo(row);
                } else if (event.getClickCount() == 2 && (!row.isEmpty())) {
                    showTopicConfigPropertiesWindow(kafkaBrokerProxyProperty.get(), row.getItem().getTopicName());
                }
            });
            return row;
        });
    }
 
源代码3 项目: kafka-message-tool   文件: BrokerConfigView.java
private void bindPopupMenuToSelectedRow(KafkaClusterProxy proxy, TableRow<TopicAggregatedSummary> row) {

        final MenuItem deleteTopicMenuItem = createMenuItemForDeletingTopic();
        final MenuItem createTopicMenuItem = createMenuItemForCreatingNewTopic();
        final MenuItem alterTopicMenuItem = createMenuItemForAlteringTopic();
        final MenuItem topicPropertiesMenuItem = createMenuItemForShowingTopicProperties();

        final ContextMenu contextMenu = getTopicManagementContextMenu(deleteTopicMenuItem,
                                                                      createTopicMenuItem,
                                                                      alterTopicMenuItem,
                                                                      topicPropertiesMenuItem);

        row.contextMenuProperty().bind(new ReadOnlyObjectWrapper<>(contextMenu));
        topicPropertiesMenuItem.disableProperty().bind(row.emptyProperty());

        if (proxy.isTopicDeletionEnabled() != TriStateConfigEntryValue.True) {
            deleteTopicMenuItem.setText("Delete topic (disabled by broker)");
            deleteTopicMenuItem.disableProperty().setValue(true);
        } else {
            deleteTopicMenuItem.disableProperty().bind(row.emptyProperty());
        }
        alterTopicMenuItem.disableProperty().bind(row.emptyProperty());
    }
 
源代码4 项目: Animu-Downloaderu   文件: TableSelectListener.java
@Override
public TableRow<DownloadInfo> call(TableView<DownloadInfo> view) {
	final TableRow<DownloadInfo> row = new TableRow<>();
	DownloadInfo info = view.getSelectionModel().getSelectedItem();
	initListeners(view, info);
	row.contextMenuProperty().bind(
			Bindings.when(Bindings.isNotNull(row.itemProperty())).then(rowMenu).otherwise((ContextMenu) null));

	row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
		final int index = row.getIndex();
		if (!event.isPrimaryButtonDown())
			return; // no action if it is not primary button
		if (index >= view.getItems().size() || view.getSelectionModel().isSelected(index)) {
			view.getSelectionModel().clearSelection();
			event.consume();
		}
	});
	return row;
}
 
public TableCell<?, ?> getVisibleCellAt(TableView<?> tableView, int row, int column) {
    Set<Node> lookupAll = getTableCells(tableView);
    TableCell<?, ?> cell = null;
    for (Node node : lookupAll) {
        TableCell<?, ?> cell1 = (TableCell<?, ?>) node;
        TableRow<?> tableRow = cell1.getTableRow();
        TableColumn<?, ?> tableColumn = cell1.getTableColumn();
        if (tableRow.getIndex() == row && tableColumn == tableView.getColumns().get(column)) {
            cell = cell1;
            break;
        }
    }
    if (cell != null) {
        return cell;
    }
    return null;
}
 
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (!r.isEmpty() && r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (cell.isEmpty())
            continue;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
源代码8 项目: marathonv5   文件: RFXComponentTest.java
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
源代码9 项目: Recaf   文件: TableViewExtra.java
private void recomputeVisibleIndexes() {
	firstIndex = -1;
	// Work out which of the rows are visible
	double tblViewHeight = table.getHeight();
	double headerHeight =
               table.lookup(".column-header-background").getBoundsInLocal().getHeight();
	double viewPortHeight = tblViewHeight - headerHeight;
	for(TableRow<T> r : rows) {
		if(!r.isVisible())
			continue;
		double minY = r.getBoundsInParent().getMinY();
		double maxY = r.getBoundsInParent().getMaxY();
		boolean hidden = (maxY < 0) || (minY > viewPortHeight);
		if(hidden)
			continue;
		if(firstIndex < 0 || r.getIndex() < firstIndex)
			firstIndex = r.getIndex();
	}
}
 
源代码10 项目: mars-sim   文件: AnimatedTableRow.java
private void moveDataWithAnimation(final TableView<Person> sourceTable,
		final TableView<Person> destinationTable,
		final Pane commonTableAncestor, final TableRow<Person> row) {
	// Create imageview to display snapshot of row:
	final ImageView imageView = createImageView(row);
	// Start animation at current row:
	final Point2D animationStartPoint = row.localToScene(new Point2D(0, 0)); // relative to Scene
	final Point2D animationEndPoint = computeAnimationEndPoint(destinationTable); // relative to Scene
	// Set start location
	final Point2D startInRoot = commonTableAncestor.sceneToLocal(animationStartPoint); // relative to commonTableAncestor
	imageView.relocate(startInRoot.getX(), startInRoot.getY());
	// Create animation
	final Animation transition = createAndConfigureAnimation(
			sourceTable, destinationTable, commonTableAncestor, row,
			imageView, animationStartPoint, animationEndPoint);
	// add animated image to display
	commonTableAncestor.getChildren().add(imageView);
	// start animation
	transition.play();
}
 
源代码11 项目: old-mzmine3   文件: SpinnerTableCell.java
public SpinnerTableCell(TableColumn<T, Integer> column, int min, int max) {

    spinner = new Spinner<>(min, max, 1);

    spinner.editableProperty().bind(column.editableProperty());
    spinner.disableProperty().bind(column.editableProperty().not());

    tableRowProperty().addListener(e -> {
      TableRow<?> row = getTableRow();
      if (row == null)
        return;
      MsSpectrumDataSet dataSet = (MsSpectrumDataSet) row.getItem();
      if (dataSet == null)
        return;
      spinner.getValueFactory().valueProperty().bindBidirectional(dataSet.lineThicknessProperty());
      disableProperty().bind(dataSet.renderingTypeProperty().isEqualTo(MsSpectrumType.CENTROIDED));

    });
  }
 
源代码12 项目: old-mzmine3   文件: SpinnerTableCell.java
public SpinnerTableCell(TableColumn<T, Integer> column, int min, int max) {

    spinner = new Spinner<>(min, max, 1);

    spinner.editableProperty().bind(column.editableProperty());
    spinner.disableProperty().bind(column.editableProperty().not());

    tableRowProperty().addListener(e -> {
      TableRow<?> row = getTableRow();
      if (row == null)
        return;
      ChromatogramPlotDataSet dataSet = (ChromatogramPlotDataSet) row.getItem();
      if (dataSet == null)
        return;
      spinner.getValueFactory().valueProperty().bindBidirectional(dataSet.lineThicknessProperty());

    });
  }
 
源代码13 项目: curly   文件: AppController.java
private void updateRowHighlight(TableRow<Map<String, String>> row) {
    int r = 160;
    int g = 160;
    int b = 160;
    if (highlightedRows.isEmpty()) {
        r = 255;
        g = 255;
        b = 255;
    } else if (highlightedRows.contains(row.getIndex())) {
        r = 200;
        g = 255;
        b = 200;
    }
    if (row.getIndex() % 2 == 1) {
        r = Math.max(0, r-16);
        g = Math.max(0, g-16);
        b = Math.max(0, b-16);
    }
    row.setBackground(new Background(new BackgroundFill(Color.rgb(r, g, b), null, null)));
}
 
源代码14 项目: Open-Lowcode   文件: CGrid.java
private TableView<CObjectGridLine<String>> generateTableViewModel() {
	TableView<CObjectGridLine<String>> returntable = new TableView<CObjectGridLine<String>>();
	Collections.sort(arraycolumns);
	for (int i = 0; i < arraycolumns.size(); i++) {
		TableColumn<CObjectGridLine<String>, String> thiscolumn = arraycolumns.get(i).column;
		logger.fine("  GTVM --- " + thiscolumn.getId());
		ObservableList<TableColumn<CObjectGridLine<String>, ?>> subcolumns = thiscolumn.getColumns();
		for (int k = 0; k < subcolumns.size(); k++)
			logger.fine("    GTVM     ++ " + subcolumns.get(k).getId());
		returntable.getColumns().add(thiscolumn);
	}
	double finalheightinpixel = 29;
	returntable.setRowFactory(tv -> new TableRow<CObjectGridLine<String>>() {

		@Override
		public void updateItem(CObjectGridLine<String> object, boolean empty) {
			super.updateItem(object, empty);
			this.setMaxHeight(finalheightinpixel);
			this.setMinHeight(finalheightinpixel);
			this.setPrefHeight(finalheightinpixel);
			this.setTextOverrun(OverrunStyle.ELLIPSIS);
			this.setEllipsisString("...");
		}
	});
	returntable.getSelectionModel().setCellSelectionEnabled(true);
	returntable.setTooltip(tooltip);
	return returntable;
}
 
源代码15 项目: kafka-message-tool   文件: BrokerConfigView.java
private void showAssignedConsumerInfo(TableRow<TopicAggregatedSummary> row) {
    final String topicName = row.getItem().getTopicName();
    final KafkaClusterProxy currentProxy = kafkaBrokerProxyProperty.get();
    final Set<AssignedConsumerInfo> consumers = currentProxy.getConsumersForTopic(topicName);
    assignedConsumerListTableView.getItems().clear();
    assignedConsumerListTableView.setItems(FXCollections.observableArrayList(consumers));
    TableUtils.autoResizeColumns(assignedConsumerListTableView);
}
 
源代码16 项目: kafka-message-tool   文件: ConsumerGroupView.java
private void bindActionsToSelectedRow() {

        consumerGroupNameTable.setRowFactory((TableView<ConsumerGroupName> tableView) -> {
            final TableRow<ConsumerGroupName> row = new TableRow<>();

            row.setOnMouseClicked(event -> {
                if (event.getClickCount() == 1 && (!row.isEmpty())) {
                    fillConsumerGroupDetailsViewForName(row.getItem().getName());
                }
            });
            return row;
        });
    }
 
源代码17 项目: phoebus   文件: PVTable.java
/** @param node Node
 *  @return <code>true</code> if node is in a table cell, and not the table header
 */
private static boolean isTableCell(Node node)
{
    while (node != null)
    {
        if (node instanceof TableRow<?>)
            return true;
        node = node.getParent();
    }
    return false;
}
 
源代码18 项目: phoebus   文件: SnapshotTable.java
SelectionTableColumn() {
    super("", "Include this PV when restoring values", 30, 30, false);
    setCellValueFactory(new PropertyValueFactory<>("selected"));
    //for those entries, which have a read-only property, disable the checkbox
    setCellFactory(column -> {
        TableCell<TableEntry, Boolean> cell = new CheckBoxTableCell<>(null,null);
        cell.itemProperty().addListener((a, o, n) -> {
            cell.getStyleClass().remove("check-box-table-cell-disabled");
            TableRow<?> row = cell.getTableRow();
            if (row != null) {
                TableEntry item = (TableEntry) row.getItem();
                if (item != null) {
                    cell.setEditable(!item.readOnlyProperty().get());
                    if (item.readOnlyProperty().get()) {
                        cell.getStyleClass().add("check-box-table-cell-disabled");
                    }
                }
            }
        });
        return cell;
    });
    setEditable(true);
    setSortable(false);
    selectAllCheckBox = new CheckBox();
    selectAllCheckBox.setSelected(false);
    selectAllCheckBox.setOnAction(e -> getItems().stream().filter(te -> !te.readOnlyProperty().get())
            .forEach(te -> te.selectedProperty().setValue(selectAllCheckBox.isSelected())));
    setGraphic(selectAllCheckBox);
    MenuItem inverseMI = new MenuItem("Inverse Selection");
    inverseMI.setOnAction(e -> getItems().stream().filter(te -> !te.readOnlyProperty().get())
            .forEach(te -> te.selectedProperty().setValue(!te.selectedProperty().get())));
    final ContextMenu contextMenu = new ContextMenu(inverseMI);
    selectAllCheckBox.setOnMouseReleased(e -> {
        if (e.getButton() == MouseButton.SECONDARY) {
            contextMenu.show(selectAllCheckBox, e.getScreenX(), e.getScreenY());
        }
    });
}
 
源代码19 项目: phoebus   文件: SampleView.java
@Override
protected void updateItem(final String item, final boolean empty)
{
    super.updateItem(item, empty);
    final TableRow<PlotSample> row = getTableRow();
    if (empty  ||  row == null  ||  row.getItem() == null)
        setText("");
    else
    {
        setText(item);
        setTextFill(SeverityColors.getTextColor(org.phoebus.core.vtypes.VTypeHelper.getSeverity(row.getItem().getVType())));
    }
}
 
源代码20 项目: phoebus   文件: DirectChoiceBoxTableCell.java
@Override
protected void updateItem(final T value, final boolean empty)
{
    super.updateItem(value, empty);

    if (empty)
        setGraphic(null);
    else
    {
        choicebox.setValue(value);
        setGraphic(choicebox);

        choicebox.setOnAction(event ->
        {
            // 'onAction' is invoked from setValue as called above,
            // but also when table updates its cells.
            // Ignore those.
            // Also ignore dummy updates to null which happen
            // when the list of choices changes
            if (! choicebox.isShowing() ||
                choicebox.getValue() == null)
                return;

            final TableRow<S> row = getTableRow();
            if (row == null)
                return;

            // Fire 'onEditCommit'
            final TableView<S> table = getTableView();
            final TableColumn<S, T> col = getTableColumn();
            final TablePosition<S, T> pos = new TablePosition<>(table, row.getIndex(), col);
            Objects.requireNonNull(col.getOnEditCommit(), "Must define onEditCommit handler")
                   .handle(new CellEditEvent<>(table, pos, TableColumn.editCommitEvent(), choicebox.getValue()));
        });
    }
}
 
源代码21 项目: phoebus   文件: JobViewer.java
@Override
protected void updateItem(final Boolean ignored, final boolean empty)
{
    super.updateItem(ignored, empty);

    boolean running = ! empty;

    TableRow<JobInfo> row = null;
    if (running)
    {
        row = getTableRow();
        if (row == null)
            running = false;
    }

    if (running)
    {
        setAlignment(Pos.CENTER_RIGHT);
        final JobInfo info = row.getItem();
        final Button cancel = new Button(Messages.JobCancel, new ImageView(ABORT));
        cancel.setOnAction(event -> info.job.cancel());
        cancel.setMaxWidth(Double.MAX_VALUE);
        setGraphic(cancel);
    }
    else
        setGraphic(null);
}
 
源代码22 项目: Recaf   文件: TableViewExtra.java
/**
 * @param tableView
 * 		Table to wrap.
 */
public TableViewExtra(TableView<T> tableView) {
	this.table = tableView;
	// Callback to monitor row creation and to identify visible screen rows
	final Callback<TableView<T>, TableRow<T>> rf = tableView.getRowFactory();
	final Callback<TableView<T>, TableRow<T>> modifiedRowFactory = param -> {
		TableRow<T> r = rf != null ? rf.call(param) : new TableRow<>();
		// Save row, this implementation relies on JaxaFX re-using TableRow efficiently
		rows.add(r);
		return r;
	};
	tableView.setRowFactory(modifiedRowFactory);
}
 
/**
 * Create the ExpandableTableRowSkin and listen to changes for the item this table row represents. When the
 * item is changed, the old expanded node, if any, is removed from the children list of the TableRow.
 *
 * @param tableRow The table row to apply this skin for
 * @param expander The expander column, used to retrieve the expanded node when this row is expanded
 */
public ExpandableTableRowSkin(TableRow<S> tableRow, TableRowExpanderColumn<S> expander) {
    super(tableRow);
    this.tableRow = tableRow;
    this.expander = expander;
    tableRow.itemProperty().addListener((observable, oldValue, newValue) -> {
        if (oldValue != null) {
            Node expandedNode = this.expander.getExpandedNode(oldValue);
            if (expandedNode != null) getChildren().remove(expandedNode);
        }
    });
}
 
源代码24 项目: mars-sim   文件: AnimatedTableRow.java
private TranslateTransition createAndConfigureAnimation(
		final TableView<Person> sourceTable,
		final TableView<Person> destinationTable,
		final Pane commonTableAncestor, final TableRow<Person> row,
		final ImageView imageView, final Point2D animationStartPoint,
		Point2D animationEndPoint) {
	final TranslateTransition transition = new TranslateTransition(ANIMATION_DURATION, imageView);
	// At end of animation, actually move data, and remove animated image
	transition.setOnFinished(createAnimationFinishedHandler(sourceTable, destinationTable, commonTableAncestor, row.getItem(), imageView));
	// configure transition
	transition.setByX(animationEndPoint.getX() - animationStartPoint.getX()); // absolute translation, computed from coords relative to Scene
	transition.setByY(animationEndPoint.getY() - animationStartPoint.getY()); // absolute translation, computed from coords relative to Scene
	return transition;
}
 
源代码25 项目: mars-sim   文件: AnimatedTableRow.java
private ImageView createImageView(final TableRow<Person> row) {
	final Image image = row.snapshot(null, null);
	final ImageView imageView = new ImageView(image);
       // Manage image location ourselves (don't let layout manage it)
       imageView.setManaged(false);
	return imageView;
}
 
public void initialize() {

    final ObservableList<MsSpectrumType> renderingChoices =
        FXCollections.observableArrayList(MsSpectrumType.CENTROIDED, MsSpectrumType.PROFILE);
    renderingTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(renderingChoices));

    colorColumn.setCellFactory(column -> new ColorTableCell<MsSpectrumDataSet>(column));

    lineThicknessColumn
        .setCellFactory(column -> new SpinnerTableCell<MsSpectrumDataSet>(column, 1, 5));

    intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn(
        new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat())));

    showDataPointsColumn
        .setCellFactory(column -> new CheckBoxTableCell<MsSpectrumDataSet, Boolean>() {
          {
            tableRowProperty().addListener(e -> {
              TableRow<?> row = getTableRow();
              if (row == null)
                return;
              MsSpectrumDataSet dataSet = (MsSpectrumDataSet) row.getItem();
              if (dataSet == null)
                return;
              disableProperty()
                  .bind(dataSet.renderingTypeProperty().isEqualTo(MsSpectrumType.CENTROIDED));

            });
          }
        });
  }
 
源代码27 项目: logbook-kai   文件: AirBaseController.java
@Override
protected void updateItem(Integer itemId, boolean empty) {
    super.updateItem(itemId, empty);

    this.getStyleClass().removeAll("change");

    if (!empty) {
        Map<Integer, SlotItem> itemMap = SlotItemCollection.get()
                .getSlotitemMap();

        SlotItem item = itemMap.get(itemId);

        if (item != null) {
            this.setGraphic(new ImageView(Items.itemImage(item)));
            this.setText(Items.name(item));
        } else {
            this.setGraphic(null);
            this.setText("未配備");
        }

        @SuppressWarnings("unchecked")
        TableRow<Plane> row = this.getTableRow();
        if (row != null) {
            Plane plane = row.getItem();
            if (plane != null && plane.getPlaneInfo() != null) {
                PlaneInfo planeInfo = plane.getPlaneInfo();
                if (planeInfo.getState() != 1) {
                    this.getStyleClass().add("change");
                }
            }
        }
    } else {
        this.setGraphic(null);
        this.setText(null);
    }
}
 
源代码28 项目: logbook-kai   文件: AirBaseController.java
@Override
protected void updateItem(Integer count, boolean empty) {
    super.updateItem(count, empty);

    this.getStyleClass().removeAll("lowsupply");

    if (!empty) {
        if (count != null) {
            @SuppressWarnings("unchecked")
            TableRow<Plane> row = this.getTableRow();
            if (row != null) {
                Plane plane = row.getItem();
                if (plane != null && plane.getPlaneInfo() != null) {
                    PlaneInfo planeInfo = plane.getPlaneInfo();
                    if (planeInfo.getCount() != null && !planeInfo.getCount().equals(planeInfo.getMaxCount())) {
                        this.getStyleClass().add("lowsupply");
                    }
                }
            }
            this.setText(String.valueOf(count));
        } else {
            this.setText(null);
        }
    } else {
        this.setText(null);
    }
}
 
源代码29 项目: pmd-designer   文件: EventLogController.java
@Override
protected void beforeParentInit() {

    final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
    logDateColumn.setCellValueFactory(entry -> new SimpleObjectProperty<>(entry.getValue()));
    logDateColumn.setCellFactory(column -> new TableCell<LogEntry, LogEntry>() {

        Subscription sub = null;


        // adds an icon to the date for new entries
        @Override
        protected void updateItem(LogEntry item, boolean empty) {
            super.updateItem(item, empty);

            if (sub != null) {
                sub.unsubscribe();
            }
            if (item == null || empty) {
                setText(null);
                setGraphic(null);
            } else {
                setText(dateFormat.format(item.getTimestamp()));
                sub = item.wasExaminedProperty()
                          .map(wasExamined -> wasExamined ? null : new FontIcon("fas-exclamation-circle"))
                          .values()
                          .subscribe(graphicProperty()::setValue);
            }
        }
    });

    logCategoryColumn.setResizable(true);
    logCategoryColumn.setCellValueFactory(new PropertyValueFactory<>("category"));
    logMessageColumn.setCellValueFactory(new PropertyValueFactory<>("message"));
    logMessageColumn.setSortable(false);

    // wrap message text
    logMessageColumn.setCellFactory(col -> {
        TableCell<LogEntry, String> cell = new TableCell<>();
        Text text = new Text();
        text.wrappingWidthProperty().bind(cell.widthProperty());
        text.textProperty().bind(cell.itemProperty());
        cell.setGraphic(text);
        return cell;
    });

    // sizing

    eventLogTableView.resizeColumn(logMessageColumn, -1);

    logMessageColumn.prefWidthProperty()
                    .bind(eventLogTableView.widthProperty()
                                           .subtract(logCategoryColumn.getWidth())
                                           .subtract(logDateColumn.getPrefWidth())
                                           .subtract(2)); // makes it work

    // add a "new-entry" pseudo-class to rows for new log entries, styling is done in CSS
    eventLogTableView.setRowFactory(tv -> {
        TableRow<LogEntry> row = new TableRow<>();
        ChangeListener<Boolean> examinedListener = (obs, oldVal, newVal) -> row.pseudoClassStateChanged(NEW_ENTRY, !newVal);
        row.itemProperty().addListener((obs, previousEntry, currentEntry) -> {
            if (previousEntry != null) {
                previousEntry.wasExaminedProperty().removeListener(examinedListener);
            }
            if (currentEntry != null) {
                currentEntry.wasExaminedProperty().addListener(examinedListener);
                row.pseudoClassStateChanged(NEW_ENTRY, !currentEntry.isWasExamined());
            } else {
                row.pseudoClassStateChanged(NEW_ENTRY, false);
            }
        });
        return row;
    });

}
 
源代码30 项目: marathonv5   文件: ResultPane.java
@SuppressWarnings("unchecked")
private void initResultTable() {
    resultTable.setId("resultTable");
    setLabel();
    TableColumn<Failure, String> messageColumn = new TableColumn<>("Message");
    messageColumn.setCellValueFactory(new PropertyValueFactory<>("message"));
    messageColumn.prefWidthProperty().bind(resultTable.widthProperty().multiply(0.50));

    TableColumn<Failure, String> fileNameColumn = new TableColumn<>("File");
    fileNameColumn.setCellValueFactory(new PropertyValueFactory<>("fileName"));
    fileNameColumn.prefWidthProperty().bind(resultTable.widthProperty().multiply(0.245));

    TableColumn<Failure, String> locationColumn = new TableColumn<>("Location");
    locationColumn.setCellValueFactory(new PropertyValueFactory<>("lineNumber"));
    locationColumn.prefWidthProperty().bind(resultTable.widthProperty().multiply(0.249));

    failuresList.addListener(new ListChangeListener<Failure>() {
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends Failure> c) {
            if (failuresList.size() == 0) {
                clearButton.setDisable(true);
            } else {
                clearButton.setDisable(false);
            }
        }
    });

    resultTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null && newValue.getMessage() != null) {
            showMessageButton.setDisable(false);
        } else {
            showMessageButton.setDisable(true);
        }
    });

    resultTable.setRowFactory(e -> {
        TableRow<Failure> tableRow = new TableRow<>();
        tableRow.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2 && !tableRow.isEmpty()) {
                SourceLine[] traceback = tableRow.getItem().getTraceback();
                if (traceback.length > 0) {
                    fireResultPaneSelectedEvent(traceback[0]);
                }
            }
        });
        return tableRow;
    });

    resultTable.setItems(failuresList);
    resultTable.getColumns().addAll(messageColumn, fileNameColumn, locationColumn);
    VBox tableContent = new VBox(tableLabel, resultTable);
    VBox.setVgrow(tableContent, Priority.ALWAYS);
    VBox.setVgrow(resultTable, Priority.ALWAYS);
    resultPaneLayout.setCenter(tableContent);
}
 
 类所在包
 类方法
 同包方法