package Common.Visual.Tables;
import _VisualDVM.Global;
import _VisualDVM.ServerObjectsCache.VisualCaches;
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
import _VisualDVM.TestingSystem.Common.TestingServer;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import Common.Passes.Pass;
import Visual_DVM_2021.Passes.Server.EditServerObject;
public class ConfigurationAutoSwitcher extends DBObjectEditor<Configuration> {
    @Override
    public void Action() {
        value.SwitchAuto();
        setIcon(value.GetAutoIcon());
        ///-
        Pass pass = new EditServerObject<TestingServer,Configuration> (Global.testingServer, Configuration.class){
            @Override
            protected boolean canStart(Object... args) throws Exception {
                target = (Configuration) args[0];
                return true;
            }
            @Override
            public String getDescription() {
                return "Обновить флаг автоматического тестирования";
            }
            @Override
            protected void showDone() throws Exception {
                VisualCaches.RefreshCache(target);
                if (target instanceof SapforConfiguration)
                    Global.testingServer.db.sapforConfigurations.ShowUI(target.id);
            }
        };
        pass.Do(value);
    }
    @Override
    public Object getCellEditorValue() {
        return value;
    }
}
