рефакторинг сохранения форм. не было единого интерфейса
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
package Common.Visual.Windows;
|
||||
import Common.Database.Objects.DBForm.DBForm;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.SavedForm;
|
||||
import Common.Visual.Themes.ThemeElement;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
public abstract class Form extends JFrame implements ThemeElement {
|
||||
private DBForm dbInfo = null;
|
||||
public abstract class Form extends JFrame implements ThemeElement, SavedForm {
|
||||
public Form() {
|
||||
if (getIconPath() != null) setIconImage(Utils_.getIcon(getIconPath()).getImage());
|
||||
SetListener();
|
||||
@@ -27,9 +25,6 @@ public abstract class Form extends JFrame implements ThemeElement {
|
||||
public String getUTitleText() {
|
||||
return "";
|
||||
}
|
||||
protected String getFormKey() {
|
||||
return null;
|
||||
}
|
||||
protected void SetListener() {
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@@ -39,9 +34,11 @@ public abstract class Form extends JFrame implements ThemeElement {
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return 800;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 450;
|
||||
}
|
||||
@@ -72,25 +69,6 @@ public abstract class Form extends JFrame implements ThemeElement {
|
||||
}
|
||||
public void AfterClose() {
|
||||
}
|
||||
public void LoadWindowParameters() throws Exception {
|
||||
if (getFormKey() != null)
|
||||
if (Global.mainModule.getDb().forms.Data.containsKey(getFormKey())) {
|
||||
dbInfo = Global.mainModule.getDb().forms.Data.get(getFormKey());
|
||||
dbInfo.Apply(this);
|
||||
return;
|
||||
}
|
||||
setSize(getDefaultWidth(), getDefaultHeight());
|
||||
setLocationRelativeTo(getRelative());
|
||||
}
|
||||
public void SaveWindowParameters() throws Exception {
|
||||
if (getFormKey() != null) {
|
||||
if (dbInfo != null) {
|
||||
dbInfo.Init(this);
|
||||
Global.mainModule.getDb().Update(dbInfo);
|
||||
} else
|
||||
Global.mainModule.getDb().Insert(new DBForm(getFormKey(), this));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
//todo -> применение темы.
|
||||
|
||||
Reference in New Issue
Block a user