Files
VisualSapfor/src/_VisualDVM/Passes/All/CreateEmptyProject.java
2025-01-29 15:20:24 +03:00

47 lines
1.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package _VisualDVM.Passes.All;
import Common.Passes.Pass;
import Common.Passes.PassException;
import Common.Utils.Utils_;
import _VisualDVM.Constants;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Visual.Windows.FileNameForm;
import java.io.File;
import java.nio.file.Paths;
public class CreateEmptyProject extends Pass<File> {
String project_name;
FileNameForm ff = new FileNameForm();
@Override
public String getIconPath() {
return "/icons/CreateProject.png";
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) throws Exception {
project_name = "";
target = null;
if (ff.ShowDialog("Укажите имя создаваемого проекта", "NewProject")) {
project_name = ff.Result;
target = Paths.get(Global.visualiser.getWorkspace().getAbsolutePath(), project_name).toFile();
if (target.exists())
Log.Writeln("Файл\n" + Utils_.Brackets(target.getAbsolutePath()) + "\nуже существует");
return Log.isEmpty();
}
return false;
}
@Override
protected void body() throws Exception {
File data = new File(target, Constants.data);
if (!(target.mkdir() && data.mkdir()))
throw new PassException("Не удалось создать проект.");
}
@Override
protected void performDone() throws Exception {
Global.mainModule.getPass(PassCode.OpenCurrentProject).Do(target);
}
}