diff --git a/fxtemplates/SNAPP.xml b/fxtemplates/SNAPP.xml index da6429f..040d7ed 100644 --- a/fxtemplates/SNAPP.xml +++ b/fxtemplates/SNAPP.xml @@ -1,12 +1,12 @@ beastfx.app.inputeditor.BeautiConnector beastfx.app.inputeditor.BeautiSubTemplate - + - + @@ -150,7 +150,7 @@ - + @@ -193,7 +193,7 @@ - + @@ -263,7 +263,7 @@ - + @@ -276,14 +276,14 @@ - + ]]> - + ]]> @@ -416,7 +416,7 @@ - + diff --git a/src/snap/app/inputeditor/DataInputEditor.java b/src/snap/app/inputeditor/DataInputEditor.java index 2ee91db..51a2a03 100644 --- a/src/snap/app/inputeditor/DataInputEditor.java +++ b/src/snap/app/inputeditor/DataInputEditor.java @@ -2,6 +2,8 @@ + + import java.util.*; import java.util.regex.PatternSyntaxException; @@ -9,8 +11,8 @@ import beastfx.app.inputeditor.BeautiDoc; import beastfx.app.inputeditor.GuessPatternDialog; import beastfx.app.inputeditor.InputEditor; -import beastfx.app.inputeditor.TaxonSetInputEditor.TaxonMap; import beastfx.app.util.FXUtils; +import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.EventHandler; import javafx.scene.control.Button; @@ -22,6 +24,7 @@ import javafx.scene.control.Tooltip; import javafx.scene.control.TableColumn.CellEditEvent; import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; @@ -39,7 +42,6 @@ public DataInputEditor(BeautiDoc doc) { super(doc); } - private static final long serialVersionUID = 1L; List m_taxonset; List m_lineageset; Map m_taxonMap; @@ -102,11 +104,11 @@ private Pane getContent(List taxonset) { } } + taxonMapping = FXCollections.observableArrayList(); // set up table. // special features: background shading of rows // custom editor allowing only Date column to be edited. taxonSetToModel(); - // set up table. // special features: background shading of rows @@ -123,17 +125,17 @@ private Pane getContent(List taxonset) { new PropertyValueFactory("Taxon") ); m_table.getColumns().add(col1); - col1.getSortNode().setOnMouseClicked(e -> { - // The index of the column whose header was clicked - int vColIndex = 0; - if (vColIndex != m_sortByColumn) { - m_sortByColumn = vColIndex; - m_bIsAscending = true; - } else { - m_bIsAscending = !m_bIsAscending; - } - taxonSetToModel(); - }); +// col1.getSortNode().setOnMouseClicked(e -> { +// // The index of the column whose header was clicked +// int vColIndex = 0; +// if (vColIndex != m_sortByColumn) { +// m_sortByColumn = vColIndex; +// m_bIsAscending = true; +// } else { +// m_bIsAscending = !m_bIsAscending; +// } +// taxonSetToModel(); +// }); TableColumn col2 = new TableColumn<>("Species/Population"); col2.setPrefWidth(500); @@ -141,17 +143,32 @@ private Pane getContent(List taxonset) { col2.setCellValueFactory( new PropertyValueFactory("Taxon2") ); - col2.getSortNode().setOnMouseClicked(e -> { - // The index of the column whose header was clicked - int vColIndex = 1; - if (vColIndex != m_sortByColumn) { - m_sortByColumn = vColIndex; - m_bIsAscending = true; - } else { - m_bIsAscending = !m_bIsAscending; - } - taxonSetToModel(); - }); + col2.setCellFactory(TextFieldTableCell.forTableColumn()); + col2.setOnEditCommit( + new EventHandler>() { + @Override + public void handle(CellEditEvent event) { + String newValue = event.getNewValue(); + TaxonMap location = event.getRowValue(); + location.taxon2 = newValue; + modelToTaxonset(); + m_table.refresh(); + validateInput(); + } + } + ); + +// col2.getSortNode().setOnMouseClicked(e -> { +// // The index of the column whose header was clicked +// int vColIndex = 1; +// if (vColIndex != m_sortByColumn) { +// m_sortByColumn = vColIndex; +// m_bIsAscending = true; +// } else { +// m_bIsAscending = !m_bIsAscending; +// } +// taxonSetToModel(); +// }); m_table.getColumns().add(col2); m_table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); @@ -415,7 +432,10 @@ private void taxonSetToModel() { i++; } } - + if (taxonMapping == null) { + return; + } + // clear table model taxonMapping.clear(); @@ -442,7 +462,9 @@ private void taxonSetToModel() { // } // } // }); - m_table.refresh(); + if (m_table != null) { + m_table.refresh(); + } }