Ejemplo n.º 1
1
  /*
  /Check of de naam in de database gelijk is aan de textveld tfBeginUsername
  */
  @FXML
  public void Login() throws IOException, SQLException, NotBoundException {
    try {
      // check if the user is already online.
      for (User usr : loginIn.getOnlineUsers()) {
        if (usr.getName().equals(tfBeginUsername.getText())) {
          Alert alert = new Alert(AlertType.INFORMATION);
          alert.setTitle("Information");
          alert.setHeaderText(null);
          alert.setContentText("User is already online");
          alert.showAndWait();

        } else if (loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText()) != null) {
          user = loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText());
          LobbySession.user = user;
          userName = user.getName();
          LbLobbyUserName.textProperty().bind(userNameProperty);
          loginIn.addToOnline(LobbySession.user);
          stage = (Stage) btBeginLogIn.getScene().getWindow();
          root = FXMLLoader.load(getClass().getResource("Lobby.fxml"));
          Scene scene = new Scene(root);
          scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm());
          stage.setScene(scene);
          stage.setResizable(false);
          stage.show();

        } else {
          Alert alert = new Alert(AlertType.INFORMATION);
          alert.setTitle("Information");
          alert.setHeaderText(null);
          alert.setContentText("Please enter correct name and password");
          alert.showAndWait();
        }
      }
      if (loginIn.getOnlineUsers().isEmpty()) {
        user = loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText());
        LobbySession.user = user;
        userName = user.getName();
        LbLobbyUserName.textProperty().bind(userNameProperty);
        loginIn.addToOnline(LobbySession.user);
        stage = (Stage) btBeginLogIn.getScene().getWindow();
        root = FXMLLoader.load(getClass().getResource("Lobby.fxml"));
        Scene scene = new Scene(root);
        scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm());
        stage.setScene(scene);
        stage.setResizable(false);
        stage.show();
      }
    } catch (Exception ex) {
      System.out.println("Not working: " + ex);
    }
  }
Ejemplo n.º 2
0
  @Override
  public void setElementText(ResourceBundle rb) {
    if (btnOK.getScene() != null)
      ((Stage) btnOK.getScene().getWindow()).setTitle(rb.getString("keyFormTUTitle"));

    btnOK.setText(rb.getString("keyApply"));
    btnCancel.setText(rb.getString("keyCancel"));
    sendText = rb.getString("keySendText");
  }
Ejemplo n.º 3
0
  public boolean isOkPressed(int typeSignal) {
    ((StageLoader) btnOK.getScene().getWindow()).setMethod(() -> btnOK());
    if (tuSignal == null) return false;
    Stage w = (Stage) btnOK.getScene().getWindow();

    if (typeSignal == 3) {
      List<SpTuCommand> tuCommands =
          SingleFromDB.spTuCommands
              .stream()
              .filter(f -> f.getObjref() == tuSignal.getStateref())
              .collect(Collectors.toList());
      ChoiceBox<SpTuCommand> chBox = new ChoiceBox<>();
      tuCommands.forEach(chBox.getItems()::add);
      chBox
          .getSelectionModel()
          .selectedItemProperty()
          .addListener(
              (observ, oldValue, newValue) -> {
                value = newValue.getVal() + "";
              });
      if (chBox.getItems().size() > 0) chBox.getSelectionModel().selectFirst();
      if (SingleObject.selectedShape.getValueProp().get()
          == chBox.getSelectionModel().getSelectedItem().getVal()) {
        chBox.getSelectionModel().selectNext();
      }
      Platform.runLater(() -> chBox.requestFocus());
      bpTU.setCenter(chBox);
    } else if (typeSignal == 1) {
      TextField txtField = new TextField();
      txtField.setText(SingleObject.selectedShape.getValueProp().get() + "");
      txtField
          .textProperty()
          .addListener(
              (observ, oldValue, newValue) -> {
                try {
                  Double.parseDouble(newValue);
                  value = newValue;
                } catch (Exception e) {
                  txtField.setText(oldValue);
                }
              });
      Platform.runLater(() -> txtField.requestFocus());
      bpTU.setCenter(txtField);
    } else {
      System.out.println("=====   This is not TU or TI   =====");
    }
    w.showAndWait();

    return isOkClicked;
  }
Ejemplo n.º 4
0
 @FXML
 private void onSaveButtonClick(ActionEvent event) {
   pc.setProp("jdkLocation", jdkLocationTextBox.getText());
   pc.saveProps();
   thisStage = (Stage) saveButton.getScene().getWindow();
   thisStage.close();
 }
 public void goToPortal() throws IOException {
   Parent page = FXMLLoader.load(getClass().getResource("Portal.fxml"));
   Scene scene = new Scene(page);
   Stage stage = (Stage) goToPortal.getScene().getWindow();
   stage.setScene(scene);
   stage.show();
 }
Ejemplo n.º 6
0
 public void createEvents() {
   closeButton.setOnAction(
       event -> {
         NetWindow = (Stage) closeButton.getScene().getWindow();
         NetWindow.close();
       });
 }
Ejemplo n.º 7
0
  public void sendRequest(String username, String password) {

    thisStage = (Stage) logInButton.getScene().getWindow();
    Response res =
        new Request("user/login").set("username", username).set("password", password).send();

    if (res.getSuccess()) {
      Main.setSessionID((String) res.get("sessionID"));
      System.out.println("Login successful.");
      Main.userNotLoggedIn.setValue(false);

      // Save the login option if checked
      if (keepMeLoggedInCheckBox.isSelected()) {
        pc.setProp("username", usernameTextField.getText());
        pc.setProp("password", passwordPasswordField.getText());
        pc.setProp("signInCheckbox", "true");
        pc.saveProps();
      }

      HomeController.userName = usernameTextField.getText();
      thisStage.close();
    } else {
      // incorrect password
    }
  }
  @FXML
  private void onOkButtonClicked() {

    if (!headerTextField.getText().isEmpty() || picturePreview.getImage() != null) {
      HTMLHeader header;
      if (!headerTextField.getText().isEmpty() && picturePreview.getImage() == null) {
        header = new HTMLHeader(headerTextField.getText());
        System.out.println("Header only has text.");
      } else if (headerTextField.getText().isEmpty() && picturePreview.getImage() != null) {
        header = new HTMLHeader(picturePreview.getImage());
        System.out.println("Header only has image.");
      } else {
        header = new HTMLHeader(headerTextField.getText(), picturePreview.getImage());
        System.out.println("Header has both image and text.");
      }

      ApplicationManager.getInstance().setWebPageHeader(header);
      System.out.println("Attempting to set header to webpage.");
      // --------------------Added By James------------------------------------------------
      // JavaToHTML HTML = new JavaToHTML();
      // ApplicationManager.getInstance().getHtmlGenerator().setHeaderFromGUI(headerTextField.getText(),picturePath.getText());
      // writeAndRefresh();
      // --------------------End Added By James------------------------------------------------
    } else {
      System.out.println("Header has nothing. Not creating an object.");
    }
    Stage stage = (Stage) okButton.getScene().getWindow();

    stage.close();
  }
 //    @Override
 //    public void setScreenParent(ScreensController screenParent) {
 //        controller = screenParent;
 //    }
 @FXML
 public void buttonClick(ActionEvent event) throws IOException {
   // controller.loadScreen(Main.createAdminFile);
   if (checkInfo()) {
     Alert emptyInfo = new Alert(Alert.AlertType.ERROR);
     emptyInfo.setTitle("Error");
     emptyInfo.setHeaderText("Please make sure to correctly fill out the following: \n");
     emptyInfo.setContentText(errorStr);
     emptyInfo.showAndWait();
   } else {
     groupDir = Paths.get("").toAbsolutePath().toString() + "\\" + groupUsernameField.getText();
     if (!Files.exists(Paths.get(groupDir))) {
       saveData();
       Stage stage = (Stage) groupNext.getScene().getWindow();
       Parent root = FXMLLoader.load(getClass().getResource(Main.createAdminFile));
       Scene scene = new Scene(root);
       stage.setScene(scene);
       stage.show();
     } else {
       Alert emptyInfo = new Alert(Alert.AlertType.ERROR);
       emptyInfo.setTitle("Error: Company exists");
       emptyInfo.setHeaderText(null);
       emptyInfo.setContentText(
           "Company by that name already exists in the system. Please enter a new company name.");
       emptyInfo.showAndWait();
     }
     // Files.delete(file.toPath());
   }
 }
 public void reserveEditNotConfirm() throws IOException {
   Parent page = FXMLLoader.load(getClass().getResource("BookingEdit.fxml"));
   Scene scene = new Scene(page);
   Stage stage = (Stage) notConfirmReserve.getScene().getWindow();
   stage.setScene(scene);
   stage.show();
 }
Ejemplo n.º 11
0
 private void handleControlPropertyChanged(final String PROPERTY) {
   if ("LOAD_BACKGROUND".equals(PROPERTY)) {
     Image image = getImage(buttonLoadBackgroundImage.getScene().getWindow());
     if (null == image) return;
     backgroundImage.setImage(image);
     backgroundImage.toBack();
   } else if ("LOAD_HEATMAP".equals(PROPERTY)) {
     Image image = getImage(buttonLoadHeatMapImage.getScene().getWindow());
     if (null == image) return;
     heatMapImage.setImage(image);
     toggleButtonShowHeatMap.setSelected(true);
   } else if ("TOGGLE_HEATMAP".equals(PROPERTY)) {
     toggleButtonShowHeatMap.setText(toggleButtonShowHeatMap.isSelected() ? "show" : "hide");
     heatMapImage.setVisible(!toggleButtonShowHeatMap.isSelected());
   }
 }
  public void initialize() throws IOException {

    lblMessage.setText("");
    lblMessage.setText("Send Oil Change Reminder Message?");

    btnCancelMessage.setOnAction(
        e -> {
          // System.exit(0);
          Stage stageBox = (Stage) btnCancelMessage.getScene().getWindow();
          stageBox.close();
        });
    btnSendMessage.setOnAction(
        e -> {
          lblMessage.setText("");
          lblMessage.setText("Message Sent!");

          try {
            btnCancelMessage.setAlignment(Pos.CENTER);
            btnSendMessage.setVisible(false);
            btnCancelMessage.setText("Done!");
            Parent stageBox = btnCancelMessage.getParent();
            ((BorderPane) stageBox).setCenter(btnCancelMessage);
          } catch (Exception exception) {
          }
        });
  }
 @FXML
 private void year(ActionEvent event) throws IOException {
   Parent page = FXMLLoader.load(getClass().getResource("yearReport.fxml"));
   Scene scene = new Scene(page);
   Stage stage = (Stage) btn_home.getScene().getWindow();
   stage.setScene(scene);
   stage.show();
 }
 @FXML
 public void OpenKataxorisi(ActionEvent e) throws IOException {
   Stage stage = (Stage) backButton.getScene().getWindow();
   sl.StageLoad(
       "/sopho/Filoksenoumenoi/KataxorisiFiloksenoumenou.fxml",
       stage,
       true,
       false); // resizable true, utility false
 }
 @FXML
 public void OpenTrexontes(ActionEvent e) throws IOException {
   Stage stage = (Stage) backButton.getScene().getWindow();
   sl.StageLoad(
       "/sopho/Filoksenoumenoi/ProvoliTrexontonFiloksenoumenon.fxml",
       stage,
       true,
       false); // resizable true, utility false
 }
Ejemplo n.º 16
0
 @FXML
 public void switchToCreateUser(Event evt) throws IOException {
   stage = (Stage) btBeginLogIn.getScene().getWindow();
   root = FXMLLoader.load(getClass().getResource("CreateUser.fxml"));
   Scene scene = new Scene(root);
   scene.getStylesheets().add((new File("css/CreateUser.css")).toURI().toURL().toExternalForm());
   stage.setScene(scene);
   stage.setResizable(false);
   stage.show();
 }
Ejemplo n.º 17
0
  @FXML
  void showFileChooser() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialFileName("export");
    fileChooser.setSelectedExtensionFilter(
        new FileChooser.ExtensionFilter("export to excel", ".xlsx"));

    File file = fileChooser.showOpenDialog(exportBtn.getScene().getWindow());
    exportFile.set(file);
  }
Ejemplo n.º 18
0
 @FXML
 public void backToLobby() throws IOException {
   stage = (Stage) btGameLobbyExit.getScene().getWindow();
   root = FXMLLoader.load(getClass().getResource("Lobby.fxml"));
   Scene scene = new Scene(root);
   scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm());
   stage.setScene(scene);
   stage.setResizable(false);
   stage.show();
 }
 public void fileFind(ActionEvent e) throws IOException {
   FileChooser chooser = new FileChooser();
   File file = chooser.showOpenDialog((Stage) fileBtn.getScene().getWindow());
   if (file != null) {
     logoLoc.setText(file.getPath());
     String fileName = file.getName();
     String filePath = Paths.get("").toAbsolutePath().toString() + fileName;
     destFile = new File(filePath);
     Files.copy(file.toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
   }
 }
 @FXML
 protected void exportKml() {
   String filename = tfFilename.getCharacters().toString();
   if (filename != null) {
     KmlExport.kmlPointLayer(filename, GeoConversor.getInstance().getList());
   } else {
     // TODO: show message dialog
   }
   Stage stage = (Stage) bExport.getScene().getWindow();
   stage.close();
 }
Ejemplo n.º 21
0
 @FXML
 private void onBrowseButtonClick(ActionEvent event) {
   Stage stage = null;
   stage = (Stage) browseButton.getScene().getWindow();
   DirectoryChooser dirChoose = new DirectoryChooser();
   dirChoose.setTitle("Choose JDK Location");
   File selectedDir = dirChoose.showDialog(stage);
   if (selectedDir != null) {
     jdkLocationTextBox.setText(selectedDir.getPath());
   }
 }
  @FXML
  protected void handleSubmitAction(ActionEvent event) throws IOException {
    String id = userIdField.getText();
    String password = passwordField.getText();
    RuleSet loginRules = RuleSetFactory.getRuleSet(this);
    ControllerInterface controller = SystemController.getInstance();

    try {
      loginRules.applyRules(this);
      controller.login(id, password);
      Auth auth = SystemController.currentAuth;
      String fxmlFile = "";

      switch (auth) {
        case ADMIN:
          fxmlFile = "../Admin.fxml";
          break;
        case LIBRARIAN:
          fxmlFile = "../Librarian.fxml";
          break;
        case BOTH:
          fxmlFile = "../MainMenu.fxml";
          break;
      }

      Pane mainMenuRoot = FXMLLoader.load(getClass().getResource(fxmlFile));
      Stage stage = new Stage();
      stage.initModality(Modality.WINDOW_MODAL);
      stage.setTitle("Main Menu");
      stage.setScene(new Scene(mainMenuRoot));
      stage.show();
      userIdField.clear();
      passwordField.clear();
      Stage loginStage = (Stage) submit.getScene().getWindow();
      loginStage.close();

    } catch (RuleException e1) {
      Alert alert = new Alert(AlertType.ERROR);
      alert.setTitle("Login Error!");
      alert.setHeaderText("Incorrect login information!");
      alert.setContentText(e1.getMessage());
      alert.show();
    } catch (LoginException e) {
      Alert alert = new Alert(AlertType.ERROR);
      alert.setTitle("Login Error!");
      alert.setHeaderText("Incorrect login information!");
      alert.setContentText(e.getMessage());
      alert.show();
    }
  }
Ejemplo n.º 23
0
  @FXML
  public void login(ActionEvent e) throws SQLException {
    if (cl.checkCredenzialiClienti(user.getText(), pass.getText())) {
      username =
          user
              .getText(); // salva l'informazione dell'username da passare all'interfaccia cliente o
                          // operatore
      // setta le informazioni nelle finestre username e operatore
      nome = cl.read(user.getText()).getNome();
      cognome = cl.read(user.getText()).getCognomeCliente();
      FrontController.getIstance().setAutenticato();
      FrontController.getIstance().dispatchRequest("FinestraClienti");
    } else if (ag.checkcredenziali(user.getText(), pass.getText())) {
      FrontController.getIstance().setAutenticato();
      try {
        setDataAgente();
        // Caricamento nuova finestra e chiusura finestra login
        FrontController.getIstance().dispatchRequest("FinestraOperatore");
        Stage stage = (Stage) exit_btn.getScene().getWindow();
        stage.close();
      } catch (Exception e1) {
        e1.printStackTrace();
      }
    } else if (user.getText().equals("capone") && pass.getText().equalsIgnoreCase("capone")) {
      FrontController.getIstance().setAutenticato();
      try {
        FrontController.getIstance().dispatchRequest("FinestraAmministrazione");
        Stage stage = (Stage) exit_btn.getScene().getWindow();
        stage.close();

      } catch (Exception e1) {
        e1.printStackTrace();
      }
    } else {
      Popup.Errore("Credenziali errate", "Hai inserito credenziali sbagliate.");
    }
  }
 @FXML
 private void handleButtonAction(ActionEvent event) throws IOException {
   Stage stage;
   Parent root;
   Button source = (Button) event.getSource();
   stage = (Stage) source.getScene().getWindow();
   if (source == editAbout) {
     root = FXMLLoader.load(getClass().getResource("/game/playerTurnFinished.fxml"));
   } else {
     root = null;
   }
   Scene scene = new Scene(root);
   stage.setScene(scene);
   stage.show();
 }
  @FXML
  void loginAction() {
    try {
      credenciais.setLogin(textLogin.getText());
      credenciais.setSenha(textPassword.getText());
      securityContext.login();

      if (securityContext.isLoggedIn()) {
        buttonLogin.getScene().getWindow().hide();
      } else {
        errorMessage.setText(resources.getString("login.errorMessage"));
        showMessageError();
      }
    } catch (Exception exception) {
      ExceptionUtils.throwCustomerException(exception, false);
    }
  }
Ejemplo n.º 26
0
  /** Logout */
  public void clickLogout() {

    try {
      Stage stage = (Stage) logoutButton.getScene().getWindow();

      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/res/LoginFormDocente.fxml"));

      Parent parent = fxmlLoader.load();

      stage.setTitle("Login Docente");
      stage.setScene(new Scene(parent, 600, 600));
      stage.setResizable(false);
      stage.show();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 @FXML
 private void Ok_click(ActionEvent event) {
   logger.entry();
   LogEntry log = new LogEntry("6.16", "Local Delete Object Instance service");
   try {
     ObjectInstanceHandle instanceHandle =
         rtiAmb
             .getObjectInstanceHandleFactory()
             .decode(
                 ByteBuffer.allocate(4)
                     .putInt(Integer.parseInt(ObjectInstanceDesignator.getText()))
                     .array(),
                 0);
     log.getSuppliedArguments()
         .add(
             new ClassValuePair(
                 "Object instance designator",
                 ObjectInstanceHandle.class,
                 instanceHandle.toString()));
     rtiAmb.localDeleteObjectInstance(instanceHandle);
     log.setDescription("Local Object instance deleted successfully");
     log.setLogType(LogEntryType.REQUEST);
   } catch (FederateNotExecutionMember
       | NotConnected
       | NumberFormatException
       | CouldNotDecode
       | RTIinternalError
       | OwnershipAcquisitionPending
       | FederateOwnsAttributes
       | ObjectInstanceNotKnown
       | SaveInProgress
       | RestoreInProgress ex) {
     log.setException(ex);
     log.setLogType(LogEntryType.ERROR);
     logger.log(Level.ERROR, ex.getMessage(), ex);
   } catch (Exception ex) {
     log.setException(ex);
     log.setLogType(LogEntryType.FATAL);
     logger.log(Level.FATAL, ex.getMessage(), ex);
   }
   logEntries.add(log);
   ((Stage) OkButton.getScene().getWindow()).close();
   logger.exit();
 }
 @FXML
 private void btn_actionClick(ActionEvent event) throws RuntimeException, IOException {
   Button tmp = (Button) event.getSource();
   Stage stage = (Stage) tmp.getScene().getWindow();
   if (tmp.getText().equals("<")) {
     this.edSenha.clear();
   } else if (tmp.getText().equals("OK")) {
     // entra da rotina de logar no sistema
     try {
       if (this.edSenha.getText().length() > 0) {
         AdministradorLogin al = new AdministradorLogin(GlobalInfor.admName, this.adm_password);
         if (al.login()) {
           // some com o painel de controle
           this.myController.setScreen("adm_main");
           System.out.println("Logado");
           stage.close();
         }
       } else {
         DefaultExceptionDialog de =
             new DefaultExceptionDialog("Campo de senha não pode ficar em branco.");
         de.showDialog();
         this.edSenha.setFocusTraversable(true);
       }
     } catch (LoginIncorretoException e) {
       DefaultExceptionDialog de = new DefaultExceptionDialog(e.getMessage());
       de.showDialog();
     } catch (SQLException e) {
       DefaultExceptionDialog de = new DefaultExceptionDialog("Erro no banco de dados");
       de.showDialog();
       stage.close();
     } finally {
       this.adm_password.clear();
       this.edSenha.clear();
     }
   } else {
     if (this.edSenha.getText().length() < 9) {
       this.edSenha.setText(this.edSenha.getText() + "1");
       this.adm_password.add(tmp.getText());
       this.ini_controllers();
     }
   }
   System.out.println("Debug: " + this.edSenha.getText());
 }
Ejemplo n.º 29
0
  /**
   * Inoltra il docente nella pagina di gestione dei verbali
   *
   * @throws Exception
   */
  @FXML
  public void clickVerbale() throws Exception {

    Stage primaryStage = (Stage) verbaleButton.getScene().getWindow();

    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/res/VerbaleFrame.fxml"));
    Parent root = fxmlLoader.load();

    VerbaleFrame controller = fxmlLoader.getController();
    controller.setDocente(currDocente);

    controller.riempiVerbaliAperti(
        mPortaleDocenteCtrl.verbaliAperti(currDocente.getMatricolaDocente()));

    primaryStage.setTitle("Verbali");
    primaryStage.setScene(new Scene(root, 800, 600));
    primaryStage.setResizable(false);
    primaryStage.show();
  }
  public void loadCatalogs() {
    Button button;
    Catalog catalog;
    List<Item> items =
        ((CatalogCollection) (new CatalogModel()).getCollection()).loadByLibraryId(libraryId);
    int i = 1;

    for (Item item : items) {
      catalog = (Catalog) item;
      button = new Button(catalog.getName());
      int catalogId = catalog.getId();
      button.setId(String.valueOf(catalogId));
      button.getStyleClass().add("cake");
      button.setOnAction(
          (ActionEvent event) -> {
            try {
              Scene sceneCurrent = btnBack.getScene();
              Stage stage = (Stage) sceneCurrent.getWindow();

              FXMLLoader fxmlLoader =
                  new FXMLLoader(getClass().getResource("/view/template/book/BookList.fxml"));
              Parent sceneNew = fxmlLoader.load();

              BookListController controller = fxmlLoader.<BookListController>getController();
              controller.setCatalogId(catalogId);
              controller.setLibraryId(libraryId);
              controller.prepareData();

              stage.setScene(
                  new Scene(sceneNew, sceneCurrent.getWidth(), sceneCurrent.getHeight()));
            } catch (IOException e) {
              logger.log(Level.SEVERE, "Error configuring catalog buttons", e);
            }
          });
      catalogContainer.add(button, i++, 1);
    }
  }