mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
dynamically truncate input and output labels in the tree on a transaction tab, and add tooltips if necessary
This commit is contained in:
parent
b3a6340c45
commit
c9d7b8ef9a
3 changed files with 22 additions and 7 deletions
|
|
@ -49,7 +49,7 @@ class LabelCell extends TextFieldTreeTableCell<Entry, String> implements Confirm
|
||||||
double width = label == null || label.length() < 20 ? 0.0 : TextUtils.computeTextWidth(getFont(), label, 0.0D);
|
double width = label == null || label.length() < 20 ? 0.0 : TextUtils.computeTextWidth(getFont(), label, 0.0D);
|
||||||
if(width > getTableColumn().getWidth()) {
|
if(width > getTableColumn().getWidth()) {
|
||||||
Tooltip tooltip = new Tooltip(label);
|
Tooltip tooltip = new Tooltip(label);
|
||||||
tooltip.setPrefWidth(getTreeTableView().getWidth());
|
tooltip.setMaxWidth(getTreeTableView().getWidth());
|
||||||
tooltip.setWrapText(true);
|
tooltip.setWrapText(true);
|
||||||
setTooltip(tooltip);
|
setTooltip(tooltip);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,19 @@ import com.sparrowwallet.drongo.wallet.*;
|
||||||
import com.sparrowwallet.sparrow.AppServices;
|
import com.sparrowwallet.sparrow.AppServices;
|
||||||
import com.sparrowwallet.sparrow.EventManager;
|
import com.sparrowwallet.sparrow.EventManager;
|
||||||
import com.sparrowwallet.sparrow.TransactionTabData;
|
import com.sparrowwallet.sparrow.TransactionTabData;
|
||||||
|
import com.sparrowwallet.sparrow.control.TextUtils;
|
||||||
import com.sparrowwallet.sparrow.control.TransactionHexArea;
|
import com.sparrowwallet.sparrow.control.TransactionHexArea;
|
||||||
import com.sparrowwallet.sparrow.event.*;
|
import com.sparrowwallet.sparrow.event.*;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.property.DoubleProperty;
|
||||||
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.TreeCell;
|
|
||||||
import javafx.scene.control.TreeItem;
|
|
||||||
import javafx.scene.control.TreeView;
|
|
||||||
import javafx.scene.input.*;
|
import javafx.scene.input.*;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import org.controlsfx.control.MasterDetailPane;
|
import org.controlsfx.control.MasterDetailPane;
|
||||||
|
|
@ -44,6 +44,9 @@ public class TransactionController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
private MasterDetailPane transactionMasterDetail;
|
private MasterDetailPane transactionMasterDetail;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private SplitPane txSplitPane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TreeView<TransactionForm> txtree;
|
private TreeView<TransactionForm> txtree;
|
||||||
|
|
||||||
|
|
@ -67,6 +70,8 @@ public class TransactionController implements Initializable {
|
||||||
private TreeItem<TransactionForm> draggedItem;
|
private TreeItem<TransactionForm> draggedItem;
|
||||||
private TreeCell<TransactionForm> dropZone;
|
private TreeCell<TransactionForm> dropZone;
|
||||||
|
|
||||||
|
private final DoubleProperty txTreeWidthProperty = new SimpleDoubleProperty();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
EventManager.get().register(this);
|
EventManager.get().register(this);
|
||||||
|
|
@ -99,6 +104,8 @@ public class TransactionController implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTxTree() {
|
private void initializeTxTree() {
|
||||||
|
txTreeWidthProperty.bind(txSplitPane.widthProperty().multiply(txSplitPane.getDividers().getFirst().positionProperty()));
|
||||||
|
|
||||||
HeadersForm headersForm = new HeadersForm(txdata);
|
HeadersForm headersForm = new HeadersForm(txdata);
|
||||||
TreeItem<TransactionForm> rootItem = new TreeItem<>(headersForm);
|
TreeItem<TransactionForm> rootItem = new TreeItem<>(headersForm);
|
||||||
rootItem.setExpanded(true);
|
rootItem.setExpanded(true);
|
||||||
|
|
@ -159,9 +166,17 @@ public class TransactionController implements Initializable {
|
||||||
|
|
||||||
if(form != null) {
|
if(form != null) {
|
||||||
Label label = form.getLabel();
|
Label label = form.getLabel();
|
||||||
label.setMaxWidth(115);
|
label.maxWidthProperty().bind(txTreeWidthProperty.subtract(70));
|
||||||
setGraphic(label);
|
setGraphic(label);
|
||||||
|
|
||||||
|
double width = TextUtils.computeTextWidth(label.getFont(), label.getText(), 0.0D);
|
||||||
|
if(width > label.getMaxWidth()) {
|
||||||
|
Tooltip tooltip = new Tooltip(label.getText());
|
||||||
|
tooltip.setMaxWidth(transactionMasterDetail.getWidth());
|
||||||
|
tooltip.setWrapText(true);
|
||||||
|
label.setTooltip(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
if(form.getSigningWallet() != null) {
|
if(form.getSigningWallet() != null) {
|
||||||
setOnDragDetected(null);
|
setOnDragDetected(null);
|
||||||
setOnDragOver(null);
|
setOnDragOver(null);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
<items>
|
<items>
|
||||||
<MasterDetailPane fx:id="transactionMasterDetail" detailSide="BOTTOM">
|
<MasterDetailPane fx:id="transactionMasterDetail" detailSide="BOTTOM">
|
||||||
<masterNode>
|
<masterNode>
|
||||||
<SplitPane dividerPositions="0.15">
|
<SplitPane fx:id="txSplitPane" dividerPositions="0.15">
|
||||||
<items>
|
<items>
|
||||||
<TreeView fx:id="txtree" minWidth="170">
|
<TreeView fx:id="txtree" minWidth="170">
|
||||||
<SplitPane.resizableWithParent>false</SplitPane.resizableWithParent>
|
<SplitPane.resizableWithParent>false</SplitPane.resizableWithParent>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue