76 lines
2.3 KiB
Java
76 lines
2.3 KiB
Java
package _VisualDVM.Visual.Windows;
|
||
import Common.Utils.CommonUtils;
|
||
import Common.Visual.Windows.Dialog.Dialog;
|
||
import Common.Database.Objects.DBForm.DBForm;
|
||
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 (((GlobalDatabase)CommonUtils.db).sapforProfiles.size() > 0) {
|
||
for (Object key : ((GlobalDatabase)CommonUtils.db).sapforProfiles.Data.keySet()) {
|
||
((GlobalDatabase)CommonUtils.db).sapforProfiles.ShowUI(key);
|
||
return;
|
||
}
|
||
} else {
|
||
((GlobalDatabase)CommonUtils.db).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 (((GlobalDatabase)CommonUtils.db).forms.Data.containsKey(getFormKey())) {
|
||
info = ((GlobalDatabase)CommonUtils.db).forms.Data.get(getFormKey());
|
||
info.Apply(this);
|
||
return;
|
||
}
|
||
setSize(getDefaultWidth(), getDefaultHeight());
|
||
}
|
||
public void SaveWindowParameters() throws Exception {
|
||
if (info != null) {
|
||
info.Init(this);
|
||
CommonUtils.db.Update(info);
|
||
} else
|
||
CommonUtils.db.Insert(new DBForm(getFormKey(), this));
|
||
}
|
||
}
|