Files
VisualSapfor/src/Common_old/UI/Tables/DataTable.java

65 lines
1.8 KiB
Java
Raw Normal View History

package Common_old.UI.Tables;
import Common.Database.Objects.DBObject;
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;
}
*/
}