2023-11-19 02:12:44 +03:00
|
|
|
|
package TestingSystem.Common.Test;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import Common.Current;
|
2023-11-17 00:04:21 +03:00
|
|
|
|
import Common.Database.iDBTable;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import Common.UI.DataSetControlForm;
|
|
|
|
|
|
import Common.UI.Windows.Dialog.DBObjectDialog;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import TestingSystem.Common.Test.UI.TestFields;
|
2023-11-17 00:04:21 +03:00
|
|
|
|
public class TestDBTable extends iDBTable<Test> {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public TestDBTable() {
|
2023-11-17 00:04:21 +03:00
|
|
|
|
super(Test.class);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getSingleDescription() {
|
|
|
|
|
|
return "тест DVM";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getPluralDescription() {
|
|
|
|
|
|
return "тесты";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected DataSetControlForm createUI() {
|
|
|
|
|
|
return new DataSetControlForm(this) {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void AdditionalInitColumns() {
|
2023-11-17 00:04:21 +03:00
|
|
|
|
//columns.get(0).setVisible(false);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public boolean hasCheckBox() {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Object getFieldAt(Test object, int columnIndex) {
|
|
|
|
|
|
switch (columnIndex) {
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
return object.description;
|
|
|
|
|
|
case 3:
|
2023-11-23 01:50:04 +03:00
|
|
|
|
return object.min_dim;
|
2023-11-23 01:17:36 +03:00
|
|
|
|
case 4:
|
2023-11-23 01:50:04 +03:00
|
|
|
|
return object.max_dim;
|
|
|
|
|
|
case 5:
|
2023-11-23 22:38:21 +03:00
|
|
|
|
return object.getFilesForTable();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
default:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String[] getUIColumnNames() {
|
|
|
|
|
|
return new String[]{
|
2023-11-23 01:50:04 +03:00
|
|
|
|
"имя",
|
|
|
|
|
|
"min_dim",
|
|
|
|
|
|
"max_dim",
|
|
|
|
|
|
"файлы"
|
|
|
|
|
|
};
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Current CurrentName() {
|
|
|
|
|
|
return Current.Test;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public DBObjectDialog<Test, TestFields> getDialog() {
|
|
|
|
|
|
return new DBObjectDialog<Test, TestFields>(TestFields.class) {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public int getDefaultHeight() {
|
|
|
|
|
|
return 200;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public int getDefaultWidth() {
|
|
|
|
|
|
return 400;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void validateFields() {
|
|
|
|
|
|
if (!edit) {
|
|
|
|
|
|
if (!Current.getGroup().language.equals(Current.getProject().languageName))
|
|
|
|
|
|
Log.Writeln_("В текущую группу могут войти только тесты на языке " + Current.getGroup().language);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void fillFields() {
|
|
|
|
|
|
fields.tfName.setText(Result.description);
|
2023-11-23 01:50:04 +03:00
|
|
|
|
fields.sMinDim.setValue(Result.min_dim);
|
|
|
|
|
|
fields.sMaxDim.setValue(Result.max_dim);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void ProcessResult() {
|
|
|
|
|
|
Result.description = fields.tfName.getText();
|
2023-11-23 01:50:04 +03:00
|
|
|
|
Result.min_dim = (int) fields.sMinDim.getValue();
|
|
|
|
|
|
Result.max_dim = (int) fields.sMaxDim.getValue();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
if (!edit) {
|
|
|
|
|
|
Result.sender_name = Current.getAccount().name;
|
|
|
|
|
|
Result.sender_address = Current.getAccount().email;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2023-12-31 17:36:20 +03:00
|
|
|
|
public boolean containsTestWithDescription(String description_in) {
|
|
|
|
|
|
for (Test test : Data.values()) {
|
|
|
|
|
|
if (test.description.equalsIgnoreCase(description_in))
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Test getTestByDescription(String description_in) {
|
|
|
|
|
|
for (Test test : Data.values()) {
|
|
|
|
|
|
if (test.description.equalsIgnoreCase(description_in))
|
|
|
|
|
|
return test;
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|