diff --git a/build.gradle b/build.gradle index 7cbc2fb1..aa46d071 100644 --- a/build.gradle +++ b/build.gradle @@ -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"] diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 1ec01d74..ecae48f4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -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(); - Stage tabStage = (Stage)tabs.getScene().getWindow(); - tabStage.setTitle("Sparrow - " + tabName); + if(tabs.getScene() != null) { + Stage tabStage = (Stage)tabs.getScene().getWindow(); + tabStage.setTitle("Sparrow - " + tabName); + } }); addExampleTxTabs(); diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java index aa83800b..49edbfa5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java +++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java @@ -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) { diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index d3945124..0613ac0f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -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 locktimeNone; + @FXML private Spinner 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(); diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml index a3bdc6d8..26751f32 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml @@ -63,6 +63,9 @@ + + +