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

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

@@ -44,7 +44,7 @@ public class AddBugReport extends AddObjectPass<BugReport> {
target.sender_address = Global.mainModule.getAccount().email;
target.project_version = "";
target.visualiser_version = Global.visualiser.version;
target.sapfor_version = Global.Components.get(ComponentType.Sapfor_F).version;
target.sapfor_version = Global.components.get(ComponentType.Sapfor_F).version;
target.sapfor_settings = (Global.mainModule.getDb()).settings.getSapforSettingsText();
target.percentage = 0;
target.description = "Черновик отчёта об ошибке.\nЗаполните описание ошибочной ситуации, и нажмите 'Опубликовать'";
@@ -72,7 +72,7 @@ public class AddBugReport extends AddObjectPass<BugReport> {
logs.add(Utils_.MainLog.getLogFile());
logs.add(Paths.get(Global.ComponentsDirectory.getAbsolutePath(), "Sapfor_log.txt").toFile());
logs.add(Paths.get(Global.ComponentsDirectory.getAbsolutePath(), "Server_log.txt").toFile());
logs.add(Global.Components.get(ComponentType.Visualizer_2).getLogFile());
logs.add(Global.components.get(ComponentType.Visualizer_2).getLogFile());
for (File file : logs) {
if (file.exists())
Files.copy(file.toPath(), Paths.get(attachementsDir.getAbsolutePath(), file.getName()), StandardCopyOption.REPLACE_EXISTING);

View File

@@ -20,21 +20,21 @@ public class GetComponentsActualVersions extends ComponentsRepositoryPass {
@Override
protected void ServerAction() throws Exception {
Vector<String> versions = new Vector<>();
for (Component component : Global.Components.Data.values())
for (Component component : Global.components.Data.values())
//if (component.isVisible())
versions.add(component.getComponentType().toString());
Command(new ServerExchangeUnit_2021(ServerCode.GetComponentsVersions, String.join("\n", versions)));
LinkedHashMap<ComponentType, String> response_actual_versions = (LinkedHashMap<ComponentType, String>) response.object;
for (ComponentType componentType : response_actual_versions.keySet()) {
Global.Components.get(componentType).unpackActualVersion(response_actual_versions.get(componentType));
Global.components.get(componentType).unpackActualVersion(response_actual_versions.get(componentType));
}
//-- получить актуальные версии с сервера.
Command(new ServerExchangeUnit_2021(ServerCode.GetComponentsMinimalVersions, String.join("\n", versions)));
LinkedHashMap<ComponentType, String> response_minimal_versions = (LinkedHashMap<ComponentType, String>) response.object;
for (ComponentType componentType : response_minimal_versions.keySet()) {
Global.Components.get(componentType).unpackMinimalVersion(response_minimal_versions.get(componentType));
Global.components.get(componentType).unpackMinimalVersion(response_minimal_versions.get(componentType));
}
for (Component component : Global.Components.Data.values()) {
for (Component component : Global.components.Data.values()) {
if (component.CanBeUpdated())
component.CheckIfNeedsUpdateOrPublish();
}

View File

@@ -48,6 +48,6 @@ public class InstallComponentFromFolder extends CurrentComponentPass {
}
@Override
protected void showDone() throws Exception {
Global.RefreshUpdatesStatus();
Global.components.RefreshUpdatesStatus();
}
}

View File

@@ -120,7 +120,7 @@ public class PublishComponent extends ComponentsRepositoryPass<Component> {
}
@Override
protected void showDone() throws Exception {
Global.RefreshUpdatesStatus();
Global.components.RefreshUpdatesStatus();
}
}

View File

@@ -58,6 +58,6 @@ public class ResurrectComponent extends CurrentComponentPass {
}
@Override
protected void showDone() throws Exception {
Global.RefreshUpdatesStatus();
Global.components.RefreshUpdatesStatus();
}
}

View File

@@ -116,6 +116,6 @@ public class ResurrectComponentFromServer extends CurrentComponentPass {
}
@Override
protected void showDone() throws Exception {
Global.RefreshUpdatesStatus();
Global.components.RefreshUpdatesStatus();
}
}

View File

@@ -16,7 +16,7 @@ public class ShowInstruction extends Pass<File> {
}
@Override
protected boolean canStart(Object... args) throws Exception {
target = Global.Components.get(ComponentType.Instruction).getFile();
target = Global.components.get(ComponentType.Instruction).getFile();
if (!target.exists()) {
Log.Writeln("файл инструкции:\n" + target.getAbsolutePath() + "\е найден! Обновите компонент 'Инструкция'");
return false;

View File

@@ -43,6 +43,6 @@ public class UpdateComponent extends Pass<Component> {
}
@Override
protected void showDone() throws Exception {
Global.RefreshUpdatesStatus();
Global.components.RefreshUpdatesStatus();
}
}

View File

@@ -22,18 +22,18 @@ public class UpdateSelectedComponents extends Pass<Vector<Component>> {
protected boolean canStart(Object... args) throws Exception {
target = new Vector<>();
//------------------------
if (Global.Components.getUI().getSelectedCount() == 0) {
if (Global.components.getUI().getSelectedCount() == 0) {
Log.Writeln_("Не отмечено ни одного компонента!");
return false;
}
target = Global.Components.getUI().getSelectedItems();
target = Global.components.getUI().getSelectedItems();
return true;
}
@Override
public String getStartDescription() {
Vector<String> question = new Vector<>();
question.add("Обновить компоненты");
for (Component component : Global.Components.getUI().getSelectedItems()) {
for (Component component : Global.components.getUI().getSelectedItems()) {
question.add(component.getComponentType().getDescription());
}
return String.join("\n", question);
@@ -41,7 +41,7 @@ public class UpdateSelectedComponents extends Pass<Vector<Component>> {
@Override
protected void body() throws Exception {
for (Component component : target) {
Global.Components.getUI().SetCurrentByPK(component.getPK());
Global.components.getUI().SetCurrentByPK(component.getPK());
Global.mainModule.getPass(PassCode.UpdateComponent).Do();
}
}