Exemple #1
0
 /**
  * Gets the list of the vnmrj users(operators) for the current unix user logged in
  *
  * @return the list of vnmrj users
  */
 protected Object[] getOperators() {
   String strUser = System.getProperty("user.name");
   User user = LoginService.getDefault().getUser(strUser);
   ArrayList<String> aListOperators = user.getOperators();
   if (aListOperators == null || aListOperators.isEmpty())
     aListOperators = new ArrayList<String>();
   Collections.sort(aListOperators);
   if (aListOperators.contains(strUser)) aListOperators.remove(strUser);
   aListOperators.add(0, strUser);
   return (aListOperators.toArray());
 }
Exemple #2
0
 void placeOrder(final User user, String cmd, Company comp, int qty, int id) {
   int cmdID = commID++;
   connect(user.getName(), user.getPassword());
   try {
     out.println(cmdID + ";" + cmd + ":" + comp.name + ":" + Integer.toString(qty) + ":" + id);
     out.flush();
     Shares pen = (Shares) receiveReply(cmdID);
     user.getPendingShares().add(pen);
     user.dataChanged();
   } catch (Exception r) {
     r.printStackTrace();
   }
 }
Exemple #3
0
 private void spend() {
   String amountStr =
       JOptionPane.showInputDialog(
           this, "Input an amount to spend:", "Spend", JOptionPane.QUESTION_MESSAGE);
   if (amountStr == null) {
     return;
   }
   String accountNumberStr =
       JOptionPane.showInputDialog(
           this,
           "To what account number? (blank is allowed)",
           "Spend",
           JOptionPane.QUESTION_MESSAGE);
   if (accountNumberStr == null) {
     return;
   }
   try {
     BigDecimal amount = FORMATTER.stringToValue(amountStr);
     Account target;
     if (accountNumberStr.isEmpty()) {
       target = null;
     } else {
       int accountNumber = new IntegerFormatter().stringToValue(accountNumberStr);
       target = null;
       for (User user : Bank.getInstance().getUsers()) {
         for (Account account : user.getAccounts()) {
           if (account.getAccountNumber() == accountNumber) {
             target = account;
           }
         }
       }
     }
     if (target != null
         && (target.getType().isLoan() && target.getBalance().negate().compareTo(amount) < 0)) {
       throw new InvalidInputException(
           accountNumberStr, "account does not exist or cannot accept this deposit");
     }
     account.withdraw(amount);
     if (target != null) {
       target.deposit(amount);
     }
     controller.updateBankDisplay();
   } catch (ParseException px) {
     controller.handleException(this, px);
   } catch (InvalidInputException iix) {
     controller.handleException(this, iix);
   } catch (InsufficientFundsException ifx) {
     controller.handleException(this, ifx);
   }
 }
  private void drawBalance(Graphics g)
        //  POST: Draws the balance of the current player
      {

    Font font; // Font used to draw balance
    String message; // Message for balance
    Color oldColor; // Sets for color
    int x1; // Upper-left x coordinate
    int y1; // Upper-left y coordinate
    int x2; // Bottom-right x coordinate
    int y2; // Bottom-right y coordinate
    int width; // Width of the dialogue box
    int height; // Height of the dialogue box
    int offset; // Offset so the dialogue box is positioned
    int balance; // Offset so the dialogue box is positioned
    User player; // User value for the player

    player = usersArray[0];

    balance = player.getBalance();
    oldColor = g.getColor();

    x1 = ScaledPoint.scalerToX(0.72);
    y1 = ScaledPoint.scalerToY(0.81);
    x2 = ScaledPoint.scalerToX(0.88);
    y2 = ScaledPoint.scalerToY(0.86);
    width = x2 - x1;
    height = y2 - y1;
    message = "Balance:";
    font = Drawing.getFont(message, width, height, FONTNAME, FONTSTYLE);
    offset = (width - getFontMetrics(font).stringWidth(message)) / 2;
    g.setColor(Color.WHITE);
    g.drawString(message, x1 + offset, y2);

    x1 = ScaledPoint.scalerToX(0.72);
    y1 = ScaledPoint.scalerToY(0.865);
    x2 = ScaledPoint.scalerToX(0.88);
    y2 = ScaledPoint.scalerToY(0.915);

    width = x2 - x1;
    height = y2 - y1;
    message = "$" + Integer.toString(balance);
    font = Drawing.getFont(message, width, height, FONTNAME, FONTSTYLE);
    offset = (width - getFontMetrics(font).stringWidth(message)) / 2;
    g.drawString(message, x1 + offset, y2);

    g.setColor(oldColor);
  }
  public void actionPerformed(ActionEvent evt) {
    // Get button clicked
    JButton buttonClicked = (JButton) evt.getSource();
    String actionCommand = new String(buttonClicked.getActionCommand());

    if (actionCommand.equals("Submit")) {
      System.out.println(clientUser.getLogon() + ": updating ticket...");

      // Recover ticket and update it
      Ticket ticketToUpdate = ticket;
      ticketToUpdate.setDesc(clientTicketDialog.getSummaryDescriptionField());
      ticketToUpdate.setResolution(clientTicketDialog.getResolutionDescriptionField());

      // Call checkInTicket() on the RMI object to update the ticket on the server
      try {
        ticketServerObject.checkInTicket(ticketToUpdate);
        // Refresh the activeTickets HashMap
        owner.getActiveTickets();
      } catch (RemoteException re) {
        System.out.println(re.getMessage());
      }

      // Close the ClientTicketDialog
      clientTicketDialog.setVisible(false);
      clientTicketDialog.dispose();
    }
  }
Exemple #6
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj.a1 = (ArrayList) ois.readObject();
    } catch (Exception e1) {
      System.out.print(e1);
    }
    int size = obj.a1.size();
    int f4 = 0;

    for (int i = 0; i < size; i++) {
      Bookinfo r2 = (Bookinfo) obj.a1.get(i);
      if (r2.bkisno.equals(obj.t3.getText()) && r2.title.equals(obj.t4.getText())) {
        JOptionPane.showMessageDialog(null, "ALREADYEXIT", "Welcome", JOptionPane.QUESTION_MESSAGE);
        f4 = 1;
      }
    }
    if (f4 == 0) {
      obj.a1.add(new Bookinfo(obj.t6.getText(), obj.t7.getText(), obj.t8.getText()));
      obj.t6.setText("");
      obj.t7.setText("");
      obj.t8.setText("");
    }
  }
Exemple #7
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj.a1 = (ArrayList) ois.readObject();

      String s1 = obj.t6.getText();
      String s2 = obj.t7.getText();

      int size = obj.a1.size();
      int f5 = 0;

      for (int i = 0; i < size; i++) {
        Bookinfo r2 = (Bookinfo) obj.a1.get(i);
        if (r2.bkisno.equals(s1) && r2.title.equals(s2)) {
          JOptionPane.showMessageDialog(
              null, "ALREADYEXIT", "Welcome", JOptionPane.QUESTION_MESSAGE);
          f5 = 1;
        }
      }

      if (f5 == 0) {
        JOptionPane.showMessageDialog(null, "ALREADYEXIT", "Welcome", JOptionPane.QUESTION_MESSAGE);
        ;
      }

      fin.close();
      ois.close();
    } catch (Exception e1) {
    }
  }
Exemple #8
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj.a1 = (ArrayList) ois.readObject();

      String s1 = obj.t1.getText();
      String s2 = obj.t2.getText();

      int size = obj.a1.size();
      int f1 = 0;

      for (int i = 0; i < size; i++) {
        info r = (info) obj.a1.get(i);
        if (r.uid.equals(s1) && r.pass.equals(s2)) {
          JOptionPane.showMessageDialog(null, "VALID", "Welcome", JOptionPane.QUESTION_MESSAGE);
          f1 = 1;
        }
      }

      if (f1 == 0) {
        JOptionPane.showMessageDialog(null, "ALREADYEXIT", "Welcome", JOptionPane.QUESTION_MESSAGE);
      }

      fin.close();
      ois.close();
    } catch (Exception e1) {
    }
  }
Exemple #9
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj1.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj1.a1 = (ArrayList) ois.readObject();

      String s3 = obj1.t3.getText();
      String s4 = obj1.t4.getText();
      String s5 = obj1.t5.getText();
      int size = obj1.a1.size();
      int f6 = 0;

      for (int i = 0; i < size; i++) {
        Stdinfo r2 = (Stdinfo) obj1.a1.get(i);
        if (r2.name.equals(s3) && r2.id.equals(s4) && r2.addr.equals(s5)) {
          JOptionPane.showMessageDialog(null, "FOUND", "Welcome", JOptionPane.QUESTION_MESSAGE);
          f6 = 1;
        }
      }

      if (f6 == 0) {
        JOptionPane.showMessageDialog(null, "NOT FOUND", "Welcome", JOptionPane.QUESTION_MESSAGE);
      }

      fin.close();
      ois.close();
    } catch (Exception e1) {
    }
  }
Exemple #10
0
  private void button3_updateActionPerformed(ActionEvent e) {
    String message = null;
    User temp = (User) list1.getSelectedValue();
    try {
      temp.name = textField1_name.getText();
      temp.emeil = textField2_emeil.getText();
      temp.telefon = Integer.valueOf(textField3_telefon.getText());
      message = "Успешно преобразован";
      textField1_name.setText("");
      textField2_emeil.setText("");
      textField3_telefon.setText("");

    } catch (NumberFormatException ex) {
      message = "Разберитесь с телефоном";
    } finally {
      JOptionPane.showMessageDialog(this, message);
    }
  }
  public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("Add User")) {
      jta.append("\n" + userId.getText());

      User user = new User(userId.getText());
    } else if (ae.getActionCommand().equals("Add Group")) {
      jta.append("\n" + groupId.getText());

      Group group = new Group(groupId.getText());
    } else if (ae.getActionCommand().equals("Open User View")) {
      try {
        if (!jta.getSelectedText().equals("null")) {
          userView.setVisible(true);
        }
      } catch (Exception e) {
        JOptionPane.showMessageDialog(
            frame, "Nothing selected", "Error", JOptionPane.ERROR_MESSAGE);
      }
    } else if (ae.getActionCommand().equals("Show User Total")) {
      JOptionPane.showMessageDialog(frame, User.getUserTotal());
    } else if (ae.getActionCommand().equals("Show Group Total")) {
      JOptionPane.showMessageDialog(frame, Group.getGroupTotal());
    } else if (ae.getActionCommand().equals("Show Messages Total")) {
      JOptionPane.showMessageDialog(frame, User.getMessageTotal());
    } else if (ae.getActionCommand().equals("Show Positive Percentage")) {
      String[] newsFeed = User.getNewsFeed();

      int positive = 0;
      int i = 0;
      while (!(newsFeed[i] == null)) {
        if (newsFeed[i].contains("good")
            || newsFeed[i].contains("great")
            || newsFeed[i].contains("excellent")) positive++;
        i++;
      }

      JOptionPane.showMessageDialog(frame, positive * 100.0 / i + "%");
    } else if (ae.getActionCommand().equals("Follow User")) {
      following.append("\n" + userId2.getText());
    } else if (ae.getActionCommand().equals("Post Tweet")) {
      User.postTweet(tweet.getText());
      newsFeed.append("\n" + jta.getSelectedText() + ": " + tweet.getText());
    }
  }
Exemple #12
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj.a1 = (ArrayList) ois.readObject();
    } catch (Exception e1) {
      System.out.print(e1);
    }

    obj.a1.add(new info(obj.t1.getText(), obj.t2.getText()));
    obj.t1.setText("");
    obj.t2.setText("");
  }
  public void updateTicketList() {
    User user = Application.getCurrentUser();

    TicketDAO dao = TicketDAO.getInstance();
    List<Ticket> openTickets;

    boolean showAllOpenTicket = false;
    if (user.getNewUserType() != null) {
      Set<UserPermission> permissions = user.getNewUserType().getPermissions();
      if (permissions != null) {
        for (UserPermission permission : permissions) {
          if (permission.equals(UserPermission.VIEW_ALL_OPEN_TICKET)) {
            showAllOpenTicket = true;
            break;
          }
        }
      }
    }

    if (showAllOpenTicket) {
      openTickets = dao.findOpenTickets();
    } else {
      openTickets = dao.findOpenTicketsForUser(user);
    }
    openTicketList.setTickets(openTickets);

    lblUserName.setText(
        POSConstants.WELCOME
            + " "
            + user.toString()
            + ". "
            + POSConstants.YOU
            + " "
            + POSConstants.HAVE
            + " "
            + openTickets.size()
            + " "
            + POSConstants.TICKETS);
  }
  public void buyItemFromUser(User buyer, User seller, Item currentItem)
        // PRE:  buyer, seller, currentItem must be initialized
        // POST: Purchases item from the store and has stores it into inventory.
      {

    int buyer_balance; // The new balance of the buyer
    int seller_balance; // The new balance of the seller
    String str; // First query
    String str2; // Second query
    String str3; // Third query

    buyer_balance = buyer.getBalance() - currentItem.getPrice();
    seller_balance = seller.getBalance() + currentItem.getPrice();

    if (buyer_balance > 0) // If the buyer wont go negative
    {
      str =
          String.format(
              "Update users set balance = (%d) where user_name = '%s'",
              buyer_balance, buyer.getUserName());

      str2 =
          String.format(
              "Update users set balance = (%d) where user_name = '%s'",
              seller_balance, seller.getUserName());

      str3 =
          String.format(
              "Update items set owner_id = (%d) where item_name = '%s'",
              buyer.getUserId(), currentItem.getItemName());

      updateTables(str, str2, str3);

    } else {
      // Prompt the user with an error
      JOptionPane.showMessageDialog(
          null, "You will go bankrupt if you try buying that, try selling some items.");
    }
  }
  private void doClockOut() {
    int option =
        JOptionPane.showOptionDialog(
            this,
            POSConstants.CONFIRM_CLOCK_OUT,
            POSConstants.CONFIRM,
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            null,
            null);
    if (option != JOptionPane.YES_OPTION) {
      return;
    }

    User user = Application.getCurrentUser();
    AttendenceHistoryDAO attendenceHistoryDAO = new AttendenceHistoryDAO();
    AttendenceHistory attendenceHistory = attendenceHistoryDAO.findHistoryByClockedInTime(user);
    if (attendenceHistory == null) {
      attendenceHistory = new AttendenceHistory();
      Date lastClockInTime = user.getLastClockInTime();
      Calendar c = Calendar.getInstance();
      c.setTime(lastClockInTime);
      attendenceHistory.setClockInTime(lastClockInTime);
      attendenceHistory.setClockInHour((short) c.get(Calendar.HOUR));
      attendenceHistory.setUser(user);
      attendenceHistory.setTerminal(Application.getInstance().getTerminal());
      attendenceHistory.setShift(user.getCurrentShift());
    }

    Shift shift = user.getCurrentShift();
    Calendar calendar = Calendar.getInstance();

    user.doClockOut(attendenceHistory, shift, calendar);

    Application.getInstance().logout();
  }
Exemple #16
0
  // Constructor receives the filename
  Rolodex(String filename) throws FileNotFoundException {
    File file = new File(filename);
    Scanner scanner = new Scanner(file);

    // Split the line with ~
    while (scanner.hasNext()) {
      tokens = scanner.nextLine().split("~");
      name = tokens[0];
      email = tokens[1];
      pictures = tokens[tokens.length - 1];

      User user = new User();
      user.setUserName(name);
      user.setUserEmail(email);
      user.setPicture(pictures);
      userList.add(user);
    }

    frame = new JFrame("Rolodex");
    frame.setSize(700, 200);

    // Menu
    JMenuBar jmb = new JMenuBar();
    JMenu jmFile = new JMenu("File");
    JMenuItem jmiOpen = new JMenuItem("Open");
    jmiOpen.setEnabled(false);
    JMenuItem jmiExit = new JMenuItem("Exit");
    jmiExit.setMnemonic(KeyEvent.VK_X);
    jmFile.add(jmiOpen);
    jmFile.addSeparator();
    jmFile.add(jmiExit);
    jmb.add(jmFile);

    jmiOpen.addActionListener(this);
    jmiExit.addActionListener(this);

    JMenu jmTabs = new JMenu("Tabs");
    jmTabs.setMnemonic(KeyEvent.VK_T);

    JMenu jmiplacement = new JMenu("Placement");
    JMenuItem jmitop = new JMenuItem("Top");
    JMenuItem jmiright = new JMenuItem("Right");
    JMenuItem jmibottom = new JMenuItem("Bottom");
    JMenuItem jmileft = new JMenuItem("Left");
    jmiplacement.add(jmitop);
    jmiplacement.add(jmiright);
    jmiplacement.add(jmibottom);
    jmiplacement.add(jmileft);

    jmitop.addActionListener(this);
    jmiright.addActionListener(this);
    jmibottom.addActionListener(this);
    jmileft.addActionListener(this);

    JMenu jmilayoutpolicy = new JMenu("Layout policy");
    JMenuItem jmiscroll = new JMenuItem("Scroll");
    JMenuItem jmiwrap = new JMenuItem("Wrap");
    jmilayoutpolicy.add(jmiscroll);
    jmilayoutpolicy.add(jmiwrap);

    jmiscroll.addActionListener(this);
    jmiwrap.addActionListener(this);

    JMenuItem jmidefaults = new JMenuItem("Defaults");
    jmidefaults.setMnemonic(KeyEvent.VK_D);
    jmidefaults.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK));
    jmidefaults.addActionListener(this);
    jmTabs.add(jmiplacement);
    jmTabs.add(jmilayoutpolicy);
    jmTabs.addSeparator();
    jmTabs.add(jmidefaults);
    jmb.add(jmTabs);

    JMenu jmHelp = new JMenu("Help");
    JMenuItem jmiabout = new JMenuItem("About");
    jmiabout.addActionListener(this);
    jmHelp.add(jmiabout);
    jmb.add(jmHelp);

    frame.setJMenuBar(jmb);

    jtp = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());

    for (User user : userList) {
      image = new ImageIcon(user.getPicture());
      panel = new JPanel();
      labname = new JLabel("Name: ");
      txtname = new JTextField(20);
      txtname.setText(user.getUserName());
      labemail = new JLabel("Email: ");
      txtemail = new JTextField(20);
      txtemail.setText(user.getUserEmail());
      l = new JLabel(image);
      l.setHorizontalAlignment(SwingConstants.LEFT);
      panel.add(l);
      panel.add(labname);
      panel.add(txtname);
      panel.add(labemail);
      panel.add(txtemail);
      jtp.addTab(user.getUserName(), panel);
      topPanel.add(jtp);
    }

    frame.add(jtp);
    center(frame);
    frame.setVisible(true);
  }
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Darya Koreneva
    scrollPane1 = new JScrollPane();
    userTable = new JTable();
    newUserNameLabel = new JLabel();
    newUserNameTextField = new JTextField();
    addButton = new JButton();
    cancelButton = new JButton();
    addUserButton = new JButton();
    deleteUserButton = new JButton();
    blockButton = new JButton();
    unblockButton = new JButton();

    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {0, 0, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights =
        new double[] {1.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 0.0, 1.0E-4};

    // ======== scrollPane1 ========
    {
      scrollPane1.setViewportView(userTable);
    }
    contentPane.add(
        scrollPane1,
        new GridBagConstraints(
            0,
            0,
            5,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    // ---- newUserNameLabel ----
    newUserNameLabel.setText("New user name:");
    newUserNameLabel.setVisible(false);
    newUserNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPane.add(
        newUserNameLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5),
            0,
            0));

    // ---- newUserNameTextField ----
    newUserNameTextField.setVisible(false);
    contentPane.add(
        newUserNameTextField,
        new GridBagConstraints(
            1,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5),
            0,
            0));

    // ---- addButton ----
    addButton.setText("Add");
    addButton.setVisible(false);
    contentPane.add(
        addButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5),
            0,
            0));

    // ---- cancelButton ----
    cancelButton.setText("Cancel");
    cancelButton.setVisible(false);
    contentPane.add(
        cancelButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    // ---- addUserButton ----
    addUserButton.setText("Add user");
    contentPane.add(
        addUserButton,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5),
            0,
            0));

    // ---- deleteUserButton ----
    deleteUserButton.setText("Delete user");
    contentPane.add(
        deleteUserButton,
        new GridBagConstraints(
            2,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5),
            0,
            0));

    // ---- blockButton ----
    blockButton.setText("Block");
    contentPane.add(
        blockButton,
        new GridBagConstraints(
            3,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5),
            0,
            0));

    // ---- unblockButton ----
    unblockButton.setText("Unblock");
    contentPane.add(
        unblockButton,
        new GridBagConstraints(
            4,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    setSize(560, 335);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents

    setData(sys.userMap);
    addUserButton.addActionListener(
        (v) -> {
          newUserNameLabel.setVisible(true);
          newUserNameTextField.setVisible(true);
          addButton.setVisible(true);
          cancelButton.setVisible(true);
        });
    addButton.addActionListener(
        (v) -> {
          String newUserName = newUserNameTextField.getText();
          sys.userMap.put(newUserName, new User(newUserName, ""));
          setData(sys.userMap);
          newUserNameLabel.setVisible(false);
          newUserNameTextField.setVisible(false);
          addButton.setVisible(false);
          cancelButton.setVisible(false);
        });
    cancelButton.addActionListener(
        (v) -> {
          newUserNameLabel.setVisible(false);
          newUserNameTextField.setVisible(false);
          addButton.setVisible(false);
          cancelButton.setVisible(false);
        });
    deleteUserButton.addActionListener(
        (v) -> {
          Object valueAt =
              userTable.getValueAt(userTable.getSelectedRow(), userTable.getSelectedColumn());
          sys.userMap.remove(valueAt);
          setData(sys.userMap);
        });
    blockButton.addActionListener(
        (v) -> {
          Object valueAt =
              userTable.getValueAt(userTable.getSelectedRow(), userTable.getSelectedColumn());
          User user = sys.getUserByName(valueAt.toString());
          user.setBlocked(true);
          setData(sys.userMap);
        });
    unblockButton.addActionListener(
        (v) -> {
          Object valueAt =
              userTable.getValueAt(userTable.getSelectedRow(), userTable.getSelectedColumn());
          User user = sys.getUserByName(valueAt.toString());
          user.setBlocked(false);
          setData(sys.userMap);
        });
  }
  public void updateView() {
    User user = Application.getCurrentUser();
    UserType userType = user.getNewUserType();
    if (userType != null) {
      Set<UserPermission> permissions = userType.getPermissions();
      if (permissions != null) {
        btnNewTicket.setEnabled(false);
        btnBackOffice.setEnabled(false);
        btnEditTicket.setEnabled(false);

        if (!"false".equalsIgnoreCase(AppConfig.getFeatureGroupTicketFlag())) {
          btnGroupSettle.setEnabled(false);
        }

        if (!"false".equalsIgnoreCase(AppConfig.getManagerMenuFlag())) {
          btnManager.setEnabled(false);
        }

        if (!"false".equalsIgnoreCase(AppConfig.getFeaturePenarikanFlag())) {
          btnPayout.setEnabled(false);
        }

        btnReopenTicket.setEnabled(false);
        btnSettleTicket.setEnabled(false);

        if (!"false".equalsIgnoreCase(AppConfig.getFeatureSplitTicketFlag())) {
          btnSplitTicket.setEnabled(false);
        }

        btnTakeout.setEnabled(false);
        btnVoidTicket.setEnabled(false);

        for (UserPermission permission : permissions) {
          if (permission.equals(UserPermission.VOID_TICKET)) {
            btnVoidTicket.setEnabled(true);
          } else if (permission.equals(UserPermission.PAY_OUT)) {
            if (!"false".equalsIgnoreCase(AppConfig.getFeaturePenarikanFlag())) {
              btnPayout.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.SETTLE_TICKET)) {
            btnSettleTicket.setEnabled(true);
            if (!"false".equalsIgnoreCase(AppConfig.getFeatureGroupTicketFlag())) {
              btnGroupSettle.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.REOPEN_TICKET)) {
            btnReopenTicket.setEnabled(true);
          } else if (permission.equals(UserPermission.PERFORM_MANAGER_TASK)) {
            if (!"false".equalsIgnoreCase(AppConfig.getManagerMenuFlag())) {
              btnManager.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.SPLIT_TICKET)) {
            if (!"false".equalsIgnoreCase(AppConfig.getFeatureSplitTicketFlag())) {
              btnSplitTicket.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.TAKE_OUT)) {
            btnTakeout.setEnabled(true);
          } else if (permission.equals(UserPermission.VIEW_BACK_OFFICE)) {
            btnBackOffice.setEnabled(true);
          }
          //                    else if (permission.equals(UserPermission.PAY_OUT)) {
          //                        btnPayout.setEnabled(true);
          //                    }
          else if (permission.equals(UserPermission.EDIT_TICKET)) {
            btnEditTicket.setEnabled(true);
          } else if (permission.equals(UserPermission.CREATE_NEW_TICKET)) {
            btnNewTicket.setEnabled(true);
          }
        }
      }
    }

    updateTicketList();
  }