промежуточный. частичный рефакторинг смены глобальный настроек. автоотключение проверки бд тестов если активных пакетов нет.

This commit is contained in:
2023-11-13 21:07:44 +03:00
parent 56f54581b6
commit a76e9d0310
21 changed files with 218 additions and 188 deletions

View File

@@ -4,6 +4,7 @@ import Common.Utils.Utils;
import javax.swing.*;
import java.io.File;
import java.lang.reflect.Field;
public abstract class Properties {
public void addFlagMenuItem(JMenu menu, String fieldName) {
JMenuItem menu_item = new StableMenuItem(getFieldDescription(fieldName),
@@ -46,4 +47,32 @@ public abstract class Properties {
//--
public abstract String getFieldDescription(String fieldName);
public abstract File getFile();
public boolean updateField(String name, Object newValue) {
try {
Field field = getClass().getField(name);
Object oldValue = field.get(Global.properties);
//---
if (newValue.equals(oldValue))
return false;
//--
field.set(this, newValue);
return true;
//--
} catch (Exception exception) {
exception.printStackTrace();
}
return false;
}
public void switchAndUpdateFlag(String name){
try {
Field field = getClass().getField(name);
boolean oldValue = (boolean) field.get(Global.properties);
boolean newValue = !oldValue;
//---
field.set(this, newValue);
//--
} catch (Exception exception) {
exception.printStackTrace();
}
}
}