예제 #1
0
 private void initInterface() {
   GUIFactory gui = new GUIFactory();
   searchButton = gui.createButton("search.png");
   searchButton.setActionCommand("search");
   searchButton.addActionListener(this);
   if (isAdmin) {
     nameField = new CaseLessCombo(Cache.getAdminUsersList(), 50, searchButton);
   } else {
     nameField = new CaseLessCombo(Cache.getOperativeUsersList(), 50, searchButton);
   }
   setInitMode();
   this.setVisible(true);
 }
예제 #2
0
  private boolean isValidUser() {
    if (target.length() == 0) {
      return false;
    }

    if (isAdmin) {
      if (Cache.isOperatorUser(target)) {
        JOptionPane.showMessageDialog(userDialog, "El usuario " + target + " es operativo. ");
        return false;
      }
      if (Cache.isAdminUser(target)) {
        switch (action) {
          case ToolsConstants.ADD:
            if (!nameField.eventFromCombo()) {
              JOptionPane.showMessageDialog(userDialog, "El usuario " + target + " ya existe. ");
            }
            return false;
        }
      } else {
        if (action != ToolsConstants.ADD) {
          JOptionPane.showMessageDialog(userDialog, "El usuario " + target + " no existe. ");
          return false;
        }
      }

    } else {
      if (Cache.isAdminUser(target)) {
        JOptionPane.showMessageDialog(userDialog, "El usuario " + target + " es administrativo. ");
        return false;
      }
      if (Cache.isOperatorUser(target)) {
        switch (action) {
          case ToolsConstants.ADD:
            if (!nameField.eventFromCombo()) {
              JOptionPane.showMessageDialog(userDialog, "El usuario " + target + " ya existe. ");
            }
            return false;
        }
      } else {
        if (action != ToolsConstants.ADD) {
          JOptionPane.showMessageDialog(userDialog, "El usuario " + target + " no existe. ");
          return false;
        }
      }
    }

    return true;
  }