2025-02-19 22:47:56 +03:00
|
|
|
|
package _VisualDVM.ComponentsServer.Recipient;
|
|
|
|
|
|
import Common.Database.Tables.DataSet;
|
|
|
|
|
|
import Common.Utils.Utils_;
|
|
|
|
|
|
import Common.Visual.DataSetControlForm;
|
2025-02-20 00:39:59 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.Recipient.Json.UserAccountJson;
|
|
|
|
|
|
import _VisualDVM.ComponentsServer.Recipient.Json.UserAccountsJson;
|
2025-02-19 22:47:56 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.Recipient.UI.RecipientsForm;
|
2025-02-20 14:13:13 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
2025-02-20 00:39:59 +03:00
|
|
|
|
import _VisualDVM.Constants;
|
2025-02-19 22:47:56 +03:00
|
|
|
|
import _VisualDVM.Global;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
2025-02-20 00:39:59 +03:00
|
|
|
|
import java.util.Vector;
|
2025-02-19 22:47:56 +03:00
|
|
|
|
public class RecipientsDataSet extends DataSet<String, Recipient> {
|
|
|
|
|
|
public RecipientsDataSet() {
|
|
|
|
|
|
super(String.class, Recipient.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Unpack(String packed){
|
|
|
|
|
|
clear();
|
2025-02-20 00:39:59 +03:00
|
|
|
|
UserAccountsJson jsons = Utils_.gson.fromJson(packed, UserAccountsJson.class);
|
|
|
|
|
|
for (UserAccountJson userAccountJson: jsons.values){
|
|
|
|
|
|
Global.componentsServer.db.recipients.put(userAccountJson.email, new Recipient(userAccountJson));
|
2025-02-19 22:47:56 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected DataSetControlForm createUI(JPanel mountPanel) {
|
|
|
|
|
|
return new RecipientsForm(this,mountPanel);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getPluralDescription() {
|
|
|
|
|
|
return "адресаты";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getSingleDescription() {
|
|
|
|
|
|
return "адресат";
|
|
|
|
|
|
}
|
2025-02-20 00:39:59 +03:00
|
|
|
|
public Vector<String> getSelectedMails(){
|
|
|
|
|
|
//баг текущий. значит адресаты уже активные и правильные. дополняем их админами и автором.
|
|
|
|
|
|
Vector<String> res = new Vector<>();
|
|
|
|
|
|
for (Recipient recipient:Data.values()){
|
|
|
|
|
|
if (recipient.isSelected()&& !res.contains(recipient.email))
|
|
|
|
|
|
res.add(recipient.email);
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
if (!res.contains(Global.mainModule.getAccount().email))
|
|
|
|
|
|
res.add(Global.mainModule.getAccount().email);
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (String admin_mail : Constants.admins_mails) {
|
|
|
|
|
|
if (!res.contains(admin_mail))
|
|
|
|
|
|
res.add(admin_mail);
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
2025-02-19 22:47:56 +03:00
|
|
|
|
}
|