no message

This commit is contained in:
2024-10-09 22:21:57 +03:00
parent 54c80c516b
commit 6252af944e
699 changed files with 2634 additions and 1997 deletions

View File

@@ -1,25 +1,25 @@
package _VisualDVM;
import Common.CurrentAnchestor;
import GlobalData.Account.Account;
import GlobalData.Compiler.Compiler;
import GlobalData.Machine.Machine;
import GlobalData.Makefile.Makefile;
import GlobalData.Module.Module;
import GlobalData.RemoteFile.RemoteFile;
import GlobalData.RunConfiguration.RunConfiguration;
import GlobalData.Tasks.CompilationTask.CompilationTask;
import GlobalData.Tasks.RunTask.RunTask;
import GlobalData.User.User;
import ProjectData.Files.DBProjectFile;
import ProjectData.Project.db_project_info;
import ProjectData.SapforData.Functions.FuncInfo;
import ProjectData.SapforData.Regions.ParallelRegion;
import Repository.BugReport.BugReport;
import Repository.Subscribes.Subscriber;
import TestingSystem.Common.Test.Test;
import TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.SapforSettings.SapforSettings;
import _VisualDVM.GlobalData.Account.Account;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import _VisualDVM.GlobalData.User.User;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.Project.db_project_info;
import _VisualDVM.ProjectData.SapforData.Functions.FuncInfo;
import _VisualDVM.ProjectData.SapforData.Regions.ParallelRegion;
import _VisualDVM.Repository.BugReport.BugReport;
import _VisualDVM.Repository.Subscribes.Subscriber;
import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings;
import Visual_DVM_2021.Passes.UI.PassForm;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -258,10 +258,10 @@ public enum Current implements CurrentAnchestor {
public static DBProjectFile getFile() {
return (DBProjectFile) CurrentAnchestor.get(File);
}
public static Repository.Component.Component getComponent() {
return (Repository.Component.Component) CurrentAnchestor.get(Component);
public static _VisualDVM.Repository.Component.Component getComponent() {
return (_VisualDVM.Repository.Component.Component) CurrentAnchestor.get(Component);
}
public static Repository.BugReport.BugReport getBugReport() {
public static _VisualDVM.Repository.BugReport.BugReport getBugReport() {
return (BugReport) CurrentAnchestor.get(BugReport);
}
public static db_project_info getRoot() {
@@ -279,7 +279,7 @@ public enum Current implements CurrentAnchestor {
public static boolean HasSubscriber() {
return CurrentAnchestor.get(Current.Subscriber) != null;
}
public static Repository.Subscribes.Subscriber getSubscriber() {
public static _VisualDVM.Repository.Subscribes.Subscriber getSubscriber() {
return (Subscriber) CurrentAnchestor.get(Current.Subscriber);
}
public static Machine getMachine() {
@@ -309,14 +309,14 @@ public enum Current implements CurrentAnchestor {
public static RunConfiguration getRunConfiguration() {
return (RunConfiguration) CurrentAnchestor.get(Current.RunConfiguration);
}
public static Repository.Component.Sapfor.Sapfor getSapfor() {
return (Repository.Component.Sapfor.Sapfor) CurrentAnchestor.get(Current.Sapfor);
public static _VisualDVM.Repository.Component.Sapfor.Sapfor getSapfor() {
return (_VisualDVM.Repository.Component.Sapfor.Sapfor) CurrentAnchestor.get(Current.Sapfor);
}
public static boolean HasGroup() {
return CurrentAnchestor.get(Current.Group) != null;
}
public static TestingSystem.Common.Group.Group getGroup() {
return (TestingSystem.Common.Group.Group) CurrentAnchestor.get(Current.Group);
public static _VisualDVM.TestingSystem.Common.Group.Group getGroup() {
return (_VisualDVM.TestingSystem.Common.Group.Group) CurrentAnchestor.get(Current.Group);
}
public static boolean HasConfiguration() {
return CurrentAnchestor.get(Current.DVMConfiguration) != null;
@@ -325,10 +325,10 @@ public enum Current implements CurrentAnchestor {
return (DVMConfiguration) CurrentAnchestor.get(Current.DVMConfiguration);
}
public static SapforConfiguration getSapforConfiguration() {
return (TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration) CurrentAnchestor.get(Current.SapforConfiguration);
return (_VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration) CurrentAnchestor.get(Current.SapforConfiguration);
}
public static Test getTest() {
return (TestingSystem.Common.Test.Test) CurrentAnchestor.get(Current.Test);
return (_VisualDVM.TestingSystem.Common.Test.Test) CurrentAnchestor.get(Current.Test);
}
public static boolean HasTest() {
return CurrentAnchestor.get(Current.Test) != null;
@@ -394,43 +394,43 @@ public enum Current implements CurrentAnchestor {
public static boolean HasSapforConfiguration() {
return CurrentAnchestor.get(Current.SapforConfiguration) != null;
}
public static ProjectData.ProjectView getProjectView() {
return (ProjectData.ProjectView) CurrentAnchestor.get(ProjectView);
public static _VisualDVM.ProjectData.ProjectView getProjectView() {
return (_VisualDVM.ProjectData.ProjectView) CurrentAnchestor.get(ProjectView);
}
public static boolean HasSapforProfile() {
return CurrentAnchestor.get(Current.SapforProfile) != null;
}
public static GlobalData.SapforProfile.SapforProfile getSapforProfile() {
return (GlobalData.SapforProfile.SapforProfile) CurrentAnchestor.get(Current.SapforProfile);
public static _VisualDVM.GlobalData.SapforProfile.SapforProfile getSapforProfile() {
return (_VisualDVM.GlobalData.SapforProfile.SapforProfile) CurrentAnchestor.get(Current.SapforProfile);
}
public static boolean HasServerSapfor() {
return CurrentAnchestor.get(Current.ServerSapfor) != null;
}
public static TestingSystem.SAPFOR.ServerSapfor.ServerSapfor getServerSapfor() {
return (TestingSystem.SAPFOR.ServerSapfor.ServerSapfor) CurrentAnchestor.get(Current.ServerSapfor);
public static _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor getServerSapfor() {
return (_VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor) CurrentAnchestor.get(Current.ServerSapfor);
}
public static boolean HasSubscriberWorkspace() {
return CurrentAnchestor.get(Current.SubscriberWorkspace) != null;
}
public static Repository.SubscriberWorkspace.SubscriberWorkspace getSubscriberWorkspace() {
return (Repository.SubscriberWorkspace.SubscriberWorkspace) CurrentAnchestor.get(Current.SubscriberWorkspace);
public static _VisualDVM.Repository.SubscriberWorkspace.SubscriberWorkspace getSubscriberWorkspace() {
return (_VisualDVM.Repository.SubscriberWorkspace.SubscriberWorkspace) CurrentAnchestor.get(Current.SubscriberWorkspace);
}
public static boolean HasDVMPackage() {
return CurrentAnchestor.get(Current.DVMPackage) != null;
}
public static TestingSystem.DVM.DVMPackage.DVMPackage getDVMPackage() {
return (TestingSystem.DVM.DVMPackage.DVMPackage) CurrentAnchestor.get(Current.DVMPackage);
public static _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage getDVMPackage() {
return (_VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage) CurrentAnchestor.get(Current.DVMPackage);
}
public static boolean HasSapforPackage() {
return CurrentAnchestor.get(Current.SapforPackage) != null;
}
public static TestingSystem.SAPFOR.SapforPackage.SapforPackage getSapforPackage() {
return (TestingSystem.SAPFOR.SapforPackage.SapforPackage) CurrentAnchestor.get(Current.SapforPackage);
public static _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage getSapforPackage() {
return (_VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage) CurrentAnchestor.get(Current.SapforPackage);
}
public static boolean HasDVMRunTask() {
return CurrentAnchestor.get(Current.DVMRunTask) != null;
}
public static TestingSystem.DVM.DVMTasks.DVMRunTask getDVMRunTask() {
return (TestingSystem.DVM.DVMTasks.DVMRunTask) CurrentAnchestor.get(Current.DVMRunTask);
public static _VisualDVM.TestingSystem.DVM.DVMTasks.DVMRunTask getDVMRunTask() {
return (_VisualDVM.TestingSystem.DVM.DVMTasks.DVMRunTask) CurrentAnchestor.get(Current.DVMRunTask);
}
}

View File

@@ -5,22 +5,22 @@ import Common.Mode;
import Common.Utils.CommonUtils;
import Common.Utils.Loggable;
import Common.Visual.CommonUI;
import GlobalData.Account.Account;
import GlobalData.Account.AccountRole;
import GlobalData.GlobalDatabase;
import GlobalData.Settings.DBSetting;
import GlobalData.Settings.SettingName;
import ProjectData.ProjectView;
import Repository.Component.*;
import Repository.Component.PerformanceAnalyzer.PerformanceAnalyzer;
import Repository.Component.Sapfor.MessagesServer;
import Repository.Component.Sapfor.Sapfor_F;
import Repository.Component.Sapfor.TransformationPermission;
import Repository.Server.ComponentsServer;
import TestingSystem.Common.TestingServer;
import TestingSystem.DVM.LocalDVMTestingPlanner;
import TestingSystem.DVM.RemoteDVMTestingPlanner;
import TestingSystem.SAPFOR.PackageModeSupervisor;
import _VisualDVM.GlobalData.Account.Account;
import _VisualDVM.GlobalData.Account.AccountRole;
import _VisualDVM.GlobalData.GlobalDatabase;
import _VisualDVM.GlobalData.Settings.DBSetting;
import _VisualDVM.GlobalData.Settings.SettingName;
import _VisualDVM.ProjectData.ProjectView;
import _VisualDVM.Repository.Component.*;
import _VisualDVM.Repository.Component.PerformanceAnalyzer.PerformanceAnalyzer;
import _VisualDVM.Repository.Component.Sapfor.MessagesServer;
import _VisualDVM.Repository.Component.Sapfor.Sapfor_F;
import _VisualDVM.Repository.Component.Sapfor.TransformationPermission;
import _VisualDVM.Repository.Server.ComponentsServer;
import _VisualDVM.TestingSystem.Common.TestingServer;
import _VisualDVM.TestingSystem.DVM.LocalDVMTestingPlanner;
import _VisualDVM.TestingSystem.DVM.RemoteDVMTestingPlanner;
import _VisualDVM.TestingSystem.SAPFOR.PackageModeSupervisor;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import _VisualDVM.Visual.Syntax.LightSPFEditorTheme;

View File

@@ -0,0 +1,70 @@
package _VisualDVM.GlobalData.Account;
import Common.Database.Objects.DBObject;
import _VisualDVM.Visual.UI;
import Common.Utils.TextLog;
import _VisualDVM.Repository.BugReport.BugReport;
import com.sun.org.glassfish.gmbal.Description;
public class Account extends DBObject {
@Description("PRIMARY KEY,NOT NULL")
public int id = 0;
public String name = "?";
public String email = "?";
//--
@Description("IGNORE")
public AccountRole role = AccountRole.Undefined; //роль незареганного пользователя
//--
public boolean CheckRegistered(TextLog Log) {
if (role.equals(AccountRole.Undefined)) {
if (Log != null) {
Log.Writeln("Пользователь не зарегистрирован");
if (UI.HasMainWindow())
UI.getMainWindow().FocusCallback();
}
return false;
}
return true;
}
public boolean isRegistered() {
return !role.equals(AccountRole.Undefined);
}
public boolean CheckAuthorship(String address_in, TextLog log) {
if (!isAdmin() && (!email.equals(address_in))) {
if (log != null)
log.Writeln_("Вы не являетесь автором или администратором");
return false;
}
return true;
}
public boolean CheckAccessRights(String address_in, TextLog log) {
return (CheckRegistered(log) && CheckAuthorship(address_in, log));
}
public boolean ExtendedCheckAccessRights(BugReport bugReport, TextLog log) {
if (CheckRegistered(log)) {
if (email.equals(bugReport.executor_address)) {
//исполнитель.
return true;
} else {
if (!isAdmin() && (!email.equals(bugReport.sender_address))) {
log.Writeln_("Вы не являетесь автором, исполнителем, или администратором");
return false;
} else return true;
}
}
return false;
}
public boolean isAdmin() {
return role.equals(AccountRole.Admin);
}
public boolean CheckAdmin(TextLog log){
if (!isAdmin()){
log.Writeln_("Вы не являетесь администратором!");
return false;
}
return true;
}
@Override
public Object getPK() {
return id;
}
}

View File

@@ -0,0 +1,22 @@
package _VisualDVM.GlobalData.Account;
public enum AccountRole {
Undefined,
User,
Developer,
Admin;
public String getDescription() {
switch (this) {
case Undefined:
return "не зарегистрирован";
case User:
return "Пользователь";
case Developer:
return "Разработчик";
case Admin:
return "Администратор";
default:
break;
}
return "";
}
}

View File

@@ -0,0 +1,19 @@
package _VisualDVM.GlobalData.Account;
public enum AccountSubscribeState {
Undefined,
None,
Active;
public String getDescription() {
switch (this) {
case Undefined:
return "Подписка: нет данных";
case None:
return "Подписка: аннулирована";
case Active:
return "Подписка: активна";
default:
break;
}
return "";
}
}

View File

@@ -0,0 +1,11 @@
package _VisualDVM.GlobalData.Account;
import Common.Database.Tables.DBTable;
public class AccountsDBTable extends DBTable<Integer, Account> {
public AccountsDBTable() {
super(Integer.class, Account.class);
}
@Override
public String getSingleDescription() {
return "аккаунт";
}
}

View File

@@ -0,0 +1,193 @@
package _VisualDVM.GlobalData.Compiler;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Validators.DVMHelpParser;
import _VisualDVM.GlobalData.CompilerEnvironment.CompilerEnvironmentsSet;
import _VisualDVM.GlobalData.CompilerOption.CompilerOptionsSet;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.LanguageName;
import com.sun.org.glassfish.gmbal.Description;
public class Compiler extends iDBObject {
public int machine_id = -1;
public String description = "";
public CompilerType type = CompilerType.dvm;
public String home_path = ""; //домашняя папка. нужна для двм компиляторов, в теории и для остальных может сгодиться, например для установки окружения ifort под виндой
public String call_command = ""; //непосредственно вызов компилятора.
public String version_command = "";//команда запроса версии компилятора.
public String help_command = "";// команда запроса help
public String version = "?";
public String revision = "?";
//-
@Description("IGNORE")
public boolean helpLoaded = false;
@Description("IGNORE")
public String helpText = "";
//-
@Description("IGNORE")
public boolean versionLoaded = false;
@Description("IGNORE")
public String versionText = "";
//-
public CompilerOptionsSet options = new CompilerOptionsSet();
public CompilerEnvironmentsSet environments = new CompilerEnvironmentsSet();
//-
public Compiler() {
}
public Compiler(Machine machine,
String description_in,
CompilerType type_in,
String call_command_in,
String version_command_in,
String help_command_in
) {
machine_id = machine.id;
description = description_in;
type = type_in;
call_command = call_command_in;
version_command = version_command_in;
help_command = help_command_in;
}
public void ResetHelp() {
helpLoaded = false;
helpText = "";
options.clear();
environments.clear();
}
public void ResetVersion() {
versionLoaded = false;
versionText = "";
}
public void ParseHelp() {
switch (type) {
case dvm:
DVMHelpParser.ReadOptions(this);
break;
default:
break;
}
}
public void ParseVersion() {
switch (type) {
case dvm:
String [] lines = versionText.split("\n");
if (lines.length>=3) {
String[] data = lines[2].split(" ");
if (data.length >= 4)
version = data[3].replace(",", "");
if (data.length >= 7) revision = data[6].replace(",", "");
}
break;
default:
break;
}
}
@Override
public boolean isVisible() {
return Current.HasMachine() && Current.getMachine().id == machine_id;
}
//todo понять как извлекать версию чтобы выдавать нормальную инфу.
@Override
public String toString() {
return call_command;
}
public String getStyleOptions(DBProjectFile program) {
String res = "";
switch (type) {
case gnu:
switch (program.languageName) {
case fortran:
switch (program.style) {
case free:
res = "-ffree-form";
break;
case extended:
res = "-ffixed-line-length-132";
break;
case fixed:
res = "-ffixed-form";
break;
case none:
break;
}
break;
}
break;
case dvm:
switch (program.languageName) {
case fortran:
switch (program.style) {
case fixed:
case extended:
res = "-FI";
break;
case free:
res = "-f90";
break;
case none:
break;
}
break;
}
break;
case intel:
switch (program.languageName) {
case fortran:
switch (program.style) {
case fixed:
case extended:
res = "-fixed";
break;
case free:
res = "-free";
break;
case none:
break;
}
break;
}
break;
}
return res;
}
//todo как то извлекать/заполнять версии компилятора?
public String getDescription() {
return description;
}
public String getSpecialLinkCommand(LanguageName languageName) {
switch (type) {
case dvm:
switch (languageName) {
case fortran:
return "flink";
case c:
return "clink";
}
break;
}
return "";
}
public String getSpecialCompilationCommand(LanguageName languageName) {
switch (type) {
case dvm:
switch (languageName) {
case fortran:
return "f";
case c:
return "c";
}
break;
}
return "";
}
public String getHelpCommand() {
return CommonUtils.DQuotes(call_command) + " " + help_command;
}
public String getVersionCommand() {
return CommonUtils.DQuotes(call_command) + " " + version_command;
}
public String getVersionInfo(){
return "v="+version+" r="+revision;
}
}

View File

@@ -0,0 +1,9 @@
package _VisualDVM.GlobalData.Compiler;
public enum CompilerType {
Undefined,
//----------------------
dvm,
mpi,
gnu,
intel
}

View File

@@ -0,0 +1,159 @@
package _VisualDVM.GlobalData.Compiler;
import Common.Utils.CommonUtils;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import _VisualDVM.Visual.UI;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.Utils;
import _VisualDVM.Validators.PathValidator;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import _VisualDVM.GlobalData.Compiler.UI.CompilerFields;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import java.util.LinkedHashMap;
public class CompilersDBTable extends iDBTable<Compiler> {
public CompilersDBTable() {
super(Compiler.class);
}
@Override
public String getSingleDescription() {
return "компилятор";
}
@Override
public String getPluralDescription() {
return "компиляторы";
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(Makefile.class, new FKBehaviour(FKDataBehaviour.DROP, FKCurrentObjectBehaviuor.PASSIVE));
res.put(Module.class, new FKBehaviour(FKDataBehaviour.DROP, FKCurrentObjectBehaviuor.PASSIVE));
res.put(RunConfiguration.class, new FKBehaviour(FKDataBehaviour.DROP, FKCurrentObjectBehaviuor.PASSIVE));
return res;
}
@Override
public DBObjectDialog<Compiler, CompilerFields> getDialog() {
return new DBObjectDialog<Compiler, CompilerFields>(CompilerFields.class) {
@Override
public void validateFields() {
//<editor-fold desc="расположение">
String home = fields.tfHome.getText();
if (!home.isEmpty()) {
if (home.startsWith("/")) {
if (CommonUtils.ContainsCyrillic(home))
Log.Writeln("Расположение компилятора не может содержать кириллицу");
else {
new PathValidator(home, "Расположение компилятора", Log).Validate();
}
} else
Log.Writeln("Расположение компилятора может быть либо пустой строкой, либо путём к файлу");
}
//</editor-fold>
//<editor-fold desc="команда вызова">
String call_command = fields.tfCallCommand.getText();
if (call_command.isEmpty())
Log.Writeln("Команда вызова компилятора не может быть пустой");
else if (CommonUtils.ContainsCyrillic(call_command))
Log.Writeln("Команда вызова компилятора не может содержать кириллицу");
else {
switch (call_command.charAt(0)) {
case ' ':
Log.Writeln("Команда вызова компилятора не может начинаться с пробела.");
break;
case '/':
if (call_command.endsWith("/"))
Log.Writeln("Каталог не может быть указан в качестве команды.");
else
new PathValidator(call_command, "Команда вызова компилятора", Log).Validate();
break;
default:
//это команда.
//самое опасное место. теоретически тут можно ввести любую команду ОС, в том числе rm -rf
if (call_command.contains(" "))
Log.Writeln("Прямая команда вызова не может содержать пробелы");
if (!call_command.contains("+")&& CommonUtils.ContainsForbiddenName(call_command))
Log.Writeln("Прямая команда вызова содержит запрещённые символы");
else {
if (Utils.isLinuxSystemCommand(call_command))
Log.Writeln(CommonUtils.DQuotes(call_command) + " является системной командой Linux");
}
break;
}
}
//</editor-fold>
}
@Override
public void fillFields() {
fields.tfDescription.setText(Result.description);
fields.tfCallCommand.setText(Result.call_command);
fields.tfHelpCommand.setText(Result.help_command);
fields.tfVersionCommand.setText(Result.version_command);
fields.tfHome.setText(Result.home_path);
CommonUI.TrySelect(fields.cbCompilerType, Result.type);
fields.events_on = true;
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.description = fields.tfDescription.getText();
Result.call_command = fields.tfCallCommand.getText();
Result.help_command = fields.tfHelpCommand.getText();
Result.version_command = fields.tfVersionCommand.getText();
Result.home_path = fields.tfHome.getText();
Result.type = (CompilerType) fields.cbCompilerType.getSelectedItem();
}
@Override
public int getDefaultHeight() {
return 300;
}
};
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{"описание", "команда вызова", "версия", "ревизия"};
}
@Override
public Object getFieldAt(Compiler object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.description;
case 2:
return object.call_command;
case 3:
return object.version;
case 4:
return object.revision;
}
return null;
}
@Override
public Current CurrentName() {
return Current.Compiler;
}
}

View File

@@ -0,0 +1,13 @@
package _VisualDVM.GlobalData.Compiler;
import Common.Visual.Menus.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class CompilersMenuBar extends DataMenuBar {
public CompilersMenuBar() {
super("компиляторы",
PassCode_2021.AddCompiler,
PassCode_2021.EditCompiler,
PassCode_2021.DeleteCompiler,
PassCode_2021.ShowCompilerVersion,
PassCode_2021.ShowCompilerHelp);
}
}

View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.Compiler.UI.CompilerFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="87831" class="javax.swing.JTextField" binding="tfHome" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<vspacer id="44b33">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="627cc" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="расположение"/>
</properties>
</component>
<component id="48916" class="javax.swing.JButton" binding="bBrowse">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<icon value="icons/LastOpened.png"/>
<text value=""/>
</properties>
</component>
<component id="d58a0" class="javax.swing.JTextField" binding="tfCallCommand" custom-create="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="f3f87" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="команда вызова"/>
</properties>
</component>
<component id="87234" class="javax.swing.JTextField" binding="tfDescription" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="d1e8b" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="описание"/>
</properties>
</component>
<component id="ac56f" class="javax.swing.JTextField" binding="tfVersionCommand" custom-create="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="34097" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="запрос версии"/>
</properties>
</component>
<component id="b2235" class="javax.swing.JTextField" binding="tfHelpCommand" custom-create="true">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="8982d" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="запрос help"/>
</properties>
</component>
<component id="19a71" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="тип"/>
</properties>
</component>
<component id="673a2" class="javax.swing.JComboBox" binding="cbCompilerType" custom-create="true">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<toolTipText value="выберите тип компилятора"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,93 @@
package _VisualDVM.GlobalData.Compiler.UI;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import Common.Visual.Windows.Dialog.VDirectoryChooser;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.Machine.MachineType;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.io.File;
import java.util.Objects;
public class CompilerFields implements DialogFields {
public JPanel content;
public JTextField tfHome;
public JButton bBrowse;
public JTextField tfDescription;
public JTextField tfCallCommand;
public JTextField tfVersionCommand;
public JTextField tfHelpCommand;
public JComboBox<CompilerType> cbCompilerType;
public boolean events_on = false;
VDirectoryChooser directoryChooser = new VDirectoryChooser("Выбор домашней папки dvm системы");
public CompilerFields() {
bBrowse.addActionListener(e -> {
CompilerType type = (CompilerType) cbCompilerType.getSelectedItem();
if (type == CompilerType.dvm) {
String dst = null;
if (Current.getMachine().type.equals(MachineType.Local)) {
File file = directoryChooser.ShowDialog();
if (file != null)
dst = file.getAbsolutePath();
} else {
if (Pass_2021.passes.get(PassCode_2021.SelectRemoteFile).Do(true))
dst = Current.getRemoteFile().full_name;
}
if (dst != null)
tfHome.setText(dst);
} else
CommonUI.Info("Назначение домашней папки поддерживается только для dvm системы.");
});
tfHome.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void removeUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void changedUpdate(DocumentEvent e) {
}
}
);
cbCompilerType.addActionListener(e -> {
if (Objects.requireNonNull(cbCompilerType.getSelectedItem()) == CompilerType.dvm) {
tfVersionCommand.setText("ver");
tfHelpCommand.setText("help");
} else {
tfVersionCommand.setText("--version");
tfHelpCommand.setText("--help");
}
});
}
public void TryRestoreCallCommand() {
if (events_on && (cbCompilerType.getSelectedItem() != null) && cbCompilerType.getSelectedItem().equals(CompilerType.dvm))
tfCallCommand.setText(tfHome.getText() +
(tfHome.getText().endsWith("/") ? "" : "/") +
"bin/dvm_drv");
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfDescription = new StyledTextField();
tfHome = new StyledTextField();
tfCallCommand = new StyledTextField();
tfVersionCommand = new StyledTextField();
tfHelpCommand = new StyledTextField();
cbCompilerType = new JComboBox<>();
cbCompilerType.addItem(CompilerType.dvm);
cbCompilerType.addItem(CompilerType.intel);
cbCompilerType.addItem(CompilerType.gnu);
}
@Override
public Component getContent() {
return content;
}
}

View File

@@ -0,0 +1,76 @@
package _VisualDVM.GlobalData.CompilerEnvironment;
import Common.Database.Objects.DBObject;
import Common.Utils.TextLog;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Vector;
public class CompilerEnvironment extends DBObject {
@Description("PRIMARY KEY, UNIQUE")
public String name = "";
public String value = "";
public EnvironmentValueType type = EnvironmentValueType.String;
public Vector<String> valueVariants = new Vector<>();
public Vector<String> description = new Vector<>();
@Override
public Object getPK() {
return name;
}
public void CheckDefaults() {
//определить тип. в dvm переменных он может быть указан в начале 1 строки.
if (!description.isEmpty()) {
String line = description.get(0);
if (line.startsWith("Boolean value.")) {
type = EnvironmentValueType.Boolean;
valueVariants.add("0");
valueVariants.add("1");
} else if (line.startsWith("Integer value.")) {
type = EnvironmentValueType.Integer;
} else if (line.startsWith("Real number.")) {
type = EnvironmentValueType.Real;
}
//-
if (line.endsWith("Accepted values:")) {
// все что дальше - варианты и их описания после запятой.
for (int i = 1; i < description.size(); ++i) {
String[] data = description.get(i).split(",");
if (data.length > 1)
valueVariants.add(data[0]);
}
}
}
}
public void validate(TextLog log, String new_value) {
if (new_value.isEmpty()) {
log.Writeln_("Переменная не предполагает пустого значения");
} else {
if (!valueVariants.isEmpty()) {
if (!valueVariants.contains(new_value))
log.Writeln_("Переменная : недопустимое значение. Выберите доступный вариант.");
}
switch (type) {
case Boolean:
if (!valueVariants.contains(new_value))
log.Writeln_("Переменная допускает только 0 или 1 в качестве значений");
break;
case Integer:
try {
Integer.parseInt(new_value);
} catch (NumberFormatException ex) {
log.Writeln_("Переменная допускает только целочисленные значения");
}
break;
case Real:
try {
Double.parseDouble(new_value);
} catch (NumberFormatException ex) {
log.Writeln_("Переменная допускает только числа с плавающей запятой в качестве значения");
}
break;
case String:
if (new_value.contains("\""))
log.Writeln_("Переменная не может содержать двойные кавычки в значении");
break;
}
}
}
}

View File

@@ -0,0 +1,45 @@
package _VisualDVM.GlobalData.CompilerEnvironment;
import Common.Database.Tables.DataSet;
import Common.Visual.DataSetControlForm;
import Common.Visual.Tables.TableEditors;
import Common.Visual.Tables.TableRenderers;
import static Common.Visual.Tables.TableRenderers.RendererMultiline;
public class CompilerEnvironmentsSet extends DataSet<String, CompilerEnvironment> {
public CompilerEnvironmentsSet() {
super(String.class, CompilerEnvironment.class);
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Значение", "Описание"
};
}
@Override
public Object getFieldAt(CompilerEnvironment object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.value;
case 3:
return object.description;
default:
return null;
}
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(2).setRenderer(TableRenderers.RendererCompilerEnvironmentValue);
columns.get(2).setEditor(TableEditors.EditorCompilerEnvironmentValue);
//-
columns.get(3).setRenderer(RendererMultiline);
}
};
}
}

View File

@@ -0,0 +1,7 @@
package _VisualDVM.GlobalData.CompilerEnvironment;
public enum EnvironmentValueType {
String,
Boolean,
Integer,
Real
}

View File

@@ -0,0 +1,35 @@
package _VisualDVM.GlobalData.CompilerEnvironment.UI;
import Common.Visual.CommonUI;
import Common.Visual.Tables.DBObjectEditor;
import Common.Visual.Fonts.VisualiserFonts;
import Common.Visual.Windows.Dialog.Text.ComboTextDialog;
import _VisualDVM.GlobalData.CompilerEnvironment.CompilerEnvironment;
public class CompilerEnvironmentValueEditor extends DBObjectEditor<CompilerEnvironment> {
@Override
public void Action() {
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
setText(value.value.isEmpty() ? "не задано" : value.value);
//-
ComboTextDialog dialog = new ComboTextDialog() {
@Override
public void validateFields() {
super.validateFields();
if (fields.getSelectedItem() != null)
value.validate(Log, fields.getSelectedItem().toString());
}
};
dialog.fields.setEditable(value.valueVariants.isEmpty());
if (!value.value.isEmpty())
CommonUI.TrySelect(dialog.fields, value.value);
if (dialog.ShowDialog("Изменить значение опции " + value.name,
value.valueVariants
)) {
value.value = dialog.Result;
setText(value.value.isEmpty() ? "не задано" : value.value);
}
}
@Override
public Object getCellEditorValue() {
return value.value;
}
}

View File

@@ -0,0 +1,15 @@
package _VisualDVM.GlobalData.CompilerEnvironment.UI;
import Common.Visual.CommonUI;
import Common.Visual.Tables.DBObjectRenderer;
import Common.Visual.Fonts.VisualiserFonts;
import _VisualDVM.GlobalData.CompilerEnvironment.CompilerEnvironment;
public class CompilerEnvironmentValueRenderer extends DBObjectRenderer {
@Override
public void Display() {
if (value != null) {
CompilerEnvironment environment = (CompilerEnvironment) value;
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
setText(environment.value.isEmpty() ? "не задано" : environment.value);
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.CompilerEnvironment.UI.CompilerEnvironmentsFields">
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>

View File

@@ -0,0 +1,12 @@
package _VisualDVM.GlobalData.CompilerEnvironment.UI;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class CompilerEnvironmentsFields implements DialogFields {
private JPanel content;
@Override
public Component getContent() {
return content;
}
}

View File

@@ -0,0 +1,48 @@
package _VisualDVM.GlobalData.CompilerOption;
import Common.Database.Objects.DBObject;
import Common.Utils.CommonUtils;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Arrays;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CompilerOption extends DBObject {
@Description("PRIMARY KEY, UNIQUE")
public String name = "";
public String parameterSeparator = "";
public String parameterName = "";
public String parameterValue = "";
public Vector<String> parameterVariants = new Vector<>();
public Vector<String> description = new Vector<>();
//--------------------------------------
public boolean hasParameter() {
return !parameterName.isEmpty();
}
@Override
public Object getPK() {
return name;
}
@Override
public String toString() {
return name + (hasParameter() ? (parameterSeparator +
(parameterValue.contains(" ") ? CommonUtils.DQuotes(parameterValue) : parameterValue)) : "");
}
public void CheckParameterVariants() {
for (String line : description)
if (CheckLine(line)) break;
}
public boolean CheckLine(String line) {
if (hasParameter()) {
Pattern DVM_PARAM_VALUES_REGEX = Pattern.compile(CommonUtils.TBrackets(parameterName) + "\\s*=\\s*" + "\\w+(\\|\\w+)+", Pattern.CASE_INSENSITIVE);
Matcher matcher = DVM_PARAM_VALUES_REGEX.matcher(line);
if (matcher.find()) {
String s = line.substring(matcher.start(), matcher.end());
String packed = s.substring(s.lastIndexOf('=') + 1).trim();
parameterVariants = new Vector<>(Arrays.asList(packed.split("\\|")));
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,47 @@
package _VisualDVM.GlobalData.CompilerOption;
import Common.Database.Tables.DataSet;
import Common.Visual.DataSetControlForm;
import Common.Visual.Tables.TableEditors;
import Common.Visual.Tables.TableRenderers;
import static Common.Visual.Tables.TableRenderers.RendererMultiline;
public class CompilerOptionsSet extends DataSet<String, CompilerOption> {
public CompilerOptionsSet() {
super(String.class, CompilerOption.class);
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Параметр", "Значение", "Описание"
};
}
@Override
public Object getFieldAt(CompilerOption object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.parameterName + object.parameterSeparator;
case 3:
return object.parameterValue;
case 4:
return object.description;
default:
return null;
}
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(2).setRenderer(TableRenderers.RendererCompilerOptionParameterName);
columns.get(3).setRenderer(TableRenderers.RendererCompilerOptionParameterValue);
columns.get(3).setEditor(TableEditors.EditorCompilerOptionParameterValue);
columns.get(4).setRenderer(RendererMultiline);
}
};
}
}

View File

@@ -0,0 +1,20 @@
package _VisualDVM.GlobalData.CompilerOption.UI;
import Common.Visual.CommonUI;
import Common.Visual.Tables.DBObjectRenderer;
import Common.Visual.Fonts.VisualiserFonts;
import _VisualDVM.GlobalData.CompilerOption.CompilerOption;
public class CompilerOptionParameterNameRenderer extends DBObjectRenderer {
@Override
public void Display() {
if (value != null) {
CompilerOption option = (CompilerOption) value;
if (option.hasParameter()) {
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.TreePlain));
setText(option.parameterName);
} else {
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.UnknownState));
setText("нет");
}
}
}
}

View File

@@ -0,0 +1,33 @@
package _VisualDVM.GlobalData.CompilerOption.UI;
import Common.Visual.CommonUI;
import Common.Visual.Tables.DBObjectEditor;
import Common.Visual.Fonts.VisualiserFonts;
import Common.Visual.Windows.Dialog.Text.ComboTextDialog;
import _VisualDVM.GlobalData.CompilerOption.CompilerOption;
public class CompilerOptionParameterValueEditor extends DBObjectEditor<CompilerOption> {
@Override
public void Action() {
if (value.hasParameter()) {
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
//-
setText(value.parameterValue.isEmpty() ? "не задано" : value.parameterValue);
//-
ComboTextDialog dialog = new ComboTextDialog();
if (!value.parameterValue.isEmpty())
CommonUI.TrySelect(dialog.fields, value.parameterValue);
dialog.fields.setEditable(value.parameterVariants.isEmpty());
if (dialog.ShowDialog("Изменить значение опции " + value.name,
value.parameterVariants)) {
value.parameterValue = dialog.Result;
setText(value.parameterValue.isEmpty() ? "не задано" : value.parameterValue);
}
} else {
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.UnknownState));
setText("нет");
}
}
@Override
public Object getCellEditorValue() {
return value.parameterValue;
}
}

View File

@@ -0,0 +1,20 @@
package _VisualDVM.GlobalData.CompilerOption.UI;
import Common.Visual.CommonUI;
import Common.Visual.Tables.DBObjectRenderer;
import Common.Visual.Fonts.VisualiserFonts;
import _VisualDVM.GlobalData.CompilerOption.CompilerOption;
public class CompilerOptionParameterValueRenderer extends DBObjectRenderer {
@Override
public void Display() {
if (value != null) {
CompilerOption option = (CompilerOption) value;
if (option.hasParameter()) {
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
setText(option.parameterValue.isEmpty() ? "не задано" : option.parameterValue);
} else {
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.UnknownState));
setText("нет");
}
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.CompilerOption.UI.CompilerOptionsFields">
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>

View File

@@ -0,0 +1,12 @@
package _VisualDVM.GlobalData.CompilerOption.UI;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class CompilerOptionsFields implements DialogFields {
private JPanel content;
@Override
public Component getContent() {
return content;
}
}

View File

@@ -0,0 +1,18 @@
package _VisualDVM.GlobalData.Credentials;
import Common.CommonConstants;
import Common.Database.Objects.iDBObject;
import com.sun.org.glassfish.gmbal.Description;
public class Credentials extends iDBObject {
@Description("DEFAULT -1")
public int machine_id = CommonConstants.Nan;
@Description("DEFAULT -1")
public int user_id = CommonConstants.Nan;
@Description("DEFAULT -1")
public int compiler_id = CommonConstants.Nan;
@Description("DEFAULT -1")
public int makefile_id = CommonConstants.Nan;
@Description("DEFAULT -1")
public int runconfiguration_id = CommonConstants.Nan;
@Description("DEFAULT -1")
public int remotesapfor_id = CommonConstants.Nan;
}

View File

@@ -0,0 +1,7 @@
package _VisualDVM.GlobalData.Credentials;
import Common.Database.Tables.iDBTable;
public class CredentialsDBTable extends iDBTable<Credentials> {
public CredentialsDBTable() {
super(Credentials.class);
}
}

View File

@@ -0,0 +1,24 @@
package _VisualDVM.GlobalData.DBLastProject;
import Common.Database.Objects.DBObject;
import _VisualDVM.ProjectData.Project.db_project_info;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Date;
public class DBLastProject extends DBObject {
@Description("PRIMARY KEY, UNIQUE")
public String HomePath = "";
public long lastOpened = 0;
public DBLastProject() {
}
public DBLastProject(db_project_info project) {
HomePath = project.Home.getAbsolutePath();
RefreshOpenTime();
}
public void RefreshOpenTime() {
lastOpened = new Date().toInstant().getEpochSecond();
}
@Override
public Object getPK() {
return HomePath;
}
}

View File

@@ -0,0 +1,22 @@
package _VisualDVM.GlobalData.DBLastProject;
import Common.Database.Tables.DBTable;
import java.util.Comparator;
import java.util.Vector;
class SortByDate implements Comparator<DBLastProject> {
public int compare(DBLastProject p1, DBLastProject p2) {
return (int) (p2.lastOpened - p1.lastOpened);
}
}
public class LastProjectsDBTable extends DBTable<String, DBLastProject> {
public LastProjectsDBTable() {
super(String.class, DBLastProject.class);
}
public Vector<DBLastProject> getOrdered() {
return getOrderedRecords(new SortByDate());
}
@Override
public String getSingleDescription() {
return "путь к проекту";
}
}

View File

@@ -0,0 +1,8 @@
package _VisualDVM.GlobalData.DVMParameter;
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValue;
public class DVMParameter extends EnvironmentValue {
@Override
public String toString() {
return name + "=" + value + ";";
}
}

View File

@@ -0,0 +1,99 @@
package _VisualDVM.GlobalData.DVMParameter;
import Common.Utils.CommonUtils;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Database.Tables.iDBTable;
import Common.Visual.DataSetControlForm;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.DVMParameter.UI.DVMParameterFields;
import _VisualDVM.GlobalData.GlobalDatabase;
public class DVMParameterDBTable extends iDBTable<DVMParameter> {
public DVMParameterDBTable() {
super(DVMParameter.class);
}
@Override
public String getSingleDescription() {
return "параметр DVM системы";
}
@Override
public String getPluralDescription() {
return "параметры DVM";
}
@Override
public String[] getUIColumnNames() {
return new String[]{"имя", "значение"};
}
@Override
public Object getFieldAt(DVMParameter object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.name;
case 2:
return object.value;
}
return null;
}
@Override
public Current CurrentName() {
return Current.DVMParameterValue;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
@Override
public DBObjectDialog<DVMParameter, DVMParameterFields> getDialog() {
return new DBObjectDialog<DVMParameter, DVMParameterFields>(DVMParameterFields.class) {
@Override
public void fillFields() {
CommonUI.TrySelect(fields.cbName, Result.name);
fields.tfValue.setText(Result.value);
}
//https://javarush.ru/groups/posts/regulyarnye-vyrazheniya-v-java
@Override
public void validateFields() {
String name = (String) fields.cbName.getSelectedItem();
String value = fields.tfValue.getText();
if (name.isEmpty())
Log.Writeln("Имя параметра DVM системы не может быть пустым.");
/*
if (!name.matches("\\w*")) {
Log.Writeln("Имя переменной окружения может содержать только латинские буквы, цифры и подчёркивания");
}
*/
if (Utils.isLinuxSystemCommand(name))
Log.Writeln(CommonUtils.DQuotes(name) + " является системной командой Linux,\nи не может быть задано в качестве имени переменной окружения.");
/*
if (value.contains("\"")) {
Log.Writeln("Значение переменной окружения не может содержать двойные кавычки");
}
*/
for (DVMParameter par : ((GlobalDatabase)CommonUtils.db).dvmParameters.Data.values()) {
if (par.isVisible() && (Result.id != par.id) && (par.name.equals(name))) {
Log.Writeln("В конфигурации запуска уже задан параметр DVM системы с именем " + CommonUtils.Brackets(name));
break;
}
}
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.run_configuration_id = Current.getRunConfiguration().id;
Result.name = (String) fields.cbName.getSelectedItem();
Result.value = fields.tfValue.getText();
}
@Override
public int getDefaultHeight() {
return 200;
}
};
}
}

View File

@@ -0,0 +1,11 @@
package _VisualDVM.GlobalData.DVMParameter;
import Common.Visual.Menus.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class DVMParametersMenuBar extends DataMenuBar {
public DVMParametersMenuBar() {
super("параметры",
PassCode_2021.AddDVMParameter,
PassCode_2021.EditDVMParameter,
PassCode_2021.DeleteDVMParameter);
}
}

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.DVMParameter.UI.DVMParameterFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="79882" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="имя"/>
</properties>
</component>
<vspacer id="db063">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="6dffc" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="значение"/>
</properties>
</component>
<component id="5996e" class="javax.swing.JTextField" binding="tfValue" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="9fa4" class="javax.swing.JComboBox" binding="cbName" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="true"/>
<font name="Times New Roman" size="16" style="0"/>
<model>
<item value="Is_DVM_STAT"/>
<item value="StatBufLength"/>
</model>
<toolTipText value="Выберите из списка дополнительную команду компиляции ( актуально для DVM компиляторов)"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,21 @@
package _VisualDVM.GlobalData.DVMParameter.UI;
import Common.Visual.Controls.StyledTextComboBox;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class DVMParameterFields implements DialogFields {
public JTextField tfValue;
public JComboBox<String> cbName;
private JPanel content;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
cbName = new StyledTextComboBox();
tfValue = new StyledTextField();
}
}

View File

@@ -0,0 +1,19 @@
package _VisualDVM.GlobalData.EnvironmentValue;
import Common.CommonConstants;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
public class EnvironmentValue extends iDBObject {
public String name = "";
public String value = "";
public int machine_id = CommonConstants.Nan; //для удаления машин
public int run_configuration_id = CommonConstants.Nan;
@Override
public boolean isVisible() {
return Current.HasRunConfiguration() && (run_configuration_id == Current.getRunConfiguration().id);
}
@Override
public String toString() {
return name + "=" + CommonUtils.DQuotes(value);
}
}

View File

@@ -0,0 +1,99 @@
package _VisualDVM.GlobalData.EnvironmentValue;
import Common.Utils.CommonUtils;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Database.Tables.iDBTable;
import Common.Visual.DataSetControlForm;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.EnvironmentValue.UI.EnvironmentValueFields;
import _VisualDVM.GlobalData.GlobalDatabase;
public class EnvironmentValuesDBTable extends iDBTable<EnvironmentValue> {
public EnvironmentValuesDBTable() {
super(EnvironmentValue.class);
}
@Override
public String getSingleDescription() {
return "переменная окружения";
}
@Override
public String getPluralDescription() {
return "переменные окружения";
}
@Override
public DBObjectDialog<EnvironmentValue, EnvironmentValueFields> getDialog() {
return new DBObjectDialog<EnvironmentValue, EnvironmentValueFields>(EnvironmentValueFields.class) {
@Override
public void fillFields() {
CommonUI.TrySelect(fields.cbName, Result.name);
fields.tfValue.setText(Result.value);
}
//https://javarush.ru/groups/posts/regulyarnye-vyrazheniya-v-java
@Override
public void validateFields() {
String name = (String) fields.cbName.getSelectedItem();
String value = fields.tfValue.getText();
if (name.isEmpty())
Log.Writeln("Имя переменной окружения не может быть пустым.");
if (!name.matches("\\w*")) {
Log.Writeln("Имя переменной окружения может содержать только латинские буквы, цифры и подчёркивания");
}
if (Utils.isLinuxSystemCommand(name))
Log.Writeln(CommonUtils.DQuotes(name) + " является системной командой Linux,\nи не может быть задано в качестве имени переменной окружения.");
if (value.contains("\"")) {
Log.Writeln("Значение переменной окружения не может содержать двойные кавычки");
}
for (EnvironmentValue env : ((GlobalDatabase)CommonUtils.db).environmentValues.Data.values()) {
if (env.isVisible() && (Result.id != env.id) && (env.name.equals(name))) {
Log.Writeln("В конфигурации запуска уже задана переменная окружения с именем " + CommonUtils.Brackets(name));
break;
}
}
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.run_configuration_id = Current.getRunConfiguration().id;
Result.name = (String) fields.cbName.getSelectedItem();
Result.value = fields.tfValue.getText();
}
@Override
public int getDefaultHeight() {
return 200;
}
};
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{"имя", "значение"};
}
@Override
public Object getFieldAt(EnvironmentValue object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.name;
case 2:
return object.value;
}
return null;
}
@Override
public Current CurrentName() {
return Current.EnvironmentValue;
}
public EnvironmentValue getEnvByName(String name_in) {
for (EnvironmentValue environmentValue : Data.values())
if (environmentValue.name.equalsIgnoreCase(name_in)) return environmentValue;
return null;
}
}

View File

@@ -0,0 +1,12 @@
package _VisualDVM.GlobalData.EnvironmentValue;
import Common.Visual.Menus.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class EnvironmentValuesMenuBar extends DataMenuBar {
public EnvironmentValuesMenuBar() {
super("переменные окружения", PassCode_2021.AddEnvironmentValue,
PassCode_2021.EditEnvironmentValue,
PassCode_2021.DeleteEnvironmentValue,
PassCode_2021.PickCompilerEnvironments
);
}
}

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.EnvironmentValue.UI.EnvironmentValueFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="4db5a" class="javax.swing.JComboBox" binding="cbName">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="true"/>
<font name="Times New Roman" size="16" style="0"/>
<model/>
<toolTipText value="Выберите из списка дополнительную команду компиляции ( актуально для DVM компиляторов)"/>
</properties>
</component>
<vspacer id="eb1a6">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="508af" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="имя"/>
</properties>
</component>
<component id="1a477" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="значение"/>
</properties>
</component>
<component id="abfff" class="javax.swing.JTextField" binding="tfValue" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,22 @@
package _VisualDVM.GlobalData.EnvironmentValue.UI;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class EnvironmentValueFields implements DialogFields {
public JPanel content;
public JComboBox cbName;
public JTextField tfValue;
public EnvironmentValueFields() {
cbName.addItem("");
}
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfValue = new StyledTextField();
}
}

View File

@@ -0,0 +1,23 @@
package _VisualDVM.GlobalData.FileObject;
import Common.Database.Objects.DBObject;
import java.io.File;
import java.util.Date;
public class DirInfo extends DBObject {
File dir;
long mdate;
public DirInfo(File dir_in, long mdate_in) {
dir = dir_in;
mdate = mdate_in;
}
@Override
public Object getPK() {
return dir.getName();
}
public Date getDate() {
return new Date(mdate);
}
public File getFile(){
return dir;
}
}

View File

@@ -0,0 +1,33 @@
package _VisualDVM.GlobalData.FileObject;
import Common.Database.Tables.DataSet;
import Common.Visual.DataSetControlForm;
import static Common.Visual.Tables.TableRenderers.*;
public class DirInfosDataSet extends DataSet<String, DirInfo> {
public DirInfosDataSet() {
super(String.class, DirInfo.class);
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
columns.get(1).setRenderer(RendererDate);
}
};
}
@Override
public String[] getUIColumnNames(){
return new String[]{
"дата изменения"};
}
@Override
public Object getFieldAt(DirInfo object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.getDate();
default:
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.FileObject.DirInfosFields">
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>

View File

@@ -0,0 +1,12 @@
package _VisualDVM.GlobalData.FileObject;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class DirInfosFields implements DialogFields {
public JPanel content;
@Override
public Component getContent() {
return content;
}
}

View File

@@ -0,0 +1,191 @@
package _VisualDVM.GlobalData;
import Common.CurrentAnchestor;
import Common.Database.VisualiserDatabase;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import Common.Database.Objects.DBObject;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Account.Account;
import _VisualDVM.GlobalData.Account.AccountsDBTable;
import _VisualDVM.GlobalData.Compiler.CompilersDBTable;
import _VisualDVM.GlobalData.Credentials.Credentials;
import _VisualDVM.GlobalData.Credentials.CredentialsDBTable;
import _VisualDVM.GlobalData.DBLastProject.LastProjectsDBTable;
import _VisualDVM.GlobalData.DVMParameter.DVMParameterDBTable;
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValuesDBTable;
import _VisualDVM.GlobalData.Machine.MachinesDBTable;
import _VisualDVM.GlobalData.Makefile.MakefilesDBTable;
import _VisualDVM.GlobalData.Module.ModulesDBTable;
import _VisualDVM.GlobalData.RunConfiguration.RunConfigurationsDBTable;
import _VisualDVM.GlobalData.SapforProfile.SapforProfile;
import _VisualDVM.GlobalData.SapforProfile.SapforProfilesDBTable;
import _VisualDVM.GlobalData.SapforProfileSetting.SapforProfileSetting;
import _VisualDVM.GlobalData.SapforProfileSetting.SapforProfileSettingsDBTable;
import _VisualDVM.GlobalData.Settings.DBSetting;
import _VisualDVM.GlobalData.Settings.SettingName;
import _VisualDVM.GlobalData.Settings.SettingsDBTable;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTasksDBTable;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTasksDBTable;
import _VisualDVM.GlobalData.User.UsersDBTable;
import _VisualDVM.Repository.Component.ComponentType;
import Visual_DVM_2021.PassStats.PassStatsDBTable;
import Visual_DVM_2021.Passes.PassCode_2021;
import java.nio.file.Paths;
import java.util.Date;
import java.util.LinkedHashMap;
public class GlobalDatabase extends VisualiserDatabase {
//---------СЕАНС----------------------------------------------
public MachinesDBTable machines;
public UsersDBTable users;
public CompilersDBTable compilers;
public MakefilesDBTable makefiles;
public ModulesDBTable modules;
public CompilationTasksDBTable compilationTasks;
public RunTasksDBTable runTasks;
public RunConfigurationsDBTable runConfigurations;
public EnvironmentValuesDBTable environmentValues;
public DVMParameterDBTable dvmParameters;
public CredentialsDBTable credentials;
//----- ДАННЫЕ ВИЗУАЛИЗАТОРА---------------------------------
public SettingsDBTable settings;
public LastProjectsDBTable lastProjects;
public AccountsDBTable accounts;
public PassStatsDBTable passStats;
//-
public SapforProfilesDBTable sapforProfiles = null;
//---------
public SapforProfileSettingsDBTable sapforProfilesSettings = null;
//-
public GlobalDatabase() {
super(Paths.get(System.getProperty("user.dir"), "Data", Global.properties.GlobalDBName).toFile());
}
@Override
protected void initAllTables() throws Exception {
super.initAllTables();
addTable(machines = new MachinesDBTable());
addTable(users = new UsersDBTable());
addTable(compilers = new CompilersDBTable());
addTable(makefiles = new MakefilesDBTable());
addTable(modules = new ModulesDBTable());
addTable(compilationTasks = new CompilationTasksDBTable());
addTable(runTasks = new RunTasksDBTable());
addTable(runConfigurations = new RunConfigurationsDBTable());
addTable(environmentValues = new EnvironmentValuesDBTable());
addTable(credentials = new CredentialsDBTable());
addTable(settings = new SettingsDBTable());
addTable(lastProjects = new LastProjectsDBTable());
addTable(accounts = new AccountsDBTable());
addTable(passStats = new PassStatsDBTable());
addTable(dvmParameters = new DVMParameterDBTable());
addTable(sapforProfiles = new SapforProfilesDBTable());
addTable(sapforProfilesSettings = new SapforProfileSettingsDBTable());
}
//---------------------------------------------------------------------------------
@Override
public void Init() throws Exception {
CurrentAnchestor.set(Current.Account,
accounts.Data.isEmpty() ? Insert(new Account()) :
accounts.getFirstRecord()
);
CurrentAnchestor.set(Current.Credentials,
credentials.Data.isEmpty() ? Insert(new Credentials()) :
credentials.getFirstRecord());
//настройки компонент
settings.AddAll();
runConfigurations.Patch();
}
@Override
public PassCode_2021 getSynchronizePassCode() {
return null;
}
public void SaveCredentials(){
try {
Credentials credentials = (Credentials) CurrentAnchestor.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;
Update(credentials);
}
catch (Exception ex){
ex.printStackTrace();
}
}
public void UpdateCredentials() {
try {
Update((DBObject) CurrentAnchestor.get(Current.Credentials));
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
}
}
//--
public LinkedHashMap<SettingName, String> getSapforSettingsForProfile() {
LinkedHashMap<SettingName, String> res = new LinkedHashMap<>();
for (DBSetting setting : settings.getSettingsByOwner(ComponentType.SapforOptions))
if (setting.Visible)
res.put(setting.Name, setting.Value);
return res;
}
//проверить, есть ли профиль с таким же набором настроек.
public SapforProfile checkProfileForCurrentSettings() {
LinkedHashMap<SettingName, String> current_values = getSapforSettingsForProfile();
for (SapforProfile profile : sapforProfiles.Data.values()) {
//--получить все настройки профиля
LinkedHashMap<SettingName, String> profileValues = new LinkedHashMap<>();
for (SapforProfileSetting setting : sapforProfilesSettings.Data.values())
if (setting.sapforprofile_id == profile.id) profileValues.put(setting.name, setting.value);
//--
if (current_values.equals(profileValues)) return profile;
}
return null;
}
public void insertProfileSettings(SapforProfile profile) throws Exception {
LinkedHashMap<SettingName, String> current_values = getSapforSettingsForProfile();
for (SettingName name : current_values.keySet()) {
//--
SapforProfileSetting sapforProfileSetting = new SapforProfileSetting();
sapforProfileSetting.name = name;
sapforProfileSetting.value = current_values.get(name);
sapforProfileSetting.sapforprofile_id = profile.id;
//--
Insert(sapforProfileSetting);
}
}
public void saveCurrentProfile(String name_in) throws Exception {
if (checkProfileForCurrentSettings() == null) {
SapforProfile profile = new SapforProfile();
profile.description = name_in;
profile.creationDate = new Date().getTime();
Insert(profile);
insertProfileSettings(profile);
}
}
public void rewriteProfileByDescription(String description_in) throws Exception {
SapforProfile old = null;
//ищем профиль с именем бага
for (SapforProfile p : sapforProfiles.Data.values())
if (p.description.equalsIgnoreCase(description_in)) {
old = p;
break;
}
if (old != null) {
//удалить профиль с именем бага,если есть, чтобы не множить кроликов.
//при условии что не видно окна профилей!!
Delete(old);
DeleteByFK(old, SapforProfileSetting.class);
}
//---
SapforProfile profile = new SapforProfile();
profile.description = description_in;
profile.creationDate = new Date().getTime();
Insert(profile);
insertProfileSettings(profile);
}
}

View File

@@ -0,0 +1,28 @@
package _VisualDVM.GlobalData.Grid;
import Common.Database.Objects.DBObject;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Arrays;
import java.util.Vector;
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() {
}
public TableVisualData(String name_in) {
name = name_in;
sizes = "";
}
@Override
public Object getPK() {
return name;
}
public Vector<Integer> unpack() {
return Arrays.stream(sizes.split("\\|")).map(Integer::parseInt).collect(Collectors.toCollection(Vector::new));
}
}

View File

@@ -0,0 +1,7 @@
package _VisualDVM.GlobalData.Grid;
import Common.Database.Tables.DBTable;
public class TablesVisualDatasDBTable extends DBTable<String, TableVisualData> {
public TablesVisualDatasDBTable() {
super(String.class, TableVisualData.class);
}
}

View File

@@ -0,0 +1,65 @@
package _VisualDVM.GlobalData.Machine;
import Common.Database.Objects.iDBObject;
import Common.Utils.CommonUtils;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.User.User;
import java.util.LinkedHashMap;
public class Machine extends iDBObject {
public MachineType type = MachineType.Server;
public String name = "";
public String address = "";
public int port = 22;
public Machine(String name_in, String address_in, int port_in, MachineType type_in) {
name = name_in;
address = address_in;
port = port_in;
type = type_in;
}
public Machine() {
}
public String getURL() {
return type.equals(MachineType.Local) ? name : (address + ":" + port);
}
public String getFullDescription() {
return //this.equals(Constants.repository_machine) ? "Репозиторий визуализатора" :
"Машина по адресу " + CommonUtils.Brackets(getURL());
}
public LinkedHashMap<Integer, Compiler> getCompilers() {
return CommonUtils.db.getMapByFKi(this, Compiler.class);
}
public LinkedHashMap<Integer, User> getUsers() {
return CommonUtils.db.getMapByFKi(this, User.class);
}
@Override
public String getDialogName() {
return super.getDialogName() + ":" + getURL();
}
/* инициализация компиляторов по умолчанию. добавить в отдельный проход.
//todo если машина локальная и винда, их не добавлять.
Visualiser.db.Insert(new Compiler(
(Machine)Target,
"gfortran",
CompilerType.gnu,
"gfortran",
"--version",
"--help"
));
Visualiser.db.Insert(new Compiler(
(Machine)Target,
"gcc",
CompilerType.gnu,
"gcc",
"--version",
"--help"
));
Visualiser.db.Insert(new Compiler(
(Machine)Target,
"g++",
CompilerType.gnu,
"g++",
"--version",
"--help"
));
*/
}

View File

@@ -0,0 +1,20 @@
package _VisualDVM.GlobalData.Machine;
public enum MachineType {
Undefined,
Server,
MVS_cluster,
Local;
public String getDescription() {
switch (this) {
case Undefined:
return "?";
case Server:
return "одиночный сервер";
case MVS_cluster:
return "MVS кластер";
case Local:
return "локальная";
}
return "";
}
}

View File

@@ -0,0 +1,126 @@
package _VisualDVM.GlobalData.Machine;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import _VisualDVM.Visual.UI;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValue;
import _VisualDVM.GlobalData.Machine.UI.MachineFields;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import _VisualDVM.GlobalData.User.User;
import java.util.LinkedHashMap;
public class MachinesDBTable extends iDBTable<Machine> {
public MachinesDBTable() {
super(Machine.class);
}
@Override
public String getSingleDescription() {
return "машина";
}
@Override
public String getPluralDescription() {
return "машины";
}
@Override
public DBObjectDialog<Machine, MachineFields> getDialog() {
return new DBObjectDialog<Machine, MachineFields>(MachineFields.class) {
@Override
public int getDefaultHeight() {
return 250;
}
@Override
public void validateFields() {
if (fields.tfAddress.getText().isEmpty())
Log.Writeln("Адрес машины не может быть пустым");
}
@Override
public void fillFields() {
fields.tfName.setText(Result.name);
fields.tfAddress.setText(Result.address);
fields.sPort.setValue(Result.port);
CommonUI.TrySelect(fields.cbMachineType, Result.type);
}
@Override
public void ProcessResult() {
Result.name = fields.tfName.getText();
Result.address = fields.tfAddress.getText();
Result.port = (int) fields.sPort.getValue();
Result.type = (MachineType) fields.cbMachineType.getSelectedItem();
}
@Override
public void SetEditLimits() {
fields.cbMachineType.setEnabled(false);
}
};
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
//-
res.put(User.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(Compiler.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(Makefile.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(RunConfiguration.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
//-
res.put(Module.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
res.put(EnvironmentValue.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
res.put(DVMParameter.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
res.put(CompilationTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(RunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
return res;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
UI.credentialsBar.ShowMachine();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
UI.credentialsBar.ShowNoMachine();
}
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{"URL"};
}
@Override
public Object getFieldAt(Machine object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.getURL();
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.Machine;
}
public boolean LocalMachineExists() {
return Data.values().stream().anyMatch(machine -> machine.type.equals(MachineType.Local));
}
}

View File

@@ -0,0 +1,29 @@
package _VisualDVM.GlobalData.Machine;
import Common.Visual.Menus.DataMenuBar;
import Common.Visual.Controls.MenuBarButton;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MachinesMenuBar extends DataMenuBar {
MenuBarButton bCollapse;
public MachinesMenuBar() {
super("машины",
PassCode_2021.AddMachine,
PassCode_2021.EditMachine,
PassCode_2021.DeleteMachine);
this.add(bCollapse = new MenuBarButton() {
{
setIcon("/icons/CollapseUp.png");
setToolTipText("Свернуть");
addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021.passes.get(PassCode_2021.UpdateProperty).Do("collapseCredentials", true);
}
});
}
}, 0);
}
}

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.Machine.UI.MachineFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="1bb3c" class="javax.swing.JTextField" binding="tfName" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<vspacer id="aac20">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="44036" class="javax.swing.JTextField" binding="tfAddress" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="a00bb" class="javax.swing.JSpinner" binding="sPort">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="ee3e1" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="имя"/>
</properties>
</component>
<component id="22dab" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="адрес"/>
</properties>
</component>
<component id="2dde3" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="порт"/>
</properties>
</component>
<component id="9d873" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="тип"/>
</properties>
</component>
<component id="7aab4" class="javax.swing.JComboBox" binding="cbMachineType" custom-create="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<toolTipText value="выберите тип машины"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,43 @@
package _VisualDVM.GlobalData.Machine.UI;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import _VisualDVM.GlobalData.Machine.MachineType;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MachineFields implements DialogFields {
private static final String localName = "этот компьютер";
public JTextField tfName;
public JTextField tfAddress;
public JSpinner sPort;
public JPanel content;
public JComboBox<MachineType> cbMachineType;
public MachineFields() {
sPort.setModel(new SpinnerNumberModel(22, 1, 65535, 1));
cbMachineType.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ((cbMachineType.getSelectedItem() != null) && (cbMachineType.getSelectedItem().equals(MachineType.Local))) {
tfName.setText(localName);
tfAddress.setText(localName);
}
}
});
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfName = new StyledTextField();
tfAddress = new StyledTextField();
//-
cbMachineType = new JComboBox<>();
cbMachineType.addItem(MachineType.Server);
cbMachineType.addItem(MachineType.MVS_cluster);
cbMachineType.addItem(MachineType.Local);
}
@Override
public Component getContent() {
return content;
}
}

View File

@@ -0,0 +1,202 @@
package _VisualDVM.GlobalData.Makefile;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import Common.Utils.TextLog;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.Module.ModuleAnchestor;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.ProjectData.Project.db_project_info;
import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.stream.Collectors;
//мейкфайл. цепочка модулей. он сам отвечает за линковку.
//И по одному модулю на каждый язык.
public class Makefile extends ModuleAnchestor {
public Makefile() {
}
@Override
public boolean isVisible() {
return Current.HasMachine() && (machine_id == Current.getMachine().id);
}
public LinkedHashMap<LanguageName, Module> getActiveModules() {
return CommonUtils.db.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));
}
public LinkedHashMap<LanguageName, Module> getModules() {
return CommonUtils.db.getByFKAndGroupBy(this, Module.class, "language", LanguageName.class);
}
public String Generate(db_project_info project, boolean useFilesOrder, LinkedHashMap<LanguageName, Module> modules) throws Exception {
Compiler linker = getCompiler();
if (linker == null) return "";
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs = project.getPrograms();
Vector<String> titles = new Vector<>();
Vector<String> objects = new Vector<>();
Vector<String> bodies = new Vector<>();
String binary = CommonUtils.DQuotes("0"); // Utils.DQuotes(project.name);
for (Module module : modules.values()) {
//определить а активен ли модуль.
//выбран ли он. есть ли у него компилятор. есть ли для него программы.
Compiler module_compiler;
if (module.isSelected() &&
((module_compiler = module.getCompiler()) != null)
&& (!programs.get(module.language).isEmpty())) {
//---------------------------------------------------------
String LANG_ = module.language.toString().toUpperCase() + "_";
Vector<String> module_objects = new Vector<>();
String module_body = "";
int i = 1;
//-------------------------------------------------------------------------
Vector<DBProjectFile> programsToAssembly = new Vector<>();
if (module.language.equals(LanguageName.fortran) && useFilesOrder) {
//для фортрана берем порядок с парсера.
for (String progName : project.files_order)
programsToAssembly.add(project.db.files.get(progName));
} else programsToAssembly = programs.get(module.language);
//--------------------------------------------------------------------------
for (DBProjectFile program : programsToAssembly) {
//--
program.last_assembly_name = module.language.toString() + "_" + i + ".o";
String object = CommonUtils.DQuotes(program.last_assembly_name);
module_objects.add(object);
module_body +=
object + ":\n" +
"\t" +
String.join(" ",
Utils.MFVar(LANG_ + "COMMAND"),
Utils.MFVar(LANG_ + "FLAGS"),
module_compiler.getStyleOptions(program),
"-c",
program.getQSourceName(),
"-o",
object + "\n\n"
);
++i;
}
titles.add(String.join("\n",
LANG_ + "COMMAND=" + CommonUtils.DQuotes(module_compiler.call_command) + " " + module.command,
LANG_ + "FLAGS=" + module.flags,
LANG_ + "OBJECTS=" + String.join(" ", module_objects),
""
));
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
bodies.add(module_body);
}
}
return String.join("\n",
"LINK_COMMAND=" + CommonUtils.DQuotes(linker.call_command) + " " + command,
"LINK_FLAGS=" + flags + "\n",
String.join("\n", titles),
"all: " + binary,
binary + " : " + String.join(" ", objects),
"\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary,
String.join(" ", bodies));
}
public String Generate(db_project_info project_info) throws Exception {
return Generate(project_info, true, getActiveModules());
}
public String GenerateForPrecompilation(db_project_info project, LinkedHashMap<LanguageName, Module> modules) {
Compiler linker = getCompiler();
if (linker == null) return "";
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs = project.getPrograms();
Vector<String> titles = new Vector<>();
Vector<String> objects = new Vector<>();
Vector<String> bodies = new Vector<>();
for (Module module : modules.values()) {
//определить а активен ли модуль.
//выбран ли он. есть ли у него компилятор. есть ли для него программы.
Compiler module_compiler;
if (module.isSelected() &&
((module_compiler = module.getCompiler()) != null)
&& (!programs.get(module.language).isEmpty())) {
//---------------------------------------------------------
String LANG_ = module.language.toString().toUpperCase() + "_";
Vector<String> module_objects = new Vector<>();
String module_body = "";
int i = 1;
//-------------------------------------------------------------------------
Vector<DBProjectFile> programsToAssembly = programs.get(module.language);
//--------------------------------------------------------------------------
for (DBProjectFile program : programsToAssembly) {
//--
program.last_assembly_name = module.language.toString() + "_" + i + ".o";
String object = CommonUtils.DQuotes(program.last_assembly_name);
module_objects.add(object);
module_body +=
object + ":\n" +
"\t" +
String.join(" ",
Utils.MFVar(LANG_ + "COMMAND"),
Utils.MFVar(LANG_ + "FLAGS"),
module_compiler.getStyleOptions(program),
"-c",
program.getQSourceName() + "\n\n"
// "-o",
// object
);
++i;
}
titles.add(String.join("\n",
LANG_ + "COMMAND=" + CommonUtils.DQuotes(module_compiler.call_command) + " " + module.command,
LANG_ + "FLAGS=" + module.flags,
LANG_ + "OBJECTS=" + String.join(" ", module_objects),
""
));
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
bodies.add(module_body);
}
}
return String.join("\n",
String.join("\n", titles),
"all: " + String.join(" ", objects),
String.join(" ", bodies));
}
//---------------------------------------
//todo возможно улучшить
//https://habr.com/ru/post/211751/
public Machine getMachine() {
return CommonUtils.db.getById(Machine.class, machine_id);
}
public boolean DependsToCompiler(Compiler compiler) {
if (compiler_id == compiler.id) return true;
else {
LinkedHashMap<LanguageName, Module> modules = getModules();
for (Module module : modules.values())
if (module.compiler_id == compiler.id) return true;
}
return false;
}
public void Validate(TextLog Log) {
Compiler linker;
if ((linker = getCompiler()) == null)
Log.Writeln("Линковщик не выбран");
else {
if (linker.type.equals(CompilerType.dvm)) {
if (!Current.getProject().languageName.getDVMLink().equals(command))
Log.Writeln("команда линковки " +
CommonUtils.Quotes(command) +
" не соответствует языку текущего проекта "
+ Current.getProject().languageName.getDescription() + "\n" +
"Используйте команду " + Current.getProject().languageName.getDVMLink());
}
}
LinkedHashMap<LanguageName, Module> modules = getModules();
for (Module module : modules.values()) {
boolean isMain = module.language.equals(Current.getProject().languageName);
if (module.isSelected()) {
if (module.getCompiler() == null)
Log.Writeln("Не назначен компилятор для языка " + module.language.getDescription());
if (isMain && Current.getProject().getPrograms().get(module.language).isEmpty())
Log.Writeln("В текущем проекте не найдено ни одной программы на языке " + module.language.getDescription());
} else {
if (isMain)
Log.Writeln("Языковой модуль, соответствующий языку текущего проекта " +
Current.getProject().languageName.getDescription() + " не помечен как активный.");
}
}
}
}

View File

@@ -0,0 +1,74 @@
package _VisualDVM.GlobalData.Makefile;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.Module.UI.ModuleAnchestorFields;
import _VisualDVM.GlobalData.Module.UI.ModuleAnchestorForm;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import java.util.LinkedHashMap;
public class MakefilesDBTable extends iDBTable<Makefile> {
public MakefilesDBTable() {
super(Makefile.class);
}
@Override
public String getSingleDescription() {
return "мейкфайл";
}
@Override
public String getPluralDescription() {
return "мейкфайлы";
}
@Override
public DBObjectDialog<Makefile, ModuleAnchestorFields> getDialog() {
return new ModuleAnchestorForm<>();
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(Module.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(CompilationTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Линковщик",
"Команда",
"Флаги"
};
}
@Override
public Object getFieldAt(Makefile object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.getCompilerDescription();
case 2:
return object.command;
case 3:
return object.flags;
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.Makefile;
}
}

View File

@@ -0,0 +1,14 @@
package _VisualDVM.GlobalData.Makefile;
import Common.Visual.Menus.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class MakefilesMenuBar extends DataMenuBar {
public MakefilesMenuBar() {
super("мейкфайлы",
PassCode_2021.Compile,
PassCode_2021.AddMakefile,
PassCode_2021.EditMakefile,
PassCode_2021.DeleteMakefile);
addSeparator();
addPasses(PassCode_2021.ShowMakefilePreview, PassCode_2021.EditProjectCompilationMaxtime);
}
}

View File

@@ -0,0 +1,22 @@
package _VisualDVM.GlobalData.Makefile.UI;
import _VisualDVM.Visual.Editor.Viewer;
import Common.Visual.Windows.Dialog.Text.TextDialog;
public class MakefilePreviewForm extends TextDialog<Viewer> {
public MakefilePreviewForm() {
super(Viewer.class);
}
@Override
public void InitFields() {
fields.setSyntaxEditingStyle("text/makefile");
fields.setWhitespaceVisible(true);
fields.setEditable(false);
}
@Override
public void setText(String text_in) {
fields.setText(text_in);
}
@Override
public void CreateButtons() {
//кнопок нет.
}
}

View File

@@ -0,0 +1,37 @@
package _VisualDVM.GlobalData.Module;
import Common.CommonConstants;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.ProjectData.LanguageName;
public class Module extends ModuleAnchestor {
public int makefile_id = CommonConstants.Nan;
public LanguageName language = LanguageName.n;
public int on = 1; //учитывать ли модуль при сборке. указание пользователя. если файлы отсутствуют - игнорится
public Module() {
}
public Module(LanguageName language_in, Makefile makefile) {
language = language_in;
if (makefile != null) {
makefile_id = makefile.id;
machine_id = makefile.machine_id;
}
}
@Override
public boolean isVisible() {
return Current.HasMakefile() && (makefile_id == Current.getMakefile().id);
}
@Override
public boolean isSelected() {
return on > 0;
}
@Override
public void Select(boolean flag) {
on = flag ? 1 : 0;
try {
CommonUtils.db.Update(this);
} catch (Exception e) {
CommonUtils.MainLog.PrintException(e);
}
}
}

View File

@@ -0,0 +1,36 @@
package _VisualDVM.GlobalData.Module;
import Common.CommonConstants;
import Common.Utils.CommonUtils;
import Common.Database.Objects.iDBObject;
import _VisualDVM.GlobalData.Compiler.Compiler;
public class ModuleAnchestor extends iDBObject {
//--------------------------------------------------------------------------------------
public int machine_id = CommonConstants.Nan;
public int compiler_id = CommonConstants.Nan;
public String command = ""; //дополнительная команда компилятору. между вызовом и флагами.
public String flags = ""; //последовательность флагов
//---------------------------------------------------------------------------------------
//для таблиц
public String getCompilerDescription() {
Compiler compiler;
return ((compiler = getCompiler()) == null) ? "" : compiler.getDescription();
}
public Compiler getCompiler() {
return CommonUtils.db.getById(Compiler.class, compiler_id);
}
public String getDescription() {
String res = "";
if (getCompiler() != null) {
res += CommonUtils.Brackets(getCompiler().getDescription());
if (!command.isEmpty())
res += " " + CommonUtils.Brackets(command);
if (!flags.isEmpty())
res += " " + CommonUtils.Brackets(flags);
}
return res;
}
public String getStatCommand() {
Compiler compiler = getCompiler();
return ((compiler != null) ? (compiler.call_command) : "");
}
}

View File

@@ -0,0 +1,65 @@
package _VisualDVM.GlobalData.Module;
import _VisualDVM.Current;
import Common.Database.Tables.iDBTable;
import Common.Visual.DataSetControlForm;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import Common.Visual.Windows.Dialog.DialogFields;
import _VisualDVM.GlobalData.Module.UI.ModuleAnchestorForm;
public class ModulesDBTable extends iDBTable<Module> {
public ModulesDBTable() {
super(Module.class);
}
@Override
public String getSingleDescription() {
return "языковой модуль";
}
@Override
public String getPluralDescription() {
return "языковые модули";
}
@Override
public DBObjectDialog<Module, ? extends DialogFields> getDialog() {
return new ModuleAnchestorForm<>();
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
@Override
public Object getFieldAt(Module object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.language.getDescription();
case 3:
return object.getCompilerDescription();
case 4:
return object.command;
case 5:
return object.flags;
default:
return null;
}
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Язык",
"Компилятор",
"Команда",
"Флаги"
};
}
@Override
public Current CurrentName() {
return Current.Module;
}
}

View File

@@ -0,0 +1,8 @@
package _VisualDVM.GlobalData.Module;
import Common.Visual.Menus.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class ModulesMenuBar extends DataMenuBar {
public ModulesMenuBar() {
super("языковые модули", PassCode_2021.EditModule);
}
}

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.Module.UI.ModuleAnchestorFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="730" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f6ea3" class="javax.swing.JComboBox" binding="cbCompilers">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="0"/>
</properties>
</component>
<vspacer id="2c3c6">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="da1b3" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="компилятор"/>
</properties>
</component>
<component id="70919" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="флаги"/>
</properties>
</component>
<component id="54213" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="команда компиляции"/>
<toolTipText value="дополнительная команда компиляции помимо флагов"/>
</properties>
</component>
<component id="f1643" class="javax.swing.JComboBox" binding="cbCommands">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="false"/>
<font name="Times New Roman" size="16" style="0"/>
<model>
<item value=""/>
<item value="flink"/>
<item value="clink"/>
<item value="f"/>
<item value="c"/>
</model>
<toolTipText value="Выберите из списка дополнительную команду компиляции ( актуально для DVM компиляторов)"/>
</properties>
</component>
<toolbar id="3961e">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="3ccf3" class="javax.swing.JComboBox" binding="cbFlags" custom-create="true">
<constraints/>
<properties>
<editable value="true"/>
<font name="Times New Roman" size="16" style="0"/>
<model>
<item value=""/>
<item value="-O2 -g -fprofile-arcs -ftest-coverage"/>
</model>
</properties>
</component>
<component id="76c58" class="javax.swing.JButton" binding="bHelp">
<constraints/>
<properties>
<icon value="icons/Help.png"/>
<text value=""/>
<toolTipText value="Отобразить справочную информацию компилятора"/>
</properties>
</component>
<component id="91678" class="javax.swing.JButton" binding="BPickOptions">
<constraints/>
<properties>
<icon value="icons/Menu/Regions.png"/>
<text value=""/>
<toolTipText value="Назначить опции компилятора"/>
</properties>
</component>
</children>
</toolbar>
</children>
</grid>
</form>

View File

@@ -0,0 +1,74 @@
package _VisualDVM.GlobalData.Module.UI;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.Controls.StyledTextComboBox;
import Common.Visual.Windows.Dialog.DialogFields;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.Module.ModuleAnchestor;
import _VisualDVM.ProjectData.LanguageName;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
public class ModuleAnchestorFields implements DialogFields {
public JPanel content;
public JComboBox<Compiler> cbCompilers;
public JComboBox<String> cbCommands;
public JComboBox<String> cbFlags;
private JButton bHelp;
private JButton BPickOptions;
private Compiler compiler;
//считаем что машина есть.
public ModuleAnchestorFields() {
//-
LinkedHashMap<Integer, Compiler> compilers = Current.getMachine().getCompilers();
compilers.values().forEach(compiler -> cbCompilers.addItem(compiler));
bHelp.addActionListener(e -> {
if (cbCompilers.getSelectedItem() != null) {
Pass_2021.passes.get(PassCode_2021.ShowCompilerHelp).Do(compiler, true);
} else CommonUI.Info("Компилятор не выбран");
});
BPickOptions.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021<String> pass = Pass_2021.passes.get(PassCode_2021.PickCompilerOptions);
if (pass.Do(compiler)) {
CommonUI.TrySelect(cbFlags, pass.target);
}
}
});
cbCompilers.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
compiler = (Compiler) cbCompilers.getSelectedItem();
}
});
}
public void setListeners(ModuleAnchestor target) {
boolean linker = (target instanceof Makefile);
LanguageName languageName = linker ?
(Current.HasProject() ? Current.getProject().languageName : LanguageName.n) :
((Module) target).language;
cbCompilers.addActionListener(e -> {
if (cbCompilers.getSelectedItem() instanceof Compiler) {
Compiler compiler = ((Compiler) cbCompilers.getSelectedItem());
CommonUI.TrySelect(cbCommands,
linker ? compiler.getSpecialLinkCommand(languageName) : compiler.getSpecialCompilationCommand(languageName));
}
});
}
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
cbFlags = new StyledTextComboBox();
}
}

View File

@@ -0,0 +1,110 @@
package _VisualDVM.GlobalData.Module.UI;
import Common.CommonConstants;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.Module.ModuleAnchestor;
import _VisualDVM.ProjectData.LanguageName;
public class ModuleAnchestorForm<T extends ModuleAnchestor> extends DBObjectDialog<T, ModuleAnchestorFields> {
public static String[] banned_flags = new String[]{
"-c", "-o",
"-ffree-form", "-ffixed-line-length-132", "-ffixed-form",
"-FI", "-f90",
"-fixed", "-free"
};
String command;
String flags;
public ModuleAnchestorForm() {
super(ModuleAnchestorFields.class);
}
@Override
public int getDefaultHeight() {
return 250;
}
@Override
public void validateFields() {
Compiler compiler = (Compiler) fields.cbCompilers.getSelectedItem();
command = (String) fields.cbCommands.getSelectedItem();
if (command == null) {
Log.Writeln("команда компиляции не выбрана");
} else {
if ((compiler != null) && compiler.type.equals(CompilerType.dvm)) {
//проверим команду.
if (Result instanceof Makefile) {
//могут быть только flink/clink
if (!command.equals("flink") && !command.equals("clink")
&&
!command.equals("f") && !command.equals("c")
) {
Log.Writeln("При линковке DVM системой допустимы\n" +
"только команды f,с, flink или clink");
}
} else if (Result instanceof Module) {
//могут быть только f/c
LanguageName languageName = ((Module) Result).language;
switch (languageName) {
case fortran:
case c:
if (!command.equals(languageName.getDVMCompile()))
Log.Writeln("компиляция " + languageName.getDescription() +
" программ DVM системой осуществляется только командой " +
languageName.getDVMCompile()
);
break;
default:
Log.Writeln("язык " + languageName + " не поддерживается DVM системой");
break;
}
}
} else {
if (!command.isEmpty())
Log.Writeln("Для всех компиляторов, кроме DVM системы, команда компиляции/линковки должна быть пуста.");
}
}
flags = (String) fields.cbFlags.getSelectedItem();
if (flags == null) Log.Writeln("флаги компиляции не выбраны");
else {
//проверка на служебные флаги
String[] data = flags.split(" ");
for (String flag : data) {
if (!flag.isEmpty()) {
/*
if (!flag.startsWith("-")) {
Log.Writeln("неверный формат флага " + Utils.Brackets(flag));
} else {
*/
for (String banned_flag : banned_flags) {
if (flag.equalsIgnoreCase(banned_flag)) {
Log.Writeln("флаги:\n" +
String.join(",", banned_flags) +
"\арезервированы системой.");
return;
}
// }
}
}
}
}
//проврка команды
}
@Override
public void fillFields() {
CommonUI.TrySelect(fields.cbFlags, Result.flags);
CommonUI.TrySelect(fields.cbCommands, Result.command);
CommonUI.TrySelect(fields.cbCompilers, Result.getCompiler());
//--------------------------------------------
fields.setListeners(Result);
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Compiler compiler = (Compiler) fields.cbCompilers.getSelectedItem();
Result.compiler_id = (compiler != null) ? compiler.id : CommonConstants.Nan;
Result.command = command;
Result.flags = flags;
}
}

View File

@@ -0,0 +1,37 @@
package _VisualDVM.GlobalData.RemoteFile;
import java.io.Serializable;
public class RemoteFile implements Serializable {
public String name;
public String full_name;
public String parent;
public boolean isDirectory;
public long updateTime;
public RemoteFile(String path, boolean isDirectory_in) {
full_name = path;
isDirectory = isDirectory_in;
String[] data = full_name.split("/");
name = (data.length > 0) ? data[data.length - 1] : "";
int i = full_name.lastIndexOf('/');
parent = (i > 0) ? full_name.substring(0, i) : "/";
}
public RemoteFile(String parent_in, String name_in, boolean isDirectory_in) {
parent = parent_in;
full_name = parent + (parent.endsWith("/") ? "" : "/") + name_in;
name = name_in;
isDirectory = isDirectory_in;
}
public RemoteFile(RemoteFile parent_in, String name_in){
this(parent_in.full_name, name_in);
}
public RemoteFile(String parent_in, String name_in) {
this(parent_in, name_in, false);
}
public static long convertUpdateTime(int mtime) {
return (long) mtime * 1000L;
}
public boolean isDirectory() {
return isDirectory;
}
}

View File

@@ -0,0 +1,97 @@
package _VisualDVM.GlobalData.RemoteFile.UI;
import Common.CurrentAnchestor;
import Common.Utils.CommonUtils;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.Windows.Dialog.Dialog;
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import com.jcraft.jsch.ChannelSftp.LsEntry;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Collections;
import java.util.Comparator;
import java.util.Vector;
public class RemoteFileChooser extends Dialog<String, RemoteFileChooserFields> {
public DefaultMutableTreeNode root = new DefaultMutableTreeNode("нет данных");
ConnectionPass session;
RemoteFile root_file;
boolean target_is_directory = false;
public RemoteFileChooser() {
super(RemoteFileChooserFields.class);
}
@Override
public boolean NeedsScroll() {
return false;
}
@Override
public void Init(Object... params) {
session = (ConnectionPass) params[0];
target_is_directory = (boolean) params[1];
try {
Refresh(session.user.connection.sftpChannel.pwd());
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
onCancel(); //закрываем окно.
}
}
public void ShowCurrentRemoteFile() {
fields.lCurrentFile.setText(Current.getRemoteFile().full_name);
}
public void Refresh(String path) {
try {
CurrentAnchestor.set(Current.RemoteFile, null);//сброс текущего файла перед любым обновлением.
fields.lCurrentFile.setText("?");
//-------------------------------------------------------------------
root_file = new RemoteFile(path, true);
root = new DefaultMutableTreeNode(root_file);
//-------------------------------------------------------
Vector<LsEntry> files = session.user.connection.sftpChannel.ls(path);
Vector<RemoteFile> directories_ = new Vector<>();
Vector<RemoteFile> files_ = new Vector<>();
//отсортировать по принадлежности.
for (LsEntry file : files) {
if (!file.getFilename().equals(".") && !file.getFilename().equals("")) {
if (file.getAttrs().isDir())
directories_.add(new RemoteFile(root_file.full_name, file.getFilename(), true));
else
files_.add(new RemoteFile(root_file.full_name, file.getFilename(), false));
}
}
//отсортировать по алфавиту
Collections.sort(directories_, Comparator.comparing(o -> o.name));
Collections.sort(files_, Comparator.comparing(o -> o.name));
for (RemoteFile f : directories_)
root.add(new DefaultMutableTreeNode(f));
for (RemoteFile f : files_)
root.add(new DefaultMutableTreeNode(f));
//просто пересоздаем дерево
fields.treeForm.Show();
fields.lCurrentFolder.setText(path);
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
onCancel();
}
}
public void goHome() {
try {
Refresh(session.user.connection.sftpChannel.getHome());
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
onCancel(); //закрываем окно.
}
}
public void goUp() {
if (!root_file.full_name.equals("/")) {
Refresh(root_file.parent);
} else CommonUI.Info("Корневая папка файловой системы достигнута.");
}
@Override
public void validateFields() {
String target_name = target_is_directory ? "папка" : "файл";
if (Current.HasRemoteFile()) {
if (target_is_directory != Current.getRemoteFile().isDirectory)
Log.Writeln("Выбранный объект - не " + target_name);
} else Log.Writeln(target_name + " не выбран(а)");
}
}

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.RemoteFile.UI.RemoteFileChooserFields">
<grid id="27dc6" binding="MainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<toolbar id="62a2c">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="3bc36" class="javax.swing.JButton" binding="bBack">
<constraints/>
<properties>
<icon value="icons/Back.png"/>
<text value=""/>
<toolTipText value="Уровень выше"/>
</properties>
</component>
<component id="57f3e" class="javax.swing.JButton" binding="bHome">
<constraints/>
<properties>
<icon value="icons/Home.png"/>
<text value=""/>
<toolTipText value="Домой"/>
</properties>
</component>
</children>
</toolbar>
<grid id="a6308" binding="TreePanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<toolbar id="6bcce">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="e92d5" class="javax.swing.JLabel">
<constraints/>
<properties>
<font name="Times New Roman" size="16" style="1"/>
<foreground color="-16777216"/>
<text value="Текущая папка: "/>
</properties>
</component>
<component id="b3611" class="javax.swing.JLabel" binding="lCurrentFolder">
<constraints/>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<foreground color="-16777216"/>
<text value="?"/>
</properties>
</component>
</children>
</toolbar>
<toolbar id="1602e">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="bf8aa" class="javax.swing.JLabel">
<constraints/>
<properties>
<font name="Times New Roman" size="16" style="1"/>
<foreground color="-16777216"/>
<text value=" выбрано: "/>
</properties>
</component>
<component id="2408c" class="javax.swing.JLabel" binding="lCurrentFile">
<constraints/>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<foreground color="-16777216"/>
<text value="?"/>
</properties>
</component>
</children>
</toolbar>
</children>
</grid>
</form>

View File

@@ -0,0 +1,40 @@
package _VisualDVM.GlobalData.RemoteFile.UI;
import Common.Visual.Trees.TreeForm;
import _VisualDVM.Visual.UI;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class RemoteFileChooserFields implements DialogFields {
public JPanel MainPanel;
public JLabel lCurrentFolder;
public JLabel lCurrentFile;
public TreeForm treeForm;
private JPanel TreePanel;
private JButton bBack;
private JButton bHome;
public RemoteFileChooserFields() {
bBack.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UI.getRemoteFileChooser().goUp();
}
});
bHome.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UI.getRemoteFileChooser().goHome();
}
});
}
private void createUIComponents() {
// TODO: place custom component creation code here
TreePanel = (treeForm = new TreeForm(RemoteFilesTree.class)).getContent();
}
@Override
public Component getContent() {
return MainPanel;
}
}

View File

@@ -0,0 +1,26 @@
package _VisualDVM.GlobalData.RemoteFile.UI;
import Common.Visual.CommonUI;
import Common.Visual.Fonts.VisualiserFonts;
import Common.Visual.Trees.StyledTreeCellRenderer;
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
public class RemoteFileRenderer extends StyledTreeCellRenderer {
public java.awt.Component getTreeCellRendererComponent(
JTree tree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
Object o = ((DefaultMutableTreeNode) value).getUserObject();
if (o instanceof RemoteFile) {
RemoteFile file = (RemoteFile) o;
setText(file.name);
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.TreePlain));
if (file.isDirectory())
setIcon(new ImageIcon(getClass().getResource("/icons/Folder.png")));
}
setForeground(tree.getForeground());
return this;
}
}

View File

@@ -0,0 +1,28 @@
package _VisualDVM.GlobalData.RemoteFile.UI;
import _VisualDVM.Current;
import Common.Visual.Trees.DataTree;
import Common.Visual.Trees.TreeRenderers;
import _VisualDVM.Visual.UI;
public class RemoteFilesTree extends DataTree {
public RemoteFilesTree() {
super(UI.getRemoteFileChooser().root);
}
@Override
public TreeRenderers getRenderer() {
return TreeRenderers.RendererRemoteFile;
}
@Override
public Current getCurrent() {
return Current.RemoteFile;
}
@Override
public void ShowCurrentObject() {
UI.getRemoteFileChooser().ShowCurrentRemoteFile();
}
@Override
public void LeftMouseAction2() {
if (Current.HasRemoteFile() && Current.getRemoteFile().isDirectory()) {
UI.getRemoteFileChooser().Refresh(Current.getRemoteFile().full_name);
}
}
}

View File

@@ -0,0 +1,258 @@
package _VisualDVM.GlobalData.RunConfiguration;
import Common.CommonConstants;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import Common.Utils.TextLog;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValue;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import _VisualDVM.GlobalData.Tasks.TaskState;
import _VisualDVM.ProjectData.Project.db_project_info;
import Visual_DVM_2021.Passes.PassException;
import com.sun.org.glassfish.gmbal.Description;
import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.stream.IntStream;
public class RunConfiguration extends iDBObject {
public static final int maxProc = 16;
public int machine_id;
//---------------------------------------->
@Description("DEFAULT -1")
public int compiler_id = CommonConstants.Nan;
public String LauncherCall = ""; //например DVM или mpirun
public String LauncherOptions = ""; //например run
//--------------------------------------
//---------------------------------------
//в случае mpi всегда одномерная. в случае DVM может быть многомерной
//------------------------>>
@Description("DEFAULT ''")
public String matrix = ""; //решетка. устаревшее поле.
//------------------------>>
@Description("DEFAULT ''")
public String minMatrix = "";
@Description("DEFAULT ''")
public String maxMatrix = "";
@Description("DEFAULT 0")
public int dim = 0;
@Description("DEFAULT 0")
public int cube = 0;
//------------------------>>
//аргументы командной строки - в линию- для запуска
public String args = ""; //аргументы КС
//---------------------------------------
@Description("DEFAULT 0")
public int gcov = 0; //совместимость. гков отныне только на локалке.
public static Vector<Integer> getBounds(String bounds) {
String[] dims_ = bounds.split(" ");
Vector<Integer> res = new Vector<>();
for (String dim_ : dims_) {
int dim = 1;
try {
dim = Integer.parseInt(dim_);
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
}
res.add(dim);
}
return res;
}
public static boolean checkCube(Vector<Integer> m) {
return IntStream.range(1, m.size()).allMatch(j -> m.get(j).equals(m.get(0)));
}
public static void gen_rec(Vector<Integer> from, Vector<Integer> to, Vector<Vector<Integer>> res, int index, int dim_, boolean cube_) {
if (index < dim_) {
Vector<Vector<Integer>> old = new Vector<>();
for (Vector<Integer> L : res)
old.add(L);
res.clear();
for (int i = from.get(index); i <= to.get(index); ++i) {
for (Vector<Integer> L : old) {
Vector<Integer> buffer = new Vector<>(L);
buffer.add(i);
if (!cube_ || checkCube(buffer))
res.add(buffer);
}
}
gen_rec(from, to, res, index + 1, dim_, cube_);
}
}
//для окна конфигурации.
public static void validateMatrixes(String minMatrix_, String maxMatrix_, int dim_, boolean cube_, TextLog log) {
Vector<Vector<Integer>> res_ = new Vector<>();
Vector<String> res = new Vector<>();
if (dim_ > 0) {
Vector<Integer> from = getBounds(minMatrix_);
Vector<Integer> to = getBounds(maxMatrix_);
if (from.size() != to.size()) {
log.Writeln_("Верхняя и нижняя границы матриц конфигурации имеют разные размерности");
return;
}
if (from.size() != dim_) {
log.Writeln_("Границы матриц не совпадают с размерностью конфигурации");
return;
}
//1 стадия. заполнение.
for (int j = from.get(0); j <= to.get(0); ++j) {
Vector<Integer> m = new Vector<>();
res_.add(m);
m.add(j);
}
//---
if (dim_ > 1)
gen_rec(from, to, res_, 1, dim_, cube_);
for (Vector<Integer> m : res_) {
Vector<String> ms = new Vector<>();
for (int i : m)
ms.add(String.valueOf(i));
res.add(String.join(" ", ms));
}
} else
res.add("");
if (res.isEmpty())
log.Writeln_("По заданным границам не будет сгенерировано ни одной матрицы.");
}
//---------------------------------------->
public Compiler getCompiler() {
return CommonUtils.db.getById(Compiler.class, compiler_id);
}
public boolean isCube() {
return cube != 0;
}
public void setCube(boolean cube_in) {
cube = cube_in ? 1 : 0;
}
public String printCube() {
return isCube() ? "Да" : "Нет";
}
public void Patch() {
if (!matrix.isEmpty()) {
// узнать из старой матрицы параметры минимума и максимума, и размерность.
String[] dims = matrix.split(" ");
dim = dims.length;
Vector<String> minDims = new Vector<>();
for (int i = 1; i <= dim; ++i)
minDims.add("1");
minMatrix = String.join(" ", minDims);
maxMatrix = matrix;
cube = 1;
matrix = "";
}
}
public String getDescription() {
String res = "";
if (!LauncherCall.isEmpty()) {
res += CommonUtils.Brackets(LauncherCall);
if (!LauncherOptions.isEmpty())
res += " " + CommonUtils.Brackets(LauncherOptions);
} else res = "";
return res;
}
public String getLaunchScriptText(String binary_name, String task_matrix) {
String res = "";
if (!LauncherCall.isEmpty()) {
res += CommonUtils.DQuotes(LauncherCall);
if (!LauncherOptions.isEmpty())
res += " " + LauncherOptions;
if (!task_matrix.isEmpty())
res += " " + task_matrix;
}
if (!res.isEmpty())
res += " ";
res += CommonUtils.DQuotes("./" + binary_name);
if (!args.isEmpty())
res += " " + args;
return res;
}
public String getLaunchShortDescription() {
String res = "";
if (compiler_id != CommonConstants.Nan) {
res += getCompiler().description;
if (!LauncherOptions.isEmpty())
res += " " + LauncherOptions;
}
if (!res.isEmpty())
res += " ";
if (!args.isEmpty())
res += " " + args;
return res;
}
@Override
public boolean isVisible() {
return Current.HasMachine() && (machine_id == Current.getMachine().id);
}
@Override
public String getFKName() {
return "run_configuration_id";
}
public Vector<String> getEnvList() {
return CommonUtils.db.getVectorStringByFK(this, EnvironmentValue.class);
}
public Vector<String> getParList() {
return CommonUtils.db.getVectorStringByFK(this, DVMParameter.class);
}
public LinkedHashMap<String, String> getEnvMap() {
LinkedHashMap<Integer, EnvironmentValue> envs = CommonUtils.db.getMapByFKi(this, EnvironmentValue.class);
LinkedHashMap<String, String> res = new LinkedHashMap<>();
for (EnvironmentValue e : envs.values()) {
if (!res.containsKey(e.name))
res.put(e.name, e.value);
}
return res;
}
public Vector<String> getMatrixes() throws Exception {
Vector<Vector<Integer>> res_ = new Vector<>();
Vector<String> res = new Vector<>();
if (dim > 0) {
Vector<Integer> from = getBounds(minMatrix);
Vector<Integer> to = getBounds(maxMatrix);
if (from.size() != to.size())
throw new PassException("Верхняя и нижняя границы матриц конфигурации имеют разные размерности");
if (from.size() != dim)
throw new PassException("Границы матриц не совпадают с размерностью конфигурации");
//1 стадия. заполнение.
for (int j = from.get(0); j <= to.get(0); ++j) {
Vector<Integer> m = new Vector<>();
res_.add(m);
m.add(j);
}
//---
if (dim > 1)
gen_rec(from, to, res_, 1, dim, isCube());
for (Vector<Integer> m : res_) {
Vector<String> ms = new Vector<>();
for (int i : m)
ms.add(String.valueOf(i));
res.add(String.join(" ", ms));
}
} else
res.add("");
if (res.isEmpty())
throw new PassException("Конфигурация не содержит ни одной матрицы.");
return res;
}
public Vector<RunTask> generateRunTasks(db_project_info info, CompilationTask ctask) throws Exception {
Vector<RunTask> res = new Vector<>();
Vector<String> matrixes_ = getMatrixes();
for (String matrix_ : matrixes_) {
RunTask task = new RunTask();
//->
task.machine_id = machine_id;
task.user_id = ctask.user_id;
task.run_configuration_id = id;
task.compilation_task_id = ctask.id;
task.project_path = info.Home.getAbsolutePath();
task.project_description = info.description;
//------------------------------------------
task.matrix = matrix_;
task.maxtime = info.run_maxtime;
task.state = TaskState.Inactive;
//->
res.add(task);
}
return res;
}
}

View File

@@ -0,0 +1,171 @@
package _VisualDVM.GlobalData.RunConfiguration;
import Common.CommonConstants;
import Common.Utils.CommonUtils;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValue;
import _VisualDVM.GlobalData.GlobalDatabase;
import _VisualDVM.GlobalData.RunConfiguration.UI.MatrixBar;
import _VisualDVM.GlobalData.RunConfiguration.UI.RunConfigurationFields;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
public class RunConfigurationsDBTable extends iDBTable<RunConfiguration> {
public RunConfigurationsDBTable() {
super(RunConfiguration.class);
}
@Override
public String getSingleDescription() {
return "конфигурация запуска";
}
@Override
public String getPluralDescription() {
return "конфигурации запуска";
}
@Override
public DBObjectDialog<RunConfiguration, RunConfigurationFields> getDialog() {
return new DBObjectDialog<RunConfiguration, RunConfigurationFields>(RunConfigurationFields.class) {
@Override
public void fillFields() {
for (Compiler compiler : ((GlobalDatabase)CommonUtils.db).compilers.Data.values()) {
if (compiler.isVisible() && compiler.type.equals(CompilerType.dvm))
fields.cbLauncherCall.addItem(compiler);
}
CommonUI.TrySelect_s(fields.cbLauncherCall, Result.LauncherCall);
CommonUI.TrySelect(fields.cbLaunchOptions, Result.LauncherOptions);
fields.tfArgs.setText(Result.args);
fields.cbLauncherCall.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (fields.cbLauncherCall.getSelectedItem() instanceof Compiler) {
CommonUI.TrySelect(fields.cbLaunchOptions, "run");
}
}
});
fields.cbCube.setSelected(Result.isCube());
//------------------------------------------->>>
fields.sMaxDim.setModel(new SpinnerNumberModel(
Result.dim,
0, RunConfiguration.maxProc, 1));
fields.minMatrixPanel.add(fields.minMatrixBar = new MatrixBar(Result.minMatrix));
fields.maxMatrixPanel.add(fields.maxMatrixBar = new MatrixBar(Result.maxMatrix));
//------------------------------------------->>>
if (!edit)
fields.sMaxDim.setValue(Current.getProject().maxdim);
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.LauncherCall = fields.cbLauncherCall.getSelectedItem().toString();
Result.LauncherOptions = (String) fields.cbLaunchOptions.getSelectedItem();
if (fields.cbLauncherCall.getSelectedItem() instanceof Compiler) {
Result.compiler_id = ((Compiler) (fields.cbLauncherCall.getSelectedItem())).id;
} else Result.compiler_id = CommonConstants.Nan;
//-
Result.dim = (int) fields.sMaxDim.getValue();
Result.minMatrix = fields.minMatrixBar.pack(Result.dim);
Result.maxMatrix = fields.maxMatrixBar.pack(Result.dim);
//-
Result.args = fields.tfArgs.getText();
Result.cube = fields.cbCube.isSelected() ? 1 : 0;
}
@Override
public void validateFields() {
String launcher_call = fields.cbLauncherCall.getSelectedItem().toString();
String launcher_options = (String) fields.cbLaunchOptions.getSelectedItem();
if (launcher_call.isEmpty() && !launcher_options.isEmpty())
Log.Writeln_("Непустые опции запуска допускаются только для DVM системы или MPI");
if (fields.cbLauncherCall.getSelectedItem() instanceof Compiler) {
Compiler compiler = (Compiler) (fields.cbLauncherCall.getSelectedItem());
switch (compiler.type) {
case dvm:
case mpi:
int dim_ = (int) fields.sMaxDim.getValue();
RunConfiguration.validateMatrixes(
fields.minMatrixBar.pack(dim_),
fields.maxMatrixBar.pack(dim_),
dim_,
fields.cbCube.isSelected(),
Log
);
break;
}
}
}
};
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(RunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(EnvironmentValue.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(DVMParameter.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Команда",
"Опции",
"Разм.",
"Куб",
"Min",
"Max",
"Аргументы"
};
}
@Override
public Object getFieldAt(RunConfiguration object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.LauncherCall;
case 2:
return object.LauncherOptions;
case 3:
return object.dim;
case 4:
return object.printCube();
case 5:
return object.minMatrix;
case 6:
return object.maxMatrix;
case 7:
return object.args;
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.RunConfiguration;
}
public void Patch() throws Exception {
for (RunConfiguration c : Data.values()) {
c.Patch();
getDb().Update(c);
}
}
}

View File

@@ -0,0 +1,13 @@
package _VisualDVM.GlobalData.RunConfiguration;
import Common.Visual.Menus.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
import javax.swing.*;
public class RunConfigurationsMenuBar extends DataMenuBar {
public RunConfigurationsMenuBar() {
super("конфигурации запуска", PassCode_2021.Run,
PassCode_2021.AddRunConfiguration, PassCode_2021.EditRunConfiguration, PassCode_2021.DeleteRunConfiguration);
add(new JSeparator());
addPasses(PassCode_2021.EditProjectRunMaxtime);
}
}

View File

@@ -0,0 +1,36 @@
package _VisualDVM.GlobalData.RunConfiguration.UI;
import javax.swing.*;
import java.util.Vector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class MatrixBar extends JToolBar {
public Vector<JSpinner> dimensions = new Vector<>();
public MatrixBar(String bounds) {
this.setFloatable(false);
if (!bounds.isEmpty()) {
String[] sDims = bounds.split(" ");
for (String sDim : sDims) {
JSpinner S = new MatrixDimensionSpinner(Integer.parseInt(sDim));
dimensions.add(S);
add(S);
}
}
}
public void ShowTillDim(int dim) {
if (dimensions.size() < dim) {
int delta = dim - dimensions.size();
// UI.Info("needs additions "+delta);
for (int i = 0; i < delta; ++i) {
JSpinner S = new MatrixDimensionSpinner(1);
dimensions.add(S);
add(S);
}
}
for (int i = 0; i < dimensions.size(); ++i)
dimensions.get(i).setVisible((i + 1) <= dim);
this.revalidate();
}
public String pack(int dim) {
return String.join(" ", IntStream.range(0, dim).mapToObj(i -> dimensions.get(i).getValue().toString()).collect(Collectors.toCollection(Vector::new)));
}
}

View File

@@ -0,0 +1,14 @@
package _VisualDVM.GlobalData.RunConfiguration.UI;
import javax.swing.*;
import java.awt.*;
public class MatrixDimensionSpinner extends JSpinner {
public MatrixDimensionSpinner(int value_in) {
java.awt.Dimension p = new Dimension(40, 26);
setMinimumSize(p);
setMaximumSize(p);
setPreferredSize(p);
setModel(new SpinnerNumberModel(
value_in,
1, 16, 1));
}
}

View File

@@ -0,0 +1,212 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.RunConfiguration.UI.RunConfigurationFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="754" height="402"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<splitpane id="e15f7">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties>
<dividerLocation value="87"/>
<dividerSize value="3"/>
<orientation value="0"/>
</properties>
<border type="none"/>
<children>
<grid id="23b61" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="left"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="56586" class="javax.swing.JTextField" binding="tfArgs" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="d5d38" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="аргументы"/>
</properties>
</component>
</children>
</grid>
<grid id="9b48" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="right"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<tabbedpane id="8af45" binding="taskTypeTabs">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="7b7aa" layout-manager="GridLayoutManager" row-count="6" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Параметры запуска"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="39e4a">
<constraints>
<grid row="5" column="1" row-span="1" col-span="7" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="6e0a2" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="вызов системы"/>
</properties>
</component>
<component id="5328f" class="javax.swing.JComboBox" binding="cbLaunchOptions">
<constraints>
<grid row="1" column="1" row-span="1" col-span="7" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="false"/>
<font name="Times New Roman" size="16" style="0"/>
<model>
<item value=""/>
<item value="run"/>
<item value="-np"/>
<item value="-n"/>
<item value="-ppn"/>
</model>
<toolTipText value="Выберите из списка дополнительную команду компиляции ( актуально для DVM компиляторов)"/>
</properties>
</component>
<component id="24ab4" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="опции"/>
</properties>
</component>
<component id="61e12" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="нижние границы решётки"/>
</properties>
</component>
<component id="e88a9" class="javax.swing.JComboBox" binding="cbLauncherCall">
<constraints>
<grid row="0" column="1" row-span="1" col-span="7" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="false"/>
<font name="Times New Roman" size="16" style="0"/>
<model>
<item value=""/>
<item value="mpirun"/>
<item value="mpiexec"/>
</model>
<toolTipText value="Выберите из списка дополнительную команду компиляции ( актуально для DVM компиляторов)"/>
</properties>
</component>
<component id="6ae5a" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="верхние границы решёток"/>
</properties>
</component>
<component id="b2e51" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="размерность решёток"/>
</properties>
</component>
<component id="cac73" class="javax.swing.JSpinner" binding="sMaxDim">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="40" height="28"/>
<preferred-size width="40" height="28"/>
<maximum-size width="40" height="28"/>
</grid>
</constraints>
<properties/>
</component>
<grid id="70852" binding="minMatrixPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="3" column="1" row-span="1" col-span="7" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="ca8e6" binding="maxMatrixPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="4" column="1" row-span="1" col-span="7" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="924db" class="javax.swing.JCheckBox" binding="cbCube">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<horizontalAlignment value="0"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="кубические решётки"/>
<toolTipText value="матрица с одинаковым размером измерений"/>
</properties>
</component>
<hspacer id="22de8">
<constraints>
<grid row="2" column="3" row-span="1" col-span="5" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</children>
</tabbedpane>
</children>
</grid>
</children>
</splitpane>
</children>
</grid>
</form>

View File

@@ -0,0 +1,38 @@
package _VisualDVM.GlobalData.RunConfiguration.UI;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class RunConfigurationFields implements DialogFields {
public JPanel content;
public JTabbedPane taskTypeTabs;
public JTextField tfArgs;
public JComboBox cbLaunchOptions;
public JComboBox cbLauncherCall;
public JButton bHelp;
//---------------------------------------->>
public JSpinner sMaxDim;
public JPanel minMatrixPanel;
public JPanel maxMatrixPanel;
public JCheckBox cbCube;
//---------------------------------------->>
public MatrixBar minMatrixBar;
public MatrixBar maxMatrixBar;
//---------------------------------------->>
public RunConfigurationFields() {
sMaxDim.addChangeListener(e -> {
minMatrixBar.ShowTillDim((Integer) sMaxDim.getValue());
maxMatrixBar.ShowTillDim((Integer) sMaxDim.getValue());
content.revalidate();
});
}
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfArgs = new StyledTextField();
}
}

View File

@@ -0,0 +1,9 @@
package _VisualDVM.GlobalData.SapforProfile;
import Common.Database.Objects.iDBObject;
import com.sun.org.glassfish.gmbal.Description;
public class SapforProfile extends iDBObject {
@Description("DEFAULT ''")
public String description = "";
@Description("DEFAULT 0")
public long creationDate= 0;
}

View File

@@ -0,0 +1,68 @@
package _VisualDVM.GlobalData.SapforProfile;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import _VisualDVM.GlobalData.SapforProfile.UI.SapforProfileFields;
import _VisualDVM.GlobalData.SapforProfileSetting.SapforProfileSetting;
import java.util.Date;
import java.util.LinkedHashMap;
public class SapforProfilesDBTable extends iDBTable<SapforProfile> {
public SapforProfilesDBTable() {
super(SapforProfile.class);
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this);
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Описание",
"Дата создания"
};
}
@Override
public Object getFieldAt(SapforProfile object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.description;
case 2:
return new Date(object.creationDate);
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.SapforProfile;
}
@Override
public DBObjectDialog<SapforProfile, SapforProfileFields> getDialog() {
return new DBObjectDialog<SapforProfile, SapforProfileFields>(SapforProfileFields.class) {
@Override
public int getDefaultHeight() {
return 250;
}
@Override
public void fillFields() {
fields.tfDescription.setText(edit ? Result.description : "По умолчанию");
}
@Override
public void ProcessResult() {
Result.description = fields.tfDescription.getText();
}
};
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(SapforProfileSetting.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
}

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.SapforProfile.UI.SapforProfileFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="6fa91" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="описание"/>
</properties>
</component>
<vspacer id="977ca">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="27b53" class="javax.swing.JTextField" binding="tfDescription" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,18 @@
package _VisualDVM.GlobalData.SapforProfile.UI;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class SapforProfileFields implements DialogFields {
private JPanel content;
public JTextField tfDescription;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfDescription = new StyledTextField();
}
}

View File

@@ -0,0 +1,18 @@
package _VisualDVM.GlobalData.SapforProfileSetting;
import Common.CommonConstants;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import _VisualDVM.GlobalData.Settings.SettingName;
import com.sun.org.glassfish.gmbal.Description;
public class SapforProfileSetting extends iDBObject {
@Description("DEFAULT 'Undefined'")
public SettingName name = SettingName.Undefined;
@Description("DEFAULT ''")
public String value = "";
@Description("DEFAULT -1")
public int sapforprofile_id = CommonConstants.Nan;
@Override
public boolean isVisible() {
return Current.HasSapforProfile() && Current.getSapforProfile().id == sapforprofile_id;
}
}

View File

@@ -0,0 +1,40 @@
package _VisualDVM.GlobalData.SapforProfileSetting;
import _VisualDVM.Current;
import Common.Database.Tables.iDBTable;
import Common.Visual.DataSetControlForm;
public class SapforProfileSettingsDBTable extends iDBTable<SapforProfileSetting> {
public SapforProfileSettingsDBTable() {
super(SapforProfileSetting.class);
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
@Override
public Current CurrentName() {
return Current.SapforProfileSetting;
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"имя",
"значение"
};
}
@Override
public Object getFieldAt(SapforProfileSetting object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.name.getDescription();
case 2:
return object.value;
default:
return null;
}
}
}

View File

@@ -0,0 +1,95 @@
package _VisualDVM.GlobalData.Settings;
import Common.Database.Objects.DBObject;
import Common.Utils.CommonUtils;
import _VisualDVM.Visual.Menus.StableMenuItem;
import _VisualDVM.Repository.Component.ComponentType;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import com.sun.org.glassfish.gmbal.Description;
import javax.swing.*;
import java.awt.event.ActionEvent;
public class DBSetting extends DBObject {
@Description("PRIMARY KEY,UNIQUE")
public SettingName Name;
public String Value;
public ComponentType Owner;
@Description("IGNORE")
public boolean Visible = true;
@Description("IGNORE")
public SettingType settingType = SettingType.Undefined;
private JMenuItem menu_item = null;
public DBSetting() {
}
public DBSetting(SettingName Name_,
Object Value_,
SettingType type_in,
ComponentType owner_in,
boolean Visible_in) {
Name = Name_;
Value = Value_.toString();
settingType = type_in;
Owner = owner_in;
Visible = Visible_in;
}
public DBSetting (SettingName Name_, String Value_){
Name = Name_;
Value = Value_;
}
public DBSetting(SettingName Name_,
Object Value_,
SettingType type_in,
ComponentType owner_in
) {
this(Name_, Value_, type_in, owner_in, true);
}
public JMenuItem getMenuItem() {
if (menu_item == null) {
menu_item = new StableMenuItem(Name.getDescription());
menu_item.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021.passes.get(PassCode_2021.UpdateSetting).Do(Name);
}
});
Mark();
}
return menu_item;
}
/*
* булевского типа не надо. только 0 или 1
*/
//заводить разные типы настроек не надо.
//иначе придется ковыряться с типами и таблицами в бд
public void Mark() {
switch (settingType) {
case SapforFlag:
getMenuItem().setIcon(CommonUtils.getIcon(toBoolean() ? "/icons/Pick.png" : "/icons/NotPick.png"));
break;
case PercentField:
getMenuItem().setText(Name.getDescription() + " : " + this + "%");
break;
case StringField:
String valueToShow = Value.isEmpty()? "не задано": CommonUtils.Quotes(toString());
getMenuItem().setText(Name.getDescription() + " : " + valueToShow);
break;
case IntField:
getMenuItem().setText(Name.getDescription() + " : " + this);
break;
}
}
public int toInt32() {
return Integer.parseInt(Value);
}
public boolean toBoolean() {
return toInt32() != 0;
}
@Override
public String toString() {
return Value;
}
@Override
public Object getPK() {
return Name;
}
}

View File

@@ -0,0 +1,167 @@
package _VisualDVM.GlobalData.Settings;
public enum SettingName {
Undefined,
//
//совместимость
ConfirmPassesStart,
ShowPassesDone,
FocusPassesResult,
AutoUpdateSearch,
AutoSubscribeTest,
VersionsMultiSelection,
FilesMultiSelection,
//----------------------------------
ProjectsSearchDirectory,
LastVersionPath,
EditorFontSize,
//---------------------------------
AutoBugReportsLoad,
AutoTestsLoad,
//-
AutoSynchronizeRecipients,
FastAccessPassesCount,
LastOpenedProjectsCount,
Workspace,
RegisterOn,
SpacesOn,
EmptyLinesOn,
FortranWrapsOn,
ExtensionsOn,
ComparsionDiffMergeOn,
DarkThemeOn,
ShowFullArraysDeclarations,
ShowFullTabsNames,
LocalMakePathWindows,
SmallScreen,
Precompilation,
SaveModifications, // сохранять исходную версию
GCOVLimit,
DVMConvertationOptions,
Kernels,
Email, //для тестирования. потом.
Pause, //стоит ли тестрование на паузе.
Queue, //хз нужна ли. будет пересказ пакета в проходе.
BugReportsAgeLimit,
//---
DVMPackageMaxId,
SAPFORPackageId,
//---
TaskMaxId, //вместо TaskCounter
SapforTaskMaxId, //для тестирования Сапфора.
//отображения галок в деревьях.
//--
//<editor-fold desc="Настройки сапфора. должны быть подряд!">
STATIC_SHADOW_ANALYSIS,
STATIC_PRIVATE_ANALYSIS,
FREE_FORM,
KEEP_DVM_DIRECTIVES,
KEEP_SPF_DIRECTIVES,
PARALLELIZE_FREE_LOOPS,
MAX_SHADOW_WIDTH,
OUTPUT_UPPER,
TRANSLATE_MESSAGES,
KEEP_LOOPS_CLOSE_NESTING,
KEEP_GCOV,
ANALYSIS_OPTIONS,
DEBUG_PRINT_ON,
MPI_PROGRAM,
IGNORE_IO_SAPFOR,
KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS,
PARSE_FOR_INLINE,
EMPTY_OPTION
;
public static SettingName getByDescription(String desc) {
SettingName[] all = SettingName.values();
for (SettingName settingName : all)
if (desc.equals(settingName.getDescription())) return settingName;
return Undefined;
}
public String getDescription() {
switch (this) {
case BugReportsAgeLimit:
return "Срок хранения отчетов об ошибках (месяцы)";
case SaveModifications:
return "Сохранять копию исходной версии при преобразованиях";
case ComparsionDiffMergeOn:
return "Автоматическое сравнение";
case DVMConvertationOptions:
return "Опции DVM конвертации";
case Kernels:
return "Число ядер при компиляции";
case GCOVLimit:
return "Нижний порог отображения GCOV";
case Precompilation:
return "Предварительная компиляция";
case SmallScreen:
return "Маленький экран";
case LocalMakePathWindows:
return "Путь к make.exe";
case ShowFullTabsNames:
return "Показывать полные имена вкладок";
case ShowFullArraysDeclarations:
return "Показывать развернутый список объявлений массивов";
case ExtensionsOn:
return "Учитывать расширения файлов";
case DarkThemeOn:
return "Тёмная тема редактора кода";
case FortranWrapsOn:
return "Учитывать переносы";
case EmptyLinesOn:
return "Учитывать пустые строки";
case SpacesOn:
return "Учитывать пробелы и табуляции";
case RegisterOn:
return "Учитывать регистр";
case Workspace:
return "Рабочее пространство визуализатора";
case AutoBugReportsLoad:
return "Автоматическая синхронизация отчётов об ошибках";
case AutoTestsLoad:
return "Автоматическая синхронизация системы тестирования";
case STATIC_SHADOW_ANALYSIS:
return "Оптимизация теневых обменов";
case STATIC_PRIVATE_ANALYSIS:
return "Статический анализ приватностей";
case FREE_FORM:
return "Свободный выходной стиль";
case KEEP_DVM_DIRECTIVES:
return "Учитывать DVM директивы";
case KEEP_SPF_DIRECTIVES:
return "Сохранять SPF директивы при построении параллельных вариантов";
case PARALLELIZE_FREE_LOOPS:
return "Улучшенное распараллеливание";
case MAX_SHADOW_WIDTH:
return "Максимальный размер теневых граней";
case OUTPUT_UPPER:
return "Верхний выходной регистр";
case TRANSLATE_MESSAGES:
return "Сообщения на русском языке";
case KEEP_LOOPS_CLOSE_NESTING:
return "Учитывать тесную вложенность циклов";
case KEEP_GCOV:
return "Учитывать GCOV";
case ANALYSIS_OPTIONS:
return "Опции анализа";
case DEBUG_PRINT_ON:
return "Включить отладочную печать";
case MPI_PROGRAM:
return "Общая память";
case IGNORE_IO_SAPFOR:
return "Игнорировать ввод/вывод";
case KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS:
return "Сохранять SPF директивы при преобразованиях";
case PARSE_FOR_INLINE:
return "Синтаксический анализ для подстановки";
case AutoSubscribeTest:
return "Автоматическая проверка подписки";
case AutoSynchronizeRecipients:
return "Автоматическое извлечение адресатов";
case FastAccessPassesCount:
return "Число проходов на панели быстрого доступа";
case LastOpenedProjectsCount:
return "Число отображаемых последних открытых проектов";
}
return "";
}
}
//</editor-fold>

View File

@@ -0,0 +1,8 @@
package _VisualDVM.GlobalData.Settings;
public enum SettingType {
Undefined,
SapforFlag,
PercentField,
StringField,
IntField
}

View File

@@ -0,0 +1,97 @@
package _VisualDVM.GlobalData.Settings;
import Common.Database.Tables.DBTable;
import Common.Utils.CommonUtils;
import _VisualDVM.Utils;
import _VisualDVM.Repository.Component.ComponentType;
import java.util.Vector;
import java.util.stream.Collectors;
public class SettingsDBTable extends DBTable<SettingName, DBSetting> {
public SettingsDBTable() {
super(SettingName.class, DBSetting.class);
}
@Override
public String getSingleDescription() {
return "настройка";
}
public void AddSetting(DBSetting s) throws Exception {
if (containsKey(s.Name)) {
DBSetting old = get(s.Name);
old.settingType = s.settingType;
old.Visible = s.Visible;
//патч на всегда включить.
if (s.Name.equals(SettingName.STATIC_PRIVATE_ANALYSIS) && !old.Value.equals("1")) {
old.Value = "1";
getDb().Update(s);
}
//---------------------------------------->>
} else
this.getDb().Insert(s);
}
public void AddAll() throws Exception {
//проверка списка всех настроек.
//<editor-fold desc="Global">
AddSetting(new DBSetting(SettingName.ProjectsSearchDirectory, "", SettingType.StringField, ComponentType.Visualiser, false));
AddSetting(new DBSetting(SettingName.EditorFontSize, "14", SettingType.StringField, ComponentType.Visualiser, false));
AddSetting(new DBSetting(SettingName.DarkThemeOn, 0, SettingType.SapforFlag, ComponentType.Visualiser, false));
// AddSetting(new DBSetting(SettingName.FocusPassesResult, 1, SettingType.SapforFlag, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.ShowFullArraysDeclarations, 0, SettingType.SapforFlag, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.ShowFullTabsNames, 0, SettingType.SapforFlag, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.FastAccessPassesCount, 5, SettingType.IntField, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.LastOpenedProjectsCount, 5, SettingType.IntField, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.Workspace, "", SettingType.StringField, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.Kernels, Utils.getHalfKernels(), SettingType.IntField, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.AutoBugReportsLoad, 0, SettingType.SapforFlag, ComponentType.Visualiser, true));
AddSetting(new DBSetting(SettingName.AutoTestsLoad, 0, SettingType.SapforFlag, ComponentType.Visualiser, true));
if (CommonUtils.isWindows())
AddSetting(new DBSetting(SettingName.LocalMakePathWindows, "C:\\MinGW\\msys\\1.0\\bin\\make.exe", SettingType.StringField, ComponentType.Visualiser));
AddSetting(new DBSetting(SettingName.SmallScreen, 0, SettingType.SapforFlag, ComponentType.Visualiser));
//совместимость. указываем явно чтобы не были видны в меню.
AddSetting(new DBSetting(SettingName.AutoSubscribeTest, 0, SettingType.SapforFlag, ComponentType.Visualiser, false));
//</editor-fold>
//--
//<editor-fold desc="Sapfor">
//при добавлении новых. учесть SapforTasksPackage (добавить поле)
//и Global.packSapforSettings (добавить запаковку поля в конец)
AddSetting(new DBSetting(SettingName.STATIC_SHADOW_ANALYSIS, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.STATIC_PRIVATE_ANALYSIS, 1, SettingType.SapforFlag, ComponentType.SapforOptions, false));
AddSetting(new DBSetting(SettingName.FREE_FORM, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.KEEP_DVM_DIRECTIVES, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.KEEP_SPF_DIRECTIVES, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.PARALLELIZE_FREE_LOOPS, 0, SettingType.SapforFlag, ComponentType.SapforOptions, false));
AddSetting(new DBSetting(SettingName.MAX_SHADOW_WIDTH, 50, SettingType.PercentField, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.OUTPUT_UPPER, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.TRANSLATE_MESSAGES, 1, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.KEEP_LOOPS_CLOSE_NESTING, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.KEEP_GCOV, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.ANALYSIS_OPTIONS, " ", SettingType.StringField, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.DEBUG_PRINT_ON, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.MPI_PROGRAM, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.IGNORE_IO_SAPFOR, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS, 1, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.PARSE_FOR_INLINE, 0, SettingType.SapforFlag, ComponentType.SapforOptions, false));
//--> косвенные, анализам не передаются.
AddSetting(new DBSetting(SettingName.Precompilation, 0, SettingType.SapforFlag, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.GCOVLimit, 10, SettingType.PercentField, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.DVMConvertationOptions, " ", SettingType.StringField, ComponentType.SapforOptions));
AddSetting(new DBSetting(SettingName.SaveModifications, 1, SettingType.SapforFlag, ComponentType.SapforOptions));
//</editor-fold>
//-
//<editor-fold desc="Comparsion">
AddSetting(new DBSetting(SettingName.ExtensionsOn, 0, SettingType.SapforFlag, ComponentType.ComparsionOptions));
AddSetting(new DBSetting(SettingName.RegisterOn, 0, SettingType.SapforFlag, ComponentType.ComparsionOptions));
AddSetting(new DBSetting(SettingName.SpacesOn, 1, SettingType.SapforFlag, ComponentType.ComparsionOptions));
AddSetting(new DBSetting(SettingName.EmptyLinesOn, 1, SettingType.SapforFlag, ComponentType.ComparsionOptions));
AddSetting(new DBSetting(SettingName.FortranWrapsOn, 1, SettingType.SapforFlag, ComponentType.ComparsionOptions));
AddSetting(new DBSetting(SettingName.ComparsionDiffMergeOn, 0, SettingType.SapforFlag, ComponentType.ComparsionOptions));
//</editor-fold>
AddSetting(new DBSetting(SettingName.BugReportsAgeLimit, 2, SettingType.IntField, ComponentType.Visualiser));
}
public Vector<DBSetting> getSettingsByOwner(ComponentType owner) {
return Data.values().stream().filter(setting -> setting.Owner.equals(owner)).collect(Collectors.toCollection(Vector::new));
}
public String getSapforSettingsText() {
return "настройки SAPFOR\n" + String.join("\n",
getSettingsByOwner(ComponentType.SapforOptions).stream().map(s -> " " + s.Name.getDescription() + "=" + s.Value).collect(Collectors.toCollection(Vector::new)));
}
}

View File

@@ -0,0 +1,22 @@
package _VisualDVM.GlobalData.Splitter;
import Common.CommonConstants;
import Common.Database.Objects.DBObject;
import com.sun.org.glassfish.gmbal.Description;
import javax.swing.*;
public class Splitter extends DBObject {
@Description("PRIMARY KEY, UNIQUE")
public String name = "";
@Description("DEFAULT -1")
public int position = CommonConstants.Nan;
public Splitter() {
}
public Splitter(JSplitPane splitPane) {
name = splitPane.getName();
position = splitPane.getDividerLocation();
}
@Override
public Object getPK() {
return name;
}
}

View File

@@ -0,0 +1,50 @@
package _VisualDVM.GlobalData.Splitter;
import Common.Database.Tables.DBTable;
import Common.Utils.CommonUtils;
import javax.swing.*;
import java.lang.reflect.Field;
import java.util.Vector;
public class SplittersDBTable extends DBTable<String, Splitter> {
public SplittersDBTable() {
super(String.class, Splitter.class);
}
private Vector<JSplitPane> InitSplitters(Object form) throws Exception {
Vector<JSplitPane> res = new Vector<>();
Class c = form.getClass();
for (Field field : c.getFields()) {
if (field.getType().getSimpleName().equals("JSplitPane")) {
JSplitPane splitPane = (JSplitPane) field.get(form);
splitPane.setName(field.getName());
res.add(splitPane);
}
}
return res;
}
public void Load(Object form) {
try {
Vector<JSplitPane> splitters = InitSplitters(form);
for (JSplitPane splitPane : splitters) {
if (Data.containsKey(splitPane.getName())) {
splitPane.setDividerLocation(Data.get(splitPane.getName()).position);
} else {
getDb().Insert(new Splitter(splitPane));
}
}
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
}
}
public void Save(Object form) {
try {
Vector<JSplitPane> splitters = InitSplitters(form);
for (JSplitPane splitPane : splitters) {
Splitter splitter = Data.get(splitPane.getName());
splitter.position = splitPane.getDividerLocation();
getDb().Update(splitter);
}
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
}
}
}

View File

@@ -0,0 +1,113 @@
package _VisualDVM.GlobalData.Tasks.CompilationTask;
import Common.CommonConstants;
import Common.CurrentAnchestor;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import _VisualDVM.GlobalData.GlobalDatabase;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import _VisualDVM.GlobalData.Tasks.Task;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.ProjectData.Project.db_project_info;
import com.sun.org.glassfish.gmbal.Description;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.LinkedHashMap;
public class CompilationTask extends Task {
public int makefile_id = CommonConstants.Nan;
public String binary_name = ""; //исполняемый файл.
//---------------------------------------------------
@Description("DEFAULT ''")
public String linkerDescription = "";
@Description("DEFAULT ''")
public String linkFlags = "";
//для отображения.
//-------------------
@Description("DEFAULT ''")
public String fortranCompilerDescription = "";
@Description("DEFAULT ''")
public String fortranFlags = "";
//-------------------
@Description("DEFAULT ''")
public String cCompilerDescription = "";
@Description("DEFAULT ''")
public String cFlags = "";
//------------------
@Description("DEFAULT ''")
public String cppCompilerDescription = "";
@Description("DEFAULT ''")
public String cppFlags = "";
//---------------------------------------------------
public void CompleteSummary(int maxtime_in) throws Exception {
maxtime = maxtime_in;
Makefile makefile = getMakefile();
LinkedHashMap<LanguageName, Module> modules = makefile.getModules();
linkerDescription = makefile.getCompilerDescription();
linkFlags = makefile.flags;
for (Module module : modules.values()) {
switch (module.language) {
case fortran:
fortranCompilerDescription = module.getCompilerDescription();
fortranFlags = module.flags;
break;
case c:
cCompilerDescription = module.getCompilerDescription();
cFlags = module.flags;
break;
case cpp:
cppCompilerDescription = module.getCompilerDescription();
cppFlags = module.flags;
break;
}
}
CommonUtils.db.Update(this);
}
//---------------------------------------------------
@Override
public File getHome() {
return Global.CompilationTasksDirectory;
}
@Override
public boolean isVisible() {
return
CurrentAnchestor.matchCurrentID(Current.Machine, machine_id) &&
CurrentAnchestor.matchCurrentID(Current.User, user_id) &&
Current.HasProject() &&
belongsToProject(Current.getProject());
}
public Makefile getMakefile() {
return CommonUtils.db.getById(Makefile.class, makefile_id);
}
@Override
public String getFullCommand() {
return "make -j -f Makefile";
}
public LinkedHashMap<Integer, RunTask> getRunTasks() {
LinkedHashMap<Integer, RunTask> res = new LinkedHashMap<>();
//так не получится. не правильно назвал ключевое поле. F...
// return Global.db.getMapByFKi(this, RunTask.class);
for (RunTask runTask : ((GlobalDatabase)CommonUtils.db).runTasks.Data.values()) {
if (runTask.compilation_task_id == id)
res.put(runTask.id, runTask);
}
return res;
}
@Override
public void AnalyzeResultsTexts(db_project_info project) throws Exception {
String output = getOutput();
String errors = getErrors();
for (DBProjectFile file : project.db.files.Data.values()) {
if (!file.last_assembly_name.isEmpty()) {
String replacement = file.last_assembly_name + " " + CommonUtils.RBrackets(file.name);
output = output.replace(file.last_assembly_name, replacement);
errors = errors.replace(file.last_assembly_name, replacement);
}
}
FileUtils.writeStringToFile(getOutputFile(), output);
FileUtils.writeStringToFile(getErrorsFile(), errors);
}
}

View File

@@ -0,0 +1,124 @@
package _VisualDVM.GlobalData.Tasks.CompilationTask;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import Common.Visual.Menus.TableMenu;
import _VisualDVM.Visual.UI;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import java.util.LinkedHashMap;
import static Common.Visual.Tables.TableRenderers.RendererDate;
import static Common.Visual.Tables.TableRenderers.RendererStatusEnum;
public class CompilationTasksDBTable extends iDBTable<CompilationTask> {
public CompilationTasksDBTable() {
super(CompilationTask.class);
}
@Override
public String getSingleDescription() {
return "задача на компиляцию";
}
@Override
public String getPluralDescription() {
return "задачи на компиляцию";
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(RunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(12).setRenderer(RendererDate);
columns.get(13).setRenderer(RendererStatusEnum);
}
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getDebugWindow().DropRunTasksComparison();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getDebugWindow().DropRunTasksComparison();
}
@Override
public void CreateControl() {
super.CreateControl();
TableMenu dataTableMenu = new TableMenu(control);
dataTableMenu.add(Pass_2021.passes.get(PassCode_2021.DeleteSelectedCompilationTasks).createMenuItem());
control.setComponentPopupMenu(dataTableMenu);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"сборка",
"",
//
"Fortran",
"",
//
"С",
"",
//
"С++",
"",
"Лимит(c)",
"Время(c)",
"Дата",
"Статус"
};
}
@Override
public Object getFieldAt(CompilationTask object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.linkerDescription;
case 3:
return object.linkFlags;
case 4:
return object.fortranCompilerDescription;
case 5:
return object.fortranFlags;
case 6:
return object.cCompilerDescription;
case 7:
return object.cFlags;
case 8:
return object.cppCompilerDescription;
case 9:
return object.cppFlags;
case 10:
return object.maxtime;
case 11:
return object.Time;
case 12:
return object.getEndDate();
case 13:
return object.state;
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.CompilationTask;
}
}

View File

@@ -0,0 +1,31 @@
package _VisualDVM.GlobalData.Tasks.Passes;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import _VisualDVM.GlobalData.Tasks.Supervisor.TaskSupervisor;
import Visual_DVM_2021.Passes.ProcessPass;
public abstract class TaskLocalPass<S extends TaskSupervisor> extends ProcessPass {
public S supervisor; //инициализация идет в конструкторе потомка.
public TaskLocalPass(Class<S> s_class) {
try {
supervisor = s_class.newInstance();
} catch (Exception e) {
CommonUtils.MainLog.PrintException(e);
}
}
@Override
protected boolean needsAnimation() {
return true;
}
@Override
protected void body() throws Exception {
supervisor.PerformTask();
}
@Override
protected void performFinish() throws Exception {
supervisor.UpdateTask();
}
@Override
public void Interrupt() throws Exception {
Current.getProject().CreateInterruptFile();
}
}

View File

@@ -0,0 +1,16 @@
package _VisualDVM.GlobalData.Tasks.QueueSystem;
import _VisualDVM.GlobalData.Tasks.TaskState;
public class MVS extends QueueSystem {
public MVS() {
cancel_command = "mcancel";
check_command = "mqtest";
refuse = "runmvsd: Error on queue task:Sorry, you achieved max task number. Try once more later.";
commands = new QueueCommand[]{
new QueueCommand(TaskState.Queued, "task", "queued successfully"),
new QueueCommand(TaskState.Running, "task", "is in the run"),
new QueueCommand(TaskState.Running, "task", "started successfully"),
new QueueCommand(TaskState.Finished, "task", "complete"),
new QueueCommand(TaskState.NoSuchTask, "", "no such task")
};
}
}

View File

@@ -0,0 +1,10 @@
package _VisualDVM.GlobalData.Tasks.QueueSystem;
import Common.Utils.StringTemplate;
import _VisualDVM.GlobalData.Tasks.TaskState;
public class QueueCommand extends StringTemplate {
public TaskState state; //состояние задачи в случае успешного разбора этой команды.
public QueueCommand(TaskState state_in, String p, String s) {
super(p, s);
state = state_in;
}
}

View File

@@ -0,0 +1,36 @@
package _VisualDVM.GlobalData.Tasks.QueueSystem;
import Common.Utils.CommonUtils;
import _VisualDVM.GlobalData.Tasks.Task;
import _VisualDVM.GlobalData.Tasks.TaskState;
public class QueueSystem {
public String check_command;
public String cancel_command;
public String refuse;
QueueCommand[] commands;
public void checkTask(String Output, Task task) {
for (QueueCommand command : commands)
if (command.check(Output)) {
task.state = command.state;
return;
}
}
public void enqueueTask(String Output, Task task) {
if (Output.equalsIgnoreCase(refuse))
task.state = TaskState.FailedToQueue;
else
for (QueueCommand command : commands) {
String c_res = command.check_and_get_param(Output);
if (c_res != null) {
task.PID = c_res.replace("\"", "").replace("'", "");
task.state = command.state;
return;
}
}
}
public String getCheckTaskCommand(Task task) {
return check_command + " " + CommonUtils.DQuotes(task.PID);
}
public String getCancelTaskCommand(Task task) {
return cancel_command + " " + CommonUtils.DQuotes(task.PID);
}
}

View File

@@ -0,0 +1,163 @@
package _VisualDVM.GlobalData.Tasks.RunTask;
import Common.CommonConstants;
import Common.CurrentAnchestor;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import _VisualDVM.GlobalData.GlobalDatabase;
import _VisualDVM.Global;
import Common.Utils.StringTemplate;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import _VisualDVM.GlobalData.Tasks.Task;
import _VisualDVM.GlobalData.Tasks.TaskState;
import _VisualDVM.ProjectData.Project.db_project_info;
import com.sun.org.glassfish.gmbal.Description;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
import java.util.List;
public class RunTask extends Task {
public int compilation_task_id = CommonConstants.Nan; //нужна для бинарника
public int run_configuration_id = CommonConstants.Nan;
@Description("DEFAULT ''")
public String last_sts_name = "";
@Description("DEFAULT 0")
public double CleanTime;
@Description("IGNORE")
public boolean hasDvmSts = false;
@Description("IGNORE")
public boolean hasGCOV = false;
//-------------------------------------
@Description("DEFAULT ''")
public String matrix = "";
//-------------------------------------
@Override
public void DropResults() throws Exception {
super.DropResults();
Utils.forceDeleteWithCheck(getLocalStsFile());
CleanTime = 0;
CommonUtils.db.Update(this);
}
@Override
public File getHome() {
return Global.RunTasksDirectory;
}
@Override
public String getFullCommand() {
return getRunConfiguration().getLaunchScriptText(getCompilationTask().binary_name, matrix);
}
//---------------------------------------
@Override
public boolean isVisible() {
return
CurrentAnchestor.matchCurrentID(Current.Machine, machine_id) &&
CurrentAnchestor.matchCurrentID(Current.User, user_id) &&
CurrentAnchestor.matchCurrentID(Current.RunConfiguration, run_configuration_id) &&
Current.HasProject() &&
belongsToProject(Current.getProject()) &&
Current.HasCompilationTask() &&
compilation_task_id == Current.getCompilationTask().id;
}
public RunConfiguration getRunConfiguration() {
return ((GlobalDatabase)CommonUtils.db).runConfigurations.Data.get(run_configuration_id);
}
public CompilationTask getCompilationTask() {
return ((GlobalDatabase)CommonUtils.db).compilationTasks.Data.get(compilation_task_id);
}
public void UpdateLastStsName(String file_name) {
if (!last_sts_name.equals(file_name)) {
last_sts_name = file_name;
try {
CommonUtils.db.Update(this);
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
}
}
}
public File getLocalStsFile() {
return Paths.get(getLocalWorkspace().getAbsolutePath(), last_sts_name).toFile();
}
public File getLocalStsTextFile() {
return Paths.get(getLocalWorkspace().getAbsolutePath(), "statistic.txt").toFile();
}
public String getLocalStsText() {
return getTextResult(getLocalStsTextFile());
}
public void parseCleanTime() {
StringTemplate template = new StringTemplate("Time in seconds =", "");
String p = template.check_and_get_param(Utils.ReadAllText(getOutputFile()));
try {
if (p != null) CleanTime = Double.parseDouble(p);
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
}
}
@Override
public void AnalyzeOutFile(db_project_info project) throws Exception {
List<String> lines = FileUtils.readLines(getOutputFile());
if (lines.stream().anyMatch(Utils::isCrushedLine)
) {
state = TaskState.Crushed;
return;
}
//->>
//тест на корректность.
if (!lines.isEmpty() && lines.get(0).toUpperCase().contains("START OF ")) {
int complete = 0;
int errors = 0;
for (int i = 1; i < lines.size(); ++i) {
String line_ = lines.get(i).toUpperCase();
if (line_.endsWith("COMPLETE")) {
complete++;
} else if (line_.endsWith("ERROR")) {
errors++;
} else if (line_.contains("END OF")) {
if (errors > 0) state = TaskState.DoneWithErrors;
else if (complete > 0) state = TaskState.Done;
return;
}
}
}
//тест на производительность.
StringTemplate stringTemplate = new StringTemplate("Verification =", "");
for (String line : lines) {
String param = stringTemplate.check_and_get_param(line);
if (param != null) {
switch (param) {
case "SUCCESSFUL":
state = TaskState.Done;
return;
case "UNSUCCESSFUL":
state = TaskState.DoneWithErrors;
return;
default:
break;
}
}
}
}
@Override
public void AnalyzeErrorsFile(db_project_info project) throws Exception {
List<String> lines = FileUtils.readLines(getErrorsFile());
if (lines.stream().anyMatch(Utils::isCrushedLine))
state = TaskState.Crushed;
}
@Override
public void Reset() {
super.Reset();
CleanTime = 0.0;
hasDvmSts = false;
hasGCOV = false;
}
public boolean hasDVMPar() {
RunConfiguration config = getRunConfiguration();
return
config.compiler_id != CommonConstants.Nan &&
config.getCompiler().type.equals(CompilerType.dvm) &&
!config.getParList().isEmpty()
;
}
}

View File

@@ -0,0 +1,88 @@
package _VisualDVM.GlobalData.Tasks.RunTask;
import _VisualDVM.Current;
import Common.Database.Tables.iDBTable;
import Common.Visual.DataSetControlForm;
import Common.Visual.Menus.TableMenu;
import _VisualDVM.Visual.UI;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import static Common.Visual.Tables.TableRenderers.RendererDate;
import static Common.Visual.Tables.TableRenderers.RendererStatusEnum;
public class RunTasksDBTable extends iDBTable<RunTask> {
public RunTasksDBTable() {
super(RunTask.class);
}
@Override
public String getSingleDescription() {
return "задача на запуск";
}
@Override
public String getPluralDescription() {
return "задачи на запуск";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(6).setRenderer(RendererDate);
columns.get(7).setRenderer(RendererStatusEnum);
}
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getDebugWindow().ShowCurrentRunTask();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getDebugWindow().ShowNoCurrentRunTask();
}
@Override
public void CreateControl() {
super.CreateControl();
TableMenu dataTableMenu = new TableMenu(control);
dataTableMenu.add(Pass_2021.passes.get(PassCode_2021.DeleteSelectedRunTasks).createMenuItem());
control.setComponentPopupMenu(dataTableMenu);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Матрица",
"Лимит(с)",
"Время(с)",
"Чистое время",
"Дата",
"Статус"};
}
@Override
public Object getFieldAt(RunTask object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.matrix;
case 3:
return object.maxtime;
case 4:
return object.Time;
case 5:
return object.CleanTime;
case 6:
return object.getEndDate();
case 7:
return object.state;
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.RunTask;
}
}

View File

@@ -0,0 +1,43 @@
package _VisualDVM.GlobalData.Tasks.Supervisor.Local.Linux;
import Common.Utils.CommonUtils;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import _VisualDVM.GlobalData.Tasks.TaskState;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
public class LinuxLocalCompilationSupervisor extends LinuxLocalTaskSupervisor<CompilationTask> {
@Override
protected void PrepareWorkspace() throws Exception {
//возможно тут сделать отличие. не удалять все, а тоже сверять по дате и именам..
super.PrepareWorkspace();
Utils.CheckAndCleanDirectory(getProjectCopy());
//скопировать проект в папку. без бд.
project.Clone(getProjectCopy(), false);
//-удалить старый бинарник если есть? бессмысленно если папка и так полностью пересоздается при каждой компиляции.
//по идее надо исправить на синхронизацию.
//if (!task.binary_name.isEmpty()) {
// File old_binary = Paths.get(getProjectCopy().getAbsolutePath(), task.binary_name).toFile();
// FileUtils.forceDelete(old_binary);
// }
//создать мейкфайл.
Makefile makefile = task.getMakefile();
File makefile_text = Paths.get(getProjectCopy().getAbsolutePath(), "Makefile").toFile();
FileUtils.write(makefile_text, makefile.Generate(project));
}
@Override
protected void ValidateTaskResults() throws Exception {
if (getBinary().exists()) {
File renamed_binary = Paths.get(getProjectCopy().getAbsolutePath(),
CommonUtils.getDateName("spf")).toFile();
task.binary_name = renamed_binary.getName();
Files.move(getBinary().toPath(), renamed_binary.toPath(), StandardCopyOption.REPLACE_EXISTING);
task.state = TaskState.Done;
} else task.state = TaskState.DoneWithErrors;
task.AnalyzeResultsTexts(project);
}
}

View File

@@ -0,0 +1,32 @@
package _VisualDVM.GlobalData.Tasks.Supervisor.Local.Linux;
import _VisualDVM.Current;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import java.util.Map;
public class LinuxLocalRunSupervisor extends LinuxLocalTaskSupervisor<RunTask> {
@Override
protected void PrepareWorkspace() throws Exception {
super.PrepareWorkspace();
PrepareRunTaskWorkspace(task);
}
@Override
protected void AchieveResults() throws Exception {
super.AchieveResults();
AchieveRunTaskResults(task);
}
@Override
protected Map<String, String> getEnvs() {
return Current.getRunConfiguration().getEnvMap();
}
@Override
protected String getScriptText() {
return "ulimit -s unlimited\n" + super.getScriptText();
}
@Override
protected void ValidateTaskResults() throws Exception {
task.AnalyzeResultsTexts(project);
}
protected String getCoupDeGrace() {
return "killall -SIGKILL " + task.getCompilationTask().binary_name;
}
}

View File

@@ -0,0 +1,83 @@
package _VisualDVM.GlobalData.Tasks.Supervisor.Local.Linux;
import Common.Utils.CommonUtils;
import _VisualDVM.Constants;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.Tasks.Supervisor.Local.LocalTaskSupervisor;
import _VisualDVM.GlobalData.Tasks.Task;
import _VisualDVM.GlobalData.Tasks.TaskState;
import _VisualDVM.GlobalData.User.User;
import Visual_DVM_2021.Passes.PassException;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Date;
public abstract class LinuxLocalTaskSupervisor<T extends Task> extends LocalTaskSupervisor<T> {
@Override
protected void StartTask() throws Exception {
super.StartTask();
task.PID = Utils.readLine(taskProcess);
}
@Override
protected String getScriptText() {
User user = task.getUser();
return
String.join(" ",
CommonUtils.DQuotes(user.getStarterFile()),
CommonUtils.DQuotes(user.getLauncherFile()),
String.valueOf(task.maxtime),
CommonUtils.DQuotes(getCoupDeGrace()),
task.getFullCommand()
);
}
@Override
protected void CheckTask() throws Exception {
if (getDONE_file().exists())
task.state = TaskState.Finished;
else if (getTIMEOUT_file().exists())
task.state = TaskState.AbortedByTimeout;
}
@Override
protected String getKillCommand() {
return "kill -2 " + task.PID;
}
@Override
public void WaitForTask() throws Exception {
if (isTaskActive()) {
if (task.PID.isEmpty())
throw new PassException("Ошибка при старте : идентификатор задачи не определен.");
task.StartDate = (new Date()).getTime();
pass.ShowMessage1("Задача активна, идентификатор " + CommonUtils.Brackets(task.PID));
RefreshProgress();
do {
Thread.sleep(getTaskCheckPeriod() * 1000L);
performanceTime += getTaskCheckPeriod();
CheckTask();
if (isTaskActive()) CheckIfNeedAbort();
RefreshProgress();
} while (isTaskActive());
}
}
protected File getProjectTime() {
return Paths.get(getProjectCopy().getAbsolutePath(), Constants.time_file).toFile();
}
protected File getDONE_file() {
return Paths.get(getProjectCopy().getAbsolutePath(), Constants.DONE).toFile();
}
protected File getTIMEOUT_file() {
return Paths.get(getProjectCopy().getAbsolutePath(), Constants.TIMEOUT).toFile();
}
@Override
protected void PrepareWorkspace() throws Exception {
super.PrepareWorkspace();
Utils.forceDeleteWithCheck(getDONE_file());
Utils.forceDeleteWithCheck(getTIMEOUT_file());
Utils.forceDeleteWithCheck(getProjectTime());
}
@Override
protected void CalculatePerformanceTime() throws Exception {
Files.move(getProjectTime().toPath(), task.getTimeFile().toPath(), StandardCopyOption.REPLACE_EXISTING);
task.RefreshTime();
}
}

Some files were not shown because too many files have changed in this diff Show More