окончательное разделение таблицы и функционала видимой ее формы
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package Common.Database.Tables;
|
||||
import Common.Current_;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.MainModule_;
|
||||
import Common.Passes.PassCode_;
|
||||
import Common.Utils.TextLog;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.UI;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
@@ -13,7 +10,6 @@ import javax.swing.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public String Name;
|
||||
public Class<K> k; //класс первичного ключа.
|
||||
@@ -46,22 +42,9 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public int getRowCountUI() {
|
||||
return ui.getRowCount();
|
||||
}
|
||||
public void SetCurrentObjectByUI(Object pk) {
|
||||
if (ui != null) {
|
||||
ui.ClearSelection(); //сброс текущего объекта и всего что с ним связано.
|
||||
ui.SetCurrentByPK(pk);
|
||||
}
|
||||
}
|
||||
protected DataSetControlForm createUI(JPanel mountPanel) {
|
||||
return null;
|
||||
}
|
||||
public void SelectAll(boolean flag) {
|
||||
for (D object : Data.values()) {
|
||||
if (getUI().isObjectVisible(object))
|
||||
object.Select(flag);
|
||||
}
|
||||
RefreshUI();
|
||||
}
|
||||
public D getFirstRecord() {
|
||||
return Data.values().stream().findFirst().orElse(null);
|
||||
}
|
||||
@@ -70,30 +53,31 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
res.sort(comparator);
|
||||
return res;
|
||||
}
|
||||
//todo все это тоже в уи?
|
||||
@SuppressWarnings("unchecked")
|
||||
public DBObjectDialog<D, ? extends DialogFields> getDialog() {
|
||||
return null;
|
||||
}
|
||||
public boolean ShowAddObjectDialog(DBObject object) {
|
||||
return getDialog().ShowDialog(getSingleDescription() + ": добавление", object);
|
||||
return getDialog().ShowDialog(getUI().getSingleDescription() + ": добавление", object);
|
||||
}
|
||||
public boolean ShowEditObjectDialog(DBObject object) {
|
||||
DBObjectDialog dialog = getDialog();
|
||||
dialog.edit = true;
|
||||
dialog.SetEditLimits();
|
||||
return dialog.ShowDialog(getSingleDescription() + ": редактирование", object);
|
||||
return dialog.ShowDialog(getUI().getSingleDescription() + ": редактирование", object);
|
||||
}
|
||||
public boolean ViewObject(DBObject object) {
|
||||
DBObjectDialog dialog = getDialog();
|
||||
dialog.SetReadonly();
|
||||
dialog.ShowDialog(getSingleDescription() + ": просмотр", object);
|
||||
dialog.ShowDialog(getUI().getSingleDescription() + ": просмотр", object);
|
||||
return false;
|
||||
}
|
||||
public boolean ShowDeleteObjectDialog(DBObject object) {
|
||||
return UI.Warning(getSingleDescription() + " " + object.getBDialogName() + " будет удален(а)");
|
||||
return UI.Warning(getUI().getSingleDescription() + " " + object.getBDialogName() + " будет удален(а)");
|
||||
}
|
||||
public boolean ShowDeleteObjectsDialog(int toDeleteCount) {
|
||||
return UI.Warning(getPluralDescription() + " в количестве " + toDeleteCount + " будут удалены)");
|
||||
return UI.Warning(getUI().getPluralDescription() + " в количестве " + toDeleteCount + " будут удалены)");
|
||||
}
|
||||
public String QName() {
|
||||
return "\"" + Name + "\"";
|
||||
@@ -101,12 +85,6 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public String getPKName() {
|
||||
return "";
|
||||
} //получить имя ключевого поля. нужно для таблиц.
|
||||
public String getPluralDescription() {
|
||||
return "";
|
||||
}
|
||||
public String getSingleDescription() {
|
||||
return "";
|
||||
}
|
||||
//-
|
||||
public void put(Object key, D object) {
|
||||
Data.put((K) key, object);
|
||||
@@ -123,17 +101,6 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public boolean containsKey(Object key) {
|
||||
return Data.containsKey(key);
|
||||
}
|
||||
//-
|
||||
public int getSelectedCount() {
|
||||
return (int) Data.values().stream().filter(d -> getUI().isObjectVisible(d) && d.isSelected()).count();
|
||||
}
|
||||
public Vector<D> getSelectedItems() {
|
||||
return Data.values().stream().filter(d -> getUI().isObjectVisible(d) && d.isSelected()).collect(Collectors.toCollection(Vector::new));
|
||||
}
|
||||
public Vector<K> getSelectedKeys() {
|
||||
return Data.values().stream().filter(DBObject::isSelected).map(d -> (K) d.getPK()).collect(Collectors.toCollection(Vector::new));
|
||||
}
|
||||
//--
|
||||
public void ShowUI() {
|
||||
if (ui != null) {
|
||||
ui.Show();
|
||||
@@ -144,53 +111,6 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
ui.Show(key);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------
|
||||
public Current_ CurrentName() {
|
||||
return null;
|
||||
}
|
||||
public boolean CheckCurrent(TextLog log) {
|
||||
return MainModule_.instance.Check(log, CurrentName());
|
||||
}
|
||||
public boolean CheckSelectedOrCurrent(TextLog log) {
|
||||
if ((getSelectedCount() == 0) && (CurrentName() == null || (getCurrent() == null))) {
|
||||
log.Writeln_(getPluralDescription() + ":");
|
||||
log.Writeln_("Отсутствуют отмеченные объекты, или текущий объект!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void dropCurrent() {
|
||||
MainModule_.instance.set(CurrentName(), null);
|
||||
}
|
||||
public D getCurrent() {
|
||||
return (D) MainModule_.instance.get(CurrentName());
|
||||
}
|
||||
public void setCurrent(D o) {
|
||||
MainModule_.instance.set(CurrentName(), o);
|
||||
}
|
||||
public Vector<D> getSelectedOrCurrent() {
|
||||
Vector<D> res = new Vector<>();
|
||||
if (getSelectedCount() > 0)
|
||||
res = getSelectedItems();
|
||||
else {
|
||||
if ((CurrentName() != null) && (getCurrent() != null)) {
|
||||
res.add(getCurrent());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public Vector<K> getSelectedOrCurrentKeys() {
|
||||
Vector<K> res = new Vector<>();
|
||||
if (getSelectedCount() > 0)
|
||||
res = getSelectedKeys();
|
||||
else {
|
||||
if ((CurrentName() != null) && (getCurrent() != null)) {
|
||||
res.add((K) getCurrent().getPK());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------
|
||||
public PassCode_ getDeletePassCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user