рефакторинг форм таблиц и заполнения информации о столбцах
This commit is contained in:
@@ -2,6 +2,7 @@ package _VisualDVM.Repository.Subscribes.UI;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Common.Visual.Tables.ColumnInfo;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.Global;
|
||||
@@ -13,33 +14,51 @@ import javax.swing.*;
|
||||
public class SubsribersForm extends DataSetControlForm<Subscriber> {
|
||||
public SubsribersForm(DataSet<?, Subscriber> dataSource_in, JPanel mountPanel_in) {
|
||||
super(dataSource_in, mountPanel_in);
|
||||
AddColumns(
|
||||
new ColumnInfo<Subscriber>("Имя") {
|
||||
@Override
|
||||
public Object getFieldAt(Subscriber object) {
|
||||
return object.name;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Global.componentsServer.db.bugReports.getUI().getCurrent() != null;
|
||||
}
|
||||
},
|
||||
new ColumnInfo<Subscriber>("Роль") {
|
||||
@Override
|
||||
public Object getFieldAt(Subscriber object) {
|
||||
return object.role.getDescription();
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Global.mainModule.getAccount().role.equals(AccountRole.Admin);
|
||||
}
|
||||
},
|
||||
new ColumnInfo<Subscriber>("Рассылка") {
|
||||
@Override
|
||||
public Object getFieldAt(Subscriber object) {
|
||||
return (object.mailOn == 0) ? "выключена" : "включена";
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Global.mainModule.getAccount().role.equals(AccountRole.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
|
||||
protected void AdditionalInitColumns() {
|
||||
boolean admin = Global.mainModule.getAccount().role.equals(AccountRole.Admin);
|
||||
columns.get(0).setVisible(admin);
|
||||
columns.get(1).setVisible(Global.componentsServer.db.bugReports.getUI().getCurrent() != null);
|
||||
columns.get(3).setVisible(admin);
|
||||
columns.get(4).setVisible(admin);
|
||||
protected ColumnInfo<Subscriber> createPKColumn() {
|
||||
return new ColumnInfo<Subscriber>(dataSource.getPKName()) {
|
||||
@Override
|
||||
public Object getFieldAt(Subscriber object) {
|
||||
return object.getPK();
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Global.mainModule.getAccount().role.equals(AccountRole.Admin);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public DataMenuBar createMenuBar() {
|
||||
|
||||
Reference in New Issue
Block a user