no message
This commit is contained in:
58
src/_VisualDVM/Passes/All/ApplyBugReportSettings.java
Normal file
58
src/_VisualDVM/Passes/All/ApplyBugReportSettings.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Settings.SettingName;
|
||||
import _VisualDVM.Repository.BugReport.BugReport;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import Common.Passes.Pass;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
public class ApplyBugReportSettings extends Pass<BugReport> {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Apply.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public boolean needsConfirmations() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) {
|
||||
if (Global.mainModule.Check(Log, Current.BugReport)) {
|
||||
target = Global.mainModule.getBugReport();
|
||||
long vv = target.visualiser_version;
|
||||
if (vv < 500) {
|
||||
Log.Writeln_("Автоматическое применение настроек поддерживается только в отчётах об ошибках,\n" +
|
||||
"отправленных с версии визуализатора 500 и выше");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user