Пример #1
0
  /**
   * Sets the corresponding values of specific user to the dialog.
   *
   * @param selectedUser . User that locate in the row of User table in which has been pressed the
   *     button Change settings.
   */
  public void setSelectedUser(User selectedUser) {
    userFullName.setValue(selectedUser.getFullName());
    userName.setValue(selectedUser.getUsername());
    password.setValue("*****");
    passwordConfim.setValue("*****");
    userEmail.setValue(selectedUser.getEmail().toString());
    roleSelector.setValue(selectedUser.getRoles());

    selectUser = selectedUser;
  }
 @Override
 public void resetForm() {
   inputUserName.setValue("");
   inputName.setValue("");
   inputTitle.setValue("");
   inputAddress.setValue("");
   inputEmployeeNum.setValue("");
   inputPhoneNumber.setValue("");
   inputPassword1.setValue("");
   inputPassword2.setValue("");
   inputSika.setValue("");
 }
 private void limpaCampos() {
   ligaCampos();
   nome.setValue("");
   email.setValue("");
   telefone.setValue("");
   cargo.setValue("");
   login.setValue("");
   senha1.setValue("");
   senha2.setValue("");
   admin.setValue(false);
   desligaCampos();
 }
Пример #4
0
 private Button genBut(String name) {
   Button b = new Button(name);
   b.addStyleName("user-select");
   b.setIcon(userIcon);
   b.addClickListener(
       e -> {
         if (loginBox.isVisible()) {
           hidePass();
           return;
         }
         loginField.setValue("");
         String t = e.getButton().getCaption();
         if (Globals.control.hasPassword(t)) {
           selected = Globals.control.getUser(t);
           showPassField();
         } else {
           User s = Globals.control.getUser(t);
           if (s == null) {
             return;
           }
           Globals.user = s;
           Globals.root.changeScreen(Globals.user);
         }
       });
   return b;
 }
Пример #5
0
  public UserSelect() {
    loginInfo = new Label("");
    loginInfo.addStyleName("error-font");
    loginInfo.addStyleName("margin15");
    loginInfo.addStyleName("margin-top40");
    loginInfo.setVisible(false);
    selected = null;
    loginField = new PasswordField("");
    loginField.setWidth("200px");
    loginField.addStyleName("margin15");
    loginField.addStyleName("margin-bot40");
    loginBut = new Button("login");
    loginBut.addStyleName("margin15");
    loginBut.addClickListener(
        e -> {
          if (loginField.getValue().equals(selected.getPassword())) {
            hidePass();
            Globals.user = selected;
            Globals.root.changeScreen(Globals.user);
          } else {
            loginInfo.setVisible(true);
            loginInfo.setValue("Wrong password");
            loginField.setValue("");
          }
        });

    loginBox = new HorizontalLayout();
    loginBox.addStyleName("popup-box");
    loginBox.addComponents(loginField, loginBut, loginInfo);
    loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_LEFT);
    loginBox.setComponentAlignment(loginBut, Alignment.MIDDLE_CENTER);
    loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_RIGHT);
    loginBox.setVisible(false);
    userIcon = new ThemeResource("icons/user.png");
    users = Globals.control.usersData();
    vbox = new VerticalLayout();
    // vbox.setSizeUndefined();
    vbox.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    Panel p = new Panel();
    p.setSizeFull();

    p.setContent(vbox);
    // vbox.addStyleName("border-l-r");
    this.addComponent(p, "left: 25%; right: 25%; top: 15px");
    this.addComponent(loginBox, "left: 25%; right: 25%; top: 40%");

    this.addLayoutClickListener(
        e -> {
          if (!loginBox.isVisible()) return;
          System.out.println(e.getClickedComponent());
          if (e.getClickedComponent() == null || e.getClickedComponent().equals(vbox)) hidePass();
        });
  }
Пример #6
0
  public LoginModule() {

    setMargin(true);
    setSpacing(true);
    grid.setSizeFull();
    grid.setSpacing(true);

    final TextField username = new TextField();
    username.setValue("username");
    username.setWidth("120px");
    username.setStyleName("small");
    grid.addComponent(username, 0, 0);

    final PasswordField password = new PasswordField();
    password.setValue("password");
    password.setWidth("120px");
    password.setStyleName("small");
    grid.addComponent(password, 0, 1);

    Button button = new Button("Login");
    button.setWidth("120px");
    button.setStyleName("small");
    button.addListener(
        new Button.ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            login.setUsername(username.getValue().toString());
            login.setPassword(password.getValue().toString());
            String user = login.getUsername();
            String pass = login.getPassword();
            // login.setResult(authLog.login(user, pass));
            boolean result = authLog.login(user, pass);
            if (result == true) {
              label.setCaption("Successfully Login");
            } else {
              label.setCaption("SQL Error");
            }
          }
        });
    grid.addComponent(button, 0, 2);
    panel.addComponent(grid);
    addComponent(panel);
    addComponent(label);
  }
  @Override
  public void buttonClick(ClickEvent event) {
    if (!userTextField.isValid() || !passwordField.isValid()) {
      return;
    }

    AuthenticationImpl auth = new AuthenticationImpl();
    boolean isValid = auth.authenticate(userTextField.getValue(), passwordField.getValue());

    if (isValid) {
      // set session parameters
      getSession().setAttribute("user", userTextField.getValue());

      // Navigate to main view
      getUI().getNavigator().navigateTo(SimpleLoginMainView.NAME);
    } else {
      passwordField.setValue(null);
      passwordField.focus();
    }
  }
Пример #8
0
  public LoginViewImpl() {
    setSizeFull();

    login.setIcon(FontAwesome.HAND_O_RIGHT);

    // TODO remove these prefilled values used for testing
    username.setValue("admin");
    password.setValue("password");
    password.focus();

    Panel loginPanel = new Panel("Login to application");
    loginPanel.setSizeUndefined();

    loginPanel.setContent(
        new MVerticalLayout(username, password, login).withAlign(login, Alignment.BOTTOM_RIGHT));

    setCompositionRoot(
        new MVerticalLayout(loginPanel)
            .withAlign(loginPanel, Alignment.MIDDLE_CENTER)
            .withFullHeight());
  }
  public SimpleLoginView() {
    setSizeFull();

    // Create the user input field
    userTextField = new TextField("User name: ");
    userTextField.setWidth("300px");
    userTextField.setRequired(true);
    userTextField.setInputPrompt("Your username (eg. user1)");
    userTextField.addValidator(new LoginValidator());
    userTextField.setInvalidAllowed(false);

    // Create the password input field
    passwordField = new PasswordField("Password:"******"300px");
    passwordField.setRequired(true);
    passwordField.addValidator(new PasswordValidator());
    passwordField.setValue("");
    passwordField.setNullRepresentation("");

    // Create login button
    loginButton = new Button("Login", this);

    // Add all to a panel
    VerticalLayout fields = new VerticalLayout(userTextField, passwordField, loginButton);
    fields.setCaption("Please login to access the application. (user1/password)");
    fields.setSpacing(true);
    fields.setMargin(new MarginInfo(true, true, true, false));
    fields.setSizeUndefined();

    // The view root layout
    VerticalLayout viewLayout = new VerticalLayout(fields);
    viewLayout.setSizeFull();
    viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER);
    viewLayout.setStyleName(Reindeer.LAYOUT_BLUE);
    setCompositionRoot(viewLayout);
  }
Пример #10
0
 private void hidePass() {
   loginBox.setVisible(false);
   loginInfo.setVisible(false);
   loginField.setValue("");
   vbox.removeStyleName("fuzzy");
 }