package _VisualDVM.Passes.All; import Common.Passes.Pass; import Common.Utils.Utils_; import Common.Visual.UI; import _VisualDVM.Global; import _VisualDVM.GlobalData.SapforProfile.SapforProfile; import _VisualDVM.Utils; import java.util.Vector; public class SetDefaultSapforProfile extends Pass { @Override protected boolean canStart(Object... args) throws Exception { target = (SapforProfile) args[0]; return UI.Question("Назначить профиль "+ Utils_.Brackets(target.description)+" профилем по умолчанию"); } @Override protected void body() throws Exception { Vector toDrop = new Vector<>(); for (SapforProfile sapforProfile : Global.mainModule.getDb().sapforProfiles.Data.values()) { if (sapforProfile.id!=target.id) { if (sapforProfile.isAuto != 0) { sapforProfile.isAuto = 0; toDrop.add(sapforProfile); } } } for (SapforProfile sapforProfile : toDrop) Global.mainModule.getDb().Update(sapforProfile); //-- target.SwitchAuto(); Global.mainModule.getDb().Update(target); } @Override protected void showFinish() throws Exception { Global.mainModule.getDb().sapforProfiles.getUI().RedrawControl(); } }