use view ordering to improve transaction pane perf

This commit is contained in:
Craig Raw
2020-06-16 12:11:06 +02:00
parent 7f03778ec7
commit 7cc330fde9
13 changed files with 48 additions and 26 deletions
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);
}
}
});