рефакторинг. переносил текущие объекты в другое место

This commit is contained in:
2024-10-13 22:08:13 +03:00
parent 09b64218bd
commit 6afa2dc892
240 changed files with 1472 additions and 1518 deletions

View File

@@ -2,6 +2,7 @@ package _VisualDVM.GlobalData.Compiler;
import Common.Utils.Utils_;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Global;
import _VisualDVM.Validators.DVMHelpParser;
import _VisualDVM.GlobalData.CompilerEnvironment.CompilerEnvironmentsSet;
import _VisualDVM.GlobalData.CompilerOption.CompilerOptionsSet;
@@ -85,7 +86,7 @@ public class Compiler extends iDBObject {
}
@Override
public boolean isVisible() {
return Current.HasMachine() && Current.getMachine().id == machine_id;
return Global.mainModule.matchCurrentID(Current.Machine, machine_id);
}
//todo понять как извлекать версию чтобы выдавать нормальную инфу.
@Override

View File

@@ -3,6 +3,7 @@ import Common.Utils.Utils_;
import Common.Visual.UI_;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import _VisualDVM.Global;
import _VisualDVM.Visual.UI;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.Utils;
@@ -101,7 +102,7 @@ public class CompilersDBTable extends iDBTable<Compiler> {
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.machine_id = Global.mainModule.getMachine().id;
Result.description = fields.tfDescription.getText();
Result.call_command = fields.tfCallCommand.getText();
Result.help_command = fields.tfHelpCommand.getText();

View File

@@ -4,6 +4,7 @@ import _VisualDVM.Current;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import Common.Visual.Windows.Dialog.VDirectoryChooser;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.Machine.MachineType;
import Visual_DVM_2021.Passes.PassCode;
@@ -31,13 +32,13 @@ public class CompilerFields implements DialogFields {
CompilerType type = (CompilerType) cbCompilerType.getSelectedItem();
if (type == CompilerType.dvm) {
String dst = null;
if (Current.getMachine().type.equals(MachineType.Local)) {
if (Global.mainModule.getMachine().type.equals(MachineType.Local)) {
File file = directoryChooser.ShowDialog();
if (file != null)
dst = file.getAbsolutePath();
} else {
if (Pass.passes.get(PassCode.SelectRemoteFile).Do(true))
dst = Current.getRemoteFile().full_name;
dst = Global.mainModule.getRemoteFile().full_name;
}
if (dst != null)
tfHome.setText(dst);

View File

@@ -86,8 +86,8 @@ public class DVMParameterDBTable extends iDBTable<DVMParameter> {
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.run_configuration_id = Current.getRunConfiguration().id;
Result.machine_id = Global.mainModule.getMachine().id;
Result.run_configuration_id = Global.mainModule.getRunConfiguration().id;
Result.name = (String) fields.cbName.getSelectedItem();
Result.value = fields.tfValue.getText();
}

View File

@@ -3,6 +3,7 @@ import Common.CommonConstants;
import Common.Utils.Utils_;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Global;
public class EnvironmentValue extends iDBObject {
public String name = "";
public String value = "";
@@ -10,7 +11,7 @@ public class EnvironmentValue extends iDBObject {
public int run_configuration_id = CommonConstants.Nan;
@Override
public boolean isVisible() {
return Current.HasRunConfiguration() && (run_configuration_id == Current.getRunConfiguration().id);
return Global.mainModule.matchCurrentID(Current.RunConfiguration, run_configuration_id);
}
@Override
public String toString() {

View File

@@ -53,8 +53,8 @@ public class EnvironmentValuesDBTable extends iDBTable<EnvironmentValue> {
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.run_configuration_id = Current.getRunConfiguration().id;
Result.machine_id = Global.mainModule.getMachine().id;
Result.run_configuration_id = Global.mainModule.getRunConfiguration().id;
Result.name = (String) fields.cbName.getSelectedItem();
Result.value = fields.tfValue.getText();
}

View File

@@ -84,11 +84,11 @@ public class GlobalDatabase extends VisualiserDatabase {
//---------------------------------------------------------------------------------
@Override
public void Init() throws Exception {
Current_.set(Current.Account,
Global.mainModule.set(Current.Account,
accounts.Data.isEmpty() ? Insert(new Account()) :
accounts.getFirstRecord()
);
Current_.set(Current.Credentials,
Global.mainModule.set(Current.Credentials,
credentials.Data.isEmpty() ? Insert(new Credentials()) :
credentials.getFirstRecord());
//настройки компонент
@@ -101,17 +101,17 @@ public class GlobalDatabase extends VisualiserDatabase {
}
public void SaveCredentials(){
try {
Credentials credentials = (Credentials) Current_.get(Current.Credentials);
if (Current.HasMachine())
credentials.machine_id = Current.getMachine().id;
if (Current.HasUser())
credentials.user_id = Current.getUser().id;
if (Current.HasCompiler())
credentials.compiler_id = Current.getCompiler().id;
if (Current.HasMakefile())
credentials.makefile_id = Current.getMakefile().id;
if (Current.HasRunConfiguration())
credentials.runconfiguration_id = Current.getRunConfiguration().id;
Credentials credentials = Global.mainModule.getCredentials();
if (Global.mainModule.HasMachine())
credentials.machine_id = Global.mainModule.getMachine().id;
if (Global.mainModule.HasUser())
credentials.user_id = Global.mainModule.getUser().id;
if (Global.mainModule.HasCompiler())
credentials.compiler_id = Global.mainModule.getCompiler().id;
if (Global.mainModule.HasMakefile())
credentials.makefile_id = Global.mainModule.getMakefile().id;
if (Global.mainModule.HasRunConfiguration())
credentials.runconfiguration_id = Global.mainModule.getRunConfiguration().id;
Update(credentials);
}
catch (Exception ex){
@@ -120,7 +120,7 @@ public class GlobalDatabase extends VisualiserDatabase {
}
public void UpdateCredentials() {
try {
Update((DBObject) Current_.get(Current.Credentials));
Update(Global.mainModule.getCredentials());
} catch (Exception ex) {
Utils_.MainLog.PrintException(ex);
}

View File

@@ -23,7 +23,7 @@ public class Makefile extends ModuleAnchestor {
}
@Override
public boolean isVisible() {
return Current.HasMachine() && (machine_id == Current.getMachine().id);
return Global.mainModule.matchCurrentID(Current.Machine, machine_id);
}
public LinkedHashMap<LanguageName, Module> getActiveModules() {
return Global.mainModule.getDb().getByFKAndGroupBy(this, Module.class, "language", LanguageName.class).values().stream().filter(Module::isSelected).collect(Collectors.toMap(module -> module.language, module -> module, (a, b) -> b, LinkedHashMap::new));
@@ -177,26 +177,26 @@ public class Makefile extends ModuleAnchestor {
Log.Writeln("Линковщик не выбран");
else {
if (linker.type.equals(CompilerType.dvm)) {
if (!Current.getProject().languageName.getDVMLink().equals(command))
if (!Global.mainModule.getProject().languageName.getDVMLink().equals(command))
Log.Writeln("команда линковки " +
Utils_.Quotes(command) +
" не соответствует языку текущего проекта "
+ Current.getProject().languageName.getDescription() + "\n" +
"Используйте команду " + Current.getProject().languageName.getDVMLink());
+ Global.mainModule.getProject().languageName.getDescription() + "\n" +
"Используйте команду " + Global.mainModule.getProject().languageName.getDVMLink());
}
}
LinkedHashMap<LanguageName, Module> modules = getModules();
for (Module module : modules.values()) {
boolean isMain = module.language.equals(Current.getProject().languageName);
boolean isMain = module.language.equals(Global.mainModule.getProject().languageName);
if (module.isSelected()) {
if (module.getCompiler() == null)
Log.Writeln("Не назначен компилятор для языка " + module.language.getDescription());
if (isMain && Current.getProject().getPrograms().get(module.language).isEmpty())
if (isMain && Global.mainModule.getProject().getPrograms().get(module.language).isEmpty())
Log.Writeln("В текущем проекте не найдено ни одной программы на языке " + module.language.getDescription());
} else {
if (isMain)
Log.Writeln("Языковой модуль, соответствующий языку текущего проекта " +
Current.getProject().languageName.getDescription() + " не помечен как активный.");
Global.mainModule.getProject().languageName.getDescription() + " не помечен как активный.");
}
}
}

View File

@@ -20,7 +20,7 @@ public class Module extends ModuleAnchestor {
}
@Override
public boolean isVisible() {
return Current.HasMakefile() && (makefile_id == Current.getMakefile().id);
return Global.mainModule.matchCurrentID(Current.Makefile, makefile_id);
}
@Override
public boolean isSelected() {

View File

@@ -3,6 +3,7 @@ import Common.Visual.UI_;
import _VisualDVM.Current;
import Common.Visual.Controls.StyledTextComboBox;
import Common.Visual.Windows.Dialog.DialogFields;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
@@ -27,7 +28,7 @@ public class ModuleAnchestorFields implements DialogFields {
//считаем что машина есть.
public ModuleAnchestorFields() {
//-
LinkedHashMap<Integer, Compiler> compilers = Current.getMachine().getCompilers();
LinkedHashMap<Integer, Compiler> compilers = Global.mainModule.getMachine().getCompilers();
compilers.values().forEach(compiler -> cbCompilers.addItem(compiler));
bHelp.addActionListener(e -> {
if (cbCompilers.getSelectedItem() != null) {
@@ -53,7 +54,7 @@ public class ModuleAnchestorFields implements DialogFields {
public void setListeners(ModuleAnchestor target) {
boolean linker = (target instanceof Makefile);
LanguageName languageName = linker ?
(Current.HasProject() ? Current.getProject().languageName : LanguageName.n) :
(Global.mainModule.HasProject() ? Global.mainModule.getProject().languageName : LanguageName.n) :
((Module) target).language;
cbCompilers.addActionListener(e -> {
if (cbCompilers.getSelectedItem() instanceof Compiler) {

View File

@@ -3,6 +3,7 @@ import Common.CommonConstants;
import Common.Visual.UI_;
import _VisualDVM.Current;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.Makefile.Makefile;
@@ -101,7 +102,7 @@ public class ModuleAnchestorForm<T extends ModuleAnchestor> extends DBObjectDial
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.machine_id = Global.mainModule.getMachine().id;
Compiler compiler = (Compiler) fields.cbCompilers.getSelectedItem();
Result.compiler_id = (compiler != null) ? compiler.id : CommonConstants.Nan;
Result.command = command;

View File

@@ -4,6 +4,7 @@ import Common.Utils.Utils_;
import Common.Visual.UI_;
import _VisualDVM.Current;
import Common.Visual.Windows.Dialog.Dialog;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import com.jcraft.jsch.ChannelSftp.LsEntry;
@@ -36,11 +37,11 @@ public class RemoteFileChooser extends Dialog<String, RemoteFileChooserFields> {
}
}
public void ShowCurrentRemoteFile() {
fields.lCurrentFile.setText(Current.getRemoteFile().full_name);
fields.lCurrentFile.setText(Global.mainModule.getRemoteFile().full_name);
}
public void Refresh(String path) {
try {
Current_.set(Current.RemoteFile, null);//сброс текущего файла перед любым обновлением.
Global.mainModule.set(Current.RemoteFile, null);//сброс текущего файла перед любым обновлением.
fields.lCurrentFile.setText("?");
//-------------------------------------------------------------------
root_file = new RemoteFile(path, true);
@@ -89,8 +90,8 @@ public class RemoteFileChooser extends Dialog<String, RemoteFileChooserFields> {
@Override
public void validateFields() {
String target_name = target_is_directory ? "папка" : "файл";
if (Current.HasRemoteFile()) {
if (target_is_directory != Current.getRemoteFile().isDirectory)
if (Global.mainModule.HasRemoteFile()) {
if (target_is_directory != Global.mainModule.getRemoteFile().isDirectory)
Log.Writeln("Выбранный объект - не " + target_name);
} else Log.Writeln(target_name + " не выбран(а)");
}

View File

@@ -2,6 +2,7 @@ package _VisualDVM.GlobalData.RemoteFile.UI;
import _VisualDVM.Current;
import Common.Visual.Trees.DataTree;
import Common.Visual.Trees.TreeRenderers;
import _VisualDVM.Global;
import _VisualDVM.Visual.UI;
public class RemoteFilesTree extends DataTree {
public RemoteFilesTree() {
@@ -21,8 +22,8 @@ public class RemoteFilesTree extends DataTree {
}
@Override
public void LeftMouseAction2() {
if (Current.HasRemoteFile() && Current.getRemoteFile().isDirectory()) {
UI.getRemoteFileChooser().Refresh(Current.getRemoteFile().full_name);
if (Global.mainModule.HasRemoteFile() && Global.mainModule.getRemoteFile().isDirectory()) {
UI.getRemoteFileChooser().Refresh(Global.mainModule.getRemoteFile().full_name);
}
}
}

View File

@@ -183,7 +183,7 @@ public class RunConfiguration extends iDBObject {
}
@Override
public boolean isVisible() {
return Current.HasMachine() && (machine_id == Current.getMachine().id);
return Global.mainModule.matchCurrentID(Current.Machine, machine_id);
}
@Override
public String getFKName() {

View File

@@ -65,11 +65,11 @@ public class RunConfigurationsDBTable extends iDBTable<RunConfiguration> {
fields.maxMatrixPanel.add(fields.maxMatrixBar = new MatrixBar(Result.maxMatrix));
//------------------------------------------->>>
if (!edit)
fields.sMaxDim.setValue(Current.getProject().maxdim);
fields.sMaxDim.setValue(Global.mainModule.getProject().maxdim);
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.machine_id = Global.mainModule.getMachine().id;
Result.LauncherCall = fields.cbLauncherCall.getSelectedItem().toString();
Result.LauncherOptions = (String) fields.cbLaunchOptions.getSelectedItem();
if (fields.cbLauncherCall.getSelectedItem() instanceof Compiler) {

View File

@@ -2,6 +2,7 @@ package _VisualDVM.GlobalData.SapforProfileSetting;
import Common.CommonConstants;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Settings.SettingName;
import com.sun.org.glassfish.gmbal.Description;
public class SapforProfileSetting extends iDBObject {
@@ -13,6 +14,6 @@ public class SapforProfileSetting extends iDBObject {
public int sapforprofile_id = CommonConstants.Nan;
@Override
public boolean isVisible() {
return Current.HasSapforProfile() && Current.getSapforProfile().id == sapforprofile_id;
return Global.mainModule.matchCurrentID(Current.SapforProfile, sapforprofile_id);
}
}

View File

@@ -74,10 +74,10 @@ public class CompilationTask extends Task {
@Override
public boolean isVisible() {
return
Current_.matchCurrentID(Current.Machine, machine_id) &&
Current_.matchCurrentID(Current.User, user_id) &&
Current.HasProject() &&
belongsToProject(Current.getProject());
Global.mainModule.matchCurrentID(Current.Machine, machine_id) &&
Global.mainModule.matchCurrentID(Current.User, user_id) &&
Global.mainModule.HasProject() &&
belongsToProject(Global.mainModule.getProject());
}
public Makefile getMakefile() {
return Global.mainModule.getDb().getById(Makefile.class, makefile_id);

View File

@@ -1,6 +1,7 @@
package _VisualDVM.GlobalData.Tasks.Passes;
import Common.Utils.Utils_;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Tasks.Supervisor.TaskSupervisor;
import Visual_DVM_2021.Passes.ProcessPass;
public abstract class TaskLocalPass<S extends TaskSupervisor> extends ProcessPass {
@@ -26,6 +27,6 @@ public abstract class TaskLocalPass<S extends TaskSupervisor> extends ProcessPas
}
@Override
public void Interrupt() throws Exception {
Current.getProject().CreateInterruptFile();
Global.mainModule.getProject().CreateInterruptFile();
}
}

View File

@@ -53,13 +53,13 @@ public class RunTask extends Task {
@Override
public boolean isVisible() {
return
Current_.matchCurrentID(Current.Machine, machine_id) &&
Current_.matchCurrentID(Current.User, user_id) &&
Current_.matchCurrentID(Current.RunConfiguration, run_configuration_id) &&
Current.HasProject() &&
belongsToProject(Current.getProject()) &&
Current.HasCompilationTask() &&
compilation_task_id == Current.getCompilationTask().id;
Global.mainModule.matchCurrentID(Current.Machine, machine_id) &&
Global.mainModule.matchCurrentID(Current.User, user_id) &&
Global.mainModule.matchCurrentID(Current.RunConfiguration, run_configuration_id) &&
Global.mainModule.HasProject() &&
belongsToProject(Global.mainModule.getProject()) &&
Global.mainModule.HasCompilationTask() &&
compilation_task_id == Global.mainModule.getCompilationTask().id;
}
public RunConfiguration getRunConfiguration() {
return (Global.mainModule.getDb()).runConfigurations.Data.get(run_configuration_id);

View File

@@ -1,5 +1,6 @@
package _VisualDVM.GlobalData.Tasks.Supervisor.Local.Linux;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import java.util.Map;
@@ -16,7 +17,7 @@ public class LinuxLocalRunSupervisor extends LinuxLocalTaskSupervisor<RunTask> {
}
@Override
protected Map<String, String> getEnvs() {
return Current.getRunConfiguration().getEnvMap();
return Global.mainModule.getRunConfiguration().getEnvMap();
}
@Override
protected String getScriptText() {

View File

@@ -1,5 +1,6 @@
package _VisualDVM.GlobalData.Tasks.Supervisor.Local.Windows;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import java.util.Map;
@@ -25,7 +26,7 @@ public class WindowsLocalRunSupervisor extends WindowsLocalTaskSupervisor<RunTas
}
@Override
protected Map<String, String> getEnvs() {
return Current.getRunConfiguration().getEnvMap();
return Global.mainModule.getRunConfiguration().getEnvMap();
}
void kill_mpi() throws Exception {
}

View File

@@ -1,6 +1,7 @@
package _VisualDVM.GlobalData.Tasks.Supervisor.Remote;
import Common.Utils.Utils_;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
import _VisualDVM.GlobalData.Tasks.QueueSystem.MVS;
import _VisualDVM.GlobalData.Tasks.TaskState;
@@ -29,7 +30,7 @@ public class MVSRunSupervisor extends ServerRunSupervisor {
}
@Override
protected void StartTask() throws Exception {
String env = String.join(" ", Current.getRunConfiguration().getEnvList());
String env = String.join(" ", Global.mainModule.getRunConfiguration().getEnvList());
mvs_time = (task.maxtime / 60); //в минутах
if (task.maxtime % 60 > 0) mvs_time += 1;
String res = "maxtime=" + Utils_.DQuotes(mvs_time) + " ./run";

View File

@@ -1,5 +1,6 @@
package _VisualDVM.GlobalData.Tasks.Supervisor.Remote;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
@@ -14,7 +15,7 @@ public class ServerRunSupervisor extends RemoteTaskSupervisor<RunTask> {
@Override
protected void StartTask() throws Exception {
String res = "./run";
String env = String.join(" ", Current.getRunConfiguration().getEnvList());
String env = String.join(" ", Global.mainModule.getRunConfiguration().getEnvList());
if (!env.isEmpty()) res = env + " " + res;
//--
task.PID = pass.user.connection.startShellProcess(getRemoteProject(),"PID",

View File

@@ -2,6 +2,7 @@ package _VisualDVM.GlobalData.User;
import Common.CommonConstants;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.TestingSystem.DVM.UserConnection;
import com.sun.org.glassfish.gmbal.Description;
@@ -38,7 +39,7 @@ public class User extends iDBObject {
}
@Override
public boolean isVisible() {
return Current.HasMachine() && Current.getMachine().id == machine_id;
return Global.mainModule.matchCurrentID(Current.Machine, machine_id);
}
@Override
public String getDialogName() {

View File

@@ -2,6 +2,7 @@ package _VisualDVM.GlobalData.User;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import Common.Visual.Tables.TableRenderers;
import _VisualDVM.Global;
import _VisualDVM.Visual.UI;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import Common.Database.Objects.DBObject;
@@ -43,7 +44,7 @@ public class UsersDBTable extends iDBTable<User> {
}
@Override
public void fillFields() {
if (Current.getMachine().type.equals(MachineType.Local)) {
if (Global.mainModule.getMachine().type.equals(MachineType.Local)) {
Result.login = "этот пользователь";
fields.tfLogin.setEditable(false);
}
@@ -58,7 +59,7 @@ public class UsersDBTable extends iDBTable<User> {
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.machine_id =Global.mainModule.getMachine().id;
Result.login = fields.tfLogin.getText();
Result.authentication = UserAuthentication.password;
Result.password = new String(fields.tfPassword.getPassword());