2024-10-09 22:21:57 +03:00
|
|
|
package _VisualDVM.GlobalData.Splitter;
|
2024-10-07 00:58:29 +03:00
|
|
|
import Common.Database.Tables.DBTable;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Utils.Utils_;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
public class SplittersDBTable extends DBTable<String, Splitter> {
|
|
|
|
|
public SplittersDBTable() {
|
|
|
|
|
super(String.class, Splitter.class);
|
|
|
|
|
}
|
|
|
|
|
private Vector<JSplitPane> InitSplitters(Object form) throws Exception {
|
|
|
|
|
Vector<JSplitPane> res = new Vector<>();
|
|
|
|
|
Class c = form.getClass();
|
|
|
|
|
for (Field field : c.getFields()) {
|
|
|
|
|
if (field.getType().getSimpleName().equals("JSplitPane")) {
|
|
|
|
|
JSplitPane splitPane = (JSplitPane) field.get(form);
|
|
|
|
|
splitPane.setName(field.getName());
|
|
|
|
|
res.add(splitPane);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public void Load(Object form) {
|
|
|
|
|
try {
|
|
|
|
|
Vector<JSplitPane> splitters = InitSplitters(form);
|
|
|
|
|
for (JSplitPane splitPane : splitters) {
|
|
|
|
|
if (Data.containsKey(splitPane.getName())) {
|
|
|
|
|
splitPane.setDividerLocation(Data.get(splitPane.getName()).position);
|
|
|
|
|
} else {
|
|
|
|
|
getDb().Insert(new Splitter(splitPane));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
2024-10-11 00:00:30 +03:00
|
|
|
Utils_.MainLog.PrintException(ex);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Save(Object form) {
|
|
|
|
|
try {
|
|
|
|
|
Vector<JSplitPane> splitters = InitSplitters(form);
|
|
|
|
|
for (JSplitPane splitPane : splitters) {
|
|
|
|
|
Splitter splitter = Data.get(splitPane.getName());
|
|
|
|
|
splitter.position = splitPane.getDividerLocation();
|
|
|
|
|
getDb().Update(splitter);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
2024-10-11 00:00:30 +03:00
|
|
|
Utils_.MainLog.PrintException(ex);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|