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);
  }
  @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);
  }
 /**
  * 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());
 }
 /**
  * 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());
 }
  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);
  }
 /**
  * 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());
 }
 /**
  * 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());
 }
 /**
  * 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());
 }
  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);
  }
Exemple #10
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);
                      }
                    }
                  };
                }
              });
        }
      }
    }
  /**
   * Erzeugt eine TableView mit den Daten aus der Datenbank.
   *
   * @return Eine TableView mit Polizist Daten
   */
  private Node getPolizistAnsichtInnereTabelle() {
    refreshPolizistAnsicht();

    // Name Spalte
    TableColumn<PolizistDaten, String> SpalteName = new TableColumn<>("Name");
    SpalteName.setMinWidth(200);
    SpalteName.setCellValueFactory(new PropertyValueFactory<>("Name"));

    // GebDatum Spalte
    TableColumn<PolizistDaten, String> SpalteDatum = new TableColumn<>("Geburtsdatum");
    SpalteDatum.setMinWidth(200);
    SpalteDatum.setCellValueFactory(new PropertyValueFactory<>("GebDatum"));

    // Nationalitaet Spalte
    TableColumn<PolizistDaten, String> SpalteNation = new TableColumn<>("Nationalität");
    SpalteNation.setMinWidth(200);
    SpalteNation.setCellValueFactory(new PropertyValueFactory<>("Nation"));

    // Geschlecht Spalte
    TableColumn<PolizistDaten, String> SpalteGeschlecht = new TableColumn<>("Geschlecht");
    SpalteGeschlecht.setMinWidth(200);
    SpalteGeschlecht.setCellValueFactory(new PropertyValueFactory<>("Geschlecht"));

    // Todesdatum Spalte
    TableColumn<PolizistDaten, String> SpalteTod = new TableColumn<>("Todesdatum");
    SpalteTod.setMinWidth(200);
    SpalteTod.setCellValueFactory(new PropertyValueFactory<>("TodDatum"));

    // Dienstgrad Spalte
    TableColumn<PolizistDaten, String> SpalteGrad = new TableColumn<>("Dienstgrad");
    SpalteGrad.setMinWidth(200);
    SpalteGrad.setCellValueFactory(new PropertyValueFactory<>("Dienstgrad"));

    Tabelle.setItems(PolizistDatenListe);
    Tabelle.getColumns().add(SpalteName);
    Tabelle.getColumns().add(SpalteDatum);
    Tabelle.getColumns().add(SpalteNation);
    Tabelle.getColumns().add(SpalteGeschlecht);
    Tabelle.getColumns().add(SpalteTod);
    Tabelle.getColumns().add(SpalteGrad);

    Tabelle.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    // Doppelklicke auf Spalten sollen Detailansichten oeffnen:
    Tabelle.setRowFactory(
        param -> {
          TableRow<PolizistDaten> Spalte = new TableRow<>();
          Spalte.setOnMouseClicked(
              event -> {
                if (event.getClickCount() == 2 && (!Spalte.isEmpty())) {
                  erzeugeDetailAnsicht(Spalte.getItem());
                }
              });
          return Spalte;
        });

    return Tabelle;
  }
  /**
   * 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);
                }
              }
            });
  }
  /**
   * 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();
                }));
  }
  @Override
  public void initialize(URL arg0, ResourceBundle arg1) {
    // TODO Auto-generated method stub

    ObservableList<String> items = FXCollections.observableArrayList();
    items.add("Si");
    items.add("No");
    cboAcreditada.setItems(items);
    cboAcreditada.getSelectionModel().selectFirst();

    TableColumn<Carrera, String> nombre = new TableColumn<>("NOMBRE");
    nombre.setSortType(TableColumn.SortType.DESCENDING);
    nombre.setCellValueFactory(new PropertyValueFactory<Carrera, String>("nombre"));

    TableColumn<Carrera, String> siglas = new TableColumn<>("SIGLAS");
    siglas.setSortType(TableColumn.SortType.DESCENDING);
    siglas.setCellValueFactory(new PropertyValueFactory<Carrera, String>("siglas"));

    TableColumn<Carrera, String> jefe = new TableColumn<>("JEFE");
    jefe.setMinWidth(40);
    jefe.setSortType(TableColumn.SortType.DESCENDING);
    jefe.setCellValueFactory(new PropertyValueFactory<Carrera, String>("jefeCarrera"));

    TableColumn<Carrera, Integer> matricula = new TableColumn<>("MATRICULA");
    matricula.setSortType(TableColumn.SortType.DESCENDING);
    matricula.setCellValueFactory(new PropertyValueFactory<Carrera, Integer>("matricula"));

    TableColumn<Carrera, String> acreditada = new TableColumn<>("ACREDITADA");
    acreditada.setSortType(TableColumn.SortType.DESCENDING);
    acreditada.setCellValueFactory(new PropertyValueFactory<Carrera, String>("acreditada"));

    tblCarrera.getColumns().addAll(nombre, siglas, jefe, matricula, acreditada);

    LLenarTabla();
    tblCarrera.setOnMouseClicked(new ClickTabla());

    txtMatricula.addEventFilter(KeyEvent.KEY_TYPED, new soloNumeros());
  }
  private Tuple2<TableView<Offer>, VBox> getOfferTable(Offer.Direction direction) {
    TableView<Offer> tableView = new TableView();

    // price
    TableColumn<Offer, Offer> priceColumn = new TableColumn<>();
    priceColumn.textProperty().bind(priceColumnLabel);
    priceColumn.setMinWidth(120);
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getPrice()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(priceColumn);

    // amount
    TableColumn<Offer, Offer> amountColumn = new TableColumn<>("Amount (BTC)");
    amountColumn.setText("Amount (BTC)");
    amountColumn.setMinWidth(120);
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatCoin(item.getAmount()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(amountColumn);

    // volume
    TableColumn<Offer, Offer> volumeColumn = new TableColumn<>("Amount (BTC)");
    volumeColumn.setMinWidth(120);
    volumeColumn.textProperty().bind(volumeColumnLabel);
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getOfferVolume()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(volumeColumn);

    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("Currently there are no offers available");
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    Label titleLabel =
        new Label(
            direction.equals(Offer.Direction.BUY)
                ? "Offers for buy bitcoin (bid)"
                : "Offers for sell bitcoin (ask)");
    titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center");
    UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));

    VBox vBox = new VBox();
    vBox.setSpacing(10);
    vBox.setFillWidth(true);
    vBox.setMinHeight(150);
    vBox.getChildren().addAll(titleLabel, tableView);
    return new Tuple2<>(tableView, vBox);
  }
Exemple #16
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("JavaFX Demo");

    /* create the menu (for the top of the user interface) */
    Menu fileMenu = new Menu("File");
    MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png"));
    newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N"));
    fileMenu.getItems().add(newMenuItem);
    fileMenu.getItems().add(new SeparatorMenuItem());
    fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png")));
    fileMenu.getItems().add(new SeparatorMenuItem());
    fileMenu.getItems().add(new MenuItem("Save", imageFile("images/save.png")));
    fileMenu.getItems().add(new MenuItem("Save As...", imageFile("images/save_as.png")));
    fileMenu.getItems().add(new SeparatorMenuItem());
    MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png"));
    fileMenu.getItems().add(exitMenuItem);
    exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q"));
    exitMenuItem.setOnAction(e -> System.exit(0));

    Menu editMenu = new Menu("Edit");
    editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png")));
    editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png")));
    editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png")));

    Menu helpMenu = new Menu("Help");
    helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png")));
    helpMenu.getItems().add(new SeparatorMenuItem());
    helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png")));

    MenuBar menuBar = new MenuBar();
    menuBar.getMenus().add(fileMenu);
    menuBar.getMenus().add(editMenu);
    menuBar.getMenus().add(helpMenu);

    /* create the table (for the center of the user interface) */
    table = new TableView<>();
    table.setItems(DataSource.getAllStudents());
    table.setEditable(true);

    /* create the table's columns */
    TableColumn<Student, Integer> sidColumn = null;
    sidColumn = new TableColumn<>("SID");
    sidColumn.setMinWidth(100);
    sidColumn.setCellValueFactory(new PropertyValueFactory<>("sid"));

    TableColumn<Student, String> firstNameColumn = null;
    firstNameColumn = new TableColumn<>("First Name");
    firstNameColumn.setMinWidth(200);
    firstNameColumn.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    firstNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn());
    firstNameColumn.setOnEditCommit(
        (CellEditEvent<Student, String> event) -> {
          ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow()))
              .setFirstName(event.getNewValue());
        });

    TableColumn<Student, String> lastNameColumn = null;
    lastNameColumn = new TableColumn<>("Last Name");
    lastNameColumn.setMinWidth(200);
    lastNameColumn.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    lastNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn());
    lastNameColumn.setOnEditCommit(
        (CellEditEvent<Student, String> event) -> {
          ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow()))
              .setLastName(event.getNewValue());
        });

    TableColumn<Student, Double> gpaColumn = null;
    gpaColumn = new TableColumn<>("GPA");
    gpaColumn.setMinWidth(100);
    gpaColumn.setCellValueFactory(new PropertyValueFactory<>("gpa"));

    table.getColumns().add(sidColumn);
    table.getColumns().add(lastNameColumn);
    table.getColumns().add(firstNameColumn);
    table.getColumns().add(gpaColumn);

    /* create an edit form (for the bottom of the user interface) */
    GridPane editArea = new GridPane();
    editArea.setPadding(new Insets(10, 10, 10, 10));
    editArea.setVgap(10);
    editArea.setHgap(10);

    Label sidLabel = new Label("SID:");
    editArea.add(sidLabel, 0, 0);
    TextField sidField = new TextField();
    sidField.setPromptText("SID");
    editArea.add(sidField, 1, 0);

    Label fnameLabel = new Label("First name:");
    editArea.add(fnameLabel, 0, 1);
    TextField fnameField = new TextField();
    fnameField.setPromptText("First Name");
    editArea.add(fnameField, 1, 1);

    Label lnameLabel = new Label("Last name:");
    editArea.add(lnameLabel, 0, 2);
    TextField lnameField = new TextField();
    lnameField.setPromptText("Last Name");
    editArea.add(lnameField, 1, 2);

    Label gpaLabel = new Label("GPA:");
    editArea.add(gpaLabel, 0, 3);
    TextField gpaField = new TextField();
    gpaField.setPromptText("GPA");
    editArea.add(gpaField, 1, 3);

    Button addButton = new Button("Add");
    addButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            int sid = Integer.parseInt(sidField.getText());
            String firstName = fnameField.getText();
            String lastName = lnameField.getText();
            double gpa = Double.parseDouble(gpaField.getText());

            table.getItems().add(new Student(sid, firstName, lastName, gpa));

            sidField.setText("");
            fnameField.setText("");
            lnameField.setText("");
            gpaField.setText("");
          }
        });
    editArea.add(addButton, 1, 4);

    /* arrange all components in the main user interface */
    layout = new BorderPane();
    layout.setTop(menuBar);
    layout.setCenter(table);
    layout.setBottom(editArea);

    Scene scene = new Scene(layout, 600, 600);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
  // METODO ENCARGADO DE CARGAR LOS DATOS A LA TABLA PROVEEDORES
  private void cargarDatosTablaProveedores(ResultSet resultadoProveedores, TableView tabla) {
    tabla.getColumns().clear();
    proveedor = FXCollections.observableArrayList();
    ResultSet resultadoDatosTablaProveedores = resultadoProveedores;

    try {
      // TITULOS DE LAS COLUMNAS
      String[] titulos = {
        "CODIGO", "RUT", "NOMBRE", "TELEFONO", "EMAIL", "TIPO_DE_PRODUCTOS", "ESTADO"
      };

      // AGREGAMOS LOS DATOS A LA TABLA DINAMICAMENTE
      for (int i = 0; i < resultadoDatosTablaProveedores.getMetaData().getColumnCount(); i++) {
        final int j = i;
        col = new TableColumn(titulos[i]);
        col.setCellValueFactory(
            new Callback<
                TableColumn.CellDataFeatures<ObservableList, String>, ObservableValue<String>>() {
              public ObservableValue<String> call(
                  TableColumn.CellDataFeatures<ObservableList, String> parametro) {
                return new SimpleStringProperty((String) parametro.getValue().get(j));
              }
            });
        tabla.getColumns().addAll(col);
        // ASIGNAMOS UN TAMAÑO A LAS COLUMNAS
        col.setMinWidth(140);
        System.out.println("Column [" + i + "] ");
        // CENTRAMOS LOS DATOS EN LA TABLA
        col.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);
                          System.out.println(t);
                          setText(t.toString());
                          setAlignment(Pos.CENTER_LEFT);
                        }
                      }
                    };
                return cell;
              }
            });
      }

      // CARGAMOS DE LA BASE DE DATOS
      while (resultadoDatosTablaProveedores.next()) {
        // ITERACION DE FILA}
        ObservableList<String> row = FXCollections.observableArrayList();
        for (int i = 1; i <= resultadoDatosTablaProveedores.getMetaData().getColumnCount(); i++) {
          // ITERACION DE COLUMNA
          row.add(resultadoDatosTablaProveedores.getString(i));
        }
        System.out.println("Row [i] added " + row);
        proveedor.addAll(row);
      }
      // FINALMENTE AGREGAMOS A LA TABLA JEFE DE SUCURSAL
      tabla.setItems(proveedor);
      resultadoDatosTablaProveedores.close();
    } catch (SQLException e) {
      System.out.println("Error " + e);
    }
  }
Exemple #18
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    window = primaryStage;
    window.setTitle("Organiseerija");
    final javafx.scene.control.Label label = new javafx.scene.control.Label("Ajaplaneerija");
    label.setFont(new Font("Arial", 20));

    // Aine veerg
    TableColumn<Kodut66.Input, String> aineColumn = new TableColumn<>("Aine");
    aineColumn.setMinWidth(150);
    aineColumn.setCellValueFactory(new PropertyValueFactory<>("aine"));

    // Ruum veerg
    TableColumn<Kodut66.Input, String> ruumColumn = new TableColumn<>("Ruum");
    ruumColumn.setMinWidth(100);
    ruumColumn.setCellValueFactory(new PropertyValueFactory<>("ruum"));

    // Kuupäeva veerg
    TableColumn<Kodut66.Input, String> dateColumn = new TableColumn<>("Kuupäev");
    dateColumn.setMinWidth(150);
    dateColumn.setCellValueFactory(new PropertyValueFactory<>("kuupäev"));

    // Sisestab aine
    aineInput = new TextField();
    aineInput.setPromptText("Aine");
    aineInput.setMinWidth(100);

    // Sisestab ruumi
    ruumInput = new TextField();
    ruumInput.setPromptText("Ruum");
    ruumInput.setMinWidth(100);

    // Sisestab kuupäeva
    dateInput = new TextField();
    dateInput.setPromptText("dd/mm/yyyy");
    dateInput.setMinWidth(100);

    // Lisa juurde töid ja kustuta tehtud tööd
    Button lisaButton = new Button("Lisa juurde");
    lisaButton.setOnAction(e -> lisaButtonVajutatud());
    Button kustutaButton = new Button("Tehtud!");
    kustutaButton.setOnAction(e -> kustutaButtonVajutatud());

    // Tabel
    table = new TableView<>();
    table.setItems(getInput());
    table.getColumns().addAll(aineColumn, ruumColumn, dateColumn);

    // Horisontaalne
    HBox hBox = new HBox();
    hBox.setPadding(new Insets(10, 10, 10, 10));
    hBox.setSpacing(10);
    hBox.getChildren().addAll(aineInput, ruumInput, dateInput, lisaButton, kustutaButton);

    // Vertikaalne
    VBox vBox = new VBox();
    vBox.getChildren().addAll(label, table, hBox);

    Scene scene = new Scene(vBox);
    window.setScene(scene);
    window.show();
  }
Exemple #19
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    /* create the menu (for the top of the user interface) */
    Menu fileMenu = new Menu("File");
    MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png"));
    newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N"));
    fileMenu.getItems().add(newMenuItem);
    fileMenu.getItems().add(new SeparatorMenuItem());
    fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png")));
    fileMenu.getItems().add(new SeparatorMenuItem());
    MenuItem saveMenuItem = new MenuItem("Save", imageFile("images/save.png"));
    fileMenu.getItems().add(saveMenuItem);
    MenuItem saveAsMenuItem = new MenuItem("Save As...", imageFile("images/save_as.png"));
    fileMenu.getItems().add(saveAsMenuItem);
    fileMenu.getItems().add(new SeparatorMenuItem());
    MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png"));
    fileMenu.getItems().add(exitMenuItem);
    exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q"));
    exitMenuItem.setOnAction(e -> System.exit(0));

    Menu editMenu = new Menu("Edit");
    editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png")));
    editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png")));
    editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png")));

    Menu helpMenu = new Menu("Help");
    helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png")));
    helpMenu.getItems().add(new SeparatorMenuItem());
    helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png")));

    MenuBar menuBar = new MenuBar();
    menuBar.getMenus().add(fileMenu);
    menuBar.getMenus().add(editMenu);
    menuBar.getMenus().add(helpMenu);
    primaryStage.setTitle("Lab08");
    // grid contains all of the textfeilds, labels , buttons, ect..
    GridPane grid = new GridPane();
    // the tableview puts all of our data into a exel like format
    TableView<StudentRecord> table = new TableView<>();
    table.setItems(DataSource.getAllMarks());
    table.setEditable(true);

    TableColumn<StudentRecord, String> IDColumn = null;
    IDColumn = new TableColumn<>("SID");
    IDColumn.setMinWidth(100);
    // the thing in quotes is what it will search for in the StudentRecords.java (MAKE SURE THERE IS
    // A GET FUNCTION FOR THAT VARIBALE)
    IDColumn.setCellValueFactory(new PropertyValueFactory<>("ID"));

    TableColumn<StudentRecord, Double> AssignmentColumn = null;
    AssignmentColumn = new TableColumn<>("Assignment");
    AssignmentColumn.setMinWidth(100);
    AssignmentColumn.setCellValueFactory(new PropertyValueFactory<>("Assign"));

    TableColumn<StudentRecord, Float> MidtermColumn = null;
    MidtermColumn = new TableColumn<>("Midterm");
    MidtermColumn.setMinWidth(100);
    MidtermColumn.setCellValueFactory(new PropertyValueFactory<>("Midterm"));

    TableColumn<StudentRecord, Float> FinalColumn = null;
    FinalColumn = new TableColumn<>("Final Exam");
    FinalColumn.setMinWidth(100);
    FinalColumn.setCellValueFactory(new PropertyValueFactory<>("Final"));

    TableColumn<StudentRecord, String> GradeColumn = null;
    GradeColumn = new TableColumn<>("Letter Grade");
    GradeColumn.setMinWidth(100);
    GradeColumn.setCellValueFactory(new PropertyValueFactory<>("Grade"));

    table.getColumns().add(IDColumn);
    table.getColumns().add(AssignmentColumn);
    table.getColumns().add(MidtermColumn);
    table.getColumns().add(FinalColumn);
    table.getColumns().add(GradeColumn);

    Label IDLabel = new Label("SID:");
    grid.add(IDLabel, 0, 0);
    TextField IDField = new TextField();
    IDField.setPromptText("SID");
    grid.add(IDField, 1, 0);

    Label AssignLabel = new Label("Assignments:");
    grid.add(AssignLabel, 2, 0);

    TextField AssignField = new TextField();
    AssignField.setPromptText("Assignment");
    grid.add(AssignField, 3, 0);

    Label MidLabel = new Label("Midterm:");
    grid.add(MidLabel, 0, 1);

    TextField midField = new TextField();
    midField.setPromptText("Midterm");
    grid.add(midField, 1, 1);

    Label FinalLabel = new Label("Final:");
    grid.add(FinalLabel, 2, 1);

    TextField FinalField = new TextField();
    FinalField.setPromptText("Final");
    grid.add(FinalField, 3, 1);

    Button AddButton = new Button("Add");
    AddButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            char Grade;
            String SID = IDField.getText();
            Float Assignment = Float.parseFloat(AssignField.getText());
            Float Midterm = Float.parseFloat(midField.getText());
            Float Final = Float.parseFloat(FinalField.getText());
            table.getItems().add(new StudentRecord(SID, Assignment, Midterm, Final));

            IDField.setText("");
            AssignField.setText("");
            midField.setText("");
            FinalField.setText("");
          }
        });
    grid.add(AddButton, 0, 2);

    layout = new BorderPane();
    layout.setTop(menuBar);
    layout.setCenter(table);
    layout.setBottom(grid);

    Scene scene = new Scene(layout);
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(10);
    grid.setHgap(10);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
  public VBox getPane() {
    gp = new GridPane();
    gp.setVgap(VERTICAL_GAP);
    gp.setHgap(HORIZ_GAP);
    gp.setPadding(new Insets(0, 0, 3, 0));

    Random rand = new Random();
    questionnaireCode = Integer.toString(rand.nextInt());

    // hard coded questions for example
    Question ques1 =
        new Question(
            "111",
            "Employees need to be supervised closely or they are not likely to do their work",
            "Quality Type A");

    Question ques2 =
        new Question(
            "202",
            "Providing guidance without pressure it they key to being a good leader",
            "Quality Type B");

    Question ques3 =
        new Question(
            "097",
            "Most workers want frequent and supportive communication from their leaders",
            "Style Type A");

    Question ques4 =
        new Question("125", "People are basically competent and do a good job", "Style Type B");

    Question ques5 =
        new Question(
            "222",
            "Most workers want frequent and supportive communication from their leaders",
            "Quality Type A");

    Question ques6 =
        new Question("021", "Most employees feel insecure about their work", "Style Type A");

    Question ques7 =
        new Question(
            "435",
            "The leader is the chief judge of the achievements of the group",
            "Style Type A");

    Question ques8 =
        new Question(
            "544",
            "Leaders should allow subordinates to appraise their own work",
            "Quality Type B");

    Question ques9 =
        new Question(
            "787", "Employees must be part of the decision-making process", "Style Type B");

    data = FXCollections.observableArrayList();

    // Add a new question
    Label quesName = new Label("New Question:");

    String lastCode = Question.lastCode();
    int nextCode = Integer.parseInt(lastCode) + 1;
    final String newCode = Integer.toString(nextCode);

    TextField newQuestion = new TextField();
    newQuestion.setPromptText("Question Text");
    newQuestion.setMinWidth(350);

    // later to be a cell factory
    ComboBox<String> typeCombo = new ComboBox<String>();
    typeCombo.getItems().addAll("Quality A", "Quality B", "Style A", "Style B");
    typeCombo.setPromptText("Question Type:");

    // Button to add new questions
    Button addQuesButton = new Button("Add Question");
    gp.setHalignment(addQuesButton, HPos.RIGHT);
    addQuesButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            // if (addQuesButton.isSelected()) {
            //
            data.add(new Question(newCode, newQuestion.getText(), typeCombo.getValue()));

            // qName.clear();
            newQuestion.clear();
          }
        });

    Label quesChoose = new Label("Select a Question:");

    // choose question in db
    ComboBox<String> quesCombo = new ComboBox<String>();

    // to display existing questions in system:
    quesCombo.setPromptText("Existing Questions:");

    TreeMap<String, Question> questionMap = new TreeMap<String, Question>();

    for (Map.Entry<String, Question> entry : Question.getQuesMap().entrySet()) {
      String key = entry.getKey();
      Question value = entry.getValue();

      questionMap.put(entry.getValue().getQuestionText(), value);

      String question = value.getQuestionText();
      quesCombo.getItems().add(question);
    }

    // to create a new question
    Button chooseQues = new Button("Add Question");
    gp.setHalignment(chooseQues, HPos.RIGHT);
    chooseQues.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            //

            data.add(questionMap.get(quesCombo.getValue()));

            // reset combo box
            // quesCombo.setPromptText("Existing Questions:");

          }
        });

    Label or = new Label("OR");

    gp.add(quesName, 0, 0);
    gp.add(newQuestion, 1, 0);
    gp.add(typeCombo, 2, 0);
    gp.add(addQuesButton, 3, 0);
    gp.add(or, 0, 1);

    gp.add(quesChoose, 0, 2);
    gp.add(quesCombo, 1, 2);
    gp.add(chooseQues, 3, 2);

    // Create a table with columns to display Organization information
    TableView<Question> table = new TableView<Question>();
    table.setEditable(true);

    TableColumn<Question, String> actionDelete = new TableColumn<Question, String>("Remove");
    actionDelete.setCellValueFactory(new PropertyValueFactory<Question, String>("OrgCode"));

    // Create button to delete records
    Callback<TableColumn<Question, String>, TableCell<Question, String>> deleteColumnCellFactory =
        new Callback<TableColumn<Question, String>, TableCell<Question, String>>() {

          @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);
                      setGraphic(null);
                    } else {
                      final Button deleteButton = new Button("Remove");
                      deleteButton.setOnAction(
                          new EventHandler<ActionEvent>() {

                            @Override
                            public void handle(ActionEvent event) {
                              param.getTableView().getSelectionModel().select(getIndex());

                              Question item = table.getSelectionModel().getSelectedItem();

                              // if (orgCode != null) {
                              // Confirmation of record deletion
                              Alert alert = new Alert(AlertType.CONFIRMATION);
                              alert.setTitle("ALERT");
                              alert.setHeaderText(
                                  "Please confirm that you would like to delete this record");
                              // alert.setContentText("Are you ok with this?");

                              ButtonType buttonTypeOne = new ButtonType("Cancel");
                              ButtonType buttonTypeTwo = new ButtonType("OK");

                              alert
                                  .showAndWait()
                                  .ifPresent(
                                      response -> {
                                        if (response == ButtonType.OK) {
                                          // code to
                                          // delete
                                          // record
                                          data.remove(item);
                                          table.getSelectionModel().clearSelection();
                                        } else {
                                          return;
                                        }
                                      });
                              // }
                            }
                          });
                      setGraphic(deleteButton);
                      setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
                    }
                  }
                };
            return cell;
          }
        };
    // Add delete button to table cell
    actionDelete.setCellFactory(deleteColumnCellFactory);

    TableColumn<Question, String> quesCode = new TableColumn<Question, String>("Code");
    quesCode.setMinWidth(50);
    quesCode.setCellValueFactory(new PropertyValueFactory<Question, String>("questionCode"));

    TableColumn<Question, String> quesText = new TableColumn<Question, String>("Text");
    quesText.setMinWidth(600);
    quesText.setCellValueFactory(new PropertyValueFactory<Question, String>("questionText"));

    TableColumn<Question, String> quesType = new TableColumn<Question, String>("Type");
    quesType.setMinWidth(150);
    quesType.setCellValueFactory(new PropertyValueFactory<Question, String>("questionType"));

    // Set the items from the ArrayList into the table
    table.setItems(data);
    table.getColumns().addAll(actionDelete, quesCode, quesText, quesType);
    table.setVisible(true);

    Button showQuestionnaire = new Button("Save This Questionnaire and View");
    gp.setHalignment(showQuestionnaire, HPos.RIGHT);
    showQuestionnaire.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            //
            MainMenu.addMap(questionnaireCode, data);
            qv = new QuestionnaireView(data);
            MainMenu.changePane(qv.getPane());
          }
        });

    // Create a vertical box that will display the table and search area
    vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(label, gp, table, showQuestionnaire);

    return vbox;
  }
  @SuppressWarnings("unchecked")
  public StackPane viewStock(String categoryId, String categoryName) {
    stack = new StackPane();

    GridPane grid = new GridPane();

    grid.setVgap(8);
    grid.setPadding(new Insets(30));
    final ObservableList<ItemVO> dataTable;
    // final ObservableList<ItemVO> dataTable1;
    // final ObservableList<ItemVO> dataTable2;
    ObservableList<CategoryTypeVO> typeList;

    Rectangle roundRect =
        RectangleBuilder.create()
            .x(50)
            .y(50)
            .width(Screen.getPrimary().getVisualBounds().getWidth() - 428)
            .height(Screen.getPrimary().getVisualBounds().getHeight() - 150)
            .arcWidth(30)
            .arcHeight(30)
            .build();

    roundRect.setFill(Color.DARKGRAY);
    roundRect.setOpacity(0.2);
    roundRect.setStroke(Color.TRANSPARENT);

    HBox hlabel = new HBox();
    hlabel.setMaxWidth(Screen.getPrimary().getVisualBounds().getWidth() - 170);
    hlabel.setMaxHeight(30);
    hlabel.setStyle("-fx-background-color:black;");
    hlabel.setOpacity(0.3);
    hlabel.setLayoutX(20);

    try {
      typeList = FXCollections.observableArrayList();
      typeList = UtiliesDAO.getUtiliesDAO().fetchTypes(categoryId);

      dataTable = FXCollections.observableArrayList();
      dataTable.addAll(stockDetailsService.viewStock(categoryId));

      /*dataTable1 = FXCollections.observableArrayList();
      dataTable2 = FXCollections.observableArrayList();

      for(int i=0;i<dataTable.size();i++)
      {
      	dataTable1.add(dataTable.get(i++));
      	if(i<=dataTable.size()-1)
      	{
      		dataTable2.add(dataTable.get(i));
      	}
      }*/

      final Label label = new Label(categoryName + " Stock");

      final Text text5 = new Text(25, 175, categoryName + " Stock");
      text5.setFill(Color.DARKORANGE);
      // text5.setFont(Font.font ("Edwardian Script ITC", 50));
      text5.setFont(Font.loadFont("file:resources/fonts/ITCEDSCR.TTF", 50));
      final Light.Distant light = new Light.Distant();
      light.setAzimuth(-135.0);
      final Lighting lighting = new Lighting();
      lighting.setLight(light);
      lighting.setSurfaceScale(9.0);
      text5.setEffect(lighting);

      label.setAlignment(Pos.CENTER_LEFT);
      // grid.add(label,1,0);

      final TableView<ItemVO> table1 = new TableView<ItemVO>();
      table1.setEditable(false);
      // table1.setMaxSize(roundRect.getWidth()*0.41, roundRect.getHeight()*0.519);//400,300
      table1.setMinSize(roundRect.getWidth() * 0.41, roundRect.getHeight() * 0.519); // 400,300
      table1.setMaxSize(roundRect.getWidth() - 50, roundRect.getHeight() - 200);

      table1.getSelectionModel().setCellSelectionEnabled(false);

      table1.setStyle("-fx-background-color: transparent;");

      TableColumn<ItemVO, String> itemName = new TableColumn<ItemVO, String>("Item");
      itemName.setResizable(false);
      itemName.setMaxWidth(roundRect.getWidth() * 0.5);
      itemName.setMinWidth(roundRect.getWidth() * 0.5); // 200
      itemName.setCellValueFactory(new PropertyValueFactory<ItemVO, String>("itemName"));

      TableColumn<ItemVO, Integer> quantity = new TableColumn<ItemVO, Integer>("Quantity#");
      quantity.setResizable(false);
      quantity.setMinWidth(roundRect.getWidth() * 0.107); // 200

      /*quantity.setCellValueFactory(
      new PropertyValueFactory<ItemVO, Integer>("quantity"));*/

      for (final CategoryTypeVO type : typeList) {
        TableColumn<ItemVO, Integer> col = new TableColumn<ItemVO, Integer>(type.getTypeName());
        col.setMinWidth(roundRect.getWidth() * 0.107); // 100
        col.setResizable(false);

        col.setCellValueFactory(
            new Callback<CellDataFeatures<ItemVO, Integer>, ObservableValue<Integer>>() {
              @Override
              public ObservableValue<Integer> call(CellDataFeatures<ItemVO, Integer> item) {
                ItemVO itemVO = item.getValue();
                if (itemVO == null) {
                  return null;
                  // or perhaps
                  // return new ReadOnlyObjectWrapper<Integer>(null);
                } else {
                  ObservableMap<String, ItemTypeVO> itemTypesMap =
                      FXCollections.observableHashMap();
                  itemTypesMap = item.getValue().getListType();

                  return new ReadOnlyObjectWrapper<Integer>(
                      itemTypesMap.get(type.getTypeId()).getQuantity());
                }
              }
            });
        col.setCellFactory(
            new Callback<TableColumn<ItemVO, Integer>, TableCell<ItemVO, Integer>>() {

              @Override
              public TableCell<ItemVO, Integer> call(TableColumn<ItemVO, Integer> paramP) {
                // TODO Auto-generated method stub
                return new TableCell<ItemVO, Integer>() {
                  @Override
                  public void updateItem(Integer item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!isEmpty()) {
                      setText(item.toString());
                      if (item <= 5) {
                        this.getStyleClass().add("celllow");
                        setTextFill(Color.RED);
                      }
                    }
                  }
                };
              }
            });
        quantity.getColumns().add(col);
      }

      if (quantity.getColumns().size() >= 5 && quantity.getColumns().size() <= 7) {
        itemName.setMinWidth(itemName.getWidth() - (quantity.getColumns().size() - 4) * 100);
      }
      if (quantity.getColumns().size() > 7) {
        itemName.setMinWidth(itemName.getWidth() - ((7 - 4) * 100));
      }

      table1.setItems(dataTable);
      final TableColumn[] columns1 = {itemName, quantity};
      table1.getColumns().addAll(columns1);
      table1
          .getColumns()
          .addListener(
              new ListChangeListener() {
                public boolean suspended;

                @Override
                public void onChanged(Change change) {
                  change.next();
                  if (change.wasReplaced() && !suspended) {
                    this.suspended = true;
                    table1.getColumns().setAll(columns1);
                    this.suspended = false;
                  }
                }
              });

      /*//final TableView<ItemVO> table2 = new TableView<ItemVO>();
      table2.setEditable(false);

      table2.setMaxSize(roundRect.getWidth()*0.41, roundRect.getHeight()*0.519);
      table2.setMinSize(roundRect.getWidth()*0.35, roundRect.getHeight()*0.519);//400,300
      table2.setStyle("-fx-background-color: transparent;");

      TableColumn<ItemVO,String> itemName2 = new TableColumn<ItemVO,String> ("Item");
      itemName2.setMinWidth(roundRect.getWidth()*0.3);//200

      itemName2.setCellValueFactory(
      		new PropertyValueFactory<ItemVO, String>("itemName"));

      TableColumn<ItemVO, Integer>  quantity2 = new TableColumn<ItemVO, Integer> ("Quantity#");
      quantity2.setMinWidth(roundRect.getWidth()*0.107);//200
      quantity.setCellValueFactory(
      		new PropertyValueFactory<ItemVO, Integer>("quantity"));



      for (final CategoryTypeVO type : typeList)
      {
      	  TableColumn<ItemVO, Integer> col2 = new TableColumn<ItemVO, Integer>(type.getTypeName());
      	  col2.setMinWidth(roundRect.getWidth()*0.107);//100
      	  col2.setResizable(false);

      	  col2.setCellValueFactory(new Callback<CellDataFeatures<ItemVO,Integer>, ObservableValue<Integer>>() {
      	    @Override
      	    public ObservableValue<Integer> call(CellDataFeatures<ItemVO,Integer> item)
      	    {
      	    	ItemVO itemVO = item.getValue();
      	    	if (itemVO == null)
      	    	{
      	    	  return null ;
      	    	// or perhaps
      	    	// return new ReadOnlyObjectWrapper<Integer>(null);
      	    	}
      	    	else
      	    	{
      		    	ObservableMap<String,ItemTypeVO> itemTypesMap = FXCollections.observableHashMap();
      		    	itemTypesMap = item.getValue().getListType();

      		    	return new ReadOnlyObjectWrapper<Integer>(itemTypesMap.get(type.getTypeId()).getQuantity());

      	    	}

      	    }

      	  });
      	 col2.setCellFactory(new Callback<TableColumn<ItemVO,Integer>, TableCell<ItemVO,Integer>>() {

      		@Override
      		public TableCell<ItemVO, Integer> call(TableColumn<ItemVO, Integer> paramP) {
      			// TODO Auto-generated method stub
      			return new TableCell<ItemVO, Integer>(){
      				@Override
      				public void updateItem(Integer item, boolean empty)
      				{
      					super.updateItem(item, empty);
      					if(item!=null)
      					{
      						setText(item.toString());
      						if(item<=5)
      						{
      							this.getStyleClass().add("celllow");
      							setTextFill(Color.RED);
      						}
      					}

      				}
      			};

      		}
      	});
      	  quantity2.getColumns().add(col2);
      	}


      table2.setItems(dataTable2);
      final TableColumn[] columns2 = {itemName2, quantity2};
      table2.getColumns().addAll(columns2);
      table2.getColumns().addListener(new ListChangeListener() {
            public boolean suspended;

            @Override
            public void onChanged(Change change) {
                change.next();
                if (change.wasReplaced() && !suspended) {
                    this.suspended = true;
                    table2.getColumns().setAll(columns2);
                    this.suspended = false;
                }
            }
        });*/

      Rectangle qtyRect = RectangleBuilder.create().x(50).y(50).width(10).height(10).build();

      qtyRect.setFill(Color.rgb(240, 128, 128));

      grid.add(table1, 0, 12);
      // grid.add(table2,1,12);
      grid.setAlignment(Pos.TOP_CENTER);

      Text man_text = new Text(CommonConstants.STAR_MSG);
      man_text.setFill(Color.DARKKHAKI);
      man_text.setFont(Font.font("Arial", 12));

      Text msg_qty = new Text(CommonConstants.QTY_MSG1);
      msg_qty.setFill(Color.DARKKHAKI);
      msg_qty.setFont(Font.font("Arial", 12));

      Text msg_qtyLow = new Text(CommonConstants.QTY_LOW);
      msg_qtyLow.setFill(Color.DARKKHAKI);
      msg_qtyLow.setFont(Font.font("Arial", 12));

      StackPane.setMargin(grid, new Insets(10, 0, 0, 0));

      StackPane.setMargin(qtyRect, new Insets(197, 850, 100, 0));
      StackPane.setAlignment(qtyRect, Pos.BASELINE_CENTER);
      StackPane.setMargin(msg_qtyLow, new Insets(197, 765, 100, 0));
      StackPane.setAlignment(msg_qtyLow, Pos.BASELINE_CENTER);

      StackPane.setAlignment(roundRect, Pos.TOP_CENTER);
      StackPane.setMargin(text5, new Insets(50, 8, 8, 8));
      StackPane.setAlignment(text5, Pos.TOP_CENTER);
      StackPane.setMargin(man_text, new Insets(197, 100, 20, 0));
      StackPane.setAlignment(man_text, Pos.BASELINE_RIGHT);
      StackPane.setMargin(msg_qty, new Insets(210, 95, 20, 0));
      StackPane.setAlignment(msg_qty, Pos.BASELINE_RIGHT);

      stack.getChildren().addAll(text5, roundRect, grid, man_text, msg_qty, qtyRect, msg_qtyLow);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return stack;
  }
  @FXML
  private void reservationsButtonClicked(ActionEvent event) {
    configureButtons();
    reservationsButton.setGraphic(reservationsSelectedIMV);

    // Clear the content of contentPane
    contentPane.getChildren().clear();

    // Set title
    titleLabel.setText("Reservations");

    // Make box for weekly availability and reservations
    VBox box = new VBox();
    box.setSpacing(10);
    box.setAlignment(Pos.TOP_CENTER);
    box.setPrefWidth(900);

    // box for availability
    VBox abox = new VBox();
    box.setSpacing(10);
    box.setAlignment(Pos.TOP_CENTER);
    box.setPrefWidth(900);

    // box for reservations
    VBox resbox = new VBox();
    box.setSpacing(10);
    box.setAlignment(Pos.TOP_CENTER);
    box.setPrefWidth(900);

    // set up for weekly table availability
    Text aHeader = new Text("Tables still available");
    aHeader.setFont(new Font("System", 24));

    TableView aTable = new TableView();
    TableColumn aDateCol = new TableColumn("Date");
    aDateCol.setCellValueFactory(new PropertyValueFactory<>("date"));
    TableColumn tablesCol = new TableColumn("Tables Available");
    tablesCol.setCellValueFactory(new PropertyValueFactory<>("tablesAvailable"));

    // add table and title to availability box
    abox.getChildren().addAll(aHeader, aTable);
    abox.setSpacing(5);

    // set width for all cols
    aDateCol.setMinWidth(100);
    tablesCol.setMinWidth(100);

    aTable.getColumns().addAll(aDateCol, tablesCol);
    // Populate data to the table view
    operation.callDates();
    ObservableList<Availability> adata =
        FXCollections.observableArrayList(operation.getWeeklyAvailability());
    aTable.setItems(adata);
    aTable.setMaxHeight(235);
    aTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    // set up for reservations
    Text resHeader = new Text("All Reservations");
    resHeader.setFont(new Font("System", 24));

    TableView resTable = new TableView();
    TableColumn firstNameCol = new TableColumn("First Name");
    firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    TableColumn lastNameCol = new TableColumn("Last Name");
    lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    TableColumn tidCol = new TableColumn("tID");
    tidCol.setCellValueFactory(new PropertyValueFactory<>("tID"));
    TableColumn partySizeCol = new TableColumn("Party Size");
    partySizeCol.setCellValueFactory(new PropertyValueFactory<>("partySize"));
    TableColumn seatsCol = new TableColumn("Seats");
    seatsCol.setCellValueFactory(new PropertyValueFactory<>("seats"));
    TableColumn dateCol = new TableColumn("Reservation Date");
    dateCol.setCellValueFactory(new PropertyValueFactory<>("reservationDate"));

    // set width for all cols
    firstNameCol.setMinWidth(100);
    lastNameCol.setMinWidth(100);
    tidCol.setMinWidth(100);
    partySizeCol.setMinWidth(100);
    seatsCol.setMinWidth(100);
    dateCol.setMinWidth(300);

    // add table and title to availability box
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(resTable);
    scrollPane.setFitToWidth(true);
    resbox.getChildren().addAll(resHeader, scrollPane);
    resbox.setSpacing(5);

    resTable
        .getColumns()
        .addAll(firstNameCol, lastNameCol, tidCol, partySizeCol, seatsCol, dateCol);
    // Populate data to the table view
    ObservableList<ReservationInfo> resdata =
        FXCollections.observableArrayList(operation.getAllReservations());
    resTable.setItems(resdata);
    resTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    // add table view to content pane
    box.getChildren().addAll(abox, resbox);
    contentPane.getChildren().add(box);
  }
  public static Group createPane() {
    Group group = new Group();
    VBox vbox = new VBox();
    Label label = new Label("List of contructors");
    label.setFont(new Font("Arial", 20));
    label.setPadding(new Insets(50, 0, 0, 100));
    // Create TableView
    TableView<ContructorViewer> table = new TableView<ContructorViewer>();
    table.setEditable(true);
    table.setMinWidth(800);
    table.setMaxHeight(500);
    TableColumn<ContructorViewer, Integer> firstNameCol =
        new TableColumn<ContructorViewer, Integer>("id");
    TableColumn<ContructorViewer, String> secondNameCol =
        new TableColumn<ContructorViewer, String>("name");
    firstNameCol.setCellValueFactory(new PropertyValueFactory<ContructorViewer, Integer>("id"));
    firstNameCol.setMinWidth(100);
    secondNameCol.setCellValueFactory(new PropertyValueFactory<ContructorViewer, String>("name"));
    secondNameCol.setMinWidth(400);

    // Добавление колонок в таблицу
    list = getList();
    table.setItems(list);
    table.getColumns().addAll(firstNameCol, secondNameCol);
    // Панель для дополнительных операций
    HBox hb = new HBox();
    hb.setPadding(new Insets(40, 0, 20, 300));
    hb.setSpacing(10);
    TextField nameContructor = new TextField();
    nameContructor.setPromptText("new name of contructor");
    Button add = new Button("Add");
    Button close = new Button("Close");
    Text textEdit = new Text("Edit operation is open");
    textEdit.setFont(new Font(15));

    // Создание кнопок
    HBox btns = new HBox();
    btns.setStyle("-fx-background-color:#E6EFF5");
    btns.setMinHeight(60);
    Button[] buttons = new Button[12];
    String[] commands =
        new String[] {
          "HELP", "SAVE", "", "EDIT", "", "", "ADD", "DELETE", "REFRESH", "EXIT", "IMPORT", "EXPORT"
        };
    for (int i = 0; i < buttons.length; i++) {
      buttons[i] = new Button("F" + Integer.toString(i + 1) + "\n" + commands[i]);
      buttons[i].setTooltip(new Tooltip(commands[i]));
      buttons[i].setStyle("-fx-background-color:#C2CCCF");
      buttons[i].setMaxSize(70, 60);
      buttons[i].setMinSize(70, 60);
    }
    btns.getChildren().addAll(buttons);
    btns.setSpacing(15);
    btns.setPadding(new Insets(10, 0, 0, 0));
    btns.setAlignment(Pos.CENTER);

    //		Добавления таблицы и кнопок на панель
    vbox.getChildren().setAll(table, btns);
    vbox.setMinWidth(800);
    vbox.setMaxHeight(500);
    //		vbox.setAlignment(Pos.CENTER);
    vbox.setPadding(new Insets(100, 20, 20, 20));

    // ==========EDIT============================
    buttons[3].setOnAction(
        new EventHandler<ActionEvent>() {
          int i = 0;

          @Override
          public void handle(ActionEvent event) {
            if (i == 0) vbox.getChildren().add(textEdit);
            // TODO Auto-generated method stub
            // Редактирование колонок
            // Открытие на редактирование колонка NAME
            secondNameCol.setCellFactory(TextFieldTableCell.forTableColumn());
            // Cобытие на изменение ячейки
            secondNameCol.setOnEditCommit(
                new EventHandler<CellEditEvent<ContructorViewer, String>>() {
                  @Override
                  public void handle(CellEditEvent<ContructorViewer, String> value) {
                    int activeRow = value.getTablePosition().getRow();
                    if (value.getNewValue().isEmpty()) {
                      MyAlert er =
                          new MyAlert(
                              "ERROR! Please try again." + "\n" + "Input name of contructor");
                      Stage primaryStage = new Stage();
                      try {
                        er.start(primaryStage);
                      } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                      }
                    } else {
                      value.getTableView().getItems().get(activeRow).setName(value.getNewValue());
                    }
                  }
                });
            i++;
          }
        });
    // ==========ADD POSITION============================
    buttons[6].setOnAction(
        new EventHandler<ActionEvent>() {
          int i = 0;

          @Override
          public void handle(ActionEvent event) {
            // TODO Auto-generated method stub
            if (i == 0) hb.getChildren().addAll(nameContructor, add, close);

            add.setOnAction(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent event) {
                    // TODO Auto-generated method stub
                    if (nameContructor.getText().isEmpty()) {
                      MyAlert er =
                          new MyAlert("ERROR! Please try again." + "\n" + "Input name of product");
                      Stage primaryStage = new Stage();
                      try {
                        er.start(primaryStage);
                      } catch (Exception e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                      }
                    } else {
                      list.add(new ContructorViewer(list.size() + 1, nameContructor.getText()));
                      nameContructor.clear();
                    }
                  }
                });
            i++;
            close.setOnAction(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent event) {
                    // TODO Auto-generated method stub
                    hb.getChildren().removeAll(nameContructor, add, close);
                    i = 0;
                  }
                });
          }
        });
    // ==========DELETE POSITION============================
    buttons[7].setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int selectedInd = table.getSelectionModel().getSelectedIndex();
            if (selectedInd >= 0) {
              table.getItems().remove(selectedInd);
            } else {
              // Nothing selected
              Stage st = new Stage();
              MyAlert er = new MyAlert("Please select row for delete");
              try {
                er.start(st);
              } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
          }
        });
    // ==========REFRESH============================
    buttons[8].setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            // TODO Auto-generated method stub
            list = getList();
            table.setItems(list);
          }
        });
    // ==========SAVE=============================================
    list = table.getItems();
    buttons[1].setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            // TODO Auto-generated method stub
            setList(list);
            Stage st = new Stage();
            MyAlert er = new MyAlert("Executed store successfully");
            try {
              er.start(st);
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
    // ==========EXIT=====================================================
    buttons[9].setOnAction(eventExit -> TabPanelJFX.primaryStage.close());

    //		Добавление панели в группу
    group.getChildren().addAll(label, vbox, hb);

    return group;
  }
  public Veld1RijtechniekKijktechniek(
      SchermController schermCtrl, EvaController evaCtrl, LeerlingController llnCtrl) {
    evaController = evaCtrl;
    schermController = schermCtrl;
    llnController = llnCtrl;

    this.llnController.getLeerling().addView(this);

    aandachtBtn = new Button("Aandachtspunt");
    aandachtBtn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            aandacht();
          }
        });

    commentaarCol = new TableColumn("Commentaar");
    commentaarCol.setCellValueFactory(new PropertyValueFactory<Rijtechniek, String>("commentaar"));
    commentaarCol.setCellFactory(TextFieldTableCell.forTableColumn());
    commentaarCol.setOnEditCommit(
        new EventHandler<CellEditEvent<Rijtechniek, String>>() {
          @Override
          public void handle(CellEditEvent<Rijtechniek, String> t) {
            ((Rijtechniek) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                .setCommentaar(t.getNewValue());
          }
        });

    table.setItems(data);
    table.getColumns().addAll(commentaarCol);

    commentaarFld = new TextField();
    commentaarFld.setPromptText("Commentaar");

    addButton = new Button("Voeg toe");
    addButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            resetAandachtBtn();
            if (!"".equals(commentaarFld.getText())) {
              data.add(new Rijtechniek(commentaarFld.getText()));
              commentaarFld.clear();
            }
          }
        });
    table.setItems(data);
    table.setOnMouseClicked(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {
            resetAandachtBtn();
          }
        });
    table.setEditable(true);

    vBox2.getChildren().addAll(table, commentaarFld);
    exit = new Button("Ga terug");

    exit.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            evaController.saveListDataRijtechniek("Stuurtechniek", data);
            Veld1RijtechniekKijktechniek.this.schermController.setScherm(MainApp.RIJTECHNIEK_ID);
            resetAandachtBtn();
          }
        });
    delBtn = new Button("Verwijder");
    delBtn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            resetAandachtBtn();

            table.getItems().remove(table.getSelectionModel().getSelectedItem());
          }
        });
    delBtn.setMinHeight(30);
    delBtn.setMaxHeight(30);
    delBtn.setMinWidth(125);
    delBtn.setMaxWidth(125);
    delBtn.setAlignment(Pos.CENTER);
    delBtn.setTranslateX(-47);
    delBtn.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");
    table.getStylesheets().add("resource/tableView.css");
    commentaarFld.setStyle("-fx-background-color:#789EBF; -fx-text-fill:white");
    commentaarCol.setMaxWidth(496);
    commentaarCol.setMinWidth(496);
    hBox1.getChildren().addAll(titelAfb, titel);
    hBox1.setMinHeight(50);
    hBox1.setMaxHeight(50);
    hBox1.setMinWidth(600);
    hBox1.setMaxWidth(600);
    hBox1.setSpacing(15);
    hBox1.setAlignment(Pos.CENTER);
    titelAfb.setFitHeight(50);
    titelAfb.setFitWidth(50);
    titel.setStyle("-fx-font: 40px Tahoma; -fx-text-fill:white");

    table.setMinWidth(500);
    table.setMaxWidth(500);
    table.setMinHeight(400);
    table.setMaxHeight(400);
    addButton.setMinHeight(30);
    addButton.setMaxHeight(30);
    addButton.setMinWidth(150);
    addButton.setMaxWidth(150);
    addButton.setAlignment(Pos.CENTER);
    aandachtBtn.setMinHeight(30);
    aandachtBtn.setMaxHeight(30);
    aandachtBtn.setMinWidth(150);
    aandachtBtn.setMaxWidth(150);
    aandachtBtn.setAlignment(Pos.CENTER);
    exit.setMinHeight(30);
    exit.setMaxHeight(30);
    exit.setMinWidth(150);
    exit.setMaxWidth(150);
    exit.setAlignment(Pos.CENTER);
    commentaarFld.setMinHeight(30);
    commentaarFld.setMaxHeight(30);
    commentaarFld.setMinWidth(250);
    commentaarFld.setMaxWidth(250);
    commentaarFld.setAlignment(Pos.CENTER);
    table.setTranslateX(70);
    commentaarFld.setTranslateX(90);
    addButton.setTranslateX(90);
    aandachtBtn.setTranslateX(90);
    exit.setTranslateX(90);

    addButton.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");
    exit.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");
    aandachtBtn.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");

    gp.setStyle(
        "-fx-border-color: #282E54; -fx-border-radius:10 10 10 10;"
            + "-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 0);"
            + "-fx-background-color: #282B3A;"
            + "-fx-background-radius: 5;");
    gp.setMaxWidth(900);
    gp.setMinWidth(900);
    gp.setMinHeight(600);
    gp.setMaxHeight(600);
    gp.setHgap(50);
    gp.setVgap(20);
    gp.setAlignment(Pos.CENTER);
    gp.add(hBox1, 0, 0, 2, 1);
    gp.add(table, 0, 1, 2, 1);
    gp.add(commentaarFld, 0, 2);
    gp.add(addButton, 1, 2);
    gp.add(aandachtBtn, 0, 3);
    gp.add(exit, 1, 3);
    gp.add(delBtn, 1, 3);

    this.setAlignment(Pos.CENTER);
    this.getChildren().add(gp);
    this.setStyle("-fx-background-image: url('resource/achtergrondStandaard.png')");

    update();
  }