2024-10-09 20:35:18 +03:00
|
|
|
package Common.Visual.Tables;
|
2024-10-07 00:58:29 +03:00
|
|
|
import Common.Database.Objects.DBObject;
|
2024-10-08 00:39:13 +03:00
|
|
|
import Common.Visual.DataControl;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import javax.swing.table.AbstractTableModel;
|
|
|
|
|
public abstract class DataTable extends StyledTable implements DataControl {
|
|
|
|
|
public DataTable(AbstractTableModel model) {
|
|
|
|
|
super(model);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void SelectRowByPK(Object pk) {
|
|
|
|
|
for (int i = 0; i < getRowCount(); ++i) {
|
|
|
|
|
DBObject o = getRowObject(i);
|
|
|
|
|
if (o!=null) {
|
|
|
|
|
if (o.getPK()
|
|
|
|
|
.equals(pk)) {
|
|
|
|
|
SelectRow(i);
|
|
|
|
|
scrollToVisible(i, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------
|
|
|
|
|
/*
|
|
|
|
|
public void SelectRow(int r) {
|
|
|
|
|
getSelectionModel().setSelectionInterval(r, r);
|
|
|
|
|
}
|
|
|
|
|
public Object getRowKey(int r) {
|
|
|
|
|
return getValueAt(r, 0);
|
|
|
|
|
}
|
|
|
|
|
public DBObject getRowObject(int row) {
|
|
|
|
|
return (DBObject) getGrid().getDataSource().get(getRowKey(row));
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------
|
|
|
|
|
|
|
|
|
|
public int getRowByKey(Object key) {
|
|
|
|
|
for (int i = 0; i < getRowCount(); ++i) {
|
|
|
|
|
if (getRowKey(i).equals(key)) return i;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
public void SelectRowByKey(Object key) {
|
|
|
|
|
int r = getRowByKey(key);
|
|
|
|
|
if (r >= 0)
|
|
|
|
|
SelectRow(r);
|
|
|
|
|
}
|
|
|
|
|
public void ClearSelectionSync() {
|
|
|
|
|
events_on = false;
|
|
|
|
|
getSelectionModel().clearSelection();
|
|
|
|
|
current_row_i = Utils.Nan;
|
|
|
|
|
events_on = true;
|
|
|
|
|
}
|
|
|
|
|
public void SelectRowByKeySync(Object key) {
|
|
|
|
|
int r = getRowByKey(key);
|
|
|
|
|
events_on = false;
|
|
|
|
|
if (r >= 0)
|
|
|
|
|
SelectRow(r);
|
|
|
|
|
events_on = true;
|
|
|
|
|
current_row_i = r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|