патч на применение настроек старых баг репортов

This commit is contained in:
2025-01-16 19:04:46 +03:00
parent 1b6db1fd5b
commit 96a269004d
10 changed files with 109 additions and 112 deletions

11
.idea/workspace.xml generated
View File

@@ -7,7 +7,16 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Project/db_project_info.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Project/db_project_info.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/AddBugReport.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/AddBugReport.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/ApplyBugReportSettings.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/ApplyBugReportSettings.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/SapforProperties.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/SapforProperties.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/BugReport.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/BugReport.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/Json/VisualiserSettingJson.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/Json/VisualiserSettingJson.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/Json/VisualiserSettingsJson.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/Json/VisualiserSettingsJson.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/Component/Visualiser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Component/Visualiser.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/CallbackForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/CallbackForm.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -3,7 +3,7 @@
"ServerAddress": "alex-freenas.ddns.net",
"ServerUserName": "testuser",
"ServerUserSHHPort": 2000,
"ComponentsServerPort": 7995,
"ComponentsServerPort": 7996,
"TestingServerPort": 7998,
"SocketTimeout": 5000,
"OldServer": false,
@@ -16,7 +16,7 @@
"collapseProjectTrees": false,
"BackupWorkspace": "_sapfor_x64_backups",
"Workspace": "E:\\Workspace",
"ProjectsSearchDirectory": "E:\\Workspace",
"ProjectsSearchDirectory": "E:\\Workspace\\bug_1588849934",
"EditorFontSize": 16,
"BackupHour": 5,
"BackupMinute": 0,

View File

@@ -46,7 +46,7 @@ public class AddBugReport extends AddObjectPass<BugReport> {
target.project_version = "";
target.visualiser_version = ComponentsSet.visualiser.version;
target.sapfor_version = Global.components.get(ComponentType.Sapfor_F).version;
target.packedSettingsJson = "";// Utils_.gson.toJson(Global.mainModule.getDb().settings.getSapforSettingsJson());
target.packedSettingsJson = "";
target.percentage = 0;
target.description = "Черновик отчёта об ошибке.\nЗаполните описание ошибочной ситуации, и нажмите 'Опубликовать'";
target.date = new Date().getTime();

View File

@@ -1,13 +1,7 @@
package _VisualDVM.Passes.All;
import Common.Passes.Pass;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Repository.BugReport.BugReport;
import _VisualDVM.Repository.BugReport.Json.VisualiserSettingJson;
import _VisualDVM.Repository.BugReport.Json.VisualiserSettingsJson;
import java.util.LinkedHashMap;
public class ApplyBugReportSettings extends Pass<BugReport> {
@Override
public String getIconPath() {
@@ -37,41 +31,6 @@ public class ApplyBugReportSettings extends Pass<BugReport> {
}
@Override
protected void body() throws Exception {
/*
LinkedHashMap<SettingName, String> to_apply = new LinkedHashMap<>();
VisualiserSettingsJson settings = Utils_.gson.fromJson(target.packedSettingsJson, VisualiserSettingsJson.class);
for (VisualiserSettingJson setting : settings.array) {
SettingName settingName = SettingName.Undefined;
try {
settingName = SettingName.valueOf(setting.name);
} catch (Exception ex) {
ex.printStackTrace();
}
if (!settingName.equals(SettingName.Undefined))
to_apply.put(settingName, setting.value);
}
*/
/*
String[] lines = target.sapfor_settings.split("\n");
LinkedHashMap<SettingName, String> to_apply = new LinkedHashMap<>();
for (int i = 1; i < lines.length; ++i) {
SettingName settingName = SettingName.getByDescription(lines[i].substring(4, lines[i].indexOf('=')));
String settingValue = lines[i].substring(lines[i].indexOf('=') + 1);
if (!settingName.equals(SettingName.Undefined))
to_apply.put(settingName, settingValue);
}
*/
//сохранить текущие настройки как профиль
// Global.db.rewriteProfileByDescription("Saved Profile");
//--
//само применение.
/*
for (SettingName settingName : to_apply.keySet())
Global.mainModule.getPass(PassCode.UpdateSetting).Do(
settingName,
to_apply.get(settingName));
*/
//сохранить настройки бага как профиль
// Global.db.rewriteProfileByDescription(target.id);
Global.mainModule.getProject().sapforProperties.applyPatch(target.getSettingsJson());
}
}

View File

@@ -1,12 +1,16 @@
package _VisualDVM.ProjectData.SapforData;
import Common.Properties;
import Common.Utils.Utils_;
import Common.Utils.Vector_;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Repository.BugReport.Json.VisualiserSettingJson;
import _VisualDVM.Repository.BugReport.Json.VisualiserSettingsJson;
import com.google.gson.annotations.Expose;
import javax.swing.*;
import java.io.File;
import java.lang.reflect.Field;
import java.util.Vector;
public class SapforProperties extends Properties {
//побочные настройки визулизатора
@@ -161,4 +165,63 @@ public class SapforProperties extends Properties {
public boolean controlAction(String fieldName, JMenuItem control) {
return (Global.mainModule.getPass(PassCode.UpdateSapforProperty).Do(fieldName));
}
public String getSummary(){
Vector<String> res = new Vector<>();
for (Field field: this.getClass().getFields()){
try {
res.add(getFieldDescription(field.getName()) + "=" + field.get(this));
}
catch (Exception ex){
ex.printStackTrace();
}
}
return String.join("\n", res);
}
public void applyPatch(VisualiserSettingsJson settings){
Vector<String> changedFields = new Vector<>();
try {
for (VisualiserSettingJson setting : settings.array) {
System.out.println(setting.name+"="+ Utils_.Brackets(setting.value));
Field field = null;
try {
field = getClass().getField(setting.name);
}
catch (Exception ex){
ex.printStackTrace();
}
if (field!=null) {
if (field.getName().equals(setting.name)) {
changedFields.add(setting.name);
switch (setting.name) {
case "GCOVLimit":
GCOVLimit = Integer.parseInt(setting.value);
break;
case "MAX_SHADOW_WIDTH":
MAX_SHADOW_WIDTH = Integer.parseInt(setting.value);
break;
case "ANALYSIS_OPTIONS":
ANALYSIS_OPTIONS = setting.value;
break;
case "DVMConvertationOptions":
DVMConvertationOptions = setting.value;
break;
default:
int value_ = Integer.parseInt(setting.value);
field.set(this, value_ != 0);
break;
}
}
}
}
if (!changedFields.isEmpty()) {
this.Update();
for (String fieldName: changedFields){
Mark(fieldName, getMenuItem(fieldName));
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@@ -3,7 +3,9 @@ import Common.Database.Objects.DBObject;
import Common.Database.Objects.rDBObject;
import Common.Utils.TextLog;
import Common.Utils.Utils_;
import Common.Utils.Vector_;
import _VisualDVM.Global;
import _VisualDVM.ProjectData.SapforData.SapforProperties;
import _VisualDVM.Repository.BugReport.Json.RecipientJson;
import _VisualDVM.Repository.BugReport.Json.RecipientsJson;
import _VisualDVM.Repository.BugReport.Json.VisualiserSettingsJson;
@@ -25,7 +27,7 @@ public class BugReport extends rDBObject {
@Description("DEFAULT ''")
public String packedRecipientsJson = "";
@Description("DEFAULT ''")
public String packedSettingsJson = "";
public String packedSettingsJson = ""; //устарело. (?)
public String executor = "";
@Description("DEFAULT ''")
public String executor_address = "";
@@ -50,7 +52,7 @@ public class BugReport extends rDBObject {
project_version = version_in;
visualiser_version = ComponentsSet.visualiser.version;
sapfor_version = Global.components.get(ComponentType.Sapfor_F).version;
packedSettingsJson = ""; //Utils_.gson.toJson(Global.mainModule.getDb().settings.getSapforSettingsJson());
packedSettingsJson = Utils_.gson.toJson(Global.mainModule.getProject().sapforProperties);
percentage = 0;
description = description_in;
date = new Date().getTime();
@@ -90,7 +92,6 @@ public class BugReport extends rDBObject {
return (data.length > 0) ? data[0] : "";
} else return "";
}
public boolean CheckNotDraft(TextLog log) {
if (state.equals(BugReportState.draft)) {
log.Writeln_("Отчёт об ошибке является черновиком");
@@ -123,11 +124,22 @@ public class BugReport extends rDBObject {
return res;
}
public String getSettingsSummary() {
return
(Global.mainModule.HasAccount() ? (Global.mainModule.getAccount().isAdmin() ? ("Адрес отправителя: " + sender_address + "\n") : "") : "") +
"Версия SAPFOR: " + sapfor_version + "\n" +
"Версия визуализатора: " + visualiser_version + "\n" +
"----------------------------------\n" + getSettingsJson().getSummary();
Vector<String> res = new Vector_<String>(
(Global.mainModule.HasAccount() ? (Global.mainModule.getAccount().isAdmin() ? ("Адрес отправителя: " + sender_address + "\n") : "") : ""),
"Версия SAPFOR: " + sapfor_version,
"Версия визуализатора: " + visualiser_version,
"----------------------------------"
);
if (!project_version.isEmpty()) {
if (visualiser_version < 1134) {
System.out.println("old bug");
res.add(getSettingsJson().getSummary());
} else {
System.out.println("new bug");
res.add(getPropertiesJson().getSummary());
}
}
return String.join("\n", res);
}
public String getPassport() {
return String.join("\n",
@@ -162,43 +174,7 @@ public class BugReport extends rDBObject {
public VisualiserSettingsJson getSettingsJson(){
return packedSettingsJson.isEmpty()? new VisualiserSettingsJson(): Utils_.gson.fromJson(packedSettingsJson,VisualiserSettingsJson.class);
}
/*
public void settingsPatch(){
// System.out.println(getPK());
// if (packedSettingsJson.isEmpty()) {
//System.out.println(sapfor_settings);
//--
VisualiserSettingsJson settings = new VisualiserSettingsJson();
String[] lines = sapfor_settings.split("\n");
for (int i = 1; i < lines.length; ++i) {
String line = lines[i];
if (!line.toLowerCase().contains("настройки")) {
line = line.replace(" :", "=").replace("True","1").replace("False","0").trim();
SettingName settingName = null;
try {
settingName = SettingName.valueOf(line.substring(0, line.indexOf('=')));
} catch (Exception ex) {
System.out.println(line);
public SapforProperties getPropertiesJson(){
return packedSettingsJson.isEmpty()? new SapforProperties(): Utils_.gson.fromJson(packedSettingsJson,SapforProperties.class);
}
if (settingName == null) {
try {
settingName = SettingName.getByDescription(line.substring(0, line.indexOf('=')));
} catch (Exception ex) {
System.out.println(line);
}
}
if (settingName != null) {
String settingValue = line.substring(line.indexOf('=') + 1);
if (!settingName.equals(SettingName.Undefined)) {
VisualiserSettingJson setting = new VisualiserSettingJson();
setting.name = settingName.toString();
setting.value = settingValue;
settings.array.add(setting);
}
}
}
}
packedSettingsJson = Utils_.gson.toJson(settings);
}
*/
}

View File

@@ -7,10 +7,4 @@ public class VisualiserSettingJson {
public String value;
public VisualiserSettingJson(){
}
/*
public VisualiserSettingJson(DBSetting dbSetting){
name = dbSetting.Name.toString();
value = dbSetting.Value;
}
*/
}

View File

@@ -1,4 +1,5 @@
package _VisualDVM.Repository.BugReport.Json;
import _VisualDVM.ProjectData.SapforData.SapforProperties;
import com.google.gson.annotations.Expose;
import java.util.List;
@@ -6,18 +7,16 @@ import java.util.Vector;
public class VisualiserSettingsJson {
@Expose
public List<VisualiserSettingJson> array = new Vector<>();
public String getSummary(){
Vector<String> res=new Vector<>();
/*
for (VisualiserSettingJson setting: array){
public String getSummary() {
SapforProperties properties = new SapforProperties(); //только для извлечения описаний.
Vector<String> res = new Vector<>();
for (VisualiserSettingJson setting : array) {
try {
res.add(SettingName.valueOf(setting.name).getDescription() + "=" + setting.value);
}
catch (Exception ex){
res.add(properties.getFieldDescription(setting.name) + "=" + setting.value);
} catch (Exception ex) {
ex.printStackTrace();
}
}
*/
return String.join("\n",res);
return String.join("\n", res);
}
}

View File

@@ -60,7 +60,7 @@ public class Visualiser extends Component {
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
@Override
public void GetVersionInfo() {
version = 1133;
version = 1134;
String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime());

View File

@@ -156,7 +156,6 @@ public class CallbackForm implements FormWithSplitters, CallbackWindow {
Global.componentsServer.db.bugReports.mountUI(bugReportsPanel);
Global.componentsServer.db.subscribers.mountUI(subscribersPanel);
Global.componentsServer.db.workspaces.mountUI(workspacesPanel);
settingsTools.add(Global.mainModule.getPass(PassCode.ApplyBugReportSettings).createButton());
//-
if (!Global.mainModule.getPass(PassCode.CheckAccount).isDone()) {
accountTools.add(Global.mainModule.getPass(PassCode.CheckAccount).createButton());
@@ -518,7 +517,6 @@ public class CallbackForm implements FormWithSplitters, CallbackWindow {
BugReportComment.ShowBegin();
BugReportCommentAddition.setText(target.commentAdditionDraft);
BugReportSettings.setText(target.getSettingsSummary());
Global.mainModule.setPassesControlsVisible(true, PassCode.ApplyBugReportSettings);
//
if (target.state.equals(BugReportState.draft)) {
ShowDraft();
@@ -559,7 +557,6 @@ public class CallbackForm implements FormWithSplitters, CallbackWindow {
PassCode.SaveBugReportDescription,
PassCode.SaveBugReportComment,
PassCode.AppendBugReportComment,
PassCode.ApplyBugReportSettings,
PassCode.PublishBugReport,
PassCode.OpenBugReport,
PassCode.CloseBugReport,