2023-11-19 02:12:44 +03:00
|
|
|
package Repository.Subscribes;
|
2023-09-17 22:13:42 +03:00
|
|
|
import Common.Current;
|
2023-12-05 16:15:12 +03:00
|
|
|
import Common.Database.*;
|
2023-09-17 22:13:42 +03:00
|
|
|
import Common.UI.DataSetControlForm;
|
|
|
|
|
import Common.UI.Windows.Dialog.DBObjectDialog;
|
|
|
|
|
import GlobalData.Account.AccountRole;
|
2023-12-05 16:15:12 +03:00
|
|
|
import Repository.SubscriberWorkspace.SubscriberWorkspace;
|
2023-11-19 02:12:44 +03:00
|
|
|
import Repository.Subscribes.UI.SubscriberFields;
|
|
|
|
|
import Repository.Subscribes.UI.SubscriberForm;
|
2023-12-05 16:15:12 +03:00
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
2023-09-17 22:13:42 +03:00
|
|
|
public class SubsribersDBTable extends DBTable<String, Subscriber> {
|
|
|
|
|
public SubsribersDBTable() {
|
|
|
|
|
super(String.class, Subscriber.class);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getSingleDescription() {
|
|
|
|
|
return "Адресат";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected DataSetControlForm createUI() {
|
|
|
|
|
return new DataSetControlForm(this) {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean hasCheckBox() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void AdditionalInitColumns() {
|
|
|
|
|
boolean admin = Current.getAccount().role.equals(AccountRole.Admin);
|
|
|
|
|
columns.get(0).setVisible(admin);
|
|
|
|
|
columns.get(1).setVisible(Current.getBugReport() != null);
|
|
|
|
|
columns.get(3).setVisible(admin);
|
|
|
|
|
columns.get(4).setVisible(admin);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String[] getUIColumnNames() {
|
|
|
|
|
return new String[]{"Имя", "Роль", "Рассылка"};
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Object getFieldAt(Subscriber object, int columnIndex) {
|
|
|
|
|
switch (columnIndex) {
|
|
|
|
|
case 2:
|
|
|
|
|
return object.name;
|
|
|
|
|
case 3:
|
|
|
|
|
return object.role.getDescription();
|
|
|
|
|
case 4:
|
|
|
|
|
return (object.mailOn==0)?"выключена":"включена";
|
|
|
|
|
}
|
|
|
|
|
return object.name;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Current CurrentName() {
|
|
|
|
|
return Current.Subscriber;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public DBObjectDialog<Subscriber, SubscriberFields> getDialog() {
|
|
|
|
|
return new SubscriberForm();
|
|
|
|
|
}
|
2023-12-05 16:15:12 +03:00
|
|
|
@Override
|
|
|
|
|
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
|
|
|
|
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
|
|
|
|
//-
|
|
|
|
|
res.put(SubscriberWorkspace.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|