public void addUser(String userid) { Object[] row = createRow(userid); if (row == null) return; ml.addUser(userid); addRow(row); }
public void removeUser(String userid) { ml.removeUser(userid); for (int i = 0; i < getRowCount(); i++) { if (getUserIdAt(i).equals(userid)) { removeRow(i); return; } } }
public MLTableModel(CourseMailingList ml) { super(new String[] {"User ID", "User Name", "Mail"}, 0); this.ml = ml; ArrayList<String> userids = ml.getUserIdList(); for (String userid : userids) { Object[] row = createRow(userid); super.addRow(row); } }
public void sendReport() { int aws = JOptionPane.showConfirmDialog( null, "Do you want to send all users.\nPress YES: Send all users.\nPress NO: Send only selected users", "Sending Mail or Report Confirm", JOptionPane.YES_NO_CANCEL_OPTION); if (aws == JOptionPane.CANCEL_OPTION) return; boolean all = (aws == JOptionPane.OK_OPTION); CourseMailingList ml = getMLTableModel().ml; if (all) { ml.sendReport(null, null); } else { ArrayList<String> selectedUserIdList = getSelectedUserIdList(); if (selectedUserIdList.size() == 0) { JOptionPane.showMessageDialog(null, "You should select one user at least to send mail"); return; } ml.sendReport(selectedUserIdList, null); } JOptionPane.showMessageDialog(null, "Report sent"); }