Промежуточный. Рефактиринг фильтров
This commit is contained in:
@@ -2,7 +2,7 @@ package TestingSystem.Common.Group;
|
||||
import Common.Current;
|
||||
import Common.Database.*;
|
||||
import Common.UI.DataSetControlForm;
|
||||
import Common.UI.Menus_2023.VisualiserMenu;
|
||||
import Common.UI.Menus_2023.DataMenuBar;
|
||||
import Common.UI.UI;
|
||||
import Common.UI.Windows.Dialog.DBObjectDialog;
|
||||
import ProjectData.LanguageName;
|
||||
@@ -16,98 +16,35 @@ import java.util.Vector;
|
||||
//-
|
||||
public class GroupsDBTable extends iDBTable<Group> {
|
||||
public static boolean filterMyOnly = false;
|
||||
public Vector<DBObjectFilter<Group>> typeFilters;
|
||||
public Vector<DBObjectFilter<Group>> languageFilters;
|
||||
//------------------------------------------------>>>
|
||||
public GroupsDBTable() {
|
||||
super(Group.class);
|
||||
if (Current.hasUI()) {
|
||||
//--
|
||||
typeFilters = new Vector<>();
|
||||
languageFilters = new Vector<>();
|
||||
//--
|
||||
for (TestType type : TestType.values()) {
|
||||
typeFilters.add(
|
||||
new DBObjectFilter<Group>(this, type.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.type.equals(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
//--
|
||||
for (LanguageName languageName : LanguageName.values()) {
|
||||
languageFilters.add(new DBObjectFilter<Group>(this, languageName.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.language.equals(languageName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------>>>
|
||||
@Override
|
||||
public void mountUI(JPanel content_in) {
|
||||
super.mountUI(content_in);
|
||||
//---
|
||||
GroupsMenuBar menuBar = (GroupsMenuBar) UI.menuBars.get(getClass());
|
||||
menuBar.DropFilters();
|
||||
//----
|
||||
menuBar.addFilters(
|
||||
new VisualiserMenu("Тип", "/icons/Filter.png", true) {
|
||||
{
|
||||
for (DBObjectFilter filter : typeFilters)
|
||||
add(filter.menuItem);
|
||||
}
|
||||
},
|
||||
new VisualiserMenu("Язык", "/icons/Filter.png", true) {
|
||||
{
|
||||
for (DBObjectFilter filter : languageFilters)
|
||||
add(filter.menuItem);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
public void ResetFiltersCount() {
|
||||
for (DBObjectFilter filter : typeFilters)
|
||||
filter.ResetCount();
|
||||
for (DBObjectFilter filter : languageFilters)
|
||||
filter.ResetCount();
|
||||
}
|
||||
public void ShowFiltersCount() {
|
||||
for (DBObjectFilter filter : typeFilters)
|
||||
filter.ShowDescriptionAndCount();
|
||||
for (DBObjectFilter filter : languageFilters)
|
||||
filter.ShowDescriptionAndCount();
|
||||
}
|
||||
public boolean applyFilters(Group object) {
|
||||
boolean type = false;
|
||||
//возвращать сразу нельзя. иначе количество не посчитает.
|
||||
for (DBObjectFilter filter : typeFilters) {
|
||||
if (filter.Validate(object)) {
|
||||
type |= true;
|
||||
protected void createFilters() {
|
||||
filters.add(new DataSetFilter<Group>("Тип", this) {
|
||||
@Override
|
||||
public void fill() {
|
||||
for (TestType type : TestType.values())
|
||||
filters.add(new DBObjectFilter<Group>(dataSet, type.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.type.equals(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
boolean language = false;
|
||||
for (DBObjectFilter filter : languageFilters) {
|
||||
if (filter.Validate(object)) {
|
||||
language |= true;
|
||||
}
|
||||
}
|
||||
return type && language;
|
||||
}
|
||||
@Override
|
||||
public void ShowUI() {
|
||||
ResetFiltersCount();
|
||||
super.ShowUI();
|
||||
ShowFiltersCount();
|
||||
}
|
||||
@Override
|
||||
public void ShowUI(Object key) {
|
||||
ResetFiltersCount();
|
||||
super.ShowUI(key);
|
||||
ShowFiltersCount();
|
||||
});
|
||||
}
|
||||
/*
|
||||
for (LanguageName languageName : LanguageName.values()) {
|
||||
languageFilters.add(new DBObjectFilter<Group>(this, languageName.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.language.equals(languageName);
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "группа тестов";
|
||||
@@ -129,10 +66,6 @@ public class GroupsDBTable extends iDBTable<Group> {
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
//columns.get(0).setVisible(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user