рефакторин методов связанных с компонентами.

This commit is contained in:
2024-10-22 20:16:57 +03:00
parent bf5d5442d4
commit c160a20d06
17 changed files with 98 additions and 88 deletions

View File

@@ -1,5 +1,4 @@
package _VisualDVM;
import Common.Database.Tables.DataSet;
import Common.Utils.Loggable;
import Common.Utils.Utils_;
import Common.Visual.UI;
@@ -34,7 +33,7 @@ public class Global {
public static boolean files_multiselection = false;
public static boolean versions_multiselection = false;
//??
public static DataSet<ComponentType, Component> Components = null;
public static ComponentsSet components = null;
public static MessagesServer messagesServer = null;
public static File ComponentsDirectory;
public static File DataDirectory;
@@ -60,9 +59,6 @@ public class Global {
//------------------------------------------------------------------
public static ComponentsServer componentsServer = new ComponentsServer();
public static TestingServer testingServer = new TestingServer();
public static int bad_state = 0;
public static int need_update = 0;
public static int need_publish = 0;
public static void SynschronizeProperties() {
try {
File new_propertiesFile = new File(Utils_.getHomeDirectory(), "properties");
@@ -163,41 +159,7 @@ public class Global {
}
System.exit(0);
}
//todo запихнуть в ComponentsSet
public static void RefreshUpdatesStatus() {
if (Components.getUI() != null)
Components.getUI().Refresh();
ValidateComponentsStates();
if (mainModule.getUI().hasMainWindow())
mainModule.getUI().getMainWindow().ShowUpdatesIcon();
}
public static boolean ValidateComponentsStates() {
bad_state = need_update = need_publish = 0;
for (Component component : Components.Data.values()) {
// if (component.isVisible()) {
switch (component.getState()) {
case Not_found:
case Unknown_version:
case Old_version:
if (component.isNecessary())
bad_state++;
component.Select(true);
break;
case Needs_update:
need_update++;
component.Select(true);
break;
case Needs_publish:
need_publish++;
break;
default:
component.Select(false);
break;
}
// }
}
return (bad_state == 0);
}
public static void changeSetting(SettingName settingName, Object new_value) throws Exception {
Global.mainModule.getPass(PassCode.UpdateSetting).Do(settingName, new_value);
}
@@ -235,15 +197,15 @@ public class Global {
}
messagesServer = new MessagesServer();
messagesServer.Start();
Components = new ComponentsSet();
components = new ComponentsSet();
mainModule.set(Current.ProjectView, ProjectView.Files);
Components.put(ComponentType.Visualiser, visualiser = new Visualiser());
Components.put(ComponentType.Sapfor_F, (Component) mainModule.set(Current.Sapfor, new Sapfor_F()));
Components.put(ComponentType.Visualizer_2, visualizer_2);
Components.put(ComponentType.PerformanceAnalyzer, performanceAnalyzer = new PerformanceAnalyzer());
Components.put(ComponentType.Instruction, new Instruction());
components.put(ComponentType.Visualiser, visualiser = new Visualiser());
components.put(ComponentType.Sapfor_F, (Component) mainModule.set(Current.Sapfor, new Sapfor_F()));
components.put(ComponentType.Visualizer_2, visualizer_2);
components.put(ComponentType.PerformanceAnalyzer, performanceAnalyzer = new PerformanceAnalyzer());
components.put(ComponentType.Instruction, new Instruction());
//-
for (Component component : Components.Data.values())
for (Component component : components.Data.values())
// if (component.isVisible())
component.InitialVersionCheck();
//-
@@ -255,13 +217,13 @@ public class Global {
//-------->>
if (properties.AutoUpdateSearch)
Global.mainModule.getPass(PassCode.GetComponentsActualVersions).Do();
ValidateComponentsStates();
if ((need_update > 0) || (bad_state > 0)) {
components.validateStates();
if (components.needWindow()) {
boolean flag = true;
do {
Global.mainModule.getUI().getComponentsWindow().ShowDialog("");
if (flag = (!ValidateComponentsStates())) {
if (!UI.Question("Найдено " + bad_state + " некорректных необходимых компонент.Работа визуализатора невозможна.\n" +
if (flag = (!components.validateStates())) {
if (!UI.Question("Найдено " + components.bad_state + " некорректных необходимых компонент.Работа визуализатора невозможна.\n" +
"Вернуться к окну компонент"
)) {
UI.Info("Визуализатор завершает работу.");