Skip to content

Commit

Permalink
more responsive refresh + do not loose list view selection #16
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Oct 4, 2022
1 parent bef311b commit 1164eea
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/beastfx/app/inputeditor/AVMNConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class AVMNConnector {

public static boolean customConnector(BeautiDoc doc) {
System.err.println("AVMNConnector::customConnector() called");
// System.err.println("AVMNConnector::customConnector() called");

// count how many partitions have the a unique clock
List<BEASTInterface> partitions = doc.getPartitions("Partitions");
Expand Down
25 changes: 19 additions & 6 deletions src/beastfx/app/inputeditor/AlignmentListInputEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.Bounds;
import javafx.geometry.Point2D;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ComboBox;
Expand Down Expand Up @@ -169,7 +172,7 @@ public void handle(DragEvent event) {
//scroller.setMinSize(doc.beauti.frame.getWidth(), doc.beauti.frame.getHeight()-155);
BeautiPanel.resizeList.clear();
BeautiPanel.resizeList.add(table);
table.setMinWidth(1020);
//table.setMinWidth(1020);
getChildren().add(pane);
updateStatus();
}
Expand Down Expand Up @@ -685,13 +688,23 @@ void initTableData() {
}

try {
if (!Double.isNaN(doc.beauti.frame.getWidth())) {
table.setMinSize(doc.beauti.frame.getWidth() - 20, doc.beauti.frame.getHeight()-160);
} else {
table.setMinSize(1024 - 20, 768 - 138);
}

// Parent root = getScene().getRoot();
// Bounds localRootBounds = root.getBoundsInLocal();
// Point2D localRootTopLeft = new Point2D(localRootBounds.getMinX(), localRootBounds.getMinY());
// Point2D screenRootTopLeft = root.localToScreen(localRootTopLeft);

table.setMinSize(doc.beauti.frame.getWidth() - 12, doc.beauti.frame.getHeight() - 160);
// System.err.println("table.setMinSize(" + (doc.beauti.frame.getWidth()-12)+","+ (doc.beauti.frame.getHeight()-230) +")");

// if (!Double.isNaN(doc.beauti.frame.getWidth())) {
// table.setMinSize(doc.beauti.frame.getWidth() - 20, doc.beauti.frame.getHeight()-160);
// } else {
// table.setMinSize(1024 - 20, 768 - 138);
// }
} catch (NullPointerException e) {
// ignore
// System.err.println("table.setMinSize(1024 - 20, 768 - 138)");
table.setMinSize(1024 - 20, 768 - 138);
}

Expand Down
15 changes: 13 additions & 2 deletions src/beastfx/app/inputeditor/BeautiPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,12 @@ private Node createList() {
}

public void updateList() {
List<Integer> selected = null;
if (listModel == null) {
return;
} else {
selected = new ArrayList<>();
selected.addAll(listOfPartitions.getSelectionModel().getSelectedIndices());
}
listModel.clear();
if (listModel.size() > 0) {
Expand All @@ -237,8 +241,15 @@ public void updateList() {
}
listModel.add(partitionID);
}
if (partitionIndex >= 0 && listModel.size() > 0)
listOfPartitions.getSelectionModel().select(partitionIndex);
if (partitionIndex >= 0 && listModel.size() > 0) {
if (selected != null && selected.size() > 0) {
for (int index : selected) {
listOfPartitions.getSelectionModel().select(index);
}
} else {
listOfPartitions.getSelectionModel().select(partitionIndex);
}
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/beastfx/app/inputeditor/InputEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ protected void sync() {
BeautiPanel panel = beauti.getCurrentPanel();
BeautiPanelConfig cfgPanel = panel.config;
cfgPanel.sync(panel.partitionIndex);
// Platform.runLater(() -> beauti.refreshPanel());
Platform.runLater(() -> beauti.refreshPanel());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/beastfx/app/inputeditor/SiteModelInputEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public static boolean customConnector(BeautiDoc doc) {
}

public static boolean avmnConnector(BeautiDoc doc) {
System.err.println("SiteModelInputEditor::avmnConnector() called");
// System.err.println("SiteModelInputEditor::avmnConnector() called");
return AVMNConnector.customConnector(doc);
}

Expand Down
9 changes: 6 additions & 3 deletions src/test/beastfx/app/beauti/BeautiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,16 @@ protected FxRobot clickOnButtonWithText(FxRobot robot, String buttonText) {

protected FxRobot clickOnNodesWithID(FxRobot robot, String id) {
NodeQuery q = robot.lookup(target -> {
if (target.getId() != null) System.err.println(target.getId());
// if (target.getId() != null) System.err.println(target.getId());
return id.equals(target.getId()) && target.isVisible();
});
Set<Node> nodes = q.queryAll();
for (Node node : nodes) {
robot.clickOn(node);
if (nodes.size() > 0) {
robot.clickOn((Node)(nodes.toArray()[0]));
}
// for (Node node : nodes) {
// robot.clickOn(node);
// }
return robot;
}

Expand Down
15 changes: 10 additions & 5 deletions src/test/beastfx/app/beauti/CloneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public void simpleSiteModelCloneTest(FxRobot robot) throws Exception {
// set category count back to 1
//beautiFrame.checkBox("shape.isEstimated").uncheck();
clickOnNodesWithID(robot, "shape.isEstimated");
printBeautiState();
assertStateEquals("Tree.t:3rdpos", "birthRate.t:3rdpos", "Tree.t:2ndpos", "birthRate.t:2ndpos", "Tree.t:noncoding", "birthRate.t:noncoding", "Tree.t:coding", "birthRate.t:coding", "Tree.t:1stpos", "birthRate.t:1stpos", "kappa.s:coding", "gammaShape.s:coding", "kappa.s:1stpos", "gammaShape.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "freqParameter.s:2ndpos", "freqParameter.s:3rdpos", "freqParameter.s:1stpos", "freqParameter.s:coding");

robot.doubleClickOn("#gammaCategoryCount").write("1");
printBeautiState();
assertStateEquals("Tree.t:3rdpos", "birthRate.t:3rdpos", "Tree.t:2ndpos", "birthRate.t:2ndpos", "Tree.t:noncoding", "birthRate.t:noncoding", "Tree.t:coding", "birthRate.t:coding", "Tree.t:1stpos", "birthRate.t:1stpos", "kappa.s:coding", "gammaShape.s:coding", "kappa.s:1stpos", "gammaShape.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "freqParameter.s:2ndpos", "freqParameter.s:3rdpos", "freqParameter.s:1stpos", "freqParameter.s:coding");
Expand Down Expand Up @@ -149,10 +152,12 @@ public void simpleClockModelCloneTest(FxRobot robot) throws Exception {
warning("1. Set the clock model of second partition to UCLD exponential");
selectTab(robot, "Clock Model");
// final ListView<?> list = robot.lookup(".list-view").queryAs(ListView.class);
robot.clickOn("noncoding");
robot.clickOn(".combo-box");//.clickOn("coding");
robot.interact(()->robot.lookup(".combo-box").queryAs(ComboBox.class).getSelectionModel().select(1));
robot.clickOn("Relaxed Clock Exponential");
robot.clickOn(".list-view").clickOn("noncoding");

// robot.clickOn(".combo-box");//.clickOn("coding");
// robot.interact(()->robot.lookup(".combo-box").queryAs(ComboBox.class).getSelectionModel().select(1));
selectFromCombobox(robot, "indexComboBox", "Relaxed Clock Exponential");
robot.clickOn(".list-view").clickOn("noncoding");
//robot.clickOn("Relaxed Clock Log Normal");

// Platform.runLater(()->list.getSelectionModel().select(1));
Expand Down Expand Up @@ -188,7 +193,7 @@ public void simpleClockModelCloneTest(FxRobot robot) throws Exception {
list.getSelectionModel().clearAndSelect(2);
});
// robot.clickOn(".combo-box").clickOn(".arrow-button").clickOn("Relaxed Clock Log Normal");
robot.interact(()->robot.lookup(".combo-box").queryAs(ComboBox.class).getSelectionModel().select(2));
robot.interact(()->robot.lookup(".combo-box").queryAs(ComboBox.class).getSelectionModel().select(3));
printBeautiState();
assertStateEquals("Tree.t:coding", "birthRate.t:coding", "clockRate.c:2ndpos", "ucedMean.c:noncoding", "expRateCategories.c:noncoding", "expRateCategories.c:coding", "ucedMean.c:3rdpos", "expRateCategories.c:3rdpos", "ucldMean.c:1stpos", "ucldStdev.c:1stpos", "rateCategories.c:1stpos");
assertOperatorsEqual("YuleBirthRateScaler.t:coding", "YuleModelBICEPSEpochTop.t:coding", "YuleModelBICEPSEpochAll.t:coding", "YuleModelBICEPSTreeFlex.t:coding", "YuleModelTreeRootScaler.t:coding", "YuleModelUniformOperator.t:coding", "YuleModelSubtreeSlide.t:coding", "YuleModelNarrow.t:coding", "YuleModelWide.t:coding", "YuleModelWilsonBalding.t:coding", "StrictClockRateScaler.c:2ndpos", "strictClockUpDownOperator.c:2ndpos", "ucedMeanScaler.c:noncoding", "ExpCategoriesRandomWalk.c:noncoding", "ExpCategoriesSwapOperator.c:noncoding", "ExpCategoriesUniform.c:noncoding", "relaxedUpDownOperatorExp.c:noncoding", "ExpCategoriesRandomWalk.c:coding", "ExpCategoriesSwapOperator.c:coding", "ExpCategoriesUniform.c:coding", "ucedMeanScaler.c:3rdpos", "ExpCategoriesRandomWalk.c:3rdpos", "ExpCategoriesSwapOperator.c:3rdpos", "ExpCategoriesUniform.c:3rdpos", "relaxedUpDownOperatorExp.c:3rdpos", "ucldMeanScaler.c:1stpos", "ucldStdevScaler.c:1stpos", "CategoriesRandomWalk.c:1stpos", "CategoriesSwapOperator.c:1stpos", "CategoriesUniform.c:1stpos", "relaxedUpDownOperator.c:1stpos");
Expand Down

0 comments on commit 1164eea

Please sign in to comment.