Example #1
0
 private synchronized void checkAccount(Account account) {
   if (account != null) {
     textFieldFirstname.setText(account.getFirstName());
     textFieldLastname.setText(account.getLastName());
     textFieldUser.setText(account.getUsername());
     passwordField.setText(account.getPassword());
     if (account.getRfidKey() != null) textFieldRfid.setText(account.getRfidKey().getId());
   }
 }
 private void getuserinfo(String name) throws IOException {
   ToServer.writeUTF("iserinfo");
   ToServer.writeUTF(name);
   txaddname.setText(FromServer.readUTF());
   txaddpass.setText(FromServer.readUTF());
   txgroupname.setText(FromServer.readUTF());
   if (FromServer.readUTF().equals("1")) cboxadmin.setSelected(true);
   else cboxadmin.setSelected(false);
 }
  public void aboutToShow() {
    syncUserName.setText("");
    password.setText("");
    fullNameUnique.setText("");
    fullName.setText("");
    userName.setText("");
    workflowUserName.setText("");
    uuid.setText("");
    roles.getSelectionModel().clearSelection();
    roles.getSelectionModel().select(RoleOption.USER.name());

    Platform.runLater(() -> fullNameUnique.requestFocus());
  }
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    // Perform any initialization steps here.
    pc = PropertiesController.getPropertiesController();
    usernameTextField.setText(pc.getProp("username"));
    passwordPasswordField.setText(pc.getProp("password"));

    String signIn = pc.getProp("signInCheckbox");
    if (signIn == null) {
      signIn = "";
    }
    if (signIn.equals("true")) {
      keepMeLoggedInCheckBox.setSelected(true);
    }
  }
 private TextInputControl createPasswordbox(
     de.akubix.keyminder.core.ApplicationInstance instance, boolean init) {
   PasswordField t = new PasswordField();
   if (!init) {
     t.setText(getUIValue());
   }
   t.addEventFilter(
       KeyEvent.KEY_RELEASED,
       new EventHandler<KeyEvent>() {
         @Override
         public void handle(KeyEvent event) {
           storeData(instance.getTree().getSelectedNode());
         }
       });
   return t;
 }
  public AddEditCredentialView(Credential credential) {
    super();
    Label domainLabel = new Label("Domain:");
    domainText = new TextField();
    domainText.setPrefWidth(250);
    domainText.setText(credential != null ? credential.getDomainName() : "");
    domainText.setPromptText("Domain");
    Platform.runLater(domainText::requestFocus);

    Label usernameLabel = new Label("Username:"******"");
    usernameText.setPromptText("Username");

    Label passwordLabel = new Label("Password:"******"");
    passwordText.setPromptText("Password");

    setHgap(10);
    setVgap(10);

    setPadding(new Insets(8, 8, 8, 8));

    add(domainLabel, 0, 0);
    add(domainText, 1, 0);
    add(usernameLabel, 0, 1);
    add(usernameText, 1, 1);
    add(passwordLabel, 0, 2);
    add(passwordText, 1, 2);
    GridPane.setHgrow(domainText, Priority.ALWAYS);
    GridPane.setHgrow(usernameText, Priority.ALWAYS);
    GridPane.setHgrow(passwordText, Priority.ALWAYS);
  }
Example #7
0
  public MyDialog(Stage owner) {
    super();
    initOwner(owner);
    setTitle("title");
    initModality(Modality.APPLICATION_MODAL);
    Group root = new Group();
    Scene scene = new Scene(root, 250, 150, Color.WHITE);
    setScene(scene);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(5);
    gridpane.setVgap(5);

    Label userNameLbl = new Label("User Name: ");
    gridpane.add(userNameLbl, 0, 1);

    Label passwordLbl = new Label("Password: "******"Admin");
    gridpane.add(userNameFld, 1, 1);

    final PasswordField passwordFld = new PasswordField();
    passwordFld.setText("password");
    gridpane.add(passwordFld, 1, 2);

    Button login = new Button("Change");
    login.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            close();
          }
        });
    gridpane.add(login, 1, 3);
    GridPane.setHalignment(login, HPos.RIGHT);
    root.getChildren().add(gridpane);
  }
 /**
  * Reset Btn Event Reset all the field
  *
  * @param ae
  */
 @FXML
 public void ResetBtnClick(ActionEvent ae) {
   password.setText("");
   userName.setText("");
   dropDown.getSelectionModel().clearSelection();
 }
 public void resetFileds() {
   fieldNewEmail.setText("");
   fieldPassword.setText("");
 }
  @Override
  public void initialize(URL url, ResourceBundle rb) {

    try { // Create a socket to connect to the server
      Socket socket = new Socket("localhost", 8000);

      FromServer = new DataInputStream(socket.getInputStream());
      // Create an output stream to send data to the server
      ToServer = new DataOutputStream(socket.getOutputStream());
    } catch (IOException ex) {
      lbout.setText(ex.toString() + '\n');
    }

    while (loged) {}
    btlogout.setOnAction(
        e -> {
          try {
            ToServer.writeUTF("Logout");
            Boolean logout = FromServer.readBoolean();
            if (logout) {
              loged = false;
              isadmin = false;
              lbloginfo.setText("Loged Out");
              tbuser.setDisable(!loged);
              tbadmin.setDisable(!isadmin);
              btlogout.setVisible(false);
              btlogin.setVisible(true);
              txaddpass.clear();
              // btlogin.setText("Login");
              tfname.setDisable(false);
              tfpass.setDisable(false);
            } else lbloginfo.setText("Logout Failed");

          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        });
    btlogin.setOnAction(
        e -> {
          String name = tfname.getText();
          String pass = tfpass.getText();
          if (name.isEmpty() && pass.isEmpty()) lbloginfo.setText("Username and Password is empty");
          else if (name.isEmpty()) lbloginfo.setText("Username is empty");
          else if (pass.isEmpty()) lbloginfo.setText("Password is empty");
          else {
            try {
              ToServer.writeUTF(tfname.getText());
              ToServer.writeUTF(tfpass.getText());
              loged = FromServer.readBoolean();
              isadmin = FromServer.readBoolean();
              if (loged) {
                lbloginfo.setText("Logged in");
                lbloginfo.setText("Welcome Back " + name);
                // btlogin.setText("Logout");
                tfname.setDisable(true);
                tfpass.setDisable(true);
                btlogin.setVisible(false);
                btlogout.setVisible(true);
                if (isadmin) {
                  lbtypeuser.setText("Loged as Administrator");

                } else lbtypeuser.setText("Loged as User");
                // tbadmin.setDisable(!isadmin);
                tbuser.setDisable(!loged);
                tbadmin.setDisable(!isadmin);
                tb.getSelectionModel().select(tbuser);
                repo = FromServer.readUTF();
                txgroup.setText(repo);
                // getuserinfo(repo);
                getFilesinfo();
                getgroupe();
                getusers();
                gettars();
                // cbbackups.getItems().addAll(tars);
                // cbgroup.getItems().addAll(groups);
                // cbselectuser.getItems().addAll(users);
              } else lbout.setText("Failed to log in");

            } catch (IOException ex) {

            }
          }
        });
    btbackup.setOnAction(
        e -> {
          try {
            tars.clear();
            ToServer.writeUTF("Backup");
            Boolean answer = FromServer.readBoolean();
            if (answer) {
              lbadmininfo.setText("Backup finished");
              gettars();
            } else {
              lbadmininfo.setText("error accured during restore");
              gettars();
            }

          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            try {
              gettars();
            } catch (Exception e2) {
              // TODO Auto-generated catch block
              e2.printStackTrace();
            }
          }
        });
    btrestore.setOnAction(
        e -> {
          try {
            if (!cbbackups.selectionModelProperty().get().getSelectedItem().isEmpty()) {
              ToServer.writeUTF("Restore");
              ToServer.writeUTF(cbbackups.selectionModelProperty().get().getSelectedItem());
              Boolean answer = FromServer.readBoolean();
              if (answer) lbadmininfo.setText("restore finished");
              else lbadmininfo.setText("error accured during backup");
            } else lbadmininfo.setText("please choose tar file");

          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        });
    btcheckin.setOnAction(
        e -> {
          if (loged) {
            file = fileChooser.showOpenDialog(new Stage());
            if (file != null) {
              try {
                ToServer.writeUTF("Checkin");
                ToServer.writeUTF(file.getName());
                ToServer.writeLong(file.lastModified());
                sendFile(file);
                String choice = null;
                choice = FromServer.readUTF();
                if (choice.equals("sync")) {
                  getFilesinfo();
                  File newfile = GetFile(FromServer);

                  writeFile(file, file.getPath() + "--old");
                  String path = file.getPath();
                  file.delete();
                  writeFile(newfile, path);
                  lbout.setText("Performing Sync with the server");
                } else if (choice.contains("locked")) {
                  getFilesinfo();
                  lbout.setText(choice);
                } else if (choice.equals("not text")) {
                  getFilesinfo();
                  lbout.setText("Check in only text files");
                } else if (choice.equals("equal")) {
                  getFilesinfo();
                  lbout.setText("The file is equal to the latest version");
                } else {
                  getFilesinfo();
                  lbout.setText("The file is uploaded successfully");
                }
                // ToServer.writeUTF("Files");

                // getFilesinfo();
              } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
            }
          }
        });
    btcheckout.setOnAction(
        e -> {
          try {
            ToServer.writeUTF("Checkout");
            ToServer.writeUTF(tbl.selectionModelProperty().get().getSelectedItem().getName());
            System.out.println(tbl.selectionModelProperty().get().getSelectedItem().getName());
            ToServer.writeUTF(cbversion.selectionModelProperty().get().getSelectedItem());
            System.out.println(cbversion.selectionModelProperty().get().getSelectedItem());
            Boolean answer = FromServer.readBoolean();
            if (answer) {
              String filename = FromServer.readUTF();
              Long timestamp = FromServer.readLong();
              File ver = GetFile(FromServer);
              String pa = System.getProperty("user.home") + "/" + filename;
              writeFile(ver, System.getProperty("user.home") + "/" + filename);
              File tim = new File(System.getProperty("user.home") + "/" + filename);
              tim.setLastModified(timestamp);
              lbout.setText("The file is saved on your home directory");
            } else lbout.setText("Checkout failed");
          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        });
    tbl.getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (obs, oldSelection, newSelection) -> {
              if (newSelection != null) {
                versions.clear();
                Float lastvers =
                    Float.valueOf(tbl.getSelectionModel().selectedItemProperty().get().getLastv());
                for (float i = 1f; i <= lastvers + 0.001; i += 0.001) {
                  if (i == 1f) versions.add(Float.toString(i) + "00");
                  else versions.add(Float.toString(i).substring(0, 5));
                }
                cbversion.getItems().addAll(versions);
              }
            });
    cbgroup
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (obs, oldSelection, newSelection) -> {
              if (newSelection != null) {
                try {

                } catch (Exception e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
              }
            });
    btadduser.setOnAction(
        e -> {
          try {
            if (!txaddname.getText().isEmpty()
                && !txaddpass.getText().isEmpty()
                && !txgroup.getText().isEmpty()) {
              ToServer.writeUTF("Adduser");
              ToServer.writeUTF(txaddname.getText());
              ToServer.writeUTF(txaddpass.getText());
              if (cboxadmin.isSelected()) ToServer.writeUTF("1");
              else ToServer.writeUTF("0");
              ToServer.writeUTF(txgroup.getText());
              Boolean answer = FromServer.readBoolean();
              try {
                if (answer) {
                  lbadmininfo.setText("User Added");
                  users.clear();
                  getusers();
                  // users.add(txaddname.getText());
                  txaddname.setText("");
                  txaddpass.setText("");
                  cboxadmin.setSelected(false);
                } else {
                  lbadmininfo.setText("User add failed");
                  getusers();
                }
              } catch (Exception p) {
                getusers();
              }
            } else {
              lbadmininfo.setText("All text must be field");
              getusers();
            }

          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            try {
              getusers();
            } catch (Exception e2) {
              // TODO Auto-generated catch block
              e2.printStackTrace();
            }
          }
        });
    btdeleteuser.setOnAction(
        e -> {
          try {
            if (!cbselectuser.selectionModelProperty().get().getSelectedItem().isEmpty()) {
              ToServer.writeUTF("Deleteuser");
              ToServer.writeUTF(cbselectuser.selectionModelProperty().get().getSelectedItem());
              cbselectuser.setValue("");
              users.clear();
              Boolean answer = FromServer.readBoolean();
              if (answer) {
                lbadmininfo.setText("User deleted");
                getusers();
                // users.remove(cbselectuser.selectionModelProperty().get().getSelectedItem());
              } else {
                lbadmininfo.setText("unable to delete user");
                getusers();
              }
            } else {
              lbadmininfo.setText("All text must be field");
              getusers();
            }

          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            try {
              getusers();
            } catch (Exception e2) {
              // TODO Auto-generated catch block
              e2.printStackTrace();
            }
          }
        });
    btaddgroup.setOnAction(
        e -> {
          try {
            if (!txgroupname.getText().isEmpty()) {
              ToServer.writeUTF("Addgroup");
              ToServer.writeUTF(txgroupname.getText());
              Boolean answer = FromServer.readBoolean();
              if (answer) {
                lbadmininfo.setText("Group Added");
                getgroupe();
              } else {
                lbadmininfo.setText("Group add failed");
                getgroupe();
              }
            } else {
              lbadmininfo.setText("All text must be field");
              getgroupe();
            }
          } catch (Exception e1) {
            // TODO Auto-generated catch block
            try {
              getgroupe();
            } catch (Exception e2) {
              // TODO Auto-generated catch block
              e2.printStackTrace();
            }
          }
        });
  }
  @FXML
  private void giris(ActionEvent event) throws IOException {
    Boolean durum = false;

    try {
      String sAdminAdi = kuladi.getText();
      String sAdminSifre = sifreleme(sifre.getText());

      if (sAdminAdi.equals("")) {

        Alert alert =
            new Alert(Alert.AlertType.WARNING, "Lütfen Kullanıcı Adını Giriniz.", ButtonType.OK);
        alert.setHeaderText(null);
        alert.setTitle("Uyarı");
        alert.showAndWait();
        kuladi.requestFocus();
        sifre.setText("");

        durum = true;

      } else if (sifre.getText().equals("")) {

        Alert alert = new Alert(Alert.AlertType.WARNING, "Lütfen Şifreyi Giriniz.", ButtonType.OK);
        alert.setHeaderText(null);
        alert.setTitle("Uyarı");
        alert.showAndWait();
        sifre.requestFocus();
        durum = true;

      } else {

        SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
        Session sess = sf.openSession();
        Transaction ts = sess.beginTransaction();

        Query qee = sess.createQuery("from SuperAdmin");
        Iterator ite = qee.iterate();

        while (ite.hasNext()) {

          SuperAdmin obj = (SuperAdmin) ite.next();
          String kuladi = obj.getKulAdi();
          String sifre = obj.getSifre();

          if (sAdminAdi.equals(kuladi) & sAdminSifre.equals(sifre)) {

            Integer sID = obj.getSuperID();
            //                label.setText(sID.toString());

            Parent root = null;
            Stage stage = new Stage();
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("yonlendir.fxml"));
            root = fxmlLoader.load();
            yonlendirController cont = fxmlLoader.getController();
            cont.getRefCode(sID);
            stage.setScene(new Scene(root));
            stage.show();
            durum = true;
          }
        }

        if (durum == false) {

          Alert alert =
              new Alert(Alert.AlertType.WARNING, "Hatalı Kullanıcı Adı veya Şifre", ButtonType.OK);
          alert.setHeaderText(null);
          alert.setTitle("Uyarı");
          alert.showAndWait();
          kuladi.setText("");
          sifre.setText("");
          kuladi.requestFocus();
        }

        ts.commit();
        sess.close();
      }
    } catch (HibernateException he) {
      System.out.println(he);
    }
  }