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

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,19 @@ import com.google.gson.annotations.Expose;
import java.io.File;
import java.nio.file.Paths;
public class GlobalProperties extends Properties {
@Override
public String getFieldDescription(String fieldName) {
switch (fieldName) {
case "ShowPassesDone":
return "Сообщать об успешном выполнении проходов";
case "ConfirmPassesStart":
return "Запрашивать подтверждения начала выполнения проходов";
case "FocusPassesResult":
return "Переходить на результирующую вкладку проходов по их завершении";
default:
return "?";
}
}
@Expose
public Current.Mode Mode = Current.Mode.Normal;
//---
@@ -37,7 +50,6 @@ public class GlobalProperties extends Properties {
public boolean ShowPassesDone = true;
@Expose
public boolean FocusPassesResult = true;
//-
@Expose
public String GlobalDBName = "db7.sqlite";
@Expose
@@ -64,21 +76,17 @@ public class GlobalProperties extends Properties {
public String PerformanceAnalyzerPath = "";
@Expose
public int ComponentsBackUpsCount=10;
//- тестирование.
@Expose
public int TestingKernels = 4; //число ядер для тестирования
@Expose
public boolean AutoCheckTesting = false; // проверять ли задачи тестирования при включенном визуализаторе.
@Expose
public int CheckTestingIntervalSeconds = 10; //интервал автопроверки тестирования
@Expose
public boolean EmailOnTestingProgress = false; //включено ли оповещение по email о результатах тестирования.
//-
@Override
public String getFieldDescription(String fieldName) {
switch (fieldName) {
case "ShowPassesDone":
return "Сообщать об успешном выполнении проходов";
case "ConfirmPassesStart":
return "Запрашивать подтверждения начала выполнения проходов";
case "FocusPassesResult":
return "Переходить на результирующую вкладку проходов по их завершении";
default:
return "?";
}
}
@Override
public File getFile() {
return Paths.get(System.getProperty("user.dir"),"properties").toFile();
}

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();
}
}
}

View File

@@ -1,5 +1,6 @@
package Common.UI.Menus_2023.TestingBar;
import Common.Current;
import Common.Global;
import Common.UI.Menus_2023.MenuBarButton;
import Common.UI.Menus_2023.VisualiserMenuBar;
import Common.UI.Themes.VisualiserFonts;
@@ -25,9 +26,10 @@ public class TestingBar extends VisualiserMenuBar {
add(sKernels = new JSpinner());
sKernels.setPreferredSize(new Dimension(60, 26));
sKernels.setMaximumSize(new Dimension(60, 26));
sKernels.setModel(new SpinnerNumberModel(TestingServer.kernels, 1, 64, 1));
sKernels.setModel(new SpinnerNumberModel(Global.properties.TestingKernels, 1, 64, 1));
sKernels.setValue(Global.properties.TestingKernels);
UI.MakeSpinnerRapid(sKernels, e -> {
TestingServer.kernels = (int) sKernels.getValue();
Global.properties.updateField("TestingKernels", sKernels.getValue());
});
//--
add(new MenuBarButton() {
@@ -36,14 +38,13 @@ public class TestingBar extends VisualiserMenuBar {
setToolTipText("Оповещение о прогрессе выполнения пакета тестов");
Mark();
addActionListener(e -> {
TestingServer.email = !TestingServer.email;
Global.properties.switchAndUpdateFlag("EmailOnTestingProgress");
Mark();
});
}
public void Mark() {
setIcon(Utils.getIcon(TestingServer.email ? "/icons/Pick.png" : "/icons/NotPick.png"));
setIcon(Utils.getIcon(Global.properties.EmailOnTestingProgress ? "/icons/Pick.png" : "/icons/NotPick.png"));
}
});
//--
add(autorefreshButton = new MenuBarButton() {
@@ -52,23 +53,29 @@ public class TestingBar extends VisualiserMenuBar {
setToolTipText("автоматическое обновление состояния пакета задач");
Mark();
addActionListener(e -> {
TestingServer.checkTasks = !TestingServer.checkTasks;
TestingServer.switchTimer(TestingServer.checkTasks);
Global.properties.switchAndUpdateFlag("AutoCheckTesting");
//-
if (Global.properties.AutoCheckTesting)
TestingServer.TimerOn();
else
TestingServer.TimerOff();
//-
Mark();
});
}
public void Mark() {
setIcon(Utils.getIcon(TestingServer.checkTasks ? "/icons/Pick.png" : "/icons/NotPick.png"));
setIcon(Utils.getIcon(Global.properties.AutoCheckTesting ? "/icons/Pick.png" : "/icons/NotPick.png"));
}
});
//--
add(sCheckTime = new JSpinner());
sCheckTime.setPreferredSize(new Dimension(60, 26));
sCheckTime.setMaximumSize(new Dimension(60, 26));
sCheckTime.setModel(new SpinnerNumberModel(TestingServer.checkIntervalSecond, 10, 3600, 1));
sCheckTime.setModel(new SpinnerNumberModel(Global.properties.CheckTestingIntervalSeconds, 10, 3600, 1));
sCheckTime.setValue(Global.properties.CheckTestingIntervalSeconds);
UI.MakeSpinnerRapid(sCheckTime, e -> {
TestingServer.checkIntervalSecond = (int) sCheckTime.getValue();
if (TestingServer.checkTasks) TestingServer.ResetTimer();
Global.properties.updateField("CheckTestingIntervalSeconds", sCheckTime.getValue());
if (Global.properties.AutoCheckTesting) TestingServer.ResetTimer();
});
add(new JLabel(" сек ") {
{
@@ -76,7 +83,7 @@ public class TestingBar extends VisualiserMenuBar {
}
});
}
public void ShowAutorefresh() {
autorefreshButton.setIcon(Utils.getIcon(TestingServer.checkTasks ? "/icons/Pick.png" : "/icons/NotPick.png"));
public void ShowAutoCheckTesting() {
autorefreshButton.setIcon(Utils.getIcon(Global.properties.AutoCheckTesting ? "/icons/Pick.png" : "/icons/NotPick.png"));
}
}