продолжение рефакторинга. создал предка для класса current

This commit is contained in:
2024-10-08 00:39:13 +03:00
parent 3516b58127
commit d0c08a2c7e
157 changed files with 648 additions and 421 deletions

View File

@@ -1,7 +1,7 @@
package Common_old;
import Common.CurrentAnchestor;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Syntax.VisualiserTheme;
import Common.Utils.TextLog;
import GlobalData.Account.Account;
import GlobalData.Compiler.Compiler;
import GlobalData.Machine.Machine;
@@ -26,15 +26,13 @@ import Visual_DVM_2021.Passes.UI.PassForm;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.util.LinkedHashMap;
public enum Current {
Undefined,
public enum Current implements CurrentAnchestor {
//--
DVMPackage,
SapforPackage,
//--
ServerSapfor,
SapforEtalonVersion,//самый левый пакет
SapforEtalonVersion,
SapforVersion,
//--
//--
@@ -109,159 +107,155 @@ public enum Current {
DVMRunTask,
SapforSettings,
SapforSettingsCommand,
DVMSettings,
;
//-
private static final LinkedHashMap<Current, Object> objects = new LinkedHashMap<>();
DVMSettings;
public static Mode mode;
public static boolean hasUI() {
return Current.mode.equals(Current.Mode.Normal);
}
public static boolean HasProject() {
return get(Project) != null;
return CurrentAnchestor.get(Project) != null;
}
public static boolean HasFile() {
return get(File) != null;
return CurrentAnchestor.get(File) != null;
}
public static boolean HasSelectedFile() {
return get(SelectedFile) != null;
return CurrentAnchestor.get(SelectedFile) != null;
}
public static boolean HasAccount() {
return get(Account) != null;
return CurrentAnchestor.get(Account) != null;
}
public static boolean HasMachine() {
return get(Machine) != null;
return CurrentAnchestor.get(Machine) != null;
}
public static boolean HasUser() {
return get(User) != null;
return CurrentAnchestor.get(User) != null;
}
public static boolean HasCompiler() {
return get(Compiler) != null;
return CurrentAnchestor.get(Compiler) != null;
}
public static boolean HasRemoteFile() {
return get(RemoteFile) != null;
return CurrentAnchestor.get(RemoteFile) != null;
}
public static boolean HasMakefile() {
return get(Makefile) != null;
return CurrentAnchestor.get(Makefile) != null;
}
public static boolean HasRunConfiguration() {
return get(RunConfiguration) != null;
return CurrentAnchestor.get(RunConfiguration) != null;
}
public static boolean HasCompilationTask() {
return get(CompilationTask) != null;
return CurrentAnchestor.get(CompilationTask) != null;
}
public static boolean HasRunTask() {
return get(RunTask) != null;
return CurrentAnchestor.get(RunTask) != null;
}
public static boolean HasPassForm() {
return get(PassForm) != null;
return CurrentAnchestor.get(PassForm) != null;
}
public static boolean HasProjectView() {
return get(ProjectView) != null;
return CurrentAnchestor.get(ProjectView) != null;
}
//для быстрого доступа на чтение. слишком много на нем завязано.
public static SapforSettings getSapforSettings() {
return (SapforSettings) get(SapforSettings);
return (SapforSettings) CurrentAnchestor.get(SapforSettings);
}
public static boolean HasSapforSettings() {
return get(SapforSettings) != null;
return CurrentAnchestor.get(SapforSettings) != null;
}
public static db_project_info getProject() {
return (db_project_info) get(Project);
return (db_project_info) CurrentAnchestor.get(Project);
}
public static DBProjectFile getFile() {
return (DBProjectFile) get(File);
return (DBProjectFile) CurrentAnchestor.get(File);
}
public static Repository.Component.Component getComponent() {
return (Repository.Component.Component) get(Component);
return (Repository.Component.Component) CurrentAnchestor.get(Component);
}
public static Repository.BugReport.BugReport getBugReport() {
return (BugReport) get(BugReport);
return (BugReport) CurrentAnchestor.get(BugReport);
}
public static db_project_info getRoot() {
return (db_project_info) get(Root);
return (db_project_info) CurrentAnchestor.get(Root);
}
public static boolean HasRoot() {
return get(Root) != null;
return CurrentAnchestor.get(Root) != null;
}
public static db_project_info getVersion() {
return (db_project_info) get(Version);
return (db_project_info) CurrentAnchestor.get(Version);
}
public static Account getAccount() {
return (Account) get(Account);
return (Account) CurrentAnchestor.get(Account);
}
public static boolean HasSubscriber() {
return get(Current.Subscriber) != null;
return CurrentAnchestor.get(Current.Subscriber) != null;
}
public static Repository.Subscribes.Subscriber getSubscriber() {
return (Subscriber) get(Current.Subscriber);
return (Subscriber) CurrentAnchestor.get(Current.Subscriber);
}
public static Machine getMachine() {
return (Machine) get(Current.Machine);
return (Machine) CurrentAnchestor.get(Current.Machine);
}
public static User getUser() {
return (User) get(Current.User);
return (User) CurrentAnchestor.get(Current.User);
}
public static Compiler getCompiler() {
return (Compiler) get(Current.Compiler);
return (Compiler) CurrentAnchestor.get(Current.Compiler);
}
public static CompilationTask getCompilationTask() {
return (CompilationTask) get(Current.CompilationTask);
return (CompilationTask) CurrentAnchestor.get(Current.CompilationTask);
}
public static RunTask getRunTask() {
return (RunTask) get(Current.RunTask);
return (RunTask) CurrentAnchestor.get(Current.RunTask);
}
public static RemoteFile getRemoteFile() {
return (RemoteFile) get(Current.RemoteFile);
return (RemoteFile) CurrentAnchestor.get(Current.RemoteFile);
}
public static Makefile getMakefile() {
return (Makefile) get(Current.Makefile);
return (Makefile) CurrentAnchestor.get(Current.Makefile);
}
public static Module getModule() {
return (Module) get(Current.Module);
return (Module) CurrentAnchestor.get(Current.Module);
}
public static RunConfiguration getRunConfiguration() {
return (RunConfiguration) get(Current.RunConfiguration);
return (RunConfiguration) CurrentAnchestor.get(Current.RunConfiguration);
}
public static Repository.Component.Sapfor.Sapfor getSapfor() {
return (Repository.Component.Sapfor.Sapfor) get(Current.Sapfor);
return (Repository.Component.Sapfor.Sapfor) CurrentAnchestor.get(Current.Sapfor);
}
public static boolean HasGroup() {
return get(Current.Group) != null;
return CurrentAnchestor.get(Current.Group) != null;
}
public static TestingSystem.Common.Group.Group getGroup() {
return (TestingSystem.Common.Group.Group) get(Current.Group);
return (TestingSystem.Common.Group.Group) CurrentAnchestor.get(Current.Group);
}
//--
public static boolean HasConfiguration() {
return get(Current.DVMConfiguration) != null;
return CurrentAnchestor.get(Current.DVMConfiguration) != null;
}
public static DVMConfiguration getDVMConfiguration() {
return (DVMConfiguration) get(Current.DVMConfiguration);
return (DVMConfiguration) CurrentAnchestor.get(Current.DVMConfiguration);
}
public static SapforConfiguration getSapforConfiguration() {
return (TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration) get(Current.SapforConfiguration);
return (TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration) CurrentAnchestor.get(Current.SapforConfiguration);
}
//--
public static Test getTest() {
return (TestingSystem.Common.Test.Test) get(Current.Test);
return (TestingSystem.Common.Test.Test) CurrentAnchestor.get(Current.Test);
}
public static boolean HasTest() {
return get(Current.Test) != null;
return CurrentAnchestor.get(Current.Test) != null;
}
public static boolean HasVersion() {
return get(Current.Version) != null;
return CurrentAnchestor.get(Current.Version) != null;
}
public static RemoteFile getComponentServerBackup() {
return (RemoteFile) get(Current.ComponentServerBackup);
return (RemoteFile) CurrentAnchestor.get(Current.ComponentServerBackup);
}
public static boolean HasComponentServerBackup() {
return get(Current.ComponentServerBackup) != null;
return CurrentAnchestor.get(Current.ComponentServerBackup) != null;
}
//-
public static DefaultMutableTreeNode getProjectNode() {
return (DefaultMutableTreeNode) get(Current.ProjectNode);
return (DefaultMutableTreeNode) CurrentAnchestor.get(Current.ProjectNode);
}
public static DefaultMutableTreeNode getProjectCurrentParentNode() {
DefaultMutableTreeNode node = Current.getProjectNode();
@@ -271,116 +265,100 @@ public enum Current {
return (node.getUserObject() instanceof DBProjectFile) ? (DefaultMutableTreeNode) node.getParent() : node;
}
public static File getSelectedDirectory() {
return (File) get(Current.SelectedDirectory);
return (File) CurrentAnchestor.get(Current.SelectedDirectory);
}
public static DBProjectFile getSelectedFile() {
return (DBProjectFile) get(Current.SelectedFile);
return (DBProjectFile) CurrentAnchestor.get(Current.SelectedFile);
}
//-
public static boolean HasBugReport() {
return get(Current.BugReport) != null;
return CurrentAnchestor.get(Current.BugReport) != null;
}
public static PassForm getPassForm() {
return (Visual_DVM_2021.Passes.UI.PassForm) get(Current.PassForm);
return (Visual_DVM_2021.Passes.UI.PassForm) CurrentAnchestor.get(Current.PassForm);
}
public static VisualiserTheme getTheme() {
return (VisualiserTheme) get(Current.Theme);
return (VisualiserTheme) CurrentAnchestor.get(Current.Theme);
}
//--------------------------------------------------------------------------------
public static ParallelRegion getParallelRegion() {
return (ParallelRegion) get(Current.ParallelRegion);
return (ParallelRegion) CurrentAnchestor.get(Current.ParallelRegion);
}
public static boolean HasParallelRegion() {
return get(Current.ParallelRegion) != null;
return CurrentAnchestor.get(Current.ParallelRegion) != null;
}
public static boolean HasFunction() {
return get(Current.Function) != null;
return CurrentAnchestor.get(Current.Function) != null;
}
public static boolean HasSelectedFunction() {
return get(Current.SelectedFunction) != null;
return CurrentAnchestor.get(Current.SelectedFunction) != null;
}
public static FuncInfo getFunction() {
return (FuncInfo) get(Current.Function);
return (FuncInfo) CurrentAnchestor.get(Current.Function);
}
public static FuncInfo getSelectionFunction() {
return (FuncInfo) get(Current.SelectedFunction);
return (FuncInfo) CurrentAnchestor.get(Current.SelectedFunction);
}
public static boolean HasScenario() {
return get(Current.Scenario) != null;
return CurrentAnchestor.get(Current.Scenario) != null;
}
public static db_project_info getPackageVersion() {
return (db_project_info) get(Current.PackageVersion);
return (db_project_info) CurrentAnchestor.get(Current.PackageVersion);
}
public static boolean HasPackageVersion() {
return get(Current.PackageVersion) != null;
return CurrentAnchestor.get(Current.PackageVersion) != null;
}
public static boolean HasSapforConfiguration() {
return get(Current.SapforConfiguration) != null;
return CurrentAnchestor.get(Current.SapforConfiguration) != null;
}
public static ProjectData.ProjectView getProjectView() {
return (ProjectData.ProjectView) get(ProjectView);
}
public static boolean Check(TextLog Log, Current... names) {
for (Current name : names)
if (get(name) == null)
Log.Writeln_(name.getDescription() + " не выбран(а)");
return Log.isEmpty();
}
public static void CreateAll() {
for (Current c : values())
objects.put(c, null);
return (ProjectData.ProjectView) CurrentAnchestor.get(ProjectView);
}
//-----------------------------------------
public static Object get(Current name) {
return objects.get(name);
}
public static Object set(Current name, Object object) {
objects.replace(name, object);
return object;
}
//применять только для наследников iDBObject
public static boolean CheckID(Current name, int id) {
return (get(name) != null) && (((iDBObject) get(name)).id == id);
return (CurrentAnchestor.get(name) != null) && (((iDBObject) CurrentAnchestor.get(name)).id == id);
}
public static boolean HasSapforProfile() {
return get(Current.SapforProfile) != null;
return CurrentAnchestor.get(Current.SapforProfile) != null;
}
public static GlobalData.SapforProfile.SapforProfile getSapforProfile() {
return (GlobalData.SapforProfile.SapforProfile) get(Current.SapforProfile);
return (GlobalData.SapforProfile.SapforProfile) CurrentAnchestor.get(Current.SapforProfile);
}
//сапфоры установленные на тестовый сервер.
public static boolean HasServerSapfor() {
return get(Current.ServerSapfor) != null;
return CurrentAnchestor.get(Current.ServerSapfor) != null;
}
public static TestingSystem.SAPFOR.ServerSapfor.ServerSapfor getServerSapfor() {
return (TestingSystem.SAPFOR.ServerSapfor.ServerSapfor) get(Current.ServerSapfor);
return (TestingSystem.SAPFOR.ServerSapfor.ServerSapfor) CurrentAnchestor.get(Current.ServerSapfor);
}
public static boolean HasSubscriberWorkspace() {
return get(Current.SubscriberWorkspace) != null;
return CurrentAnchestor.get(Current.SubscriberWorkspace) != null;
}
public static Repository.SubscriberWorkspace.SubscriberWorkspace getSubscriberWorkspace() {
return (Repository.SubscriberWorkspace.SubscriberWorkspace) get(Current.SubscriberWorkspace);
return (Repository.SubscriberWorkspace.SubscriberWorkspace) CurrentAnchestor.get(Current.SubscriberWorkspace);
}
//----->>
public static boolean HasDVMPackage() {
return get(Current.DVMPackage) != null;
return CurrentAnchestor.get(Current.DVMPackage) != null;
}
public static TestingSystem.DVM.DVMPackage.DVMPackage getDVMPackage() {
return (TestingSystem.DVM.DVMPackage.DVMPackage) get(Current.DVMPackage);
return (TestingSystem.DVM.DVMPackage.DVMPackage) CurrentAnchestor.get(Current.DVMPackage);
}
public static boolean HasSapforPackage() {
return get(Current.SapforPackage) != null;
return CurrentAnchestor.get(Current.SapforPackage) != null;
}
public static TestingSystem.SAPFOR.SapforPackage.SapforPackage getSapforPackage() {
return (TestingSystem.SAPFOR.SapforPackage.SapforPackage) get(Current.SapforPackage);
return (TestingSystem.SAPFOR.SapforPackage.SapforPackage) CurrentAnchestor.get(Current.SapforPackage);
}
public static boolean HasDVMRunTask() {
return get(Current.DVMRunTask) != null;
return CurrentAnchestor.get(Current.DVMRunTask) != null;
}
public static TestingSystem.DVM.DVMTasks.DVMRunTask getDVMRunTask() {
return (TestingSystem.DVM.DVMTasks.DVMRunTask) Current.get(Current.DVMRunTask);
return (TestingSystem.DVM.DVMTasks.DVMRunTask) CurrentAnchestor.get(Current.DVMRunTask);
}
//--------------------------------------------
@Override
public String getDescription() {
switch (this) {
case DVMSettings: