2024-10-09 22:21:57 +03:00
|
|
|
package _VisualDVM.Repository.Subscribes.UI;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Utils.Utils_;
|
2024-10-15 15:13:57 +03:00
|
|
|
import Common.Visual.UI;
|
2024-10-08 22:33:49 +03:00
|
|
|
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.GlobalData.Account.AccountRole;
|
|
|
|
|
import _VisualDVM.Repository.Subscribes.Subscriber;
|
2024-10-22 16:44:13 +03:00
|
|
|
public class SubscriberDialog extends DBObjectDialog<Subscriber, SubscriberFields> {
|
|
|
|
|
public SubscriberDialog() {
|
2023-09-17 22:13:42 +03:00
|
|
|
super(SubscriberFields.class);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public int getDefaultHeight() {
|
|
|
|
|
return 250;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public int getDefaultWidth() {
|
|
|
|
|
return 450;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void validateFields() {
|
|
|
|
|
if (fields.tfName.getText().isEmpty())
|
|
|
|
|
Log.Writeln("Имя учётной записи не может быть пустым");
|
2024-10-11 00:00:30 +03:00
|
|
|
Utils_.validateEmail(fields.tfAddress.getText(), Log);
|
2023-09-17 22:13:42 +03:00
|
|
|
if (fields.tfAddress.getText().isEmpty())
|
|
|
|
|
Log.Writeln_("Адрес электронной почты не может быть пустым");
|
|
|
|
|
if (!title_text.equals("Регистрация") && (fields.tfAddress.isEditable() && Global.componentsServer.db.subscribers.Data.containsKey(fields.tfAddress.getText()))) {
|
2024-10-11 00:00:30 +03:00
|
|
|
Log.Writeln_("Адрес электронной почты " + Utils_.Brackets(fields.tfAddress.getText()) + " уже есть в списке.");
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void fillFields() {
|
|
|
|
|
fields.tfName.setText(Result.name);
|
|
|
|
|
fields.tfAddress.setText(Result.address);
|
2024-10-14 15:19:13 +03:00
|
|
|
fields.cbMail.setSelected(Result.mailOn != 0);
|
2024-10-15 15:13:57 +03:00
|
|
|
UI.TrySelect(fields.cbRole, Result.role);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void SetEditLimits() {
|
|
|
|
|
fields.tfAddress.setEditable(false);
|
|
|
|
|
}
|
|
|
|
|
private AccountRole getSelectedRole() {
|
|
|
|
|
return (AccountRole) fields.cbRole.getSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void ProcessResult() {
|
|
|
|
|
Result.name = fields.tfName.getText();
|
|
|
|
|
Result.address = fields.tfAddress.getText();
|
2024-10-14 15:19:13 +03:00
|
|
|
Result.mailOn = fields.cbMail.isSelected() ? 1 : 0;
|
2023-09-17 22:13:42 +03:00
|
|
|
Result.role = getSelectedRole();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|