Revert "упорядочил папки с кодом."

This reverts commit 44c6daffa3.
This commit is contained in:
2023-11-19 02:12:44 +03:00
parent 44c6daffa3
commit 28908bcfac
596 changed files with 1569 additions and 2140 deletions

View File

@@ -0,0 +1,74 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants;
import Common.Current;
import Common.UI.UI;
import Common.UI.Windows.Dialog.Text.FileNameForm;
import Common.Utils.Utils;
import ProjectData.Files.DBProjectFile;
import ProjectData.Files.FileType;
import Visual_DVM_2021.Passes.ChangeFilePass;
import org.apache.commons.io.FileUtils;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.nio.file.Paths;
public class AddFile extends ChangeFilePass<DBProjectFile> {
Mode mode;
File src;
@Override
protected boolean canStart(Object... args) throws Exception {
resetArgs();
mode = Mode.Dialog;
src = null;
if (args.length > 0) {
src = (File) args[0];
mode = Mode.Import;
fileName = src.getName();
if (Utils.ContainsCyrillic(fileName)) {
Log.Writeln_("Имя файла " + Utils.Brackets(fileName) + " содержит кириллицу.");
return false;
}
if (Utils.ContainsForbiddenName(fileName)) {
Log.Writeln_("Имя файла " + Utils.Brackets(fileName)
+ " содержит запрещенные символы." +
"\n" + Constants.all_forbidden_characters_string);
return false;
}
} else {
(ff = new FileNameForm()).ShowDialog("Введите имя создаваемого файла");
fileName = ff.Result;
//тут имена фильтруются уже на этапе формы.
}
if (fileName != null) {
//->
parent_node = Current.getProjectCurrentParentNode();
target_dir = (File) parent_node.getUserObject();
//->
dst = Paths.get(target_dir.getAbsolutePath(), fileName).toFile();
if (dst.exists()) {
Log.Writeln_("Файл с именем " + Utils.Brackets(fileName) + " уже существует");
return false;
}
target = new DBProjectFile(dst, project);
if (target.fileType.equals(FileType.forbidden)) {
Log.Writeln_("Расширение " + Utils.Brackets(Utils.getExtension(dst)) + " недопустимо");
return false;
}
return true;
}
return false;
}
@Override
protected void body() throws Exception {
if (mode == Mode.Dialog) Utils.WriteToFile(target.file, "");
else FileUtils.copyFile(src, dst);
project.db.Insert(target);
UI.getMainWindow().getProjectWindow().getFilesTreeForm().getTree().AddNode(parent_node,
dst_node = target.node = new DefaultMutableTreeNode(target)
);
}
enum Mode {
Dialog,
Import
}
}