List of usage examples for javafx.scene.control TableView getItems
public final ObservableList<S> getItems()
From source file:com.bekwam.examples.javafx.memorytests.BigTableController.java
static <T, S> T getObjectAtEvent(CellEditEvent<T, S> evt) { TableView<T> tableView = evt.getTableView(); ObservableList<T> items = tableView.getItems(); TablePosition<T, S> tablePosition = evt.getTablePosition(); int rowId = tablePosition.getRow(); T obj = items.get(rowId);/*from w w w . j av a 2 s . co m*/ return obj; }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
void refreshTable(TableView tableView) { final ObservableList items = tableView.getItems(); if (items == null || items.size() == 0) return;/*w w w .j a v a 2s .com*/ Object item = tableView.getItems().get(0); items.remove(item); Platform.runLater(new Runnable() { @Override public void run() { items.add(0, item); } }); }
From source file:com.saiton.ccs.validations.FormatAndValidate.java
public boolean validTableView(TableView tableView) { boolean valid = false; if (!tableView.getItems().isEmpty()) { valid = true;/*from w w w .j ava 2s. c o m*/ } else { valid = false; } return valid; }
From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java
@FXML void onTableClicked(MouseEvent event) { if (event.getClickCount() != 2) return;/*from w w w . j av a 2s .com*/ TableView tableView = ((TableView) event.getSource()); TableView.TableViewFocusModel focusModel = (TableView.TableViewFocusModel) tableView.focusModelProperty() .getValue(); TablePosition position = focusModel.getFocusedCell(); if (position.getTableColumn() == null) return; ObservableValue value = position.getTableColumn().getCellObservableValue(position.getRow()); String valueStr = value.getValue().toString(); Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setHeaderText(String.format("Value at ID:%d %s", ((LIMSData) tableView.getItems().get(position.getRow())).getId(), position.getTableColumn().getText())); if (valueStr.length() > 300) alert.setContentText(valueStr.substring(0, 300) + "..."); else alert.setContentText(valueStr); TextArea textArea = new TextArea(valueStr); textArea.setEditable(false); alert.getDialogPane().setExpandableContent(textArea); event.consume(); alert.show(); }
From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java
public List<List<String>> getDataAsTable(TableView tv) { // What columns do we have? List<List<String>> result = new LinkedList<>(); List<TableColumn> columns = tv.getColumns(); columns.forEach(col -> {//from w ww . j a v a 2 s.c om List<String> column = new LinkedList<>(); // Add the header. column.add(col.getText()); // Add the data. for (int x = 0; x < tv.getItems().size(); x++) { ObservableValue cellObservableValue = col.getCellObservableValue(x); column.add(cellObservableValue.getValue().toString()); } result.add(column); }); return result; }
From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java
public List<List<String>> getDataAsTable(TableView tv) { // What columns do we have? List<List<String>> result = new LinkedList<>(); List<TableColumn> columns = tv.getColumns(); columns.forEach(col -> {//from w w w . j av a2 s . co m List<String> column = new LinkedList<>(); // Add the header. column.add(col.getText()); // Add the data. for (int x = 0; x < tv.getItems().size(); x++) { ObservableValue cellObservableValue = col.getCellObservableValue(x); Object val = (Object) cellObservableValue.getValue(); if (val == null) column.add(""); // or NA? else column.add(val.toString()); } result.add(column); }); return result; }
From source file:org.simmi.GeneSetHead.java
License:asdf
public int searchTable(TableView table, String text, int i, boolean back, int... columns) { int v;//w w w. ja va 2 s.com if (back) { v = i - 1; if (v == -1) v = table.getItems().size(); } else v = (i + 1) % table.getItems().size(); if (isGeneview()) { while (v != i) { //int m = table.convertRowIndexToModel(v); //if( m != -1 ) { //Gene g = geneset.genelist.get(m); //String name = column == 7 || column[0] == 8 ? g.getGeneGroup().getCommonSymbol() + ", " + g.getGeneGroup().getCommonKOName( ko2name ) + ", " + : g.getGeneGroup().getCommonName(); ObservableList<TableColumn> cc = table.getColumns(); String name = ""; for (int k : columns) { TableColumn tc = cc.get(k); String val = tc.getCellObservableValue(v).toString(); name += val;//table.getValueAt(v, k); } if (name.toLowerCase().contains(text)) { //int r = table.convertRowIndexToView(v); table.scrollTo(v); //Rectangle rect = table.getCellRect(v, 0, true); //table.scrollRectToVisible( rect ); break; } if (back) { v--; if (v == -1) v = table.getItems().size() - 1; } else v = (v + 1) % table.getItems().size(); //} else break; } } else { while (v != i) { //int m = table.convertRowIndexToModel(v); //if( m != -1 ) { //GeneGroup gg = allgenegroups.get(m); //String name = gg.getCommonName(); ObservableList<TableColumn> cc = table.getColumns(); String name = ""; for (int k : columns) { TableColumn tc = cc.get(k); String val = tc.getCellObservableValue(v).toString(); name += val; //name += table.getValueAt(v, k); } if (name.toLowerCase().contains(text)) { //int r = table.convertRowIndexToView(i); //Rectangle rect = table.getCellRect(v, 0, true); //table.scrollRectToVisible( rect ); table.scrollTo(v); break; } if (back) { v--; if (v == -1) v = table.getItems().size() - 1; } else v = (v + 1) % table.getItems().size(); //} else break; } } return v; }
From source file:org.simmi.GeneSetHead.java
License:asdf
public void updateFilter(TableView table, Label label) { if (label != null) label.setText(table.getItems().size() + "/" + table.getSelectionModel().getSelectedIndices().size()); }
From source file:UI.MainStageController.java
/** * shows the correlation table in the analysis view *//* www. j a v a 2s . com*/ @FXML private void displayCorrelationTable() { //Delete whatever's been in the table before TableView<String[]> analysisTable = new TableView<>(); //We want to display correlations and p-Values of every node combination double[][] correlationMatrix = AnalysisData.getCorrelationMatrix().getData(); double[][] pValueMatrix = AnalysisData.getPValueMatrix().getData(); LinkedList<TaxonNode> taxonList = SampleComparison.getUnifiedTaxonList(LoadedData.getSamplesToAnalyze(), AnalysisData.getLevelOfAnalysis()); //Table will consist of strings String[][] tableValues = new String[correlationMatrix.length][correlationMatrix[0].length + 1]; //Add the values as formatted strings for (int i = 0; i < tableValues.length; i++) { tableValues[i][0] = taxonList.get(i).getName(); for (int j = 1; j < tableValues[0].length; j++) { tableValues[i][j] = String.format("%.3f", correlationMatrix[i][j - 1]).replace(",", ".") + "\n(" + String.format("%.2f", pValueMatrix[i][j - 1]).replace(",", ".") + ")"; } } for (int i = 0; i < tableValues[0].length; i++) { String columnTitle; if (i > 0) { columnTitle = taxonList.get(i - 1).getName(); } else { columnTitle = ""; } TableColumn<String[], String> column = new TableColumn<>(columnTitle); final int columnIndex = i; column.setCellValueFactory(cellData -> { String[] row = cellData.getValue(); return new SimpleStringProperty(row[columnIndex]); }); analysisTable.getColumns().add(column); //First column contains taxon names and should be italic if (i == 0) column.setStyle("-fx-font-style:italic;"); } for (int i = 0; i < tableValues.length; i++) { analysisTable.getItems().add(tableValues[i]); } //Display table on a new stage Stage tableStage = new Stage(); tableStage.setTitle("Correlation Table"); BorderPane tablePane = new BorderPane(); Button exportCorrelationsButton = new Button("Save correlation table to CSV"); Button exportPValuesButton = new Button("Save p-value table to CSV"); exportCorrelationsButton.setOnAction(e -> exportTableToCSV(tableValues, false)); exportPValuesButton.setOnAction(e -> exportTableToCSV(tableValues, true)); HBox exportBox = new HBox(exportCorrelationsButton, exportPValuesButton); exportBox.setPadding(new Insets(10)); exportBox.setSpacing(10); tablePane.setTop(exportBox); tablePane.setCenter(analysisTable); Scene tableScene = new Scene(tablePane); tableStage.setScene(tableScene); tableStage.show(); }