@Override
  public void init() {
    // allow multiple rows selection
    tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    // listener for items selection change
    tableView
        .getSelectionModel()
        .getSelectedIndices()
        .addListener(
            (ListChangeListener<Integer>)
                change -> {
                  if (change.getList().size() > 0) {
                    setContextMenuState(true, true, true, true);
                  } else {
                    setContextMenuState(false, false, false, false);
                  }
                });

    // prevent table columns reordering
    tableView
        .getColumns()
        .addListener(
            (ListChangeListener<TableColumn<FileItem, ?>>)
                change -> {
                  change.next();
                  if (change.wasReplaced()) {
                    tableView.getColumns().clear();
                    tableView.getColumns().addAll(selectColumn, filenameColumn, filepathColumn);
                  }
                });

    // set column as a CheckBox column
    selectColumn.setCellFactory(
        cellData -> {
          CheckBoxTableCell<FileItem, Boolean> checkBoxTableCell = new CheckBoxTableCell<>();
          // set value changed listener
          checkBoxTableCell.setSelectedStateCallback(
              index -> tableView.getItems().get(index).selectedProperty());
          return checkBoxTableCell;
        });

    // add checkbox to column heading
    selectFilesCheckBox = new CheckBox();
    selectFilesCheckBox.setDisable(true);
    selectColumn.setGraphic(selectFilesCheckBox);
    selectFilesCheckBox
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              synchronized (LOCK) {
                tableView.getItems().forEach(fileItem -> fileItem.setSelected(newValue));
              }
            });

    // set value of cells in column
    selectColumn.setCellValueFactory(cellData -> cellData.getValue().selectedProperty());
    filenameColumn.setCellValueFactory(cellData -> cellData.getValue().filenameProperty());
    filepathColumn.setCellValueFactory(cellData -> cellData.getValue().filepathProperty());
  }
예제 #2
0
  @FXML
  private void initialize() {
    personTableNameColumn.setCellValueFactory(
        (dataFeatures) -> dataFeatures.getValue().nameProperty());
    personTableNameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    personTableNameColumn.setOnEditCommit(
        (cellEditEvent) -> {
          int row = cellEditEvent.getTablePosition().getRow();
          Person person = cellEditEvent.getTableView().getItems().get(row);
          person.setName(cellEditEvent.getNewValue());
        });

    personTableEmailColumn.setCellValueFactory(
        (dataFeatures) -> dataFeatures.getValue().emailProperty());
    personTableEmailColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    personTableNameColumn.setOnEditCommit(
        (cellEditEvent) -> {
          int row = cellEditEvent.getTablePosition().getRow();
          Person person = cellEditEvent.getTableView().getItems().get(row);
          person.setEmail(cellEditEvent.getNewValue());
        });

    ReadOnlyObjectProperty<Person> selectionProperty =
        personTableView.getSelectionModel().selectedItemProperty();
    selectionProperty.addListener(
        (observable, oldValue, newValue) -> {
          personPaneController.setModel(newValue);
        });
    personList = personTableView.getItems();
  }
예제 #3
0
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    table = new TableView<>();
    data = new ProjectData();

    TableColumn idProjectCol = new TableColumn("ID");
    idProjectCol.setCellValueFactory(
        new PropertyValueFactory<ProjectDataItem, String>("IDProject"));
    idProjectCol.setCellFactory(new EditableCell());

    TableColumn nameCol = new TableColumn("Name");
    nameCol.setCellValueFactory(new PropertyValueFactory<ProjectDataItem, String>("Name"));
    nameCol.setCellFactory(new EditableCell());

    TableColumn descriptionCol = new TableColumn("Description");
    descriptionCol.setCellValueFactory(
        new PropertyValueFactory<ProjectDataItem, String>("Description"));
    descriptionCol.setCellFactory(new EditableCell());

    table.setItems(data.getData());
    table.getColumns().addAll(idProjectCol, nameCol, descriptionCol);
    table.setEditable(true);
    table.setTableMenuButtonVisible(true);
    table.setContextMenu(new ProjectFormController.ProjectContextMenu());
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    paneTable.getChildren().add(table);
    AnchorPane.setTopAnchor(table, 0.0);
    AnchorPane.setLeftAnchor(table, 0.0);
    AnchorPane.setRightAnchor(table, 0.0);
    AnchorPane.setBottomAnchor(table, 50.0);
  }
  /**
   * Initializes the controller class. This method is automatically called after fxml file has been
   * loaded.
   */
  @FXML
  private void initialize() {

    // setting up the radioButtons
    final ToggleGroup timeIntervalGroup = new ToggleGroup();
    monthlyRadioButton.setToggleGroup(timeIntervalGroup);
    dailyRadioButton.setToggleGroup(timeIntervalGroup);
    hourlyRadioButton.setToggleGroup(timeIntervalGroup);
    fifteenMinRadioButton.setToggleGroup(timeIntervalGroup);
    fifteenMinRadioButton.setSelected(true);

    final ToggleGroup typOfChartGroup = new ToggleGroup();
    regularTimeSeriesRadioButton.setToggleGroup(typOfChartGroup);
    scatterRadioButton.setToggleGroup(typOfChartGroup);
    dailyTypeOfDayRadioButton.setToggleGroup(typOfChartGroup);
    regularTimeSeriesRadioButton.setSelected(true);

    final ToggleGroup typeOfDayGroup = new ToggleGroup();
    schoolDayRadioButton.setToggleGroup(typeOfDayGroup);
    summerDayRadioButton.setToggleGroup(typeOfDayGroup);
    holidayRadioButton.setToggleGroup(typeOfDayGroup);
    weekendRadioButton.setToggleGroup(typeOfDayGroup);
    everyDayRadioButton.setToggleGroup(typeOfDayGroup);
    everyDayRadioButton.setSelected(true);

    updateEnabledButtons();

    // initialize a unique instance of the database
    database = Database.getInstance();
    // initialize the meter table with all the columns.
    meterNumberColumn.setCellValueFactory(cellData -> cellData.getValue().getMeterNumber());
    meterTable.setEditable(true);
    meterNumberColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    meterNumberColumn.setOnEditCommit(
        new EventHandler<TableColumn.CellEditEvent<Meter, String>>() {
          @Override
          public void handle(CellEditEvent<Meter, String> event) {
            event
                .getTableView()
                .getItems()
                .get(event.getTablePosition().getRow())
                .setMeterNumber(Assistant.parsePropertiesString(event.getNewValue()));
          }
        });
    startDateColumn.setCellValueFactory(
        cellData -> Assistant.parsePropertiesString(cellData.getValue().getStartDate().toString()));
    endDateColumn.setCellValueFactory(
        cellData -> Assistant.parsePropertiesString(cellData.getValue().getEndDate().toString()));

    activatedColumn.setCellFactory(cellData -> new CheckBoxCell());

    colorColumn.setCellFactory(cellData -> new ColorButtonCell(java.awt.Color.GREEN));

    initializeDateTable();
  }
예제 #5
0
    /**
     * initialize column
     *
     * @param colNameMap <column name, property id>
     */
    public void initColumn(Map<String, String> colNameMap) {

      int numCol = colNameMap.size();
      if (numCol == 0) return;
      getColumns().clear();

      for (Map.Entry<String, String> entry : colNameMap.entrySet()) {
        TableColumn newCol = new TableColumn();
        String colName = entry.getKey();
        newCol.setText(colName);
        newCol.setCellValueFactory(new PropertyValueFactory(entry.getValue()));
        newCol.setMinWidth(COL_UNIT_WIDTH * entry.getKey().length());
        getColumns().add(newCol);
        // set style
        if (colName.equals("Last Price")
            || colName.equals("UnRealized Gain")
            || colName.equals("Realised Gain")
            || colName.equals("Total Gain")) {
          newCol.setCellFactory(
              new Callback<TableColumn, TableCell>() {
                public TableCell call(TableColumn param) {
                  return new TableCell<PortfolioData, Double>() {
                    @Override
                    public void updateItem(Double item, boolean empty) {
                      super.updateItem(item, empty);
                      if (!isEmpty()) {
                        if (item >= 0) this.setTextFill(Color.GREEN);
                        else this.setTextFill(Color.RED);
                        setText(String.valueOf(item));
                      }
                    }
                  };
                }
              });
        } else if (colName.equals("Change Percent")) {
          newCol.setCellFactory(
              new Callback<TableColumn, TableCell>() {
                public TableCell call(TableColumn param) {
                  return new TableCell<PortfolioData, String>() {
                    @Override
                    public void updateItem(String item, boolean empty) {
                      super.updateItem(item, empty);
                      if (!isEmpty()) {
                        if (item.contains("-")) this.setTextFill(Color.RED);
                        else this.setTextFill(Color.GREEN);
                        setText(item);
                      }
                    }
                  };
                }
              });
        }
      }
    }
예제 #6
0
  public MediaTable() {
    imageColumnHeaderText = new SimpleStringProperty("Image");
    titleColumnHeaderText = new SimpleStringProperty("Title");
    descriptionColumnHeaderText = new SimpleStringProperty("Description");

    imageColumnHeaderVisible = new SimpleBooleanProperty(true);
    titleColumnHeaderVisible = new SimpleBooleanProperty(true);
    descriptionColumnHeaderVisible = new SimpleBooleanProperty(true);

    TableColumn<T, Image> imageTableColumn = new TableColumn<>();
    imageTableColumn.setCellValueFactory(c -> c.getValue().imageProperty());
    imageTableColumn.textProperty().bind(imageColumnHeaderText);
    imageTableColumn.visibleProperty().bind(imageColumnHeaderVisible);
    imageTableColumn.setCellFactory(c -> new ImageTableCell());

    TableColumn<T, String> titleTableColumn = new TableColumn<>();
    titleTableColumn.setCellValueFactory(c -> c.getValue().titleProperty());
    titleTableColumn.textProperty().bind(titleColumnHeaderText);
    titleTableColumn.visibleProperty().bind(titleColumnHeaderVisible);

    TableColumn<T, String> descriptionTableColumn = new TableColumn<>();
    descriptionTableColumn.setCellValueFactory(c -> c.getValue().descriptionProperty());
    descriptionTableColumn.textProperty().bind(descriptionColumnHeaderText);
    descriptionTableColumn.visibleProperty().bind(descriptionColumnHeaderVisible);

    getColumns().addAll(imageTableColumn, titleTableColumn, descriptionTableColumn);
  }
  @FXML
  private void genararb(ActionEvent event) {
    tablabloque.getColumns().clear();
    String[] titulos = {
      "Numero", "bloque", "Fecha De Creacion", "Fecha De Modificacion",
    };

    for (int i = 0; i < titulos.length; i++) {
      final int j = i;
      this.titulo = new TableColumn(titulos[i]);
      this.titulo.setCellValueFactory(
          new Callback<
              TableColumn.CellDataFeatures<ObservableList, String>, ObservableValue<String>>() {
            @Override
            public ObservableValue<String> call(
                TableColumn.CellDataFeatures<ObservableList, String> parametro) {
              return new SimpleStringProperty((String) parametro.getValue().get(j));
            }
          });
      tablabloque.getColumns().addAll(titulo);
      // Asignamos un tamaño a ls columnnas
      titulo.setMinWidth(120);

      // Centrar los datos de la tabla
      titulo.setCellFactory(
          new Callback<TableColumn<String, String>, TableCell<String, String>>() {
            @Override
            public TableCell<String, String> call(TableColumn<String, String> p) {
              TableCell cell =
                  new TableCell() {
                    @Override
                    protected void updateItem(Object t, boolean bln) {
                      if (t != null) {
                        super.updateItem(t, bln);
                        setText(t.toString());
                        setAlignment(Pos.CENTER); // Setting the Alignment
                      }
                    }
                  };
              return cell;
            }
          });
    }

    tbbloque = FXCollections.observableArrayList();
    for (Tbbloque bloq : resultsbloque) {
      ObservableList<String> row = FXCollections.observableArrayList();
      row.add(bloq.getId().toString());
      row.add(bloq.getNombre());
      row.add(df1.format(bloq.getFechacreacion()));
      System.out.print(bloq.getFechacreacion());
      String fecha =
          bloq.getFechamodificacion() == null
              ? bloq.getFechamodificacion() + ""
              : df1.format(bloq.getFechamodificacion());
      row.add(fecha);
      tbbloque.addAll(row);
    }
    tablabloque.setItems(tbbloque);
  }
예제 #8
0
 private TableColumn<MarketStatisticItem, MarketStatisticItem> getSpreadColumn() {
   TableColumn<MarketStatisticItem, MarketStatisticItem> column =
       new TableColumn<MarketStatisticItem, MarketStatisticItem>("Spread") {
         {
           setMinWidth(130);
         }
       };
   column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
   column.setCellFactory(
       new Callback<
           TableColumn<MarketStatisticItem, MarketStatisticItem>,
           TableCell<MarketStatisticItem, MarketStatisticItem>>() {
         @Override
         public TableCell<MarketStatisticItem, MarketStatisticItem> call(
             TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
           return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
             @Override
             public void updateItem(final MarketStatisticItem item, boolean empty) {
               super.updateItem(item, empty);
               if (item != null && !empty && item.spread != null)
                 setText(formatter.formatFiatWithCode(item.spread));
               else setText("");
             }
           };
         }
       });
   return column;
 }
예제 #9
0
 private TableColumn<Dispute, Dispute> getDateColumn() {
   TableColumn<Dispute, Dispute> column =
       new TableColumn<Dispute, Dispute>("Date") {
         {
           setMinWidth(130);
         }
       };
   column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
   column.setCellFactory(
       new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
         @Override
         public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
           return new TableCell<Dispute, Dispute>() {
             @Override
             public void updateItem(final Dispute item, boolean empty) {
               super.updateItem(item, empty);
               if (item != null && !empty)
                 setText(formatter.formatDateTime(item.getOpeningDate()));
               else setText("");
             }
           };
         }
       });
   return column;
 }
예제 #10
0
 private TableColumn<MarketStatisticItem, MarketStatisticItem> getNumberOfOffersColumn() {
   TableColumn<MarketStatisticItem, MarketStatisticItem> column =
       new TableColumn<MarketStatisticItem, MarketStatisticItem>("Total offers") {
         {
           setMinWidth(100);
         }
       };
   column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
   column.setCellFactory(
       new Callback<
           TableColumn<MarketStatisticItem, MarketStatisticItem>,
           TableCell<MarketStatisticItem, MarketStatisticItem>>() {
         @Override
         public TableCell<MarketStatisticItem, MarketStatisticItem> call(
             TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
           return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
             @Override
             public void updateItem(final MarketStatisticItem item, boolean empty) {
               super.updateItem(item, empty);
               if (item != null && !empty) setText(String.valueOf(item.numberOfOffers));
               else setText("");
             }
           };
         }
       });
   return column;
 }
예제 #11
0
 private TableColumn<Dispute, Dispute> getRoleColumn() {
   TableColumn<Dispute, Dispute> column =
       new TableColumn<Dispute, Dispute>("Role") {
         {
           setMinWidth(130);
         }
       };
   column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
   column.setCellFactory(
       new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
         @Override
         public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
           return new TableCell<Dispute, Dispute>() {
             @Override
             public void updateItem(final Dispute item, boolean empty) {
               super.updateItem(item, empty);
               if (item != null && !empty) {
                 if (item.isDisputeOpenerIsOfferer())
                   setText(item.isDisputeOpenerIsBuyer() ? "Buyer/Offerer" : "Seller/Offerer");
                 else setText(item.isDisputeOpenerIsBuyer() ? "Buyer/Taker" : "Seller/Taker");
               } else {
                 setText("");
               }
             }
           };
         }
       });
   return column;
 }
예제 #12
0
 private TableColumn<MarketStatisticItem, MarketStatisticItem> getCurrencyColumn() {
   TableColumn<MarketStatisticItem, MarketStatisticItem> column =
       new TableColumn<MarketStatisticItem, MarketStatisticItem>("Currency") {
         {
           setMinWidth(100);
         }
       };
   column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
   column.setCellFactory(
       new Callback<
           TableColumn<MarketStatisticItem, MarketStatisticItem>,
           TableCell<MarketStatisticItem, MarketStatisticItem>>() {
         @Override
         public TableCell<MarketStatisticItem, MarketStatisticItem> call(
             TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
           return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
             @Override
             public void updateItem(final MarketStatisticItem item, boolean empty) {
               super.updateItem(item, empty);
               if (item != null && !empty) setText(CurrencyUtil.getNameByCode(item.currencyCode));
               else setText("");
             }
           };
         }
       });
   return column;
 }
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    try {

      fillTableFromData();
      action.setSortable(false);

      action.setCellValueFactory(
          new Callback<
              TableColumn.CellDataFeatures<EmployeeVO, Boolean>, ObservableValue<Boolean>>() {

            @Override
            public ObservableValue<Boolean> call(
                TableColumn.CellDataFeatures<EmployeeVO, Boolean> p) {
              return new SimpleBooleanProperty(p.getValue() != null);
            }
          });

      action.setCellFactory(
          new Callback<TableColumn<EmployeeVO, Boolean>, TableCell<EmployeeVO, Boolean>>() {

            @Override
            public TableCell<EmployeeVO, Boolean> call(TableColumn<EmployeeVO, Boolean> p) {
              return new ButtonCell();
            }
          });

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /** Initializes the controller class. */
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    resultTable.setItems(searchResults);

    titleC.setCellFactory(
        (TableColumn<SearchResult, String> p) -> {
          TextFieldTableCell<SearchResult, String> cell = new TextFieldTableCell<>();
          cell.setOnMouseClicked(
              t -> {
                if (t.getClickCount() == 2 && (!cell.isEmpty())) {
                  try {
                    String file = cell.getTableView().getItems().get(cell.getIndex()).getId().get();
                    Runtime.getRuntime()
                        .exec(
                            "open /Users/Luxin/Documents/UTC/LO17/SearchEngine/TD/TD01/BULLETINS/"
                                + file
                                + ".htm");
                  } catch (IOException ex) {
                    Logger.getLogger(SearchEngineInterfaceController.class.getName())
                        .log(Level.SEVERE, null, ex);
                  }
                }
              });
          return cell;
        });

    scoreC.setCellValueFactory(cell -> cell.getValue().getScore());
    idC.setCellValueFactory(cell -> cell.getValue().getId());
    titleC.setCellValueFactory(cell -> cell.getValue().getTitle());
  }
  /**
   * Build a column representing an instance of the Object class. The object is represented by its
   * toString result.
   *
   * @param name label of the column
   * @param propertyName name of the property which is bound to the column
   * @param columnCount number of columns
   * @return a column of name name, bound with the property propertyName and with intelligent size
   */
  @Override
  public TableColumn buildColumn(String name, String propertyName, int columnCount) {
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory(new PropertyValueFactory(propertyName));
    column.prefWidthProperty().bind(owner.widthProperty().divide(columnCount));
    column.setCellFactory(
        new Callback<TableColumn<E, C>, TableCell<E, C>>() {

          @Override
          public TableCell<E, C> call(TableColumn<E, C> p) {
            TableCell<E, C> cell =
                new TableCell<E, C>() {

                  @Override
                  protected void updateItem(C t, boolean bln) {
                    if (t != null) {
                      Text text = new Text(t.toString());
                      setGraphic(text);
                    }
                  }
                };
            return cell;
          }
        });
    return column;
  }
  private void CargarTabla() {
    tablabloque.getColumns().clear();
    String[] titulos = {
      "Bloque", "Pregunta",
    };

    for (int i = 0; i < titulos.length; i++) {
      final int j = i;
      this.titulo = new TableColumn(titulos[i]);
      this.titulo.setCellValueFactory(
          new Callback<
              TableColumn.CellDataFeatures<ObservableList, String>, ObservableValue<String>>() {
            @Override
            public ObservableValue<String> call(
                TableColumn.CellDataFeatures<ObservableList, String> parametro) {
              return new SimpleStringProperty((String) parametro.getValue().get(j));
            }
          });
      tablabloque.getColumns().addAll(titulo);
      // Asignamos un tamaño a ls columnnas
      if (i == 0) {
        titulo.setMinWidth(120);
      } else {
        titulo.setMinWidth(450);
      }

      // Centrar los datos de la tabla
      titulo.setCellFactory(
          new Callback<TableColumn<String, String>, TableCell<String, String>>() {
            @Override
            public TableCell<String, String> call(TableColumn<String, String> p) {
              TableCell cell =
                  new TableCell() {
                    @Override
                    protected void updateItem(Object t, boolean bln) {
                      if (t != null) {
                        super.updateItem(t, bln);
                        setText(t.toString());
                        setAlignment(Pos.CENTER); // Setting the Alignment
                      }
                    }
                  };
              return cell;
            }
          });
    }

    tbbloque = FXCollections.observableArrayList();
    for (Tbbloquesxpregunta bloqxpreg : resultsbloqxpreg) {
      ObservableList<String> row = FXCollections.observableArrayList();
      row.add(bloqxpreg.getIdbloque().getNombre());
      row.add(bloqxpreg.getIdpregunta().getNombre());
      tbbloque.addAll(row);
    }
    tablabloque.setItems(tbbloque);
  }
  public void setFddObjectModel(FddObjectModel fddObjectModel) {
    logger.entry();
    if (fddObjectModel != null) {
      fddObjectModel
          .getInteractionClasses()
          .values()
          .stream()
          .forEach(
              (value) -> {
                interactions.add(new InteractionState(value));
              });
      InteractionTableView.setItems(interactions);
      interactions.forEach(
          (interaction) -> {
            interaction
                .onProperty()
                .addListener(
                    (observable, oldValue, newValue) -> {
                      if (!newValue) {
                        cb.setSelected(false);
                      } else if (interactions.stream().allMatch(a -> a.isOn())) {
                        cb.setSelected(true);
                      }
                    });
          });
      InteractionTableColumn.setCellValueFactory(new PropertyValueFactory<>("interactionName"));
      CheckTableColumn.setCellValueFactory(
          new Callback<
              TableColumn.CellDataFeatures<InteractionState, Boolean>, ObservableValue<Boolean>>() {
            @Override
            public ObservableValue<Boolean> call(
                TableColumn.CellDataFeatures<InteractionState, Boolean> param) {
              return param.getValue().onProperty();
            }
          });

      CheckTableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(CheckTableColumn));
      cb.setUserData(CheckTableColumn);
      cb.setOnAction(
          (ActionEvent event) -> {
            CheckBox cb1 = (CheckBox) event.getSource();
            TableColumn tc = (TableColumn) cb1.getUserData();
            InteractionTableView.getItems()
                .stream()
                .forEach(
                    (item) -> {
                      item.setOn(cb1.isSelected());
                    });
          });
      CheckTableColumn.setGraphic(cb);
    }
    logger.exit();
  }
 @Override
 public void initialize(URL location, ResourceBundle resources) {
   // cellvaluefactory
   checkedColumn.setCellValueFactory(new PropertyValueFactory<>("checked"));
   columnNameColumn.setCellValueFactory(new PropertyValueFactory<>("columnName"));
   jdbcTypeColumn.setCellValueFactory(new PropertyValueFactory<>("jdbcType"));
   propertyNameColumn.setCellValueFactory(new PropertyValueFactory<>("propertyName"));
   typeHandlerColumn.setCellValueFactory(new PropertyValueFactory<>("typeHandler"));
   // Cell Factory that customize how the cell should render
   checkedColumn.setCellFactory(CheckBoxTableCell.forTableColumn(checkedColumn));
   javaTypeColumn.setCellFactory(TextFieldTableCell.forTableColumn());
   // handle commit event to save the user input data
   javaTypeColumn.setOnEditCommit(
       event -> {
         event
             .getTableView()
             .getItems()
             .get(event.getTablePosition().getRow())
             .setJavaType(event.getNewValue());
       });
   propertyNameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
   propertyNameColumn.setOnEditCommit(
       event -> {
         event
             .getTableView()
             .getItems()
             .get(event.getTablePosition().getRow())
             .setPropertyName(event.getNewValue());
       });
   typeHandlerColumn.setCellFactory(TextFieldTableCell.forTableColumn());
   typeHandlerColumn.setOnEditCommit(
       event -> {
         event
             .getTableView()
             .getItems()
             .get(event.getTablePosition().getRow())
             .setTypeHandle(event.getNewValue());
       });
 }
예제 #19
0
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    itemKeyColumn.setCellFactory(
        c -> {
          AutoCompleteTextFieldTableCell<InventoryItemProperty> actftc =
              new AutoCompleteTextFieldTableCell<>();
          actftc.getItemsProperty().bind(itemDict.itemKeys());
          return actftc;
        });
    countColumn.setCellFactory(
        c -> new FormattedTextFieldTableCell<>(Utils.getNewIntegerTextFormatter(1)));

    healthField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));
    dodgeField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));

    bAttackField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));
    pAttackField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));
    sAttackField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));

    bDefenseField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));
    pDefenseField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));
    sDefenseField.setTextFormatter(Utils.getNewIntegerTextFormatter(0));
  }
  /**
   * Displays event end dates. Today's and tomorrow's dates will be labeled as today and tomorrow.
   * Passed dates will be highlighted grey.
   */
  private void displayEventEndDateColumn() {
    eventEndDateColumn.setCellFactory(
        column -> {
          return new TableCell<Task, String>() {
            @Override
            protected void updateItem(String item, boolean empty) {
              super.updateItem(item, empty);

              if (item == null || empty) {
                setText("");
                setStyle("");
              } else {
                boolean isExpired = false;
                boolean isTomorrow = false;
                boolean isToday = false;
                String[] date = item.split("-");
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.DAY_OF_MONTH, 1);
                Date todayDate = MainLogic.getCurrentDate();
                Date tmrwDate =
                    new Date(
                        cal.get(Calendar.DAY_OF_MONTH),
                        cal.get(Calendar.MONTH) + 1,
                        cal.get(Calendar.YEAR));
                Date taskDate =
                    new Date(
                        Integer.parseInt(date[0]),
                        Integer.parseInt(date[1]),
                        Integer.parseInt(date[2]));
                assertTrue(todayDate.isValid());
                assertTrue(tmrwDate.isValid());
                assertTrue(taskDate.isValid());
                if (taskDate.compareTo(todayDate) < 0) isExpired = true;
                if (taskDate.equals(tmrwDate)) isTomorrow = true;
                if (taskDate.equals(todayDate)) isToday = true;
                setText(item);
                if (isExpired) {
                  setTextFill(Color.WHITE);
                  setStyle("-fx-background-color: transparent, derive(#808080,20%);");
                } else {
                  setTextFill(Color.BLACK);
                  setStyle("");
                }
                if (isTomorrow) setText("Tomorrow");
                if (isToday) setText("Today");
              }
            }
          };
        });
  }
예제 #21
0
  @Override
  public void initialize(URL url, ResourceBundle rb) {

    Sql.loadSql();

    total.setText("$" + expenseTotal);

    name.setCellValueFactory(new PropertyValueFactory<Expense, String>("name"));
    name.setCellFactory(TextFieldTableCell.<String>forTableColumn());
    vendor.setCellValueFactory(new PropertyValueFactory<Expense, String>("vendor"));
    vendor.setCellFactory(TextFieldTableCell.<String>forTableColumn());
    date.setCellValueFactory(new PropertyValueFactory<Expense, String>("date"));
    date.setCellFactory(TextFieldTableCell.<String>forTableColumn());
    cost.setCellValueFactory(new PropertyValueFactory<Expense, Double>("cost"));
    cost.setCellFactory(
        TextFieldTableCell.forTableColumn(
            new StringConverter<Double>() {

              @Override
              public String toString(Double object) {
                return object.toString();
              }

              @Override
              public Double fromString(String string) {
                return Double.parseDouble(string);
              }
            }));

    add.setOnAction(e -> Action.addExpense());
    delete.setOnAction(e -> Action.deleteExpense());

    if (tableList.size() > 0) emptyLabel.setText("");

    table.setItems(tableList);
    pieChart.setData(pieChartList);
  }
 public void populateDataTable(final SoapServiceVirtualizeDto srv) {
   // dataTableModel.removeActionListeners();
   populateServiceData(
       srv.getSoapServiceVirtualizeName(),
       srv.getCreationTimeStamp(),
       srv.getLastUpdatedTimeStamp(),
       srv.getResponseStub(),
       srv.getRequesStub());
   elementValue.setCellFactory(TextFieldTableCell.forTableColumn());
   elementValue.setOnEditCommit(
       (final TableColumn.CellEditEvent<TableEntry, String> t) -> {
         updateTableDetails(
             srv, t.getTableView().getItems().get(t.getTablePosition().getRow()), t.getNewValue());
       });
 }
  /** Wraps text in deadline details table column. */
  private void taskDetailsWrap() {
    taskDetailsColumn.setCellFactory(
        new Callback<TableColumn<Task, String>, TableCell<Task, String>>() {

          @Override
          public TableCell<Task, String> call(TableColumn<Task, String> param) {
            TableCell<Task, String> cell = new TableCell<>();
            Text text = new Text();
            cell.setGraphic(text);
            cell.setPrefHeight(Control.USE_COMPUTED_SIZE);
            text.wrappingWidthProperty().bind(taskDetailsColumn.widthProperty());
            text.textProperty().bind(cell.itemProperty());
            return cell;
          }
        });
  }
 public void populateDataTable(final RestServiceVirtualizeDto rstDto) {
   populateServiceData(
       rstDto.getRestServiceVirtualName(),
       rstDto.getCreationTimeStamp(),
       rstDto.getLastUpdatedTimeStamp(),
       rstDto.getResponseStub(),
       rstDto.getRequesStub());
   elementValue.setCellFactory(TextFieldTableCell.forTableColumn());
   elementValue.setOnEditCommit(
       (final TableColumn.CellEditEvent<TableEntry, String> t) -> {
         updateTableDetails(
             rstDto,
             t.getTableView().getItems().get(t.getTablePosition().getRow()),
             t.getNewValue());
       });
 }
예제 #25
0
 @FXML
 private void initialize() {
   nameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
   sizeColumn.setCellValueFactory(cellData -> cellData.getValue().sizeProperty());
   doneColumn.setCellValueFactory(new PropertyValueFactory<>("done"));
   doneColumn.setCellFactory(ProgressBarTableCell.<DoneTask>forTableColumn());
   torrentList.setCellFactory(
       cellData ->
           new ListCell<Torrenta>() {
             @Override
             public void updateItem(Torrenta item, boolean empty) {
               super.updateItem(item, empty);
               if (item != null && !empty) {
                 setText(item.getName());
               }
             }
           });
 }
예제 #26
0
  @SuppressWarnings("unchecked")
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    tableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    TableViewSearchable<ImageResource> searchable = new TableViewSearchable<>(tableView);
    searchable.setCaseSensitive(false);

    TableColumn<ImageResource, String> tc =
        (TableColumn<ImageResource, String>) tableView.getColumns().get(0);
    tc.setCellValueFactory(new PropertyValueFactory<>("href"));
    tc.setSortable(true);

    TableColumn<ImageResource, Image> tc2 =
        (TableColumn<ImageResource, Image>) tableView.getColumns().get(1);
    tc2.setCellValueFactory(new PropertyValueFactory<>("cover"));
    tc2.setCellFactory(new ImageCellFactory<>(null, 100d));
    tc2.setSortable(false);

    tableView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<ImageResource>() {
              @Override
              public void changed(
                  ObservableValue<? extends ImageResource> observable,
                  ImageResource oldValue,
                  ImageResource newValue) {
                refreshImageView(newValue);
              }
            });
    tableView.setOnMouseClicked(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            if (event.getButton().equals(MouseButton.PRIMARY)) {
              if (event.getClickCount() == 2) {
                insertCover();
              }
            }
          }
        });
    instance = this;
  }
 public void populateDataTableModel(final ProjectDetailsDto projectDetailsDto) {
   removeEntries();
   TableEntry projectName = new TableEntry(PROJECT_NAME, projectDetailsDto.getProjectName());
   TableEntry projectShortName =
       new TableEntry(PROJECT_SHORT_NAME, projectDetailsDto.getProjectShortName());
   TableEntry projectDescription =
       new TableEntry(PROJECT_DETAILS, projectDetailsDto.getProjectDescription());
   dataTable.getItems().add(projectName);
   dataTable.getItems().add(projectShortName);
   dataTable.getItems().add(projectDescription);
   elementValue.setCellFactory(TextFieldTableCell.forTableColumn());
   elementValue.setOnEditCommit(
       (final TableColumn.CellEditEvent<TableEntry, String> t) -> {
         updateTableDetails(
             projectDetailsDto,
             t.getTableView().getItems().get(t.getTablePosition().getRow()),
             t.getNewValue());
       });
 }
  @FXML
  private void initialize() {
    ObservableList<String> kunden =
        FXCollections.observableArrayList(KundeSession.getAllKundenNamen());
    kunden.add(0, "Alle");
    kundenChoiceBox.setItems(kunden);
    kundenChoiceBox.setValue("Alle");

    String dm = now.getDayOfMonth() + "." + now.getMonthValue() + ".";
    day1Label.setText("1.1. - " + dm);
    day2Label.setText("1.1. - " + dm);

    List<Auftrag> auftraege = AuftragSession.getAllAuftraege();
    auftraege.sort(Comparator.comparing(Auftrag::getErstellung));
    LocalDate oldestAuftrag = auftraege.get(0).getErstellung();

    ObservableList<Number> years = FXCollections.observableArrayList();
    for (int i = now.getYear(); i >= oldestAuftrag.getYear(); i--) {
      years.add(i);
    }
    year1ChoiceBox.setItems(years);
    year1ChoiceBox.setValue(years.get(1));
    year2ChoiceBox.setItems(years);
    year2ChoiceBox.setValue(years.get(0));

    calculate();

    pNrColumn.setCellValueFactory(cellData -> cellData.getValue().produktNr);
    bezColumn.setCellValueFactory(cellData -> cellData.getValue().bezeichnung);
    bildColumn.setCellValueFactory(cellData -> cellData.getValue().bild);
    bildColumn.setCellFactory(imageCellFactory);
    s1Column.setCellValueFactory(cellData -> cellData.getValue().stuckzahl1);
    u1Column.setCellValueFactory(cellData -> cellData.getValue().umsatz1);
    s2Column.setCellValueFactory(cellData -> cellData.getValue().stuckzahl2);
    u2Column.setCellValueFactory(cellData -> cellData.getValue().umsatz2);
    pInfoTable.setItems(dataShow);

    kundenChoiceBox.valueProperty().addListener(observable -> calculate());
    year1ChoiceBox.valueProperty().addListener(observable -> calculate());
    year2ChoiceBox.valueProperty().addListener(observable -> calculate());
  }
예제 #29
0
  private TableColumn<Dispute, Dispute> getTradeIdColumn() {
    TableColumn<Dispute, Dispute> column =
        new TableColumn<Dispute, Dispute>("Trade ID") {
          {
            setMinWidth(130);
          }
        };
    column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
    column.setCellFactory(
        new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
          @Override
          public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
            return new TableCell<Dispute, Dispute>() {
              private Hyperlink hyperlink;

              @Override
              public void updateItem(final Dispute item, boolean empty) {
                super.updateItem(item, empty);

                if (item != null && !empty) {
                  Optional<Trade> tradeOptional = tradeManager.getTradeById(item.getTradeId());
                  hyperlink = new Hyperlink(item.getShortTradeId());
                  if (tradeOptional.isPresent()) {
                    hyperlink.setMouseTransparent(false);
                    Tooltip.install(hyperlink, new Tooltip(item.getShortTradeId()));
                    hyperlink.setOnAction(event -> tradeDetailsPopup.show(tradeOptional.get()));
                  } else {
                    hyperlink.setMouseTransparent(true);
                  }
                  setGraphic(hyperlink);
                } else {
                  setGraphic(null);
                  setId(null);
                }
              }
            };
          }
        });
    return column;
  }
예제 #30
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();
                }));
  }