public FileInfoTablePanel() {
    tableItems = FXCollections.observableArrayList();

    tableView = new TableView<>(tableItems);

    final TableColumn<FileInfoPath, String> col0 = new TableColumn<>("Name");
    col0.setCellValueFactory(
        p -> new ReadOnlyObjectWrapper<>(p.getValue().getFileInfo().getFilename()));
    col0.prefWidthProperty().bind(tableView.widthProperty().multiply(0.3));
    tableView.getColumns().add(col0);

    final TableColumn<FileInfoPath, String> col1 = new TableColumn<>("Path");
    col1.setCellValueFactory(p -> new ReadOnlyObjectWrapper<>(p.getValue().getPath()));
    col1.prefWidthProperty().bind(tableView.widthProperty().multiply(0.6));
    tableView.getColumns().add(col1);

    final TableColumn<FileInfoPath, String> col2 = new TableColumn<>("Size");
    col2.setCellValueFactory(
        p ->
            new ReadOnlyObjectWrapper<>(
                BackupUtil.humanReadableByteCount(p.getValue().getFileInfo().getSize())));
    col2.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
    tableView.getColumns().add(col2);

    final TableColumn<FileInfoPath, String> col3 = new TableColumn<>("Alg");
    col3.setCellValueFactory(
        p -> new ReadOnlyObjectWrapper<>(p.getValue().getFileInfo().getDigestAlg().name()));
    col3.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
    tableView.getColumns().add(col3);

    final TableColumn<FileInfoPath, String> col4 = new TableColumn<>("Digest");
    col4.setCellValueFactory(
        p -> new ReadOnlyObjectWrapper<>(p.getValue().getFileInfo().getDigest()));
    col4.prefWidthProperty().bind(tableView.widthProperty().multiply(0.2));
    tableView.getColumns().add(col4);

    final TableColumn<FileInfoPath, String> col5 = new TableColumn<>("Timestamp");
    col5.setCellValueFactory(
        p -> new ReadOnlyObjectWrapper<>(p.getValue().getFileInfo().getLastModifiedStr()));
    col5.prefWidthProperty().bind(tableView.widthProperty().multiply(0.2));
    tableView.getColumns().add(col5);

    final TableColumn<FileInfoPath, Integer> col6 = new TableColumn<>("Path Len");
    col6.setCellValueFactory(p -> new ReadOnlyObjectWrapper<>(p.getValue().getPath().length()));
    col6.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
    tableView.getColumns().add(col6);

    tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    // pathList.setVisibleRowCount(4);
    tableView.setPrefHeight(100);

    label = new Label();

    final ScrollPane scrollPane = GuiUtils.createScrollPane(tableView);

    setCenter(scrollPane);
    setBottom(label);

    setFileInfo(null, null);
  }
Beispiel #2
0
  public static String getSpeed(final long bytes, final long timeElapsed) {
    final String ret;

    if (timeElapsed > 0) {
      final long bytesPerSec =
          Math.round(bytes / (double) TimeUnit.SECONDS.convert(timeElapsed, TimeUnit.MILLISECONDS));

      ret = BackupUtil.humanReadableByteCount(bytesPerSec) + "/s";
    } else {
      ret = "?";
    }

    return ret;
  }