mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
remove block hash from transaction tab fields, add to context menu for block height and timestamp
This commit is contained in:
parent
4e3e8b7cc4
commit
a6a671f687
2 changed files with 34 additions and 28 deletions
|
@ -176,12 +176,6 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
@FXML
|
||||
private CopyableLabel blockTimestamp;
|
||||
|
||||
@FXML
|
||||
private Field blockHashField;
|
||||
|
||||
@FXML
|
||||
private IdLabel blockHash;
|
||||
|
||||
@FXML
|
||||
private Form signingWalletForm;
|
||||
|
||||
|
@ -746,11 +740,11 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
|
||||
blockHeightField.managedProperty().bind(blockHeightField.visibleProperty());
|
||||
blockTimestampField.managedProperty().bind(blockTimestampField.visibleProperty());
|
||||
blockHashField.managedProperty().bind(blockHashField.visibleProperty());
|
||||
|
||||
if(blockTransaction.getHeight() > 0) {
|
||||
blockHeightField.setVisible(true);
|
||||
blockHeight.setText(Integer.toString(blockTransaction.getHeight()));
|
||||
blockHeight.setContextMenu(new BlockHeightContextMenu(blockTransaction));
|
||||
} else {
|
||||
blockHeightField.setVisible(false);
|
||||
}
|
||||
|
@ -759,17 +753,10 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
blockTimestampField.setVisible(true);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(BLOCK_TIMESTAMP_DATE_FORMAT);
|
||||
blockTimestamp.setText(dateFormat.format(blockTransaction.getDate()));
|
||||
blockTimestamp.setContextMenu(new BlockHeightContextMenu(blockTransaction));
|
||||
} else {
|
||||
blockTimestampField.setVisible(false);
|
||||
}
|
||||
|
||||
if(blockTransaction.getBlockHash() != null && !blockTransaction.getBlockHash().equals(Sha256Hash.ZERO_HASH)) {
|
||||
blockHashField.setVisible(true);
|
||||
blockHash.setText(blockTransaction.getBlockHash().toString());
|
||||
blockHash.setContextMenu(new BlockHeightContextMenu(blockTransaction.getBlockHash()));
|
||||
} else {
|
||||
blockHashField.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeSignButton(Wallet signingWallet) {
|
||||
|
@ -809,15 +796,38 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
}
|
||||
|
||||
private static class BlockHeightContextMenu extends ContextMenu {
|
||||
public BlockHeightContextMenu(Sha256Hash blockHash) {
|
||||
MenuItem copyBlockHash = new MenuItem("Copy Block Hash");
|
||||
copyBlockHash.setOnAction(AE -> {
|
||||
hide();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(blockHash.toString());
|
||||
Clipboard.getSystemClipboard().setContent(content);
|
||||
});
|
||||
getItems().add(copyBlockHash);
|
||||
public BlockHeightContextMenu(BlockTransaction blockTransaction) {
|
||||
if(blockTransaction.getHeight() > 0) {
|
||||
MenuItem copyBlockHeight = new MenuItem("Copy Block Height");
|
||||
copyBlockHeight.setOnAction(AE -> {
|
||||
hide();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(Integer.toString(blockTransaction.getHeight()));
|
||||
Clipboard.getSystemClipboard().setContent(content);
|
||||
});
|
||||
getItems().add(copyBlockHeight);
|
||||
}
|
||||
if(blockTransaction.getDate() != null) {
|
||||
MenuItem copyBlockTimestamp = new MenuItem("Copy Block Timestamp");
|
||||
copyBlockTimestamp.setOnAction(AE -> {
|
||||
hide();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(BLOCK_TIMESTAMP_DATE_FORMAT);
|
||||
content.putString(dateFormat.format(blockTransaction.getDate()));
|
||||
Clipboard.getSystemClipboard().setContent(content);
|
||||
});
|
||||
getItems().add(copyBlockTimestamp);
|
||||
}
|
||||
if(blockTransaction.getBlockHash() != null && !blockTransaction.getBlockHash().equals(Sha256Hash.ZERO_HASH)) {
|
||||
MenuItem copyBlockHash = new MenuItem("Copy Block Hash");
|
||||
copyBlockHash.setOnAction(AE -> {
|
||||
hide();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(blockTransaction.getBlockHash().toString());
|
||||
Clipboard.getSystemClipboard().setContent(content);
|
||||
});
|
||||
getItems().add(copyBlockHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1342,7 +1352,6 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
errorGlyph.getStyleClass().add("failure");
|
||||
blockHeightField.setVisible(false);
|
||||
blockTimestampField.setVisible(false);
|
||||
blockHashField.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,9 +187,6 @@
|
|||
<Field fx:id="blockTimestampField" text="Timestamp:">
|
||||
<CopyableLabel fx:id="blockTimestamp" />
|
||||
</Field>
|
||||
<Field fx:id="blockHashField" text="Block Hash:">
|
||||
<IdLabel fx:id="blockHash" />
|
||||
</Field>
|
||||
</Fieldset>
|
||||
</DynamicForm>
|
||||
|
||||
|
|
Loading…
Reference in a new issue