/**
   * Sets up the entire TableView with all its functionalities.
   *
   * @return The created TableView.
   */
  private TableView<FilterInput> setUpTableView() {
    // Set up table view
    final TableView<FilterInput> tableView = new TableView<>();
    tableView.setEditable(true);
    tableView.setMinWidth(522);
    tableView.setMinHeight(280);

    // Set up columns
    setUpFilterColumn(tableView);
    setUpTypeColumn(tableView);
    setUpOriginColumn(tableView);
    setUpColorColumn(tableView);
    setUpPriorityColumn(tableView);
    setUpLegalityColumn(tableView);
    setUpActiveColumn(tableView);

    // Insert data from database into table
    tableView.setItems(data);

    // Set select/deselect on mouse click
    tableView.setRowFactory(
        tableViewLambda -> {
          final TableRow<FilterInput> row = new TableRow<>();
          row.addEventFilter(
              MouseEvent.MOUSE_PRESSED,
              event -> {
                final int index = row.getIndex();
                if (index >= 0
                    && index < tableView.getItems().size()
                    && tableView.getSelectionModel().isSelected(index)) {
                  tableView.getSelectionModel().clearSelection();
                  event.consume();
                }
              });
          return row;
        });

    return tableView;
  }
  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();
  }