diff --git a/src/beastfx/app/beauti/MRCAPriorProvider.java b/src/beastfx/app/beauti/MRCAPriorProvider.java index 882debb..e08534e 100644 --- a/src/beastfx/app/beauti/MRCAPriorProvider.java +++ b/src/beastfx/app/beauti/MRCAPriorProvider.java @@ -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; @@ -53,7 +55,8 @@ public List 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 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; } diff --git a/src/beastfx/app/inputeditor/TaxonSetDialog.java b/src/beastfx/app/inputeditor/TaxonSetDialog.java index 72637fc..4e43c1d 100644 --- a/src/beastfx/app/inputeditor/TaxonSetDialog.java +++ b/src/beastfx/app/inputeditor/TaxonSetDialog.java @@ -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; @@ -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; @@ -165,12 +167,44 @@ Pane createTaxonSelector() { listOfTaxonCandidates.setId("listOfTaxonCandidates"); listOfTaxonCandidates.setMinSize(200,300); listOfTaxonCandidates.setPrefSize(200,300); + listOfTaxonCandidates.setCellFactory(new Callback, ListCell>() { + @Override + public ListCell call(ListView param) { + return new ListCell() { + @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, ListCell>() { + @Override + public ListCell call(ListView param) { + return new ListCell() { + @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); diff --git a/src/beastfx/app/util/Alert.java b/src/beastfx/app/util/Alert.java index 7547550..9881f1a 100644 --- a/src/beastfx/app/util/Alert.java +++ b/src/beastfx/app/util/Alert.java @@ -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])) {