Skip to content

Commit

Permalink
fix torrent result display
Browse files Browse the repository at this point in the history
  • Loading branch information
optyfr committed May 1, 2023
1 parent 4e45a2d commit 1ea0130
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
18 changes: 2 additions & 16 deletions jrmfx/src/main/java/jrm/fx/ui/BatchToolsPanelController.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import jrm.fx.ui.controls.ButtonCellFactory;
import jrm.fx.ui.controls.Dialogs;
import jrm.fx.ui.controls.DropCell;
import jrm.fx.ui.controls.NodeCellFactory;
import jrm.fx.ui.misc.DragNDrop;
import jrm.fx.ui.misc.FileResult;
import jrm.fx.ui.misc.SrcDstResult;
Expand Down Expand Up @@ -425,22 +426,7 @@ private void initTorrentList()
saveTorrentDst();
}, File::isDirectory));
tvBatchToolsTorrentDstDirsCol.setCellValueFactory(param -> param.getValue().dstProperty());
tvBatchToolsTorrentResultCol.setCellFactory(param -> new TableCell<SrcDstResult, String>()
{
@Override
protected void updateItem(String item, boolean empty)
{
super.updateItem(item, empty);
setFont(font);
if(empty)
setText("");
else
{
setText(item);
setTooltip(new Tooltip(item));
}
}
});
tvBatchToolsTorrentResultCol.setCellFactory(param -> new NodeCellFactory<>());
tvBatchToolsTorrentResultCol.setCellValueFactory(param -> param.getValue().resultProperty());
tvBatchToolsTorrentSelCol.setCellFactory(CheckBoxTableCell.forTableColumn(param -> {
final var sdr = tvBatchToolsTorrent.getItems().get(param);
Expand Down
34 changes: 34 additions & 0 deletions jrmfx/src/main/java/jrm/fx/ui/controls/NodeCellFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package jrm.fx.ui.controls;

import javafx.geometry.Pos;
import javafx.scene.control.TableCell;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextFlow;
import jrm.fx.ui.status.NeutralToNodeFormatter;

public final class NodeCellFactory<T> extends TableCell<T,String>
{
@Override
protected void updateItem(String item, boolean empty)
{
setFont(new Font(10));
setGraphic(null);
setStyle("");
if (empty || item == null)
setText("");
else
{
setAlignment(Pos.CENTER);
setGraphic(null);
setStyle("");
final var tf = new TextFlow();
tf.getChildren().addAll(NeutralToNodeFormatter.toNodes(item));
tf.setMinWidth(USE_PREF_SIZE);
tf.setPrefWidth(USE_COMPUTED_SIZE);
tf.setTextAlignment(TextAlignment.LEFT);
tf.setPrefHeight(10);
setGraphic(tf);
}
}
}

0 comments on commit 1ea0130

Please sign in to comment.