package _VisualDVM.Passes.All;
import Common.Passes.Pass;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.Project.db_project_info;

import javax.swing.*;
public class CloseCurrentProject extends Pass<db_project_info> {
    @Override
    public String getButtonText() {
        return "";
    }
    @Override
    public String getIconPath() {
        return "/Common/icons/Close.png";
    }
    @Override
    public Icon getTabIcon() {
        return Utils_.getIcon("/Common/icons/Close_18.png");
    }
    @Override
    protected boolean canStart(Object... args) throws Exception {
        return (target = Global.mainModule.getProject()) != null;
    }
    @Override
    protected void performPreparation() throws Exception {
        Global.mainModule.getPass(PassCode.CloseCurrentFile).Do();
    }
    @Override
    protected void body() throws Exception {
        target.Close();
        Global.mainModule.getUI().HideSearchForm();
    }
    @Override
    protected void performDone() throws Exception {
        Global.files_multiselection = false;
        //--
        Global.mainModule.getSapfor().ResetAllAnalyses();
        Global.mainModule.getSapfor().cd(Utils_.getHomeDirectory());
        Global.mainModule.DropCurrentProject();
        //-
    }
    @Override
    protected void showDone() throws Exception {
        if (Global.mainModule.getUI().hasMainWindow()) {
            Global.mainModule.getUI().getMainWindow().ShowNoProject();
            Global.mainModule.getUI().getVersionsWindow().ShowNoProjectVariants();
            Global.mainModule.getUI().getVersionsWindow().BlockVariants();
        }
    }
}
