diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersForm.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersForm.java index 05ee5e1e..85d85039 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersForm.java @@ -14,6 +14,7 @@ public class HeadersForm extends TransactionForm { public Node getContents() throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("headers.fxml")); Node node = loader.load(); + node.setUserData(this); HeadersController controller = loader.getController(); controller.setModel(this); return node; diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java index b0d18bfd..605f0523 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java @@ -48,6 +48,7 @@ public class InputForm extends IndexedTransactionForm { public Node getContents() throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("input.fxml")); Node node = loader.load(); + node.setUserData(this); InputController controller = loader.getController(); controller.setModel(this); return node; diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputsForm.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputsForm.java index f88545a9..d2a49bc6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputsForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputsForm.java @@ -14,6 +14,7 @@ public class InputsForm extends TransactionForm { public Node getContents() throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("inputs.fxml")); Node node = loader.load(); + node.setUserData(this); InputsController controller = loader.getController(); controller.setModel(this); return node; diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java index db8c5e89..235f6851 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java @@ -38,6 +38,7 @@ public class OutputForm extends IndexedTransactionForm { public Node getContents() throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("output.fxml")); Node node = loader.load(); + node.setUserData(this); OutputController controller = loader.getController(); controller.setModel(this); return node; diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputsForm.java b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputsForm.java index f80c0d1c..3ec5eb37 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputsForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputsForm.java @@ -17,6 +17,7 @@ public class OutputsForm extends TransactionForm { public Node getContents() throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("outputs.fxml")); Node node = loader.load(); + node.setUserData(this); OutputsController controller = loader.getController(); controller.setModel(this); return node; diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java index a0af149b..b9d3321f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java @@ -197,31 +197,44 @@ public class TransactionController implements Initializable { Platform.runLater(this::refreshTxHex); } } else { + Node detailPane = null; + for(Node txdetail : txpane.getChildren()) { + TransactionForm childForm = (TransactionForm)txdetail.getUserData(); + if(transactionForm == childForm) { + detailPane = txdetail; + txdetail.setViewOrder(0); + } else { + txdetail.setViewOrder(1); + } + } + try { - Node node = transactionForm.getContents(); - txpane.getChildren().clear(); - txpane.getChildren().add(node); - - if (node instanceof Parent) { - Parent parent = (Parent) node; - txhex.getStylesheets().clear(); - txhex.getStylesheets().addAll(parent.getStylesheets()); - - selectedInputIndex = -1; - selectedOutputIndex = -1; - if (transactionForm instanceof InputForm) { - InputForm inputForm = (InputForm) transactionForm; - selectedInputIndex = inputForm.getTransactionInput().getIndex(); - } else if (transactionForm instanceof OutputForm) { - OutputForm outputForm = (OutputForm) transactionForm; - selectedOutputIndex = outputForm.getTransactionOutput().getIndex(); - } - - Platform.runLater(this::refreshTxHex); + if(detailPane == null) { + detailPane = transactionForm.getContents(); + detailPane.setViewOrder(0); + txpane.getChildren().add(detailPane); } } catch (IOException e) { throw new IllegalStateException("Can't find pane", e); } + + if(detailPane instanceof Parent) { + Parent parent = (Parent)detailPane; + txhex.getStylesheets().clear(); + txhex.getStylesheets().addAll(parent.getStylesheets()); + + selectedInputIndex = -1; + selectedOutputIndex = -1; + if(transactionForm instanceof InputForm) { + InputForm inputForm = (InputForm) transactionForm; + selectedInputIndex = inputForm.getTransactionInput().getIndex(); + } else if(transactionForm instanceof OutputForm) { + OutputForm outputForm = (OutputForm) transactionForm; + selectedOutputIndex = outputForm.getTransactionOutput().getIndex(); + } + + Platform.runLater(this::refreshTxHex); + } } }); diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml index 15a0df89..9497d0c6 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml @@ -15,7 +15,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml index eae921c9..1c490635 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml @@ -17,7 +17,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.fxml index ddc7e1d3..610ba159 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.fxml @@ -8,7 +8,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml index 467652a5..400cefdf 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml @@ -15,7 +15,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.fxml index e24b56fd..04935840 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.fxml @@ -8,7 +8,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.css index 7f4f89e5..523ec217 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.css +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.css @@ -4,6 +4,10 @@ -fx-padding: 2; } +.tx-pane { + -fx-background-color: -fx-background; +} + .color-0 { -fx-fill: #ca1243 } .color-1 { -fx-fill: #d75f00 } .color-2 { -fx-fill: #c18401 } diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.fxml index cddf4585..3a5d8d90 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/transaction.fxml @@ -15,7 +15,7 @@ false - +