Пример #1
0
 /**
  * Create the legalality column, which holds the legality of a filter and also creates a callback
  * to the string property behind it.
  */
 private void setUpLegalityColumn(TableView<FilterInput> tableView) {
   // Set up priority column
   final TableColumn<FilterInput, Boolean> legalColumn = new TableColumn<>("Authorized");
   legalColumn.setMinWidth(70);
   legalColumn.setPrefWidth(70);
   tableView.getColumns().add(legalColumn);
   legalColumn.setCellValueFactory(p -> p.getValue().getLegalProperty());
 }
Пример #2
0
 /**
  * Create the priority column, which holds the priority of a filter and also creates a callback to
  * the integer property behind it.
  */
 private void setUpPriorityColumn(TableView<FilterInput> tableView) {
   // Set up priority column
   final TableColumn<FilterInput, Integer> priorityColumn = new TableColumn<>("Priority");
   priorityColumn.setMinWidth(50);
   priorityColumn.setPrefWidth(50);
   tableView.getColumns().add(priorityColumn);
   priorityColumn.setCellValueFactory(p -> p.getValue().getPriorityProperty().asObject());
 }
Пример #3
0
 /**
  * Create the origin column, which holds the type of the origin and also creates a callback to the
  * string property behind it.
  */
 private void setUpOriginColumn(TableView<FilterInput> tableView) {
   // Set up origin column
   final TableColumn<FilterInput, String> originColumn = new TableColumn<>("Filtered By");
   originColumn.setMinWidth(90);
   originColumn.setPrefWidth(90);
   tableView.getColumns().add(originColumn);
   originColumn.setCellValueFactory(p -> p.getValue().getFilterTypeProperty());
 }
Пример #4
0
 /**
  * Create the type column, which holds the type of the filter and also creates a callback to the
  * string property behind it.
  */
 private void setUpTypeColumn(TableView<FilterInput> tableView) {
   // Set up type column
   final TableColumn<FilterInput, String> typeColumn = new TableColumn<>("Selection Model");
   typeColumn.setMinWidth(90);
   typeColumn.setPrefWidth(90);
   tableView.getColumns().add(typeColumn);
   typeColumn.setCellValueFactory(p -> p.getValue().getSelectionModelProperty());
 }
Пример #5
0
 /**
  * Create the filter column, which holds the name of the filter and also creates a callback to the
  * string property behind it.
  */
 private void setUpFilterColumn(TableView<FilterInput> tableView) {
   // Set up filter column
   final TableColumn<FilterInput, String> filterColumn = new TableColumn<>("Filter");
   filterColumn.setMinWidth(120);
   filterColumn.setPrefWidth(120);
   tableView.getColumns().add(filterColumn);
   filterColumn.setCellValueFactory(p -> p.getValue().getNameProperty());
 }
Пример #6
0
  private void setupTracksView() {
    TableColumn titleColumn = new TableColumn("Title");
    titleColumn.setSortable(false);
    titleColumn.setMinWidth(USE_COMPUTED_SIZE);
    titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

    TableColumn durationColumn = new TableColumn("Duration");
    durationColumn.setMinWidth(60);
    durationColumn.setMaxWidth(60);
    durationColumn.setSortable(false);
    durationColumn.setCellValueFactory(new PropertyValueFactory<>("durationFormatted"));
    durationColumn.getStyleClass().add("text-layout-center");

    tracksView.getColumns().clear();
    tracksView.getColumns().addAll(titleColumn, durationColumn);
    tracksView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  }
Пример #7
0
  private void setupPlaylistsView() {
    TableColumn titleColumn = new TableColumn("Title");
    titleColumn.setMinWidth(USE_COMPUTED_SIZE);
    titleColumn.setSortable(false);
    titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

    TableColumn countColumn = new TableColumn("Tracks");
    countColumn.setMinWidth(60);
    countColumn.setMaxWidth(60);
    countColumn.setSortable(false);
    countColumn.setCellValueFactory(new PropertyValueFactory<>("count"));
    countColumn.getStyleClass().add("text-layout-right");

    playlistsView.getColumns().clear();
    playlistsView.getColumns().addAll(titleColumn, countColumn);
    playlistsView.setContextMenu(playlistsContextMenu);
    playlistsView.setPlaceholder(playlistPlaceholder);
    playlistsView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  }
Пример #8
0
  /**
   * Create the active column, which holds the activity state and also creates a callback to the
   * string property behind it.
   */
  private void setUpActiveColumn(TableView<FilterInput> tableView) {
    // Set up active column
    final TableColumn<FilterInput, Boolean> activeColumn = new TableColumn<>("Active");
    activeColumn.setMinWidth(50);
    activeColumn.setPrefWidth(50);
    tableView.getColumns().add(activeColumn);
    activeColumn.setSortable(false);

    activeColumn.setCellFactory(
        CheckBoxTableCell.forTableColumn(
            (Callback<Integer, ObservableValue<Boolean>>)
                param -> {
                  final FilterInput input = tableView.getItems().get(param);
                  input
                      .getActiveProperty()
                      .addListener(
                          l -> {
                            notifyUpdateCommand(input);
                          });
                  return input.getActiveProperty();
                }));
  }
Пример #9
0
  /**
   * Create the color column, which holds the color and also creates a callback to the string
   * property behind it.
   */
  private void setUpColorColumn(TableView<FilterInput> tableView) {
    final TableColumn<FilterInput, Color> colorColumn = new TableColumn<>("Color");
    colorColumn.setMinWidth(50);
    colorColumn.setPrefWidth(50);
    colorColumn.setSortable(false);
    tableView.getColumns().add(colorColumn);

    // Set the cell value factory for the color
    colorColumn.setCellValueFactory(p -> p.getValue().getColorProperty());

    // Set the cell factory for the color
    colorColumn.setCellFactory(
        param ->
            new TableCell<FilterInput, Color>() {

              final Rectangle rectangle = new Rectangle();

              @Override
              public void updateItem(Color item, boolean empty) {
                // Add the color to the row
                if (item != null) {
                  HBox hBox = new HBox();
                  hBox.getChildren().add(rectangle);
                  rectangle.setHeight(20);
                  rectangle.setWidth(30);
                  hBox.setAlignment(Pos.CENTER);

                  rectangle.setFill(item);

                  setGraphic(hBox);
                }

                // Remove the color if the row has been removed
                if (empty) {
                  setGraphic(null);
                }
              }
            });
  }