for (TableRow row : rows) { for (TableCell field : row.getF()) { System.out.printf("%-50s", field.getV());
tc.setCellFactory(new Callback<TableColumn, TableCell>(){ @Override public TableCell call(TableColumn param){ return new TableCell(){ @Override public void updateItem(Object item, boolean isEmpty){ //...logic to format the text assertEquals(getText(), "20%"); } }; } });
column.setCellFactory(new Callback<TableColumn, TableCell>() { @Override public TableCell call(TableColumn param) { TableCell cell = new TableCell() { @Override public void updateItem(Object item, boolean empty) { // Don't omit this: super.updateItem(item, empty); if (item != null) { setText(item.toString()); } } }; cell.setAlignment(Pos.CENTER); return cell; } });
TableColumn firstNameCol = new TableColumn(); firstNameCol.setText("First"); firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName")); firstNameCol.setCellFactory(new Callback<TableColumn, TableCell>() { @Override public TableCell call(final TableColumn param) { final TableCell cell = new TableCell() { @Override public void updateItem(Object item, boolean empty) { super.updateItem(item, empty); if (empty) { setText(null); } else { if (isEditing()) { setText(null); } else { setText(getItem().toString()); setGraphic(null); } } } }; // This way I will have context menu only for specific column cell.setContextMenu(ContextMenuBuilder.create().items(MenuItemBuilder.create().text("menu").build()).build()); return cell; } });
public TableCell call(final TableColumn param) { final TableCell cell = new TableCell() { @Override cell.commitEdit(selectedVals); } else { cell.cancelEdit();
private QueryResponse createResponseContainingTestData() { TableCell field1 = new TableCell(); field1.setV("abc"); TableCell field2 = new TableCell(); field2.setV("2"); TableCell field3 = new TableCell(); field3.setV("testing BigQuery matcher."); TableRow row = new TableRow(); row.setF(Lists.newArrayList(field1, field2, field3)); QueryResponse response = new QueryResponse(); response.setJobComplete(true); response.setRows(Lists.newArrayList(row)); response.setTotalRows(BigInteger.ONE); return response; } }
private String formatRows(int totalNumRows) { StringBuilder samples = new StringBuilder(); List<TableRow> rows = response.getRows(); for (int i = 0; i < totalNumRows && i < rows.size(); i++) { samples.append(String.format("%n\t\t")); for (TableCell field : rows.get(i).getF()) { samples.append(String.format("%-10s", field.getV())); } } if (rows.size() > totalNumRows) { samples.append(String.format("%n\t\t...")); } return samples.toString(); } }
@Test public void testDecodeEncodeEqual() throws Exception { BigQueryInsertError value = new BigQueryInsertError( new TableRow().setF(Collections.singletonList(new TableCell().setV("Value"))), new TableDataInsertAllResponse.InsertErrors() .setIndex(0L) .setErrors( Collections.singletonList( new ErrorProto() .setReason("a Reason") .setLocation("A location") .setMessage("A message") .setDebugInfo("The debug info"))), new TableReference() .setProjectId("dummy-project-id") .setDatasetId("dummy-dataset-id") .setTableId("dummy-table-id")); CoderProperties.coderDecodeEncodeEqual(TEST_CODER, value); } }
private String generateHash(@Nonnull List<TableRow> rows) { List<HashCode> rowHashes = Lists.newArrayList(); for (TableRow row : rows) { List<String> cellsInOneRow = Lists.newArrayList(); for (TableCell cell : row.getF()) { cellsInOneRow.add(Objects.toString(cell.getV())); Collections.sort(cellsInOneRow); } rowHashes.add(Hashing.sha1().hashString(cellsInOneRow.toString(), StandardCharsets.UTF_8)); } return Hashing.combineUnordered(rowHashes).toString(); }
cellScriptFunction = new TableCell(); // in this table cell I want to place the control which is returned from the javascript cellScriptFunction.Text = "<script> Vizit.Write(\"http://path/to/file.ext\", { buttons: [ \"InstantPreview\" ] }); </script>";
/** * Tries to parse the JSON {@link TableRow} from BigQuery. * * <p>Only supports basic types and arrays. Doesn't support date types. */ public static Row toBeamRow(Schema rowSchema, TableSchema bqSchema, TableRow jsonBqRow) { List<TableFieldSchema> bqFields = bqSchema.getFields(); Map<String, Integer> bqFieldIndices = IntStream.range(0, bqFields.size()) .boxed() .collect(toMap(i -> bqFields.get(i).getName(), i -> i)); List<Object> rawJsonValues = rowSchema .getFields() .stream() .map(field -> bqFieldIndices.get(field.getName())) .map(index -> jsonBqRow.getF().get(index).getV()) .collect(toList()); return IntStream.range(0, rowSchema.getFieldCount()) .boxed() .map(index -> toBeamValue(rowSchema.getField(index).getType(), rawJsonValues.get(index))) .collect(toRow(rowSchema)); }
lastNameCol.setCellFactory(new Callback() { @Override public TableCell call(TableColumn col) { return new TableCell() { @Override public void updateItem(Boolean item, boolean empty) { if (!empty) { // Don't care about the value of item // Just look up the value of firstNameCol using // getTablePosition(), then create and populate // a ComboBox with the appropriate items and set // it as the graphic for this cell via this.setGraphic() // Add handler to ComboBox control to update data item when // selection changes } } }; } });
private void verifyLegacyQueryRes() throws Exception { LOG.info("Starting verifyLegacyQueryRes in outputTable {}", outputTable); List<String> legacyQueryExpectedRes = ImmutableList.of("apple", "orange"); QueryResponse response = bqClient.queryWithRetries(String.format("SELECT fruit from [%s];", outputTable), project); LOG.info("Finished to query result table {}", this.outputTable); List<String> tableResult = response .getRows() .stream() .flatMap(row -> row.getF().stream().map(cell -> cell.getV().toString())) .sorted() .collect(Collectors.toList()); assertEquals(legacyQueryExpectedRes, tableResult); }
public static final Callback<TableColumn<?,?>, TableCell<?,?>> DEFAULT_CELL_FACTORY = new Callback<TableColumn<?,?>, TableCell<?,?>>() { @Override public TableCell<?,?> call(TableColumn<?,?> param) { return new TableCell() { @Override protected void updateItem(Object item, boolean empty) { if (item == getItem()) return; super.updateItem(item, empty); if (item == null) { super.setText(null); super.setGraphic(null); } else if (item instanceof Node) { super.setText(null); super.setGraphic((Node)item); } else { super.setText(item.toString()); super.setGraphic(null); } } }; } };
/** * Makes an API call to the BigQuery API * * @param bigquery an authorized BigQuery client * @param projectId a string containing the current project ID * @param completedJob to the completed Job * @throws IOException */ private static void displayQueryResults(Bigquery bigquery, String projectId, Job completedJob) throws IOException { GetQueryResultsResponse queryResult = bigquery.jobs() .getQueryResults( projectId, completedJob .getJobReference() .getJobId() ).execute(); List<TableRow> rows = queryResult.getRows(); System.out.print("\nQuery Results:\n------------\n"); for (TableRow row : rows) { for (TableCell field : row.getF()) { System.out.printf("%-50s", field.getV()); } System.out.println(); } } // [END display_result]
protected void AddRow(object sender, EventArgs e) { TableRow row = new TableRow(); TableCell cell = new TableCell(); aTable.Rows.Add(row); cell.Text = "Test"; row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); }
GridView1_RowCreated(Object sender, GridViewRowEventArgs e) { //some code here LinkButton lb = new LinkButton(); lb.Text = "something"; lb.ID = "someId"; TableCell cell = new TableCell(); cell.Controls.Add(lb); e.Row.Cells.Add(cell); }