package _VisualDVM.Passes.SSH;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Tasks.Supervisor.Remote.RemoteTaskSupervisor;
public abstract class TaskConnectionPass<S extends RemoteTaskSupervisor> extends ConnectionPass {
    public S supervisor; //инициализация идет в конструкторе потомка.
    public TaskConnectionPass(Class<S> s_class) {
        try {
            supervisor = s_class.newInstance();
        } catch (Exception e) {
            Utils_.MainLog.PrintException(e);
        }
    }
    @Override
    protected boolean needsAnimation() {
        return true;
    }
    @Override
    public void Connect() throws Exception {
        machine = supervisor.task.getMachine();
        user = supervisor.task.getUser();
        super.Connect();
        user.connection.CheckUserInitialization(Global.mainModule.getAccount().email);
        /*
        String log = user.connection.CheckModulesVersion();
        if (!log.isEmpty()) {
            throw new PassException("Сборка модулей не выполнена");
        }
         */
    }
    @Override
    protected void ServerAction() throws Exception {
        supervisor.PerformTask();
    }
    @Override
    protected void performFinish() throws Exception {
        supervisor.UpdateTask();
        super.performFinish(); //disconnect
    }
    @Override
    public void Interrupt() throws Exception {
        Global.mainModule.getProject().CreateInterruptFile();
    }
}
