Skip to content

Commit

Permalink
towards fixing #50
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed May 17, 2023
1 parent d66c60d commit a163b0d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/beastfx/app/beauti/MRCAPriorProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import beastfx.app.util.Alert;

import beastfx.app.inputeditor.BEASTObjectPanel;
import beastfx.app.inputeditor.BeautiDoc;
import beastfx.app.inputeditor.TaxonSetDialog;
import beast.base.evolution.alignment.Taxon;
import beast.base.evolution.alignment.TaxonSet;
import beast.base.evolution.tree.MRCAPrior;
import beast.base.evolution.tree.Tree;
Expand Down Expand Up @@ -53,7 +55,8 @@ public List<Distribution> createDistribution(BeautiDoc doc) {
prior.treeInput.setValue(trees.get(treeIndex), prior);
TaxonSet taxonSet = new TaxonSet();

TaxonSetDialog dlg = new TaxonSetDialog(taxonSet, PriorListInputEditor.getTaxonCandidates(prior, doc), doc);
Set<Taxon> candidates = PriorListInputEditor.getTaxonCandidates(prior, doc);
TaxonSetDialog dlg = new TaxonSetDialog(taxonSet, candidates, doc);
if (!dlg.showDialog() || dlg.taxonSet.getID() == null || dlg.taxonSet.getID().trim().equals("")) {
return null;
}
Expand Down
34 changes: 34 additions & 0 deletions src/beastfx/app/inputeditor/TaxonSetDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javafx.scene.control.DialogPane;

import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import beastfx.app.beauti.ThemeProvider;
Expand All @@ -24,6 +25,7 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.util.Callback;

import javax.swing.UIManager;

Expand Down Expand Up @@ -165,12 +167,44 @@ Pane createTaxonSelector() {
listOfTaxonCandidates.setId("listOfTaxonCandidates");
listOfTaxonCandidates.setMinSize(200,300);
listOfTaxonCandidates.setPrefSize(200,300);
listOfTaxonCandidates.setCellFactory(new Callback<ListView<Taxon>, ListCell<Taxon>>() {
@Override
public ListCell<Taxon> call(ListView<Taxon> param) {
return new ListCell<Taxon>() {
@Override
public void updateItem(Taxon taxon, boolean empty) {
super.updateItem(taxon, empty);
if (empty || taxon == null) {
setText(null);
} else {
setText(taxon.getID());
}
}
};
}
});

listOfTaxonSet = new ListView<>();
listOfTaxonSet.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
listOfTaxonSet.setId("listOfTaxonSet");
listOfTaxonSet.setMinSize(200,300);
listOfTaxonSet.setPrefSize(200,300);
listOfTaxonSet.setCellFactory(new Callback<ListView<Taxon>, ListCell<Taxon>>() {
@Override
public ListCell<Taxon> call(ListView<Taxon> param) {
return new ListCell<Taxon>() {
@Override
public void updateItem(Taxon taxon, boolean empty) {
super.updateItem(taxon, empty);
if (empty || taxon == null) {
setText(null);
} else {
setText(taxon.getID());
}
}
};
}
});

// ScrollPane scroller = new ScrollPane();
// scroller.setContent(listOfTaxonCandidates);
Expand Down
3 changes: 3 additions & 0 deletions src/beastfx/app/util/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ public static Object showInputDialog(Parent parent,
dlg.setX(node.getX() + node.getWidth()/2);
dlg.setY(node.getY() + node.getHeight()/2);
}
if (option == null) {
return null;
}
String value = (String) option.get();
for (int i = 0; i < values.length; i++) {
if (value.equals(values[i])) {
Expand Down

0 comments on commit a163b0d

Please sign in to comment.