Esempio n. 1
0
  /**
   * Update members.
   *
   * @return true, if successful
   */
  private boolean updateMembers() {
    boolean cansync = true;
    name.removeStyleName(errorfieldstyle);
    if (editlogin != null) {
      login.removeStyleName(errorfieldstyle);
    }
    password.removeStyleName(errorfieldstyle);

    String sometext = name.getText().trim();
    if (sometext.isEmpty()) {
      cansync = false;
      name.addStyleName(errorfieldstyle);
    }

    user.setUsername(sometext);
    if (editlogin == null) {
      sometext = login.getText().trim();
      if (sometext.isEmpty()) {
        cansync = false;
        login.addStyleName(errorfieldstyle);
      }
      user.setLogin(sometext);
    }

    sometext = password.getText();
    if ((editlogin == null) && sometext.isEmpty()) {
      cansync = false;
      password.addStyleName(errorfieldstyle);
    }

    user.setPassword(sometext);
    user.setActive(isactive.getValue());
    UserRole role = new UserRole();
    if (isadmin.getValue()) {
      role.setAdmin();
    }

    if (isdocuments.getValue()) {
      role.setDocuments();
    }

    if (isfinances.getValue()) {
      role.setFinances();
    }

    if (ismanager.getValue()) {
      role.setManager();
    }
    user.setUserrole(role);

    return cansync;
  }
Esempio n. 2
0
  /**
   * Gets the user.
   *
   * @return the user
   */
  private void getUser() {
    user = null;
    if (editlogin == null) {
      user = new User();
      user.initAsDefault();
      createGUI();
    } else {
      UserRole role = Ballance_autosauler_net.sessionId.getUserrole();
      if (role.isAdmin()) {
        MainPanel.setCommInfo(true);

        Services.users.getUser(
            editlogin,
            new AsyncCallback<User>() {

              @Override
              public void onFailure(Throwable caught) {
                MainPanel.setCommInfo(false);
                new AlertDialog(caught).show();
              }

              @Override
              public void onSuccess(User result) {
                user = result;
                EditUserDialog.this.createGUI();

                MainPanel.setCommInfo(false);
              }
            });
      }
    }
  }
Esempio n. 3
0
  /** Creates the gui. */
  private void createGUI() {

    if (editlogin == null) {
      setText(M.users.menuAddUser());
    } else {
      setText(M.users.titleEditUser());
    }
    setAnimationEnabled(true);
    setGlassEnabled(true);

    String addText = M.users.btnAdd();
    if (editlogin != null) {
      addText = M.users.btnUpdate();
    }
    Button btnAdd = new Button(addText);

    btnAdd.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            if (editlogin == null) {
              createUser();
            } else {
              updateUser();
            }
          }
        });

    Button btnCancel = new Button(M.users.btnCancel());
    btnCancel.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            EditUserDialog.this.hide();
          }
        });

    VerticalPanel vpanel = new VerticalPanel();
    // vpanel.setWidth("400px");

    FlexTable layout = new FlexTable();
    layout.setCellSpacing(6);

    layout.setHTML(0, 0, M.users.fullName());
    name = new TextBox();
    name.setText(user.getUsername());
    layout.setWidget(0, 1, name);

    layout.setHTML(1, 0, M.users.login());
    login = new TextBox();
    login.setText(user.getLogin());
    if (editlogin != null) {
      login.setReadOnly(true);
    }
    layout.setWidget(1, 1, login);

    layout.setHTML(2, 0, M.users.password());
    password = new TextBox();
    password.setText("");
    layout.setWidget(2, 1, password);

    layout.setHTML(3, 0, M.users.isactive());
    isactive = new CheckBox();
    isactive.setValue(user.isActive());
    layout.setWidget(3, 1, isactive);

    layout.setHTML(4, 0, M.users.access());

    UserRole role = user.getUserrole();

    FlexTable access = new FlexTable();
    access.setCellSpacing(6);

    access.setHTML(0, 0, M.users.isadmin());
    isadmin = new CheckBox();
    isadmin.setValue(role.isAdmin());
    access.setWidget(0, 1, isadmin);

    access.setHTML(1, 0, M.users.isdocuments());
    isdocuments = new CheckBox();
    isdocuments.setValue(role.isDocuments());
    access.setWidget(1, 1, isdocuments);

    access.setHTML(2, 0, M.users.isfinances());
    isfinances = new CheckBox();
    isfinances.setValue(role.isFinances());
    access.setWidget(2, 1, isfinances);

    access.setHTML(3, 0, M.users.ismanager());
    ismanager = new CheckBox();
    ismanager.setValue(role.isManager());
    access.setWidget(3, 1, ismanager);

    layout.setWidget(4, 1, access);

    vpanel.add(layout);

    HorizontalPanel buttons = new HorizontalPanel();
    buttons.setWidth("100%");
    buttons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    HorizontalPanel bcontainer = new HorizontalPanel();
    bcontainer.add(btnAdd);
    bcontainer.add(btnCancel);
    bcontainer.setSpacing(5);
    buttons.add(bcontainer);

    vpanel.add(buttons);

    setWidget(vpanel);
    /*
     * setPopupPosition( (Ballance_autosauler_net.mainpanel.getOffsetWidth()
     * / 2 - 200), 100);
     */
    show();
  }