2024-10-09 22:15:56 +03:00
|
|
|
|
package _VisualDVM.Visual.Windows;
|
2024-10-08 01:30:25 +03:00
|
|
|
|
import Common.Utils.CommonUtils;
|
2024-10-08 22:33:49 +03:00
|
|
|
|
import Common.Visual.Windows.Dialog.Dialog;
|
2024-10-08 16:59:20 +03:00
|
|
|
|
import Common.Database.Objects.DBForm.DBForm;
|
2024-10-09 22:21:57 +03:00
|
|
|
|
import _VisualDVM.GlobalData.GlobalDatabase;
|
2024-10-08 16:20:45 +03:00
|
|
|
|
//todo разобраться с DBform
|
2023-09-17 22:13:42 +03:00
|
|
|
|
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) {
|
2024-10-08 01:30:25 +03:00
|
|
|
|
if (((GlobalDatabase)CommonUtils.db).sapforProfiles.size() > 0) {
|
|
|
|
|
|
for (Object key : ((GlobalDatabase)CommonUtils.db).sapforProfiles.Data.keySet()) {
|
|
|
|
|
|
((GlobalDatabase)CommonUtils.db).sapforProfiles.ShowUI(key);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2024-10-08 01:30:25 +03:00
|
|
|
|
((GlobalDatabase)CommonUtils.db).sapforProfiles.ShowUI();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-10-08 23:21:47 +03:00
|
|
|
|
protected String getFormKey() {
|
|
|
|
|
|
return "Profiles"; //можно было бы через имя класса
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public void LoadWindowParameters() throws Exception {
|
2024-10-08 23:21:47 +03:00
|
|
|
|
if (((GlobalDatabase)CommonUtils.db).forms.Data.containsKey(getFormKey())) {
|
|
|
|
|
|
info = ((GlobalDatabase)CommonUtils.db).forms.Data.get(getFormKey());
|
2023-09-17 22:13:42 +03:00
|
|
|
|
info.Apply(this);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setSize(getDefaultWidth(), getDefaultHeight());
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SaveWindowParameters() throws Exception {
|
|
|
|
|
|
if (info != null) {
|
|
|
|
|
|
info.Init(this);
|
2024-10-08 01:30:25 +03:00
|
|
|
|
CommonUtils.db.Update(info);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
} else
|
2024-10-08 23:21:47 +03:00
|
|
|
|
CommonUtils.db.Insert(new DBForm(getFormKey(), this));
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|