package _VisualDVM.Passes.All;
import Common.Passes.Pass;
import _VisualDVM.Global;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import org.apache.commons.io.FileUtils;
public class Save extends Pass<DBProjectFile> {
    @Override
    public String getIconPath() {
        return "/Common/icons/Save.png";
    }
    @Override
    public String getButtonText() {
        return "";
    }
    @Override
    protected boolean canStart(Object... args) {
        if (Global.mainModule.HasFile()) {
            target = Global.mainModule.getFile();
            return (target.NeedsSave);
        }
        return false;
    }
    @Override
    protected void body() throws Exception {
        FileUtils.write(target.file, target.form.getEditor().getText());
        target.NeedsSave = false;
    }
    @Override
    protected void showDone() throws Exception {
        setControlsEnabled(false);
    }
    @Override
    public void Reset() {
        super.Reset();
        setControlsEnabled(true);
    }
}
