Ejemplo n.º 1
0
 /**
  * Check password filled if it is true then save the user data
  *
  * @return true if the data is saved successfully, false if password is entered and it does not
  *     match.
  */
 private boolean save() {
   char[] pchars = password.getPassword();
   String pword = "";
   if (pchars.length > 0) {
     pword = MD5.computeDigest(pchars);
     Arrays.fill(pchars, '\u0000');
     char[] cchars = confirmPassword.getPassword();
     String cword = MD5.computeDigest(cchars);
     Arrays.fill(cchars, '\u0000');
     if (!pword.equals(cword)) {
       Toolkit.getDefaultToolkit().beep();
       JOptionPane.showMessageDialog(
           this,
           "Password must match Confirm Password." + "\nPlease re-enter.",
           "Password Error",
           JOptionPane.ERROR_MESSAGE);
       return false;
     }
   }
   final ClientTask task;
   int teamsId = teamsModel.getSelectedId();
   if (teamsId < 0) {
     teamsId = 0;
   }
   usersData = new UsersData();
   usersData.users_id = usersId;
   usersData.teams_id = teamsId;
   usersData.user_name = userName.getText();
   usersData.first_name = fname.getText();
   usersData.last_name = lname.getText();
   usersData.unitize = unitizeCheckBox.isSelected() ? "Yes" : "No";
   usersData.uqc = uqcCheckBox.isSelected() ? "Yes" : "No";
   usersData.coding = codingCheckBox.isSelected() ? "Yes" : "No";
   usersData.codingqc = codingqcCheckBox.isSelected() ? "Yes" : "No";
   usersData.qa = qaCheckBox.isSelected() ? "Yes" : "No";
   usersData.listing = listingCheckBox.isSelected() ? "Yes" : "No";
   usersData.tally = tallyCheckBox.isSelected() ? "Yes" : "No";
   usersData.teamLeader = tlCheckBox.isSelected() ? "Yes" : "No";
   usersData.admin = adminCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminUsers = adminUsersCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminProject = adminProjectCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminBatch = adminBatchCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminEdit = adminEditCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminImport = adminImportCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminExport = adminExportCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminProfit = adminProfitCheckBox.isSelected() ? "Yes" : "No";
   usersData.password = pword;
   usersData.dateOfJoin = field.getText();
   task = new TaskSendUsersData(usersData);
   task.enqueue(this);
   return true;
 }
Ejemplo n.º 2
0
  /**
   * Load the user's data.
   *
   * @param queryResult - ResultSet returned by ClientTask in loadUsersDataEntry
   */
  private void getUserByIdDataEntry(ResultSet queryResult) {
    try {
      if (queryResult.next()) {
        // updating a user
        userName.setText(queryResult.getString(2));
        fname.setText(queryResult.getString(4));
        lname.setText(queryResult.getString(3));
        unitizeCheckBox.setSelected((queryResult.getString(5).equals("Yes") ? true : false));
        uqcCheckBox.setSelected((queryResult.getString(6).equals("Yes") ? true : false));
        codingCheckBox.setSelected((queryResult.getString(7).equals("Yes") ? true : false));
        codingqcCheckBox.setSelected((queryResult.getString(8).equals("Yes") ? true : false));
        listingCheckBox.setSelected(
            ((queryResult.getString(9) == null || queryResult.getString(9).equals("Yes"))
                ? true
                : false));
        tallyCheckBox.setSelected(
            ((queryResult.getString(10) == null || queryResult.getString(10).equals("Yes"))
                ? true
                : false));
        qaCheckBox.setSelected((queryResult.getString(11).equals("Yes") ? true : false));
        tlCheckBox.setSelected((queryResult.getString(12).equals("Yes") ? true : false));
        adminCheckBox.setSelected((queryResult.getString(13).equals("Yes") ? true : false));
        adminUsersCheckBox.setSelected((queryResult.getString(14).equals("Yes") ? true : false));
        adminProjectCheckBox.setSelected((queryResult.getString(15).equals("Yes") ? true : false));
        adminBatchCheckBox.setSelected((queryResult.getString(16).equals("Yes") ? true : false));
        adminEditCheckBox.setSelected((queryResult.getString(17).equals("Yes") ? true : false));
        adminImportCheckBox.setSelected((queryResult.getString(18).equals("Yes") ? true : false));
        adminExportCheckBox.setSelected((queryResult.getString(19).equals("Yes") ? true : false));
        adminProfitCheckBox.setSelected((queryResult.getString(20).equals("Yes") ? true : false));
        teamsCombo.setSelectedIndex(teamsModel.indexOf(queryResult.getInt(1)));
        password.setText("");
        confirmPassword.setText("");
        String date = queryResult.getString(21);

        if (null != date) {
          String[] splitDate = date.split(" ");
          field.setText(splitDate[0]);
        }

        enableAdminPriv();
      }
    } catch (SQLException e) {
      Log.quit(e);
    }
  }
Ejemplo n.º 3
0
 /**
  * Overrides PlainDocument.replace, to suppress separate change operations on delete and insert.
  * This avoids temporarily seeing an invalid field when setText is called, thus possibly losing
  * a button press.
  */
 public void replace(int offset, int length, String text, AttributeSet attrs)
     throws BadLocationException {
   isReplacing = true;
   String oldText = LTextField.this.getText();
   super.replace(offset, length, text, attrs);
   isReplacing = false;
   setChanged(true);
   firePropertyChange("text", oldText, LTextField.super.getText());
 }
Ejemplo n.º 4
0
 public void remove(int offs, int len) throws BadLocationException {
   String oldText = LTextField.this.getText();
   super.remove(offs, len);
   SplitPaneViewer.clearViewerStatus(LTextField.this);
   // Log.print("setChanged from remove true");
   if (!isReplacing) {
     setChanged(true);
     firePropertyChange("text", oldText, LTextField.super.getText());
   }
 }
Ejemplo n.º 5
0
 /**
  * For L1 verification dialog
  *
  * @param evt
  * @return
  */
 private int doVerify(KeyEvent evt) {
   Object getComponent = evt.getSource();
   LTextField field = (LTextField) getComponent;
   boolean checkIsEnabled = field.isEditable();
   System.out.println("LTextField==========" + checkIsEnabled);
   ShowVerifyDialog verifyDialog = null;
   if (codingData == null) {
     if (checkIsEnabled) {
       verifyDialog =
           new ShowVerifyDialog(
               this,
               getText(),
               codingData_F6.valueMap,
               fieldName,
               codingData_F6.childId,
               whichStatus,
               "LTextField");
       verifyDialog.setLocationRelativeTo(this);
       verifyDialog.setModal(true);
       verifyDialog.show();
     }
     // verifyDialog = new ShowVerifyDialog(this, getText(), codingData_F6.valueMap, fieldName,
     // codingData_F6.childId, whichStatus, "LTextField");
   } else {
     if (checkIsEnabled) {
       verifyDialog =
           new ShowVerifyDialog(
               this,
               getText(),
               codingData.valueMap,
               fieldName,
               codingData.childId,
               whichStatus,
               "LTextField");
       verifyDialog.setLocationRelativeTo(this);
       verifyDialog.setModal(true);
       verifyDialog.show();
     }
   }
   return 0;
 }
Ejemplo n.º 6
0
 public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
   String checkedString = checkText(str, offs);
   if (checkedString == null
       || (this.getLength() + checkedString.length() > getColumns()
           && getColumns() > 0) // && userEntered
   ) {
     // Refuse the insertion and beep to notify user
     Toolkit.getDefaultToolkit().beep();
     Log.print("BEEP> LTextField: insertString(" + offs + ",'" + str + "') " + this.getLength());
   } else {
     String oldText = LTextField.this.getText();
     super.insertString(offs, checkedString, a);
     // Log.print("(LTextField) changed");
     if (!isReplacing) {
       setChanged(true);
       firePropertyChange("text", oldText, LTextField.super.getText());
     }
   }
 }
Ejemplo n.º 7
0
  /** Add ui controls */
  private void addControls() {
    unitizeCheckBox = new JCheckBox("Unitize");
    unitizeCheckBox.addActionListener(buttonComboListener);
    uqcCheckBox = new JCheckBox("Unitize QC");
    uqcCheckBox.addActionListener(buttonComboListener);
    codingCheckBox = new JCheckBox("Coding");
    codingCheckBox.addActionListener(buttonComboListener);
    codingqcCheckBox = new JCheckBox("Coding QC");
    codingqcCheckBox.addActionListener(buttonComboListener);
    qaCheckBox = new JCheckBox("QA");
    qaCheckBox.addActionListener(buttonComboListener);
    listingCheckBox = new JCheckBox("Listing");
    listingCheckBox.addActionListener(buttonComboListener);
    tallyCheckBox = new JCheckBox("Tally");
    tallyCheckBox.addActionListener(buttonComboListener);
    tlCheckBox = new JCheckBox("Team Leader");
    tlCheckBox.addActionListener(buttonComboListener);
    adminCheckBox = new JCheckBox("Admin");
    adminCheckBox.addActionListener(buttonComboListener);
    teamsCombo.addActionListener(buttonComboListener);

    adminUsersCheckBox = new JCheckBox("Users");
    adminUsersCheckBox.addActionListener(buttonComboListener);
    adminProjectCheckBox = new JCheckBox("Project");
    adminProjectCheckBox.addActionListener(buttonComboListener);
    adminBatchCheckBox = new JCheckBox("Batch");
    adminBatchCheckBox.addActionListener(buttonComboListener);
    adminEditCheckBox = new JCheckBox("Global Edit");
    adminEditCheckBox.addActionListener(buttonComboListener);
    adminImportCheckBox = new JCheckBox("Import");
    adminImportCheckBox.addActionListener(buttonComboListener);
    adminExportCheckBox = new JCheckBox("Export");
    adminExportCheckBox.addActionListener(buttonComboListener);
    adminProfitCheckBox = new JCheckBox("Profit");
    adminProfitCheckBox.addActionListener(buttonComboListener);

    userName = new LTextField(40);
    fname = new LTextField(40);
    lname = new LTextField(40);
    team = new LTextField(40);
    userName.setDocument(getUpperPlainDocument());
    userName.setToolTipText("User Id may contain only letters and digits.");
    fname.setDocument(getPlainDocument());
    lname.setDocument(getPlainDocument());

    JLabel seperator_lbl_1 = new JLabel("    ");
    JLabel seperator_lbl_2 = new JLabel("    ");
    JLabel seperator_lbl_3 = new JLabel("    ");

    password = new JPasswordField(32);
    confirmPassword = new JPasswordField(32);
    password.setDocument(getPlainDocument());
    confirmPassword.setDocument(getPlainDocument());

    dateField.getComponent(1).setMaximumSize(new Dimension(50, 20));
    field = (JTextField) dateField.getComponent(0);
    field.setColumns(10);
    dateField.addPropertyChangeListener(
        new java.beans.PropertyChangeListener() {

          public void propertyChange(java.beans.PropertyChangeEvent evt) {
            // dateFieldPropertyChange(evt);
          }
        });

    // internal_volume_namePanel.add(dateField);

    rolePane.add(unitizeCheckBox);
    rolePane.add(uqcCheckBox);
    rolePane.add(codingCheckBox);
    rolePane.add(codingqcCheckBox);
    rolePane.add(listingCheckBox);
    rolePane.add(tallyCheckBox);
    rolePane.add(qaCheckBox);
    rolePane.add(tlCheckBox);
    rolePane.add(adminCheckBox);

    namePane.add(0, 0, "User Id:", userName);
    namePane.add(0, 1, "", new Label());
    namePane.add(0, 2, "First Name:", fname);
    namePane.add(0, 3, "", new Label());
    namePane.add(0, 4, "Last Name:", lname);
    namePane.add(0, 5, "", new Label());
    namePane.add(0, 6, "Join Date:", dateField);
    namePane.add(0, 7, "Roles:", rolePane);
    namePane.add(0, 8, "Admin:", adminPrivPane);
    namePane.add(0, 9, "Team:", teamsCombo);
    namePane.add(0, 10, "", seperator_lbl_1);
    namePane.add(0, 11, "Password:"******"", seperator_lbl_2);
    namePane.add(0, 13, "Confirm Password:"******"", seperator_lbl_3);

    adminPrivPane.add(adminUsersCheckBox);
    adminPrivPane.add(adminProjectCheckBox);
    adminPrivPane.add(adminBatchCheckBox);
    adminPrivPane.add(adminEditCheckBox);
    adminPrivPane.add(adminImportCheckBox);
    adminPrivPane.add(adminExportCheckBox);
    adminPrivPane.add(adminProfitCheckBox);

    selectPanel.add(namePane, BorderLayout.CENTER);
    pack();
  }