mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06: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
|
@FXML
|
||||||
private CopyableLabel blockTimestamp;
|
private CopyableLabel blockTimestamp;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Field blockHashField;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private IdLabel blockHash;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Form signingWalletForm;
|
private Form signingWalletForm;
|
||||||
|
|
||||||
|
@ -746,11 +740,11 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
|
|
||||||
blockHeightField.managedProperty().bind(blockHeightField.visibleProperty());
|
blockHeightField.managedProperty().bind(blockHeightField.visibleProperty());
|
||||||
blockTimestampField.managedProperty().bind(blockTimestampField.visibleProperty());
|
blockTimestampField.managedProperty().bind(blockTimestampField.visibleProperty());
|
||||||
blockHashField.managedProperty().bind(blockHashField.visibleProperty());
|
|
||||||
|
|
||||||
if(blockTransaction.getHeight() > 0) {
|
if(blockTransaction.getHeight() > 0) {
|
||||||
blockHeightField.setVisible(true);
|
blockHeightField.setVisible(true);
|
||||||
blockHeight.setText(Integer.toString(blockTransaction.getHeight()));
|
blockHeight.setText(Integer.toString(blockTransaction.getHeight()));
|
||||||
|
blockHeight.setContextMenu(new BlockHeightContextMenu(blockTransaction));
|
||||||
} else {
|
} else {
|
||||||
blockHeightField.setVisible(false);
|
blockHeightField.setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -759,17 +753,10 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
blockTimestampField.setVisible(true);
|
blockTimestampField.setVisible(true);
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(BLOCK_TIMESTAMP_DATE_FORMAT);
|
SimpleDateFormat dateFormat = new SimpleDateFormat(BLOCK_TIMESTAMP_DATE_FORMAT);
|
||||||
blockTimestamp.setText(dateFormat.format(blockTransaction.getDate()));
|
blockTimestamp.setText(dateFormat.format(blockTransaction.getDate()));
|
||||||
|
blockTimestamp.setContextMenu(new BlockHeightContextMenu(blockTransaction));
|
||||||
} else {
|
} else {
|
||||||
blockTimestampField.setVisible(false);
|
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) {
|
private void initializeSignButton(Wallet signingWallet) {
|
||||||
|
@ -809,15 +796,38 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BlockHeightContextMenu extends ContextMenu {
|
private static class BlockHeightContextMenu extends ContextMenu {
|
||||||
public BlockHeightContextMenu(Sha256Hash blockHash) {
|
public BlockHeightContextMenu(BlockTransaction blockTransaction) {
|
||||||
MenuItem copyBlockHash = new MenuItem("Copy Block Hash");
|
if(blockTransaction.getHeight() > 0) {
|
||||||
copyBlockHash.setOnAction(AE -> {
|
MenuItem copyBlockHeight = new MenuItem("Copy Block Height");
|
||||||
hide();
|
copyBlockHeight.setOnAction(AE -> {
|
||||||
ClipboardContent content = new ClipboardContent();
|
hide();
|
||||||
content.putString(blockHash.toString());
|
ClipboardContent content = new ClipboardContent();
|
||||||
Clipboard.getSystemClipboard().setContent(content);
|
content.putString(Integer.toString(blockTransaction.getHeight()));
|
||||||
});
|
Clipboard.getSystemClipboard().setContent(content);
|
||||||
getItems().add(copyBlockHash);
|
});
|
||||||
|
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");
|
errorGlyph.getStyleClass().add("failure");
|
||||||
blockHeightField.setVisible(false);
|
blockHeightField.setVisible(false);
|
||||||
blockTimestampField.setVisible(false);
|
blockTimestampField.setVisible(false);
|
||||||
blockHashField.setVisible(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,9 +187,6 @@
|
||||||
<Field fx:id="blockTimestampField" text="Timestamp:">
|
<Field fx:id="blockTimestampField" text="Timestamp:">
|
||||||
<CopyableLabel fx:id="blockTimestamp" />
|
<CopyableLabel fx:id="blockTimestamp" />
|
||||||
</Field>
|
</Field>
|
||||||
<Field fx:id="blockHashField" text="Block Hash:">
|
|
||||||
<IdLabel fx:id="blockHash" />
|
|
||||||
</Field>
|
|
||||||
</Fieldset>
|
</Fieldset>
|
||||||
</DynamicForm>
|
</DynamicForm>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue