77 lines
2.3 KiB
Java
77 lines
2.3 KiB
Java
package _VisualDVM.Visual.Windows;
|
||
import Common.Utils.Utils_;
|
||
import Common.Visual.Windows.Dialog.Dialog;
|
||
import Common.Database.Objects.DBForm.DBForm;
|
||
import _VisualDVM.Global;
|
||
import _VisualDVM.GlobalData.GlobalDatabase;
|
||
//todo разобраться с DBform
|
||
public class ProfilesForm extends Dialog<Object, ProfilesFields> {
|
||
private DBForm info = null;
|
||
public ProfilesForm() {
|
||
super(ProfilesFields.class);
|
||
}
|
||
@Override
|
||
public boolean NeedsScroll() {
|
||
return false;
|
||
}
|
||
@Override
|
||
public void CreateButtons() {
|
||
}
|
||
@Override
|
||
public void Init(Object... params) {
|
||
if ((Global.mainModule.getDb()).sapforProfiles.size() > 0) {
|
||
for (Object key : (Global.mainModule.getDb()).sapforProfiles.Data.keySet()) {
|
||
(Global.mainModule.getDb()).sapforProfiles.ShowUI(key);
|
||
return;
|
||
}
|
||
} else {
|
||
(Global.mainModule.getDb()).sapforProfiles.ShowUI();
|
||
}
|
||
}
|
||
@Override
|
||
public int getDefaultWidth() {
|
||
return 400;
|
||
}
|
||
@Override
|
||
public int getDefaultHeight() {
|
||
return 300;
|
||
}
|
||
@Override
|
||
public void CreateContent() {
|
||
super.CreateContent();
|
||
fields.LoadSplitters();
|
||
try {
|
||
LoadWindowParameters();
|
||
} catch (Exception ex) {
|
||
ex.printStackTrace();
|
||
}
|
||
}
|
||
@Override
|
||
public void onClose() {
|
||
fields.SaveSplitters();
|
||
try {
|
||
SaveWindowParameters();
|
||
} catch (Exception ex) {
|
||
ex.printStackTrace();
|
||
}
|
||
}
|
||
protected 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));
|
||
}
|
||
}
|