no message

This commit is contained in:
2024-10-08 15:32:39 +03:00
parent 18ceb04325
commit e7939713e7
24 changed files with 82 additions and 155 deletions

10
src/Common/Mode.java Normal file
View File

@@ -0,0 +1,10 @@
package Common;
public enum Mode {
Undefined,
Normal,
Server,
Testing,
Package,
MachineQueue,
LocalMachineQueue
}

View File

@@ -1,7 +1,8 @@
package Common.Utils;
import Common.CommonConstants;
import Common.Database.Database;
import Common.Database.VisualiserDatabase;
import Common.Mode;
import Common_old.Current;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.commons.io.FileUtils;
@@ -23,6 +24,11 @@ import java.util.concurrent.Semaphore;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
public class CommonUtils {
//Режим
public static Mode mode= Mode.Undefined;
public static boolean hasUI() {
return mode.equals(Mode.Normal);
}
//Текущая оперционная система
public static boolean isWindows=true;
//Домашняя папка.

View File

@@ -1,6 +1,4 @@
package Common.Utils;
import Common.Utils.CommonUtils;
import Common_old.Current;
import Common_old.UI.DebugPrintLevel;
import Common_old.UI.UI;
import Common_old.Utils.Utils;
@@ -42,7 +40,7 @@ public interface Loggable {
ex.printStackTrace(writer);
writer.flush();
Print(out.toString());
if (Current.hasUI())
if (CommonUtils.hasUI())
UI.Error("Возникло исключение. Подробности в файле журнала\n" +
CommonUtils.Brackets(getLogFile().getAbsolutePath()));
}

View File

@@ -68,7 +68,6 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
try {
if ((CurrentName() != null)) {
String tableName= CurrentName().toString();
System.out.println(tableName+" savingColumns...");
Vector<String> widths = IntStream.range(0, columns.size()).mapToObj(i -> String.valueOf(control.getColumnModel().getColumn(i).getWidth())).collect(Collectors.toCollection(Vector::new));
String packed = String.join("|", widths);
TableVisualData tableVisualData;
@@ -80,7 +79,6 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
}
tableVisualData.sizes = packed;
CommonUtils.db.Update(tableVisualData);
System.out.println("done");
}
} catch (Exception ex) {
ex.printStackTrace();

View File

@@ -108,10 +108,6 @@ public enum Current implements CurrentAnchestor {
SapforSettings,
SapforSettingsCommand,
DVMSettings;
public static Mode mode;
public static boolean hasUI() {
return Current.mode.equals(Current.Mode.Normal);
}
public static boolean HasProject() {
return CurrentAnchestor.get(Project) != null;
}
@@ -463,14 +459,4 @@ public enum Current implements CurrentAnchestor {
return "";
}
}
//---
public enum Mode {
Undefined,
Normal,
Server,
Testing,
Package,
MachineQueue,
LocalMachineQueue
}
}

View File

@@ -26,7 +26,7 @@ public class GlobalProperties extends Properties {
}
}
@Expose
public Current.Mode Mode = Current.Mode.Normal;
public Common.Mode Mode = Common.Mode.Normal;
@Expose
public String ServerAddress = "alex-freenas.ddns.net";
@Expose
@@ -105,8 +105,6 @@ public class GlobalProperties extends Properties {
public int ComponentsBackUpsCount = 10;
//- тестирование.
@Expose
public int TestingKernels = 4; //число ядер для тестирования
@Expose
public boolean AutoCheckTesting = false; // проверять ли задачи тестирования при включенном визуализаторе.
@Expose
public int CheckTestingIntervalSeconds = 10; //интервал автопроверки тестирования
@@ -159,7 +157,6 @@ public class GlobalProperties extends Properties {
InstructionPath = p.InstructionPath;
PerformanceAnalyzerPath = p.PerformanceAnalyzerPath;
ComponentsBackUpsCount = p.ComponentsBackUpsCount;
TestingKernels = p.TestingKernels;
AutoCheckTesting = p.AutoCheckTesting;
CheckTestingIntervalSeconds = p.CheckTestingIntervalSeconds;
EmailOnTestingProgress = p.EmailOnTestingProgress;

View File

@@ -319,7 +319,7 @@ public class UI {
}
//---------------
public static boolean Question(Component parent, String text) {
return !Current.hasUI() || (JOptionPane.showConfirmDialog(parent,
return !CommonUtils.hasUI() || (JOptionPane.showConfirmDialog(parent,
text + "?",
"Подтверждение",
JOptionPane.YES_NO_OPTION,
@@ -330,16 +330,16 @@ public class UI {
}
public static void Info(String message) {
CommonUtils.CopyToClipboard(message);
if (Current.hasUI())
if (CommonUtils.hasUI())
JOptionPane.showMessageDialog(getFrontWindow(), message, "", 1);
}
public static void Error(String message) {
CommonUtils.CopyToClipboard(message);
if (Current.hasUI())
if (CommonUtils.hasUI())
JOptionPane.showMessageDialog(getFrontWindow(), message, "", 0);
}
public static boolean Warning(String text) {
return !Current.hasUI() ||
return !CommonUtils.hasUI() ||
JOptionPane.showConfirmDialog(getFrontWindow(),
text + "\nВы уверены?",
"Подтверждение",

View File

@@ -9,6 +9,8 @@ import java.util.stream.Collectors;
public class TableVisualData extends DBObject {
@Description("PRIMARY KEY, UNIQUE") //имя таблицы
public String name = null;
//todo запаковать в json (?)
@Description("DEFAULT ''")
public String sizes = ""; //ширины столбцов запакованные через |. вводить объекты ради них нецелесообразно.
public TableVisualData() {

View File

@@ -1,13 +1,14 @@
package ProjectData.Messages;
import Common.CurrentAnchestor;
import Common.Mode;
import Common.Utils.CommonUtils;
import Common_old.Constants;
import Common_old.Current;
import _VisualDVM.Global;
import GlobalData.Settings.SettingName;
import ProjectData.SapforData.FileObject;
import ProjectData.SapforData.FileObjectWithMessages;
import Visual_DVM_2021.Passes.PassException;
import _VisualDVM.Global;
import java.util.HashMap;
import java.util.Map;
@@ -26,7 +27,7 @@ public class Message extends FileObject {
setGroup(group_in);
if ((group == Constants.parser_group) ||
(group == Constants.compiler_group) ||
(Current.mode != Current.Mode.Normal)) {
(CommonUtils.mode != Mode.Normal)) {
value = value_in;
} else {
value = !Global.getSetting(SettingName.TRANSLATE_MESSAGES).toBoolean() ? value_in : decodeRussianMessage(value_in);

View File

@@ -691,7 +691,7 @@ public class db_project_info extends DBObject {
Utils.forceDeleteWithCheck(file);
}
public void CreateInterruptFile() throws Exception {
FileUtils.write(getInterruptFile(), Current.mode.toString());
FileUtils.write(getInterruptFile(), CommonUtils.mode.toString());
}
public void AppendScenario(String line_in) {
Scenario += (line_in + "\n");

View File

@@ -351,13 +351,13 @@ public abstract class Sapfor extends OSDComponent {
for (PassCode_2021 code : getAnalysesCodes())
(Pass_2021.passes.get(code)).Reset();
//------------------------------------------------------------------------------------------>>>> пакетный режим.
if (Current.hasUI()) {
if (CommonUtils.hasUI()) {
Pass_2021.passes.get(PassCode_2021.Precompilation).Reset();
Pass_2021.passes.get(PassCode_2021.SPF_GetGCovInfo).Reset();
}
Global.enable_text_changed = false;
Global.transformationPermission = TransformationPermission.None;
if ((Current.hasUI()) && (UI.getMainWindow() != null) && (UI.getVersionsWindow() != null))
if ((CommonUtils.hasUI()) && (UI.getMainWindow() != null) && (UI.getVersionsWindow() != null))
UI.getVersionsWindow().BlockVariants();
}
//--------------------------------------------------------------------------->>

View File

@@ -45,7 +45,7 @@ public class Group extends riDBObject {
@Override
public void select(boolean flag) {
super.select(flag);
if (Current.hasUI())
if (CommonUtils.hasUI())
UI.getMainWindow().ShowCheckedTestsCount();
}
//--

View File

@@ -1,13 +1,13 @@
package TestingSystem.Common.MachineProcess;
import Common.CommonConstants;
import Common.Database.Objects.DBObject;
import Common.Mode;
import Common.Utils.CommonUtils;
import Common_old.Constants;
import Common_old.Current;
import Common.Database.Objects.DBObject;
import _VisualDVM.Global;
import Common_old.GlobalProperties;
import Common_old.Utils.Utils;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import _VisualDVM.Global;
import org.apache.commons.io.FileUtils;
import java.io.File;
@@ -101,8 +101,7 @@ public class MachineProcess extends DBObject {
FileUtils.copyFile(src, supervisor);
//создание настроек
GlobalProperties properties = new GlobalProperties(Global.properties);
properties.Mode = //isLocal()?Current.Mode.LocalMachineQueue:
Current.Mode.MachineQueue;
properties.Mode = Mode.MachineQueue;
CommonUtils.jsonToFile(properties, new File(workspace, "properties"));
Vector<String> args = new Vector<>();
args.add(CommonUtils.DQuotes(machineAddress));

View File

@@ -53,7 +53,7 @@ public class Test extends riDBObject {
@Override
public void select(boolean flag) {
super.select(flag);
if (Current.hasUI())
if (CommonUtils.hasUI())
UI.getMainWindow().ShowCheckedTestsCount();
}
//---

View File

@@ -2,7 +2,6 @@ package TestingSystem.Common;
import Common.CommonConstants;
import Common.Utils.CommonUtils;
import Common_old.Constants;
import Common_old.Current;
import _VisualDVM.Global;
import Common_old.Utils.Utils;
import GlobalData.Machine.Machine;
@@ -206,7 +205,7 @@ public abstract class TestingPlanner<P extends TestingPackage> extends Repositor
}
@Override
public String getLogName() {
return Current.mode.toString();
return CommonUtils.mode.toString();
}
};
CommonUtils.MainLog.ClearLog();

View File

@@ -1,9 +1,8 @@
package TestingSystem.SAPFOR;
import Common.CommonConstants;
import Common.Mode;
import Common.Utils.CommonUtils;
import Common_old.Constants;
import Common_old.Current;
import _VisualDVM.Global;
import Common_old.GlobalProperties;
import Common_old.Utils.Utils;
import ProjectData.LanguageName;
@@ -18,6 +17,7 @@ import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
import _VisualDVM.Global;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
@@ -94,7 +94,7 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
FileUtils.copyFile(new File(CommonUtils.Home, "TestingSystem.jar"), visualiser);
//создание настроек
GlobalProperties properties = new GlobalProperties(Global.properties);
properties.Mode = Current.Mode.Package;
properties.Mode = Mode.Package;
CommonUtils.jsonToFile(properties, new File(workspace, "properties"));
//подготовка пакетного режима. Запустит его уже очередь.
Utils.createScript(workspace, workspace, "start", "java -jar VisualSapfor.jar");

View File

@@ -21,7 +21,7 @@ public class DeleteVersion extends Pass_2021<db_project_info> {
current = (Current.getVersion() != null) && Current.getVersion().Home.equals(target.Home);
return true;
} else {
if (((target = Current.getVersion()) != null) && (!Current.hasUI() ||
if (((target = Current.getVersion()) != null) && (!CommonUtils.hasUI() ||
UI.Warning("Удалить " +
((Current.HasProject() && target.Home.equals(Current.getProject().Home)) ? "текущий проект" : "версию ")
+ CommonUtils.Brackets(target.name)))) {
@@ -39,7 +39,7 @@ public class DeleteVersion extends Pass_2021<db_project_info> {
if ((Current.getProject().Home.getAbsolutePath().startsWith(target.Home.getAbsolutePath())))
passes.get(PassCode_2021.CloseCurrentProject).Do();
}
if (Current.hasUI()) {
if (CommonUtils.hasUI()) {
UI.getVersionsWindow().RemoveVersionFromComparison(target);
}
}

View File

@@ -1,10 +1,11 @@
package Visual_DVM_2021.Passes.All;
import Common_old.Current;
import _VisualDVM.Global;
import Common.Mode;
import Common.Utils.CommonUtils;
import ProjectData.SapforData.Variants.ParallelVariant;
import Repository.Component.Sapfor.TransformationPermission;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.SapforTransformation;
import _VisualDVM.Global;
public class SPF_CreateParallelVariant extends SapforTransformation {
ParallelVariant variant = null;
@Override
@@ -65,13 +66,13 @@ public class SPF_CreateParallelVariant extends SapforTransformation {
protected void performDone() throws Exception {
Global.transformationPermission = TransformationPermission.VariantsOnly;
target.migrateFilesSettings(target.last_version, true, true);
if (Current.hasUI())
if (CommonUtils.hasUI())
variant.UpdateStats(sapfor.getPredictorStats(), target.last_version.name);
}
@Override
protected void performFinish() throws Exception {
//в пакетном режиме вариант всегда один. поэтому, сообщения надо распаковать сразу.
if (Current.mode.equals(Current.Mode.Package))
if (CommonUtils.mode.equals(Mode.Package))
super.performFinish();
}
@Override

View File

@@ -111,7 +111,7 @@ public class SPF_ParseFilesWithOrder extends SapforAnalysis {
protected void performPreparation() throws Exception {
super.performPreparation(); //удаление интеррупта.
//------------------------------------------------------------------------------------------>>> пакетный режим.
if (!precompilation_done && Current.hasUI()) {
if (!precompilation_done && CommonUtils.hasUI()) {
passes.get(PassCode_2021.Save).Do();
target.CleanAnalyses();
}

View File

@@ -191,30 +191,30 @@ public class Pass_2021<T> {
//-
private void PerformCanNotStart() throws Exception {
performCanNotStart();
if (Current.hasUI())
if (CommonUtils.hasUI())
showCanNotStart();
}
protected void PerformPreparation() throws Exception {
performPreparation();
if (Current.hasUI())
if (CommonUtils.hasUI())
showPreparation();
}
private void PerformFinish() throws Exception {
performFinish();
//-
if (Current.hasUI())
if (CommonUtils.hasUI())
showFinish();
}
private void PerformDone() throws Exception {
performDone();
//-
if (Current.hasUI())
if (CommonUtils.hasUI())
showDone();
}
private void PerformFail() throws Exception {
performFail();
//-
if (Current.hasUI())
if (CommonUtils.hasUI())
showFail();
}
//------
@@ -298,11 +298,11 @@ public class Pass_2021<T> {
timer.Start();
//------------------------------->
try {
if (Current.hasUI()) FocusBeforeStart();
if (CommonUtils.hasUI()) FocusBeforeStart();
if (canStart(args)) {
PerformPreparation();
//todo тут должна быть вилка на анимацию?
if (Current.hasUI() && needsAnimation()) {
if (CommonUtils.hasUI() && needsAnimation()) {
animation_sem = new Semaphore(1);
animation_sem.acquire();
//---
@@ -386,7 +386,7 @@ public class Pass_2021<T> {
" окончен за " + timer.Print() +
" состояние " + CommonUtils.Brackets(state.getDescription())
);
if (!Log.isEmpty() && Current.hasUI())
if (!Log.isEmpty() && CommonUtils.hasUI())
UI.Error(
"проход " + CommonUtils.Brackets(getDescription()) + "\n" + state.getDescription() + "\n\n" +
Log.toString());
@@ -396,7 +396,7 @@ public class Pass_2021<T> {
}
//--
public void ShowSapforMessage(String message) {
if (Current.hasUI() && form != null) {
if (CommonUtils.hasUI() && form != null) {
String[] data = message.split(":");
switch (data[0]) {
case "message_1":

View File

@@ -1,6 +1,5 @@
package Visual_DVM_2021.Passes;
import Common.Utils.CommonUtils;
import Common_old.Current;
import _VisualDVM.Global;
import Common_old.UI.DebugPrintLevel;
import Common_old.UI.Menus_2023.PassControl;
@@ -49,7 +48,7 @@ public class SapforAnalysis extends SapforPass {
@Override
protected void PerformPreparation() throws Exception {
//-
if (Current.hasUI())
if (CommonUtils.hasUI())
showPreparation(); // отображение пустых данных
//-
performPreparation(); //в данном случае удаление данных

View File

@@ -146,7 +146,7 @@ public class Global {
}
@Override
public String getLogName() {
return Current.mode.toString();
return CommonUtils.mode.toString();
}
};
CommonUtils.MainLog.ClearLog();
@@ -216,7 +216,7 @@ public class Global {
}
//возможно заменить settings на properties
public static DBSetting getSetting(SettingName settingName) throws Exception {
switch (Current.mode) {
switch (CommonUtils.mode) {
case Normal:
return ((GlobalDatabase)CommonUtils.db).settings.get(settingName);
default:
@@ -386,10 +386,10 @@ public class Global {
System.out.println("home directory is" + CommonUtils.Brackets(CommonUtils.Home));
//---
SynschronizeProperties();
Current.mode = properties.Mode;
System.out.println("mode is " + Current.mode);
CommonUtils.mode = properties.Mode;
System.out.println("mode is " + CommonUtils.mode);
try {
switch (Current.mode) {
switch (CommonUtils.mode) {
case Normal:
NormalMode(Integer.parseInt(args[1]));
break;