Пример #1
0
  /**
   * uploads File into currently selected Task.
   *
   * @param event
   * @throws ClassNotFoundException
   * @throws IOException
   * @throws SQLException
   */
  @FXML
  private void uploadFile(ActionEvent event)
      throws ClassNotFoundException, IOException, SQLException {

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open Resource File");
    File file = fileChooser.showOpenDialog(mainStage).getAbsoluteFile();

    // FileUtils.copyFileToDirectory(file, FileUtils.getFile(super.getPath(file.getName())), true);
    File selectedDir = new File(super.getPath("files"));
    FileUtils.copyFileToDirectory(file, new File(selectedDir.getAbsolutePath()));
    shl.getCurrentTab().addFile("File-" + file.getName(), file);

    download.setText("Upload done!");
    download.setTextFill(Color.GREEN);

    super.saveShell();
    super.saveLog(
        shl.getCurrentUser().getID()
            + " - "
            + shl.getCurrentUser().getName()
            + " - "
            + "UPLOADED "
            + file.getName());

    System.out.println("File uploaded as " + file.toString());
  }
  /**
   * Creates a new account (User)
   *
   * @param event
   * @throws IOException
   * @throws ClassNotFoundException
   * @throws SQLException
   */
  @FXML
  public void createAccount(ActionEvent event)
      throws IOException, ClassNotFoundException, SQLException {

    roles.setTextFill(Color.RED);
    wrongPass.setTextFill(Color.RED);
    duplicateID.setTextFill(Color.RED);

    if (super.loadShell() != null) {
      Shell loadShell = loadShell();
      shl.setEmployees(loadShell.getEmployees());
      shl.setManagers(loadShell.getManagers());
      shl.setTabs(loadShell.getTabs());
      shl.setUsers(loadShell.getUsers());
    }

    loadLog();

    if (!user.getText().equals("")
        && !password.getText().equals("")
        && !passconf.getText().equals("")
        && !name.getText().equals("")
        && !post.getText().equals("")) {

      if (shl.findUser(user.getText()) != null) {
        user.getStyleClass().add("error");
        duplicateID.setVisible(true);

        System.out.printf(
            "[SHELL] User %s exists as %s %s\n ",
            user.getText(), shl.findUser(user.getText()), shl.findUser(user.getText()));
      } else if (password.getText().equals(passconf.getText())) {
        shl.createUser(user.getText(), password.getText(), post.getText(), name.getText());

        System.out.printf("Created User %s\n", user.getText());

        user.getStyleClass().remove("error");
        password.getStyleClass().remove("error");
        passconf.getStyleClass().remove("error");
        roles.setVisible(false);
        duplicateID.setVisible(false);
        wrongPass.setVisible(false);

        super.saveShell();
        super.saveLog("USER " + user.getText() + " - " + name.getText() + " HAS BEEN CREATED");

        goToScreen1(event);

      } else {
        System.out.println("[SHELL] User creation failed - Passwords don't match");

        password.getStyleClass().add("error");
        passconf.getStyleClass().add("error");
        wrongPass.setVisible(true);
      }

    } else System.out.println("[SHELL] User creation failed - Missing fields");
  }
Пример #3
0
  /**
   * It's responsible for refreshing the application's task list when the "Refresh" button is
   * pressed.
   *
   * @throws ClassNotFoundException
   * @throws SQLException
   * @throws IOException
   */
  @FXML
  public void refreshList() throws ClassNotFoundException, SQLException, IOException {

    super.loadShell();

    super.loadLog();

    lstView.setItems(FXCollections.observableArrayList(shl.mapToSet()));
    // lstView.setCellFactory(ComboBoxListCell.forListView(FXCollections.observableArrayList(data)));
    // lstView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    lstView.setEditable(true);

    lstView.setOnMouseClicked(
        new EventHandler<MouseEvent>() {

          @Override
          public void handle(MouseEvent event) {

            System.out.println("clicked on " + lstView.getSelectionModel().getSelectedItem());

            shl.setCurrentTab((Task) lstView.getSelectionModel().getSelectedItem());
            whatever();

            taskName.setText(shl.getCurrentTab().getName());
            description.setText(shl.getCurrentTaskDescription());
            name.setText(shl.getCurrentTab().getAssignee());
            authorname.setText(shl.getCurrentTab().getAuthor());
            comment.setText(shl.getCurrentTab().getComment());
            lastEditor.setText(shl.getCurrentTab().getLastEditor().getID());
            status.setText(statusCheck());
            statusV.setText(statusVCheck());
            lastEditDate.setText(shl.getCurrentTab().getLastEditDate());
            creationDate.setText(shl.getCurrentTab().getCreationDate());
            verificationDate.setText(shl.getCurrentTab().getVerificationDate());
            completionDate.setText(shl.getCurrentTab().getCompletionDate());
            // authorname.setText(shl.getCurrentTab().getAuthor().getName());

            if (shl.getCurrentTab().getFileDemo() != null) {
              fileLabel.setText(shl.getCurrentTab().getFileDemo().toString());

            } else fileLabel.setText("No file uploaded");

            if (shl.getCurrentTab().isLOCKED()) {
              comment.setDisable(true);

            } else comment.setDisable(false);

            /*if(shl.getCurrentTab().getStatus()==true && shl.getCurrentTab().getStatusV()==true){
            	set background color green
            }*/
          }
        });
  }
Пример #4
0
  @FXML
  protected void statusVReject(ActionEvent event)
      throws ClassNotFoundException, IOException, SQLException {

    shl.markAsRejected();

    super.saveShell();

    super.saveLog(
        shl.getCurrentUser().getID()
            + " - "
            + shl.getCurrentUser().getName()
            + " - "
            + "REJECTED TASK "
            + shl.getCurrentTab().getName());
  }
Пример #5
0
  /**
   * marks the current Task as Verified by a Manager
   *
   * @param event
   * @throws ClassNotFoundException
   * @throws IOException
   * @throws SQLException
   */
  @FXML
  private void markAsVerified(ActionEvent event)
      throws ClassNotFoundException, IOException, SQLException {

    shl.markAsVerified();
    shl.getCurrentTab().setReject(false);

    super.saveShell();

    super.saveLog(
        shl.getCurrentUser().getID()
            + " - "
            + shl.getCurrentUser().getName()
            + " - "
            + "MARKED TASK "
            + shl.getCurrentTab().getName()
            + " AS VERIFIED");
  }
Пример #6
0
 /** Method implementation of the ControlledScreen interface. @see ControlledScreen */
 @Override
 public void setParentScreen(ScreenController parent) {
   try {
     super.loadShell();
     refreshList();
   } catch (ClassNotFoundException | SQLException | IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   controller = parent;
 }