package Visual_DVM_2021.Passes.All; import Common_old.Current; import _VisualDVM.Global; import Common_old.GlobalProperties; import Common_old.UI.UI; import Visual_DVM_2021.Passes.Pass_2021; import java.lang.reflect.Field; public class UpdateProperty extends Pass_2021 { //todo в дальнейшем, все настройки перевести в properties, и перенести сюда функционал UpdateSetting (?) String name = ""; Field field = null; Object oldValue = null; Object newValue = null; @Override protected boolean canStart(Object... args) throws Exception { name = (String) args[0]; newValue = args[1]; //-- field = GlobalProperties.class.getField(name); oldValue = field.get(Global.properties); //--- return !newValue.equals(oldValue); } @Override protected void body() throws Exception { field.set(Global.properties, newValue); Global.properties.Update(); } @Override protected void showDone() throws Exception { switch (name) { case "collapseCredentials": if ((boolean) newValue) UI.getMainWindow().getTestingWindow().CollapseCredentials(); else UI.getMainWindow().getTestingWindow().ExpandCredentials(); break; case "collapseProjectTrees": if (Current.HasProject()) { if ((boolean) newValue) UI.getMainWindow().getProjectWindow().CollapseProjectTrees(); else UI.getMainWindow().getProjectWindow().ExpandProjectTrees(); } break; case "collapseFileGraphs": if (Current.HasFile()) { if ((boolean) newValue) Current.getFile().form.CollapseGraphs(); else Current.getFile().form.ExpandGraphs(); } break; case "collapseFileMessages": if (Current.HasFile()) { if ((boolean) newValue) Current.getFile().form.CollapseMessages(); else Current.getFile().form.ExpandMessages(); } break; } } }