package _VisualDVM.Passes.Project;
import Common.Passes.Pass;
import _VisualDVM.Global;
import _VisualDVM.ProjectData.Files.DBProjectFile;
public abstract class FilesMassPass<T> extends Pass<T> {
    @Override
    protected boolean canStart(Object... args) throws Exception {
        if (Global.mainModule.getProject().db.files.getSelectedCount() == 0) {
            Log.Writeln_("Не отмечено ни одного файла.");
            return false;
        }
        return true;
    }
    /*
    @Override
    protected boolean needsAnimation() {
        return true;
    }
     */
    @Override
    protected void body() throws Exception {
        Global.mainModule.getProject().db.BeginTransaction();
        for (DBProjectFile file : Global.mainModule.getProject().db.files.getSelectedItems()) {
            ShowMessage1(file.name);
            operation(file);
        }
    }
    @Override
    protected void performFinish() throws Exception {
        Global.mainModule.getProject().db.Commit();
    }
    protected abstract void operation(DBProjectFile file);
    @Override
    protected void showFinish() throws Exception {
        Global.mainModule.getUI().getMainWindow().getProjectWindow().RefreshProjectFiles();
    }
}
