рефакторинг сохранения форм. не было единого интерфейса
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package _VisualDVM.Visual.Windows;
|
||||
import Common.Database.Objects.DBForm.DBForm;
|
||||
import Common.Visual.SavedForm;
|
||||
import Common.Visual.Windows.Dialog.Dialog;
|
||||
import _VisualDVM.Global;
|
||||
//todo разобраться с DBform
|
||||
public class ProfilesForm extends Dialog<Object, ProfilesFields> {
|
||||
public class ProfilesForm extends Dialog<Object, ProfilesFields> implements SavedForm {
|
||||
private DBForm info = null;
|
||||
public ProfilesForm() {
|
||||
super(ProfilesFields.class);
|
||||
@@ -38,37 +38,15 @@ public class ProfilesForm extends Dialog<Object, ProfilesFields> {
|
||||
public void CreateContent() {
|
||||
super.CreateContent();
|
||||
fields.LoadSplitters();
|
||||
try {
|
||||
LoadWindowParameters();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
LoadWindowParameters();
|
||||
}
|
||||
@Override
|
||||
public void onClose() {
|
||||
fields.SaveSplitters();
|
||||
try {
|
||||
SaveWindowParameters();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
SaveWindowParameters();
|
||||
}
|
||||
protected String getFormKey() {
|
||||
@Override
|
||||
public String getFormKey() {
|
||||
return "Profiles"; //можно было бы через имя класса
|
||||
}
|
||||
public void LoadWindowParameters() throws Exception {
|
||||
if ((Global.mainModule.getDb()).forms.Data.containsKey(getFormKey())) {
|
||||
info = (Global.mainModule.getDb()).forms.Data.get(getFormKey());
|
||||
info.Apply(this);
|
||||
return;
|
||||
}
|
||||
setSize(getDefaultWidth(), getDefaultHeight());
|
||||
}
|
||||
public void SaveWindowParameters() throws Exception {
|
||||
if (info != null) {
|
||||
info.Init(this);
|
||||
Global.mainModule.getDb().Update(info);
|
||||
} else
|
||||
Global.mainModule.getDb().Insert(new DBForm(getFormKey(), this));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user