продолжение рефакторинга таблиц. перевод меню баров в интерфейс
This commit is contained in:
@@ -7,6 +7,7 @@ import Common.Database.Tables.DataSet;
|
||||
import Common.Database.Tables.FKBehaviour;
|
||||
import Common.MainModule_;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Common.Visual.Menus.TableMenu;
|
||||
import Common.Visual.Tables.ColumnInfo;
|
||||
import Common.Visual.Tables.DBObjectSelectionRenderer;
|
||||
@@ -26,15 +27,35 @@ import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
public class DataSetControlForm extends ControlForm<DataTable> {
|
||||
|
||||
protected DataSet dataSource;
|
||||
protected int current_row_i;
|
||||
protected DataSet dataSource; //источник данных
|
||||
protected DataMenuBar bar = null; //верхняя панель меню
|
||||
protected int current_row_i; //индекс текущей строки.
|
||||
protected boolean events_on = true;
|
||||
protected String colNamesAndSizes = "";
|
||||
protected Vector<ColumnInfo> columns = new Vector<>();
|
||||
protected Vector<ColumnInfo> columns = new Vector<>(); //информация о столбцах и их оформлении
|
||||
FilterInterface f_ui; // отображение количества объектов ( todo слить с баром ?)
|
||||
public DataSetControlForm(DataSet dataSource_in, JPanel mountPanel_in) {
|
||||
super(DataTable.class, mountPanel_in);
|
||||
dataSource = dataSource_in;
|
||||
//--
|
||||
if (hasMenuBar()) {
|
||||
try {
|
||||
if (!MainModule_.instance.getUI().menuBars.containsKey(dataSource.getClass())) {
|
||||
bar = createMenuBar();
|
||||
if (hasCheckBox())
|
||||
bar.createSelectionButtons(dataSource);
|
||||
MainModule_.instance.getUI().menuBars.put(dataSource.getClass(), bar);
|
||||
} else {
|
||||
bar = MainModule_.instance.getUI().menuBars.get(dataSource.getClass());
|
||||
}
|
||||
mountPanel.add(bar, BorderLayout.NORTH);
|
||||
//--
|
||||
f_ui = (count -> bar.countLabel.setText(String.valueOf(count)));
|
||||
//--
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SaveColumns() {
|
||||
if (MainModule_.instance.getDb() != null) {
|
||||
@@ -58,9 +79,6 @@ public class DataSetControlForm extends ControlForm<DataTable> {
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean hasCheckBox() {
|
||||
return false;
|
||||
}
|
||||
private Vector<String> getHeaders() {
|
||||
return columns.stream().map(ColumnInfo::getName).collect(Collectors.toCollection(Vector::new));
|
||||
}
|
||||
@@ -254,10 +272,18 @@ public class DataSetControlForm extends ControlForm<DataTable> {
|
||||
}
|
||||
}
|
||||
}
|
||||
protected DataMenuBar createMenuBar() {
|
||||
return new DataMenuBar(dataSource.getPluralDescription());
|
||||
}
|
||||
@Override
|
||||
protected void redrawControl() {
|
||||
control.CorrectSizes();
|
||||
}
|
||||
@Override
|
||||
public void Show() {
|
||||
super.Show();
|
||||
if (f_ui != null) f_ui.ShowMatchesCount(getRowCount());
|
||||
}
|
||||
public void Show(Object pk) {
|
||||
Show();
|
||||
Select(pk);
|
||||
@@ -267,8 +293,12 @@ public class DataSetControlForm extends ControlForm<DataTable> {
|
||||
control.SelectRowByPK(pk);
|
||||
}
|
||||
public void ClearSelection() {
|
||||
if (isShown())
|
||||
control.clearSelection(); //строка сбросится сама. благодаря сбросу события выбора
|
||||
if (isShown()) control.clearSelection(); //строка сбросится сама. благодаря сбросу события выбора
|
||||
}
|
||||
@Override
|
||||
public void Clear() {
|
||||
super.Clear();
|
||||
if (f_ui != null) f_ui.ShowNoMatches();
|
||||
}
|
||||
public int getRowCount() {
|
||||
return control.getRowCount();
|
||||
@@ -303,5 +333,13 @@ public class DataSetControlForm extends ControlForm<DataTable> {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void MouseAction2() throws Exception{}
|
||||
public void MouseAction2() throws Exception {
|
||||
}
|
||||
//-
|
||||
public boolean hasCheckBox() {
|
||||
return false;
|
||||
}
|
||||
public boolean hasMenuBar() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user