56 lines
2.1 KiB
Java
56 lines
2.1 KiB
Java
package _VisualDVM.ComponentsServer.Recipient;
|
||
import Common.Database.Tables.DataSet;
|
||
import Common.Utils.Utils_;
|
||
import Common.Visual.DataSetControlForm;
|
||
import _VisualDVM.ComponentsServer.Recipient.Json.UserAccountJson;
|
||
import _VisualDVM.ComponentsServer.Recipient.Json.UserAccountsJson;
|
||
import _VisualDVM.ComponentsServer.Recipient.UI.RecipientsForm;
|
||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||
import _VisualDVM.Constants;
|
||
import _VisualDVM.Global;
|
||
|
||
import javax.swing.*;
|
||
import java.util.Vector;
|
||
public class RecipientsDataSet extends DataSet<String, Recipient> {
|
||
public RecipientsDataSet() {
|
||
super(String.class, Recipient.class);
|
||
}
|
||
public void Unpack(String packed){
|
||
clear();
|
||
UserAccountsJson jsons = Utils_.gson.fromJson(packed, UserAccountsJson.class);
|
||
for (UserAccountJson userAccountJson: jsons.values){
|
||
Global.componentsServer.db.recipients.put(userAccountJson.email, new Recipient(userAccountJson));
|
||
}
|
||
}
|
||
@Override
|
||
protected DataSetControlForm createUI(JPanel mountPanel) {
|
||
return new RecipientsForm(this,mountPanel);
|
||
}
|
||
@Override
|
||
public String getPluralDescription() {
|
||
return "адресаты";
|
||
}
|
||
@Override
|
||
public String getSingleDescription() {
|
||
return "адресат";
|
||
}
|
||
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;
|
||
}
|
||
}
|