mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
fix locktime none and date
This commit is contained in:
parent
b25aa27375
commit
79e7b2440c
5 changed files with 24 additions and 9 deletions
|
@ -42,7 +42,7 @@ dependencies {
|
|||
testImplementation('junit:junit:4.12')
|
||||
}
|
||||
|
||||
mainClassName = 'com.sparrowwallet.sparrow.MainApp'
|
||||
mainClassName = 'com.sparrowwallet.sparrow/com.sparrowwallet.sparrow.MainApp'
|
||||
|
||||
run {
|
||||
applicationDefaultJvmArgs = ["-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow.png"]
|
||||
|
|
|
@ -35,8 +35,10 @@ public class AppController implements Initializable {
|
|||
void initializeView() {
|
||||
tabs.getSelectionModel().selectedItemProperty().addListener((observable, old_val, new_val) -> {
|
||||
String tabName = new_val.getText();
|
||||
if(tabs.getScene() != null) {
|
||||
Stage tabStage = (Stage)tabs.getScene().getWindow();
|
||||
tabStage.setTitle("Sparrow - " + tabName);
|
||||
}
|
||||
});
|
||||
|
||||
addExampleTxTabs();
|
||||
|
|
|
@ -14,7 +14,6 @@ public class MainApp extends Application {
|
|||
FXMLLoader transactionLoader = new FXMLLoader(getClass().getResource("app.fxml"));
|
||||
Parent root = transactionLoader.load();
|
||||
AppController appController = transactionLoader.getController();
|
||||
appController.initializeView();
|
||||
|
||||
Scene scene = new Scene(root);
|
||||
scene.getStylesheets().add(getClass().getResource("app.css").toExternalForm());
|
||||
|
@ -23,6 +22,8 @@ public class MainApp extends Application {
|
|||
stage.setScene(scene);
|
||||
stage.getIcons().add(new Image(MainApp.class.getResourceAsStream("/sparrow.png")));
|
||||
stage.show();
|
||||
|
||||
appController.initializeView();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -42,12 +42,18 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
@FXML
|
||||
private Fieldset locktimeFieldset;
|
||||
|
||||
@FXML
|
||||
private Field locktimeNoneField;
|
||||
|
||||
@FXML
|
||||
private Field locktimeBlockField;
|
||||
|
||||
@FXML
|
||||
private Field locktimeDateField;
|
||||
|
||||
@FXML
|
||||
private Spinner<Integer> locktimeNone;
|
||||
|
||||
@FXML
|
||||
private Spinner<Integer> locktimeBlock;
|
||||
|
||||
|
@ -102,16 +108,15 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
if(selection.equals("none")) {
|
||||
locktimeFieldset.getChildren().remove(locktimeDateField);
|
||||
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
||||
locktimeFieldset.getChildren().add(locktimeBlockField);
|
||||
locktimeBlock.setDisable(true);
|
||||
locktimeBlock.getValueFactory().setValue(0);
|
||||
locktimeFieldset.getChildren().remove(locktimeNoneField);
|
||||
locktimeFieldset.getChildren().add(locktimeNoneField);
|
||||
tx.setLockTime(0);
|
||||
EventManager.get().notify(tx);
|
||||
} else if(selection.equals("block")) {
|
||||
locktimeFieldset.getChildren().remove(locktimeDateField);
|
||||
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
||||
locktimeFieldset.getChildren().remove(locktimeNoneField);
|
||||
locktimeFieldset.getChildren().add(locktimeBlockField);
|
||||
locktimeBlock.setDisable(false);
|
||||
Integer block = locktimeBlock.getValue();
|
||||
if(block != null) {
|
||||
tx.setLockTime(block);
|
||||
|
@ -120,9 +125,11 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
} else {
|
||||
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
||||
locktimeFieldset.getChildren().remove(locktimeDateField);
|
||||
locktimeFieldset.getChildren().remove(locktimeNoneField);
|
||||
locktimeFieldset.getChildren().add(locktimeDateField);
|
||||
LocalDateTime date = locktimeDate.getDateTimeValue();
|
||||
if(date != null) {
|
||||
locktimeDate.setDateTimeValue(date);
|
||||
tx.setLockTime(date.toEpochSecond(OffsetDateTime.now(ZoneId.systemDefault()).getOffset()));
|
||||
EventManager.get().notify(tx);
|
||||
}
|
||||
|
@ -130,14 +137,16 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
}
|
||||
});
|
||||
|
||||
locktimeNone.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1, 0));
|
||||
if(tx.getLockTime() < MAX_BLOCK_LOCKTIME) {
|
||||
locktimeBlock.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1, (int)tx.getLockTime()));
|
||||
if(tx.getLockTime() == 0) {
|
||||
locktimeToggleGroup.selectToggle(locktimeNoneType);
|
||||
locktimeBlock.setDisable(true);
|
||||
} else {
|
||||
locktimeToggleGroup.selectToggle(locktimeBlockType);
|
||||
}
|
||||
LocalDateTime date = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
locktimeDate.setDateTimeValue(date);
|
||||
} else {
|
||||
locktimeBlock.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1));
|
||||
LocalDateTime date = Instant.ofEpochSecond(tx.getLockTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
|
|
|
@ -63,6 +63,9 @@
|
|||
</buttons>
|
||||
</SegmentedButton>
|
||||
</Field>
|
||||
<Field fx:id="locktimeNoneField" text="Block:">
|
||||
<Spinner fx:id="locktimeNone" disable="true" prefWidth="120"/>
|
||||
</Field>
|
||||
<Field fx:id="locktimeBlockField" text="Block:">
|
||||
<Spinner fx:id="locktimeBlock" prefWidth="120"/>
|
||||
</Field>
|
||||
|
|
Loading…
Reference in a new issue