рефакторинг

This commit is contained in:
2023-09-29 21:46:08 +03:00
parent 12898b07bb
commit 760707e6fb
41 changed files with 510 additions and 486 deletions

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants.Constants;
import Common.Current;
import Common.UI.UI;
import Common.UI.Windows.Dialog.Text.FileNameForm;
@@ -30,7 +31,7 @@ public class AddFile extends ChangeFilePass<DBProjectFile> {
if (Utils.ContainsForbiddenName(fileName)) {
Log.Writeln_("Имя файла " + Utils.Brackets(fileName)
+ " содержит запрещенные символы." +
"\n" + Utils.all_forbidden_characters_string);
"\n" + Constants.all_forbidden_characters_string);
return false;
}
} else {

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants.Constants;
import Common.Current;
import Common.Utils.Utils;
import ProjectData.Files.DBProjectFile;
@@ -43,7 +44,7 @@ public class OpenSapforTest extends Pass_2021<SapforTaskResult> {
public MessageError unpackMessage(String line_in) throws Exception {
MessageError res = new MessageError();
res.file = "";
res.line = Utils.Nan;
res.line = Constants.Nan;
res.value = "";
String line = line_in.substring(9);
System.out.println(line);

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants.Constants;
import Common.Utils.Utils;
import ProjectData.Project.db_project_info;
import SapforTestingSystem.Json.SapforVersion_json;
@@ -22,7 +23,7 @@ public class PerformSapforTasksPackage extends Pass_2021<SapforScenario_json> {
File task;
//---
Process process = null;
int exit_code = Utils.Nan;
int exit_code = Constants.Nan;
//----
File outputFile = null;
File errorsFile = null;
@@ -75,7 +76,7 @@ public class PerformSapforTasksPackage extends Pass_2021<SapforScenario_json> {
}
protected boolean performSapforScript(String name, File workspace, String flags, String command, String outName, String errName) throws Exception {
process = null;
exit_code = Utils.Nan;
exit_code = Constants.Nan;
//---
File data_workspace = new File(workspace, db_project_info.data);
Utils.CheckDirectory(data_workspace);

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants.Constants;
import Common.Global;
import Common.Utils.Utils;
import ProjectData.Project.db_project_info;
@@ -25,7 +26,7 @@ public class PerformScenario extends Pass_2021<SapforScenario_json> {
File task;
//---
Process process = null;
int exit_code = Utils.Nan;
int exit_code = Constants.Nan;
//----
File outputFile = null;
File errorsFile = null;
@@ -95,7 +96,7 @@ public class PerformScenario extends Pass_2021<SapforScenario_json> {
}
protected boolean performSapforScript(String name, File workspace, String flags, String command, String outName, String errName) throws Exception {
process = null;
exit_code = Utils.Nan;
exit_code = Constants.Nan;
//---
File data_workspace = new File(workspace, db_project_info.data);
Utils.CheckDirectory(data_workspace);

View File

@@ -1,8 +1,8 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants.Constants;
import Common.Current;
import Common.Global;
import Common.UI.Windows.Dialog.Dialog;
import Common.Utils.Utils;
import GlobalData.Compiler.Compiler;
import GlobalData.Compiler.CompilerType;
import GlobalData.CompilerEnvironment.CompilerEnvironment;
@@ -29,7 +29,7 @@ public class PickCompilerEnvironments extends Pass_2021<String> {
protected boolean canStart(Object... args) throws Exception {
if (Current.Check(Log, Current.RunConfiguration)) {
RunConfiguration configuration = Current.getRunConfiguration();
if (configuration.compiler_id == Utils.Nan) {
if (configuration.compiler_id == Constants.Nan) {
Log.Writeln_("Отсутвует DVM компилятор, связанный с текущей конфигурацией запуска.\n" +
"Если конфигурация содержит вызов DVM компилятора, но была создана на версии 801 и ниже,\n" +
"войдите в окно её редактирования,нажмите ОК, а затем повторите попытку.");

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants.Constants;
import Common.Current;
import Common.Global;
import Common.UI.UI;
@@ -89,7 +90,7 @@ public class Precompilation extends Pass_2021<db_project_info> {
prepareForParse(); //---->
//-
performanceTime = 0;
exitCode = Utils.Nan;
exitCode = Constants.Nan;
//------------------
workspace = Paths.get(Global.TempDirectory.getAbsolutePath(), Utils.getDateName("precompilation")).toFile();
FileUtils.forceMkdir(workspace);
@@ -138,8 +139,8 @@ public class Precompilation extends Pass_2021<db_project_info> {
protected static void unpackPrecompilationMessages(db_project_info target, String text) throws Exception {
boolean messageStarted = false;
String messageFile = "";
int messageLine = Utils.Nan;
int messageType = Utils.Nan;
int messageLine = Constants.Nan;
int messageType = Constants.Nan;
Vector<String> messageText = new Vector<>();
String[] nw = text.split("\n");
for (String S : nw) {
@@ -155,7 +156,7 @@ public class Precompilation extends Pass_2021<db_project_info> {
messageText.add(S.substring(6));
messageType = 2;
}
if (messageType != Utils.Nan) {
if (messageType != Constants.Nan) {
target.db.files.Data.get(messageFile).CreateAndAddNewMessage(messageType, String.join("\n", messageText), messageLine, Message.parser_group);
messageStarted = false;
} else {
@@ -170,7 +171,7 @@ public class Precompilation extends Pass_2021<db_project_info> {
if (data.length > 1) {
messageFile = name;
messageLine = Integer.parseInt(data[1]);
messageType = Utils.Nan;
messageType = Constants.Nan;
messageText = new Vector<>();
messageStarted = true;
}

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes;
import Common.Constants.Constants;
import Common.Global;
import Common.Utils.Utils;
@@ -10,13 +11,13 @@ import java.util.LinkedHashMap;
import java.util.Vector;
public abstract class ProcessPass<T> extends Pass_2021<T> {
public Process process = null;
public int exit_code = Utils.Nan;
public int exit_code = Constants.Nan;
public LinkedHashMap<String, String> envs = new LinkedHashMap<>();
public Vector<String> output = new Vector<>();
protected String process_path = "";
public void CreateProcess(String exec_path_in, File workspace, String ... command) throws Exception {
output.clear();
exit_code = Utils.Nan;
exit_code = Constants.Nan;
process_path = exec_path_in;
ProcessBuilder procBuilder = new ProcessBuilder(process_path);
//-

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.UI.Main;
import Common.Constants.Constants;
import Common.Current;
import Common.Database.DBObject;
import Common.Global;
@@ -188,7 +189,7 @@ public abstract class ComparisonForm<T extends DBObject> {
//предполагаем что оба объекта есть и мы можем получить с них текст.
protected void Compare() throws Exception {
events_on = false;
current_diff_line = Utils.Nan;
current_diff_line = Constants.Nan;
colors.clear();
//-----------------------------------------------------------------------------------------------
Body.setText("");
@@ -252,7 +253,7 @@ public abstract class ComparisonForm<T extends DBObject> {
}
public void Show() throws Exception {
events_on = false;
current_diff_line = Utils.Nan;
current_diff_line = Constants.Nan;
colors.clear();
//----------------------------------------------------------------------------------------------
Body.setText("");
@@ -339,7 +340,7 @@ public abstract class ComparisonForm<T extends DBObject> {
//</editor-fold>
slave.master = this;
bPrevious.addActionListener(e -> {
if (current_diff_line != Utils.Nan) {
if (current_diff_line != Constants.Nan) {
if (current_diff_line > 0)
current_diff_line--;
else
@@ -348,7 +349,7 @@ public abstract class ComparisonForm<T extends DBObject> {
}
});
bNext.addActionListener(e -> {
if (current_diff_line != Utils.Nan) {
if (current_diff_line != Constants.Nan) {
if (current_diff_line < colors.size() - 1)
current_diff_line++;
else

View File

@@ -1,10 +1,10 @@
package Visual_DVM_2021.UI.Main;
import Common.Constants.Constants;
import Common.Global;
import Common.UI.Editor.Viewer;
import Common.UI.Menus_2023.FileMenuBar.FileMenuBar;
import Common.UI.Trees.TreeForm;
import Common.UI.UI;
import Common.Utils.Utils;
import GlobalData.Settings.SettingName;
import ProjectData.Files.DBProjectFile;
import ProjectData.Files.UI.Editor.SPFEditor;
@@ -29,7 +29,7 @@ public class FileForm implements FileWindow, FormWithSplitters {
//контролы в столбцах
//https://stackoverflow.com/questions/7137786/how-can-i-put-a-control-in-the-jtableheader-of-a-jtable
//todo _ временно
public static int current_file_line = Utils.Nan;
public static int current_file_line = Constants.Nan;
private final Viewer compilationOutput;
private final Viewer runOutput;
private final Viewer gcovLog;

View File

@@ -1,10 +1,10 @@
package Visual_DVM_2021.UI.Main;
import Common.Constants.Constants;
import Common.Current;
import Common.Global;
import Common.UI.Menus_2023.TasksPackagesMenuBar.TasksPackagesMenuBar;
import Common.UI.TextField.StyledTextField;
import Common.UI.UI;
import Common.Utils.Utils;
import GlobalData.Compiler.CompilerType;
import GlobalData.Credentials.Credentials;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
@@ -355,48 +355,48 @@ public class TestingForm implements FormWithSplitters, TestingWindow {
@Override
public void RestoreLastCredentials() {
Credentials credentials = (Credentials) Current.get(Current.Credentials);
if (credentials.machine_id != Utils.Nan) {
if (credentials.machine_id != Constants.Nan) {
if (Global.db.machines.containsKey(credentials.machine_id)) {
Global.db.machines.ShowUI(credentials.machine_id);
if (Global.db.users.containsKey(credentials.user_id)) {
Global.db.users.ShowUI(credentials.user_id);
} else {
credentials.user_id = Utils.Nan;
credentials.user_id = Constants.Nan;
Global.db.UpdateCredentials();
}
if (Global.db.compilers.containsKey(credentials.compiler_id)) {
Global.db.compilers.ShowUI(credentials.compiler_id);
} else {
credentials.compiler_id = Utils.Nan;
credentials.compiler_id = Constants.Nan;
Global.db.UpdateCredentials();
}
//-
if (Global.db.makefiles.containsKey(credentials.makefile_id)) {
Global.db.makefiles.ShowUI(credentials.makefile_id);
} else {
credentials.makefile_id = Utils.Nan;
credentials.makefile_id = Constants.Nan;
Global.db.UpdateCredentials();
}
//-
if (Global.db.runConfigurations.containsKey(credentials.runconfiguration_id)) {
Global.db.runConfigurations.ShowUI(credentials.runconfiguration_id);
} else {
credentials.runconfiguration_id = Utils.Nan;
credentials.runconfiguration_id = Constants.Nan;
Global.db.UpdateCredentials();
}
if (Global.db.remoteSapfors.containsKey(credentials.remotesapfor_id)) {
Global.db.remoteSapfors.ShowUI(credentials.remotesapfor_id);
} else {
credentials.remotesapfor_id = Utils.Nan;
credentials.remotesapfor_id = Constants.Nan;
Global.db.UpdateCredentials();
}
} else {
credentials.machine_id = Utils.Nan;
credentials.user_id = Utils.Nan;
credentials.compiler_id = Utils.Nan;
credentials.remotesapfor_id = Utils.Nan;
credentials.makefile_id = Utils.Nan;
credentials.runconfiguration_id = Utils.Nan;
credentials.machine_id = Constants.Nan;
credentials.user_id = Constants.Nan;
credentials.compiler_id = Constants.Nan;
credentials.remotesapfor_id = Constants.Nan;
credentials.makefile_id = Constants.Nan;
credentials.runconfiguration_id = Constants.Nan;
Global.db.UpdateCredentials();
}
}